: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 {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
  min-width: 320px;
  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,
select {
  font: inherit;
}
button,
select {
  cursor: pointer;
}
button {
  color: inherit;
}
svg {
  display: block;
}
h1,
h2,
h3 {
  margin: 0;
  font-family: var(--font-display);
  text-wrap: balance;
}
p {
  text-wrap: pretty;
}
[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

.container {
  width: min(100%, 760px);
  margin-inline: auto;
  padding-inline: var(--container-gutter-phone);
}

.icon-btn {
  width: 44px;
  height: 44px;
  display: inline-grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: transparent;
  transition:
    background var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard),
    transform var(--motion-fast) var(--ease-standard);
}

.icon-btn:hover {
  border-color: var(--border);
  background: var(--surface);
}
.icon-btn:active {
  transform: translateY(1px);
}
.icon-btn svg {
  width: 20px;
  height: 20px;
}
.icon-btn[data-active="true"] {
  border-color: var(--border);
  background: var(--surface-warm);
  color: var(--fg);
}
.icon-btn[data-active="true"] svg {
  fill: currentColor;
}

.section {
  padding-block: var(--space-5) var(--section-y-phone);
}

.subject-switch {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.subject-label {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.subject-select {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0.02em;
  transition:
    border-color var(--motion-fast) var(--ease-standard),
    background var(--motion-fast) var(--ease-standard);
}

.subject-select:hover {
  border-color: var(--fg-2);
  background: var(--bg);
}
.subject-select:focus-visible {
  border-color: var(--fg);
  outline: 0;
  box-shadow: var(--focus-ring);
}

.search-field {
  position: relative;
  border-radius: var(--radius-md);
  box-shadow: var(--elev-ring);
  background: var(--surface);
}

.search-field > svg {
  position: absolute;
  inset-inline-start: var(--space-4);
  inset-block-start: 50%;
  width: 20px;
  height: 20px;
  transform: translateY(-50%);
  color: var(--muted);
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 54px;
  padding: 12px 50px 12px 46px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--fg);
  font-size: 16px;
}

.search-input::placeholder {
  color: var(--muted);
}
.search-input:focus {
  outline: 0;
  box-shadow: var(--focus-ring);
}
.clear-search {
  position: absolute;
  inset-inline-end: 5px;
  inset-block-start: 5px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr);
  gap: var(--space-2);
  margin-top: var(--space-2);
  border-bottom: 1px solid var(--border-soft);
}

.control-btn,
.sort-select {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.control-btn {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  gap: var(--space-2);
  padding-inline: var(--space-3);
  transition:
    background var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard);
}

.control-btn:hover {
  background: var(--surface);
}
.control-btn:active {
  background: var(--surface-warm);
}
.control-btn svg {
  width: 17px;
  height: 17px;
}

.count-badge {
  min-width: 22px;
  height: 22px;
  display: inline-grid;
  place-items: center;
  padding-inline: var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--fg);
  color: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.sort-wrap {
  position: relative;
  border-inline-start: 1px solid var(--border-soft);
}
.sort-wrap svg {
  position: absolute;
  inset-inline-start: var(--space-3);
  inset-block-start: 50%;
  width: 17px;
  height: 17px;
  transform: translateY(-50%);
  pointer-events: none;
}

.sort-select {
  appearance: none;
  padding: 0 32px 0 36px;
}

.sort-wrap::after {
  content: "";
  position: absolute;
  inset-inline-end: var(--space-3);
  inset-block-start: 50%;
  width: 7px;
  height: 7px;
  border-inline-end: 1.5px solid var(--fg);
  border-block-end: 1.5px solid var(--fg);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}

.active-filters {
  display: flex;
  gap: var(--space-2);
  overflow-x: auto;
  padding: var(--space-3) 0 2px;
  scrollbar-width: none;
}
.active-filters[hidden] {
  display: none;
}

.active-filters::-webkit-scrollbar {
  display: none;
}
.filter-chip {
  flex: 0 0 auto;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--fg-2);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

.filter-chip:hover {
  border-color: var(--fg-2);
  color: var(--fg);
}
.filter-chip:active {
  background: var(--surface-warm);
}

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: var(--space-3);
  margin: var(--space-5) 0 var(--space-2);
}

.results-count {
  color: var(--muted);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  white-space: nowrap;
}

.task-list {
  border-top: 1px solid var(--border);
  background: var(--bg);
}

.task-card {
  padding: var(--space-4) 0;
  background: var(--bg);
  transition: background var(--motion-fast) var(--ease-standard);
}

.task-card + .task-card {
  border-top: 1px solid var(--border-soft);
}
.task-card:hover {
  background: color-mix(in oklab, var(--surface) 58%, var(--bg));
}

.task-top,
.task-actions,
.task-meta,
.source-line {
  display: flex;
  align-items: center;
}

.task-top {
  justify-content: space-between;
  gap: var(--space-2);
}
.task-actions {
  flex: 0 0 auto;
  gap: 0;
}
.task-actions .icon-btn {
  color: var(--muted);
}
.task-actions .icon-btn:hover {
  color: var(--fg);
}
.task-number {
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 650;
  letter-spacing: 0;
}
.task-number:empty {
  display: none;
}
.difficulty-badge {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 1px 0 1px 10px;
  border: 0;
  border-left: 1px solid var(--border);
  border-radius: 0;
  background: transparent;
  color: var(--fg-2);
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}
.difficulty-badge.difficulty-easy { color: #27845b; }
.difficulty-badge.difficulty-medium { color: #b47712; }
.difficulty-badge.difficulty-hard { color: #c34f4f; }

.task-title {
  margin: var(--space-2) 0 var(--space-2);
  font-size: 20px;
  font-weight: 600;
  line-height: 1.25;
  letter-spacing: -0.012em;
}

.task-title a {
  color: inherit;
  text-decoration: none;
}
.task-title a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.task-title .text-btn {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}
.task-title .text-btn:hover {
  background: none;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.task-fragment {
  display: -webkit-box;
  margin: var(--space-2) 0 0;
  overflow: hidden;
  color: var(--fg-2);
  font-size: var(--text-base);
  line-height: 1.55;
  text-decoration: none;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}
.task-fragment:hover { color: var(--fg); }
.inline-math math {
  font-size: 1.05em;
  white-space: nowrap;
}

.task-description {
  margin: var(--space-2) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.task-meta {
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-2);
  color: var(--muted);
  font-size: var(--text-xs);
}

.meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 24px;
}
.meta-item svg {
  width: 17px;
  height: 17px;
}
.difficulty-dot {
  width: 9px;
  height: 9px;
  border-radius: var(--radius-pill);
}
.difficulty-easy .difficulty-dot {
  background: var(--success);
}
.difficulty-medium .difficulty-dot {
  background: var(--warn);
}
.difficulty-hard .difficulty-dot {
  background: var(--danger);
}

.source-line {
  gap: var(--space-2);
  margin-top: var(--space-3);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.source-line svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}

.demo-note {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: var(--space-4) 0 0;
  color: var(--muted);
  font-size: var(--text-sm);
}

.demo-note svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}

.empty-state {
  padding: var(--space-12) var(--space-4);
  border-top: 1px solid var(--border);
  text-align: center;
}

.empty-state h3 {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.empty-state p {
  max-width: 36ch;
  margin: var(--space-2) auto var(--space-5);
  color: var(--muted);
  font-size: var(--text-base);
}

.text-btn {
  min-height: 44px;
  padding-inline: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: transparent;
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
}

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

.task-page {
  min-height: calc(
    100dvh - var(--app-header-height) - var(--app-nav-height) -
      env(safe-area-inset-bottom)
  );
  padding-block: var(--space-5) var(--section-y-phone);
  background: var(--surface);
}
.task-page-inner {
  width: min(100%, 820px);
  margin-inline: auto;
  padding-inline: var(--container-gutter-phone);
}
.task-back {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 44px;
  margin-bottom: var(--space-4);
  padding: 0;
  border: 0;
  background: none;
  color: var(--fg-2);
  font-size: var(--text-sm);
  font-weight: 600;
}
.task-back:hover {
  color: var(--fg);
}
.task-detail-card,
.task-solution {
  padding: clamp(20px, 4vw, 40px);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  background: var(--bg);
}
.task-detail-card {
  border-top: 4px solid #d7fa6c;
}
.task-page-meta {
  margin: 0 0 var(--space-4);
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: 1.5;
}
.task-page-title {
  max-width: 27ch;
  margin: 0 0 var(--space-6);
  overflow-wrap: anywhere;
  font-size: clamp(25px, 4vw, 38px);
  line-height: 1.18;
  letter-spacing: var(--tracking-display);
}
.task-detail-label {
  margin: 0 0 var(--space-2);
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.task-statement,
.task-solution-text {
  max-width: 72ch;
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: clamp(16px, 2vw, 18px);
  line-height: 1.65;
}
.task-source {
  display: inline-flex;
  margin-top: var(--space-6);
  color: var(--fg);
  font-size: var(--text-sm);
  font-weight: 600;
  text-underline-offset: 4px;
}
.task-solution {
  margin-top: var(--space-4);
}
.task-solution h2 {
  margin-bottom: var(--space-4);
  font-size: var(--text-xl);
}
.task-answer {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow-wrap: anywhere;
}
.task-answer span {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
}
@media (max-width: 700px) {
  .task-page {
    background: var(--bg);
    padding-top: var(--space-3);
  }
  .task-detail-card,
  .task-solution {
    padding: var(--space-5) 0;
    border: 0;
    border-radius: 0;
  }
  .task-detail-card {
    border-top: 0;
  }
  .task-solution {
    border-top: 1px solid var(--border-soft);
  }
}
.task-loading {
  color: var(--muted);
}

dialog {
  width: min(100% - 20px, 520px);
  height: min(88dvh, 720px);
  max-height: calc(100dvh - 20px);
  margin: auto auto 10px;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--elev-raised);
}

dialog[open] {
  display: flex;
  flex-direction: column;
}

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

.sheet-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-soft);
}

.sheet-head h2 {
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 var(--space-4) var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.filter-group {
  padding: var(--space-4) 0;
  border-bottom: 1px solid var(--border-soft);
}
.filter-group:last-child {
  border-bottom: 0;
}
.filter-group h3 {
  margin-bottom: var(--space-3);
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: 600;
  letter-spacing: 0;
}
.choice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}
.choice {
  position: relative;
}
.choice input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.choice span {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.02em;
  transition:
    background var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard),
    color var(--motion-fast) var(--ease-standard);
}

.choice input:focus-visible + span {
  box-shadow: var(--focus-ring);
}
.choice input:checked + span {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--surface);
}
.choice:hover span {
  border-color: var(--fg-2);
}

#filter-dialog .filter-selects {
  display: grid;
  gap: var(--space-3);
}
#filter-dialog .select-field {
  display: grid;
  gap: var(--space-2);
}
#filter-dialog .select-field > span {
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 600;
}
#filter-dialog .filter-select {
  width: 100%;
  min-height: 48px;
  padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--fg);
  font: 500 var(--text-base)/1 var(--font-body);
  letter-spacing: 0;
}
#filter-dialog .filter-select:hover {
  border-color: var(--fg-2);
}
#filter-dialog .filter-select:focus-visible {
  border-color: var(--fg);
  outline: 0;
  box-shadow: var(--focus-ring);
}
#filter-dialog .filter-select:disabled {
  background: var(--surface-warm);
  color: var(--muted);
  cursor: not-allowed;
}
.olympiad-picker {
  position: relative;
  display: grid;
  gap: var(--space-2);
}
.olympiad-options {
  position: absolute;
  inset: calc(100% + 5px) 0 auto;
  z-index: 15;
  max-height: min(300px, 42vh);
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  box-shadow: var(--elev-raised);
  overscroll-behavior: contain;
}
.olympiad-option {
  width: 100%;
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 0;
  border-bottom: 1px solid var(--border-soft);
  background: transparent;
  color: var(--fg);
  text-align: left;
  font-size: var(--text-sm);
  line-height: 1.35;
}
.olympiad-option:last-child {
  border-bottom: 0;
}
.olympiad-option:hover,
.olympiad-option:focus-visible {
  background: var(--surface);
}
.olympiad-option strong {
  font-size: var(--text-sm);
  font-weight: 600;
}
.olympiad-option small {
  color: var(--muted);
  font-size: var(--text-xs);
}
.olympiad-empty {
  margin: 0;
  padding: 12px;
  color: var(--muted);
  font-size: var(--text-sm);
}
.olympiad-selection {
  width: fit-content;
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-height: 34px;
  padding: 3px 4px 3px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--fg-2);
  font-size: var(--text-sm);
  font-weight: 600;
}
.olympiad-selection-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.olympiad-selection-clear {
  width: 26px;
  height: 26px;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
}
.olympiad-selection-clear:hover {
  background: var(--surface-warm);
  color: var(--fg);
}

.classifier-options {
  display: grid;
  gap: 2px;
  max-height: 220px;
  margin-top: var(--space-2);
  overflow-y: auto;
  overscroll-behavior: contain;
}
.classifier-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 44px;
  padding: 7px var(--space-2);
  border-radius: var(--radius-sm);
  color: var(--fg);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
  cursor: pointer;
}
.classifier-option:hover {
  background: var(--surface-warm);
}
.classifier-option input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  accent-color: var(--fg);
}
.classifier-status {
  margin: 0;
  padding: var(--space-3) var(--space-2);
  color: var(--muted);
  font-size: var(--text-sm);
}

.sheet-actions {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1.35fr;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5)
    max(var(--space-3), env(safe-area-inset-bottom));
  border-top: 1px solid var(--border-soft);
  background: var(--surface);
}

.btn {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  font-weight: 600;
  letter-spacing: 0.02em;
  transition:
    background var(--motion-fast) var(--ease-standard),
    border-color var(--motion-fast) var(--ease-standard),
    transform var(--motion-fast) var(--ease-standard);
}

.btn:active {
  transform: translateY(1px);
}
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.48;
  transform: none;
}
.btn-secondary {
  border-color: var(--border);
  background: transparent;
  color: var(--fg);
}
.btn-secondary:hover {
  border-color: var(--fg-2);
  background: var(--surface-warm);
}
.btn-primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--accent-on);
}
.btn-primary:hover {
  border-color: var(--accent-hover);
  background: var(--accent-hover);
  color: var(--accent-on);
}
.btn-primary:active {
  border-color: var(--accent-active);
  background: var(--accent-active);
  color: var(--accent-on);
}

.toast {
  position: fixed;
  z-index: 50;
  inset-inline: var(--container-gutter-phone);
  inset-block-end: max(var(--space-5), env(safe-area-inset-bottom));
  width: min(calc(100% - var(--container-gutter-phone) * 2), 520px);
  margin-inline: auto;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--fg);
  color: var(--surface);
  box-shadow: var(--elev-raised);
  font-size: var(--text-sm);
  text-align: center;
}

.max-share-wrap {
    margin-top: 12px;
}

#task-share-max {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 50px;
    background: linear-gradient(135deg, #667eea 0%, #334bb7 100%);
    color: #fff;
    text-decoration: none;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
    transition:
        transform 0.2s ease,
        box-shadow 0.2s ease;
}

#task-share-max svg {
    width: 24px;
    height: 24px;
    flex: 0 0 auto;
}

#task-share-max:hover {
    background: linear-gradient(135deg, #667eea 0%, #334bb7 100%);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(102, 126, 234, 0.45);
}

#task-share-max:active {
    transform: translateY(0);
}

.detail-answer-row { display:flex; gap:10px; margin-top:10px; }
.detail-answer-row input { flex:1; min-width:0; min-height:48px; padding:10px; border:1px solid var(--border); border-radius:8px; background:var(--bg); color:var(--fg); }
.detail-answer-row input::placeholder { color:var(--muted); }
.detail-answer-row button, #detail-mark-solved { min-height:48px; padding:10px 14px; border:0; border-radius:8px; background:var(--accent); color:var(--accent-on); font-weight:650; cursor:pointer; }
#detail-mark-solved { margin-top:16px; }
.detail-answer-row button:disabled, #detail-mark-solved:disabled { opacity:.6; cursor:default; }

@media (max-width: 700px) {
  body.answer-input-focused olympiad-nav { display:none; }
  body.answer-input-focused .task-page { padding-bottom:calc(var(--keyboard-inset, 0px) + 24px); }
}

@media (min-width: 600px) {
  .container {
    padding-inline: var(--container-gutter-tablet);
  }
  .section {
    padding-block-start: var(--space-8);
  }
  .task-card {
    padding-block: var(--space-6);
  }
  dialog {
    margin: auto;
  }
  .task-page-inner {
    padding-inline: var(--container-gutter-tablet);
  }
}

@media (max-width: 390px) {
  .sort-select {
    padding-inline-end: 28px;
  }
  dialog {
    width: calc(100% - 12px);
    height: calc(100dvh - 12px);
    margin-block-end: 6px;
  }
  .sheet-head {
    padding-inline: var(--space-4);
  }
  .sheet-actions {
    padding-inline: var(--space-4);
  }
}

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