:root {
  --bg: #f4f2ee;
  --surface: #ffffff;
  --ink: #1d232b;
  --muted: #5b6673;
  --line: #e2ded6;
  --accent: #1f5f4a;
  --accent-ink: #ffffff;
  --accent-soft: #e3efe9;
  --danger: #a3302a;
  --danger-soft: #fbeceb;
  --notice: #fff6dd;
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
.page { max-width: 520px; margin: 0 auto; padding: 20px 16px calc(40px + env(safe-area-inset-bottom)); }
.page-wide { max-width: 760px; }

h1 { font-size: 1.7rem; line-height: 1.2; margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font-size: 1.3rem; line-height: 1.25; margin: 0 0 8px; }
h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin: 24px 0 8px; }
p { margin: 0 0 12px; }
a { color: var(--accent); }
.muted { color: var(--muted); }
.fine { font-size: 0.85rem; color: var(--muted); margin-top: 10px; }
.break { word-break: break-all; }
.eyebrow { font-size: 0.8rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--accent); margin: 0 0 4px; }

.venue-head { margin: 8px 0 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; margin-bottom: 16px; }

.field { display: block; margin-bottom: 18px; }
.label { display: block; font-weight: 600; margin-bottom: 6px; }
input[type="text"], input[type="email"], input[type="password"], textarea {
  width: 100%; font: inherit; color: inherit; background: var(--surface);
  border: 1px solid #cfc9bf; border-radius: var(--radius-sm); padding: 12px 14px;
}
textarea { resize: vertical; min-height: 110px; }
input:focus, textarea:focus, .btn:focus-visible, .chip:focus-visible, .photo-pick:focus-within {
  outline: 3px solid var(--accent-soft); outline-offset: 0; border-color: var(--accent);
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: -8px 0 18px; }
.chip {
  font: inherit; font-size: 0.9rem; padding: 7px 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--ink); cursor: pointer;
}
.chip:active { background: var(--accent-soft); border-color: var(--accent); }

.photo-pick {
  display: flex; align-items: center; justify-content: center; min-height: 56px;
  border: 1.5px dashed #bdb6aa; border-radius: var(--radius-sm); padding: 12px; cursor: pointer;
  color: var(--accent); font-weight: 600; text-align: center; position: relative;
}
.photo-pick input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.photo-preview { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.photo-preview img { width: 76px; height: 76px; object-fit: cover; border-radius: var(--radius-sm); border: 1px solid var(--line); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  min-height: 50px; padding: 12px 20px; border-radius: var(--radius-sm); border: 1px solid transparent;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--accent); color: var(--accent-ink); }
.btn-primary:disabled { opacity: 0.6; cursor: progress; }
.btn-secondary { background: var(--surface); color: var(--accent); border-color: var(--accent); }
.link-btn { background: none; border: 0; padding: 4px 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }

.alert { background: var(--danger-soft); color: var(--danger); border-radius: var(--radius-sm); padding: 12px 14px; margin-bottom: 16px; font-weight: 500; }
.notice { background: var(--notice); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.9rem; }
.flash { background: var(--accent-soft); color: var(--accent); border-radius: var(--radius-sm); padding: 10px 14px; font-weight: 600; }

.done { text-align: center; padding: 32px 20px; }
.tick { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 30px; line-height: 56px; margin: 0 auto 14px; }
.ref { font: 700 2rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace; letter-spacing: 0.04em; margin: 0 0 14px; }

/* Inbox */
.inbox-head { margin-bottom: 16px; }
.inbox-title { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-top: 14px; }
.tab { padding: 10px 16px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; margin-bottom: -1px; }
.tab-active { color: var(--ink); border-bottom-color: var(--accent); }
.count { display: inline-block; min-width: 22px; padding: 0 6px; border-radius: 999px; background: var(--line); color: var(--ink); font-size: 0.8rem; text-align: center; }
.subnav { display: flex; gap: 16px; font-size: 0.9rem; margin-top: 10px; }
.subnav a[aria-current] { color: var(--ink); font-weight: 600; text-decoration: none; }

.ticket-list { list-style: none; margin: 0; padding: 0; }
.ticket-row { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 10px; color: inherit; text-decoration: none; }
.ticket-row:hover { border-color: var(--accent); }
.row-title { display: block; font-weight: 600; margin-bottom: 4px; }
.untitled { font-weight: 500; }
.row-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; font-size: 0.85rem; color: var(--muted); }
.pill { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 1px 9px; border-radius: 999px; background: var(--line); color: var(--ink); }
.pill-open { background: var(--accent-soft); color: var(--accent); }

.back { font-size: 0.9rem; text-decoration: none; }
.ticket-ref { display: flex; justify-content: space-between; align-items: center; font: 600 0.9rem ui-monospace, SFMono-Regular, Menlo, monospace; color: var(--muted); }
.ticket-title { font-size: 1.4rem; margin-top: 4px; }
.original { margin: 0; padding: 12px 14px; background: var(--bg); border-left: 3px solid #c9c2b6; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 14px 0 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; overflow-wrap: anywhere; }
.facts-tight { margin: 0 0 10px; }
.photo { margin: 0; }
.photo img { display: block; max-width: 100%; max-height: 480px; border-radius: var(--radius-sm); border: 1px solid var(--line); }
.photo figcaption { font-size: 0.85rem; margin-top: 6px; color: var(--muted); }
.ticket-action { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); }
.status-closed { font-weight: 600; color: var(--muted); margin: 0; }

.empty { text-align: center; padding: 36px 16px; color: var(--muted); }

.email details summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.email-text { white-space: pre-wrap; font-size: 0.85rem; background: var(--bg); padding: 12px; border-radius: var(--radius-sm); overflow-wrap: anywhere; }

.poster { text-align: center; padding: 32px 20px; }
.poster h2 { font-size: 2rem; }
.qr { width: min(320px, 80vw); margin: 18px auto; }
.qr svg { width: 100%; height: auto; display: block; }

@media print {
  body { background: #fff; }
  .inbox-head, .no-print, .notice { display: none; }
  .poster { border: 0; }
}

.hint { display: block; font-size: 0.85rem; color: var(--muted); margin-top: 6px; }
.switch { text-align: center; color: var(--muted); }

/* Room buttons on the report form */
.chips-rooms { margin: 0 0 10px; }
.chips-rooms .chip { padding: 10px 14px; font-size: 0.95rem; }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chips-rooms + .hint { margin: 0 0 8px; }

/* Rooms page */
.inline { display: inline; margin: 0; }
.add-room { display: flex; gap: 8px; margin: 14px 0 4px; }
.add-room input { flex: 1; min-width: 0; }
.add-room .btn { min-height: 48px; }
.rooms { list-style: none; margin: 0; padding: 0; }
.room { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); }
.room-rename { display: flex; align-items: center; gap: 10px; flex: 1 1 220px; min-width: 0; }
.room-rename input { flex: 1; min-width: 0; padding: 9px 12px; }
.room-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn { font: inherit; font-size: 0.9rem; min-width: 40px; min-height: 40px; padding: 6px 10px; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); cursor: pointer; }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.room-next { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; margin: 22px 0 0; }
.center { text-align: center; }
.warn { color: var(--danger); font-weight: 600; }
