/* Raga Finder — app stylesheet (direction A). Rules: docs/design/DECISIONS.md
   Text contrast ≥ 4.5:1; no horizontal scrolling; labels on buttons, chips and tabs never wrap. */

:root {
  --ink: #111827;
  --ink-2: #374151;
  --muted: #4B5563;
  --faint: #5F6673;
  --line: #E5E7EB;
  --line-2: #D1D5DB;
  --panel: #F4F5FA;
  --panel-2: #E5E7F0;
  --accent: #4F46E5;
  --accent-ink: #3730A3;
  --accent-link: #4338CA;
  --accent-soft: #EEF0FF;
  --accent-soft-2: #E0E7FF;
  --gold: #FFC447;
  --warn-ink: #8A3B00;
  --warn-line: #F0B27A;
  --radius: 14px;
  --font: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --tabs-h: 64px;
  box-sizing: border-box;
  -webkit-text-size-adjust: 100%;
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body {
  margin: 0;
  background: #FFFFFF;
  color: var(--ink);
  font: 400 15px/1.5 var(--font);
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px));
  overflow-x: hidden;
}
@media (min-width: 760px) { body { padding-bottom: env(safe-area-inset-bottom, 0px); } }

/* Reset browser control styling (Safari rounds buttons on its own). */
button, input, select { font: inherit; color: inherit; }
button { -webkit-appearance: none; appearance: none; border: 0; background: none; padding: 0; border-radius: 0; cursor: pointer; }
input { -webkit-appearance: none; appearance: none; border-radius: 0; }
input[type="checkbox"] { -webkit-appearance: auto; appearance: auto; }
::placeholder { color: var(--faint); opacity: 1; }
a { color: var(--accent-link); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: 12px; top: -60px; background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 10px; z-index: 50; }
.skip:focus { top: 12px; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
p { margin: 0; }

/* ---------- header ---------- */
.top { display: flex; align-items: center; gap: 16px; padding: 12px 12px 4px 20px; max-width: 760px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; color: var(--ink); text-decoration: none; white-space: nowrap; }
.mark { width: 32px; height: 32px; border-radius: 10px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.top .spacer { flex-grow: 1; }
.top-nav { display: none; gap: 4px; }
.top-nav a { padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 500; font-size: 14px; white-space: nowrap; }
.top-nav a[aria-current="page"] { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.icon-btn { width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center; border-radius: 12px; color: var(--ink); flex-shrink: 0; text-decoration: none; }
.icon-btn:hover { background: var(--panel); }
@media (min-width: 760px) { .top-nav { display: flex; } }

/* ---------- bottom tabs (phone) ---------- */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr));
  background: rgba(255,255,255,.96); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-top: 1px solid var(--line); padding: 4px 8px calc(6px + env(safe-area-inset-bottom, 0px)); }
.tabs a { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; min-height: 52px; justify-content: center;
  text-decoration: none; color: var(--muted); font-size: 12px; font-weight: 500; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--accent); font-weight: 600; }
@media (min-width: 760px) { .tabs { display: none; } }

/* ---------- page ---------- */
#view { display: block; max-width: 720px; margin: 0 auto; padding: 8px 20px 32px; outline: none; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 10px; }
.page-head { display: flex; align-items: center; gap: 8px; margin: 0 -8px; }
.page-head .t { display: flex; flex-direction: column; min-width: 0; }
.page-head h1 { font-size: 22px; }
.page-head .sub { font-size: 13px; }
.title-xl { font-size: 28px; line-height: 1.15; letter-spacing: -0.02em; }
.h2 { font-size: 18px; }
.h3 { font-size: 15px; }
.h3.quiet { font-size: 13px; color: var(--muted); font-weight: 600; }
.sub { color: var(--muted); font-size: 14px; }
.small { font-size: 13px; }
.section { display: flex; flex-direction: column; gap: 10px; }
.section + .section { margin-top: 8px; }

/* ---------- surfaces ---------- */
.panel { background: var(--panel); border-radius: 20px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.note { font-size: 13px; color: var(--ink-2); background: var(--panel); border-radius: 12px; padding: 10px 12px; line-height: 1.55; }
.card { display: flex; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink); }
.card.soft { background: var(--panel); border-color: var(--panel); }
.card .m { flex-grow: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.card .m b { font-size: 15px; }
.card .m span { font-size: 13px; color: var(--muted); }
.av { width: 44px; height: 44px; border-radius: 10px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-weight: 700; color: var(--accent-ink); font-size: 14px; flex-shrink: 0; }
.av.white { background: #fff; }
.av.k { background: #FFF4D6; color: #7A5200; }

/* ---------- controls ---------- */
.btn { height: 52px; border-radius: var(--radius); background: var(--accent); color: #fff; font-weight: 600; font-size: 15px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-decoration: none; padding: 0 16px; white-space: nowrap; }
.btn.dark { background: var(--ink); }
.btn.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line-2); }
.btn.sm { height: 44px; font-size: 14px; border-radius: 12px; }
.btn.tall { height: auto; min-height: 64px; flex-direction: column; gap: 0; line-height: 1.3; padding: 10px; }
.btn .s { display: block; font-weight: 400; font-size: 12px; opacity: .9; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; }
.row2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.seg { display: grid; grid-auto-columns: minmax(0, 1fr); grid-auto-flow: column; gap: 4px; background: var(--panel-2); padding: 4px; border-radius: 12px; }
.seg button { height: 40px; border-radius: 9px; font-weight: 500; font-size: 14px; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px rgba(17,24,39,.12); }
.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.input { height: 48px; border: 1px solid var(--line-2); border-radius: 12px; padding: 0 14px; font-size: 16px; font-weight: 400; background: #fff; color: var(--ink); width: 100%; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5; color: var(--ink-2); }
.check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--accent); flex-shrink: 0; }
.disc { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 44px; font-weight: 500; font-size: 14px; color: var(--ink-2); }
.disc em { font-style: normal; color: var(--faint); font-weight: 400; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { min-height: 36px; padding: 0 14px; border-radius: 999px; border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  font-weight: 500; font-size: 13px; display: inline-flex; align-items: center; white-space: nowrap; text-decoration: none; }
.chip[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 600; }
.mini { min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line-2); background: #fff; color: var(--ink);
  font-weight: 600; font-size: 13px; display: inline-flex; align-items: center; text-decoration: none; white-space: nowrap; }
.mini.dark { background: var(--ink); color: #fff; border-color: var(--ink); }
.acts { display: flex; gap: 8px; flex-wrap: wrap; }

.share-note { display: flex; gap: 10px; align-items: flex-start; font-size: 13px; line-height: 1.5; color: var(--ink-2); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin: 0; }
.share-note svg { flex-shrink: 0; margin-top: 1px; color: var(--accent); }
.page-head.no-back { margin: 0; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.list > a, .list > .li { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 56px; padding: 10px 16px;
  color: var(--ink); text-decoration: none; border-bottom: 1px solid var(--line); }
.list > :last-child { border-bottom: 0; }
.list > a:hover { background: #FAFAFC; }
.list .r { color: var(--muted); font-size: 13px; text-align: right; flex-shrink: 0; }
.list .li.dev { color: var(--muted); font-size: 13px; min-height: 48px; }
.nm { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.nm b { font-size: 15px; }
.grp { font-size: 14px; font-weight: 700; color: var(--ink-2); margin-top: 8px; }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

/* ---------- swaras and sargam ---------- */
.sg { font-weight: 500; font-size: 13px; color: var(--muted); letter-spacing: .04em; }
.seq { font-size: 16px; font-weight: 600; letter-spacing: .05em; color: var(--ink); }
.ko { text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1.5px; }
.sw { display: flex; gap: 6px; flex-wrap: wrap; }
.sw > span { min-width: 38px; height: 38px; padding: 0 6px; border-radius: 10px; background: var(--accent-soft); display: flex; align-items: center; justify-content: center; font-weight: 600; color: var(--accent-ink); }
.sw > span.rest { background: var(--accent); color: #fff; }
.sw > span.off { background: #fff; border: 1.5px dashed #9CA3AF; color: var(--muted); }
.kv { display: grid; grid-template-columns: 84px minmax(0, 1fr); gap: 6px 12px; margin: 0; font-size: 14px; align-items: baseline; }
.kv dt { font-weight: 600; color: var(--ink-2); }
.kv dd { margin: 0; }
.phrase { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; min-height: 48px; }
.phrase .play { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid #C7D2FE; background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; font-size: 13px; white-space: nowrap; }
.phrase .lbl { font-size: 12px; color: var(--muted); }

/* ---------- raga page ---------- */
.diff { display: flex; flex-direction: column; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; }
.diff a, .diff b { font-size: 15px; font-weight: 700; }
.diff a { color: var(--ink); }
.diff span { font-size: 14px; color: var(--ink-2); }
.mx { display: grid; grid-template-columns: minmax(0, 9rem) minmax(0, 1fr) 28px; gap: 10px; align-items: center; font-size: 14px; min-height: 28px; }
.mx a { color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx i { display: block; height: 8px; border-radius: 4px; background: #EEF0F3; }
.mx i b { display: block; height: 8px; border-radius: 4px; background: var(--accent); }
.mx .c { text-align: right; color: var(--muted); font-size: 13px; }
.song { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); }
.song .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.song .meta { font-size: 13px; color: var(--muted); line-height: 1.5; }
.stitle { color: var(--ink); font-weight: 700; font-size: 15px; text-decoration: underline; text-decoration-color: #9CA3AF; text-underline-offset: 3px; }
.stitle:hover { text-decoration-color: var(--ink); }
span.stitle { text-decoration: none; }
.badge { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; flex-shrink: 0; }
.badge.match { background: var(--accent); color: #fff; }
.badge.close, .badge.top3 { background: var(--accent-soft-2); color: var(--accent-ink); }
.badge.miss, .badge.low { background: #fff; color: var(--warn-ink); border: 1px solid var(--warn-line); }
.banner { border: 1px solid var(--warn-line); background: #FFF8F1; color: var(--warn-ink); border-radius: 12px; padding: 10px 12px; font-size: 14px; }

/* ---------- result ---------- */
.box { border: 1px solid var(--line); border-radius: 16px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tile { background: #fff; border-radius: var(--radius); padding: 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.tile .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.tile .v { font-size: 20px; font-weight: 700; }
.tile .n { font-size: 12px; color: var(--muted); }
.taalv { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: 6px; }
.beats { font-size: 13px; font-weight: 500; color: var(--muted); letter-spacing: 0; }
.meter { height: 6px; border-radius: 3px; background: #DDE0EE; }
.meter i { display: block; height: 6px; border-radius: 3px; background: var(--accent); }
.alt { text-align: left; border: 1px dashed #A5B4FC; border-radius: var(--radius); padding: 12px 14px; font-size: 14px; color: var(--ink); background: #fff; }
.btn.wide { justify-content: space-between; height: auto; padding: 14px 16px; text-align: left; white-space: normal; }
.ck { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.5; }
.ck .d { width: 22px; height: 22px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; margin-top: 1px; }
.ck .d.y { background: var(--accent-soft-2); color: var(--accent-ink); }
.ck .d.n { background: #FDE7D3; color: var(--warn-ink); }

/* note bar (Try another Sa, Karaoke key) */
.keybar { display: flex; align-items: stretch; gap: 4px; }
.kstep { width: 44px; height: 48px; border: 1px solid var(--line-2); border-radius: 10px; background: #fff; font-size: 20px; font-weight: 600; color: var(--ink); flex-shrink: 0; }
.keys { flex-grow: 1; min-width: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); background: var(--panel); border-radius: 10px; overflow: hidden; height: 48px; }
.kc { font-size: 14px; font-weight: 600; color: var(--ink-2); display: flex; align-items: center; justify-content: center; min-width: 0; border-radius: 0; }
.kc + .kc { border-left: 1px solid var(--line); }
.kc.song { box-shadow: inset 0 0 0 2px var(--ink); color: var(--ink); }
.kc.on { background: var(--accent); color: #fff; }
.kc.on.song { box-shadow: inset 0 0 0 2px var(--accent-ink); }

/* ---------- full analysis ---------- */
.subnav { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.subnav button { height: 40px; border-radius: 10px; background: var(--panel); color: var(--ink-2); font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 6px; }
.subnav button[aria-current="true"] { background: var(--accent); color: #fff; font-weight: 600; }
.regbar { display: flex; height: 12px; border-radius: 6px; overflow: hidden; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 13px; color: var(--ink-2); }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.trow { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; padding: 10px 0; border-bottom: 1px solid #EEF0F3; font-size: 14px; }
.trow:last-child { border-bottom: 0; }
.trow span { color: var(--ink-2); }
a.play { display: inline-flex; align-items: center; text-decoration: none; }
.phrase .lbl { flex-grow: 1; }
details.box > summary { display: flex; justify-content: space-between; align-items: center; min-height: 32px; cursor: pointer; font-weight: 700; font-size: 15px; list-style: none; }
details.box > summary::-webkit-details-marker { display: none; }
details.box > summary::after { content: "+"; color: var(--muted); font-weight: 400; margin-left: 10px; }
details.box[open] > summary::after { content: "−"; }
details.box > summary > span:first-child { flex-grow: 1; }
.strip { display: flex; gap: 3px; height: 28px; }
.strip i { border-radius: 4px; background: var(--accent); }
.strip i.unclear { background: var(--line-2); }
.melody { background: var(--panel); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; }
.melody .seq { font-size: 15px; line-height: 1.7; overflow-wrap: anywhere; }

/* ---------- jobs ---------- */
.stages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; font-size: 14px; color: var(--muted); }
.stages li { display: flex; align-items: center; gap: 10px; }
.stages .dot { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line-2); display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.stages li.done { color: var(--ink-2); }
.stages li.done .dot { background: var(--accent-soft-2); border-color: var(--accent-soft-2); color: var(--accent-ink); }
.stages li.now { color: var(--ink); font-weight: 600; }
.stages li.now .dot { border-color: var(--accent); box-shadow: inset 0 0 0 4px #fff; background: var(--accent); }

/* ---------- karaoke ---------- */
.step { display: flex; gap: 12px; }
.step > .n { width: 28px; height: 28px; border-radius: 50%; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.step > .n.todo { background: #fff; border: 1.5px solid #9CA3AF; color: var(--muted); }
.step > .b { flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 12px; padding-bottom: 8px; }
.step > .b > h2 { margin-top: 3px; }
.ends { display: flex; justify-content: space-between; margin-top: -8px; }
input[type="range"] { -webkit-appearance: auto; appearance: auto; width: 100%; accent-color: var(--accent); height: 32px; }
.input.area { height: auto; padding: 10px 14px; line-height: 1.5; resize: vertical; font-family: inherit; }
.linkish { color: var(--accent-link); text-decoration: underline; font-size: inherit; }

/* ---------- about ---------- */
.prose { display: flex; flex-direction: column; gap: 14px; font-size: 15px; line-height: 1.6; max-width: 68ch; }
.prose h2 { margin-top: 12px; }
.prose ul, .prose ol { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 6px; }
.table-wrap { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.prose table { border-collapse: collapse; width: 100%; font-size: 14px; }
.prose th, .prose td { overflow-wrap: anywhere; text-align: left; vertical-align: top; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.prose th { background: var(--panel); font-weight: 600; }
.prose tr:last-child td { border-bottom: 0; }

/* ---------- placeholder screens ---------- */
.soon { padding: 24px 0; display: flex; flex-direction: column; gap: 12px; }

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }

/* Wide tables in About texts become one card per row on phones; each cell shows its column name. */
@media (max-width: 599px) {
  table.stackable thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.stackable, table.stackable tbody, table.stackable tr, table.stackable td { display: block; width: auto; }
  table.stackable tr { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; background: #fff; }
  table.stackable td { border: 0; padding: 3px 0; }
  table.stackable td:first-child { font-weight: 600; }
  table.stackable td[data-label]:not(:first-child)::before { content: attr(data-label); display: block; font-size: 12px; font-weight: 600; color: var(--muted); }
  .table-wrap:has(table.stackable) { border: 0; background: none; overflow: visible; }
}
.progress-list { margin-top: 4px; }

/* Melody lines: time, then swaras with the seconds held small and a tie for glides */
.melody .ml { display: flex; gap: 10px; align-items: baseline; }
.ml-t { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; flex-shrink: 0; min-width: 34px; }
.mn { white-space: nowrap; }
.mn small { font-size: 10px; color: var(--muted); margin-left: 1px; font-weight: 400; }
.mn .gl { font-style: normal; color: var(--muted); margin-left: 1px; }
.ml-more { font-size: 13px; color: var(--muted); }
.melody .ml > span[aria-hidden] { min-width: 0; }

/* Labels and versions */
.tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: -6px; }
.tag { font-size: 12px; font-weight: 600; color: var(--ink-2); background: var(--panel); border-radius: 999px; padding: 4px 10px; text-decoration: none; }
.tag::before { content: "#"; color: var(--muted); }
.tagline { font-size: 12px; color: var(--muted); }
.card.ver { align-items: center; }
.card.ver .m { text-decoration: none; color: inherit; }
.card.ver.sug { border-style: dashed; }
.page-head .mini { margin-left: auto; align-self: center; flex-shrink: 0; }
.card.ver .m { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card.ver .m b, .card.ver .m a { overflow-wrap: anywhere; }
.card.ver > .mini, .card.ver > .acts { flex-shrink: 0; }
@media (max-width: 380px) { .card.ver.sug { flex-wrap: wrap; } .card.ver.sug > .mini { margin-left: auto; } }

/* Test-song pills: each shows its share; raga page jump links; the upload player */
.chip .pct { margin-left: 6px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.chip[aria-pressed="true"] .pct { color: #D1D5DB; }
.jump { display: flex; flex-wrap: wrap; gap: 6px; }
.jump .chip { font-size: 13px; min-height: 36px; }
audio.listen { width: 100%; margin-top: -4px; }
[tabindex="-1"]:focus { outline: none; }

/* RF code: a third tile; keeps its size and wraps below Sa and Taal on narrow screens */
.row2.has-rf { grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
@media (max-width: 559px) { .row2.has-rf { grid-template-columns: repeat(2, minmax(0, 1fr)); } .row2.has-rf .tile.rf { grid-column: 1 / -1; } }
.tile.rf { align-items: flex-start; gap: 6px; }
.rfc { display: block; image-rendering: pixelated; image-rendering: crisp-edges; background: #fff; border-radius: 6px; box-shadow: 0 0 0 1px var(--line); }
.rf-outline { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; margin-top: 4px; }
.rf-outline .tile { background: var(--panel); }
.rf-outline > p { flex: 1 1 200px; margin: 0; }

/* Four view buttons: one row on wider screens, two by two on phones */
@media (max-width: 479px) { .seg.seg4 { grid-auto-flow: row; grid-template-columns: repeat(2, minmax(0, 1fr)); } }

.prog-row { padding: 12px 14px; display: flex; flex-direction: column; gap: 3px; border-top: 1px solid var(--line); }
.prog-row:first-child { border-top: 0; }
.prog-row .ph { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 15px; }
.prog-row .ph .sub { font-size: 13px; margin-left: auto; }
.prog-row .pl { font-size: 13px; color: var(--ink-2); font-variant-numeric: tabular-nums; }

/* RF code: tap to enlarge */
.rfc-btn { padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: 6px; line-height: 0; }
.rfc-btn:hover .rfc { box-shadow: 0 0 0 2px var(--accent); }
.rf-dlg { border: 0; border-radius: 18px; padding: 16px; max-width: min(640px, calc(100vw - 24px)); max-height: calc(100vh - 24px); overflow: auto;
  box-shadow: 0 20px 60px rgba(17, 24, 39, .35); color: var(--ink); }
.rf-dlg::backdrop { background: rgba(17, 24, 39, .55); }
.rf-dlg { display: none; }
.rf-dlg[open] { display: flex; flex-direction: column; gap: 12px; align-items: center; }
.rf-dlg-h { display: flex; align-items: center; justify-content: space-between; gap: 12px; align-self: stretch; }
.rf-dlg-h h2 { margin: 0; overflow-wrap: anywhere; }
.rf-dlg .rfc.big { box-shadow: none; }
.rf-dlg > p { align-self: stretch; margin: 0; }
.rf-dlg .acts { align-self: stretch; }

/* The work behind it: model rows and experiments from the record */
.prog-row .ms { margin: 2px 0; font-size: 14px; line-height: 1.5; }
.prog-row .ms.sub { font-size: 13px; }
.stand-box { background: var(--panel); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.stand-box p { margin: 0; }
.stand-box .pl { font-size: 14px; color: var(--ink-2); }
.exp .learned { color: var(--ink-2); }
.badge.kept-open { background: var(--accent-soft-2); color: var(--accent-ink); }
.defs { display: flex; flex-direction: column; gap: 8px; }
.defs > div { border: 1px solid var(--line); border-radius: 12px; padding: 10px 14px; display: flex; flex-direction: column; gap: 2px; }
.defs > div p { margin: 0; font-size: 14px; color: var(--ink-2); }
.exp { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; font-size: 14px; line-height: 1.55; }
.exp p { margin: 0; }
.exp .head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.exp .badge { flex-shrink: 0; }
.badge.kept-yes { background: var(--accent); color: #fff; }
.badge.kept-partly { background: var(--accent-soft-2); color: var(--accent-ink); }
.badge.kept-no { background: #fff; color: var(--warn-ink); border: 1px solid var(--warn-line); }

/* Add to Home Screen offer */
.a2hs { align-items: flex-start; }
.a2hs .m { gap: 2px; }
.a2hs-steps { margin: 8px 0 4px; padding-left: 20px; display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.5; color: var(--ink); }
.a2hs .a2hs-steps b, .a2hs .a2hs-steps li { font-size: 14px; }
.a2hs .a2hs-steps b { font-weight: 700; display: inline; }

/* Editor: review answers */
.ans { border: 1px solid var(--line); border-radius: 14px; padding: 14px; display: flex; flex-direction: column; gap: 10px; background: #fff; }
.ans.sa-diff { border-color: var(--warn-line); box-shadow: inset 4px 0 0 var(--warn-line); }
.ans.done { opacity: .55; }
.ans.done .acts, .ans.done [data-note-input] { display: none; }
.ans-h { display: flex; flex-direction: column; gap: 2px; }
.ans-h .stitle { text-decoration: none; color: var(--ink); font-size: 15px; }
.tags-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tags-row:empty { display: none; }
.ans-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.ans-cols > div { background: var(--panel); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ans-cols .k { font-size: 12px; font-weight: 600; color: var(--muted); }
.ans-cols p { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.ans-cols p.hl { color: var(--warn-ink); font-weight: 600; }
.ans-c { margin: 0; padding: 8px 12px; border-left: 3px solid var(--line-2); color: var(--ink-2); font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.seg .pct { margin-left: 4px; font-weight: 400; color: var(--muted); font-variant-numeric: tabular-nums; }
.ans.done .credit { display: none; }

/* Public visitors: welcome; report */
.welcome { display: flex; flex-direction: column; gap: 4px; }
.welcome b { font-size: 15px; color: var(--ink); }
.report { display: flex; flex-direction: column; gap: 8px; }
.report .link { align-self: flex-start; color: var(--muted); }

/* Editor hub */
.adm-nav { margin-top: -4px; }
.imp-row { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; display: flex; flex-direction: column; gap: 6px; background: #fff; }
.imp-row.st-not_found { border-style: dashed; }
.imp-h { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.imp-h b { overflow-wrap: anywhere; }
.imp-v { display: flex; flex-direction: column; gap: 2px; background: var(--panel); border-radius: 10px; padding: 8px 10px; font-size: 14px; }
.imp-v a { overflow-wrap: anywhere; }
.imp-fix { display: flex; gap: 8px; flex-wrap: wrap; }
.imp-fix .input { flex: 1 1 220px; }
.job-mini { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.job-mini .meter { flex: 1 1 160px; }
.spin { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-soft-2); border-top-color: var(--accent); animation: spin .9s linear infinite; flex-shrink: 0; }
@keyframes spin { to { transform: rotate(360deg); } }
.ans.done-q { opacity: .7; }
.tog { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; }
.tog input { width: 22px; height: 22px; margin-top: 1px; accent-color: var(--accent); flex-shrink: 0; }
.tog > span { display: flex; flex-direction: column; gap: 2px; }
.tog.big { border-color: var(--accent); background: var(--accent-soft); }
.tog.big b { font-size: 16px; }

/* Locked (by invitation): greyed, the reason on hover (title) and on tap (toast) */
.locked { opacity: .45; cursor: not-allowed; filter: grayscale(1); }
.locked:hover { opacity: .55; }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom, 0px)); z-index: 50;
  width: min(520px, calc(100vw - 32px)); box-sizing: border-box; background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 12px;
  font-size: 14px; line-height: 1.5; box-shadow: 0 10px 30px rgba(17, 24, 39, .3); }
@media (min-width: 720px) { .toast { bottom: 24px; } }

/* History rows with an Analyse button; reviewed readings; record-from options */
.card-row { display: flex; gap: 8px; align-items: center; }
.card-row > .card { flex: 1 1 auto; min-width: 0; }
.card-row > .mini { flex-shrink: 0; }
.badge.rev { vertical-align: middle; font-size: 11px; background: var(--accent-soft-2); color: var(--accent-ink); letter-spacing: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex-shrink: 0; }

.fail-d { margin-top: 6px; }
.fail-d summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.fail-d p { margin: 6px 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; overflow-wrap: anywhere; white-space: pre-wrap; }

/* Reviewers' page: compact rows (one line each on a laptop) */
.rv-prof { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; padding: 10px 14px; background: var(--panel); border-radius: 12px; font-size: 14px; }
.rv-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: #fff; }
.rv-t { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.rv-t b { font-size: 15px; }
.rv-t .mini { margin-left: auto; }
.rv-f { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.rv-f .field { font-size: 12px; gap: 4px; }
.rv-f .input { height: 40px; font-size: 15px; padding: 6px 10px; }
.rv-f textarea.input { height: 40px; min-height: 40px; resize: none; overflow: hidden; line-height: 1.4; }
.rv-why { grid-column: 1 / -1; }
@media (min-width: 900px) { .rv-f { grid-template-columns: 9rem 12rem minmax(0, 1fr) 8rem; } .rv-why { grid-column: auto; } }
.yt { position: relative; padding-top: 56.25%; border-radius: 10px; overflow: hidden; background: #000; }
.yt iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
/* Collaborators */
.col-opt { padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; }
.col-opt > span { display: flex; flex-direction: column; gap: 2px; }
.chip.chk { cursor: pointer; }
.chip.chk input { position: absolute; opacity: 0; pointer-events: none; }
.chip.chk:has(input:checked) { background: var(--ink); color: #fff; border-color: var(--ink); }
.chip.chk:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.err { color: var(--warn-ink); }
.adm-links { display: flex; flex-direction: column; gap: 4px; color: var(--ink-2); overflow-wrap: anywhere; }
/* Progress chart */
.pchart { margin: 8px 0 16px; display: flex; flex-direction: column; gap: 8px; }
.pchart figcaption { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; font-size: 14px; }
.pchart .legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 13px; color: var(--ink-2); }
.pchart .legend i { display: inline-block; width: 22px; margin-right: 6px; vertical-align: middle; }
.pchart svg { width: 100%; height: auto; display: block; overflow: visible; }
.pchart .cg { stroke: var(--line); stroke-width: 1; }
.pchart .cl { font-size: 17px; fill: var(--muted); }
.pchart .px { display: grid; text-align: center; margin-top: -4px; }
.pchart .px .link { font-size: 12px; white-space: nowrap; }
.pchart .px-cap { text-align: center; margin-top: -6px; }
.pchart .px .link { font-size: 13px; font-weight: 600; min-width: 28px; min-height: 28px; }
fieldset.q { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; min-width: 0; }
fieldset.q legend { padding: 0; margin-bottom: 8px; }
@media (max-width: 399px) { .tabs a { font-size: 11px; letter-spacing: -0.01em; } }
