/* ============================================================
   Döner Runde — Operate-Mode UI
   Warm paper ground, döner-red accent, chalkboard header.
   Mobile-first; structural breakpoint at 560px.
   ============================================================ */

:root {
  --bg: #f4efe4;
  --surface: #fffdf8;
  --surface-sunk: #efe8d7;
  --ink: #2a211a;
  --ink-soft: #6c5d4c;
  --ink-faint: #8f8067;
  --line: #e4dac5;
  --accent: #b8372a;
  --accent-strong: #97291d;
  --accent-tint: #f8e7e3;
  --char: #241f1d;
  --wa: #1c9d4e;
  --wa-strong: #167f3f;
  --ok: #2f7d46;

  --r-sm: 9px;
  --r: 13px;
  --r-lg: 18px;

  --shadow-sm: 0 1px 2px rgba(42, 33, 26, .06);
  --shadow: 0 1px 2px rgba(42, 33, 26, .06), 0 10px 26px -12px rgba(42, 33, 26, .22);

  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;

  --tap: 44px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17130f;
    --surface: #221c17;
    --surface-sunk: #1b1611;
    --ink: #f2e9dc;
    --ink-soft: #c3b4a0;
    --ink-faint: #9a8b76;
    --line: #382e25;
    --accent: #e2705f;
    --accent-strong: #ef8877;
    --accent-tint: #35211d;
    --char: #0f0c0a;
    --wa: #2bb765;
    --wa-strong: #35c771;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 12px 30px -12px rgba(0, 0, 0, .6);
  }
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

::selection { background: var(--accent); color: #fff; }

:where(a) { color: var(--accent); }

:where(button, input, select, a):focus-visible {
  outline: 2.5px solid var(--accent);
  outline-offset: 2px;
  border-radius: 6px;
}

* { scrollbar-width: thin; scrollbar-color: var(--line) transparent; }
*::-webkit-scrollbar { width: 10px; height: 10px; }
*::-webkit-scrollbar-thumb { background: var(--line); border-radius: 6px; border: 2px solid var(--bg); }

.icon-defs { position: absolute; width: 0; height: 0; overflow: hidden; }

.ic {
  width: 1.25em;
  height: 1.25em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Shell ---------- */

.page {
  min-height: 100dvh;
  padding-bottom: calc(28px + env(safe-area-inset-bottom));
}

.masthead {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  max-width: 620px;
  margin: 0 auto;
  padding: 22px 20px 18px;
}

.mark {
  grid-row: 1 / 3;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: var(--char);
  color: #f4efe4;
  box-shadow: var(--shadow-sm);
}
.mark .ic { width: 26px; height: 26px; stroke-width: 1.6; }

.masthead h1 {
  margin: 0;
  font-size: 1.4rem;
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.tagline {
  margin: 2px 0 0;
  font-size: 0.82rem;
  color: var(--ink-soft);
}

.conn {
  grid-column: 1 / 3;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin: 12px 0 0;
  font-size: 0.76rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--ink-soft);
  text-transform: uppercase;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-faint);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent);
}
.conn.is-online .dot { background: var(--ok); animation: pulse 2.4s ease-out infinite; }
.conn.is-offline .dot { background: var(--accent); }

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 55%, transparent); }
  70% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--ok) 0%, transparent); }
  100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--ok) 0%, transparent); }
}

.wrap {
  max-width: 620px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Panels ---------- */

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

.panel-title {
  margin: 0 0 14px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-faint);
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-badge {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0;
  color: var(--accent);
  background: var(--accent-tint);
  border-radius: 999px;
  padding: 1px 9px;
}

/* ---------- Form ---------- */

.order-form { display: flex; flex-direction: column; gap: 14px; }

.field-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}
@media (min-width: 400px) {
  .field-grid { grid-template-columns: 1fr 1fr; }
}

/* Kategorie/Gericht brauchen mehr Breite – erst spät zweispaltig */
.field-grid-wide { grid-template-columns: 1fr; }
@media (min-width: 520px) {
  .field-grid-wide { grid-template-columns: 1fr 1fr; }
}

.field { display: flex; flex-direction: column; gap: 6px; }

.label {
  font-size: 0.78rem;
  font-weight: 650;
  color: var(--ink-soft);
}
.label-hint { font-weight: 400; color: var(--ink-faint); }

input[type="text"],
input[type="number"],
select {
  width: 100%;
  min-height: var(--tap);
  padding: 11px 12px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--line);
  border-radius: var(--r-sm);
  transition: border-color .14s ease, box-shadow .14s ease;
  appearance: none;
}

input::placeholder { color: var(--ink-faint); }

input[type="text"]:hover,
input[type="number"]:hover,
select:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }

input[type="text"]:focus,
input[type="number"]:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}

select {
  padding-right: 38px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%236c5d4c' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  cursor: pointer;
}

.price-input { position: relative; }
.price-input input { padding-right: 30px; font-variant-numeric: tabular-nums; }
.price-suffix {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-faint);
  font-weight: 600;
  pointer-events: none;
}

.menu-desc {
  margin: -4px 0 0;
  font-size: 0.85rem;
  color: var(--ink-soft);
  font-style: italic;
}

/* ---------- Chips ---------- */

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}
.chip-row:empty { display: none; }

.chip {
  --chip-bd: var(--line);
  appearance: none;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 550;
  line-height: 1.15;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--chip-bd);
  border-radius: 999px;
  padding: 8px 13px;
  min-height: 36px;
  cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease, transform .1s ease;
}
.chip:hover { border-color: var(--accent); background: var(--accent-tint); }
.chip:active { transform: scale(.96); }

.chip[aria-pressed="true"],
.chip.chip-active {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.chip.chip-variant { font-weight: 700; }
.chip.chip-variant .chip-price { opacity: .8; font-weight: 600; margin-left: 4px; }

.option-block { display: flex; flex-direction: column; gap: 6px; }

/* ---------- Errors / empty ---------- */

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  font-size: 0.86rem;
  font-weight: 550;
  color: var(--accent-strong);
  background: var(--accent-tint);
  border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent);
  border-radius: var(--r-sm);
}
.form-error .ic { color: var(--accent); margin-top: 1px; }

.empty-state {
  margin: 4px 0 0;
  padding: 22px 16px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-soft);
  background: var(--surface-sunk);
  border-radius: var(--r);
}

/* ---------- Buttons ---------- */

.form-actions { display: flex; gap: 10px; align-items: center; }

.btn {
  appearance: none;
  font: inherit;
  font-size: 0.98rem;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: var(--r-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.btn:active { transform: translateY(1px); }
.btn .ic { width: 1.2em; height: 1.2em; }

.btn-primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-strong); }

.btn-ghost {
  background: transparent;
  color: var(--ink-soft);
  border-color: var(--line);
}
.btn-ghost:hover { background: var(--surface-sunk); color: var(--ink); }

.export-actions {
  max-width: 620px;
  margin: 4px auto 0;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-whatsapp { background: var(--wa); color: #fff; }
.btn-whatsapp:hover { background: var(--wa-strong); }

.btn-dark { background: var(--char); color: #f4efe4; }
.btn-dark:hover { background: #100d0c; }

.btn-reset { align-self: center; }
.btn-reset[data-armed="true"] {
  color: #fff !important;
  background: var(--accent) !important;
  border-color: var(--accent) !important;
}

/* ---------- Grouped summary ---------- */

.grouped-list { list-style: none; margin: 0; padding: 0; }
.grouped-list li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.94rem;
}
.grouped-list li:last-child { border-bottom: 0; padding-bottom: 0; }
.grouped-list li:first-child { padding-top: 0; }
.grouped-list .g-qty { font-weight: 700; color: var(--accent); }
.grouped-list .g-sum { font-variant-numeric: tabular-nums; color: var(--ink-soft); white-space: nowrap; }

/* ---------- Orders list ---------- */

.orders-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }

.order-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: "who what price" "who what actions";
  align-items: center;
  column-gap: 11px;
  row-gap: 2px;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r);
  animation: card-in .22s cubic-bezier(.2, .7, .3, 1);
}
@keyframes card-in {
  from { opacity: 0; transform: translateY(-4px); }
}

.order-card:not(.has-actions) {
  grid-template-areas: "who what price";
}

.order-card.is-mine { border-color: color-mix(in srgb, var(--accent) 32%, var(--line)); }

.who {
  grid-area: who;
  display: grid;
  place-items: center;
  min-width: 38px;
  height: 38px;
  padding: 0 7px;
  border-radius: 10px;
  background: var(--surface-sunk);
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.order-card.is-mine .who { background: var(--accent-tint); color: var(--accent-strong); }

.what { grid-area: what; min-width: 0; padding: 2px 0; }
.what .dish { display: block; font-weight: 600; font-size: 0.95rem; line-height: 1.3; }
.what .note {
  display: block;
  margin-top: 1px;
  font-size: 0.8rem;
  line-height: 1.3;
  color: var(--accent-strong);
}

.order-price {
  grid-area: price;
  align-self: end;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  text-align: right;
}
.order-card:not(.has-actions) .order-price { align-self: center; }

.order-actions {
  grid-area: actions;
  display: flex;
  justify-content: flex-end;
  gap: 2px;
  margin-right: -6px;
}

.icon-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--ink-faint);
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  cursor: pointer;
  transition: background .14s ease, color .14s ease;
}
.icon-btn:hover { background: var(--surface-sunk); color: var(--accent); }
.icon-btn:last-child:hover { color: var(--accent-strong); }
.icon-btn .ic { width: 18px; height: 18px; }

/* ---------- Total ---------- */

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-top: 14px;
  padding-top: 13px;
  border-top: 2px solid var(--line);
  font-size: 0.9rem;
  color: var(--ink-soft);
}
.total-row strong {
  font-size: 1.3rem;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}

/* ---------- Motion prefs ---------- */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .001ms !important;
  }
}

@media (min-width: 560px) {
  .wrap, .export-actions { padding-left: 0; padding-right: 0; }
  .panel { padding: 22px 22px; }
  .export-actions { flex-direction: row; flex-wrap: wrap; }
  .export-actions .btn { flex: 1; min-width: 200px; }
  .btn-reset { flex-basis: 100%; }
}
