:root {
  --bg: #ffffff;
  --surface: #f7f7f7;
  --surface-warm: #eeeeee;
  --fg: #111111;
  --fg-2: #3a3a3a;
  --muted: #707070;
  --meta: #111111;
  --border: #d9d9d9;
  --border-soft: #eeeeee;
  --accent: #111111;
  --accent-on: #ffffff;
  --accent-hover: color-mix(in oklab, var(--accent), black 8%);
  --accent-active: color-mix(in oklab, var(--accent), black 14%);
  --success: #168a46;
  --warn: #b7791f;
  --danger: #c53030;
  --font-display: Inter, system-ui, sans-serif;
  --font-body: Inter, system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, monospace;
  --text-xs: 12px;
  --text-sm: 14px;
  --text-base: 16px;
  --text-lg: 18px;
  --text-xl: 24px;
  --text-2xl: 36px;
  --text-3xl: 54px;
  --text-4xl: 76px;
  --leading-body: 1.52;
  --leading-tight: 1.06;
  --tracking-display: -0.025em;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;
  --section-y-desktop: 96px;
  --section-y-tablet: 68px;
  --section-y-phone: 48px;
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-pill: 9999px;
  --elev-flat: none;
  --elev-ring: 0 0 0 1px var(--border);
  --elev-raised: 0 16px 40px rgba(0, 0, 0, 0.1);
  --focus-ring: 0 0 0 3px rgba(17, 17, 17, 0.18);
  --motion-fast: 150ms;
  --motion-base: 240ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --container-max: 1180px;
  --container-gutter-desktop: 36px;
  --container-gutter-tablet: 24px;
  --container-gutter-phone: 16px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  display: block;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  line-height: var(--leading-body);
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  color: inherit;
  cursor: pointer;
}

svg {
  display: block;
  flex: 0 0 auto;
}

h1,
h2,
p {
  margin: 0;
}

h1,
h2 {
  font-family: var(--font-display);
  text-wrap: balance;
}

p {
  text-wrap: pretty;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 0;
  box-shadow: var(--focus-ring);
}

.stage {
  display: block;
}

.caption {
  display: none;
}

.island,
.statusbar {
  display: none !important;
}

.device {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  padding: 0;
  background: var(--bg);
}

.screen {
  position: relative;
  width: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.statusbar {
  flex: 0 0 47px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 17px 24px 0;
  font-size: 15px;
  font-weight: 650;
}

.statusbar-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.statusbar svg {
  width: 17px;
  height: 11px;
  fill: var(--fg);
}

.statusbar .battery {
  width: 25px;
}

.num {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.appbar {
  position: sticky;
  top: 0;
  z-index: 6;
  flex: 0 0 56px;
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  align-items: center;
  padding: 6px 12px;
  border-bottom: 1px solid var(--border-soft);
  background: color-mix(in oklab, var(--bg) 94%, transparent);
  backdrop-filter: blur(16px);
}

.appbar-title {
  text-align: center;
  font-size: var(--text-sm);
  font-weight: 650;
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
}

.icon-btn:hover {
  background: var(--surface);
}

.icon-btn:active {
  background: var(--surface-warm);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
}

.content {
  flex: 1 1 auto;
  width: min(100%, 560px);
  margin-inline: auto;
  overflow: visible;
  padding: var(--space-5) var(--space-4) var(--space-8);
  -webkit-overflow-scrolling: touch;
}

.content::-webkit-scrollbar {
  display: none;
}

.view {
  min-height: 100%;
}

.view[aria-hidden="false"] {
  animation: enter var(--motion-base) var(--ease-standard);
}

@keyframes enter {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.intro {
  padding: var(--space-8) 0 var(--space-6);
}

.intro h1 {
  font-size: 31px;
  line-height: 1.08;
  letter-spacing: var(--tracking-display);
}

.intro p {
  max-width: 31ch;
  margin-top: var(--space-3);
  color: var(--muted);
}

.field-label {
  display: block;
  margin-bottom: var(--space-2);
  color: var(--fg-2);
  font-size: var(--text-sm);
  font-weight: 650;
}

.search-field {
  position: relative;
  margin-bottom: var(--space-5);
}

.search-field svg {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  stroke: var(--muted);
  fill: none;
  stroke-width: 1.8;
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px 12px 44px;
  color: var(--fg);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.search-input::placeholder {
  color: var(--muted);
}

.search-input:focus {
  border-color: var(--fg);
}

.choice-list {
  display: grid;
  gap: var(--space-2);
}

.choice-card {
  position: relative;
  display: block;
}

.choice-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.choice-body {
  min-height: 58px;
  display: grid;
  grid-template-columns: 1fr 24px;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
  transition:
    background var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard);
}

.choice-card:hover .choice-body {
  border-color: var(--fg-2);
  background: var(--surface);
}

.choice-card input:checked + .choice-body {
  border-color: var(--accent);
  background: var(--surface);
}

.choice-card input:focus-visible + .choice-body {
  box-shadow: var(--focus-ring);
}

.choice-title {
  display: block;
  font-weight: 650;
  line-height: 1.3;
}

.choice-note {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.35;
}

.radio-dot {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 50%;
}

.radio-dot::after {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
}

.choice-card input:checked + .choice-body .radio-dot {
  border-color: var(--accent);
}

.choice-card input:checked + .choice-body .radio-dot::after {
  background: var(--accent);
}

.empty-state {
  padding: var(--space-8) 0;
  color: var(--muted);
  text-align: center;
}

.bottom-action {
  position: sticky;
  bottom: 0;
  z-index: 5;
  flex: 0 0 auto;
  padding: var(--space-3) max(var(--space-4), env(safe-area-inset-right))
    calc(var(--space-3) + env(safe-area-inset-bottom))
    max(var(--space-4), env(safe-area-inset-left));
  border-top: 1px solid var(--border-soft);
  background: color-mix(in oklab, var(--bg) 96%, transparent);
  backdrop-filter: blur(18px);
}

.action-inner {
  display: grid;
  width: min(100%, 528px);
  margin-inline: auto;
  gap: var(--space-2);
}

.btn-primary,
.btn-secondary,
.btn-text {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  border-radius: var(--radius-lg);
  font-weight: 650;
  text-decoration: none;
  transition:
    background var(--motion-fast) var(--ease-standard),
    transform var(--motion-fast) var(--ease-standard);
}

.btn-primary {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--accent-on);
}

.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
}

.btn-primary:active {
  border-color: var(--accent-active);
  background: var(--accent-active);
  transform: translateY(1px);
}

.btn-primary:disabled {
  cursor: not-allowed;
  border-color: var(--surface-warm);
  background: var(--surface-warm);
  color: var(--muted);
}

.btn-secondary {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
}

.btn-secondary:hover {
  border-color: var(--fg);
  background: var(--surface);
}

.btn-text {
  min-height: 44px;
  border: 0;
  background: transparent;
  color: var(--fg-2);
}

.btn-text:hover {
  background: var(--surface);
}

.home-indicator {
  display: none;
}

.results-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.results-head h1 {
  font-size: var(--text-xl);
  line-height: 1.2;
  letter-spacing: var(--tracking-display);
}

.result-count {
  padding-top: 6px;
  color: var(--muted);
  font: var(--text-xs) var(--font-mono);
  white-space: nowrap;
}

.criteria-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) 0 var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-soft);
}

.criteria-copy {
  min-width: 0;
}

.criteria-copy strong,
.criteria-copy span {
  display: block;
}

.criteria-copy strong {
  overflow: hidden;
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.criteria-copy span {
  margin-top: 2px;
  color: var(--muted);
  font-size: var(--text-xs);
}

.edit-link {
  min-height: 44px;
  padding: 0 var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  font-size: var(--text-sm);
  font-weight: 650;
}

.edit-link:hover {
  background: var(--surface);
}

.segment {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-1);
  padding: var(--space-1);
  margin-bottom: var(--space-5);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.segment button {
  min-height: 44px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--muted);
  font-size: var(--text-sm);
}

.segment button[aria-pressed="true"] {
  background: var(--bg);
  color: var(--fg);
  box-shadow: var(--elev-ring);
  font-weight: 650;
}

.cards {
  display: grid;
  gap: var(--space-3);
}

.olympiad-card {
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg);
}

.card-head {
  display: grid;
  grid-template-columns: 1fr 44px;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-3);
}

.card-kicker {
  color: var(--muted);
  font: var(--text-xs) var(--font-mono);
}

.card-head h2 {
  margin-top: var(--space-1);
  font-size: var(--text-lg);
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.favorite {
  align-self: start;
}

.favorite[aria-pressed="true"] svg {
  fill: var(--fg);
}

.card-facts {
  padding: 0 var(--space-4);
}

.fact-row {
  display: grid;
  grid-template-columns: 22px 88px 1fr;
  align-items: start;
  gap: var(--space-2);
  padding: 10px 0;
  border-top: 1px solid var(--border-soft);
  font-size: var(--text-sm);
}

.fact-row svg {
  width: 18px;
  height: 18px;
  margin-top: 1px;
  stroke: var(--fg-2);
  fill: none;
  stroke-width: 1.7;
}

.fact-label {
  color: var(--muted);
}

.fact-value {
  min-width: 0;
  font-weight: 650;
}

.difficulty {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.difficulty::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warn);
}

.difficulty.very-hard::before {
  background: var(--danger);
}

.benefit {
  display: inline-flex;
  width: fit-content;
  padding: 2px 8px;
  border: 1px solid var(--fg);
  border-radius: var(--radius-pill);
  font: var(--text-xs) var(--font-mono);
}

.card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}

.card-foot p {
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.35;
}

.places-btn {
  min-height: 44px;
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  font-size: var(--text-sm);
  font-weight: 650;
}

.places-btn:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Results screen: program summary and compact, scannable olympiad cards. */
[data-step="2"] .results-head {
  margin-bottom: 20px;
}
[data-step="2"] .results-head h1 {
  font-size: clamp(28px, 4vw, 40px);
}
[data-step="2"] .result-count {
  display: none;
}
[data-step="2"] .criteria-summary {
  min-height: 112px;
  padding: 18px 20px;
  margin-bottom: 16px;
  border: 1px solid var(--border-soft);
  border-radius: 18px;
}
[data-step="2"] .criteria-copy {
  flex: 1;
}
[data-step="2"] .criteria-copy::before {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  content: "ПРОГРАММА";
  font-size: 12px;
  letter-spacing: 0.04em;
}
[data-step="2"] .criteria-copy strong {
  font-size: 18px;
  white-space: normal;
}
[data-step="2"] .criteria-copy span {
  margin-top: 5px;
  font-size: 15px;
}
[data-step="2"] .edit-link {
  padding: 0 16px;
  background: var(--surface);
}
[data-step="2"] .segment {
  margin-bottom: 14px;
  border: 0;
  border-radius: 16px;
}
[data-step="2"] .segment button {
  min-height: 52px;
  font-size: 16px;
}
[data-step="2"] .notice,
[data-step="2"] > p:last-child {
  display: none;
}
.card-head {
  padding: 18px 20px 12px;
}
.card-kicker {
  font: inherit;
  font-size: 13px;
  text-transform: uppercase;
}
.card-head h2 {
  margin-top: 8px;
  font-size: 23px;
  line-height: 1.28;
}
.olympiad-card .favorite {
  display: none;
}
.card-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 20px 16px;
}
.fact-row {
  display: block;
  width: auto;
  padding: 10px 14px;
  border: 0;
  border-radius: 12px;
  background: var(--surface);
  font-size: 14px;
}
.fact-row:first-child {
  order: 2;
  color: var(--muted);
}
.fact-row:last-child {
  order: 1;
  background: #eef7ed;
  color: #26732d;
}
.fact-row::before {
  content: "";
}
.fact-label {
  color: inherit;
}
.fact-value {
  margin-left: 4px;
}
.card-foot {
  min-height: 62px;
  padding: 12px 20px;
  border-top: 1px solid var(--border-soft);
  background: transparent;
}
.card-foot p {
  display: none;
}
.places-btn {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  min-height: 38px;
  padding: 0;
  color: var(--fg-2);
  text-align: left;
  font-size: 15px;
  font-weight: 500;
}
.places-btn svg {
  width: 25px;
  height: 25px;
  flex: none;
  margin-right: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.places-btn::after {
  content: "›";
  margin-left: auto;
  color: var(--fg);
  font-size: 28px;
}
.results-count-label {
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 15px;
}
@media (max-width: 600px) {
  [data-step="2"] .results-head h1 {
    font-size: 28px;
  }
  [data-step="2"] .criteria-summary {
    padding: 14px;
  }
  [data-step="2"] .criteria-copy strong {
    font-size: 15px;
  }
  [data-step="2"] .edit-link {
    padding-inline: 10px;
  }
  .card-head h2 {
    font-size: 18px;
  }
  .card-facts {
    gap: 8px;
    padding-inline: 14px;
  }
  .fact-row {
    padding: 8px 10px;
    font-size: 12px;
  }
  .card-head {
    padding-inline: 14px;
  }
  .card-foot {
    padding-inline: 14px;
  }
}

.notice {
  margin-top: var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: 1.45;
}

dialog {
  width: min(calc(100% - 24px), 370px);
  max-height: 72%;
  margin: auto auto 0;
  padding: 0;
  overflow: auto;
  color: var(--fg);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  box-shadow: var(--elev-raised);
}

dialog::backdrop {
  background: color-mix(in oklab, var(--fg) 32%, transparent);
  backdrop-filter: blur(2px);
}

.sheet {
  padding: var(--space-5);
}

.sheet-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.sheet-head h2 {
  font-size: var(--text-xl);
}

.sheet-sub {
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-sm);
}

.place-list {
  padding: 0;
  margin: var(--space-5) 0 0;
  list-style: none;
}

.place-list li {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--border-soft);
  font-size: var(--text-sm);
}

.sheet-note {
  margin-top: var(--space-4);
  color: var(--muted);
  font-size: var(--text-xs);
}

.sheet-actions {
  display: grid;
  margin-top: var(--space-5);
}

@media (min-width: 700px) {
  .appbar {
    width: min(100%, 560px);
    margin-inline: auto;
  }

  .content {
    padding-top: var(--space-6);
  }

  .bottom-action {
    padding-inline: 24px;
  }
}

dialog {
  width: min(calc(100% - 24px), 520px);
  max-height: min(72dvh, 680px);
  margin: auto;
  border-radius: var(--radius-lg);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
