/* Tokens follow fonte-ios-app/DESIGN.md. Light appearance overrides are below. */

@font-face {
  font-family: "Instrument Sans";
  font-weight: 500;
  font-display: swap;
  src: url("/static/InstrumentSans-Medium.ttf") format("truetype");
}
@font-face {
  font-family: "Instrument Sans";
  font-weight: 600;
  font-display: swap;
  src: url("/static/InstrumentSans-SemiBold.ttf") format("truetype");
}

:root {
  --ground: #0B1030;
  --surface: #141A3C;
  --surface-2: #1C2350;
  --accent: #2B4EFF;
  --accent-text: #8FA3FF;
  --accent-soft: #1F2A66;
  --live: #27C8FF;
  --ink: #F4F3EE;
  --ink-2: #A0A6B4;
  --ink-3: #9CA3B3;
  --control-border: #7F8797;
  --border: rgba(244, 243, 238, 0.10);
  --error: #FF6B81;
  --warmup: #F5B453;
  --drop: #B5A6F5;
  --failure: #F08C9B;
  --superset: #8B5CF6;
  --danger: #D8465B;
  --on-accent: #FFFFFF;

  --radius-field: 8px;
  --radius-card: 16px;
  --radius-pill: 999px;

  --gutter: 20px;
  --card: 16px;
  --section: 22px;

  --font: "Instrument Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { background: var(--ground); color: var(--ink); }

body {
  margin: 0;
  font-family: var(--font);
  font-weight: 500;
  font-size: 16px;
  line-height: 1.45;
  background:
    radial-gradient(ellipse 70% 45% at 50% -8%, rgba(43, 78, 255, 0.55), transparent 70%),
    var(--ground);
  background-repeat: no-repeat;
  min-height: 100vh;
}

a { color: var(--accent-text); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Shell: the bloom sits behind the header and fades before content begins. */
.shell {
  max-width: 760px;
  margin: 0 auto;
  padding: 0 var(--gutter) 64px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 0;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--ink);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.04em;
}
.wordmark:hover { text-decoration: none; }
/* The brand mark is inlined SVG (squatter-plate.svg): a 100-unit plate in a 120-unit box, so a
   32 px plate is a 38.4 px box; the negative margin keeps the row's height at the text. */
.plate {
  width: 38.4px;
  height: 38.4px;
  margin: -6px 0;
  display: inline-block;
  color: var(--ink);
  flex: none;
}

.nav { display: flex; gap: 18px; font-size: 14px; }
.nav a { color: var(--ink-2); }
.nav a[aria-current="page"] { color: var(--ink); }

h1 {
  font-weight: 600;
  font-size: 34px;
  letter-spacing: -0.04em;
  line-height: 1.1;
  margin: 28px 0 6px;
  font-variant-numeric: tabular-nums;
}
.lede { color: var(--ink-2); margin: 0 0 var(--section); }
h2 {
  font-weight: 600;
  font-size: 17px;
  margin: var(--section) 0 10px;
}
.meta { color: var(--ink-2); font-size: 14px; }
.hint { color: var(--ink-3); font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* Cards and lists. */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  padding: var(--card);
  margin-bottom: 12px;
}
a.card { display: block; color: var(--ink); }
a.card:hover { text-decoration: none; background: var(--surface-2); }
.card-title { font-weight: 600; font-size: 17px; margin: 0 0 4px; }
.row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; }

.stats {
  display: flex;
  gap: 28px;
  margin: 8px 0 var(--section);
}
.stats .value {
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
}
.stats .label { color: var(--ink-3); font-size: 13px; }

/* Set tables: dense, dividers only. SET and the result column heads are the one allowed
   uppercase exception. */
table.sets {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  margin-top: 8px;
}
table.sets th {
  text-align: left;
  font-size: 12px;
  font-weight: 500;
  color: var(--ink-3);
  padding: 4px 4px;
  border-bottom: 1px solid var(--border);
}
table.sets td {
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
table.sets tr:last-child td { border-bottom: 0; }
table.sets .n { width: 72px; color: var(--ink-2); white-space: nowrap; }
table.sets .kind { color: var(--ink-3); font-size: 13px; margin-left: 4px; }
.kind-warmup { color: var(--warmup); }
.kind-drop { color: var(--drop); }
.kind-failure { color: var(--failure); }
.skipped { color: var(--ink-3); }
/* Superset label: the hue marks it, the text stays in ink-3 for AA contrast on surface. */
.superset { color: var(--ink-3); font-size: 13px; margin: 0 0 4px; }
.superset-mark {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--superset);
  margin-right: 6px;
  vertical-align: middle;
}
.flush { margin: 0; }

/* Forms and buttons. */
label { display: block; font-size: 14px; color: var(--ink-2); margin-bottom: 6px; }
input[type="email"], input[type="file"], textarea {
  width: 100%;
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-field);
  padding: 12px 10px;
  min-height: 44px;
}
input[type="email"]:focus, input[type="file"]:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
textarea { resize: vertical; min-height: 240px; }
input[type="file"]::file-selector-button {
  font: inherit;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-field);
  padding: 8px 10px;
  min-height: 44px;
  margin-right: 10px;
}
select {
  font: inherit;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--control-border);
  border-radius: var(--radius-field);
  padding: 10px;
  min-height: 44px;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 16px;
  border-radius: var(--radius-card);
  border: 0;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  background: var(--accent);
  color: var(--on-accent);
}
.button:hover { filter: brightness(0.92); }
.button.secondary {
  background: var(--surface-2);
  color: var(--ink);
  border: 1px solid var(--border);
}
.button.text {
  background: none;
  color: var(--accent-text);
  min-height: 44px;
  padding: 0;
}
.button.danger { background: var(--danger); color: var(--on-accent); }
.danger-text { color: var(--error); }
.stack > * + * { margin-top: 14px; }
.error { color: var(--error); font-size: 14px; }
.notice { color: var(--ink-2); font-size: 14px; }

.pager {
  display: flex;
  justify-content: space-between;
  margin-top: var(--section);
  font-size: 14px;
}

.empty {
  text-align: center;
  padding: 48px var(--card);
  color: var(--ink-2);
}
.empty p:first-child { color: var(--ink); font-weight: 600; font-size: 17px; }

.signin { max-width: 420px; margin: 48px auto 0; }

dl.facts { margin: 0; }
dl.facts div { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); }
dl.facts div:last-child { border-bottom: 0; }
dl.facts dt { color: var(--ink-2); }
dl.facts dd { margin: 0; text-align: right; }

@media (max-width: 480px) {
  h1 { font-size: 28px; }
  .stats { gap: 18px; }
}

.exercise-heading { display: flex; align-items: center; gap: 12px; min-width: 0; }
.exercise-icon { width: 40px; height: 40px; flex: 0 0 40px; border-radius: 8px; background: #fff; object-fit: contain; color: #5D6470; }
.exercise-heading .card-title { margin: 0; overflow-wrap: anywhere; }

.body-map { display: block; width: 160px; max-width: 100%; height: auto; }
.muscle-card { display: flex; gap: 22px; align-items: center; }
.muscle-card h2 { font-size: 17px; }
.history-map { float: right; margin-left: 12px; }
.history-map .body-map { width: 64px; }
@media (max-width: 430px) { .muscle-card { align-items: start; } .muscle-card .body-map { width: 96px; } }

@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --ground: #F3F5FB; --surface: #FFFFFF; --surface-2: #E9EDF7;
    --accent-text: #2B4EFF; --accent-soft: #E6EAFF; --live: #0B8FC2;
    --ink: #12151B; --ink-2: #5D6470; --ink-3: #626975;
    --control-border: #747C8A; --border: rgba(18, 21, 27, 0.10);
    --error: #B4233D; --warmup: #A34A00; --drop: #6D4FD8; --failure: #C43A4E;
  }
  body { background: radial-gradient(ellipse 70% 240px at 50% -8%, rgba(43, 78, 255, 0.18), transparent 70%), var(--ground); }
}
.muscle-card > div:first-child { flex: 0 0 160px; }
@media (max-width: 430px) { .muscle-card > div:first-child { flex-basis: 96px; } }

/* Library rows share the phone's type and white-backed artwork. */
.library-search { margin: 22px 0; }
.search-row { display: flex; gap: 12px; align-items: end; }
.search-row > div { flex: 1; min-width: 0; }
input[type="search"] { width: 100%; min-height: 48px; font: inherit; padding: 10px; color: var(--ink); background: var(--surface); border: 1px solid var(--control-border); border-radius: 8px; }
input[type="search"]:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.library-filters summary { cursor: pointer; min-height: 44px; padding: 10px 0; color: var(--accent-text); }
.filter-fields { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }
.filter-fields > div { flex: 1 1 180px; min-width: 0; }
.filter-fields select { width: 100%; max-width: 100%; }
.clear-filters { display: inline-flex; align-items: center; min-height: 48px; }
.library-name-sections { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; align-items: start; }
.library-name-sections .exercise-grid { grid-template-columns: minmax(0,1fr); }
.library-sections h2 { font-size: 1rem; }
.exercise-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }
a.library-exercise { display: flex; gap: 12px; align-items: center; margin: 0; min-height: 80px; }
.library-exercise > div { min-width: 0; }
.library-exercise .card-title { font-size: 16px; }
.exercise-detail-heading { display: flex; gap: 16px; align-items: center; margin: 28px 0 22px; }
.exercise-detail-heading .exercise-icon { width: 96px; height: 96px; flex-basis: 96px; }
.exercise-detail-heading h1 { margin-top: 0; }
.exercise-detail-heading .lede { margin: 8px 0 0; }
.exercise-detail-grid { display: grid; grid-template-columns: minmax(0,1fr); gap: 12px; }
.exercise-detail-grid h2, .guidance h2 { margin-top: 0; }
.exercise-muscles .body-map { width: 160px; margin: 0 auto; }
.muscle-key { display: inline-block; width: 12px; height: 12px; margin-right: 4px; border-radius: 50%; }
.muscle-key.primary { background: #2B4EFF; }
.muscle-key.secondary { background: #89A9FF; }
.strava-identities { padding-left: 20px; }
h3 { font-size: 16px; }
h1, h2, h3, p, dd, li, .meta { overflow-wrap: anywhere; }
dl.facts > div { flex-wrap: wrap; }
dl.facts dd { min-width: 0; max-width: 100%; }
.pager a, .guidance a, .exercise-heading a, .meta > a, .nav a { display: inline-flex; align-items: center; min-height: 44px; }
.stats { flex-wrap: wrap; gap: 18px 28px; }
.stats > div { flex: 0 1 auto; }
.topbar { flex-wrap: wrap; gap: 8px 16px; }
.nav { flex-wrap: wrap; }
@media (min-width: 600px) {
  .exercise-grid, .library-name-sections { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .library-name-sections .exercise-grid { grid-template-columns: minmax(0,1fr); }
  .exercise-detail-grid { grid-template-columns: minmax(0,1fr) minmax(0,2fr); }
}
@media (min-width: 1100px) {
  .shell { max-width: 1120px; }
  .exercise-grid, .library-name-sections { grid-template-columns: repeat(3,minmax(0,1fr)); }
}
@media (max-width: 430px) {
  .topbar { align-items: start; }
  .nav { gap: 14px; }
  .exercise-detail-heading { align-items: start; }
  .exercise-detail-heading h1 { font-size: 26px; }
  .stats .value { white-space: nowrap; }
  dl.facts > div { display: block; }
  dl.facts dd { text-align: left; margin-top: 4px; }
}
