:root {
  color-scheme: dark;
  --background: #0e0816;
  --surface: #171020;
  --surface-raised: #21152f;
  --surface-soft: #29193b;
  --line: rgba(204, 178, 255, .2);
  --line-strong: rgba(189, 154, 255, .42);
  --text: #f7f2ff;
  --muted: #c8bad8;
  --faint: #9b8daa;
  --purple: #9d6cff;
  --purple-bright: #cdb4ff;
  --mint: #67e3ae;
  --gold: #f2c96b;
  --red: #ff8f9d;
  --shadow: 0 24px 70px rgba(0, 0, 0, .34);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--background);
  color: var(--text);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-width: 300px; scroll-behavior: smooth; }
body {
  min-width: 300px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 12% -10%, rgba(157, 108, 255, .24), transparent 36rem),
    radial-gradient(circle at 95% 18%, rgba(103, 227, 174, .08), transparent 30rem),
    var(--background);
}

button, input, select { font: inherit; }
button, select, input[type="time"], input[type="number"], input[type="text"], input[type="password"] { min-height: 46px; }
button, a, input, select { -webkit-tap-highlight-color: transparent; }
a { color: var(--purple-bright); }

.skip-link {
  position: fixed;
  z-index: 100;
  left: 12px;
  top: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  color: #130a20;
  background: var(--mint);
  font-weight: 850;
  transform: translateY(-160%);
}
.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 66px;
  padding: calc(9px + env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 9px max(14px, env(safe-area-inset-left));
  border-bottom: 1px solid var(--line);
  background: rgba(14, 8, 22, .9);
  -webkit-backdrop-filter: blur(16px);
  backdrop-filter: blur(16px);
}

.brand { display: flex; min-width: 0; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-mark { display: grid; width: 38px; height: 38px; flex: 0 0 38px; place-items: center; border: 1px solid var(--line-strong); border-radius: 11px; color: var(--mint); background: linear-gradient(145deg, #351f52, #1b1029); box-shadow: 0 0 28px rgba(157, 108, 255, .2); }
.brand > span:last-child { display: grid; min-width: 0; }
.brand strong { font-size: .92rem; letter-spacing: .08em; }
.brand small { overflow: hidden; color: var(--faint); font-size: .66rem; text-overflow: ellipsis; white-space: nowrap; }
.events-link { flex: 0 0 auto; min-height: 44px; display: inline-flex; align-items: center; padding: 0 12px; border: 1px solid var(--line); border-radius: 11px; color: var(--muted); font-size: .78rem; font-weight: 800; text-decoration: none; }

main { width: min(100% - 24px, 1040px); margin: 0 auto; padding: 24px 0 76px; }
.hero { max-width: 840px; padding: 10px 2px 24px; }
.eyebrow, .step-label { margin: 0 0 7px; color: var(--mint); font-size: .7rem; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { max-width: 780px; margin: 0; font-size: clamp(2.15rem, 6vw, 3.9rem); line-height: 1; letter-spacing: -.05em; }
.hero-copy { max-width: 690px; margin: 14px 0 0; color: var(--muted); font-size: clamp(.96rem, 2.5vw, 1.12rem); line-height: 1.55; }
.hero-points { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.hero-points span { padding: 7px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--purple-bright); background: rgba(157, 108, 255, .07); font-size: .72rem; font-weight: 820; }

.page-status, .action-status, .inline-notice { padding: 13px 15px; border: 1px solid var(--line); border-radius: 12px; color: var(--muted); background: rgba(255, 255, 255, .025); line-height: 1.45; }
.page-status { margin: 0; text-align: center; }
.page-status::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 9px; border: 2px solid rgba(205, 180, 255, .25); border-top-color: var(--purple-bright); border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
.action-status[data-tone="success"] { border-color: rgba(103, 227, 174, .34); color: #bdffe1; background: rgba(28, 116, 82, .18); }
.action-status[data-tone="error"], .inline-notice.warning { border-color: rgba(255, 143, 157, .35); color: #ffd3d9; background: rgba(130, 35, 52, .15); }

.state-card, .settings-card, .consent-card, .account-bar, .server-alert-card {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(145deg, rgba(33, 21, 47, .96), rgba(19, 12, 28, .96));
  box-shadow: var(--shadow);
}
.state-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 16px; padding: 22px; }
.state-card h2 { margin: 4px 0 8px; font-size: clamp(1.35rem, 5vw, 2rem); }
.state-card p:not(.eyebrow) { margin: 0 0 18px; color: var(--muted); line-height: 1.58; }
.state-icon { display: grid; width: 46px; height: 46px; place-items: center; border: 1px solid var(--line-strong); border-radius: 14px; color: var(--purple-bright); background: rgba(157, 108, 255, .12); font-size: 1.2rem; font-weight: 900; }
.error-card { border-color: rgba(255, 143, 157, .3); }

.primary-button, .secondary-button, .danger-button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 17px;
  border-radius: 12px;
  font-weight: 850;
  cursor: pointer;
  text-decoration: none;
  transition: border-color .16s ease, background .16s ease, transform .16s ease;
}
.primary-button { border: 1px solid #b998ff; color: #160b25; background: linear-gradient(135deg, #cdb4ff, #9d6cff); box-shadow: 0 10px 30px rgba(101, 56, 185, .3); }
.secondary-button { border: 1px solid var(--line-strong); color: var(--purple-bright); background: rgba(157, 108, 255, .08); }
.danger-button { border: 1px solid rgba(255, 143, 157, .32); color: #ffc3cb; background: rgba(157, 47, 67, .1); }
.primary-button:hover, .secondary-button:hover, .danger-button:hover, .events-link:hover { transform: translateY(-1px); border-color: var(--purple-bright); }
button:disabled, .primary-button[aria-disabled="true"] { opacity: .48; cursor: not-allowed; transform: none; }
.discord-button { width: 100%; margin-top: 3px; }
.state-card .discord-community-link { margin: 12px 0 0; font-size: .74rem; }

.account-bar { display: grid; gap: 18px; margin-bottom: 16px; padding: 17px; }
.account-summary { display: flex; min-width: 0; align-items: center; gap: 12px; }
.account-initial { display: grid; width: 42px; height: 42px; flex: 0 0 42px; place-items: center; border-radius: 50%; color: #160b25; background: var(--purple-bright); font-weight: 950; }
.account-summary div { display: grid; min-width: 0; gap: 2px; }
.account-summary span:not(.account-initial) { color: var(--faint); font-size: .7rem; }
.account-summary strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.delivery-summary { display: flex; flex-wrap: wrap; align-items: center; gap: 7px 12px; color: var(--faint); font-size: .72rem; }
.health-badge { padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-weight: 850; }
.health-badge[data-tone="success"] { border-color: rgba(103, 227, 174, .35); color: #adffd8; background: rgba(28, 116, 82, .16); }
.health-badge[data-tone="warning"] { border-color: rgba(242, 201, 107, .38); color: #ffe5a5; background: rgba(130, 92, 20, .14); }
.health-badge[data-tone="error"] { border-color: rgba(255, 143, 157, .35); color: #ffc9d0; background: rgba(130, 35, 52, .14); }
.delivery-error { flex-basis: 100%; color: #ffc9d0; overflow-wrap: anywhere; }

.discord-delivery-requirement {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  margin-bottom: 16px;
  padding: 16px;
  border: 1px solid rgba(242, 201, 107, .34);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(113, 78, 16, .2), rgba(33, 21, 47, .88));
}
.discord-delivery-requirement-mark { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(242, 201, 107, .4); border-radius: 11px; color: #ffe5a5; background: rgba(130, 92, 20, .18); font-weight: 950; }
.discord-delivery-requirement .eyebrow { margin-bottom: 4px; color: var(--gold); }
.discord-delivery-requirement h2 { margin: 0; font-size: clamp(1rem, 3vw, 1.25rem); }
.discord-delivery-requirement p:not(.eyebrow) { margin: 6px 0 0; color: var(--muted); font-size: .75rem; line-height: 1.5; }
.discord-delivery-requirement .secondary-button { width: 100%; grid-column: 1 / -1; }

.server-alert-card {
  display: block;
  margin-top: 18px;
  margin-bottom: 16px;
  padding: 0;
  overflow: hidden;
  border-color: rgba(103, 227, 174, .27);
  background: linear-gradient(145deg, rgba(20, 58, 50, .5), rgba(19, 12, 28, .96));
}
.server-alert-summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  list-style: none;
  cursor: pointer;
}
.server-alert-summary::-webkit-details-marker { display: none; }
.server-alert-summary::after { content: "Open"; color: var(--purple-bright); font-size: .72rem; font-weight: 850; }
.server-alert-card[open] .server-alert-summary::after { content: "Close"; }
.server-alert-summary > span:first-child { display: grid; min-width: 0; gap: 4px; }
.server-alert-summary strong { font-size: clamp(1.05rem, 3vw, 1.4rem); }
.server-alert-summary small { color: var(--faint); font-size: .72rem; font-weight: 600; line-height: 1.45; }
.server-alert-summary .health-badge { width: fit-content; max-width: 100%; overflow-wrap: anywhere; }
.server-alert-content { display: grid; gap: 18px; padding: 0 20px 20px; border-top: 1px solid var(--line); }
.server-alert-intro { margin: 16px 0 0; color: var(--muted); font-size: .78rem; line-height: 1.5; }
.server-health-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.server-health-grid > div {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255, 255, 255, .025);
}
.server-health-grid span { color: var(--faint); font-size: .66rem; font-weight: 750; }
.server-health-grid strong, .server-health-grid time { color: var(--muted); font-size: .75rem; overflow-wrap: anywhere; }
.server-health-grid .server-delivery-error { border-color: rgba(255, 143, 157, .3); color: #ffc9d0; background: rgba(130, 35, 52, .12); font-size: .72rem; line-height: 1.45; overflow-wrap: anywhere; }
.server-alert-form { display: grid; gap: 14px; }
.server-alert-fields { display: grid; min-width: 0; gap: 12px; }
.server-alert-fields input[type="text"], .server-alert-fields input[type="password"] {
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: #120b1b;
}
.server-permission-check { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 11px; color: #e7dff0; font-size: .76rem; line-height: 1.55; cursor: pointer; }
.server-permission-check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--purple); }
.server-privacy-hint { margin: 0; color: var(--faint); font-size: .7rem; line-height: 1.5; }
.server-action-bar { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.server-action-bar button { width: 100%; }

#alertsForm { display: grid; gap: 16px; }
.settings-card { padding: 20px; box-shadow: 0 16px 44px rgba(0, 0, 0, .2); }
.section-heading { display: grid; gap: 6px; margin-bottom: 18px; }
.section-heading h2, .consent-card h2 { margin: 0; font-size: clamp(1.25rem, 4vw, 1.75rem); }
.section-heading > p { margin: 0; color: var(--faint); font-size: .8rem; line-height: 1.45; }
.step-label { margin-bottom: 4px; }

fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
.field, .compact-field { display: grid; gap: 6px; color: var(--muted); font-size: .78rem; font-weight: 800; }
.field > span, .compact-field > span { display: flex; justify-content: space-between; gap: 8px; }
.field em { color: var(--faint); font-size: .66rem; font-style: normal; font-weight: 700; }
.field small { color: var(--faint); font-weight: 500; line-height: 1.45; }
select, input[type="time"], input[type="number"] {
  width: 100%;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  color: var(--text);
  background: #120b1b;
}
.timezone-field { max-width: 480px; margin-bottom: 17px; }

.schedule-grid, .choice-grid, .scope-grid { display: grid; gap: 10px; }
.schedule-card, .choice-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, .025);
}
.schedule-card { display: grid; gap: 12px; padding: 14px; }
.toggle-row, .choice-card { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: start; gap: 11px; cursor: pointer; }
.choice-card { padding: 13px; }
.toggle-row input, .choice-card input, .consent-check input { width: 20px; height: 20px; margin: 1px 0 0; accent-color: var(--purple); }
.toggle-row span, .choice-card span { display: grid; gap: 4px; }
.toggle-row strong, .choice-card strong { color: var(--text); font-size: .86rem; }
.toggle-row small, .choice-card small { color: var(--faint); font-size: .7rem; font-weight: 600; line-height: 1.4; }
.schedule-fields { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 9px; }
.schedule-card:has(.toggle-row input:checked), .choice-card:has(input:checked) { border-color: rgba(157, 108, 255, .62); background: rgba(157, 108, 255, .09); box-shadow: inset 0 0 0 1px rgba(157, 108, 255, .08); }
.schedule-card:has(.toggle-row input:not(:checked)) .compact-field { opacity: .48; }
.choice-card:has(input:disabled) { opacity: .42; cursor: not-allowed; }

.location-fields { display: grid; gap: 12px; margin-top: 14px; padding: 15px; border: 1px dashed var(--line); border-radius: 14px; background: rgba(0, 0, 0, .1); }
.location-fields[data-disabled="true"] { opacity: .48; }
.privacy-hint { margin: 10px 2px 0; color: var(--faint); font-size: .7rem; line-height: 1.45; }

.consent-card { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 14px; padding: 19px; border-color: rgba(103, 227, 174, .27); background: linear-gradient(145deg, rgba(23, 54, 47, .54), rgba(19, 12, 28, .96)); }
.consent-mark { display: grid; width: 38px; height: 38px; place-items: center; border: 1px solid rgba(103, 227, 174, .38); border-radius: 12px; color: var(--mint); background: rgba(103, 227, 174, .09); font-weight: 950; }
.consent-check { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 11px; margin-top: 12px; color: #e7dff0; font-size: .76rem; line-height: 1.55; cursor: pointer; }
.consent-card p { margin: 10px 0 0; color: var(--faint); font-size: .68rem; line-height: 1.45; }

.action-bar { position: sticky; z-index: 10; bottom: 0; display: grid; gap: 8px; padding: 12px 0 calc(12px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, rgba(14, 8, 22, .95) 18%); }
.action-bar button { width: 100%; }

footer { width: min(100% - 24px, 1040px); min-height: 100px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin: 0 auto; padding: 24px 0 calc(24px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); color: var(--faint); font-size: .72rem; }
footer nav { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 10px; }
footer a { color: var(--muted); font-weight: 750; text-decoration: none; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 3px solid var(--mint); outline-offset: 3px; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (min-width: 660px) {
  main { padding-top: 52px; }
  .state-card { padding: 30px; }
  .discord-button { width: auto; }
  .account-bar { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr); align-items: center; }
  .discord-delivery-requirement { grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; }
  .discord-delivery-requirement .secondary-button { width: auto; grid-column: auto; white-space: nowrap; }
  .server-alert-fields { grid-template-columns: minmax(180px, .65fr) minmax(0, 1.35fr); }
  .server-health-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .server-health-grid .server-delivery-error { grid-column: 1 / -1; }
  .server-action-bar { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .delivery-summary { justify-content: flex-end; }
  .schedule-grid, .choice-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .scope-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .location-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .action-bar { grid-template-columns: minmax(180px, 1.5fr) repeat(3, minmax(130px, 1fr)); }
}

@media (min-width: 900px) {
  .site-header { padding-inline: max(28px, calc((100vw - 1120px) / 2)); }
  .hero { padding-block: 24px 32px; }
  .server-action-bar { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .settings-card { padding: 27px; }
  .section-heading { grid-template-columns: minmax(0, 1fr) minmax(220px, .55fr); align-items: end; }
  .section-heading > p { text-align: right; }
}

@media (max-width: 659px) {
  .action-bar { position: static; padding-block: 0; background: none; }
}

@media (max-width: 430px) {
  .brand small { display: none; }
  .events-link { padding-inline: 9px; font-size: .72rem; }
  .hero { padding-top: 4px; }
  .hero h1 { font-size: clamp(2.05rem, 11vw, 2.75rem); }
  .hero-points { gap: 6px; }
  .hero-points span { padding: 6px 8px; }
  .server-alert-summary { grid-template-columns: minmax(0, 1fr) auto; padding: 16px; }
  .server-alert-summary .health-badge { grid-column: 1; grid-row: 2; justify-self: start; }
  .server-alert-summary::after { grid-column: 2; grid-row: 1 / span 2; }
  .server-alert-content { padding: 0 16px 16px; }
  .state-card, .consent-card { grid-template-columns: 1fr; }
  .state-icon, .consent-mark { width: 40px; height: 40px; }
  .schedule-fields { grid-template-columns: 1fr; }
  footer { align-items: flex-start; flex-direction: column; }
  footer nav { justify-content: flex-start; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .001ms !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; }
}
