:root {
  color-scheme: dark;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page: #071420;
  --surface: #101e2b;
  --raised: #152636;
  --bar: #1b2121;
  --line: #2d3f4e;
  --ink: #f8fafc;
  --muted: #b9c4d1;
  --accent: #ffbc0b;
  --accent-hover: #ffd451;
  --accent-ink: #151406;
  --focus: #ffcf43;
  --title: #fff;
  --canvas-title: #fff;
  --good: #12362d;
  --good-ink: #a5eed1;
  --bad: #421f2b;
  --bad-ink: #ffc5ce;
  background: var(--page);
  color: var(--ink);
}

:root[data-theme="sun"] {
  --page: #ffbc0b;
  --bar: #25261e;
  --canvas-title: #141a25;
  --focus: #ffdb75;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
.topbar, main { width: min(1160px, calc(100% - 56px)); margin-inline: auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  min-height: 74px; margin-top: 22px; padding: 12px 20px;
  background: var(--bar); border: 1px solid #ffffff1c; border-radius: 20px;
  box-shadow: 0 8px 24px #0002;
}
.brand, .topbar-actions { display: flex; align-items: center; gap: .8rem; }
.brand img { width: 72px; height: auto; display: block; }
.brand span { color: #dfe3e8; font-size: .9rem; border-left: 1px solid #ffffff32; padding-left: .8rem; }
.topbar-actions { gap: .5rem; }
#theme-toggle { min-width: 43px; padding: 0; font-size: 1.2rem; color: var(--accent); }
main { padding: clamp(26px, 5vw, 62px) 0 62px; }
h1, h2, p { overflow-wrap: anywhere; }
h1 {
  margin: 0 0 clamp(18px, 3vw, 32px); color: var(--canvas-title);
  font-size: clamp(2.2rem, 5.8vw, 4.2rem); line-height: .99;
  font-weight: 900; letter-spacing: -.065em;
}
h2 { margin: 0 0 1rem; color: var(--title); font-size: 1.38rem; letter-spacing: -.035em; }
p { margin: .3rem 0 .85rem; line-height: 1.55; color: var(--muted); }
section {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: clamp(16px, 3vw, 28px); margin-bottom: 16px;
}
#login { max-width: 470px; }
#login-status:empty, #import-details:empty, #delivery-next:empty { display: none; }
#login-form { gap: 1rem; }
#login-form button { margin-top: .25rem; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
form { display: grid; gap: .75rem; align-items: end; }
.row { grid-template-columns: minmax(0, 1fr) auto; }
label { display: block; font-size: .9rem; font-weight: 675; }
input, button, .file { font: inherit; min-height: 46px; border-radius: 11px; }
input { display: block; width: 100%; margin-top: 6px; padding: 10px 12px; font-size: 16px; background: #081723; border: 1px solid #4a6073; color: var(--ink); }
button, .file { cursor: pointer; border: 1px solid transparent; background: var(--accent); color: var(--accent-ink); font-weight: 750; padding: .62rem .95rem; }
button:hover:not(:disabled), .file:hover { background: var(--accent-hover); }
button:disabled { opacity: .5; cursor: not-allowed; }
.secondary, .file.secondary { color: var(--ink); background: var(--raised); border-color: #405666; }
.secondary:hover:not(:disabled), .file.secondary:hover { background: #263a4b; }
.quiet { min-height: 42px; color: var(--ink); background: transparent; border-color: #ffffff3b; font-size: .87rem; }
.quiet:hover:not(:disabled) { background: #ffffff16; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.panel-nav, .buttons { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.panel-nav { width: fit-content; max-width: 100%; padding: .27rem; border-radius: 14px; background: #0b1723; border: 1px solid var(--line); }
.panel-nav button { min-height: 38px; padding: .4rem .8rem; background: transparent; color: var(--muted); border: 0; }
.panel-nav button:hover:not(:disabled) { background: var(--raised); }
.panel-nav button[aria-pressed="true"], .panel-nav button[aria-pressed="true"]:hover { background: var(--accent); color: var(--accent-ink); }
#door-navigation { margin-left: 0; }
.section-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .75rem; margin-bottom: 1rem; }
.section-header h2 { margin: 0; }
#event-workspace { padding: 0; border: 0; background: transparent; }
#event-workspace .section-header h2 { color: var(--canvas-title); }
:root[data-theme="sun"] #new-event-toggle { background: var(--bar); color: var(--ink); }
:root[data-theme="sun"] #new-event-toggle:hover { background: #111a25; }
#new-event-details { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 1.2rem; margin-top: 1rem; }
#new-event-details summary { font-weight: 740; cursor: pointer; color: var(--accent); }
#new-event, #delivery-controls { margin-top: 1rem; }
#empty-events { padding: 1.15rem; border-radius: 14px; background: var(--surface); }

.event-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.event-card {
  position: relative; isolation: isolate; display: grid; justify-items: start; align-content: end; gap: .6rem;
  min-height: clamp(240px, 25vw, 315px); width: 100%; padding: clamp(18px, 3vw, 34px);
  background: linear-gradient(18deg, #09121e 7%, #13223d 64%, #293663);
  border: 1px solid #ffffff2e; border-radius: 23px; overflow: hidden;
  color: #fff; text-align: left; box-shadow: 0 14px 30px #0003;
}
.event-card:hover:not(:disabled) { background: linear-gradient(18deg, #09121e 7%, #1b2c50 64%, #364680); border-color: var(--accent); }
.event-card-demo, .event-card-demo:hover:not(:disabled) { background: linear-gradient(18deg, #0b1422 8%, #181d35 63%, #382c60); }
.event-card strong { max-width: 100%; font-size: clamp(1.55rem, 3.5vw, 2.65rem); font-weight: 900; letter-spacing: -.055em; line-height: 1.05; overflow-wrap: anywhere; }
.event-date { font-size: .9rem; color: #ffd75a; }
.event-location { color: #d7e1ef; font-weight: 475; }
.event-card small { color: #d3d9e5; }
.event-action { margin-top: .5rem; color: #151406; background: var(--accent); padding: .56rem .8rem; border-radius: 10px; font-size: .88rem; }
.selected-event-bar { background: linear-gradient(110deg, #101d32, #242e52); }
.selected-event-bar h2 { font-size: clamp(1.65rem, 4vw, 2.85rem); margin: 1rem 0 .4rem; }
.selected-event-bar .panel-nav { margin: .8rem 0 0; }
.file { position: relative; display: inline-flex; align-items: center; }
.file input { position: absolute; inset: 0; height: 100%; margin: 0; opacity: 0; cursor: pointer; }
.file:focus-within { outline: 2px solid var(--focus); outline-offset: 3px; }
video { width: 100%; max-height: 310px; object-fit: contain; background: #05111e; border-radius: 11px; margin-bottom: .65rem; }
#camera { min-height: 57px; }
.status { background: var(--raised); color: var(--ink); border: 1px solid var(--line); border-radius: 12px; padding: .85rem; margin-bottom: 16px; font-weight: 740; overflow-wrap: anywhere; }
.status.good { background: var(--good); color: var(--good-ink); }
.status.bad { background: var(--bad); color: var(--bad-ink); }
ul { padding: 0; list-style: none; margin: 12px 0 0; }
li { padding: 12px 0; border-top: 1px solid var(--line); display: flex; justify-content: space-between; gap: .65rem; align-items: center; flex-wrap: wrap; overflow-wrap: anywhere; }
small { display: block; color: var(--muted); }
a { color: #ffce43; }
#delivery-stats { font-weight: 750; }
#webhook-setup { padding: .8rem; border-radius: .65rem; background: #081723; }
#webhook-setup code { display: block; overflow-wrap: anywhere; margin-bottom: .55rem; }
#mail-preview { width: 100%; min-height: 440px; border: 0; border-radius: 12px; background: #fff; }
.participant-delivery { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: .55rem; }
.participant-delivery span { color: var(--muted); }
#participants + .buttons { margin: .75rem 0 0; }
#sent-mail-dialog { width: min(520px, calc(100% - 28px)); background: var(--surface); color: var(--ink); border: 1px solid var(--line); border-radius: 16px; padding: 1.25rem; }
#sent-mail-dialog::backdrop { background: #061323ae; }
#sent-mail-subject { font-weight: 750; }
#sent-mail-body { white-space: pre-wrap; overflow-wrap: anywhere; margin: .75rem 0 1.2rem; }
.mail-account { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 180px), 1fr)); gap: .6rem; }
.mail-account div { background: #081723; border: 1px solid var(--line); border-radius: 10px; padding: .75rem; min-width: 0; }
.mail-account dt { color: var(--muted); font-size: .85rem; }
.mail-account dd { margin: .25rem 0 0; font-weight: 700; overflow-wrap: anywhere; }
@media (max-width: 660px) {
  .topbar, main { width: calc(100% - 30px); }
  .topbar { min-height: 64px; margin-top: 12px; padding: 10px 12px; border-radius: 16px; }
  .brand { gap: .55rem; }
  .brand img { width: 56px; }
  .brand span { padding-left: .55rem; font-size: .76rem; }
  .grid, .event-cards { grid-template-columns: 1fr; }
  .grid { gap: 0; }
  .event-card { min-height: 205px; border-radius: 17px; }
}
@media (max-width: 360px) {
  .row { grid-template-columns: 1fr; }
  .brand span { display: none; }
}

.topbar-link { display: inline-flex; align-items: center; padding: .5rem .7rem; border: 1px solid #ffffff3b; border-radius: 11px; text-decoration: none; }
.setup-steps, .delivery-checklist { padding: 0; list-style: none; }
.setup-steps { counter-reset: setup; margin-top: 1.25rem; }
.setup-steps li { counter-increment: setup; display: block; position: relative; padding: 1.2rem 0 1.2rem 3rem; }
.setup-steps li::before { content: counter(setup); position: absolute; left: 0; top: 1.15rem; display: grid; place-items: center; width: 2rem; height: 2rem; border-radius: .6rem; background: var(--accent); color: var(--accent-ink); font-weight: 850; }
.setup-steps h2 { margin-bottom: .5rem; }
.delivery-checklist { display: grid; gap: .45rem; margin: 0; }
.delivery-checklist li { border: 1px solid var(--line); background: #081723; border-radius: 9px; padding: .65rem; }
.mail-preview-panel { margin-top: 1.25rem; }
#sent-mail-html { width: 100%; height: min(440px, 48vh); border: 0; border-radius: 10px; background: #fff; }
#sent-mail-dialog { max-height: 90vh; }
#resend-mail { margin: .8rem 0; }
@media (max-width: 470px) {
  .topbar-link { max-width: 7rem; text-align: center; line-height: 1.15; }
  .brand span { display: none; }
}
