:root {
  --paper: #F2EEE4; --paper-2: #E8E2D2; --card: #FCFAF5; --ink: #17222E; --ink-2: #4A5663;
  --line: #CFC8B6; --accent: #C2410C; --accent-2: #F97316; --on-accent: #fff;
  --ok: #14532D; --ok-bg: #D7EDD8; --warn: #7A3E06; --warn-bg: #F9E6BD;
  --bad: #8F1B1B; --bad-bg: #F6D6D3; --info: #173F70; --info-bg: #D9E6F4;
  --r: 14px; --tap: 48px; --nav-h: 66px; --gap: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh; min-height: 100dvh; color: var(--ink); font: 16px/1.45 var(--font);
  background-color: var(--paper);
  background-image: linear-gradient(rgba(23,34,46,.045) 1px, transparent 1px), linear-gradient(90deg, rgba(23,34,46,.045) 1px, transparent 1px);
  background-size: 28px 28px;
  -webkit-tap-highlight-color: transparent; overscroll-behavior-y: none;
}
h1, h2, h3, p, ul, ol, figure, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
img, svg { max-width: 100%; }
:focus-visible { outline: 3px solid var(--accent-2); outline-offset: 2px; border-radius: 6px; }
.top :focus-visible { outline-color: #fff; }
[hidden] { display: none !important; }
.sr-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; }
.sr-file:focus-visible + * { outline: 3px solid var(--accent-2); }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* shell */
.app { max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
.top { position: sticky; top: 0; z-index: 30; background: var(--ink); color: #fff; padding-top: env(safe-area-inset-top); }
.top-bar { display: flex; align-items: center; gap: 10px; padding: 8px 12px; min-height: 56px; }
.brand { flex: 1; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; font-size: 15px; display: flex; align-items: center; gap: 8px; min-width: 0; }
.brand-m { display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; background: var(--accent-2); color: var(--ink); font-weight: 900; }
.lang { display: flex; align-items: center; gap: 2px; color: #cbd3dc; }
.lang button { min-width: 44px; min-height: 44px; background: none; border: 0; color: #cbd3dc; font-weight: 700; letter-spacing: .06em; border-radius: 10px; }
.lang button[aria-pressed="true"] { color: #fff; background: rgba(255,255,255,.14); }
.icon-btn { width: var(--tap); height: var(--tap); display: inline-grid; place-items: center; border: 0; background: transparent; border-radius: 12px; color: inherit; }
.icon-btn.on-dark { color: #fff; }
.demo-strip { background: var(--warn-bg); color: var(--warn); font-size: 12.5px; font-weight: 600; padding: 5px 12px; text-align: center; }
.view { flex: 1; padding: 16px 16px calc(var(--nav-h) + env(safe-area-inset-bottom) + 20px); outline: none; min-width: 0; }
.tabs {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(560px, 100%); z-index: 30;
  display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; min-width: 0; min-height: var(--nav-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: none; border: 0; color: var(--ink-2); font-size: 12px; font-weight: 600; padding: 6px 2px; position: relative;
}
.tab span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tab[aria-current="page"] { color: var(--accent); }
.tab[aria-current="page"]::before { content: ""; position: absolute; top: 0; left: 22%; right: 22%; height: 3px; background: var(--accent); border-radius: 0 0 3px 3px; }
@media (hover: hover) { .tab:hover { color: var(--ink); } }

/* type */
.h1 { font-size: 26px; line-height: 1.15; font-weight: 800; letter-spacing: .02em; text-transform: uppercase; }
.h2 { font-size: 19px; line-height: 1.2; font-weight: 800; letter-spacing: .03em; text-transform: uppercase; }
.h3 { font-size: 15px; line-height: 1.25; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; }
.eyebrow { font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.muted { color: var(--ink-2); }
.small { font-size: 13.5px; }
.center { text-align: center; }
.tnum { font-variant-numeric: tabular-nums; }
.err { color: var(--bad); font-size: 13.5px; font-weight: 600; }

/* layout helpers */
.stack { display: flex; flex-direction: column; gap: var(--gap); min-width: 0; }
.stack.tight { gap: 6px; }
.row { display: flex; align-items: center; gap: 10px; min-width: 0; }
.grow { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.list { display: flex; flex-direction: column; gap: 10px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 16px; position: relative; min-width: 0;
  box-shadow: 0 1px 0 rgba(23,34,46,.06);
}
.card::before { content: ""; position: absolute; top: -1px; left: -1px; width: 18px; height: 18px; border-top: 3px solid var(--accent); border-left: 3px solid var(--accent); border-top-left-radius: var(--r); pointer-events: none; }
.note { padding: 12px 14px; border-radius: 12px; font-size: 14.5px; display: flex; flex-direction: column; gap: 4px; }
.note.info { background: var(--info-bg); color: var(--info); flex-direction: row; align-items: center; gap: 8px; }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note.bad { background: var(--bad-bg); color: var(--bad); }
.pill {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 700; white-space: nowrap;
  background: var(--paper-2); color: var(--ink-2);
}
.pill.ok, .pill.st-done { background: var(--ok-bg); color: var(--ok); }
.pill.warn, .pill.st-doing { background: var(--warn-bg); color: var(--warn); }
.pill.info { background: var(--info-bg); color: var(--info); }
.pill.st-todo { background: var(--paper-2); color: var(--ink-2); }

/* controls */
.btn {
  min-height: var(--tap); padding: 10px 18px; border-radius: 12px; border: 2px solid var(--ink); background: var(--card); color: var(--ink);
  font-weight: 700; display: inline-flex; align-items: center; justify-content: center; gap: 8px; text-align: center; line-height: 1.2;
  transition: transform .12s ease, background-color .15s ease;
}
.btn:active { transform: scale(.97); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 44px; padding: 6px 12px; font-size: 14px; }
.btn.link { border: 0; background: none; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; justify-content: flex-start; padding-left: 0; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
@media (hover: hover) { .btn.ghost:hover { background: var(--paper-2); } .btn.primary:hover { background: #A8370A; } }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field label, .field .lbl { font-weight: 700; font-size: 14px; }
.field input[type="text"], .field textarea, .field select {
  width: 100%; min-height: var(--tap); padding: 10px 12px; background: #fff; border: 2px solid var(--line); border-radius: 10px; font-size: 16px;
}
.field textarea { resize: vertical; }
.field [aria-invalid="true"] { border-color: var(--bad); }
.field input[type="range"] { width: 100%; height: var(--tap); accent-color: var(--accent); }
fieldset { border: 1px solid var(--line); min-width: 0; }
legend { padding: 0; }
.seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.seg-i { position: relative; }
.seg-i input { position: absolute; opacity: 0; inset: 0; }
.seg-i span { display: flex; align-items: center; justify-content: center; text-align: center; min-height: var(--tap); padding: 6px; border: 2px solid var(--line); border-radius: 10px; font-size: 13.5px; font-weight: 700; background: #fff; }
.seg-i input:checked + span { border-color: var(--accent); background: #FDEBDD; color: var(--accent); }
.seg-i input:focus-visible + span { outline: 3px solid var(--accent-2); outline-offset: 2px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { min-height: 44px; padding: 6px 16px; border-radius: 99px; border: 2px solid var(--line); background: #fff; font-weight: 700; font-size: 14px; }
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }

/* sheet + toast */
.sheet { border: 0; padding: 0; width: min(520px, 100%); max-width: 100%; margin: auto auto 0; border-radius: 20px 20px 0 0; background: var(--paper); color: var(--ink); max-height: 90dvh; }
.sheet::backdrop { background: rgba(23,34,46,.55); }
.sheet-in { padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); }
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 16px); transform: translate(-50%, 20px); z-index: 60;
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-size: 14.5px; max-width: min(92vw, 420px); text-align: center;
  opacity: 0; pointer-events: none; transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* wide screens */
@media (min-width: 768px) {
  .app { max-width: 1040px; display: grid; grid-template-columns: 92px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .top { grid-column: 1 / -1; }
  .view { grid-column: 2; grid-row: 2; padding: 24px 24px 40px; }
  .tabs { position: sticky; grid-column: 1; grid-row: 2; top: 120px; align-self: start; left: auto; bottom: auto; transform: none; width: auto; flex-direction: column; margin-top: 24px; border: 1px solid var(--line); border-radius: var(--r); padding-bottom: 0; }
  .tabs[hidden] { display: none !important; }
  .app:has(.tabs[hidden]) { grid-template-columns: minmax(0, 1fr); }
  .app:has(.tabs[hidden]) .view { grid-column: 1; max-width: 560px; margin: 0 auto; width: 100%; }
  .tab { min-height: 74px; }
  .tab[aria-current="page"]::before { top: 22%; bottom: 22%; left: 0; right: auto; width: 3px; height: auto; border-radius: 0 3px 3px 0; }
  .toast { bottom: 24px; }
  .sheet { margin: auto; border-radius: 20px; }
  .grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--gap); align-items: start; }
}
