:root {
  --bg: #f6f5f1;
  --card: #ffffff;
  --ink: #16171a;
  --muted: #676a70;
  --line: #e3e0d8;
  --soft: #efede7;
  --ok: #1f7a4d;
  --warn: #9a6200;
  --bad: #b42318;
  --radius: 14px;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: inherit; }
button { font: inherit; }
[hidden] { display: none !important; }

.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px clamp(16px, 4vw, 40px);
}
.brand { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; letter-spacing: -0.02em; text-decoration: none; }
.mark { width: 18px; height: 18px; border-radius: 5px; background: linear-gradient(135deg, #16171a 0 50%, #c9a227 50% 100%); }
.beta { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; padding: 2px 7px; border-radius: 999px; background: var(--ink); color: #fff; }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.avatar { width: 28px; height: 28px; border-radius: 50%; }
.who-name { max-width: 30vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

main { flex: 1; width: 100%; max-width: 1080px; margin: 0 auto; padding: 8px clamp(16px, 4vw, 40px) 40px; }
.loading { color: var(--muted); padding: 60px 0; text-align: center; }

.hero { max-width: 640px; margin: 7vh auto 0; text-align: center; }
.hero h1 { font-size: clamp(32px, 5vw, 48px); line-height: 1.08; letter-spacing: -0.03em; margin: 0 0 16px; }
.lead { font-size: 19px; color: #3a3c40; margin: 0 auto 28px; max-width: 520px; }
.gbtn { display: flex; justify-content: center; min-height: 44px; }
.facts { list-style: none; padding: 0; margin: 36px 0 24px; display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.facts li { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 12px; display: flex; flex-direction: column; gap: 2px; }
.facts strong { font-size: 15px; }
.facts span { font-size: 13px; color: var(--muted); }
.fine { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; }
.stat-label { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; }
.stat-value { font-size: 34px; font-weight: 700; letter-spacing: -0.02em; line-height: 1.2; margin: 4px 0 2px; }
.stat-of { font-size: 16px; font-weight: 500; color: var(--muted); margin-left: 6px; letter-spacing: 0; }
.stat-note { font-size: 13px; color: var(--muted); }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.drop {
  border: 2px dashed #cfcac0; border-radius: 12px; padding: 34px 16px; text-align: center; cursor: pointer;
  transition: border-color .15s, background-color .15s;
}
.drop:hover, .drop:focus-visible, .drop.over { border-color: var(--ink); background: #fbfaf7; outline: none; }
.drop.off { cursor: not-allowed; opacity: .55; }
.drop-title { font-size: 18px; font-weight: 600; }
.as-link { text-decoration: underline; text-underline-offset: 3px; }
.drop-hint { font-size: 13px; color: var(--muted); margin-top: 6px; }
.chosen { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 4px 2px; flex-wrap: wrap; }
.chosen-text { font-size: 15px; }
.chosen-text .warn { color: var(--warn); display: block; font-size: 13px; }
.chosen-actions { display: flex; gap: 8px; }
.sending { padding: 14px 4px 2px; }
.bar { height: 8px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.bar-fill { height: 100%; width: 0; background: var(--ink); transition: width .3s; }
.sending-row { display: flex; justify-content: space-between; margin-top: 8px; font-size: 14px; color: var(--muted); }
.note { margin-top: 12px; font-size: 14px; color: var(--warn); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: var(--ink); color: #fff; border: 1px solid var(--ink); border-radius: 999px;
  padding: 9px 18px; font-size: 15px; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.btn:hover { background: #2b2d31; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.ghost:hover { border-color: var(--ink); }
.btn.small { padding: 5px 12px; font-size: 13px; }
.link { background: none; border: 0; padding: 0; color: var(--muted); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font-size: 14px; }
.link:hover { color: var(--ink); }

.section { font-size: 20px; letter-spacing: -0.01em; margin: 32px 0 12px; }
.orders { display: flex; flex-direction: column; gap: 14px; }
.order { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px 16px; }
.order-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.order-title { font-weight: 600; }
.order-meta { font-size: 13px; color: var(--muted); }
.order-actions { display: flex; gap: 8px; align-items: center; }
.pill { font-size: 12px; font-weight: 600; padding: 3px 10px; border-radius: 999px; background: var(--soft); color: var(--muted); }
.pill.ok { background: #e3f3ea; color: var(--ok); }
.pill.work { background: #fbf0d9; color: var(--warn); }
.pill.bad { background: #fbe5e2; color: var(--bad); }
.order-status { font-size: 14px; color: #3a3c40; margin: 6px 0 0; }
.mini-bar { height: 4px; background: var(--soft); border-radius: 999px; overflow: hidden; margin-top: 8px; }
.mini-bar > div { height: 100%; background: var(--warn); transition: width .4s; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.tile { position: relative; aspect-ratio: 3 / 2; border-radius: 8px; overflow: hidden; background: var(--soft); border: 0; padding: 0; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .label { position: absolute; inset: auto 0 0 0; font-size: 11px; padding: 3px 6px; background: rgba(0,0,0,.55); color: #fff; text-align: left; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile.wait { cursor: default; background: linear-gradient(100deg, var(--soft) 30%, #f8f6f1 50%, var(--soft) 70%); background-size: 300% 100%; animation: shimmer 1.6s infinite linear; }
.tile.miss { cursor: default; display: flex; align-items: center; justify-content: center; text-align: center; font-size: 12px; color: var(--muted); padding: 6px; }
.tile .flagmark { position: absolute; top: 5px; right: 5px; font-size: 10px; background: #fff; color: var(--ink); border-radius: 999px; padding: 1px 6px; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

.foot { display: flex; gap: 18px; justify-content: center; align-items: center; padding: 20px; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.foot a { color: var(--muted); }

.viewer { position: fixed; inset: 0; background: rgba(12,12,14,.96); color: #fff; display: flex; flex-direction: column; z-index: 50; }
.viewer-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; flex-wrap: wrap; }
.viewer-name { font-size: 14px; opacity: .85; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn.light { background: #fff; color: #111; border-color: #fff; }
.btn.ghost.light { background: transparent; color: #fff; border-color: rgba(255,255,255,.35); }
.viewer-stage { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; min-height: 0; padding: 0 56px 16px; }
.viewer-stage img { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 4px; }
.nav { position: absolute; top: 50%; transform: translateY(-50%); background: rgba(255,255,255,.12); color: #fff; border: 0; width: 40px; height: 64px; border-radius: 8px; font-size: 32px; cursor: pointer; }
.nav:hover { background: rgba(255,255,255,.22); }
.prev { left: 8px; } .next { right: 8px; }
.flag-form { padding: 0 16px 16px; display: flex; flex-direction: column; gap: 6px; max-width: 640px; margin: 0 auto; width: 100%; }
.flag-form textarea { width: 100%; border-radius: 8px; border: 1px solid rgba(255,255,255,.35); background: rgba(255,255,255,.08); color: #fff; padding: 8px; font: inherit; }
.flag-actions { display: flex; gap: 8px; justify-content: flex-end; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; z-index: 60; max-width: calc(100vw - 32px); }

.text-page { max-width: 720px; }
.text-page h1 { font-size: 34px; letter-spacing: -0.02em; margin: 8px 0 4px; }
.text-page h2 { font-size: 19px; margin: 26px 0 6px; }
.text-page li { margin: 6px 0; }

@media (max-width: 640px) {
  .facts { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .stat-value { font-size: 28px; }
  .viewer-stage { padding: 0 8px 12px; }
  .nav { display: none; }
}
