/* ============================================================
   Yarn Diary — crochet tracker
   Design tokens follow the "soft yarn" palette.
   ============================================================ */

@font-face {
  font-family: 'Quicksand';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/quicksand-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Quicksand';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/quicksand-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

/* Comfortaa carries the wordmark only — rounder than Quicksand, which is what
   makes "yarndiary" read as a mark rather than as a line of interface text. */
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/comfortaa-latin.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC,
    U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'Comfortaa';
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url(../fonts/comfortaa-latin-ext.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304,
    U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0,
    U+2113, U+2C60-2C7F, U+A720-A7FF;
}

:root {
  --bg: #f7f4f1;
  --surf: #fff;
  --surf2: #f0ecf4;
  --warm: #f0ece6;
  --text: #3b3540;
  --muted: #8d8892;
  --line: #e6e0ea;
  --lil: #a89bc4;
  --lil-deep: #7d6ca3;
  --lils: #f4f0f8;
  --sage: #7f9a7c;
  --sage-deep: #5e7a5b;
  --sages: #eaf1ea;
  --amber: #b8894a;
  --terra: #c98f6a;
  --terras: #f7ece5;
  --ambers: #f7efe3;
  --danger: #b4635f;
  --dangers: #f7ebea;
  --on-acc: #fff;
  --sh: 0 8px 24px rgba(59, 53, 64, .07);
  --sh2: 0 14px 40px rgba(59, 53, 64, .10);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --rail-w: 232px;
  --r-lg: 22px;
  --r-md: 18px;
  --r-sm: 14px;
}

[data-theme="dark"] {
  --bg: oklch(0.185 0.014 300);
  --surf: oklch(0.235 0.018 300);
  --surf2: oklch(0.285 0.02 300);
  --warm: oklch(0.27 0.012 60);
  --text: oklch(0.94 0.01 300);
  --muted: oklch(0.72 0.015 300);
  --line: oklch(0.33 0.02 300);
  --lil: oklch(0.79 0.08 300);
  --lil-deep: oklch(0.86 0.09 300);
  --lils: oklch(0.30 0.04 300);
  --sage: oklch(0.80 0.07 148);
  --sage-deep: oklch(0.86 0.08 148);
  --sages: oklch(0.30 0.035 148);
  --amber: oklch(0.82 0.09 70);
  --ambers: oklch(0.31 0.04 70);
  --terra: oklch(0.80 0.08 55);
  --terras: oklch(0.31 0.04 55);
  --danger: oklch(0.76 0.10 25);
  --dangers: oklch(0.30 0.045 25);
  --on-acc: oklch(0.22 0.02 300);
  --sh: 0 8px 24px rgba(0, 0, 0, .3);
  --sh2: 0 16px 44px rgba(0, 0, 0, .34);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Quicksand, system-ui, -apple-system, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}

a { color: var(--lil-deep); text-decoration: none; }
a:hover { color: var(--text); }

button {
  font: inherit;
  color: inherit;
  border: 0;
  background: none;
  cursor: pointer;
  text-align: left;
  padding: 0;
}

input, textarea, select {
  font: inherit;
  color: var(--text);
  background: var(--surf2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  padding: 11px 14px;
  width: 100%;
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--lil);
  background: var(--surf);
}
textarea { resize: vertical; line-height: 1.6; }

:focus-visible { outline: 2px solid var(--lil); outline-offset: 2px; }

h1, h2, h3 { margin: 0; font-weight: 700; letter-spacing: -.02em; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 99px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================================ layout */

.app { display: flex; min-height: 100%; }

.rail {
  width: var(--rail-w);
  flex: none;
  background: var(--surf);
  border-right: 1px solid var(--line);
  padding: 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.rail-brand { display: flex; align-items: center; gap: 10px; padding: 0 6px; }
/* The mark sits on a pale disc, the full two-colour drawing rather than a
   cut-down one — at 26px the hook still reads. */
.brand-badge {
  width: 34px; height: 34px; border-radius: 99px;
  background: var(--lils); display: grid; place-items: center; flex: none;
}
.brand-mark { width: 21px; height: 21px; display: block; object-fit: contain; }

/* The mark is drawn for a light ground: its hook is near-black, so on the dark
   theme's own --lils the hook disappears into the disc. Keeping the disc light
   in dark mode preserves the artwork as drawn rather than recolouring it. */
[data-theme="dark"] .brand-badge { background: oklch(0.88 0.035 300); }

/* The wordmark is one lowercase word in two weights: "yarn" medium, "diary"
   bold and lilac. Set in Comfortaa, never in the interface font. */
.brand-name {
  font-family: 'Comfortaa', 'Quicksand', system-ui, sans-serif;
  font-weight: 500; font-size: 17px; letter-spacing: -.005em;
}
.brand-name b { font-weight: 700; color: var(--lil); }

.rail-nav { display: flex; flex-direction: column; gap: 4px; }
.rail-nav button {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 12px; border-radius: var(--r-sm);
  font-size: 14px; font-weight: 500; color: var(--muted);
}
.rail-nav button .ico { font-size: 15px; width: 18px; text-align: center; }
.rail-nav button:hover { background: var(--surf2); color: var(--text); }
.rail-nav button[aria-current="page"] { background: var(--lils); color: var(--lil-deep); font-weight: 700; }

.rail-current { display: flex; flex-direction: column; gap: 8px; }
.rail-current .lbl {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; padding: 0 12px;
}
.rail-current button {
  padding: 12px; border-radius: var(--r-md); background: var(--lils);
  display: flex; flex-direction: column; gap: 8px; width: 100%;
}
.rail-spacer { flex: 1; }
.rail-theme {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 12px; border-radius: var(--r-sm);
  background: var(--surf2); font-size: 13px; font-weight: 600;
}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: flex-end; gap: 14px;
  padding: 20px 28px 14px;
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
}
.topbar-titles { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.topbar-crumb { font-size: 12px; color: var(--muted); font-weight: 600; }
.topbar-title { font-size: 25px; }
.topbar-sub { font-size: 13px; color: var(--muted); }
.topbar-actions { display: flex; gap: 8px; align-items: center; flex: none; }
.topbar-back, .topbar-theme {
  width: 36px; height: 36px; border-radius: 99px; background: var(--surf2);
  display: grid; place-items: center; font-size: 16px; flex: none;
}
.topbar-back { display: none; }
.topbar-theme { display: none; }

.view { padding: 22px 28px 60px; flex: 1; }

.tabbar { display: none; }

@media (max-width: 900px) {
  .rail { display: none; }
  .topbar { padding: 14px 16px 12px; align-items: center; }
  .topbar-title { font-size: 19px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-sub { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-crumb { display: none; }
  .topbar-back:not([hidden]) { display: grid; }
  .topbar-theme { display: grid; }
  .topbar-actions { display: none; }
  .view { padding: 16px 16px calc(96px + env(safe-area-inset-bottom)); }

  .tabbar {
    display: flex; gap: 4px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--surf); border-top: 1px solid var(--line);
    padding: 8px 10px calc(12px + env(safe-area-inset-bottom));
  }
  .tabbar button {
    flex: 1; padding: 8px 4px; border-radius: var(--r-md);
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: var(--muted);
  }
  .tabbar button .ico { font-size: 17px; line-height: 1; }
  .tabbar button .lbl { font-size: 10px; font-weight: 700; }
  .tabbar button[aria-current="page"] { background: var(--lils); color: var(--lil-deep); }
}

/* ============================================================ primitives */

.card {
  background: var(--surf);
  border-radius: var(--r-lg);
  padding: 18px;
  box-shadow: var(--sh);
}
.card-flush { padding: 0; overflow: hidden; }

.btn {
  padding: 11px 18px; border-radius: 99px;
  background: var(--surf2); color: var(--text);
  font-size: 13px; font-weight: 700; text-align: center;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  transition: filter .15s ease;
  min-height: 42px;
}
.btn:hover { filter: brightness(.96); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--lil); color: var(--on-acc); }
.btn-sage { background: var(--sage); color: var(--on-acc); }
.btn-danger { background: var(--dangers); color: var(--danger); }
.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--surf2); }
.btn-block { display: flex; width: 100%; }
.btn-lg { padding: 14px 22px; font-size: 14px; min-height: 50px; }
.btn-sm { padding: 8px 13px; font-size: 12px; min-height: 34px; }

.chip {
  font-size: 11px; font-weight: 700; padding: 6px 11px; border-radius: 99px;
  background: var(--warm); color: var(--muted);
  display: inline-flex; align-items: center; gap: 5px;
}
.chip-lil { background: var(--lils); color: var(--lil-deep); }
.chip-sage { background: var(--sages); color: var(--sage-deep); }
.chip-amber { background: var(--ambers); color: var(--amber); }
.chip-mono { font-family: var(--mono); }

.bar { height: 8px; border-radius: 99px; background: var(--surf2); display: block; overflow: hidden; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--lil); transition: width .3s ease; }
.bar.done > i { background: var(--sage); }
.bar-lg { height: 10px; }

.seg { display: flex; gap: 5px; background: var(--surf2); padding: 4px; border-radius: 99px; }
.seg button {
  flex: 1; padding: 9px 16px; border-radius: 99px;
  font-size: 13px; font-weight: 700; text-align: center; color: var(--muted);
  white-space: nowrap;
}
.seg button[aria-pressed="true"] { background: var(--surf); color: var(--text); box-shadow: var(--sh); }

.pillrow { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.pillrow::-webkit-scrollbar { display: none; }
.pill {
  flex: none; font-size: 12px; font-weight: 700;
  padding: 8px 14px; border-radius: 99px;
  background: var(--surf); color: var(--muted); box-shadow: var(--sh);
}
.pill[aria-pressed="true"] { background: var(--lil); color: var(--on-acc); }
.pill.is-done[aria-pressed="false"] { color: var(--sage-deep); }

.field { display: flex; flex-direction: column; gap: 7px; }
.field > label, .lbl-cap {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 700;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; }
.row-wrap { flex-wrap: wrap; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.tiny { font-size: 11px; }
.mono { font-family: var(--mono); }
.grow { flex: 1; min-width: 0; }
.center { text-align: center; }
.prose { font-size: 13px; line-height: 1.6; color: var(--muted); text-wrap: pretty; }

.sec-title { font-weight: 700; font-size: 15px; }

.empty {
  border: 2px dashed var(--line); border-radius: var(--r-lg);
  padding: 40px 24px; text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  color: var(--muted);
}
.empty .big { font-size: 26px; }
.empty .hd { font-size: 15px; font-weight: 700; color: var(--text); }
.empty p { margin: 0; font-size: 12px; line-height: 1.55; max-width: 320px; }

.stepper {
  display: flex; align-items: center; gap: 7px;
  background: var(--surf2); border-radius: 99px; padding: 5px;
}
.stepper button {
  width: 36px; height: 36px; border-radius: 99px; background: var(--surf);
  font-size: 18px; display: grid; place-items: center; flex: none;
}
.stepper .val { flex: 1; text-align: center; font-weight: 700; font-size: 16px; }

.divider { height: 1px; background: var(--line); }

/* ============================================================ projects list */

.proj-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
@media (max-width: 1180px) { .proj-grid { grid-template-columns: 1fr; } }

.proj-card {
  background: var(--surf); border-radius: var(--r-lg); padding: 14px;
  display: flex; gap: 14px; box-shadow: var(--sh); width: 100%;
  transition: transform .15s ease, box-shadow .15s ease;
}
.proj-card:hover { transform: translateY(-2px); box-shadow: var(--sh2); }
.proj-thumb {
  width: 104px; height: 104px; border-radius: var(--r-md);
  background: var(--warm); flex: none; overflow: hidden;
  display: grid; place-items: center; color: var(--muted); font-size: 26px;
}
.proj-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.proj-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 7px; justify-content: center; }
.proj-name { font-weight: 700; font-size: 17px; letter-spacing: -.01em; }
@media (max-width: 900px) {
  .proj-thumb { width: 84px; height: 84px; }
  .proj-name { font-size: 16px; }
}

/* ============================================================ project detail */

.proj-layout { display: grid; grid-template-columns: 1.15fr .85fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .proj-layout { grid-template-columns: 1fr; } }

.donut {
  width: 96px; height: 96px; border-radius: 99px; flex: none;
  display: grid; place-items: center;
}
.donut > span {
  width: 72px; height: 72px; border-radius: 99px; background: var(--surf);
  display: grid; place-items: center; font-size: 19px; font-weight: 700;
}
@media (max-width: 900px) {
  .donut { width: 74px; height: 74px; }
  .donut > span { width: 56px; height: 56px; font-size: 15px; }
}

.part-row {
  background: var(--surf); border-radius: var(--r-md); padding: 14px 16px;
  display: flex; align-items: center; gap: 14px; box-shadow: var(--sh); width: 100%;
}
.part-row:hover { filter: brightness(.985); }
.part-icon {
  width: 34px; height: 34px; border-radius: 99px; flex: none;
  display: grid; place-items: center; font-size: 14px; font-weight: 700;
  background: var(--lils); color: var(--lil-deep);
}
.part-row.is-done .part-icon { background: var(--sages); color: var(--sage-deep); }
.part-name { flex: 1; font-weight: 700; font-size: 15px; }
.part-bar { width: 180px; flex: none; }
.part-count { width: 82px; text-align: right; font-size: 12px; font-weight: 700; color: var(--muted); flex: none; }
@media (max-width: 760px) {
  .part-row { flex-wrap: wrap; }
  .part-bar { width: 100%; order: 3; }
  .part-count { width: auto; }
}

.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-cell { display: flex; flex-direction: column; gap: 6px; position: relative; }
.photo-cell .frame {
  height: 150px; border-radius: var(--r-md); background: var(--warm);
  overflow: hidden; display: grid; place-items: center;
}
.photo-cell .frame img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-cell .cap { font-size: 11px; color: var(--muted); font-weight: 600; }
.photo-del {
  position: absolute; top: 6px; right: 6px;
  width: 26px; height: 26px; border-radius: 99px;
  background: rgba(20, 16, 24, .6); color: #fff;
  display: grid; place-items: center; font-size: 13px;
  opacity: 0; transition: opacity .15s ease;
}
.photo-cell:hover .photo-del, .photo-cell:focus-within .photo-del { opacity: 1; }
@media (hover: none) { .photo-del { opacity: 1; } }

.photo-strip { display: flex; gap: 9px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.photo-strip::-webkit-scrollbar { display: none; }
.photo-strip .photo-cell { flex: none; width: 106px; }
.photo-strip .frame { width: 106px; height: 132px; }

.dropzone {
  border: 2px dashed var(--line); border-radius: var(--r-md);
  padding: 20px; text-align: center; color: var(--muted); font-size: 13px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  width: 100%;
}
.dropzone.is-over { border-color: var(--lil); background: var(--lils); color: var(--lil-deep); }
.dropzone-sm { padding: 14px; font-size: 12px; }

/* ============================================================ round tracker */

.part-layout { display: grid; grid-template-columns: 1fr 330px; gap: 20px; align-items: start; }
.part-side { display: flex; flex-direction: column; gap: 14px; position: sticky; top: 96px; }

/* On narrow screens the progress and tap counter belong above the round list,
   not below it — they are what you look at while stitching. */
@media (max-width: 1100px) {
  .part-layout { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
  .part-side { display: contents; }
  .part-progress { order: 1; }
  .counter { order: 2; }
  .part-main { order: 3; }
  .part-extras { order: 4; display: flex; flex-direction: column; gap: 14px; }
}

.round {
  background: var(--surf); border: 1px solid var(--line);
  border-radius: var(--r-md); padding: 13px 16px;
  display: flex; gap: 16px; align-items: center;
  transition: background .2s ease, border-color .2s ease;
}
.round.is-current { border-color: var(--lil); box-shadow: 0 0 0 3px var(--lils); }
.round.is-done { background: var(--sages); border-color: transparent; }
.round.is-done .round-instr { text-decoration: line-through; text-decoration-color: var(--sage); opacity: .8; }
.round.has-issue { border-color: var(--amber); }

.round-n {
  font-weight: 700; font-size: 30px; letter-spacing: -.03em; line-height: 1;
  min-width: 46px; flex: none; color: var(--text); font-variant-numeric: tabular-nums;
}
.round.is-done .round-n { color: var(--sage-deep); }
.round.is-current .round-n { color: var(--lil-deep); }
.round-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.round-instr { font-size: 16px; font-weight: 600; line-height: 1.35; }
.round-note {
  font-size: 12px; color: var(--muted); line-height: 1.45;
  border-left: 2px solid var(--lil); padding-left: 8px;
}
.round-flag {
  font-size: 11px; font-weight: 700; color: var(--amber);
  display: flex; align-items: center; gap: 5px;
}
.round-count {
  font-family: var(--mono); font-size: 12px; font-weight: 700;
  padding: 4px 9px; border-radius: 9px; background: var(--surf2); flex: none;
}
.round.is-done .round-count { background: color-mix(in srgb, var(--sage) 18%, transparent); }
.round-check {
  width: 32px; height: 32px; border-radius: 99px; flex: none;
  border: 2px solid var(--line); background: transparent; color: var(--muted);
  display: grid; place-items: center; font-size: 15px; font-weight: 700;
}
.round.is-done .round-check { border-color: var(--sage); background: var(--sage); color: var(--on-acc); }

@media (max-width: 700px) {
  .round { padding: 12px 14px; gap: 13px; align-items: flex-start; }
  .round-n { font-size: 26px; min-width: 34px; }
  .round-instr { font-size: 15px; }
  .round-check { width: 30px; height: 30px; font-size: 14px; }
  .round-count { font-size: 11px; padding: 3px 8px; }
}

.counter { background: var(--lils); border-radius: var(--r-lg); padding: 18px; display: flex; flex-direction: column; gap: 12px; }
.counter .info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.counter .cap { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--lil-deep); font-weight: 700; }
.counter .big { font-weight: 700; font-size: 34px; letter-spacing: -.03em; line-height: 1; font-variant-numeric: tabular-nums; }
.counter .btns { display: flex; gap: 9px; }
.counter .btns button { height: 52px; border-radius: 99px; display: grid; place-items: center; font-size: 22px; font-weight: 700; }
.counter .minus { width: 52px; flex: none; background: var(--surf); }
.counter .plus { flex: 1; background: var(--lil); color: var(--on-acc); }
.counter.is-full .big { color: var(--sage-deep); }

@media (max-width: 1100px) {
  .counter { position: sticky; top: 84px; z-index: 10; flex-direction: row; align-items: center; gap: 14px; }
  .counter .info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
  .counter .big { font-size: 28px; }
  .counter .btns { flex: none; flex-direction: column; gap: 6px; }
  .counter .btns button { height: 48px; }
  .counter .minus { width: 54px; height: 40px; }
  .counter .plus { width: 54px; }
}

/* ============================================================ pattern input */

.new-layout { display: grid; grid-template-columns: .9fr 1.1fr; gap: 20px; align-items: start; }
@media (max-width: 1100px) { .new-layout { grid-template-columns: 1fr; } }

.scanzone {
  border: 2px dashed var(--lil); border-radius: var(--r-lg);
  padding: 38px 20px; background: var(--lils);
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-align: center; width: 100%;
}
.scanzone .big { font-size: 28px; }
.scanzone .hd { font-weight: 700; font-size: 16px; color: var(--text); }
.scanzone.is-over { background: color-mix(in srgb, var(--lil) 22%, var(--lils)); }

.notation-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.notation-tags span {
  font-family: var(--mono); font-size: 11px;
  padding: 5px 8px; border-radius: 8px; background: var(--surf2);
}

.ocr-row {
  background: var(--surf); border: 1px solid var(--line); border-radius: var(--r-sm);
  padding: 12px 14px; display: flex; gap: 12px; align-items: flex-start; width: 100%;
}
.ocr-row.has-flag { border-color: var(--amber); }
.ocr-row.is-skipped { opacity: .45; }
.ocr-row .n { font-weight: 700; font-size: 20px; min-width: 46px; flex: none; letter-spacing: -.02em; }
.ocr-row .body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.ocr-row .edit { color: var(--muted); font-size: 13px; flex: none; }

.builder-preview {
  font-family: var(--mono); font-size: 14px;
  background: var(--surf2); border-radius: var(--r-sm); padding: 12px 14px;
  line-height: 1.5; word-break: break-word;
}
.seg-chips { display: flex; flex-wrap: wrap; gap: 7px; }
.seg-chip {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  padding: 9px 12px; border-radius: 99px; background: var(--surf2);
}
.seg-chip[aria-pressed="true"] { background: var(--lils); color: var(--lil-deep); }
.seg-chip.is-part { background: var(--lils); color: var(--lil-deep); display: inline-flex; align-items: center; gap: 6px; }
.seg-chip.is-part .x { opacity: .6; font-size: 15px; }

/* ============================================================ stitch guide */

.stitch-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 1100px) { .stitch-grid { grid-template-columns: 1fr; } }

.stitch-card {
  background: var(--surf); border-radius: var(--r-lg); padding: 16px;
  display: flex; flex-direction: column; gap: 8px; box-shadow: var(--sh);
}
.stitch-abbr {
  font-family: var(--mono); font-size: 13px; font-weight: 700;
  padding: 4px 9px; border-radius: 99px; background: var(--lils); color: var(--lil-deep); flex: none;
}
.stitch-name { font-weight: 700; font-size: 16px; }
.stitch-desc { font-size: 13px; line-height: 1.55; text-wrap: pretty; }
.stitch-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: auto; }

.cat-head {
  font-size: 11px; letter-spacing: .1em; text-transform: uppercase;
  color: var(--muted); font-weight: 700; grid-column: 1 / -1; padding-top: 6px;
}

/* ============================================================ lightbox */

.lightbox {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(26, 22, 30, .96);
  display: flex; flex-direction: column;
  touch-action: none;
}
.lb-top {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: calc(16px + env(safe-area-inset-top)) 20px 12px; color: #f6f3f8; flex: none;
}
.lb-tag { font-size: 13px; opacity: .8; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-stage { flex: 1; overflow: hidden; position: relative; display: grid; place-items: center; }
.lb-stage img {
  max-width: 100%; max-height: 100%; display: block;
  transform-origin: 0 0; will-change: transform;
  user-select: none; -webkit-user-drag: none;
}
.lb-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 22px calc(22px + env(safe-area-inset-bottom)); color: #f6f3f8; flex: none;
}
.lb-btn {
  width: 44px; height: 44px; border-radius: 99px; flex: none;
  background: rgba(255, 255, 255, .14); color: #fff;
  display: grid; place-items: center; font-size: 19px;
}
.lb-btn:hover { background: rgba(255, 255, 255, .24); }
.lb-track { flex: 1; height: 4px; border-radius: 99px; background: rgba(255, 255, 255, .22); }
.lb-track > i { display: block; height: 100%; border-radius: 99px; background: #fff; }
.lb-zoom { font-size: 12px; opacity: .75; width: 46px; flex: none; font-variant-numeric: tabular-nums; }
.lb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  width: 46px; height: 68px; border-radius: 14px;
  background: rgba(255, 255, 255, .12); color: #fff;
  display: grid; place-items: center; font-size: 24px;
}
.lb-nav.prev { left: 12px; }
.lb-nav.next { right: 12px; }
@media (max-width: 900px) { .lb-nav { display: none; } }

/* ============================================================ modal */

.modal-scrim {
  position: fixed; inset: 0; z-index: 90;
  background: rgba(26, 22, 30, .5);
  display: grid; place-items: center; padding: 20px;
  backdrop-filter: blur(3px);
}
.modal {
  background: var(--surf); border-radius: 24px; box-shadow: var(--sh2);
  width: min(520px, 100%); max-height: min(86vh, 760px);
  display: flex; flex-direction: column; overflow: hidden;
}
.modal-head { padding: 20px 22px 6px; display: flex; flex-direction: column; gap: 3px; }
.modal-head h2 { font-size: 19px; }
.modal-body { padding: 14px 22px; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; }
.modal-foot { padding: 14px 22px calc(20px + env(safe-area-inset-bottom)); display: flex; gap: 9px; border-top: 1px solid var(--line); }
.modal-foot .btn { flex: 1; }
@media (max-width: 620px) {
  .modal-scrim { padding: 0; align-items: flex-end; }
  .modal { width: 100%; max-height: 92vh; border-radius: 24px 24px 0 0; }
}

/* ============================================================ toasts */

.toasts {
  position: fixed; z-index: 200; left: 50%; transform: translateX(-50%);
  bottom: calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 8px; align-items: center;
  pointer-events: none; width: max-content; max-width: calc(100vw - 32px);
}
@media (max-width: 900px) { .toasts { bottom: calc(96px + env(safe-area-inset-bottom)); } }
.toast {
  background: var(--text); color: var(--bg);
  padding: 12px 18px; border-radius: 99px;
  font-size: 13px; font-weight: 600; box-shadow: var(--sh2);
  animation: toast-in .25s ease;
}
.toast.is-bad { background: var(--danger); color: #fff; }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* ============================================================ misc */

.progress-line { height: 4px; background: var(--surf2); border-radius: 99px; overflow: hidden; }
.progress-line > i { display: block; height: 100%; background: var(--lil); transition: width .2s ease; }

.spinner {
  width: 18px; height: 18px; border-radius: 99px;
  border: 2px solid var(--line); border-top-color: var(--lil);
  animation: spin .8s linear infinite; flex: none;
}
@keyframes spin { to { transform: rotate(360deg); } }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
