:root {
  --bg: #f5f7fa;
  --card: #ffffff;
  --ink: #1f2733;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #b4283c;
  --accent-ink: #ffffff;
  --pop: #0f172a;
  --perf: #94a3b8;
  --shadow: 0 1px 2px rgba(15,23,42,.06), 0 8px 24px rgba(15,23,42,.06);
  --radius: 14px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.55;
  font-size: 17px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 18px; }

/* header / footer / crumbs */
.site-head { border-bottom: 1px solid var(--line); background: var(--card); }
.site-head .wrap { display: flex; align-items: center; justify-content: space-between; height: 58px; }
.brand { font-weight: 800; font-size: 19px; color: var(--pop); letter-spacing: -.02em; }
.brand:hover { text-decoration: none; }
.nav a { color: var(--muted); font-size: 15px; margin-left: 18px; }
.crumbs { font-size: 13px; color: var(--muted); margin: 18px 0 4px; }
.crumbs a { color: var(--muted); }
h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.02em; margin: 10px 0 14px; }
.lead { color: var(--muted); margin: 0 0 20px; }
h2 { font-size: 20px; margin: 30px 0 12px; letter-spacing: -.01em; }
.site-foot { border-top: 1px solid var(--line); margin-top: 40px; padding: 22px 0 50px; color: var(--muted); font-size: 14px; background: var(--card); }
.site-foot a { color: var(--muted); }
.site-foot .wrap { display: flex; flex-wrap: wrap; gap: 8px 18px; }

/* controls */
.controls { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; margin: 8px 0 18px; }
.controls label { display: block; font-size: 13px; color: var(--muted); margin: 0 0 5px; font-weight: 600; }
.row { display: flex; flex-wrap: wrap; gap: 14px; }
.row + .row { margin-top: 14px; }
.row > div { flex: 1; min-width: 130px; }
.row > div.titlecell { flex: 2; min-width: 220px; }
input, select { width: 100%; padding: 10px 12px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fff; color: var(--ink); }
.ctl-foot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 14px; }
.print-btn { font: inherit; font-weight: 700; font-size: 16px; cursor: pointer; background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 11px 20px; }
.print-btn:hover { filter: brightness(1.1); }
.hint { color: var(--muted); font-size: 13px; }

/* ticket sheets — the artifact IS the page */
.ticket-wrap { margin: 0 0 22px; }
.ticket-page {
  display: grid;
  grid-template-columns: repeat(var(--cols, 2), 1fr);
  gap: 10px;
  margin: 0 0 16px;
}
.ticket {
  display: flex;
  border: 1.5px solid var(--pop);
  border-radius: 6px;
  overflow: hidden;
  min-height: 96px;
  background: #fff;
  box-shadow: var(--shadow);
}
.ticket-main {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 6px;
  border-left: 5px solid var(--accent);
}
.tk-body { min-width: 0; }
.tk-title { font-weight: 800; font-size: 15px; line-height: 1.15; letter-spacing: -.01em; color: var(--pop); word-break: break-word; }
.tk-title:empty::before { content: "\200b"; }
.tk-sub { font-size: 12px; color: var(--muted); margin-top: 3px; word-break: break-word; }
.tk-num { font-weight: 800; font-size: 14px; color: var(--accent); white-space: nowrap; }

/* tear-off stub */
.ticket.has-stub .ticket-stub {
  flex: 0 0 33%;
  min-width: 0;
  padding: 8px 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #fbfbfc;
  border-left: 2px dashed var(--perf);
}
.tk-stub-top { font-weight: 700; font-size: 10.5px; line-height: 1.15; color: var(--pop); word-break: break-word; }
.tk-stub-num { font-size: 12px; }
.tk-stub-lines { display: flex; flex-direction: column; gap: 5px; margin-top: 2px; }
.tk-stub-line { display: flex; align-items: baseline; gap: 4px; font-size: 10px; color: var(--muted); }
.tk-stub-line i { flex: 1; border-bottom: 1px solid #cbd5e1; height: 10px; }

/* show / hide numbers */
.hide-nums .tk-num { display: none; }

/* link grids */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin-bottom: 10px; }
.grid a { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; color: var(--ink); font-size: 15px; }
.grid a:hover { border-color: var(--accent); text-decoration: none; }
.chip-emoji { margin-right: 6px; }

/* prose + ads */
.prose { margin: 22px 0; }
.prose p { margin: 0 0 14px; }
.ad-slot {
  margin: 22px 0;
  min-height: 90px;
  display: flex; align-items: center; justify-content: center;
  background: repeating-linear-gradient(45deg, #eef2f6, #eef2f6 10px, #f4f7fa 10px, #f4f7fa 20px);
  border: 1px dashed #cbd5e1;
  border-radius: 10px;
  color: #94a3b8; font-size: 12px; letter-spacing: .1em; text-transform: uppercase;
}

@media (max-width: 620px) {
  h1 { font-size: 23px; }
  .ticket-page { grid-template-columns: repeat(min(var(--cols, 2), 2), 1fr); }
  .tk-title { font-size: 14px; }
}

/* print: the tickets are the page, everything else disappears */
@media print {
  body { background: #fff; font-size: 12pt; }
  .no-print, .ad-slot { display: none !important; }
  .wrap { max-width: none; padding: 0; }
  .ticket-wrap { margin: 0; }
  .ticket-page { gap: 0.16in; margin: 0; page-break-after: always; break-after: page; }
  .ticket-page:last-child { page-break-after: auto; break-after: auto; }
  .ticket {
    break-inside: avoid;
    min-height: 1.15in;
    box-shadow: none;
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
  .ticket-main, .ticket-stub, .tk-num, .tk-title {
    -webkit-print-color-adjust: exact; print-color-adjust: exact;
  }
}
