:root {
  --bg: #f7f4ef;
  --surface: #ffffff;
  --surface-2: #f1ede6;
  --ink: #1d1a22;
  --ink-2: #4a4552;
  --muted: #7a7482;
  --line: #e3ddd3;
  --accent: #a3213a;        /* 緞帳の赤 */
  --accent-ink: #ffffff;
  --accent-soft: #f6e4e7;
  --gold: #b08a3e;
  --ok: #1f7a4d;
  --ok-soft: #e2f3ea;
  --warn: #9a6200;
  --warn-soft: #fbf0d9;
  --danger: #b42318;
  --danger-soft: #fde8e6;
  --t0: #a3213a; --t1: #2f5d8a; --t2: #3c7a55; --t3: #8a5a2f; --t4: #6b4a8a;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(29 26 34 / .06), 0 4px 16px rgb(29 26 34 / .06);
  --font: "Noto Sans JP", system-ui, -apple-system, "Hiragino Sans", sans-serif;
  --serif: "Noto Serif JP", "Hiragino Mincho ProN", serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--font); font-size: 15px; line-height: 1.75;
  font-feature-settings: "palt"; letter-spacing: .02em;
}
a { color: inherit; }
img { max-width: 100%; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.4; margin: 0 0 .5em; letter-spacing: .04em; }
h1 { font-size: clamp(24px, 4vw, 34px); }
h2 { font-size: 20px; }
h3 { font-size: 16px; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }

/* ---- ヘッダー ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgb(247 244 239 / .92); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .inner { display: flex; align-items: center; gap: 16px; height: 60px; }
.logo { display: flex; align-items: center; gap: 10px; text-decoration: none; font-family: var(--serif); font-weight: 700; font-size: 19px; letter-spacing: .08em; }
.logo-mark { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); position: relative; overflow: hidden; }
.logo-mark::before, .logo-mark::after { content: ""; position: absolute; top: 0; bottom: 0; width: 52%; background: #7d1529; border-radius: 0 0 60% 0; }
.logo-mark::before { left: 0; }
.logo-mark::after { right: 0; border-radius: 0 0 0 60%; }
.topbar nav { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.topbar nav a { text-decoration: none; font-size: 14px; padding: 6px 10px; border-radius: 8px; color: var(--ink-2); }
.topbar nav a:hover { background: var(--surface-2); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px; }
.narrow { max-width: 720px; }
main { padding: 28px 0 80px; }

/* ---- 部品 ---- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card + .card, .stack > * + * { margin-top: 16px; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.spread { display: flex; gap: 12px; align-items: center; justify-content: space-between; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .seat:focus-visible { outline: 3px solid rgb(163 33 58 / .35); outline-offset: 2px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: #8a1b31; }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.danger { color: var(--danger); }
.btn.sm { min-height: 34px; padding: 0 12px; font-size: 13px; border-radius: 8px; }
.btn.block { width: 100%; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.badge { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--ink-2); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

label.field { display: block; font-size: 13px; font-weight: 600; color: var(--ink-2); }
label.field > span { display: block; margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line);
  background: #fff; color: var(--ink); font: inherit; font-size: 16px;
}
textarea { min-height: 110px; resize: vertical; }
.form-grid { display: grid; gap: 14px; }
.form-grid.cols { grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); align-items: end; }

.alert { padding: 12px 14px; border-radius: 10px; font-size: 14px; }
.alert.error { background: var(--danger-soft); color: var(--danger); }
.alert.info { background: var(--surface-2); color: var(--ink-2); }
.hidden { display: none !important; }

table.list { width: 100%; border-collapse: collapse; font-size: 14px; }
table.list th, table.list td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.list th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.list td.r, table.list th.r { text-align: right; }
.table-scroll { overflow-x: auto; }

.stat { padding: 16px; border-radius: 12px; background: var(--surface-2); }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.stat .value { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; }

.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: inherit; }

#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; font-size: 14px; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transition: opacity .2s; max-width: calc(100vw - 32px); }
#toast.show { opacity: 1; }

/* ---- ヒーロー / 公演一覧 ---- */
.hero { padding: 40px 0 24px; }
.hero .eyebrow { color: var(--accent); font-weight: 700; font-size: 13px; letter-spacing: .12em; }
.event-card { display: flex; flex-direction: column; text-decoration: none; overflow: hidden; padding: 0; transition: transform .15s; }
.event-card:hover { transform: translateY(-2px); }
.event-card .poster { aspect-ratio: 16 / 9; background: linear-gradient(135deg, #2a1420, #a3213a 60%, #c8963f); position: relative; display: flex; align-items: flex-end; padding: 16px; color: #fff; }
.event-card .poster h3 { font-size: 20px; margin: 0; text-shadow: 0 1px 8px rgb(0 0 0 / .3); }
.event-card .body { padding: 14px 16px 16px; display: grid; gap: 4px; }

/* ---- 購入画面 ---- */
.purchase { display: grid; gap: 24px; grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
@media (max-width: 860px) { .purchase { grid-template-columns: 1fr; } }
.summary { position: sticky; top: 76px; }
.step-title { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-size: 18px; font-weight: 700; margin-bottom: 12px; }
.step-title .n { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; font-family: var(--font); font-size: 14px; display: grid; place-items: center; flex: none; }

.choice { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; cursor: pointer; background: #fff; }
.choice:hover { border-color: #cfc6b8; }
.choice:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.choice input { accent-color: var(--accent); width: 18px; height: 18px; flex: none; margin: 0; }
.choice .main { flex: 1; min-width: 0; }
.choice.disabled { opacity: .5; cursor: not-allowed; }
.choices { display: grid; gap: 8px; }

.stepper { display: inline-flex; align-items: center; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.stepper button { width: 40px; height: 40px; border: 0; background: var(--surface-2); font-size: 18px; cursor: pointer; color: var(--ink); }
.stepper output { width: 40px; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }

.line { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; padding: 4px 0; }
.line.total { border-top: 1px solid var(--line); margin-top: 8px; padding-top: 12px; font-size: 18px; font-weight: 700; }

/* ---- 座席表 ---- */
.seatmap-wrap { overflow-x: auto; padding: 8px 0 4px; }
.seatmap { display: inline-block; min-width: 100%; text-align: center; }
.stage { margin: 0 auto 18px; width: min(80%, 520px); padding: 6px; border-radius: 0 0 40px 40px; background: var(--ink); color: #fff; font-size: 12px; letter-spacing: .4em; }
.seats { display: inline-grid; grid-template-columns: 22px repeat(var(--cols), 28px) 22px; gap: 5px; justify-content: center; }
.row-label { font-size: 11px; color: var(--muted); display: grid; place-items: center; font-weight: 700; }
.seat { width: 28px; height: 28px; border-radius: 7px 7px 4px 4px; border: 0; padding: 0; cursor: pointer; background: var(--seat, var(--t1)); opacity: .9; color: #fff; font-size: 10px; font-weight: 700; }
.seat:hover { opacity: 1; transform: scale(1.08); }
.seat.taken { background: #d8d2c8 !important; cursor: not-allowed; transform: none; }
.seat.selected { background: var(--ink) !important; box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); }
.seat.void { visibility: hidden; }
.seatmap.readonly .seat { cursor: default; }
.seatmap.readonly .seat:hover { transform: none; }
.legend { display: flex; flex-wrap: wrap; gap: 8px 16px; justify-content: center; font-size: 13px; margin-top: 14px; }
.legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -2px; margin-right: 6px; }

/* ---- 会場レイアウトの座席表 ---- */
.purchase > *, .venuemap { min-width: 0; max-width: 100%; }
.venuemap .zoom { margin-bottom: 8px; }
.venue-scroll { overflow: auto; max-height: 75vh; border: 1px solid var(--line); border-radius: 12px; background: #fbfaf7; padding: 8px; }
.venue-inner { --seat-size: 14px; --aisle: calc(var(--seat-size) * .7); --lbl: calc(var(--seat-size) * 1.4); display: inline-block; min-width: 100%; text-align: center; }
.venue-stage { width: min(60%, 520px); }
.floor-name { font-weight: 700; font-size: 13px; color: var(--muted); margin: 18px 0 6px; text-align: left; }
.floor { display: flex; gap: calc(var(--seat-size) * 1.2); justify-content: center; align-items: flex-start; }
.vsection { margin-top: calc(var(--offset) * (var(--seat-size) + 2px)); }
.vsection-label { font-size: 11px; font-weight: 700; color: var(--ink-2); margin-bottom: 4px; }
.vgrid { display: grid; gap: max(1px, calc(var(--seat-size) * .14)); grid-auto-rows: var(--seat-size); }
.vgrid .row-label { font-size: max(5px, calc(var(--seat-size) * .6)); }
.vgrid .seat { width: var(--seat-size); height: var(--seat-size); border-radius: 30% 30% 18% 18%; }
.vgrid .seat.off { border: 1px solid #ddd6ca; background: transparent; cursor: default; display: block; }
.vgrid .seat.selected { box-shadow: 0 0 0 1px #fff, 0 0 0 2px var(--ink); }

/* ---- チケット ---- */
.ticket { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); padding: 18px; position: relative; box-shadow: var(--shadow); }
.ticket::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--accent); border-radius: var(--radius) 0 0 var(--radius); }
.ticket .qr { background: #fff; padding: 8px; border-radius: 10px; border: 1px solid var(--line); line-height: 0; }
.ticket .qr img, .ticket .qr canvas { width: 128px; height: 128px; }
.ticket .seat-big { font-family: var(--serif); font-size: 26px; font-weight: 700; }
.ticket.used { opacity: .6; }
@media (max-width: 520px) { .ticket { grid-template-columns: 1fr; } .ticket .qr { justify-self: start; } }

.big-qr { display: grid; place-items: center; padding: 18px; background: #fff; border-radius: 16px; border: 1px solid var(--line); line-height: 0; }
.big-qr img, .big-qr canvas { width: min(260px, 70vw); height: auto; }

/* ---- 入場受付 ---- */
.scan-result { border-radius: 16px; padding: 22px; text-align: center; min-height: 140px; display: grid; place-content: center; gap: 6px; }
.scan-result.ok { background: var(--ok-soft); color: var(--ok); }
.scan-result.warn { background: var(--warn-soft); color: var(--warn); }
.scan-result.ng { background: var(--danger-soft); color: var(--danger); }
.scan-result.idle { background: var(--surface-2); color: var(--muted); }
.scan-result .headline { font-size: 26px; font-weight: 800; font-family: var(--serif); }
#reader { border-radius: 12px; overflow: hidden; background: #000; }
#reader video { border-radius: 12px; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 20px; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 3px solid transparent; padding: 10px 14px; font: inherit; font-weight: 600; color: var(--muted); cursor: pointer; white-space: nowrap; }
.tabs button[aria-selected=true] { color: var(--accent); border-bottom-color: var(--accent); }

.mail { white-space: pre-wrap; font-size: 14px; background: var(--surface-2); padding: 14px; border-radius: 10px; margin-top: 8px; word-break: break-all; }
footer.site { border-top: 1px solid var(--line); padding: 24px 0; color: var(--muted); font-size: 13px; }

/* エラー：違反した購入ルール */
.err-msg { font-weight: 700; }
.err-rule { margin-top: 8px; padding: 8px 10px; border-radius: 8px; background: rgb(255 255 255 / .7); font-size: 13px; line-height: 1.6; }
.rules li.violated { background: var(--accent-soft); outline: 2px solid var(--accent); border-radius: 6px; padding: 2px 6px; }

/* 購入者画面の右上：主催者の管理画面ボタン */
.topbar nav a.admin-btn { border: 1px solid var(--line); background: #fff; font-weight: 600; color: var(--accent); }
.topbar nav a.admin-btn:hover { border-color: var(--accent); background: var(--accent-soft); }
@media (max-width: 520px) { .topbar nav a.admin-btn { font-size: 12px; padding: 4px 8px; } }
