  :root {
    --ground: #F6F7F9;
    --surface: #FFFFFF;
    --surface-2: #F1F4F8;
    --ink: #12161C;
    --ink-2: #4A5361;
    --muted: #5B6472;
    --line: #E3E7ED;
    --line-2: #D5DBE4;
    --blue: #1F5FD1;
    --blue-ink: #1A4FAF;
    --blue-soft: #EAF0FB;
    --orange: #C2410C;
    --orange-ink: #B23A0A;
    --orange-soft: #FBEDE6;
    --display: 'Space Grotesk', Inter, system-ui, sans-serif;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; }
  body {
    background: #E9ECF1;
    color: var(--ink);
    font-family: Inter, system-ui, -apple-system, sans-serif;
    -webkit-font-smoothing: antialiased;
  }
  button, input, select { font-family: inherit; }
  [hidden] { display: none !important; }
  .sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

  .app {
    max-width: 480px; margin: 0 auto; height: 100vh; height: 100dvh;
    display: flex; flex-direction: column; background: var(--ground); overflow: hidden;
  }
  .view { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
  .boot { margin: auto; padding: 24px; text-align: center; color: var(--ink-2); font-size: 15px; line-height: 1.5; }
  .boot.error { color: var(--orange-ink); }

  /* header */
  .top { display: flex; flex-direction: column; gap: 14px; padding: 20px 20px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
  .top-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
  .titles { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .eyebrow { font-size: 12px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); }
  h1 { margin: 0; font-family: var(--display); font-size: 24px; font-weight: 700; line-height: 1.15; }
  h2 { margin: 0; font-size: 15px; font-weight: 700; }
  .muted { font-size: 13px; color: var(--muted); }
  .muted-sm { font-size: 12px; color: var(--muted); }

  .class-pick select {
    height: 44px; max-width: 170px; padding: 0 34px 0 14px; border-radius: 12px; border: 1px solid var(--line-2);
    background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2312161C' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat right 12px center;
    color: var(--ink); font-size: 14px; font-weight: 600; appearance: none; -webkit-appearance: none; cursor: pointer;
    text-overflow: ellipsis;
  }

  .session-nav { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px; border-radius: 14px; background: var(--surface-2); }
  .icon-btn { display: flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; border: none; background: var(--surface); color: var(--ink); cursor: pointer; }
  .icon-btn:disabled { color: #AEB7C4; cursor: default; }
  .session-label { display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
  .session-date { font-size: 16px; font-weight: 700; }

  .stat-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border-radius: 12px; }
  .stat-num { font-family: var(--display); font-size: 22px; font-weight: 700; }
  .stat-label { font-size: 12px; font-weight: 500; }
  .stat-p { background: var(--blue-soft); } .stat-p .stat-num { color: var(--blue); } .stat-p .stat-label { color: #33405A; }
  .stat-a { background: var(--orange-soft); } .stat-a .stat-num { color: var(--orange-ink); } .stat-a .stat-label { color: #5A3A2C; }
  .stat-n { background: var(--surface-2); } .stat-n .stat-label { color: var(--ink-2); }

  /* lists */
  .list-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 20px 4px; }
  .list-count { font-size: 13px; font-weight: 600; color: var(--ink-2); }
  .text-btn { height: 44px; padding: 0 4px; border: none; background: transparent; color: var(--blue); font-size: 14px; font-weight: 600; cursor: pointer; }
  .list { flex: 1 1 auto; min-height: 0; margin: 0; padding: 4px 16px 12px; list-style: none; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  #member-list { padding-top: 12px; }
  .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 8px 8px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
  .row-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
  .row-name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }
  .toggles { display: flex; gap: 6px; flex-shrink: 0; }
  .mark { min-width: 52px; height: 44px; padding: 0 12px; border-radius: 10px; font-size: 15px; font-weight: 700; cursor: pointer; border: 1.5px solid; background: var(--surface); }
  .mark-p { color: var(--blue); border-color: #C9D3E3; }
  .mark-a { color: var(--orange-ink); border-color: #E6CFC4; }
  .mark-p[aria-pressed="true"] { background: var(--blue); border-color: var(--blue); color: #fff; }
  .mark-a[aria-pressed="true"] { background: var(--orange); border-color: var(--orange); color: #fff; }
  .empty { padding: 24px 8px; text-align: center; color: var(--muted); font-size: 14px; }

  .save-bar { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px; background: var(--surface); border-top: 1px solid var(--line); }
  .primary-btn { height: 52px; border-radius: 14px; border: none; background: var(--blue); color: #fff; font-size: 16px; font-weight: 700; cursor: pointer; }
  .primary-btn:disabled { background: #8FA9D9; cursor: default; }
  .banner { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; line-height: 1.4; }
  .banner.ok { background: var(--blue-soft); color: var(--blue-ink); }
  .banner.err { background: var(--orange-soft); color: var(--orange-ink); }

  /* members */
  .search { display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 14px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--surface); color: var(--muted); }
  .search input { flex: 1 1 auto; min-width: 0; height: 40px; border: none; outline: none; background: transparent; color: var(--ink); font-size: 16px; }
  .segmented { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; padding: 4px; border-radius: 12px; background: var(--surface-2); }
  .segmented button { height: 40px; border-radius: 9px; border: none; background: transparent; color: var(--ink-2); font-size: 14px; font-weight: 600; cursor: pointer; }
  .segmented button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(18,22,28,.12); }
  .member { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
  .avatar { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 40px; height: 40px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-ink); font-size: 14px; font-weight: 700; }
  .member-body { display: flex; flex-direction: column; gap: 6px; flex: 1 1 auto; min-width: 0; }
  .member-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .pct { font-family: var(--display); font-size: 16px; font-weight: 700; color: var(--blue); }
  .pct.low { color: var(--orange-ink); }
  .pct.none { color: var(--muted); }
  .bar { height: 6px; border-radius: 3px; background: #E8ECF2; overflow: hidden; }
  .bar > div { height: 6px; border-radius: 3px; background: var(--blue); }
  .bar > div.low { background: var(--orange); }

  /* dashboard */
  .dash { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 12px; padding: 16px; overflow-y: auto; }
  .card { border-radius: 14px; background: var(--surface); border: 1px solid var(--line); }
  .kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { display: flex; flex-direction: column; gap: 4px; padding: 14px; }
  .kpi-label { font-size: 12px; font-weight: 600; color: var(--ink-2); }
  .kpi-num { font-family: var(--display); font-size: 30px; font-weight: 700; line-height: 1; color: var(--ink); }
  .kpi-num.blue { color: var(--blue); }
  .kpi-num.orange { color: var(--orange-ink); }
  .chart-card { display: flex; flex-direction: column; gap: 14px; padding: 16px; }
  .card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
  .chart-scroll { overflow-x: auto; }
  .chart { display: flex; gap: 10px; align-items: flex-end; min-width: 100%; }
  .chart-col { flex: 1 0 44px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
  .chart-plot { width: 100%; height: 150px; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
  .chart-val { font-size: 12px; font-weight: 700; color: #33405A; }
  .chart-val.low { color: var(--orange-ink); }
  .chart-bar { width: 100%; border-radius: 8px 8px 2px 2px; background: var(--blue); }
  .chart-bar.low { background: var(--orange); }
  .chart-bar.next { height: 24px; background: transparent; border: 1.5px dashed #AEB7C4; }
  .chart-date { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
  .insights h2 { padding: 14px 16px 6px; }
  .insight { display: flex; gap: 12px; padding: 12px 16px; border-top: 1px solid #EEF1F5; }
  .insight svg { flex-shrink: 0; margin-top: 1px; }
  .insight-body { display: flex; flex-direction: column; gap: 2px; }
  .insight-title { font-size: 14px; font-weight: 600; }
  .insight-sub { font-size: 13px; color: var(--muted); }

  /* tab bar */
  .tabbar { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 6px 8px calc(14px + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-top: 1px solid var(--line); }
  .tabbar button { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; min-height: 48px; border: none; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; }
  .tabbar button[aria-current="page"] { color: var(--blue); font-weight: 700; }

  button:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid #8FB3F0; outline-offset: 2px; }

/* retry + banner actions */
.boot .retry { margin-top: 16px; padding: 0 24px; }
.banner { justify-content: space-between; }
.banner-btn { flex-shrink: 0; height: 36px; padding: 0 14px; border-radius: 8px; border: 1.5px solid currentColor; background: transparent; color: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
