:root {
  --bg: #020202;
  --surface: #150e11;
  --line: #4f3c45;
  --ink: #f4ecef;
  --muted: #b49da7;
  --rose: #f990c4;
  --reading: #edd198;
  --alert: #d33a3c;
  --alert-ink: #ffedeb;
  --alert-bg: #260404;
  --dept-ink: #f7b267;
  --dept-bg: rgba(240, 138, 36, 0.14);
  --dept-line: rgba(240, 138, 36, 0.55);
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
}

*, *::before, *::after {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

html, body {
  margin: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Syne, system-ui, sans-serif;
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-font-smoothing: antialiased;
}

body.kiosk {
  display: grid;
  grid-template-rows: 72px 1fr;
}

.bar {
  position: relative;
  display: flex;
  align-items: center;
  gap: 22px;
  padding: 0 28px;
  border-bottom: 1px solid var(--line);
}

.wordmark {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 28px;
  font-weight: 500;
  letter-spacing: 0.04em;
  font-style: italic;
}

.wordmark em {
  font-style: normal;
  font-family: Caveat, "Bradley Hand", "Segoe Script", cursive;
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1;
  color: var(--rose);
  margin-left: 8px;
  position: relative;
  top: 2px;
  transform: rotate(-4deg);
  display: inline-block;
}

.clock {
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.bar-spacer { flex: 1; }

.live-meta,
.printer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.live-meta[hidden] { display: none; }

.setup-link {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
}
.setup-link:active { color: var(--ink); }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--rose);
  flex-shrink: 0;
  animation: live 2.4s var(--ease-out) infinite;
}

.printer-dot {
  background: #64748b;
  animation: none;
}

.printer[data-state="connecting"] .printer-dot {
  background: #f59e0b;
  animation: live 1.2s var(--ease-out) infinite;
}

.printer[data-state="connected"] .printer-dot {
  background: #34d399;
}

.printer[data-state="offline"] .printer-dot,
.printer[data-state="error"] .printer-dot {
  background: var(--alert);
  animation: none;
}

@keyframes live {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.28; }
}

.admin-hotspot {
  position: absolute;
  top: 0;
  right: 0;
  width: 72px;
  height: 72px;
  border: 0;
  background: transparent;
  cursor: default;
  opacity: 0;
}

.kiosk-main {
  display: grid;
  grid-template-rows: minmax(0, 1.1fr) auto minmax(300px, 0.78fr);
  height: 100%;
  min-height: 0;
  padding: 16px 20px 20px;
}

body.temps-off .kiosk-main {
  grid-template-rows: 1fr;
}

body.temps-off .rule,
body.temps-off .temps {
  display: none;
}

.print-pager {
  position: relative;
  display: grid;
  grid-template-rows: minmax(0, 1fr) 22px;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
}

.print-track {
  display: flex;
  height: 100%;
  min-height: 0;
  will-change: transform;
  transition: transform 320ms var(--ease-out);
}

.print-track.dragging { transition: none; }

.print-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 1fr 1fr;
  gap: 12px;
  min-height: 0;
  flex: 0 0 100%;
  width: 100%;
  padding-right: 0;
}

.print-grid + .print-grid { margin-left: 24px; }

.page-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding-top: 8px;
}

.page-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--line);
  transition: background 180ms var(--ease-out), transform 180ms var(--ease-out);
}

.page-dots i.on {
  background: var(--rose);
  transform: scale(1.25);
}

.page-dots:empty { display: none; }

.tile {
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 0;
  cursor: pointer;
  font: inherit;
  position: relative;
  overflow: hidden;
  transition: transform 140ms var(--ease-out), background 180ms var(--ease-out), border-color 180ms var(--ease-out);
}

.tile:active { transform: scale(0.97); }

.tile .label {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: 0.02em;
  line-height: 1.1;
}

.tile .sub {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.tile.add {
  background: transparent;
  border: 1px dashed var(--line);
  color: var(--muted);
}

.tile.add .plus {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 56px;
  font-weight: 500;
  line-height: 1;
  color: var(--muted);
}

.tile.add .sub {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tile.add.pressing { background: rgba(244, 236, 239, 0.04); }

.tile.custom .sub { color: var(--rose); }

.tile .dept,
.tile-preview .dept {
  position: absolute;
  right: 12px;
  bottom: 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dept-ink);
  background: var(--dept-bg);
  border: 1px solid var(--dept-line);
  line-height: 1.2;
}

.tile.add.add-page .plus { font-size: 44px; }
.tile.add.add-page .label {
  font-size: 22px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.tile.drag-source {
  opacity: 0.35;
  border-style: dashed;
}

.tile.drop-target {
  border-color: var(--rose);
  box-shadow: 0 0 0 2px rgba(249, 144, 196, 0.35) inset;
}

.tile.drag-ghost {
  position: fixed;
  z-index: 70;
  pointer-events: none;
  margin: 0;
  border-color: var(--rose);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.6);
  transition: none;
  will-change: transform;
}

.print-pager.dragging-tile .print-track { transition: transform 260ms var(--ease-out); }

.drag-trash {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translate(-50%, 12px);
  width: 128px;
  height: 64px;
  border-radius: 999px;
  border: 1px dashed rgba(211, 58, 60, 0.55);
  background: rgba(38, 4, 4, 0.55);
  color: #fb9890;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  z-index: 75;
  backdrop-filter: blur(6px);
  transition: opacity 180ms var(--ease-out), transform 180ms var(--ease-out), background 120ms var(--ease-out);
}

.print-pager.dragging-tile .drag-trash {
  opacity: 0.85;
  transform: translate(-50%, 0);
}

.drag-trash.hot {
  opacity: 1;
  background: rgba(211, 58, 60, 0.85);
  border-style: solid;
  border-color: var(--alert);
  color: var(--alert-ink);
  transform: translate(-50%, 0) scale(1.08);
}

.tile.drag-ghost.to-trash { opacity: 0.55; border-color: var(--alert); }

.tile.pressing::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(244, 236, 239, 0.08);
}

.tile.printing::after {
  content: "Printing…";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(2, 2, 2, 0.72);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.rule {
  height: 28px;
  margin: 4px 2px;
  border: 0;
  border-top: 1px solid var(--line);
  align-self: center;
}

.temps {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  min-height: 0;
}

.temp {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 16px 18px 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  min-width: 0;
  animation: temp-in 420ms var(--ease-out) both;
}

.temp:nth-child(1) { animation-delay: 0ms; }
.temp:nth-child(2) { animation-delay: 40ms; }
.temp:nth-child(3) { animation-delay: 80ms; }
.temp:nth-child(4) { animation-delay: 120ms; }
.temp:nth-child(5) { animation-delay: 160ms; }
.temp:nth-child(6) { animation-delay: 200ms; }

@keyframes temp-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.temp header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.temp n {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 26px;
  font-weight: 600;
  line-height: 1.15;
  letter-spacing: 0.01em;
}

.temp .dot { margin-top: 8px; }

.temp v {
  margin-top: 6px;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 56px;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 0.95;
  color: var(--reading);
}

.temp st {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.temp.offline n,
.temp.offline v { color: var(--muted); }
.temp.offline .dot {
  background: var(--muted);
  animation: none;
  opacity: 0.5;
}

.temp.alert {
  background: var(--alert-bg);
  border-color: var(--alert);
  animation: alert-pulse 2.8s var(--ease-out) infinite;
}

.temp.alert n,
.temp.alert v { color: var(--alert-ink); }
.temp.alert st { color: #fb9890; }
.temp.alert .dot {
  background: var(--alert);
  animation: none;
  opacity: 1;
}

.temp.alert.just-breached {
  animation: alert-flash 700ms var(--ease-out);
}

@keyframes alert-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(211, 58, 60, 0); }
  50% { box-shadow: 0 0 0 4px rgba(211, 58, 60, 0.35); }
}

@keyframes alert-flash {
  0% { transform: scale(1); }
  35% { transform: scale(1.03); }
  100% { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .dot, .temp, .temp.alert, .temp.alert.just-breached { animation: none; }
  .tile { transition: none; }
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(2, 2, 2, 0.78);
  display: grid;
  place-items: center;
  z-index: 50;
}

.modal[hidden] { display: none; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 28px 28px 22px;
  width: min(520px, 92vw);
}

.modal-title {
  font-size: 22px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 12px;
}

.qty-display {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 72px;
  text-align: center;
  line-height: 1;
  margin: 8px 0 16px;
}

.qty-controls, .qty-presets, .modal-actions, .btn-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.qty-btn, .preset, .btn-primary, .btn-secondary {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
}

.qty-btn { width: 64px; height: 56px; font-size: 28px; }
.preset { padding: 10px 16px; }
.btn-primary, .btn-secondary { padding: 12px 22px; margin-top: 16px; }
.btn-primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }

.create-card {
  width: min(420px, 92vw);
  padding: 26px 26px 22px;
}

.create-step[hidden] { display: none; }

.modal-eyebrow {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: center;
  margin-bottom: 6px;
}

.create-card .modal-title {
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: 30px;
  font-weight: 500;
  margin-bottom: 18px;
}

.pin-dots {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin: 4px 0 22px;
  min-height: 14px;
}

.pin-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid var(--line);
  transition: background 120ms var(--ease-out), border-color 120ms var(--ease-out);
}

.pin-dots span.on {
  background: var(--rose);
  border-color: var(--rose);
}

.pin-dots.shake {
  animation: pin-shake 360ms var(--ease-out);
}

.pin-dots.shake span {
  background: var(--alert);
  border-color: var(--alert);
}

@keyframes pin-shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.pin-key {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 26px;
  font-weight: 600;
  height: 64px;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 120ms var(--ease-out), background 120ms var(--ease-out);
}

.pin-key:active { transform: scale(0.96); background: var(--surface); }

.pin-key.ghost {
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  letter-spacing: 0.08em;
}

.name-input {
  display: block;
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-align: center;
  text-transform: uppercase;
  padding: 14px 16px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.name-input:focus { border-color: var(--rose); }
.name-input::placeholder { color: var(--line); font-weight: 600; }

.dept-block { margin-top: 14px; }

.field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.field-label span {
  letter-spacing: 0.06em;
  text-transform: none;
  opacity: 0.7;
  margin-left: 6px;
}

.dept-chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.chip {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.chip.on {
  color: var(--dept-ink);
  background: var(--dept-bg);
  border-color: var(--dept-line);
}

.dept-input {
  display: block;
  width: 100%;
  appearance: none;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 10px 12px;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}

.dept-input:focus { border-color: var(--dept-line); }
.dept-input::placeholder { color: var(--line); text-transform: none; letter-spacing: 0; font-weight: 500; }

.preview-row {
  display: flex;
  gap: 14px;
  align-items: stretch;
  justify-content: center;
  margin: 16px 0 4px;
}

.tile-preview {
  position: relative;
  width: 150px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 10px 10px 26px;
}

.tile-preview .label { font-size: 20px; font-weight: 700; letter-spacing: 0.02em; text-align: center; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tile-preview .sub { font-size: 11px; font-weight: 600; letter-spacing: 0.06em; color: var(--rose); }
.tile-preview .dept { right: 8px; bottom: 8px; font-size: 9px; padding: 3px 8px; }
.tile-preview .dept[hidden] { display: none; }

.name-preview {
  margin: 0;
  width: 200px;
  background: #fff;
  color: #000;
  border-radius: 3px;
  padding: 10px 12px 8px;
  text-align: center;
  font-family: Arial, sans-serif;
  line-height: 1.15;
}

.name-preview .np-label { font-size: 14px; font-weight: 700; text-transform: uppercase; }
.name-preview .np-time { font-size: 26px; font-weight: 700; font-variant-numeric: tabular-nums; }
.name-preview .np-date { font-size: 16px; font-weight: 700; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--ink);
  padding: 14px 22px;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  z-index: 60;
}

.toast[hidden] { display: none; }
.toast.err { border-color: var(--alert); color: var(--alert-ink); background: var(--alert-bg); }

.toast .toast-action {
  appearance: none;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--rose);
  font: inherit;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  margin-left: 14px;
  cursor: pointer;
}

#label-preview {
  position: fixed;
  left: -10000px;
  top: -10000px;
  pointer-events: none;
}
