/* The dashboard's whole stylesheet.
 *
 * One file, linked by both the deployed page and web/preview/, because it used to be a
 * byte-identical <style> block in each and a rule added to one would simply not exist in
 * the other — which defeats the point of having a preview at all.
 */

      /* Dark is the default, and the brand's own scheme. Light follows the system setting
         until the header's toggle (theme.js) picks one, which is kept as data-theme on
         <html>. The light values are the phone's light scheme (Color.kt), so the two
         read the same; theme.test.mjs holds the two light blocks below identical. */
      :root {
        color-scheme: dark;
        --bg: #091819;
        --surface: #10262A;
        --line: #1C3438;
        --text: #E6E3E5;
        --muted: #B5B0B3;
        --accent: #CE5100;
        --on-accent: #FFFFFF;
        --error: #FFB4AB;
        --badge-bg: rgba(206,81,0,0.22);
        --badge-text: #FF8A45;
        --panel-tint: rgba(255,255,255,0.02);
        /* The consistency ramp, matching HeatStep1..4 in the Android theme so a pale
           cell here and a pale cell on the phone mean the same thing. */
        --heat-0: #10262A;
        --heat-1: #5C2400;
        --heat-2: #963B00;
        --heat-3: #CE5100;
        --heat-4: #FF8A45;
        --heat-empty-outline: #2A4145;
      }
      @media (prefers-color-scheme: light) {
        :root:not([data-theme="dark"]) {
          color-scheme: light;
          --bg: #F6F5F6;
          --surface: #FFFFFF;
          --line: #E4E1E3;
          --text: #091819;
          --muted: #4A4649;
          --accent: #A34000;
          --on-accent: #FFFFFF;
          --error: #B3261E;
          --badge-bg: #FFDBC8;
          --badge-text: #3A1400;
          --panel-tint: rgba(9,24,25,0.03);
          /* HeatStep1Light..4Light: darkening as volume rises, the reverse of dark. */
          --heat-0: #FFFFFF;
          --heat-1: #F0A57A;
          --heat-2: #D9662A;
          --heat-3: #A34000;
          --heat-4: #6B2A00;
          --heat-empty-outline: #D5D1D3;
        }
      }
      :root[data-theme="light"] {
        color-scheme: light;
        --bg: #F6F5F6;
        --surface: #FFFFFF;
        --line: #E4E1E3;
        --text: #091819;
        --muted: #4A4649;
        --accent: #A34000;
        --on-accent: #FFFFFF;
        --error: #B3261E;
        --badge-bg: #FFDBC8;
        --badge-text: #3A1400;
        --panel-tint: rgba(9,24,25,0.03);
        /* HeatStep1Light..4Light: darkening as volume rises, the reverse of dark. */
        --heat-0: #FFFFFF;
        --heat-1: #F0A57A;
        --heat-2: #D9662A;
        --heat-3: #A34000;
        --heat-4: #6B2A00;
        --heat-empty-outline: #D5D1D3;
      }
      * { box-sizing: border-box; }
      body {
        font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
        margin: 0; padding: 24px 16px; background: var(--bg); color: var(--text);
      }
      .container { max-width: 1040px; margin: auto; }
      header { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
      h1 { color: var(--accent); margin: 0 0 4px; font-size: 1.6rem; letter-spacing: 0.5px; }
      h2 { margin: 0; font-size: 1.05rem; }
      .sub { color: var(--muted); font-size: 0.85rem; margin: 2px 0 14px; }
      button {
        font: inherit; padding: 9px 16px; border-radius: 8px; cursor: pointer;
        border: 1px solid var(--accent); background: var(--accent); color: var(--on-accent); font-weight: 600;
      }
      button.ghost { background: transparent; color: var(--accent); }
      /* Deleting an account is the one irreversible thing this page can do, so it looks like
         it: outlined in the error colour rather than the accent every other control uses. */
      button.danger { background: transparent; color: var(--error); border-color: var(--error); }
      #auth-actions, .header-actions { display: flex; gap: 8px; flex-wrap: wrap; }
      #status { margin: 20px 0; color: var(--muted); font-size: 0.9rem; }
      .error { color: var(--error); }
      .empty, .note { color: var(--muted); font-size: 0.85rem; margin: 10px 0 0; }

      /* Links to the disclosures site. Muted and small: it has to be findable, not loud. */
      .site-footer {
        margin-top: 32px; padding-top: 14px; border-top: 1px solid var(--line);
        color: var(--muted); font-size: 0.85rem; display: flex; flex-wrap: wrap; gap: 8px;
      }
      .site-footer a { color: var(--muted); }
      .site-footer a:hover { color: var(--text); }

      .card {
        background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
        padding: 16px 18px; margin-bottom: 14px;
      }

      /* Headline numbers */
      .stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin-bottom: 14px; }
      .stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 14px 16px; }
      .stat-label { color: var(--muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.6px; }
      .stat-value { color: var(--accent); font-size: 1.7rem; font-weight: 600; line-height: 1.3; }
      .stat-note { color: var(--muted); font-size: 0.75rem; }

      /* Per-muscle bars */
      .bars { display: flex; flex-direction: column; gap: 5px; }
      .bar-row { display: grid; grid-template-columns: 110px 1fr 34px; align-items: center; gap: 10px; }
      .bar-name { font-size: 0.82rem; color: var(--muted); }
      .bar-track { background: var(--line); border-radius: 4px; height: 14px; overflow: hidden; display: flex; }
      .bar-fill { background: var(--accent); height: 100%; border-radius: 4px; min-width: 2px; }
      /* Half sets from secondary muscles: the same hue, lighter, after the direct part. */
      .bar-fill.indirect { opacity: 0.4; border-radius: 0 4px 4px 0; }
      /* An untrained muscle is an empty track, not a short bar: absence is not a small
         magnitude, and a hairline would read as "a little". */
      .bar-fill.zero { background: transparent; min-width: 0; }
      .bar-value { font-size: 0.8rem; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

      /* Consistency grid */
      .heat { display: flex; gap: 3px; overflow-x: auto; padding-bottom: 4px; }
      .heat-col { display: flex; flex-direction: column; gap: 3px; }
      .heat-cell { width: 14px; height: 14px; border-radius: 3px; background: var(--heat-0); }
      .heat-cell.s0 { background: transparent; border: 1px solid var(--heat-empty-outline); }
      .heat-cell.s1 { background: var(--heat-1); }
      .heat-cell.s2 { background: var(--heat-2); }
      .heat-cell.s3 { background: var(--heat-3); }
      .heat-cell.s4 { background: var(--heat-4); }

      /* History */
      .sessions { display: flex; flex-direction: column; gap: 8px; }
      .session { border-top: 1px solid var(--line); padding-top: 8px; }
      .session:first-child { border-top: none; padding-top: 0; }
      .session-name { font-weight: 600; font-size: 0.92rem; }
      .session-meta { color: var(--muted); font-size: 0.82rem; margin-top: 2px; }
      .badge {
        display: inline-block; font-size: 0.72rem; padding: 2px 8px; border-radius: 999px;
        background: var(--badge-bg); color: var(--badge-text); margin-left: 8px; vertical-align: middle;
      }

      @media (max-width: 560px) {
        .bar-row { grid-template-columns: 88px 1fr 30px; }
        .bar-name { font-size: 0.76rem; }
      }

      /* --- Drill-downs ------------------------------------------------------------
         A row you can open is a row that has to look like one. Same treatment on the
         muscle bars and the exercise list, so the gesture reads the same in both. */
      .drill {
        background: none; border: none; padding: 0; margin: 0; font: inherit;
        color: inherit; cursor: pointer; text-align: left; width: 100%;
        display: block; border-radius: 6px;
      }
      .drill:hover .bar-name, .drill:hover .ex-name { color: var(--text); }
      .drill:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
      .caret {
        display: inline-block; width: 0.85em; color: var(--muted);
        transition: transform 120ms ease; font-size: 0.7rem;
      }
      .drill[aria-expanded="true"] .caret { transform: rotate(90deg); }

      .panel {
        margin: 6px 0 10px 12px; padding: 10px 12px;
        border-left: 2px solid var(--line); background: var(--panel-tint);
        border-radius: 0 6px 6px 0;
      }
      .panel-empty { color: var(--muted); font-size: 0.82rem; }

      /* Exercise list */
      .ex-row {
        display: grid; grid-template-columns: 1fr 52px 74px 64px;
        align-items: baseline; gap: 8px; padding: 6px 0;
        border-top: 1px solid var(--line);
      }
      .ex-row:first-child { border-top: none; }
      .ex-name { font-size: 0.88rem; color: var(--muted); }
      .ex-sub { font-size: 0.72rem; color: var(--muted); opacity: 0.75; }
      .ex-num {
        font-size: 0.8rem; text-align: right; color: var(--muted);
        font-variant-numeric: tabular-nums;
      }
      .ex-num.lead { color: var(--accent); }

      /* One session of one exercise */
      .drill-session { padding: 5px 0; border-top: 1px solid var(--line); }
      .drill-session:first-child { border-top: none; }
      .drill-date { font-size: 0.78rem; color: var(--muted); }
      .drill-sets { font-size: 0.82rem; font-variant-numeric: tabular-nums; }
      .drill-best { font-size: 0.72rem; color: var(--muted); }

      /* Estimated 1RM over the window. Bars rather than a line: there is one value per
         session, not a continuous signal, and a line between two sessions six weeks
         apart draws a trend nobody measured. */
      .spark { display: flex; align-items: flex-end; gap: 2px; height: 34px; margin: 6px 0 2px; }
      .spark-bar { flex: 1; min-width: 2px; background: var(--heat-2); border-radius: 1px; }
      .spark-bar.best { background: var(--accent); }
      .spark-caption { font-size: 0.72rem; color: var(--muted); }

      @media (max-width: 560px) {
        .ex-row { grid-template-columns: 1fr 40px 62px 56px; gap: 6px; }
        .ex-name { font-size: 0.8rem; }
      }

      /* Coaching: the My training / Clients / Coaches switch, and the lists under it */
      .modes { display: flex; gap: 8px; margin: 0 0 14px; }
      .muted { color: var(--muted); font-size: 0.85rem; }
      .card h2 { margin-bottom: 8px; }
      .card > p { margin: 0 0 10px; }
      .row {
        display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
        padding: 8px 0; border-top: 1px solid var(--line);
      }
      .row > span:first-child, .row > code { flex: 1; }
      .row button { padding: 6px 12px; }
      .card > button { margin-top: 10px; }
      code { font-size: 0.95rem; letter-spacing: 1px; }
      #coach-panel > button { margin-bottom: 14px; }
      .feedback { padding: 8px 0; border-top: 1px solid var(--line); font-size: 0.9rem; }
      .feedback > div { margin-top: 2px; }
      input[type="file"] { color: var(--muted); }
      .row > input:not([type="file"]) {
        flex: 1; min-width: 160px; padding: 7px 10px; font: inherit;
        color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px;
      }

      /* How a workout went, in History and an exercise's drill-down */
      .session-meta.pain { color: var(--error); }
      /* A workout's comments in History: the coach's tinted, your own plain */
      .comments { margin-top: 6px; display: flex; flex-direction: column; gap: 6px; }
      .comment { background: var(--surface); border-left: 3px solid var(--accent); padding: 6px 10px; border-radius: 4px; font-size: 0.9rem; }
      .comment.mine { border-left-color: var(--line); }
      .comment-meta { color: var(--muted); font-size: 0.75rem; }
      .comment-form { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
      .comment-form[hidden] { display: none; }
      .comment-form textarea, .comment-form select {
        font: inherit; color: inherit; background: var(--bg);
        border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
      }
      .comment-form button, .comments > div > button { align-self: flex-start; }
      button.small { padding: 4px 12px; font-size: 0.85rem; }
      /* Messages with a client: theirs tinted on the left, yours plain on the right */
      .messages { display: flex; flex-direction: column; gap: 6px; max-height: 420px; overflow-y: auto; margin-bottom: 8px; }
      .message { background: var(--surface); border-left: 3px solid var(--accent); padding: 6px 10px; border-radius: 4px; font-size: 0.9rem; max-width: 85%; align-self: flex-start; white-space: pre-wrap; }
      .message.mine { border-left-color: var(--line); align-self: flex-end; }
      .message > .muted { font-size: 0.75rem; white-space: normal; }
      .card > textarea {
        width: 100%; box-sizing: border-box; font: inherit; color: inherit; background: var(--bg);
        border: 1px solid var(--line); border-radius: 6px; padding: 6px 8px;
      }
      .drill-note { font-size: 0.78rem; color: var(--text); font-style: italic; margin-top: 2px; }

      /* Body check-ins and a client's programs */
      .check-in, .program-row { padding: 7px 0; border-top: 1px solid var(--line); }
      .check-in:first-child { border-top: none; }
      .check-in-date { font-size: 0.8rem; color: var(--accent); }
      .check-in-figures { font-size: 0.9rem; font-variant-numeric: tabular-nums; }
      .check-in-note { font-size: 0.8rem; color: var(--muted); font-style: italic; }
      .check-in-more { font-size: 0.82rem; color: var(--muted); }
      .program-name { font-size: 0.95rem; }
      .program-meta { font-size: 0.78rem; color: var(--muted); }
      .program-row.archived .program-name { color: var(--muted); }

      /* A program printed for a client: only the sheet goes to paper */
      #print-area { display: none; }
      @media print {
        body > *:not(#print-area) { display: none !important; }
        body { background: #fff; color: #000; }
        #print-area { display: block; }
        .print-sheet { font: 11pt/1.35 system-ui, sans-serif; color: #000; }
        .print-sheet h1 { font-size: 18pt; margin: 0 0 2pt; color: #000; }
        .print-sheet h2 { font-size: 13pt; margin: 14pt 0 4pt; border-bottom: 1px solid #000; }
        .print-sheet h3 { font-size: 10pt; margin: 6pt 0 2pt; text-transform: uppercase; letter-spacing: 0.5pt; }
        .print-meta { color: #444; margin: 0 0 8pt; }
        .print-day { break-inside: avoid; }
        .print-sheet table { width: 100%; border-collapse: collapse; table-layout: fixed; }
        .print-sheet th, .print-sheet td { border: 1px solid #999; padding: 3pt 5pt; text-align: left; vertical-align: top; }
        .print-sheet th { font-size: 9pt; background: #eee; }
        .print-sheet th:nth-child(1) { width: 28%; }
        .print-sheet th:nth-child(2) { width: 28%; }
        .print-sheet th:nth-child(4) { width: 16%; }
        .print-group { font-size: 8.5pt; color: #444; }
      }
      .row > select { flex: 1; min-width: 160px; padding: 7px 10px; font: inherit; color: inherit; background: var(--bg); border: 1px solid var(--line); border-radius: 6px; }
