:root {
  color-scheme: light;
  --bg: #f7f1e9;
  --bg-2: #f0e6d9;
  --bg-glow: #fbe4cf;
  --bg-glow-2: #f4e3cf;
  --card: #fffdfa;
  --line: #e9dccb;
  --line-strong: #dcc8b1;
  --text: #2c2118;
  --muted: #8b7562;
  --accent: #c2571a;
  --accent-2: #e07a2f;
  --accent-soft: #fbe8da;
  --danger: #b23a30;
  --ok: #2f7d4f;
  --shadow: 0 1px 2px rgba(92, 54, 16, .05), 0 10px 30px rgba(92, 54, 16, .07);
  --radius: 16px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #171310;
    --bg-2: #221b15;
    --bg-glow: #2a1b11;
    --bg-glow-2: #241a13;
    --card: #211a15;
    --line: #392d24;
    --line-strong: #4b3b2e;
    --text: #f3e9df;
    --muted: #b29c88;
    --accent: #e8894b;
    --accent-2: #f0a468;
    --accent-soft: #3a2417;
    --danger: #ff8174;
    --ok: #6cc08a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 8% -10%, var(--bg-glow), transparent 70%),
    radial-gradient(700px 360px at 100% 0%, var(--bg-glow-2), transparent 65%),
    var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", "PingFang SC", sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-text-size-adjust: 100%;
  padding-bottom: env(safe-area-inset-bottom);
}

.top {
  max-width: 1160px;
  margin: 0 auto;
  padding: 20px 22px 12px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  box-shadow: var(--shadow);
  flex: none;
}

.brand-text { min-width: 0; }

.brand h1 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.25;
}

.brand p {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

.layout {
  max-width: 1160px;
  margin: 0 auto;
  padding: 8px 22px 28px;
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(0, .88fr);
  gap: 18px;
  align-items: start;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
}

.card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0 0 12px;
}

.card-head h2 {
  margin: 0;
  font-size: 14.5px;
  font-weight: 600;
}

.count, .sync {
  font-size: 11.5px;
  color: var(--muted);
  font-weight: 400;
}

.sync { margin-left: auto; }

.head-actions {
  margin-left: auto;
  display: flex;
  gap: 6px;
}

.field { margin: 0 0 15px; }

.label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: .02em;
}

.label-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 6px;
}

.label-row .label { margin: 0; }

.hint {
  font-size: 11.5px;
  color: var(--muted);
  text-align: right;
}

.opt {
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
}

.input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.input::placeholder { color: var(--muted); opacity: .8; }

.input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.kind {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.kind button {
  appearance: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 9px 4px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 13.5px;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease;
}

.kind button em {
  font-style: normal;
  font-size: 11px;
  color: var(--muted);
}

.kind button:hover { background: var(--bg); }

.kind button.is-on {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.kind button.is-on em { color: var(--accent); }

.menu {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.menu-rule {
  margin: -2px 0 8px;
  font-size: 11.5px;
  color: var(--muted);
}

.dish {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: var(--card);
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, opacity .12s ease;
}

.dish:hover {
  border-color: var(--accent-2);
  background: var(--bg);
}

.dish.is-picked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dish.is-locked {
  cursor: default;
}

.dish.is-locked:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.dish.is-disabled {
  opacity: .45;
  cursor: default;
}

.dish.is-disabled:hover {
  border-color: var(--line-strong);
  background: var(--card);
}

.dish-check {
  flex: none;
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.dish.is-disabled .dish-check {
  cursor: default;
}

.dish-name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  line-height: 1.35;
}

.dish-price {
  flex: none;
  font-size: 11px;
  color: var(--muted);
}

.picked {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 26px;
  margin-top: 8px;
}

.pick {
  appearance: none;
  border: 1px dashed var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 999px;
  padding: 2px 9px;
  font: inherit;
  font-size: 11.5px;
  cursor: pointer;
}

.pick:hover { background: var(--accent-soft); }

.submit-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  margin-top: 2px;
}

.price {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
  min-width: 70px;
}

.price span { font-size: 11px; color: var(--muted); }

.price strong {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: .01em;
}

.submit-bar .btn-primary {
  flex: 1;
  padding: 11px 16px;
  font-size: 14px;
}

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-decoration: none;
  cursor: pointer;
  transition: background .12s ease, border-color .12s ease, color .12s ease, filter .12s ease;
}

.btn:hover:not(:disabled) { background: var(--bg); }

.btn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent);
  border-color: var(--accent);
  filter: brightness(1.06);
}

.btn:disabled,
.btn-primary:disabled {
  opacity: .45;
  cursor: default;
  filter: none;
}

.btn-quiet { background: var(--card); }

.btn-sm { padding: 5px 10px; font-size: 12px; }

.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line-strong)); }

.btn-danger:hover:not(:disabled) { background: color-mix(in srgb, var(--danger) 8%, var(--card)); }

.btn-danger.is-armed {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.list-card {
  position: sticky;
  top: 14px;
  display: flex;
  flex-direction: column;
  max-height: calc(100dvh - 28px);
  padding: 0;
}

.list-card .card-head {
  padding: 15px 16px 11px;
  margin: 0;
  border-bottom: 1px solid var(--line);
}

.orders {
  flex: 1;
  min-height: 80px;
  overflow: auto;
  padding: 10px 12px 4px;
}

.order {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  padding: 10px 12px;
  margin: 0 0 8px;
}

.order-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.order-index {
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 10.5px;
  line-height: 18px;
  text-align: center;
}

.order-person {
  font-size: 14px;
  font-weight: 600;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.order-kind {
  flex: none;
  font-size: 10.5px;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 38%, transparent);
  border-radius: 999px;
  padding: 0 7px;
  line-height: 16px;
}

.order-price {
  margin-left: auto;
  flex: none;
  font-size: 13.5px;
  font-weight: 600;
}

.order-items {
  margin: 5px 0 0 28px;
  font-size: 12.5px;
  color: var(--muted);
  word-break: break-word;
}

.order-note {
  margin: 3px 0 0 28px;
  font-size: 11.5px;
  color: var(--muted);
}

.order-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.link {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11.5px;
  padding: 2px 0;
  cursor: pointer;
}

.link:hover { color: var(--text); }

.link.danger:hover,
.link.danger.is-armed { color: var(--danger); }

.link.is-armed { font-weight: 600; }

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 34px 10px;
  margin-bottom: 8px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 12px;
}

.empty p {
  margin: 0;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
}

.empty span { font-size: 12px; }

.by-dish { padding: 4px 16px 0; }

.by-dish h3 {
  margin: 8px 0 6px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--muted);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11.5px;
}

.chip b {
  color: var(--accent);
  font-weight: 600;
}

.list-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 16px 0;
}

.preview {
  width: calc(100% - 32px);
  min-height: 140px;
  margin: 10px 16px 0;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  color: var(--text);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  resize: vertical;
}

.preview:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.list-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid var(--line);
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.list-foot strong {
  margin-left: auto;
  color: var(--text);
  font-size: 14.5px;
}

.page-foot {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 22px 26px;
  font-size: 11.5px;
  color: var(--muted);
  text-align: center;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translate(-50%, 8px);
  max-width: min(92vw, 480px);
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--text);
  color: var(--card);
  font-size: 13px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 50;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.copy-helper {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.login-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(360px, 100%);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 28px 24px 24px;
  text-align: center;
}

.login-card img {
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.login-card h1 {
  margin: 12px 0 4px;
  font-size: 20px;
}

.login-card p {
  margin: 0 0 16px;
  font-size: 13px;
  color: var(--muted);
}

.login-card form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.login-card .btn-primary {
  padding: 10px 14px;
  font-size: 14px;
}

.login-error {
  margin: 0 0 12px;
  color: var(--danger);
  font-size: 12.5px;
}

@media (max-width: 900px) {
  .top { padding: 16px 14px 10px; }
  .brand h1 { font-size: 18px; }
  .brand p { white-space: normal; font-size: 12px; }
  .layout {
    grid-template-columns: 1fr;
    padding: 6px 14px 22px;
    gap: 14px;
  }
  .card { padding: 14px; }
  .list-card {
    position: static;
    max-height: none;
  }
  .list-card .card-head { padding: 14px 14px 10px; }
  .orders { overflow: visible; max-height: none; }
  .by-dish { padding: 2px 14px 0; }
  .list-actions { padding: 10px 14px 0; }
  .preview { width: calc(100% - 28px); margin: 10px 14px 0; }
  .list-foot { padding: 11px 14px; }
}

@media (max-width: 420px) {
  .top-actions .pill { font-size: 11px; padding: 4px 9px; }
  .brand-mark { width: 38px; height: 38px; }
  .menu { gap: 7px; }
  .dish { padding: 8px 9px; }
}

@media (pointer: coarse) {
  .input { font-size: 16px; }
}
