/* Link Plus Web — clean neutral theme. Tokens first; light default, dark via OS or
   [data-theme]. Mobile-first: bottom tab bar; >= 56rem: left sidebar. */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --ink: #14171c;
  --ink-2: #3b414b;
  --muted: #6b7280;
  --line: #e4e7ec;
  --line-2: #d5d9e0;
  --accent: #3a5bdc;
  --accent-ink: #ffffff;
  --accent-soft: #eaeffd;
  --ok: #17803d;   --ok-soft: #e6f4ea;
  --warn: #b45309; --warn-soft: #fdf3e2;
  --bad: #c62828;  --bad-soft: #fdeaea;
  --info: #5b5fc7; --info-soft: #eeeefb;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 1px 3px rgba(16, 24, 40, .06);
  --shadow-lg: 0 8px 24px rgba(16, 24, 40, .10);

  --r-sm: 8px; --r: 12px; --r-lg: 16px;
  --s1: .25rem; --s2: .5rem; --s3: .75rem; --s4: 1rem; --s5: 1.5rem; --s6: 2rem;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Code", Consolas, monospace;
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --ink: #e9ebef; --ink-2: #c3c8d1;
    --muted: #8b93a1; --line: #262b34; --line-2: #333945;
    --accent: #7b96ff; --accent-ink: #0f1115; --accent-soft: #1f2741;
    --ok: #4cc47a; --ok-soft: #15291e; --warn: #f0a648; --warn-soft: #2e2415;
    --bad: #ff7369; --bad-soft: #321a1a; --info: #a3a6ff; --info-soft: #23243d;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 8px 24px rgba(0, 0, 0, .45);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1115; --surface: #171a20; --surface-2: #1e222a; --ink: #e9ebef; --ink-2: #c3c8d1;
  --muted: #8b93a1; --line: #262b34; --line-2: #333945;
  --accent: #7b96ff; --accent-ink: #0f1115; --accent-soft: #1f2741;
  --ok: #4cc47a; --ok-soft: #15291e; --warn: #f0a648; --warn-soft: #2e2415;
  --bad: #ff7369; --bad-soft: #321a1a; --info: #a3a6ff; --info-soft: #23243d;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3); --shadow-lg: 0 8px 24px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

/* --- Base ------------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh;
  background: var(--bg); color: var(--ink);
  font: 400 15px/1.5 var(--sans); font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; letter-spacing: -.015em; }
h1 { font-size: 1.5rem; font-weight: 700; }
h2 { font-size: 1rem; font-weight: 600; }
p { margin: 0; }
a { color: var(--accent); text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.mono, .code { font-family: var(--mono); }
.ic { width: 20px; height: 20px; flex: none; }
.ic-end { margin-left: auto; color: var(--muted); }

/* --- App shell ------------------------------------------------------------- */
.view {
  width: 100%; max-width: 44rem; margin: 0 auto; outline: none;
  padding: calc(var(--s5) + env(safe-area-inset-top, 0px)) var(--s4) calc(var(--tab-h) + var(--safe-b) + var(--s6));
  display: flex; flex-direction: column; gap: var(--s4);
}
.sidebar { display: none; }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: end;
  height: calc(var(--tab-h) + var(--safe-b)); padding-bottom: var(--safe-b);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--tab-h); color: var(--muted); font-size: .7rem; font-weight: 500;
  touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
.tabbar a .ic { width: 22px; height: 22px; }
.tabbar a.is-active { color: var(--accent); }
.tabbar a.nav-scan .ic {
  width: 56px; height: 56px; padding: 15px; margin-top: -22px; border-radius: 50%;
  background: var(--accent); color: var(--accent-ink); box-shadow: var(--shadow-lg);
  border: 4px solid var(--bg);
}
.tabbar a.nav-scan { color: var(--ink-2); }
.tabbar a.nav-scan.is-active { color: var(--accent); }

body.is-auth .tabbar, body.is-auth .sidebar { display: none !important; }
body.is-auth .view { padding-bottom: var(--s6); max-width: 26rem; min-height: 100dvh; justify-content: center; }

@media (min-width: 56rem) {
  .tabbar { display: none; }
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: 15rem; z-index: 10;
    display: flex; flex-direction: column; gap: var(--s4);
    padding: var(--s5) var(--s3); background: var(--surface); border-right: 1px solid var(--line);
  }
  body:not(.is-auth) { padding-left: 15rem; }
  .view { max-width: 72rem; padding: var(--s6); gap: var(--s5); }
  body.is-auth .view { padding: var(--s6) var(--s4); }
  .only-mobile { display: none !important; }
}
.side-brand { display: flex; align-items: center; gap: var(--s3); padding: 0 var(--s2) var(--s3); color: var(--ink); font-weight: 650; }
.side-brand em { font-style: normal; color: var(--muted); font-weight: 500; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav a, .side-logout {
  display: flex; align-items: center; gap: var(--s3); padding: .6rem var(--s3);
  border-radius: var(--r-sm); color: var(--ink-2); font-weight: 500; font-size: .92rem;
}
.side-nav a:hover, .side-logout:hover { background: var(--surface-2); }
.side-nav a.is-active { background: var(--accent-soft); color: var(--accent); }
.side-logout { margin-top: auto; border: 0; background: none; cursor: pointer; color: var(--bad); text-align: left; }

.mark {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-weight: 700; font-size: .95rem; letter-spacing: -.03em;
  background: var(--accent); color: var(--accent-ink);
}

/* --- Page head ------------------------------------------------------------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--s3); }
.page-sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; flex: none;
  border-radius: 50%; border: 1px solid var(--line); background: var(--surface);
  color: var(--ink-2); cursor: pointer; touch-action: manipulation;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn .ic { width: 18px; height: 18px; }

/* --- Cards ----------------------------------------------------------------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: var(--s4); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: var(--s3); min-width: 0;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.card-head .muted { font-weight: 500; margin-left: .3rem; }
.card-note { color: var(--muted); font-size: .85rem; }
.link { font-size: .85rem; font-weight: 600; }

/* --- Buttons & forms ------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: 44px; padding: .6rem 1rem; border-radius: var(--r);
  border: 1px solid transparent; font-weight: 600; font-size: .92rem; cursor: pointer;
  touch-action: manipulation; transition: background .15s, border-color .15s, opacity .15s;
}
.btn .ic { width: 18px; height: 18px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:not(:disabled):hover { filter: brightness(1.06); }
.btn-ghost { background: var(--surface); border-color: var(--line-2); color: var(--ink); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-danger { background: var(--bad-soft); color: var(--bad); }
.btn-sm { min-height: 36px; padding: .4rem .8rem; font-size: .85rem; align-self: flex-start; }
.btn-block { width: 100%; }
.row { display: flex; gap: var(--s2); flex-wrap: wrap; }

.form { display: flex; flex-direction: column; gap: var(--s4); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.field input {
  font: inherit; font-size: 1rem; color: var(--ink); width: 100%;
  min-height: 46px; padding: .65rem .8rem; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line-2);
}
.field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.pw { position: relative; }
.pw input { padding-right: 4.2rem; }
.pw-toggle {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
  border: 0; background: none; color: var(--muted); font-size: .8rem; font-weight: 600;
  padding: .45rem .6rem; cursor: pointer; border-radius: var(--r-sm);
}
.msg { font-size: .88rem; min-height: 1.3em; color: var(--muted); }
.msg.err { color: var(--bad); }
.msg.ok { color: var(--ok); }

/* --- Login ----------------------------------------------------------------- */
.auth { display: flex; flex-direction: column; gap: var(--s5); }
.auth-brand { display: flex; flex-direction: column; align-items: center; gap: var(--s2); text-align: center; }
.auth-brand .mark { width: 56px; height: 56px; border-radius: 16px; font-size: 1.3rem; margin-bottom: var(--s2); }
.auth-brand h1 span { color: var(--muted); font-weight: 500; }
.auth-brand p { color: var(--muted); text-wrap: balance; }
.auth-card { padding: var(--s5); gap: var(--s4); }
.auth-card h2 { font-size: 1.15rem; }
.auth-note { color: var(--muted); font-size: .78rem; text-align: center; }

/* --- States ---------------------------------------------------------------- */
.skel-group { display: flex; flex-direction: column; gap: 10px; padding: 2px 0; }
.skel {
  height: 14px; border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--line) 50%, var(--surface-2) 75%);
  background-size: 200% 100%; animation: shimmer 1.3s infinite linear;
}
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) { .skel { animation: none; } }
.empty { color: var(--muted); font-size: .9rem; padding: var(--s2) 0; }
.error-box {
  display: flex; flex-direction: column; gap: var(--s2);
  padding: var(--s3); border-radius: var(--r); background: var(--bad-soft); color: var(--bad); font-size: .9rem;
}
.error-box details { color: var(--ink-2); font-size: .8rem; }
.error-box summary { cursor: pointer; }
.code {
  margin: 0; padding: var(--s3); border-radius: var(--r-sm); background: var(--surface-2);
  border: 1px solid var(--line); font-size: .76rem; color: var(--ink-2);
  white-space: pre-wrap; overflow-wrap: anywhere; max-height: 20rem; overflow: auto;
}
.code.err { color: var(--bad); }

.kv { display: grid; grid-template-columns: auto 1fr; gap: .45rem var(--s4); margin: 0; font-size: .9rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

.badge {
  display: inline-flex; align-items: center; padding: 1px 8px; border-radius: 99px;
  font-size: .7rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2);
  letter-spacing: .01em; vertical-align: middle;
}
.badge-accent { background: var(--accent); color: var(--accent-ink); }
.chip { padding: 1px 8px; border-radius: 6px; font-size: .72rem; font-weight: 600; background: var(--surface-2); color: var(--ink-2); }
.chip-L { background: var(--accent-soft); color: var(--accent); }
.chip-B { background: var(--ok-soft); color: var(--ok); }
.chip-T { background: var(--warn-soft); color: var(--warn); }
.chip-W { background: var(--info-soft); color: var(--info); }
span.code { font-family: var(--mono); font-size: .82rem; font-weight: 600; color: var(--ink); background: none; border: 0; padding: 0; }

.tone-ok { color: var(--ok); } .tone-warn { color: var(--warn); } .tone-bad { color: var(--bad); }
.bg-ok { background: var(--ok); } .bg-warn { background: var(--warn); } .bg-bad { background: var(--bad); } .bg- { background: var(--muted); }

/* --- Dashboard ------------------------------------------------------------- */
.dash { display: flex; flex-direction: column; gap: var(--s4); }
.hero { position: relative; padding-right: 48px; min-height: 48px; }
.hero h1 { font-size: 1.65rem; }
.hero-sub { color: var(--muted); margin-top: 2px; }
.hero-week { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); margin-top: var(--s3); font-size: .88rem; color: var(--ink-2); }
.week-pill { padding: 3px 10px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: .8rem; }
.hero-refresh { position: absolute; top: 0; right: 0; }

.scan-cta {
  display: flex; align-items: center; gap: var(--s3); padding: var(--s4);
  border-radius: var(--r-lg); background: var(--accent); color: var(--accent-ink);
  box-shadow: var(--shadow-lg); touch-action: manipulation;
}
.scan-cta b { display: block; font-size: 1rem; }
.scan-cta small { opacity: .85; font-size: .82rem; }
.scan-cta .ic-end { color: inherit; opacity: .8; }
.scan-cta-ic { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 12px; background: rgba(255, 255, 255, .18); }
.scan-cta-ic .ic { width: 24px; height: 24px; }

.dash-grid, .dash-side { display: flex; flex-direction: column; gap: var(--s4); }
@media (min-width: 44rem) {
  .dash-grid { display: grid; grid-template-columns: 1fr 1fr; align-items: start; }
}

/* Class list (dashboard + timetable) */
.class-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.class {
  display: flex; gap: var(--s3); padding: var(--s3); border-radius: var(--r);
  background: var(--surface-2); border: 1px solid transparent; position: relative;
}
.class.is-now { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 35%, transparent); }
.class.is-next { border-color: var(--line-2); background: var(--surface); }
.class.is-done { opacity: .55; }
.class-time {
  flex: none; width: 4.6rem; display: flex; flex-direction: column;
  font-size: .78rem; font-variant-numeric: tabular-nums; color: var(--muted); line-height: 1.35;
}
.class-time span:first-child { color: var(--ink); font-weight: 600; }
.class-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 2px; }
.class-title { display: flex; align-items: center; gap: var(--s2); flex-wrap: wrap; }
.class-desc { font-weight: 500; font-size: .9rem; overflow-wrap: break-word; hyphens: auto; }
.class-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin-top: 4px; font-size: .78rem; color: var(--muted); }
.room { display: inline-flex; align-items: center; gap: 3px; }
.room .ic { width: 14px; height: 14px; }

/* Attendance bars */
.bars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: var(--s3); }
.bar-label { display: flex; align-items: baseline; gap: var(--s2); font-size: .85rem; }
.bar-name { flex: 1; min-width: 0; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin-top: 5px; }
.bar i { display: block; height: 100%; border-radius: inherit; }

.stats { display: flex; gap: var(--s3); }
.stat { flex: 1; padding: var(--s3); border-radius: var(--r); background: var(--surface-2); display: flex; flex-direction: column; }
.stat-num { font-size: 1.6rem; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat-lbl { color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; }

/* --- Timetable ------------------------------------------------------------- */
.day-chips {
  display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none;
  margin: var(--s3) calc(-1 * var(--s4)) var(--s4); padding: 2px var(--s4);
}
.day-chips::-webkit-scrollbar { display: none; }
.day-chip {
  flex: 1 1 0; min-width: 2.7rem; min-height: 52px; padding: 6px 8px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  border-radius: var(--r); border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: .85rem; cursor: pointer; touch-action: manipulation;
}
.day-chip i { font-style: normal; font-size: .7rem; color: var(--muted); font-weight: 500; min-height: 1em; }
.day-chip.is-today { border-color: var(--accent); }
.day-chip.is-empty span { color: var(--muted); }
.day-chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.day-chip.is-active i, .day-chip.is-active span { color: inherit; }
.week { display: flex; flex-direction: column; gap: var(--s4); }
.day-col { display: none; flex-direction: column; gap: var(--s3); }
.day-col.is-active { display: flex; }
.day-col h2 { display: flex; align-items: center; gap: var(--s2); }
@media (min-width: 56rem) {
  .day-chips { display: none; }
  .week { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); align-items: start; gap: var(--s3); }
  .day-col { display: flex; padding: var(--s3); border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); }
  .day-col.is-today { border-color: var(--accent); }
  .day-col .class { flex-direction: column; gap: var(--s1); }
  .day-col .class-time { flex-direction: row; gap: 4px; width: auto; }
  .day-col .class-time span:last-child::before { content: "– "; }
}

/* --- Attendance ------------------------------------------------------------ */
.stack { display: flex; flex-direction: column; gap: var(--s3); }
.summary { flex-direction: row; align-items: center; gap: var(--s4); }
.ring {
  --p: 0; --tone: var(--muted);
  width: 56px; height: 56px; flex: none; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--tone) calc(var(--p) * 1%), var(--surface-2) 0);
  position: relative; font-size: .78rem; font-weight: 700; font-variant-numeric: tabular-nums;
}
.ring::before { content: ""; position: absolute; inset: 6px; border-radius: 50%; background: var(--surface); }
.ring span { position: relative; color: var(--ink); }
.ring.tone-ok { --tone: var(--ok); } .ring.tone-warn { --tone: var(--warn); } .ring.tone-bad { --tone: var(--bad); }
.ring-lg { width: 72px; height: 72px; font-size: .95rem; }
.ring-lg::before { inset: 7px; }

.subj-grid { display: grid; gap: var(--s3); }
@media (min-width: 56rem) { .subj-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.subj { padding: 0; gap: 0; }
.subj summary {
  list-style: none; display: flex; align-items: center; gap: var(--s3);
  padding: var(--s4); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.subj summary::-webkit-details-marker { display: none; }
.subj .chev { transition: transform .2s; }
.subj[open] .chev { transform: rotate(90deg); }
.subj-body { min-width: 0; flex: 1; }
.subj-name { font-weight: 500; font-size: .9rem; overflow-wrap: break-word; hyphens: auto; }
.subj-counts { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 4px; font-size: .78rem; color: var(--muted); }
.subj-counts b { color: var(--ink); font-weight: 600; }
.subj-counts .tone-bad b { color: var(--bad); }
.sessions { list-style: none; margin: 0; padding: 0 var(--s4) var(--s3); border-top: 1px solid var(--line); }
.session { display: flex; align-items: center; justify-content: space-between; gap: var(--s3); padding: var(--s3) 0; border-bottom: 1px solid var(--line); }
.session:last-child { border-bottom: 0; }
.session-date { font-size: .88rem; font-weight: 500; }
.session-meta { font-size: .76rem; color: var(--muted); }
.status { flex: none; padding: 2px 10px; border-radius: 99px; font-size: .74rem; font-weight: 600; }
.status-ok { background: var(--ok-soft); color: var(--ok); }
.status-bad { background: var(--bad-soft); color: var(--bad); }
.status-info { background: var(--info-soft); color: var(--info); }
.status-none { background: var(--surface-2); color: var(--muted); }

/* --- Subjects -------------------------------------------------------------- */
.subject-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s3); }
@media (min-width: 56rem) { .subject-list { grid-template-columns: 1fr 1fr; } }
.subject { flex-direction: row; align-items: center; justify-content: space-between; gap: var(--s3); }
.subject-main { min-width: 0; }
.subject-name { font-weight: 500; overflow-wrap: break-word; hyphens: auto; }
.subject-meta { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; font-size: .78rem; color: var(--muted); white-space: nowrap; }
.subject-meta b { color: var(--ink); }

/* --- Scan ------------------------------------------------------------------ */
.scan { display: flex; flex-direction: column; gap: var(--s4); }
.scan-stage {
  position: relative; aspect-ratio: 1 / 1; max-height: 62vh; width: 100%; margin: 0 auto;
  border-radius: var(--r-lg); overflow: hidden; background: #0b0d10;
}
.scan-stage video { width: 100%; height: 100%; object-fit: cover; display: none; transform-origin: center; }
.scan-stage.is-live video { display: block; }
.scan-idle { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: var(--s2); color: #8b93a1; font-size: .9rem; }
.scan-idle .ic { width: 48px; height: 48px; opacity: .6; }
.scan-stage.is-live .scan-idle { display: none; }
.scan-actions { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s2); }
.scan-actions #qrStartCam, .scan-actions #qrStopCam { grid-column: 1 / -1; }
.scan-hud {
  position: absolute; left: var(--s2); right: var(--s2); bottom: var(--s2);
  display: flex; justify-content: space-between; align-items: center; gap: var(--s2);
}
.scan-stage:not(.is-live) .scan-hud { display: none; }
.hud-pill {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, .55); color: #fff; font: 600 .78rem/1 var(--sans);
  font-variant-numeric: tabular-nums; border: 0;
}
.hud-btn { cursor: pointer; min-height: 36px; }
.hud-btn .ic { width: 16px; height: 16px; }
.hud-btn:active { background: rgba(0, 0, 0, .75); }
.zoom { display: flex; flex-direction: column; gap: 2px; padding: 0 2px; }
.zoom input[type="range"] { width: 100%; margin: 0; height: 28px; accent-color: var(--accent); touch-action: pan-y; }
.zoom-ticks { position: relative; height: 1rem; margin: 0 10px; font-size: .7rem; color: var(--muted); }
.zoom-ticks span { position: absolute; transform: translateX(-50%); }
.zoom-ticks span.is-lens { color: var(--ink); font-weight: 600; }
.qr-prog { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; }
.qr-step { display: flex; flex-direction: column; gap: 4px; align-items: center; font-size: .66rem; color: var(--muted); }
.qr-step i { display: block; width: 100%; height: 5px; border-radius: 3px; background: var(--surface-2); box-shadow: inset 0 0 0 1px var(--line); position: relative; overflow: hidden; }
.qr-step.is-done i { background: var(--accent); box-shadow: none; }
.qr-step.is-on i { background: var(--accent-soft); box-shadow: none; }
.qr-step.is-on i::after {
  content: ""; position: absolute; inset: 0; width: 45%;
  background: var(--accent); border-radius: 3px; animation: qr-run 1s ease-in-out infinite;
}
.qr-step.is-on, .qr-step.is-done { color: var(--ink); }
.qr-step.is-on span { font-weight: 600; }
.qr-prog[data-tone="bad"] .qr-step.is-on i { background: var(--bad); }
.qr-prog[data-tone="bad"] .qr-step.is-on i::after { display: none; }
.qr-prog[data-tone="bad"] .qr-step.is-on { color: var(--bad); }
.qr-prog[data-tone="ok"] .qr-step i { background: var(--ok); }
@keyframes qr-run { from { transform: translateX(-100%); } to { transform: translateX(230%); } }
@media (prefers-reduced-motion: reduce) { .qr-step.is-on i::after { animation: none; width: 100%; opacity: .6; } }
.qr-line {
  text-align: center; font-size: .85rem; min-height: 1.3em; color: var(--muted); margin-top: calc(-1 * var(--s2));
  font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qr-line.ok { color: var(--ok); }
.qr-line.bad { color: var(--bad); white-space: normal; }
.result { padding: var(--s4); border-radius: var(--r-lg); display: flex; flex-direction: column; gap: var(--s2); }
.result-ok { background: var(--ok-soft); color: var(--ok); }
.result-bad { background: var(--bad-soft); color: var(--bad); }
.result .kv { color: var(--ink); }
@media (min-width: 56rem) { .scan { max-width: 30rem; } }
@media (pointer: coarse) { .only-fine { display: none; } }

.cam-list { list-style: none; margin: var(--s2) 0; padding: 0; display: flex; flex-direction: column; gap: var(--s2); }
.cam { border: 1px solid var(--line); border-radius: var(--r); padding: var(--s3); display: flex; flex-direction: column; gap: var(--s2); }
.cam-head { overflow-wrap: anywhere; }
.cam-role { display: flex; align-items: center; gap: var(--s2); }
.cam-role select { font: inherit; padding: 4px 6px; border-radius: var(--r-sm); border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); }
.err-text { color: var(--bad); }

/* --- Profile / More -------------------------------------------------------- */
.profile-top { display: flex; align-items: center; gap: var(--s3); }
.profile-top > div:last-child { display: flex; flex-direction: column; }
.profile-name { font-size: 1.05rem; }
.avatar {
  width: 52px; height: 52px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 1.05rem;
}
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: var(--r); background: var(--surface-2); }
.seg-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px;
  border: 0; border-radius: var(--r-sm); background: none; color: var(--muted); font-weight: 600; font-size: .85rem; cursor: pointer;
}
.seg-btn .ic { width: 16px; height: 16px; }
.seg-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.menu { padding: var(--s2); gap: 0; }
.menu-item { display: flex; align-items: center; gap: var(--s3); padding: var(--s3); border-radius: var(--r); color: var(--ink); }
.menu-item:hover { background: var(--surface-2); }
.menu-item b { display: block; font-weight: 600; }
.menu-item small { color: var(--muted); font-size: .8rem; }
.menu-ic { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--surface-2); color: var(--ink-2); }
