:root {
  --bg: #15171c;
  --surface: #1e2128;
  --surface-2: #272b34;
  --line: #333846;
  --text: #ebe9e2;
  --muted: #9aa0ad;
  --faint: #6b7180;
  --tag: #f2c94c;            /* 整理番号 = チケット半券の色 */
  --tag-ink: #1a1500;
  --acquired: #4fc47f;
  --awaiting: #f0a33a;
  --applied: #5aa9e6;
  --won: #b58cf2;
  --lost: #6b7180;
  --danger: #e5645a;
  --radius: 10px;
  font-size: 16px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", sans-serif;
  line-height: 1.45; -webkit-text-size-adjust: 100%; padding-bottom: 90px;
}
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
input, select, textarea {
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; width: 100%;
}
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--tag); outline-offset: 1px; }
textarea { min-height: 88px; resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
.num { font-variant-numeric: tabular-nums; }

/* ---- ヘッダ ---- */
.top {
  position: sticky; top: 0; z-index: 20; background: rgba(21,23,28,.94); backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line); padding: 10px 14px 0;
}
.top-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.top-row h1 { font-size: 1.05rem; margin: 0; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-row .back { color: var(--muted); font-size: 1.2rem; padding: 4px 6px 4px 0; }
.menu-btn { background: none; border: 0; color: var(--muted); font-size: 1.4rem; padding: 2px 8px; letter-spacing: 1px; }
.menu { position: absolute; right: 10px; top: 46px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--radius);
  min-width: 190px; box-shadow: 0 10px 30px rgba(0,0,0,.5); display: none; z-index: 30; }
.menu.open { display: block; }
.menu a, .menu button { display: block; width: 100%; text-align: left; padding: 12px 16px; background: none; border: 0; border-bottom: 1px solid var(--line); }
.menu a:last-child, .menu button:last-child { border-bottom: 0; }
.seg { display: flex; gap: 0; margin-top: 8px; }
.seg a { flex: 1; text-align: center; padding: 8px 0 10px; color: var(--muted); border-bottom: 2px solid transparent; font-size: .95rem; }
.seg a.on { color: var(--text); border-bottom-color: var(--tag); }
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 9px; background: var(--danger); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; margin-left: 4px; vertical-align: 2px; }

main { padding: 12px 14px; max-width: 720px; margin: 0 auto; }
.flash { background: #2c3141; border-left: 3px solid var(--tag); padding: 10px 12px; border-radius: 6px; margin-bottom: 12px; font-size: .92rem; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .82rem; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.right { text-align: right; }
.mt { margin-top: 14px; }
.hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
h2 { font-size: 1rem; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }

/* ---- ボタン ---- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface-2); cursor: pointer; white-space: nowrap; }
.btn.primary { background: var(--tag); color: var(--tag-ink); border-color: var(--tag); font-weight: 600; }
.btn.danger { color: var(--danger); border-color: #5a3532; }
.btn.sm { padding: 6px 10px; font-size: .85rem; }
.btn.block { width: 100%; }
.btn.ghost { background: none; }
.fab { position: fixed; right: 16px; bottom: 22px; width: 54px; height: 54px; border-radius: 50%; background: var(--tag); color: var(--tag-ink);
  font-size: 1.7rem; display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 20px rgba(0,0,0,.45); z-index: 15; border: 0; }

/* ---- イベント一覧 ---- */
.day { margin: 14px 0 6px; font-size: .85rem; color: var(--muted); display: flex; align-items: baseline; gap: 8px; }
.day b { color: var(--text); font-size: 1rem; }
.day.today b { color: var(--tag); }
.ev { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; background: var(--surface); border-radius: var(--radius); margin-bottom: 8px; }
.ev .name { font-weight: 600; grid-column: 1 / -1; }
.ev .venue { color: var(--muted); font-size: .85rem; }
.ev .counts { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }

/* ---- 状態チップ ---- */
.chip { display: inline-block; padding: 2px 8px; border-radius: 6px; font-size: .78rem; line-height: 1.5; border: 1px solid transparent; white-space: nowrap; }
.chip.acquired { color: var(--acquired); border-color: color-mix(in srgb, var(--acquired) 40%, transparent); }
.chip.awaiting_payment { color: var(--awaiting); border-color: color-mix(in srgb, var(--awaiting) 40%, transparent); }
.chip.applied { color: var(--applied); border-color: color-mix(in srgb, var(--applied) 40%, transparent); }
.chip.won { color: var(--won); border-color: color-mix(in srgb, var(--won) 40%, transparent); }
.chip.lost, .chip.cancelled, .chip.not_applied { color: var(--lost); border-color: #3a3f4d; }
.chip.n { background: var(--surface-2); color: var(--muted); }
.chip.ok { color: var(--acquired); } .chip.needs_review { color: var(--awaiting); } .chip.error { color: var(--danger); } .chip.unsupported, .chip.ignored { color: var(--lost); }
.chip.prov { color: var(--tag); border-color: color-mix(in srgb, var(--tag) 45%, transparent); }
.chip.req { color: var(--won); border-color: color-mix(in srgb, var(--won) 40%, transparent); }

/* ---- イベント詳細 ---- */
.evhead { padding: 6px 0 10px; }
.evhead .date { color: var(--tag); font-weight: 600; }
.evhead .venue { color: var(--muted); }
.evhead .meta { color: var(--faint); font-size: .85rem; margin-top: 2px; }
.sortbar { display: flex; gap: 6px; overflow-x: auto; padding: 6px 0 10px; scrollbar-width: none; }
.sortbar::-webkit-scrollbar { display: none; }
.sortbar button { flex: 0 0 auto; padding: 6px 12px; border-radius: 16px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); font-size: .85rem; }
.sortbar button.on { color: var(--text); border-color: var(--tag); }
.sortbar button.on::after { content: " ↑"; } .sortbar button.on.desc::after { content: " ↓"; }
.group { margin: 12px 0 4px; font-size: .85rem; color: var(--muted); display: flex; justify-content: space-between; align-items: baseline; }
.group .sec { color: var(--faint); }
.tk { display: grid; grid-template-columns: minmax(64px, auto) 1fr auto; align-items: center; gap: 4px 10px;
  background: var(--surface); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 6px; }
.tk .no { font-size: 1.35rem; font-weight: 700; color: var(--tag); letter-spacing: .5px; line-height: 1.1; word-break: break-all; }
.tk .no.none { color: var(--faint); font-weight: 400; }
.tk .mid { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tk .line { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: .85rem; color: var(--muted); }
.tk .line .k { color: var(--faint); }
.tk .line i { color: var(--faint); }
.tk .sec { color: var(--faint); font-size: .8rem; }
.tk .act { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; }
.tk .chipbtn { background: none; border: 0; padding: 0; }
.tk .hand { padding: 6px 10px; font-size: .82rem; }
.tk .hand.has { border-color: color-mix(in srgb, var(--tag) 50%, transparent); }
.tk.handed { opacity: .55; }
.tk.lost .no { color: var(--faint); }

/* ---- カード ---- */
.card { background: var(--surface); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.card h3 { margin: 0 0 6px; font-size: .95rem; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: .9rem; }
.kv dt { color: var(--faint); } .kv dd { margin: 0; word-break: break-all; }
details summary { cursor: pointer; color: var(--muted); padding: 8px 0; }
pre { background: #0f1115; padding: 10px; border-radius: 8px; overflow: auto; font-size: .78rem; white-space: pre-wrap; word-break: break-all; max-height: 60vh; }
.list a.item, .item { display: block; padding: 12px 14px; background: var(--surface); border-radius: var(--radius); margin-bottom: 8px; }
.item .t { font-weight: 600; }
.item .s { color: var(--muted); font-size: .85rem; margin-top: 2px; }
.issues { color: var(--awaiting); font-size: .85rem; margin: 4px 0 0; padding-left: 16px; }

/* ---- ボトムシート ---- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: none; z-index: 40; }
.sheet-bg.open { display: block; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; background: var(--surface-2); border-radius: 16px 16px 0 0; padding: 12px 16px 28px;
  transform: translateY(100%); transition: transform .18s ease-out; z-index: 41; max-height: 85vh; overflow: auto; max-width: 720px; margin: 0 auto; }
.sheet.open { transform: translateY(0); }
.sheet::before { content: ""; display: block; width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet h3 { margin: 0 0 10px; font-size: 1rem; }
.sheet .opts { display: grid; gap: 8px; }
.sheet .opts button { text-align: left; padding: 13px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); }
.sheet .opts button.cur { border-color: var(--tag); }
.copyrow { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); }
.copyrow .k { color: var(--faint); font-size: .85rem; } .copyrow .v { word-break: break-all; font-size: .9rem; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 20px;
  font-size: .85rem; opacity: 0; transition: opacity .15s; pointer-events: none; z-index: 50; }
.toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { .sheet { transition: none; } }
