@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/Inter-Variable.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}
:root {
  --bg: #F4F4F5;
  --surface: #FFFFFF;
  --surface-2: #FAFAFA;
  --line: #E4E4E7;
  --line-strong: #D4D4D8;
  --ink: #18181B;
  --soft: #52525B;
  --faint: #A1A1AA;
  --accent: #2E5BFF;
  --accent-ink: #1F45E0;
  --accent-tint: #EEF2FF;
  --ok: #15803D;
  --ok-tint: #ECFDF3;
  --danger: #B91C1C;
  --warn: #B45309;
  --stage: #E7E7EA;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(24, 24, 27, .06), 0 1px 1px rgba(24, 24, 27, .04);
  --shadow-lg: 0 12px 32px rgba(24, 24, 27, .16), 0 2px 6px rgba(24, 24, 27, .08);
  --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  color-scheme: light;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 14px/1.5 var(--font); font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 24px; font-weight: 650; }
h2 { font-size: 16px; font-weight: 650; }
h3 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
code { background: #F1F1F3; border-radius: 4px; padding: 1px 5px; }
.muted { color: var(--soft); }
.small { font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.spacer { flex: 1; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- controls ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 14px;
  border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink);
  font: 550 13.5px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none; transition: background-color .12s, border-color .12s, color .12s; }
.btn:hover { background: #F4F4F5; text-decoration: none; }
.btn:disabled { opacity: .55; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(24, 24, 27, .06); }
.btn.sm { height: 28px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn.wide { width: 100%; height: 40px; }
.btn.ok { color: var(--ok); border-color: #BBE5C9; background: var(--ok-tint); }
.btn.ok:hover { background: #DCF7E6; }
.btn.danger-text { color: var(--danger); }
.link { border: 0; background: none; padding: 0; color: var(--soft); font: inherit; cursor: pointer; }
.link:hover { color: var(--ink); text-decoration: underline; }
.icon-btn { display: inline-grid; place-items: center; width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--soft); cursor: pointer; }
.icon-btn:hover { background: rgba(24, 24, 27, .06); color: var(--ink); text-decoration: none; }
input, select, textarea { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; }
input, select { height: 36px; padding: 0 10px; }
textarea { width: 100%; padding: 8px 10px; resize: vertical; min-height: 64px; line-height: 1.45; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46, 91, 255, .18); }
label { display: grid; gap: 6px; font-weight: 550; font-size: 13px; }
label.check { display: inline-flex; align-items: center; gap: 6px; font-weight: 450; color: var(--soft); white-space: nowrap; cursor: pointer; }
label.check input { width: 15px; height: 15px; margin: 0; accent-color: var(--accent); }
.row { display: flex; gap: 8px; align-items: center; }
.row.end { justify-content: flex-end; }
.stack { display: grid; gap: 14px; }
.badge { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 11px; background: #F1F1F3; color: var(--soft); font-size: 12px; font-weight: 550; white-space: nowrap; }
.badge.open { background: var(--accent-tint); color: var(--accent-ink); }
.alert { padding: 10px 12px; border-radius: 8px; background: #FEF2F2; color: var(--danger); border: 1px solid #FECACA; }
.notice { padding: 10px 12px; border-radius: 8px; background: var(--ok-tint); color: var(--ok); border: 1px solid #BBE5C9; margin-bottom: 16px; }
.avatar { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: #E0E7FF; color: #3730A3; font-size: 11.5px; font-weight: 650; flex: none; }
.avatar.sm { width: 24px; height: 24px; font-size: 10.5px; vertical-align: middle; margin-right: 4px; }

/* ---------- app chrome ---------- */
.top { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; gap: 20px; height: 56px; padding: 0 20px;
  background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; align-items: center; gap: 8px; color: var(--ink); font-weight: 650; font-size: 15px; }
.brand svg { color: var(--accent); }
.brand:hover { text-decoration: none; }
.brand.big { font-size: 18px; margin-bottom: 20px; }
.brand.big svg { width: 28px; height: 28px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 10px; border-radius: 7px; color: var(--soft); font-weight: 550; }
.nav a:hover { background: #F4F4F5; color: var(--ink); text-decoration: none; }
.nav a.on { color: var(--ink); background: #F1F1F3; }
.who { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who-name { font-weight: 550; }
.page { max-width: 1040px; margin: 0 auto; padding: 32px 20px 64px; }
.page.narrow { max-width: 640px; }
.page-head { display: grid; gap: 6px; margin-bottom: 24px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; color: var(--soft); margin-bottom: 12px; font-weight: 550; }

/* ---------- sign in ---------- */
body.auth { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 32px 28px; box-shadow: var(--shadow); display: grid; gap: 16px; }
.auth-card h1 { font-size: 22px; }

/* ---------- projects ---------- */
.projects { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.project { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; box-shadow: var(--shadow); }
.project-main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.project-name { font-size: 16px; font-weight: 650; color: var(--ink); }
.versions { display: grid; gap: 10px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.vgroup { display: grid; grid-template-columns: 150px 1fr; gap: 12px; align-items: start; }
.vgroup-label { color: var(--soft); font-size: 12.5px; padding-top: 5px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); color: var(--ink); font-size: 13px; font-weight: 500; }
.chip:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
.chip-n { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 650; }
.empty-card { background: var(--surface); border: 1px dashed var(--line-strong); border-radius: 12px; padding: 32px; text-align: center; display: grid; gap: 8px; }

/* ---------- settings ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px; }
.card-head { display: grid; gap: 4px; margin-bottom: 14px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 12px; font-weight: 600; color: var(--soft); padding: 8px 10px; border-bottom: 1px solid var(--line); }
.table td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr.off td { color: var(--faint); }
.table .actions { text-align: right; white-space: nowrap; }
.table .actions form { display: inline; }
.table .actions .btn + .btn, .table .actions form + form, .table .actions a + form { margin-left: 4px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 10px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.inline-form h3 { width: 100%; }
.inline-form label { min-width: 160px; }
.inline-form label.grow { flex: 1; min-width: 240px; }
.inline-form .btn { height: 36px; }
.form-note { margin-top: 12px; }
.invite-box { background: var(--accent-tint); border: 1px solid #C7D2FE; border-radius: 12px; padding: 16px; margin-bottom: 20px; display: grid; gap: 10px; }
.invite-box input { flex: 1; min-width: 0; }

/* ---------- review screen ---------- */
body.review-body { height: 100vh; height: 100dvh; display: flex; flex-direction: column; overflow: hidden; }
.rbar { flex: none; display: flex; align-items: center; gap: 10px; height: 56px; padding: 0 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.rtitle { display: flex; align-items: center; gap: 10px; min-width: 0; }
.pname { font-weight: 650; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vselect select { height: 32px; max-width: 220px; font-weight: 500; }
.widths { display: inline-flex; padding: 3px; gap: 2px; background: #F1F1F3; border-radius: 9px; margin-left: 8px; }
.widths button { height: 28px; padding: 0 11px; border: 0; border-radius: 7px; background: transparent; color: var(--soft); font: 550 12.5px/1 var(--font); cursor: pointer; }
.widths button:hover { color: var(--ink); }
.widths button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.wlabel { min-width: 90px; font-variant-numeric: tabular-nums; }
#mode.on { background: var(--ink); border-color: var(--ink); }
#mode.on:hover { background: #000; }
.list-toggle { display: none; }
.list-toggle span { min-width: 14px; }

.review { flex: 1; display: flex; min-height: 0; }
.stage { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--stage);
  background-image: radial-gradient(rgba(24, 24, 27, .07) 1px, transparent 1px); background-size: 16px 16px; display: flex; align-items: center; justify-content: center; }
.device { position: relative; overflow: hidden; background: #fff; box-shadow: var(--shadow-lg); border-radius: 6px; }
.device.phone { border-radius: 22px; outline: 8px solid #18181B; outline-offset: 0; }
.device iframe { display: block; border: 0; background: #fff; transform-origin: 0 0; }
.hint { position: absolute; left: 50%; bottom: 18px; transform: translateX(-50%); padding: 8px 14px; border-radius: 20px; background: var(--ink); color: #fff; font-weight: 550; font-size: 13px; box-shadow: var(--shadow-lg); white-space: nowrap; pointer-events: none; }
.hint .muted { color: #A1A1AA; }
.banner { position: absolute; left: 16px; right: 16px; top: 16px; max-width: 560px; margin: 0 auto; padding: 12px 14px; border-radius: 10px; background: #FFFBEB; color: #78350F; border: 1px solid #FDE68A; box-shadow: var(--shadow-lg); }

.side { flex: none; width: 380px; display: flex; flex-direction: column; min-height: 0; min-width: 0; overflow: hidden; background: var(--surface); border-left: 1px solid var(--line); }
.side-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 0; }
.side-close { display: none; margin-left: auto; }
.tabs { display: flex; gap: 2px; }
.tabs button { height: 34px; padding: 0 10px; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--soft); font: 600 13px/1 var(--font); cursor: pointer; }
.tabs button span { margin-left: 3px; color: var(--faint); font-weight: 550; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.side-filters { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.side-filters select { height: 30px; font-size: 13px; }
.composer { grid-template-columns: minmax(0, 1fr); margin: 12px; padding: 12px; border: 1px solid var(--accent); border-radius: var(--radius); background: var(--accent-tint); display: grid; gap: 10px; box-shadow: 0 0 0 3px rgba(46, 91, 255, .12); }
.composer-target { display: grid; gap: 2px; font-size: 12.5px; min-width: 0; }
.ct-label { font-size: 13.5px; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-meta { color: var(--soft); white-space: nowrap; }
.composer textarea { background: #fff; }
.kbd-hint { margin-right: auto; }
.clist { list-style: none; margin: 0; padding: 8px; overflow-y: auto; overflow-x: hidden; grid-template-columns: minmax(0, 1fr); flex: 1; min-height: 0; display: grid; align-content: start; gap: 8px; }
.clist:empty { display: none; }
.side-empty { padding: 28px 20px; text-align: center; display: grid; gap: 6px; color: var(--soft); }
.citem { border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; background: var(--surface); cursor: pointer; display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; min-width: 0; transition: border-color .12s, box-shadow .12s; }
.citem:hover { border-color: var(--line-strong); }
.citem.sel { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(46, 91, 255, .14); }
.citem.resolved .cnum { background: #71717A; }
.citem.deleted { background: var(--surface-2); }
.citem.deleted .cnum { background: var(--faint); }
.chead { display: flex; align-items: center; gap: 8px; min-width: 0; }
.cnum { display: inline-grid; place-items: center; min-width: 24px; height: 22px; padding: 0 6px; border-radius: 11px 11px 11px 3px; background: var(--accent); color: #fff; font-size: 11.5px; font-weight: 700; flex: none; }
.cauthor { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctime { font-size: 12.5px; white-space: nowrap; }
.cwidth { margin-left: auto; font-size: 11.5px; font-weight: 550; color: var(--soft); background: #F1F1F3; padding: 2px 7px; border-radius: 6px; white-space: nowrap; }
.cwidth.other { color: var(--warn); background: #FFF7ED; }
.cbody { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; }
.ctarget { font-size: 12.5px; color: var(--soft); overflow-wrap: anywhere; }
.ctarget code { font-size: 11.5px; }
.cpage { color: var(--soft); }
.cwarn { display: block; margin-top: 4px; color: var(--warn); font-weight: 550; }
.cwarn.soft { color: var(--soft); font-weight: 450; }
.cshot-btn { display: block; padding: 0; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #F4F4F5; cursor: zoom-in; width: 100%; }
.cshot { display: block; width: 100%; height: 150px; object-fit: cover; object-position: center; }
.cshot-wait { height: 44px; display: grid; place-items: center; border: 1px dashed var(--line-strong); border-radius: 8px; color: var(--soft); font-size: 12.5px; }
.thread { list-style: none; margin: 0; padding: 0 0 0 10px; border-left: 2px solid var(--line); display: grid; gap: 8px; }
.treply p, .tevent p { white-space: pre-wrap; overflow-wrap: anywhere; }
.tmeta { font-size: 12.5px; }
.treply.bot .tmeta strong { color: var(--accent-ink); }
.tevent { font-size: 12.5px; color: var(--soft); }
.tevent.resolved > span:first-child { color: var(--ok); font-weight: 550; }
.tevent.reopened > span:first-child { color: var(--warn); font-weight: 550; }
.tevent p { color: var(--ink); margin-top: 2px; }
.cactions { display: flex; flex-wrap: wrap; gap: 6px; }
.cform { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }

.lightbox { position: fixed; inset: 0; z-index: 50; background: rgba(9, 9, 11, .82); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; box-shadow: var(--shadow-lg); background: #fff; }
.lightbox .icon-btn { position: absolute; top: 12px; right: 12px; color: #fff; background: rgba(255, 255, 255, .12); }
.toast { position: fixed; left: 50%; top: 68px; transform: translateX(-50%); z-index: 60; padding: 10px 16px; border-radius: 10px; background: var(--ink); color: #fff; font-weight: 550; box-shadow: var(--shadow-lg); max-width: calc(100vw - 32px); }

@media (prefers-reduced-motion: no-preference) {
  .toast:not([hidden]) { animation: rise .2s ease-out; }
  @keyframes rise { from { opacity: 0; transform: translate(-50%, -8px); } }
}

/* ---------- smaller screens ---------- */
@media (max-width: 1180px) {
  .wlabel { display: none; }
  .side { width: 340px; }
}
@media (max-width: 900px) {
  .list-toggle { display: inline-flex; }
  .side { position: fixed; z-index: 30; right: 0; top: 56px; bottom: 0; width: min(400px, 100vw); box-shadow: var(--shadow-lg);
    transform: translateX(105%); transition: transform .22s ease; }
  body.side-open .side { transform: none; }
  .side-close { display: inline-grid; }
  .widths { margin-left: 0; }
}
@media (max-width: 640px) {
  .top { gap: 12px; padding: 0 12px; }
  .who-name { display: none; }
  .page { padding: 24px 16px 48px; }
  .vgroup { grid-template-columns: 1fr; gap: 6px; }
  .vgroup-label { padding-top: 0; }
  .rbar { gap: 6px; padding: 0 6px; }
  .widths, #openTab { display: none; }
  .vselect select { max-width: 132px; }
  #mode span { display: none; }
  #mode { padding: 0 10px; }
  /* The sheet sits on top of the on-screen keyboard: --kb (keyboard overlap) and --vvh (visible height)
     come from visualViewport in review.js. */
  .side { top: auto; bottom: var(--kb, 0px); height: min(78dvh, 640px, calc(var(--vvh, 100dvh) - 16px)); width: 100vw; border-left: 0;
    border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; transform: translateY(calc(105% + var(--kb, 0px))); }
  /* Writing a comment: the sheet holds only the composer, sized to its content. */
  body.composing .side { height: auto; max-height: calc(var(--vvh, 100dvh) - 16px); }
  body.composing .side-head, body.composing .side-filters, body.composing .clist, body.composing .side-empty { display: none !important; }
  body.composing .composer { margin: 12px 12px calc(12px + env(safe-area-inset-bottom)); overflow-y: auto; }
  .composer textarea { min-height: 88px; }
  .hint { bottom: 12px; }
  .table thead { display: none; }
  .table tr { display: grid; padding: 10px 0; border-bottom: 1px solid var(--line); }
  .table td { border: 0; padding: 3px 0; }
  .table td[data-label]::before { content: attr(data-label) ": "; color: var(--soft); font-size: 12px; }
  .table .actions { text-align: left; white-space: normal; padding-top: 6px; }
  .inline-form label, .inline-form label.grow { min-width: 100%; }
}
@media (max-width: 640px), (pointer: coarse) { .kbd-hint, .hint .muted { display: none; } }
/* iPhone Safari zooms the whole page into any field with text under 16px (and the zoom pushes the
   composer and its buttons off screen). 16px on touch screens and small windows. */
@media (max-width: 900px), (pointer: coarse) {
  input, select, textarea { font-size: 16px; }
}
@media (max-width: 420px) {
  .rtitle .pname { display: none; }
  .rtitle { flex: 1; }
  .vselect { flex: 1; min-width: 0; }
  .vselect select { width: 100%; max-width: none; }
  .rbar .spacer { display: none; }
}
@media (prefers-reduced-motion: reduce) { .side { transition: none; } }
