:root {
  --bg: #f6f7f5;
  --surface: #fff;
  --soft: #eef3f2;
  --ink: #17212b;
  --muted: #65717a;
  --line: #dce2df;
  --primary: #0f6f6a;
  --primary-ink: #fff;
  --danger: #c8493f;
  --gold: #d49b2a;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.dark {
  --bg: #10151a;
  --surface: #18212a;
  --soft: #202c34;
  --ink: #eef3f5;
  --muted: #a7b3bb;
  --line: #32404a;
  --primary: #54c6ba;
  --primary-ink: #102033;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--ink); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.shell { width: min(100%, 980px); margin: 0 auto; padding: 18px 16px 28px; }
.topbar, .session-row, .section-title, .form-footer, .filters, .grid-actions, .maintenance { display: flex; align-items: center; gap: 10px; }
.topbar { justify-content: space-between; }
.topbar p, .hero p, .stats span, .form-footer, .qr-card p { color: var(--muted); }
.topbar p { margin: 0 0 4px; font-size: .78rem; font-weight: 800; text-transform: uppercase; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.55rem, 7vw, 2.5rem); line-height: 1.02; }

.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.gate-card, .card-form, .poll-card, .question-card, .qr-card { border: 1px solid var(--line); border-radius: 8px; background: var(--surface); padding: 14px; }
.gate-card { width: min(100%, 380px); display: grid; gap: 12px; }

.icon { width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); }
.primary { min-height: 44px; border: 0; border-radius: 8px; background: var(--primary); color: var(--primary-ink); font-weight: 900; padding: 0 14px; }
.secondary { background: var(--soft); color: var(--ink); border: 1px solid var(--line); }
.danger { background: var(--danger); color: #fff; }

label { font-size: .85rem; font-weight: 800; }
input, select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink); outline: none; }
input, select { height: 44px; padding: 0 12px; }
textarea { min-height: 124px; resize: vertical; padding: 12px; line-height: 1.35; }

.session-row { margin: 20px 0 12px; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.tabs button, .filters button { min-height: 40px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-weight: 800; }
.tabs button.active, .filters button.active { background: var(--surface); color: var(--ink); }
.participant-mode .tabs { display: none; }
.internal-mode .tabs { grid-template-columns: repeat(2, 1fr); }

.hero { display: grid; grid-template-columns: 108px 1fr; gap: 16px; align-items: stretch; margin: 16px -16px 0; padding: 18px 16px; background: #102033; color: #fff; }
.visual { position: relative; min-height: 118px; border-radius: 8px; overflow: hidden; background: linear-gradient(145deg, #1d8b83, #142133 52%, #c8493f); }
.fallback-art::before { content: ""; position: absolute; inset: 14px auto auto 14px; width: 58px; height: 58px; border-radius: 50%; background: rgba(255,255,255,.2); }
.fallback-art::after { content: ""; position: absolute; right: 18px; bottom: 14px; width: 42px; height: 62px; border-radius: 8px 8px 3px 3px; background: #f2bc51; }
.visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: var(--surface); padding: 12px; z-index: 2; }
.hero h2 { margin-bottom: 8px; font-size: clamp(1.25rem, 5vw, 2.1rem); line-height: 1.08; }
.hero p { margin-bottom: 6px; color: rgba(255,255,255,.78); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 14px 0; }
.stats article { padding: 12px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.stats strong { display: block; font-size: 1.35rem; line-height: 1; }
.stats span { display: block; margin-top: 6px; font-size: .78rem; font-weight: 700; }

.panel { display: none; margin: 16px 0; }
.panel.active { display: grid; gap: 14px; }
.card-form { display: grid; gap: 10px; }
.grid-actions, .maintenance { display: grid; grid-template-columns: repeat(2, 1fr); }
.qr-card { display: grid; grid-template-columns: minmax(0, 1fr) 116px; gap: 12px; align-items: center; }
.qr-card p { margin-bottom: 10px; font-size: .78rem; overflow-wrap: anywhere; }
.qr-card img { width: 116px; height: 116px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; }

.questions { margin-top: 20px; }
.section-title { justify-content: space-between; margin-bottom: 12px; }
.section-title h2 { margin: 0; font-size: 1.05rem; }
.filters { overflow-x: auto; margin: -4px 0 12px; }
.filters button { flex: 0 0 auto; padding: 0 14px; border: 1px solid var(--line); background: var(--surface); }
.stack { display: grid; gap: 10px; }
.question-card, .poll-card { display: grid; gap: 12px; }
.meta { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: .8rem; font-weight: 700; }
.question-text, .poll-title { margin: 0; line-height: 1.42; overflow-wrap: anywhere; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions button, .poll-option { min-height: 38px; padding: 0 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); color: var(--ink); font-weight: 800; }
.actions .primary-small, .poll-option.voted { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.actions .danger-small { color: var(--danger); border-color: rgba(200,73,63,.32); }
.bar { display: grid; gap: 6px; }
.bar-row { display: grid; gap: 5px; }
.bar-label { display: flex; justify-content: space-between; gap: 8px; font-size: .84rem; }
.bar-fill { height: 9px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.bar-fill span { display: block; height: 100%; border-radius: 999px; background: var(--primary); }
.toast { position: fixed; left: 16px; right: 16px; bottom: 16px; display: none; max-width: 520px; margin: 0 auto; padding: 12px 14px; border-radius: 8px; background: var(--ink); color: var(--bg); font-weight: 800; }
.toast.active { display: block; }

@media (min-width: 760px) {
  main { display: grid; grid-template-columns: minmax(0, .9fr) minmax(340px, 1.1fr); gap: 18px; }
  .session-row, .tabs, .hero, .stats { grid-column: 1 / -1; }
  .hero { margin-left: 0; margin-right: 0; border-radius: 8px; grid-template-columns: 180px 1fr; }
  .visual { min-height: 150px; }
  .questions { grid-row: span 3; margin-top: 16px; }
}
