:root {
  --shell-bg: var(--bg);
  --shell-panel: var(--surface);
  --shell-panel-raised: var(--surface-raised);
  --shell-field: var(--surface-subtle);
  --shell-line: var(--line);
  --shell-line-strong: var(--line-strong);
  --shell-text: var(--text);
  --shell-muted: var(--muted);
  --shell-accent: var(--accent);
  --shell-accent-ink: var(--accent-contrast);
  --shell-warning: var(--warning);
  --shell-danger: var(--danger);
  --shell-radius: var(--radius-panel);
  --shell-shadow: var(--shadow);
  background: var(--shell-bg);
  color: var(--shell-text);
  font-family: var(--font-sans);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { min-width: 320px; }

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background: var(--shell-bg);
  color: var(--shell-text);
  line-height: 1.55;
}

button,
input,
select,
textarea { font: inherit; }

a {
  color: var(--shell-accent);
  text-underline-offset: 0.18em;
  text-decoration-thickness: 1px;
}

a:hover { color: var(--accent-hover); }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--focus) !important;
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 10px;
  left: 10px;
  padding: 9px 13px;
  border-radius: 9px;
  background: var(--shell-accent);
  color: var(--shell-accent-ink);
  font-weight: 900;
  transform: translateY(-180%);
}

.skip-link:focus { transform: translateY(0); }

.site-header {
  position: sticky;
  z-index: 30;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 68px;
  padding: 12px max(20px, calc((100vw - 1120px) / 2));
  border-bottom: 1px solid var(--shell-line);
  background: var(--surface-raised);
}

.site-brand {
  color: var(--shell-text);
  font-size: 21px;
  font-weight: 950;
  letter-spacing: -0.045em;
  text-decoration: none;
}

.site-brand span { color: var(--shell-accent); }

.site-header__context {
  color: var(--shell-muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.page-shell {
  width: min(1120px, 100%);
  margin: 0 auto;
  padding: clamp(24px, 5vw, 64px) clamp(16px, 3.5vw, 34px) 72px;
}

.page-shell > :first-child { margin-top: 0; }

h1,
h2,
h3 {
  color: var(--shell-text);
  letter-spacing: -0.025em;
  text-wrap: balance;
}

h1 {
  max-width: 880px;
  margin: 0 0 18px;
  font-size: clamp(34px, 6vw, 66px);
  line-height: 0.99;
}

h2 { margin: 0 0 12px; font-size: clamp(21px, 3vw, 30px); }
h3 { margin: 0 0 8px; font-size: 18px; }
p { color: var(--shell-muted); }
strong { color: var(--shell-text); }

.hero {
  position: relative;
  isolation: isolate;
  min-height: min(620px, 74vh);
  display: grid;
  align-content: center;
  padding: clamp(32px, 7vw, 88px) clamp(22px, 6vw, 72px);
  overflow: hidden;
  border: 1px solid var(--shell-line-strong);
  border-radius: 28px;
  background: var(--shell-panel);
  box-shadow: var(--shell-shadow);
}

.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  width: 330px;
  height: 330px;
  right: -120px;
  bottom: -150px;
  border: 54px solid var(--surface-accent);
  border-radius: 50%;
}

.hero .eyebrow {
  margin: 0 0 22px;
  color: var(--shell-accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.hero .lead {
  max-width: 760px;
  margin: 0 0 30px;
  color: var(--text-soft);
  font-size: clamp(17px, 2.2vw, 23px);
  line-height: 1.5;
}

.hero nav,
.page-actions,
.session-actions,
.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.primary-link,
button,
.button-link,
[data-event-catalog] article > p:last-child a,
[data-shared-event-catalog] article > p:last-child a {
  width: fit-content;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 9px 14px;
  border: 1px solid var(--shell-line-strong);
  border-radius: 10px;
  background: var(--shell-panel-raised);
  color: var(--shell-text);
  font-weight: 850;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.primary-link,
button[type='submit'],
[data-event-catalog] article > p:last-child a,
[data-shared-event-catalog] article > p:last-child a {
  border-color: var(--shell-accent);
  background: var(--shell-accent);
  color: var(--shell-accent-ink);
}

button:hover:not(:disabled),
.button-link:hover,
[data-event-catalog] article > p:last-child a:hover,
[data-shared-event-catalog] article > p:last-child a:hover {
  border-color: var(--accent-hover);
  color: var(--accent-hover);
}

.primary-link:hover,
button[type='submit']:hover:not(:disabled),
[data-event-catalog] article > p:last-child a:hover,
[data-shared-event-catalog] article > p:last-child a:hover {
  background: var(--accent-hover);
  color: var(--accent-contrast);
}

button:disabled { cursor: default; opacity: 0.45; }

form[action$='/archive'] button,
form[action$='/deletion-request'] button,
form[action='/sessions/revoke-all'] button,
form[action$='/mfa/disable'] button,
form[action='/profile/close-account'] button {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--danger-text);
}

.danger-zone {
  border-color: color-mix(in srgb, var(--shell-danger) 52%, transparent) !important;
  background: color-mix(in srgb, var(--danger) 9%, var(--surface)) !important;
}

.danger-zone h2 { color: var(--danger-text); }

form:not(.inline) {
  width: min(100%, 720px);
  display: grid;
  gap: 14px;
  margin: 20px 0;
  padding: clamp(18px, 3vw, 28px);
  border: 1px solid var(--shell-line);
  border-radius: var(--shell-radius);
  background: var(--shell-panel);
  box-shadow: var(--shadow-soft);
}

form.inline {
  display: inline-grid;
  margin: 0;
}

label {
  min-width: 0;
  display: grid;
  gap: 6px;
  color: var(--shell-muted);
  font-size: 13px;
  font-weight: 800;
}

label:has(> input[type='checkbox']) {
  grid-template-columns: auto minmax(0, 1fr);
  align-items: start;
  font-weight: 650;
}

input,
select,
textarea {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 9px 11px;
  border: 1px solid var(--shell-line-strong);
  border-radius: 10px;
  background: var(--shell-field);
  color: var(--shell-text);
}

input[type='checkbox'],
input[type='radio'] {
  width: 20px;
  min-height: 20px;
  margin: 2px 0 0;
  padding: 0;
  accent-color: var(--shell-accent);
}

input::placeholder,
textarea::placeholder { color: var(--muted); }

textarea { resize: vertical; }

input:focus,
select:focus,
textarea:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 40%, transparent);
}

aside,
[role='status']:not(.site-header__context),
[role='alert'] {
  max-width: 820px;
  margin: 18px 0;
  padding: 13px 15px;
  border: 1px solid var(--warning);
  border-radius: 12px;
  background: var(--surface-warning);
  color: var(--warning-text);
}

[role='alert'] {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--danger-text);
}

.feature-grid,
.role-example {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin: 30px 0;
}

.feature-grid article,
.role-example article,
[data-event-catalog] article,
[data-shared-event-catalog] article {
  position: relative;
  min-width: 0;
  padding: 22px;
  overflow: hidden;
  border: 1px solid var(--shell-line);
  border-radius: var(--shell-radius);
  background: var(--shell-panel-raised);
}

.feature-grid article::before {
  content: "";
  display: block;
  width: 34px;
  height: 4px;
  margin-bottom: 20px;
  border-radius: 999px;
  background: var(--shell-accent);
}

.feature-grid h2 { font-size: 22px; }
.feature-grid p,
.role-example p { margin-bottom: 0; }

.page-shell > section:not(.feature-grid),
.page-shell > dl {
  margin: 28px 0;
  padding: clamp(20px, 4vw, 34px);
  border: 1px solid var(--shell-line);
  border-radius: var(--shell-radius);
  background: var(--shell-panel);
}

.page-shell > section > form:not(.inline) { background: var(--shell-field); }

[data-event-catalog],
[data-shared-event-catalog] {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin: 22px 0 34px;
  padding: 0;
  list-style: none;
}

[data-event-catalog] article,
[data-shared-event-catalog] article {
  height: 100%;
  display: grid;
  align-content: start;
}

[data-event-catalog] article > p:last-child,
[data-shared-event-catalog] article > p:last-child { margin-top: auto; padding-top: 12px; }

.catalog-hero,
.event-shell-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  overflow: hidden;
  background: var(--surface-accent) !important;
}

.catalog-hero h1,
.event-shell-hero h1 { margin-bottom: 8px; }
.catalog-hero p,
.event-shell-hero > p { max-width: 650px; margin: 0; }
.catalog-eyebrow {
  color: var(--shell-accent) !important;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.catalog-hero .primary-link,
.event-primary-actions .primary-link,
.event-primary-actions .button-link {
  min-height: 52px;
  padding-inline: 18px;
}
.catalog-account { margin: -10px 2px 18px; font-size: 13px; }

.catalog-empty {
  min-height: 280px;
  display: grid;
  align-content: center;
  justify-items: start;
  gap: 9px;
  background: var(--surface-subtle) !important;
}

.catalog-empty__mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 13px;
  background: var(--surface-accent);
  color: var(--shell-accent);
  font-size: 12px;
  font-weight: 950;
}
.catalog-empty h2,
.catalog-empty p { margin: 0; }
.catalog-empty p { max-width: 620px; }
.catalog-empty .primary-link { min-height: 50px; margin-top: 10px; padding-inline: 18px; }

.session-management {
  max-width: 820px;
  margin: 58px 0 0 !important;
  padding: 18px 0 0 !important;
  border: 0 !important;
  border-top: 1px solid var(--shell-line) !important;
  border-radius: 0 !important;
  background: transparent !important;
}
.session-management h2 { margin: 0; color: var(--shell-muted); font-size: 15px; }
.session-management p { max-width: 680px; margin: 4px 0 12px; font-size: 12px; }
.session-management button,
.session-management form[action='/sessions/revoke-all'] button {
  border-color: var(--shell-line-strong);
  background: transparent;
  color: var(--shell-muted);
  font-size: 13px;
}
.session-management button:hover:not(:disabled) {
  border-color: var(--shell-muted);
  color: var(--shell-text);
}

.event-shell-hero { grid-template-columns: minmax(0, 1fr); align-items: start; }
.event-shell-meta { max-width: 720px; margin: 14px 0 6px; }
.event-primary-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.event-primary-actions .event-live-action {
  border-color: var(--accent);
  background: var(--surface-accent);
  color: var(--shell-accent);
}
.event-structure {
  display: grid;
  grid-template-columns: minmax(180px, .65fr) minmax(0, 1.35fr);
  gap: 24px;
}
.event-structure section { min-width: 0; }
.event-structure h2 { font-size: 19px; }
.event-structure ul { margin-bottom: 0; }
.event-lifecycle-secondary { margin-top: 64px; }
.event-lifecycle-secondary > section {
  max-width: 820px;
  margin: 0;
  padding: 24px;
  border: 1px solid var(--shell-line);
  border-radius: var(--shell-radius);
  background: var(--shell-panel);
}
.event-lifecycle-secondary > .danger-zone {
  border-color: color-mix(in srgb, var(--danger) 52%, var(--line)) !important;
  background: color-mix(in srgb, var(--danger) 9%, var(--surface)) !important;
  box-shadow: none;
}
.event-lifecycle-secondary > .danger-zone::before {
  display: block;
  margin-bottom: 8px;
  color: var(--danger-text);
  content: "Опасная зона";
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.event-lifecycle-secondary > .danger-zone h2 { font-size: 20px; }
.event-lifecycle-secondary form:not(.inline) {
  margin-bottom: 0;
  border-color: color-mix(in srgb, var(--danger) 38%, var(--line));
  background: var(--surface);
  box-shadow: none;
}
.event-secondary-nav { display: flex; flex-wrap: wrap; gap: 10px 18px; margin-top: 30px; }

dl {
  display: grid;
  grid-template-columns: minmax(120px, 0.4fr) minmax(0, 1fr);
  gap: 8px 18px;
}

dt { color: var(--shell-muted); font-size: 13px; font-weight: 750; }
dd { min-width: 0; margin: 0; overflow-wrap: anywhere; }

code,
pre {
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  background: var(--bg-deep);
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

code { padding: 0.14em 0.38em; }

pre {
  max-width: 100%;
  overflow: auto;
  padding: 18px;
  white-space: pre;
}

[data-recovery-codes] {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  max-width: 720px;
  padding-left: 28px;
}

.recovery-panel {
  position: relative;
  max-width: 820px;
  margin: 24px 0;
  padding: clamp(20px, 4vw, 32px);
  overflow: hidden;
  border: 1px solid var(--accent);
  border-radius: 20px;
  background: var(--surface-accent);
  box-shadow: var(--shell-shadow);
}

.recovery-panel::after {
  position: absolute;
  width: 150px;
  height: 150px;
  right: -75px;
  top: -75px;
  border: 28px solid var(--surface-raised);
  border-radius: 50%;
  content: "";
  pointer-events: none;
}

.recovery-panel [data-recovery-codes] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin: 18px 0;
  padding: 0;
  counter-reset: recovery-code;
  list-style: none;
}

.recovery-panel [data-recovery-codes] li {
  display: flex;
  min-width: 0;
  gap: 9px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--shell-line);
  border-radius: 10px;
  background: var(--surface-subtle);
  counter-increment: recovery-code;
}

.recovery-panel [data-recovery-codes] li::before {
  min-width: 1.4em;
  color: var(--shell-muted);
  content: counter(recovery-code) ".";
  font-size: 12px;
  font-weight: 800;
}

.recovery-panel [data-recovery-codes] code {
  min-width: 0;
  padding: 0;
  overflow-wrap: anywhere;
  border: 0;
  background: transparent;
  font-size: clamp(13px, 2vw, 16px);
  letter-spacing: .025em;
}

.recovery-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.recovery-actions button {
  min-height: 46px;
}

.recovery-status {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--shell-muted);
}

.recovery-status[data-state='ok'] { color: var(--success-text); }
.recovery-status[data-state='error'] { color: var(--danger-text); }

.recovery-confirm {
  max-width: 720px;
  padding: 13px 14px;
  border: 1px solid var(--shell-line-strong);
  border-radius: 12px;
  background: var(--surface-accent);
  color: var(--shell-text);
}

.recovery-copy-fallback {
  position: fixed;
  left: -10000px;
  top: 0;
}

.lifecycle-confirmation {
  width: min(560px, calc(100vw - 32px));
  max-width: 100%;
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: auto;
  border: 1px solid var(--danger);
  border-radius: 20px;
  background: var(--shell-panel);
  color: var(--shell-text);
  box-shadow: var(--shadow);
}

.lifecycle-confirmation::backdrop {
  background: color-mix(in srgb, var(--brand-navy) 82%, transparent);
}

.lifecycle-confirmation__panel { padding: clamp(22px, 5vw, 34px); }
.lifecycle-confirmation__panel h2 { margin-bottom: 14px; }
.lifecycle-confirmation__panel p { overflow-wrap: anywhere; }

.lifecycle-confirmation__eyebrow {
  margin: 0 0 9px;
  color: var(--danger-text) !important;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.lifecycle-confirmation__actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.lifecycle-confirmation__actions button { min-height: 44px; }
.lifecycle-confirmation__actions [data-archive-confirm] {
  border-color: var(--danger);
  background: var(--shell-danger);
  color: var(--accent-contrast);
}

.event-builder-form {
  width: min(100%, 980px) !important;
  gap: 18px !important;
  background: transparent !important;
  box-shadow: none !important;
  padding: 0 !important;
  border: 0 !important;
}

.event-builder-step,
.event-builder,
.event-builder-advanced {
  padding: clamp(18px, 4vw, 30px);
  border: 1px solid var(--shell-line);
  border-radius: var(--shell-radius);
  background: var(--shell-panel);
  box-shadow: var(--shadow-soft);
}

.event-builder-step,
.event-builder-heading {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 0 14px;
}

.event-builder-step > label,
.event-builder-step > .event-time-zone-field {
  grid-column: 1 / -1;
}

.event-step-number {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid var(--accent);
  border-radius: 12px;
  background: var(--surface-accent);
  color: var(--shell-accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .08em;
}

.event-builder-step h2,
.event-builder-heading h2 { margin-bottom: 2px; }
.event-builder-step h2 + p,
.event-builder-heading h2 + p { margin: 0 0 18px; }

.event-time-zone-field {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.event-time-zone-field button { min-height: 44px; }

.event-builder[hidden] { display: none; }

.event-builder-grid {
  display: grid;
  grid-template-columns: minmax(240px, .75fr) minmax(340px, 1.25fr);
  gap: 14px;
}

.event-builder fieldset {
  min-width: 0;
  margin: 0;
  padding: 16px;
  border: 1px solid var(--shell-line);
  border-radius: 14px;
  background: var(--surface-subtle);
}

.event-builder legend {
  padding: 0 7px;
  color: var(--shell-text);
  font-size: 16px;
  font-weight: 850;
}

.event-builder-list,
.event-lane-list {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.event-day-row,
.event-lane-row,
.event-hall-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
}

.event-hall-card {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--shell-line);
  border-radius: 12px;
  background: var(--shell-panel);
}

.event-lane-list {
  margin: 0 0 0 20px;
  padding-left: 12px;
  border-left: 2px solid var(--accent);
}

.event-builder-remove {
  min-width: 44px;
  min-height: 44px;
  padding-inline: 11px;
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  color: var(--danger-text);
}

.event-builder-summary {
  min-height: 24px;
  margin: 14px 0 0;
  color: var(--shell-accent);
  font-weight: 800;
}

.event-builder-advanced {
  padding-block: 16px;
}

.event-builder-advanced summary {
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--shell-text);
  cursor: pointer;
  font-weight: 850;
}

.event-builder-advanced[open] summary { margin-bottom: 12px; }
.event-builder-advanced label + label { margin-top: 12px; }

.event-builder-submit {
  display: flex;
  padding: 10px;
  justify-content: flex-end;
  border: 1px solid var(--shell-line);
  border-radius: 14px;
  background: var(--surface-raised);
  box-shadow: var(--shadow);
}

.event-builder-submit button {
  min-height: 50px;
  padding-inline: 22px;
}

hr {
  margin: 36px 0 20px;
  border: 0;
  border-top: 1px solid var(--shell-line);
}

footer {
  margin-top: 42px;
  padding-top: 22px;
  border-top: 1px solid var(--shell-line);
  color: var(--shell-muted);
  font-size: 13px;
}

@media (max-width: 760px) {
  .site-header { min-height: 60px; padding: 10px 16px; }
  .site-header__context { display: none; }
  .page-shell { padding-top: 20px; }
  .hero { min-height: auto; padding: 34px 22px; border-radius: 20px; }
  .hero::after { width: 220px; height: 220px; }
  .feature-grid,
  .role-example,
  [data-event-catalog],
  [data-shared-event-catalog] { grid-template-columns: 1fr; }
  .catalog-hero { grid-template-columns: 1fr; align-items: start; }
  .catalog-hero .primary-link { width: 100%; }
  .catalog-empty { min-height: 240px; }
  .event-primary-actions { align-items: stretch; flex-direction: column; }
  .event-primary-actions :is(.primary-link, .button-link) { width: 100%; }
  .event-structure { grid-template-columns: 1fr; }
  .event-lifecycle-secondary { margin-top: 48px; }
  .event-lifecycle-secondary > section { padding: 18px; }
  .event-lifecycle-secondary form:not(.inline) { padding: 14px; }
  dl { grid-template-columns: 1fr; gap: 3px; }
  dd { margin-bottom: 10px; }
  form:not(.inline) { padding: 18px; }
  .recovery-panel [data-recovery-codes] { grid-template-columns: 1fr; }
  .recovery-actions { align-items: stretch; flex-direction: column; }
  .recovery-actions button { width: 100%; }
  .event-time-zone-field,
  .event-builder-grid,
  .event-day-row,
  .event-lane-row,
  .event-hall-heading { grid-template-columns: 1fr; }
  .event-time-zone-field button,
  .event-builder fieldset > button,
  .event-hall-card > button,
  .event-builder-remove { width: 100%; }
  .event-lane-list { margin-left: 0; }
  .event-builder-submit button { width: 100%; }
  .session-actions { align-items: stretch; flex-direction: column; }
  .session-actions form,
  .session-actions button { width: 100%; }
  .lifecycle-confirmation__actions { align-items: stretch; flex-direction: column; }
  .lifecycle-confirmation__actions button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; }
}

@media print {
  :root { background: var(--bg); color: var(--text); }
  body { background: var(--bg); color: var(--text); }
  .site-header, .skip-link, .session-actions { display: none; }
  .page-shell { width: 100%; padding: 0; }
  .hero, section, article, form { box-shadow: none !important; break-inside: avoid; }
}
