/* Yiwu Tracker — one token set (Rule 4). Dark only (Visual rules). System fonts only:
   Google Fonts is blocked in China, so nothing here loads from Google. */
:root {
  --bg: #141B19;        /* dark grey-green, never pure black */
  --surface: #1B2421;   /* panels */
  --raised: #24302C;    /* raised = lighter, not shadow */
  --line: #34433E;
  --ink: #F1ECE0;       /* off-white, never pure white */
  --dim: #B4BDB8;
  --faint: #8E9993;
  --accent: #E8B04A;    /* the one "act here" colour: primary button, current selection */
  --accent-ink: #1C1406;
  --accent-tint: rgba(232, 176, 74, .14);
  --done: #4CBFB0;      /* status: done / shortlisted */
  --done-tint: rgba(76, 191, 176, .14);
  --danger: #F2937C;    /* status: danger only */
  --danger-tint: rgba(242, 147, 124, .14);
  --s1: 4px; --s2: 8px; --s3: 16px; --s4: 24px; --s5: 32px;
  --r: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  --display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Songti SC", serif;
  --tab-h: 60px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 16px/1.5 var(--font); font-variant-numeric: tabular-nums; overscroll-behavior-y: contain; }
button, input, textarea, select { font: inherit; color: inherit; }
a { color: var(--ink); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---- frame ---- */
.top {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding: calc(env(safe-area-inset-top) + var(--s2)) var(--s3) var(--s2);
  display: flex; align-items: center; gap: var(--s2); min-height: 56px; border-bottom: 1px solid var(--line);
}
.top h1 { font: 600 22px/1.2 var(--display); margin: 0; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .back { margin-left: calc(-1 * var(--s2)); }
main { padding: var(--s3) var(--s3) calc(var(--tab-h) + 96px + env(safe-area-inset-bottom)); max-width: 720px; margin: 0 auto; }
.bar {
  position: fixed; left: 0; right: 0; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom)); z-index: 15;
  padding: var(--s2) var(--s3); display: flex; gap: var(--s2); background: linear-gradient(to top, var(--bg) 70%, transparent);
}
.bar.solo { bottom: env(safe-area-inset-bottom); }
.bar > * { max-width: 720px; }
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 16; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; padding-bottom: env(safe-area-inset-bottom);
}
.tabs a {
  flex: 1; min-height: var(--tab-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  text-decoration: none; color: var(--dim); font-size: 12px; position: relative;
}
.tabs a[aria-current="page"] { color: var(--accent); }
.tabs svg { width: 24px; height: 24px; }
.badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--raised); color: var(--ink); font-size: 12px; line-height: 18px; text-align: center; border: 1px solid var(--line); }

/* ---- type ---- */
h2 { font: 600 20px/1.25 var(--display); margin: var(--s4) 0 var(--s2); }
h2:first-child { margin-top: 0; }
.label { font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); font-weight: 600; }
.muted { color: var(--dim); }
.small { font-size: 14px; }
p { margin: 0 0 var(--s2); }

/* ---- buttons (one look per role, Rule 5) ---- */
.btn {
  min-height: 48px; padding: 0 var(--s3); border-radius: var(--r); border: 2px solid var(--line); background: var(--raised);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--s2); font-weight: 600; cursor: pointer; text-decoration: none;
  transition: transform .12s ease, background-color .15s ease, border-color .15s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn:focus-visible, .chip:focus-visible, .row:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); flex: 1; }
.btn.primary:hover { filter: brightness(1.06); }
.btn.secondary:hover { border-color: var(--dim); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--dim); }
.btn.ghost:hover { color: var(--ink); }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); min-height: 44px; font-weight: 500; }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn.loading { opacity: .7; pointer-events: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn.wide { width: 100%; }
.btn.square { width: 56px; padding: 0; flex: none; }
.icon-btn { width: 44px; height: 44px; border-radius: var(--r); border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink); flex: none; }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn:active { background: var(--raised); }

/* ---- status pill (quiet, consistent place: top right) ---- */
.pill { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 var(--s2); border-radius: var(--r); font-size: 14px; color: var(--dim); background: none; border: 0; cursor: pointer; }
.pill svg { width: 18px; height: 18px; }
.pill.ok svg { color: var(--done); }
.pill.warn { color: var(--danger); }

/* ---- panels & rows ---- */
.panel { background: var(--surface); border-radius: var(--r); padding: var(--s3); margin-bottom: var(--s3); }
.panel.tint-done { background: var(--done-tint); }
.panel.tint-danger { background: var(--danger-tint); }
.panel.tint-accent { background: var(--accent-tint); }
.list { background: var(--surface); border-radius: var(--r); margin-bottom: var(--s3); overflow: hidden; }
.row { display: flex; align-items: center; gap: var(--s3); padding: var(--s2) var(--s3); min-height: 56px; border-top: 1px solid var(--line); text-decoration: none; color: var(--ink); cursor: pointer; width: 100%; background: none; border-left: 0; border-right: 0; border-bottom: 0; text-align: left; }
.row:first-child { border-top: 0; }
.row:active { background: var(--raised); }
.row .main { flex: 1; min-width: 0; }
.row .title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row .sub { font-size: 14px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .end { text-align: right; font-size: 14px; flex: none; }
.row > svg { width: 24px; height: 24px; flex: none; color: var(--dim); }
.row .chev { color: var(--faint); width: 20px; height: 20px; flex: none; }
svg { width: 24px; height: 24px; }
.thumb { width: 56px; height: 56px; border-radius: 6px; background: var(--raised); flex: none; object-fit: cover; display: flex; align-items: center; justify-content: center; color: var(--faint); }
.thumb svg { width: 24px; height: 24px; }
.group-h { padding: var(--s2) var(--s3); font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--dim); font-weight: 600; background: var(--bg); }

/* status tag: always icon/word, never colour alone */
.tag { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 999px; background: var(--raised); color: var(--dim); white-space: nowrap; }
.tag svg { width: 14px; height: 14px; }
.tag.done { background: var(--done-tint); color: var(--done); }
.tag.danger { background: var(--danger-tint); color: var(--danger); }

/* ---- chips ---- */
.chips { display: flex; flex-wrap: wrap; gap: var(--s2); }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * var(--s3)); padding: 0 var(--s3); }
.chips.scroll::-webkit-scrollbar { display: none; }
.chip { min-height: 44px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--line); background: transparent; cursor: pointer; white-space: nowrap; display: inline-flex; align-items: center; gap: 8px; flex: none; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-tint); color: var(--ink); }
.chip[aria-pressed="true"]::before { content: ""; width: 14px; height: 14px; background: currentColor; -webkit-mask: var(--tick) center/contain no-repeat; mask: var(--tick) center/contain no-repeat; }
.chip .count { color: var(--dim); font-size: 14px; }
:root { --tick: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M5 12.5l4.5 4.5L19 7.5' fill='none' stroke='black' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E"); }

/* ---- forms ---- */
.field { margin-bottom: var(--s3); }
.field > label, .field > .label { display: block; margin-bottom: 8px; font-size: 14px; color: var(--dim); font-weight: 600; letter-spacing: 0; text-transform: none; }
.input { width: 100%; min-height: 48px; padding: 8px 16px; border-radius: var(--r); border: 2px solid var(--line); background: var(--bg); font-size: 16px; }
.input:focus { outline: none; border-color: var(--accent); }
textarea.input { min-height: 88px; resize: vertical; }
.affix { position: relative; display: flex; align-items: center; }
.affix .input { padding-left: 32px; }
.affix .pre { position: absolute; left: 16px; color: var(--dim); pointer-events: none; }
.affix .post { position: absolute; right: 16px; color: var(--dim); pointer-events: none; font-size: 14px; }
.hint { font-size: 14px; color: var(--dim); margin-top: 4px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: var(--s3); }
.three { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: var(--s2); }
.section { margin-top: var(--s4); }
.section > .label { display: block; margin-bottom: var(--s2); }
.readonly { padding: var(--s2) var(--s3); display: flex; align-items: center; border-radius: var(--r); background: var(--surface); color: var(--dim); min-height: 48px; }
.calc { display: flex; justify-content: space-between; align-items: baseline; padding: var(--s3); background: var(--surface); border-radius: var(--r); margin-bottom: var(--s3); }
.calc b { font-size: 18px; }

/* photos */
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--s2); }
.photos .ph { aspect-ratio: 1; border-radius: 6px; overflow: hidden; background: var(--raised); position: relative; border: 0; padding: 0; cursor: pointer; }
.photos .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photos .ph .kind { position: absolute; left: 4px; bottom: 4px; }
.shot { display: flex; align-items: center; gap: var(--s3); width: 100%; min-height: 72px; padding: var(--s2) var(--s3); border-radius: var(--r); border: 2px dashed var(--line); background: transparent; cursor: pointer; text-align: left; }
.shot svg { width: 28px; height: 28px; color: var(--accent); flex: none; }
.shot.done { border-style: solid; }
.shot.done svg { color: var(--done); }
.shot img { width: 56px; height: 56px; border-radius: 6px; object-fit: cover; }

/* progress */
.progress { height: 8px; border-radius: 4px; background: var(--raised); overflow: hidden; margin: var(--s2) 0 var(--s1); }
.progress > i { display: block; height: 100%; background: var(--done); border-radius: 4px; transition: width .25s ease; }

/* dashboard */
.key { font: 600 30px/1.1 var(--display); }
.bars { display: grid; gap: var(--s2); margin-top: var(--s3); }
.barrow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px var(--s2); font-size: 14px; }
.barrow .track { grid-column: 1 / -1; height: 8px; background: var(--raised); border-radius: 4px; overflow: hidden; }
.barrow .track i { display: block; height: 100%; background: var(--dim); border-radius: 4px; }
.barrow .num { text-align: right; }

/* sheets & overlays */
.scrim { position: fixed; inset: 0; background: rgba(8, 12, 11, .6); z-index: 40; animation: fade .18s ease; }
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41; background: var(--surface); border-radius: 16px 16px 0 0;
  max-height: 88vh; overflow-y: auto; padding: var(--s2) var(--s3) calc(var(--s3) + env(safe-area-inset-bottom)); animation: up .2s ease;
  max-width: 720px; margin: 0 auto;
}
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 4px auto var(--s3); }
.sheet h2 { margin-top: 0; }
.actions { display: flex; gap: var(--s2); align-items: center; flex-wrap: wrap; }
.sheet .actions { margin-top: var(--s3); }
.sheet .actions .btn.primary { flex: 1; }
@keyframes up { from { transform: translateY(24px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }
.viewer { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: flex; flex-direction: column; }
.viewer img { flex: 1; min-height: 0; object-fit: contain; width: 100%; }
.viewer .vbar { display: flex; justify-content: space-between; align-items: center; padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; }
.viewer .vfoot { display: flex; justify-content: center; padding: 8px 8px calc(16px + env(safe-area-inset-bottom)); }

/* toast */
.toast {
  position: fixed; left: var(--s3); right: var(--s3); bottom: calc(var(--tab-h) + 88px + env(safe-area-inset-bottom)); z-index: 60;
  background: var(--raised); border: 1px solid var(--line); border-radius: var(--r); padding: 8px 8px 8px var(--s3); display: flex; align-items: center; gap: var(--s2);
  max-width: 560px; margin: 0 auto; animation: up .18s ease;
}
.toast .msg { flex: 1; }
.toast .btn { min-height: 44px; }

/* recorder */
.rec-time { font: 600 40px/1 var(--display); text-align: center; margin: var(--s3) 0 var(--s1); }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); display: inline-block; margin-right: 8px; animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* skeleton (Rule 3) */
.skel { background: linear-gradient(90deg, var(--surface), var(--raised), var(--surface)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: var(--r); height: 56px; margin-bottom: var(--s2); }
@keyframes sk { to { background-position: -200% 0; } }

/* hints (Rule 10) */
.hintbox { display: flex; gap: var(--s2); align-items: flex-start; background: var(--accent-tint); border-radius: var(--r); padding: var(--s3); margin-bottom: var(--s3); }
.hintbox p { flex: 1; margin: 0; font-size: 14px; }

.empty { text-align: center; padding: var(--s5) var(--s3); color: var(--dim); }
.empty svg { width: 40px; height: 40px; color: var(--faint); margin-bottom: var(--s2); }
.empty p { max-width: 36ch; margin: 0 auto var(--s3); }

.seg { border-top: 1px solid var(--line); padding-top: var(--s3); margin-top: var(--s3); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px var(--s3); font-size: 14px; margin: var(--s2) 0; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; }
details > summary { cursor: pointer; min-height: 44px; display: flex; align-items: center; color: var(--dim); font-size: 14px; }
audio { width: 100%; height: 44px; margin: var(--s2) 0; }
.blocked { padding: var(--s5) var(--s3); text-align: center; }

@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }
@media (min-width: 760px) { .bar { justify-content: center; } .bar .btn.primary { max-width: 480px; } }
