
/* Layout: a workshop ledger. Desk = sidebar + phase board; phone = stacked phases + bottom bar. Progress is drawn as a line of saddle stitches. */
:root {
  --bg: #EEE8DE;
  --surface: #FAF7F1;
  --sunk: #E5DDD0;
  --ink: #1D1A17;
  --muted: #645B51;
  --line: #D8CDBD;
  --accent: #8F4F29;
  --accent-soft: rgba(143, 79, 41, .11);
  --good: #3D6847;
  --warn: #8A5D0C;
  --bad: #A13827;
  --scrim: rgba(20, 16, 12, .45);
  --shadow: 0 1px 2px rgba(40, 28, 18, .06), 0 10px 30px rgba(40, 28, 18, .08);
  --serif: "Cormorant Garamond", "Iowan Old Style", Georgia, serif;
  --sans: "Manrope", "Helvetica Neue", Arial, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, monospace;
  --gl: max(16px, env(safe-area-inset-left, 0px));
  --gr: max(16px, env(safe-area-inset-right, 0px));
  --sb: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12100E; --surface: #1C1916; --sunk: #171411; --ink: #EEE7DB; --muted: #A69B8B; --line: #322B25;
    --accent: #D9925F; --accent-soft: rgba(217, 146, 95, .14); --good: #86B790; --warn: #DDAE52; --bad: #E58571;
    --scrim: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12100E; --surface: #1C1916; --sunk: #171411; --ink: #EEE7DB; --muted: #A69B8B; --line: #322B25;
  --accent: #D9925F; --accent-soft: rgba(217, 146, 95, .14); --good: #86B790; --warn: #DDAE52; --bad: #E58571;
  --scrim: rgba(0, 0, 0, .6); --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .35); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; }
body { background: var(--bg); color: var(--ink); font-family: var(--sans); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }

/* shell */
.app { display: flex; min-height: 100vh; }
.side { display: none; }
main { flex: 1; min-width: 0; padding-block: 20px calc(var(--sb) + 112px); padding-left: var(--gl); padding-right: var(--gr); }
.wrap { max-width: 1320px; margin: 0 auto; display: flex; flex-direction: column; gap: 20px; }
@media (min-width: 900px) {
  .side { display: flex; flex-direction: column; gap: 22px; position: sticky; top: 0; height: 100vh; width: 240px; flex: 0 0 240px; padding: 26px 18px; background: var(--surface); border-right: 1px solid var(--line); }
  main { padding-block: 32px 64px; padding-left: max(40px, env(safe-area-inset-left, 0px)); padding-right: max(40px, env(safe-area-inset-right, 0px)); }
  .phone-only { display: none !important; }
}
@media (max-width: 899px) { .desk-only { display: none !important; } }

.brand { display: flex; align-items: center; gap: 12px; }
.stamp { width: 40px; height: 40px; border-radius: 50%; border: 1.5px solid var(--ink); display: grid; place-items: center; font-family: var(--serif); font-size: 22px; font-weight: 600; position: relative; }
.stamp::after { content: ""; position: absolute; inset: 3px; border-radius: 50%; border: 1px dashed var(--muted); }
.brand b { display: block; font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1; }
.brand small { color: var(--muted); font-size: 12px; }
.side-nav { display: flex; flex-direction: column; gap: 2px; }
.side-nav button { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 10px; background: none; font-weight: 600; font-size: 14px; color: var(--muted); text-align: left; }
.side-nav button:hover { background: var(--sunk); color: var(--ink); }
.side-nav button[aria-current="page"] { background: var(--sunk); color: var(--ink); }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); }
.linkbtn { background: none; border: 0; padding: 6px 0; text-align: left; color: var(--muted); font-size: 12px; text-decoration: underline; text-underline-offset: 3px; }

.tabbar { position: fixed; z-index: 30; left: 0; right: 0; bottom: 0; display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; gap: 8px; padding: 8px var(--gr) calc(var(--sb) + 8px) var(--gl); background: var(--surface); border-top: 1px solid var(--line); }
.tabbar > button:not(.fab) { display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 48px; justify-content: center; background: none; border: 0; font-size: 11.5px; font-weight: 600; color: var(--muted); }
.tabbar > button[aria-current="page"] { color: var(--ink); }
.tab-new .plus { width: 30px; height: 30px; border-radius: 50%; background: var(--ink); color: var(--bg); display: grid; place-items: center; margin-bottom: 1px; }
.tabbar > button.tab-new { color: var(--ink); }
.fab { width: 56px; height: 56px; border-radius: 50%; border: 0; background: var(--ink); color: var(--bg); display: grid; place-items: center; margin-top: -24px; box-shadow: var(--shadow); }

/* type & atoms */
.kicker { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .16em; text-transform: uppercase; color: var(--muted); }
.h1 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: clamp(34px, 8vw, 46px); line-height: 1.02; letter-spacing: -.01em; text-wrap: balance; }
.h2 { margin: 0; font-family: var(--serif); font-weight: 600; font-size: 26px; line-height: 1.1; }
.lede { margin: 0; color: var(--muted); font-size: 15px; max-width: 60ch; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
.page-head > div { display: flex; flex-direction: column; gap: 6px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, transform .1s; }
.btn:hover { border-color: var(--muted); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--sunk); }
.btn.sm { min-height: 38px; padding: 0 12px; font-size: 13px; border-radius: 9px; }
.btn.block { width: 100%; }
.btn.rec { border-color: var(--bad); color: var(--bad); }
.icon-btn { width: 44px; height: 44px; flex: 0 0 44px; display: grid; place-items: center; border-radius: 10px; border: 1px solid transparent; background: none; color: var(--muted); }
.icon-btn:hover { background: var(--sunk); color: var(--ink); }
.icon-btn.sm { width: 36px; height: 36px; flex-basis: 36px; }
.icon-btn.solid { border-color: var(--line); background: var(--surface); color: var(--ink); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

.tag { display: inline-flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tag::before { content: ""; width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--muted); }
.tag.commission { color: var(--accent); }
.tag.commission::before { background: var(--accent); border-color: var(--accent); }
.due { font-size: 12px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.due.warn { color: var(--warn); }
.due.bad { color: var(--bad); }
.chip { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; background: var(--sunk); font-size: 12px; font-weight: 600; }

/* stitch progress: one slanted stitch per step */
.stitches { display: flex; gap: 6px; align-items: center; }
.stitches i { flex: 1; height: 4px; border-radius: 2px; background: var(--line); transform: skewX(-38deg); }
.stitches i.on { background: var(--ink); }
.stitches i.now { background: var(--accent); }
.stitches.big i { height: 6px; }
.stitches.ticks { gap: 4px; }
.stitches.ticks i { transform: none; height: 6px; border-radius: 1.5px; }
.stitches.ticks.big i { height: 9px; }

/* stats */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
@media (min-width: 700px) { .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.stat { background: var(--surface); padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.stat b { font-family: var(--mono); font-weight: 500; font-size: 22px; font-variant-numeric: tabular-nums; }
.stat span { font-size: 12px; color: var(--muted); }

.seg { display: inline-flex; padding: 3px; border-radius: 11px; background: var(--sunk); gap: 2px; max-width: 100%; overflow-x: auto; }
.seg button { min-height: 38px; padding: 0 14px; border: 0; border-radius: 9px; background: none; font-size: 13px; font-weight: 600; color: var(--muted); white-space: nowrap; }
.seg button[aria-pressed="true"], .seg button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }

/* board */
.board { display: flex; flex-direction: column; gap: 22px; }
@media (min-width: 900px) {
  .board { display: grid; grid-template-columns: repeat(var(--cols, 5), minmax(200px, 1fr)); gap: 14px; overflow-x: auto; padding-bottom: 8px; align-items: start; }
}
.col { display: flex; flex-direction: column; gap: 10px; min-width: 0; }
@media (min-width: 900px) { .col { background: var(--sunk); border-radius: 14px; padding: 10px; min-height: 160px; } }
.col-head { display: flex; align-items: baseline; gap: 8px; padding: 2px 4px; }
.col-head h2 { margin: 0; font-family: var(--serif); font-size: 21px; font-weight: 600; }
.col-head .count { font-family: var(--mono); font-size: 12px; color: var(--muted); }
.col .empty { margin: 0; padding: 4px; font-size: 13px; color: var(--muted); }
@media (max-width: 899px) { .col.is-empty { display: none; } }

.card { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; transition: border-color .15s, box-shadow .15s, transform .15s; }
.card:hover { border-color: var(--muted); box-shadow: var(--shadow); }
.card-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 6px 8px; }
.card-mid { display: flex; gap: 12px; align-items: flex-start; }
.card-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.card-title { margin: 0; font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.08; }
.card-link { all: unset; cursor: pointer; }
.card-link::after { content: ""; position: absolute; inset: 0; border-radius: 12px; }
.card-link:focus-visible::after { outline: 2px solid var(--accent); outline-offset: 2px; }
.card-sub { margin: 0; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.thumb { width: 52px; height: 52px; flex: 0 0 52px; border-radius: 8px; background: var(--sunk) center / cover; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.now { font-size: 13px; color: var(--muted); }
.now b { color: var(--ink); font-weight: 700; }
.card .icon-btn { position: relative; z-index: 1; border-color: var(--line); color: var(--ink); width: 40px; height: 40px; flex-basis: 40px; }
.card .icon-btn:hover { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.delivered { border-top: 1px solid var(--line); padding-top: 14px; }
.delivered summary { cursor: pointer; font-weight: 600; font-size: 14px; color: var(--muted); min-height: 44px; display: flex; align-items: center; }
.dl-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.dl-list button { width: 100%; display: flex; justify-content: space-between; gap: 12px; padding: 12px 4px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.dl-list span:first-child { font-family: var(--serif); font-size: 19px; font-weight: 600; }

/* project */
.back { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; padding: 0 10px 0 4px; margin-left: -4px; border: 0; border-radius: 9px; background: none; color: var(--muted); font-weight: 600; font-size: 14px; align-self: flex-start; }
.back:hover { color: var(--ink); background: var(--sunk); }
.proj-head { display: flex; flex-direction: column; gap: 10px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.done-badge { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 10px; background: var(--sunk); font-weight: 700; color: var(--good); }
.proj { display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px; align-items: start; }
@media (min-width: 1080px) { .proj { grid-template-columns: minmax(0, 1fr) 300px; gap: 28px; } }
.proj-main { min-width: 0; display: flex; flex-direction: column; gap: 16px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button { position: relative; display: inline-flex; align-items: center; gap: 6px; min-height: 46px; padding: 0 12px; border: 0; background: none; font-weight: 600; font-size: 14px; color: var(--muted); white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); }
.tabs button[aria-selected="true"]::after { content: ""; position: absolute; left: 10px; right: 10px; bottom: -1px; height: 2px; background: var(--ink); border-radius: 2px; }
.tab-n { font-family: var(--mono); font-size: 11.5px; font-weight: 500; color: var(--muted); }
.panel { animation: rise .22s ease both; display: flex; flex-direction: column; gap: 16px; }
@keyframes rise { from { opacity: .3; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* timeline */
.tl { list-style: none; margin: 0; padding: 0; position: relative; display: flex; flex-direction: column; gap: 4px; }
.tl::before { content: ""; position: absolute; left: 21px; top: 22px; bottom: 22px; border-left: 2px dashed var(--line); }
.tl-step { position: relative; border-radius: 12px; }
.tl-step.drag-over { box-shadow: 0 -2px 0 var(--accent); }
.tl-step.is-open { background: var(--surface); border: 1px solid var(--line); }
.tl-row { width: 100%; display: flex; align-items: center; gap: 14px; min-height: 56px; padding: 8px 12px 8px 12px; border: 0; background: none; text-align: left; border-radius: 12px; }
.tl-step:not(.is-open) .tl-row:hover { background: var(--sunk); }
.dot { position: relative; z-index: 1; width: 20px; height: 20px; flex: 0 0 20px; border-radius: 50%; border: 2px solid var(--line); background: var(--bg); display: grid; place-items: center; color: var(--bg); }
.tl-step.is-open .dot { background: var(--surface); }
.tl-step.done .dot { background: var(--ink); border-color: var(--ink); }
.tl-step.current .dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 5px var(--accent-soft); }
.tl-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.tl-name { font-weight: 700; font-size: 15px; }
.tl-step.done .tl-name { color: var(--muted); }
.tl-step.current .tl-name { font-family: var(--serif); font-size: 22px; font-weight: 600; line-height: 1.1; }
.tl-meta { font-size: 12.5px; color: var(--muted); }
.phase { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.tl-body { padding: 0 12px 14px 46px; display: flex; flex-direction: column; gap: 12px; }
.strip { display: flex; gap: 8px; overflow-x: auto; }
.strip button { width: 76px; height: 76px; flex: 0 0 76px; border-radius: 8px; border: 0; background: var(--sunk) center / cover; }
.tl-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.tl-actions .spacer { flex: 1; }
.add-step, .inline-form { display: flex; gap: 8px; flex-wrap: wrap; }
.add-step input { flex: 1 1 200px; min-width: 0; }

input[type="text"], input[type="number"], input[type="date"], input[type="email"], input:not([type]), select, textarea {
  min-height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); width: 100%;
}
textarea { padding: 10px 12px; line-height: 1.45; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); }
.add-step input, .add-step select { width: auto; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 700; color: var(--muted); }
.field.grow { flex: 1 1 240px; }
.suffix { display: flex; align-items: center; gap: 8px; }
.suffix input { width: 84px; }

/* costs */
.lines { border-top: 1px solid var(--line); }
.line { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "name name del" "qty cost total"; gap: 6px 10px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 700px) { .line { grid-template-columns: minmax(0, 1fr) 150px 120px 100px 36px; grid-template-areas: "name qty cost total del"; } }
.ln-name { grid-area: name; font-weight: 600; min-width: 0; }
.ln-name small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.ln-qty { grid-area: qty; display: flex; align-items: center; gap: 8px; }
.ln-qty input { width: 76px; min-height: 38px; font-family: var(--mono); }
.unit { font-family: var(--mono); font-size: 12.5px; color: var(--muted); white-space: nowrap; }
.ln-cost { grid-area: cost; font-family: var(--mono); font-size: 13px; color: var(--muted); }
.ln-total { grid-area: total; font-family: var(--mono); font-variant-numeric: tabular-nums; text-align: right; font-weight: 500; }
.ln-del { grid-area: del; justify-self: end; }
.line-head { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); padding: 8px 0; }
@media (max-width: 699px) { .line-head { display: none; } }
.line.labour { background: var(--accent-soft); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 0; }
.add-line { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.add-line .field.qty { width: 96px; }
.custom { display: flex; gap: 10px; flex-wrap: wrap; width: 100%; }
.custom .field { flex: 1 1 140px; }
.totals { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 700px) { .totals { grid-template-columns: 220px minmax(0, 1fr); } }
.adj { display: flex; flex-direction: column; gap: 12px; }
@media (max-width: 699px) { .adj { flex-direction: row; } }
.sum { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 6px 16px; }
.sum div { display: flex; justify-content: space-between; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.sum div:last-child { border-bottom: 0; }
.sum dt { color: var(--muted); font-size: 14px; }
.sum dd { margin: 0; font-family: var(--mono); font-variant-numeric: tabular-nums; }
.sum .strong dt, .sum .strong dd { color: var(--ink); font-weight: 700; }
.sum .hi { margin: 4px -10px; padding: 12px 10px; border-radius: 9px; background: var(--ink); border-bottom: 0; }
.sum .hi dt, .sum .hi dd { color: var(--bg); font-weight: 600; }
.sum .neg dd { color: var(--bad); }
.sum .pos dd { color: var(--good); }

/* notes & files */
.note-form { display: flex; flex-direction: column; gap: 10px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.note-form .row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; justify-content: space-between; }
.note-form .row .field { flex: 1 1 180px; }
.notes { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.note { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.note-meta { font-size: 12px; font-weight: 600; color: var(--muted); }
.note p { margin: 0; grid-column: 1; font-family: var(--serif); font-size: 19px; line-height: 1.35; max-width: 60ch; }
.note .icon-btn { grid-column: 2; grid-row: 1 / span 2; }
.files-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.files-head p { margin: 0; font-size: 13px; max-width: 46ch; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.tile { position: relative; aspect-ratio: 1; max-width: 100%; border-radius: 10px; border: 1px solid var(--line); background: var(--sunk) center / cover; padding: 0; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; color: var(--muted); font-size: 12px; text-align: center; }
.tile-cap { position: absolute; left: 6px; bottom: 6px; padding: 3px 8px; border-radius: 999px; background: rgba(20,16,12,.7); color: #F4EEE4; font-size: 11px; font-weight: 600; }
.tile.file span { padding: 0 10px; word-break: break-word; color: var(--ink); }
.empty-state { padding: 28px 16px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: 12px; font-size: 14px; }

/* rail */
.rail { display: flex; flex-direction: column; gap: 14px; }
@media (max-width: 1079px) { .rail { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); } }
.rcard { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 14px 16px; display: flex; flex-direction: column; gap: 6px; }
.rh { margin: 0; font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.kv { margin: 0; }
.kv div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.kv div:last-child { border-bottom: 0; }
.kv dt { color: var(--muted); font-size: 13.5px; }
.kv dd { margin: 0; font-family: var(--mono); font-size: 14px; font-variant-numeric: tabular-nums; text-align: right; }
.kv .big dd { font-size: 16px; font-weight: 500; color: var(--ink); }
.rcard p { margin: 0; font-size: 14px; }

/* library */
.lib-list { display: flex; flex-direction: column; border-top: 1px solid var(--line); }
.lib-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name del" "price price"; gap: 6px 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
@media (min-width: 700px) { .lib-row { grid-template-columns: minmax(0, 1fr) 90px 200px 40px; grid-template-areas: "name unit price del"; } }
.lib-name { grid-area: name; min-width: 0; }
.lib-name b { display: block; font-weight: 600; }
.lib-name small { color: var(--muted); font-size: 12.5px; }
.lib-unit { grid-area: unit; }
.lib-price { grid-area: price; display: flex; align-items: center; gap: 8px; }
.lib-price input { width: 100px; min-height: 38px; font-family: var(--mono); }
.lib-row .icon-btn { grid-area: del; }
@media (max-width: 699px) { .lib-unit { display: none; } }
.notice { margin: 0; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: 13px; }
.tpl { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.tpl-steps { display: flex; flex-wrap: wrap; gap: 6px; }
.tpl-steps .chip { gap: 4px; padding-right: 4px; }
.tpl-steps .chip button { width: 22px; height: 22px; border: 0; border-radius: 50%; background: none; display: grid; place-items: center; color: var(--muted); }
.tpl-steps .chip button:hover { background: var(--line); color: var(--ink); }
.tpl small { color: var(--muted); }
.rates { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px; max-width: 720px; }

/* materials, lots, suppliers */
.mats { display: flex; flex-direction: column; gap: 10px; }
.mat { border: 1px solid var(--line); border-radius: 14px; background: var(--surface); overflow: hidden; }
.mat-head { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 60px; padding: 12px 16px; background: none; border: 0; text-align: left; }
.mat-head:hover { background: var(--sunk); }
.mat-name { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mat-name b { font-weight: 700; font-size: 15px; }
.mat-name small { color: var(--muted); font-size: 12.5px; }
.inuse { font-family: var(--mono); font-size: 12px; padding: 4px 10px; border: 1.5px dashed var(--accent); border-radius: 6px; color: var(--accent); white-space: nowrap; }
.chev { flex: 0 0 18px; color: var(--muted); transition: transform .2s; }
.mat-head[aria-expanded="true"] .chev { transform: rotate(180deg); }
.lots { border-top: 1px solid var(--line); }
.lot { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "code who status" "nums nums nums" "acts acts acts"; gap: 8px 12px; align-items: center; padding: 12px 16px; border-bottom: 1px dashed var(--line); }
@media (min-width: 1000px) { .lot { grid-template-columns: 116px minmax(0, 1fr) minmax(0, 1.7fr) 120px 190px; grid-template-areas: "code who nums status acts"; } }
.lot.used { opacity: .55; }
.lot-code { grid-area: code; justify-self: start; font-family: var(--mono); font-size: 12.5px; font-weight: 500; padding: 4px 8px; border: 1.5px dashed var(--ink); border-radius: 6px; }
.lot-who { grid-area: who; display: flex; flex-direction: column; min-width: 0; }
.lot-who b { font-weight: 600; font-size: 14px; }
.lot-who small, .lot-status small { color: var(--muted); font-size: 12px; }
.lot-nums { grid-area: nums; font-family: var(--mono); font-size: 12.5px; color: var(--muted); display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; font-variant-numeric: tabular-nums; }
.lot-nums b { color: var(--ink); font-weight: 500; }
.xtra { display: inline-flex; align-items: center; gap: 2px; }
.xtra input { width: 76px; min-height: 30px; padding: 0 6px; font-family: var(--mono); font-size: 12.5px; }
.lot-status { grid-area: status; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.lot-acts { grid-area: acts; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; padding: 3px 8px; border-radius: 999px; background: var(--sunk); color: var(--muted); }
.badge.use { background: var(--accent-soft); color: var(--accent); }
.mat-foot { padding: 6px 16px 10px; display: flex; justify-content: flex-end; }
.purchase { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.p-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.p-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) minmax(0, 1fr); gap: 10px; align-items: end; }
@media (max-width: 599px) { .p-row { grid-template-columns: 1fr 1fr; } .p-row .field:first-child { grid-column: 1 / -1; } }
.ln-name .lot-pick { display: block; width: auto; max-width: 100%; min-height: 32px; margin-top: 6px; padding: 0 10px; border-radius: 999px; background: var(--sunk); border: 1.5px dashed var(--line); font-family: var(--mono); font-size: 12px; font-weight: 500; color: var(--ink); }
.ln-name .lot-pick.est { border-color: var(--warn); color: var(--warn); }
.est-tag { margin-left: 6px; font-style: normal; font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--warn); }
.est-note { margin: 0; padding: 10px 14px; border-radius: 10px; border: 1px dashed var(--warn); color: var(--warn); font-size: 13px; }

/* overlays */
.overlay { position: fixed; inset: 0; z-index: 60; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; animation: fade .18s ease both; }
@keyframes fade { from { opacity: 0; } }
.sheet { width: 100%; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 20px 20px 0 0; padding: 20px var(--gr) calc(var(--sb) + 20px) var(--gl); display: flex; flex-direction: column; gap: 14px; animation: up .25s cubic-bezier(.2,.8,.2,1) both; }
@keyframes up { from { transform: translateY(24px); opacity: .5; } }
@media (min-width: 700px) { .overlay { align-items: center; } .sheet { width: 540px; border-radius: 18px; padding: 24px; } }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.sheet form { display: flex; flex-direction: column; gap: 14px; }
.two { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.seg-radio { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg-radio label { position: relative; }
.seg-radio input { position: absolute; opacity: 0; inset: 0; }
.seg-radio span { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-weight: 700; font-size: 14px; }
.seg-radio small { font-weight: 400; color: var(--muted); font-size: 12px; }
.seg-radio input:checked + span { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.seg-radio input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sheet-actions { display: flex; justify-content: flex-end; gap: 8px; }

.lightbox { position: fixed; inset: 0; z-index: 70; background: rgba(10,8,6,.92); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; padding: 24px var(--gr) calc(var(--sb) + 24px) var(--gl); animation: fade .18s ease both; }
.lightbox img { max-height: 78vh; border-radius: 8px; object-fit: contain; }
.lightbox p { margin: 0; color: #E9E1D4; font-size: 14px; }
.lightbox .icon-btn { position: absolute; top: calc(env(safe-area-inset-top, 0px) + 12px); right: var(--gr); color: #E9E1D4; }

.timer { position: fixed; z-index: 40; right: var(--gr); bottom: calc(var(--sb) + 84px); display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 14px; border-radius: 999px; background: var(--ink); color: var(--bg); box-shadow: var(--shadow); max-width: calc(100% - 32px); }
@media (min-width: 900px) { .timer { right: max(28px, env(safe-area-inset-right, 0px)); bottom: 24px; width: 280px; border-radius: 14px; padding: 10px 8px 10px 14px; } }
.pulse { width: 8px; height: 8px; flex: 0 0 8px; border-radius: 50%; background: var(--bad); animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.timer-main { all: unset; cursor: pointer; display: flex; flex-direction: column; min-width: 0; flex: 1; }
.t-time { font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.t-what { font-size: 11.5px; opacity: .75; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer .icon-btn { color: var(--bg); width: 40px; height: 40px; flex-basis: 40px; }
.timer .icon-btn:hover { background: rgba(255,255,255,.12); color: var(--bg); }

.toast { position: fixed; z-index: 80; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 12px); display: flex; align-items: center; gap: 14px; padding: 10px 10px 10px 16px; border-radius: 12px; background: var(--ink); color: var(--bg); font-size: 14px; font-weight: 600; box-shadow: var(--shadow); width: max-content; max-width: calc(100% - 32px); animation: up .2s ease both; }
@media (min-width: 900px) { .toast { top: auto; bottom: 28px; } }
.toast button { min-height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid rgba(255,255,255,.25); background: none; color: var(--bg); font-weight: 700; font-size: 13px; }

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* first-run setup */
body.is-setup .side, body.is-setup .tabbar { display: none !important; }
.setup { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; gap: 28px; }
.setup-head { display: flex; flex-direction: column; gap: 12px; }
.setup form { display: flex; flex-direction: column; gap: 26px; }
.setup fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.setup legend { padding: 0; margin-bottom: 12px; }
.step-n { font-family: var(--mono); font-size: 13px; color: var(--accent); margin-right: 8px; }
.kits { display: grid; gap: 12px; }
@media (min-width: 700px) { .kits { grid-template-columns: 1fr 1fr; } }
.kit { position: relative; display: block; }
.kit input { position: absolute; opacity: 0; inset: 0; }
.kit-body { height: 100%; display: flex; flex-direction: column; gap: 10px; padding: 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.kit-body b { font-family: var(--serif); font-size: 24px; font-weight: 600; line-height: 1.05; }
.kit-body > span { color: var(--muted); font-size: 14px; }
.kit input:checked + .kit-body { border-color: var(--ink); box-shadow: inset 0 0 0 1px var(--ink); }
.kit input:focus-visible + .kit-body { outline: 2px solid var(--accent); outline-offset: 2px; }
.kit-cols { display: flex; flex-wrap: wrap; gap: 6px; }
.kit-cols i { font-style: normal; font-size: 11.5px; font-weight: 700; padding: 4px 9px; border-radius: 7px; background: var(--sunk); }
.kit-body small { color: var(--muted); font-size: 12.5px; }
.kit-body .stitches { max-width: 220px; }
.check { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--ink); flex: none; }
.check span { display: flex; flex-direction: column; gap: 2px; font-weight: 700; font-size: 14px; }
.check small { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.check.is-off { opacity: .55; cursor: default; }
.studio-fields { display: grid; gap: 14px; grid-template-columns: 1fr 1fr; }
.studio-fields .field:first-child { grid-column: 1 / -1; }
@media (min-width: 700px) { .studio-fields { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1.3fr) minmax(0, 1fr); } .studio-fields .field:first-child { grid-column: auto; } }
.setup-go { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

/* studio */
.studio { display: grid; gap: 18px; align-items: start; }
@media (min-width: 1080px) { .studio { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); } }
.sbox { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.sbox > p { margin: 0; }
.sbox .h2 { font-size: 23px; }
.sbox.danger { border-color: color-mix(in srgb, var(--bad) 45%, var(--line)); }
.scol { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.rates2 { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); }
.cols-edit { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.col-row { display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; grid-template-areas: "n name acts" ". use use"; gap: 4px 10px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.col-row:last-child { border-bottom: 0; }
@media (min-width: 700px) { .col-row { grid-template-columns: 30px minmax(0, 1fr) 190px auto; grid-template-areas: "n name use acts"; } }
.col-n { grid-area: n; font-family: var(--mono); font-size: 12px; color: var(--muted); }
.col-row input { grid-area: name; }
.col-use { grid-area: use; font-size: 12.5px; color: var(--muted); }
.col-acts { grid-area: acts; display: flex; gap: 2px; }
.kit-line { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.kit-line .field { flex: 1 1 180px; }
.applied { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: color-mix(in srgb, var(--bad) 10%, transparent); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.card-tags { display: flex; gap: 8px; align-items: center; }
.card-tags .badge { font-size: 9.5px; padding: 2px 7px; }
.edit-cols { font-size: 13px; padding: 0; }
.tpl-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.tpl-steps .chip small { color: var(--muted); font-weight: 600; margin-left: 4px; font-size: 10.5px; }
