:root {
  --green: #4f8a6c;
  --green-soft: #e3eee7;
  --ink: #1d2a23;
  --muted: #66746c;
  --paper: #f5f7f3;
  --line: #e1e7e1;
  --dark: #121815;
  --dark-2: #1a221e;
  --dark-line: #2a3530;
  --on-dark: #e6eee9;
  --on-dark-muted: #9aaaa1;
  --live: #ff6b5e;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--sans); color: var(--ink); -webkit-font-smoothing: antialiased; }
h1, h2 { margin: 0; letter-spacing: -.01em; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.eyebrow { margin: 0 0 .4rem; font-size: .8rem; letter-spacing: .12em; text-transform: uppercase; color: var(--green); font-weight: 600; }
.primary { border: 0; border-radius: .8rem; padding: .9rem 1.4rem; background: var(--green); color: #fff; font-size: 1.05rem; font-weight: 600; cursor: pointer; }
.primary:disabled { opacity: .6; }

/* ---------- Hub ---------- */
.home { background: var(--paper); }
.home-wrap { max-width: 52rem; margin: 0 auto; padding: 4rem 1.5rem; }
.home h1 { font-size: clamp(2rem, 5vw, 3rem); }
.lede { color: var(--muted); margin: .6rem 0 2.2rem; font-size: 1.1rem; }
.tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(17rem, 1fr)); gap: 1rem; }
.tool { display: flex; gap: 1rem; align-items: flex-start; padding: 1.3rem; border-radius: 1.1rem; background: #fff; border: 1px solid var(--line); color: inherit; text-decoration: none; transition: transform .15s, box-shadow .15s; }
a.tool:hover { transform: translateY(-2px); box-shadow: 0 12px 30px -18px rgba(29, 42, 35, .4); }
.tool h2 { font-size: 1.2rem; }
.tool p { margin: .35rem 0 0; color: var(--muted); line-height: 1.45; }
.tool-icon { flex: none; width: 3rem; height: 3rem; border-radius: .9rem; display: grid; place-items: center; background: var(--green-soft); color: var(--green); }
.tool-icon svg { width: 1.7rem; height: 1.7rem; }
.tool.soon { background: transparent; border-style: dashed; }

/* ---------- Shared dark UI ---------- */
.pill { display: inline-flex; align-items: center; gap: .45rem; padding: .35rem .8rem; border-radius: 999px; font-size: .88rem; background: rgba(255,255,255,.08); color: var(--on-dark-muted); }
.pill::before { content: ""; width: .5rem; height: .5rem; border-radius: 50%; background: currentColor; opacity: .6; }
.pill[data-kind="live"] { color: #8fe0b4; }
.pill[data-kind="live"]::before { background: var(--live); opacity: 1; box-shadow: 0 0 0 4px rgba(255,107,94,.2); }
.pill[data-kind="warn"] { color: #f2c879; }
.pill[data-kind="error"] { color: #ff9b91; }
.btn { display: inline-flex; align-items: center; gap: .45rem; border: 0; border-radius: .7rem; padding: .55rem 1rem; background: var(--green); color: #fff; font-weight: 600; cursor: pointer; }
.btn svg { width: 1.15rem; height: 1.15rem; }
.btn:disabled { opacity: .35; cursor: default; }
.btn.ghost { background: rgba(255,255,255,.08); color: var(--on-dark); }
.btn.icon-only { padding: .55rem .6rem; }

/* ---------- Presenter ---------- */
.presenter { background: var(--dark); color: var(--on-dark); overflow: hidden; }
.topbar { height: 3.6rem; display: flex; align-items: center; gap: .8rem; padding: 0 1.2rem; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; font-size: 1.1rem; color: var(--on-dark); text-decoration: none; margin-right: .4rem; }
.brand-mark { width: 1.1rem; height: 1.1rem; border-radius: 50%; border: 3px solid #8fc7a8; box-shadow: inset 0 0 0 3px var(--dark), inset 0 0 0 10px #8fc7a8; }
.spacer { flex: 1; }
.layout { height: calc(100vh - 3.6rem); display: grid; grid-template-columns: 1fr 15.5rem; gap: 1rem; padding: 0 1rem 1rem; }
.stage { position: relative; min-width: 0; min-height: 0; border-radius: 1.1rem; background: #0a0e0c; overflow: hidden; display: grid; place-items: center; }
.stage > img, .stage > video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.badge { position: absolute; top: 1rem; left: 1rem; padding: .35rem .75rem; border-radius: .5rem; background: rgba(10,14,12,.72); backdrop-filter: blur(6px); font-size: .82rem; font-weight: 700; letter-spacing: .06em; color: #f2c879; }
.badge.live { color: #fff; display: flex; align-items: center; gap: .45rem; }
.badge.live::before { content: ""; width: .55rem; height: .55rem; border-radius: 50%; background: var(--live); animation: pulse 1.6s ease-in-out infinite; }
.back { position: absolute; top: .8rem; right: 1rem; }
.waiting { color: var(--on-dark-muted); }
.connect-panel { display: flex; align-items: center; gap: 2.4rem; padding: 2rem; max-width: 46rem; }
.connect-panel h2 { font-size: clamp(1.4rem, 2.4vw, 2rem); }
.connect-panel ol { margin: 1rem 0 0; padding-left: 1.2rem; color: var(--on-dark-muted); font-size: 1.1rem; line-height: 1.9; }
.connect-panel b { color: var(--on-dark); }
.qr-box { flex: none; width: min(18rem, 34vw); aspect-ratio: 1; padding: 1rem; background: #fff; border-radius: 1.1rem; }
.qr-box img { width: 100%; height: 100%; display: block; }
.flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
.flash.on { animation: flash .5s ease-out; }
@keyframes flash { from { opacity: .55; } to { opacity: 0; } }
@keyframes pulse { 50% { opacity: .35; } }

.rail { display: flex; flex-direction: column; min-height: 0; background: var(--dark-2); border-radius: 1.1rem; padding: .9rem; }
.rail-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: .7rem; }
.rail-head #count { color: var(--on-dark-muted); font-weight: 500; }
.rail-empty { color: var(--on-dark-muted); font-size: .9rem; line-height: 1.5; margin: 0; }
.rail-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .7rem; padding-right: .2rem; }
.shot { position: relative; }
.shot-open { display: block; width: 100%; padding: 0; border: 2px solid transparent; border-radius: .8rem; background: #0a0e0c; overflow: hidden; cursor: pointer; text-align: left; }
.shot-open img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
.shot-open span { display: block; padding: .35rem .55rem; font-size: .8rem; color: var(--on-dark-muted); }
.shot.selected .shot-open { border-color: #8fc7a8; }
.shot.selected .shot-open span { color: var(--on-dark); }
.shot.fresh .shot-open { animation: fresh 1.6s ease-out; }
@keyframes fresh { from { border-color: #fff; box-shadow: 0 0 0 4px rgba(143,199,168,.5); } }
.shot-delete { position: absolute; top: .35rem; right: .35rem; width: 1.7rem; height: 1.7rem; border: 0; border-radius: 50%; background: rgba(10,14,12,.75); color: #fff; font-size: 1.1rem; line-height: 1; cursor: pointer; opacity: 0; transition: opacity .15s; }
.shot:hover .shot-delete, .shot-delete:focus-visible { opacity: 1; }

.modal { position: fixed; inset: 0; background: rgba(5,8,6,.7); display: grid; place-items: center; z-index: 10; }
.modal-card { position: relative; width: min(24rem, 90vw); background: var(--dark-2); border-radius: 1.3rem; padding: 2rem; text-align: center; }
.modal-card .qr-box { width: 100%; margin-bottom: 1.2rem; }
.modal-card p { color: var(--on-dark-muted); line-height: 1.5; margin: .6rem 0 0; }
.close { position: absolute; top: .6rem; right: .8rem; background: none; border: 0; font-size: 1.6rem; color: var(--on-dark-muted); cursor: pointer; }

@media (max-width: 800px) {
  .presenter { overflow: auto; }
  .layout { height: auto; grid-template-columns: 1fr; }
  .stage { aspect-ratio: 4 / 3; }
  .connect-panel { flex-direction: column; text-align: center; gap: 1.2rem; padding: 1rem; }
  .connect-panel ol { text-align: left; }
  .qr-box { width: 12rem; }
  .rail-list { flex-direction: row; overflow-x: auto; }
  .shot { width: 9rem; flex: none; }
}

/* ---------- Phone camera ---------- */
.camera { background: #000; color: var(--on-dark); overflow: hidden; height: 100dvh; }
.camera video { position: fixed; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #000; }
.camera video.mirror { transform: scaleX(-1); }
.intro { position: fixed; inset: 0; display: grid; place-items: center; padding: 1.5rem; background: var(--dark); }
.intro-card { max-width: 22rem; text-align: center; }
.intro-card h1 { font-size: 2.2rem; margin-bottom: .8rem; }
.intro-card p { color: var(--on-dark-muted); line-height: 1.5; margin: 0 0 1.6rem; }
.intro-card .primary { width: 100%; }
.intro-card .hint { margin: 1rem 0 0; color: #ff9b91; font-size: .92rem; }
.cam-top { position: fixed; top: calc(env(safe-area-inset-top) + .8rem); left: 0; right: 0; display: flex; justify-content: center; }
.cam-top .pill { background: rgba(0,0,0,.55); backdrop-filter: blur(6px); }
.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 8.5rem); transform: translate(-50%, .5rem); padding: .5rem 1rem; border-radius: 999px; background: rgba(0,0,0,.7); color: #fff; font-size: .92rem; opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.cam-controls { position: fixed; left: 0; right: 0; bottom: 0; padding: 1.2rem 2rem calc(env(safe-area-inset-bottom) + 1.4rem); display: flex; align-items: center; justify-content: space-between; background: linear-gradient(transparent, rgba(0,0,0,.6)); }
.round { width: 3.2rem; height: 3.2rem; border-radius: 50%; border: 0; background: rgba(255,255,255,.16); color: #fff; display: grid; place-items: center; cursor: pointer; }
.round svg { width: 1.4rem; height: 1.4rem; }
.shutter { width: 4.6rem; height: 4.6rem; border-radius: 50%; border: 4px solid #fff; background: transparent; padding: 4px; cursor: pointer; }
.shutter span { display: block; width: 100%; height: 100%; border-radius: 50%; background: #fff; transition: transform .1s; }
.shutter:active span { transform: scale(.88); }
