:root {
  --ink: #f3eee6;
  --muted: #9a9188;
  --bg: #05040a;
  --card: #14101a;
  --line: rgba(255, 255, 255, 0.09);
  --gold: #d4b06a;
  --velvet: #7a2432;
  --cream: #efe6d6;
  --serif: Fraunces, Georgia, serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}
.app {
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  padding-bottom: 72px;
  background:
    radial-gradient(480px 220px at 50% -5%, rgba(122, 36, 50, 0.4), transparent 60%),
    var(--bg);
}
.screen { display: none; }
.screen.is-active { display: block; }

.topbar {
  display: grid;
  grid-template-columns: 40px 1fr 40px;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  position: sticky;
  top: 0;
  z-index: 8;
  background: linear-gradient(180deg, rgba(5, 4, 10, 0.92), rgba(5, 4, 10, 0.55) 70%, transparent);
}
.topbar.solid {
  background: rgba(5, 4, 10, 0.96);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(10px);
}
.titles { text-align: center; }
.brand {
  margin: 0;
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  font-weight: 700;
}
.topbar h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.15rem;
  font-weight: 560;
  letter-spacing: -0.02em;
}
.icon, .badge {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(20, 16, 26, 0.85);
  color: var(--ink);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}
.badge { width: auto; padding: 0 12px; color: var(--muted); font-size: 0.75rem; }

.sticky { position: relative; }
.stage-frame {
  height: min(46vh, 400px);
  min-height: 260px;
  background: #000;
  overflow: hidden;
}
#stage-canvas { display: block; width: 100%; height: 100%; }

.floor {
  padding: 10px 12px 6px;
  background: #0e0c14;
  border-bottom: 1px solid var(--line);
}
.seg {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  margin-bottom: 8px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
}
.seg.trio { grid-template-columns: 1fr 1fr 1fr; }
.seg.quad { grid-template-columns: repeat(4, 1fr); }
.seg-b {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 9px;
  padding: 10px 6px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 650;
  cursor: pointer;
}
.seg-b.on {
  background: var(--velvet);
  color: #fff;
  box-shadow: 0 4px 14px rgba(122, 36, 50, 0.35);
}
.open-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
.op {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--muted);
  border-radius: 999px;
  padding: 7px 11px;
  font: inherit;
  font-size: 0.75rem;
  cursor: pointer;
}
.op.on {
  border-color: rgba(212, 176, 106, 0.5);
  color: var(--gold);
  background: rgba(212, 176, 106, 0.12);
}
.open-line {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
}
input[type="range"] { width: 100%; accent-color: var(--gold); margin: 4px 0 2px; }

.sheet { padding: 16px 16px 28px; }
.venues {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.venue {
  border: 1px solid var(--line);
  background: var(--card);
  color: var(--ink);
  border-radius: 14px;
  padding: 12px 6px;
  text-align: center;
  font: inherit;
  cursor: pointer;
}
.venue strong { display: block; font-size: 0.92rem; }
.venue span { color: var(--muted); font-size: 0.7rem; }
.venue.on {
  border-color: var(--gold);
  background: linear-gradient(165deg, #3a1820, var(--card));
}

.live-price {
  margin: 0;
  font-family: var(--serif);
  font-size: 1.85rem;
  color: var(--gold);
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.live-sub { margin: 4px 0 14px; color: var(--muted); font-size: 0.82rem; line-height: 1.35; }

.block-title {
  margin: 16px 0 8px;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 560;
}
.fabs { display: grid; gap: 8px; }
.fab {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: #1a1520;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.fab.on { border-color: var(--gold); box-shadow: inset 0 0 0 1px rgba(212, 176, 106, 0.3); }
.fab .sw {
  width: 56px;
  height: 56px;
  border-radius: 12px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}
.fab strong { display: block; font-size: 0.9rem; }
.fab small { color: var(--muted); font-size: 0.72rem; line-height: 1.3; }

.layers { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.layer {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--card);
  font-size: 0.85rem;
  cursor: pointer;
}
.layer input { accent-color: var(--velvet); }
.mini {
  display: block;
  margin: 10px 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}

.btn {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  margin-top: 12px;
  padding: 15px 16px;
  border: 0;
  border-radius: 14px;
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.btn.primary {
  background: linear-gradient(180deg, #f7f0e4, #e2d4be);
  color: #140e18;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}
.btn.ghost {
  background: transparent;
  color: var(--gold);
  border: 1px solid rgba(212, 176, 106, 0.4);
}

.scroll { padding: 10px 16px 28px; }
.lead { color: var(--muted); margin: 0 0 14px; line-height: 1.45; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 12px;
}
.card h2 {
  margin: 0 0 10px;
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 560;
}
label {
  display: block;
  margin: 10px 0 4px;
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--muted);
}
input:not([type="range"]):not([type="checkbox"]), textarea {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #1a1520;
  color: var(--ink);
  font: inherit;
}
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 10px; }

.invoice {
  background:
    radial-gradient(240px 100px at 100% 0%, rgba(122, 36, 50, 0.45), transparent),
    var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 16px;
  margin-bottom: 10px;
}
.invoice .big {
  font-family: var(--serif);
  font-size: 2rem;
  color: var(--gold);
  letter-spacing: -0.03em;
}
.invoice .s { margin: 6px 0 0; color: var(--muted); font-size: 0.82rem; line-height: 1.4; }
.mech {
  background: #1a1520;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.45;
}
.mech strong { color: var(--gold); }
.q {
  display: grid;
  grid-template-columns: 8px 1fr auto;
  gap: 10px;
  align-items: start;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  margin-bottom: 8px;
}
.q .bar { width: 8px; min-height: 42px; border-radius: 6px; background: var(--sw, var(--velvet)); }
.q strong { display: block; font-size: 0.92rem; }
.q .s { color: var(--muted); font-size: 0.76rem; line-height: 1.35; margin-top: 3px; }
.q .sum { font-weight: 700; font-size: 0.88rem; white-space: nowrap; color: var(--ink); }
.more {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: var(--card);
}
.more summary { cursor: pointer; color: var(--muted); font-weight: 600; font-size: 0.88rem; }
.checks { margin: 8px 0 0; padding-left: 1.1rem; color: var(--muted); font-size: 0.84rem; line-height: 1.4; }
.docs { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
.doc {
  border: 1px solid rgba(212, 176, 106, 0.35);
  background: transparent;
  color: var(--gold);
  border-radius: 12px;
  padding: 12px 8px;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 650;
  cursor: pointer;
}
.note { color: var(--muted); font-size: 0.85rem; }
.link { display: inline-block; margin-top: 14px; color: var(--gold); }

.drawer[hidden] { display: none !important; }
.drawer {
  position: fixed;
  inset: 0;
  z-index: 40;
  max-width: 430px;
  margin: 0 auto;
}
.drawer-bg { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.drawer-panel {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  max-height: 88vh;
  border-radius: 20px 20px 0 0;
  background: #121018;
  border-top: 1px solid var(--line);
  display: flex;
  flex-direction: column;
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}
.drawer-head h2 { margin: 0; font-family: var(--serif); font-size: 1.15rem; font-weight: 560; }
.drawer-body { overflow: auto; padding: 8px 16px calc(24px + env(safe-area-inset-bottom)); }

.bottom {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(430px, 100%);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 8px 4px calc(8px + env(safe-area-inset-bottom));
  background: rgba(5, 4, 10, 0.94);
  border-top: 1px solid var(--line);
  backdrop-filter: blur(12px);
  z-index: 20;
}
.bottom button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.68rem;
  font-weight: 650;
  padding: 6px 2px;
  cursor: pointer;
}
.bottom button i {
  display: block;
  width: 18px;
  height: 3px;
  margin: 0 auto 6px;
  border-radius: 2px;
  background: var(--line);
}
.bottom button.on { color: var(--ink); }
.bottom button.on i { background: var(--gold); }

#toast {
  position: fixed;
  left: 50%;
  bottom: 86px;
  transform: translateX(-50%);
  background: #241e30;
  color: #fff;
  padding: 10px 14px;
  border-radius: 12px;
  font-size: 0.85rem;
  z-index: 50;
  max-width: 88%;
  border: 1px solid var(--line);
}
