/* QIQCOP Zoo — stylesheet
   Palette continues the previous site: warm paper, deep navy, mint, coral,
   amber. Status colours: unsolved = red, solved = cyan; amber highlights a
   targeted reference. Logo letters: light grey, O light cyan, P light red.
   Taxonomy: fields are solid pills, topics outlined pills. */

:root {
  color-scheme: light;
  --ink: #112336;
  --ink-soft: #516174;
  --ink-faint: #7d8a98;
  --paper: #f4f1e9;
  --paper-deep: #e9e3d6;
  --card: #fbf9f3;
  --card-raised: #ffffff;
  --navy: #0d1b2a;
  --navy-raised: #13263a;
  --on-navy: #f7f2e8;
  --mint: #83e6d0;
  --mint-deep: #1f8f7d;
  --coral: #ff7a66;
  --amber: #eeb85b;
  --link: #1d5c8a;
  --cite: #1c3f8a;
  --line: rgba(17, 35, 54, 0.14);
  --line-strong: rgba(17, 35, 54, 0.3);
  --shadow: 0 16px 44px rgba(13, 27, 42, 0.09);
  --unsolved-bg: #ffe2dc;
  --unsolved-fg: #a8261a;
  --unsolved-line: #f0a496;
  --highlight-bg: #fdefd0;
  --highlight-line: #ecc77a;
  --solved-bg: #d9f2f5;
  --solved-fg: #0f5f6b;
  --solved-line: #8fd6e0;
  --logo-gray: #b8c1ca;
  --logo-cyan: #9de3ec;
  --logo-red: #ff9d8f;
  --accent-solid: #0d1b2a;
  --on-accent-solid: #f7f2e8;
  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --sans: "Inter", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --serif: "Source Serif 4", "Iowan Old Style", Baskerville, "Times New Roman", serif;
  --logo-font: "Jost", "Futura", "Century Gothic", "Avenir Next", "Helvetica Neue", sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  --shell: min(1200px, calc(100vw - 48px));
}

[data-theme="dark"] {
  color-scheme: dark;
  --ink: #e6ece8;
  --ink-soft: #aab8c2;
  --ink-faint: #8595a3;
  --paper: #0b1622;
  --paper-deep: #0f1f2f;
  --card: #11253a;
  --card-raised: #16304a;
  --navy: #07111b;
  --navy-raised: #102439;
  --on-navy: #f4efe6;
  --mint-deep: #78ddc7;
  --link: #8fc3ea;
  --cite: #9db8ff;
  --line: rgba(220, 235, 240, 0.14);
  --line-strong: rgba(220, 235, 240, 0.3);
  --shadow: 0 18px 56px rgba(0, 0, 0, 0.32);
  --unsolved-bg: rgba(255, 122, 102, 0.16);
  --unsolved-fg: #ffa294;
  --unsolved-line: rgba(255, 122, 102, 0.45);
  --highlight-bg: rgba(238, 184, 91, 0.16);
  --highlight-line: rgba(238, 184, 91, 0.45);
  --solved-bg: rgba(157, 227, 236, 0.16);
  --solved-fg: #a9e8f0;
  --solved-line: rgba(157, 227, 236, 0.45);
  --accent-solid: #83e6d0;
  --on-accent-solid: #07111b;
}

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

html { scroll-behavior: smooth; scroll-padding-top: 96px; overflow-x: clip; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.62;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--link); text-decoration-thickness: 1px; text-underline-offset: 2px; }
a:hover { color: var(--mint-deep); }
button, input, select, textarea { font: inherit; }
button, select { cursor: pointer; }
code { font-family: var(--mono); font-size: 0.9em; background: color-mix(in srgb, var(--ink) 7%, transparent); padding: 0.08em 0.35em; border-radius: 5px; }
kbd { font-family: var(--mono); font-size: 0.85em; padding: 0 6px; border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 5px; background: var(--card-raised); }
pre { font-family: var(--mono); font-size: 0.82rem; line-height: 1.5; margin: 0; white-space: pre-wrap; word-break: break-word; }
h1, h2, h3 { font-family: var(--serif); font-weight: 600; letter-spacing: -0.01em; line-height: 1.2; margin: 0; }
p { margin: 0 0 1em; }
.muted { color: var(--ink-soft); }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 3px solid var(--coral);
  outline-offset: 3px;
}

.skip-link {
  position: fixed; z-index: 1000; top: 12px; left: 12px; padding: 10px 14px;
  border-radius: 8px; background: var(--mint); color: var(--navy); font-weight: 700;
  transform: translateY(-160%); transition: transform 160ms ease;
}
.skip-link:focus { transform: translateY(0); }

/* ---------------------------------------------------------------------- */
/* Logo                                                                    */
/* ---------------------------------------------------------------------- */

.logo {
  --logo-size: 22px;
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  font-family: var(--logo-font);
  font-size: var(--logo-size);
  font-weight: 600;
  line-height: 0.96;
  letter-spacing: 0.09em;
  color: var(--logo-gray);
  white-space: nowrap;
  user-select: none;
  flex-shrink: 0;
}
.logo-line { display: flex; align-items: baseline; }
.logo-bar { display: inline-block; width: 0.075em; height: 0.7em; margin: 0 0.06em 0 0.01em; background: var(--logo-gray); }
.logo-ket { display: inline-block; width: 0.3em; height: 0.7em; margin-left: -0.06em; fill: none; stroke: var(--logo-gray); stroke-width: 2.6; stroke-linecap: butt; stroke-linejoin: miter; }
.logo-ghost { visibility: hidden; }
.logo-oo { position: relative; }
.logo-z { position: absolute; right: 100%; top: 0; }
.logo-o { color: var(--logo-cyan); }
.logo-p { color: var(--logo-red); }
.logo-small { --logo-size: 15px; }

/* ---------------------------------------------------------------------- */
/* Header                                                                  */
/* ---------------------------------------------------------------------- */

.site-header {
  position: sticky; z-index: 100; top: 0;
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  grid-template-areas: "brand nav tools";
  gap: 8px 20px; align-items: center;
  min-height: 64px;
  padding: 8px max(24px, calc((100vw - 1200px) / 2));
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: color-mix(in srgb, var(--navy) 94%, transparent);
  color: var(--on-navy);
  backdrop-filter: blur(14px);
}
.brand { grid-area: brand; display: inline-flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-copy { color: rgba(247, 242, 232, 0.7); font-size: 10.5px; line-height: 1.3; letter-spacing: 0.06em; text-transform: uppercase; }
.site-nav { grid-area: nav; justify-self: start; display: flex; flex-wrap: wrap; gap: 16px; align-items: center; margin-left: 6px; }
.site-nav a { color: rgba(247, 242, 232, 0.8); font-size: 13.5px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.site-nav a:hover, .site-nav a[aria-current="page"] { color: var(--mint); }
.header-tools { grid-area: tools; justify-self: end; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }

.random-control {
  display: inline-flex; align-items: center; gap: 4px; height: 36px; padding: 0 4px 0 12px;
  border-radius: 999px; border: 1px solid rgba(247, 242, 232, 0.22); white-space: nowrap;
}
.random-label { margin-right: 4px; color: rgba(247, 242, 232, 0.6); font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.08em; text-transform: uppercase; }
.random-pill {
  display: inline-flex; align-items: center; height: 26px; padding: 0 11px; border-radius: 999px;
  font-size: 12.5px; font-weight: 700; line-height: 1; text-decoration: none;
}
.random-unsolved { background: #ffb3a7; color: #5a1a12; }
.random-solved { background: #a6e2ea; color: #0b3f46; }
.random-pill:hover { filter: brightness(1.06); color: inherit; }

.theme-button {
  display: grid; place-items: center; width: 36px; height: 36px;
  border: 1px solid rgba(247, 242, 232, 0.24); border-radius: 50%;
  background: transparent; color: var(--on-navy);
}
.theme-button:hover { border-color: var(--mint); color: var(--mint); }
.theme-button svg { width: 18px; fill: none; stroke: currentColor; stroke-linecap: round; stroke-width: 1.6; }

/* ---------------------------------------------------------------------- */
/* Shared layout                                                            */
/* ---------------------------------------------------------------------- */

.section-shell { width: var(--shell); margin: 0 auto; padding: 56px 0; }
.section-heading { display: flex; flex-wrap: wrap; gap: 16px 40px; align-items: flex-end; justify-content: space-between; margin-bottom: 28px; }
.section-heading h1 { font-size: clamp(2rem, 3.6vw, 2.8rem); }
.section-heading h2 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); }
.section-heading > p { max-width: 520px; margin: 0; color: var(--ink-soft); font-size: 15px; }
.section-index { margin: 0 0 8px; color: var(--mint-deep); font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.12em; text-transform: uppercase; }
.text-link { font-weight: 600; text-decoration: none; }
.crumbs { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 18px; color: var(--ink-faint); font-size: 13px; }
.crumbs a { color: var(--ink-soft); text-decoration: none; }
.crumbs a:hover { color: var(--mint-deep); }

.button {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 20px;
  border-radius: 999px; border: 1px solid transparent; font-weight: 700; font-size: 14.5px;
  text-decoration: none; cursor: pointer; transition: transform 120ms ease, background 120ms ease;
}
.button:hover { transform: translateY(-1px); }
.button-ghost { background: transparent; color: inherit; border-color: currentColor; }

/* Status tags */
.status-tag {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 12px;
  border-radius: 999px; border: 1px solid; font-size: 12.5px; font-weight: 700;
  letter-spacing: 0.04em; text-transform: uppercase; line-height: 1.2; white-space: nowrap;
}
.status-tag::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.status-tag.status-unsolved { background: var(--unsolved-bg); color: var(--unsolved-fg); border-color: var(--unsolved-line); }
.status-tag.status-solved { background: var(--solved-bg); color: var(--solved-fg); border-color: var(--solved-line); }
.status-tag-small { padding: 3px 9px; font-size: 11px; }

/* Fields (solid) and topics (outlined) */
.tag-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 11px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--card-raised);
  color: var(--ink-soft); font-size: 12.5px; font-weight: 600; text-decoration: none; line-height: 1.3;
}
.tag:hover { border-color: var(--mint-deep); color: var(--mint-deep); }
.tag-count { color: var(--ink-faint); font-weight: 500; font-family: var(--mono); font-size: 11px; }
.tag-field { background: var(--accent-solid); border-color: var(--accent-solid); color: var(--on-accent-solid); font-weight: 700; }
.tag-field:hover { background: var(--mint-deep); border-color: var(--mint-deep); color: #ffffff; }
.tag-field .tag-count { color: inherit; opacity: 0.72; }
.tag-more { border-style: dashed; }
.tag-muted { opacity: 0.7; }
.tag-list-compact .tag { padding: 2px 9px; font-size: 11.5px; }
.tag-list-large .tag { font-size: 14px; padding: 6px 14px; }

/* ---------------------------------------------------------------------- */
/* Home: panels                                                             */
/* ---------------------------------------------------------------------- */

.panels {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 22px;
  width: var(--shell); margin: 40px auto 0; position: relative; z-index: 2;
}
.panel {
  padding: 26px 28px 28px; border-radius: var(--radius-lg);
  border: 1px solid var(--line); background: var(--card); box-shadow: var(--shadow);
}
.panel-stats { grid-column: 1 / -1; }
.panel-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.panel-stats .panel-head { justify-content: flex-end; }
.panel-head h2 { font-size: 1.35rem; }
.panel-note { color: var(--ink-faint); font-size: 13px; font-family: var(--mono); }

/* The site search: one large box in the overview panel. Focus changes only
   colours and shadows, never the size, so nothing moves. */
.hero-search {
  display: flex; align-items: center; gap: 12px;
  margin: 4px 0 10px; padding: 8px 8px 8px 22px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card-raised);
  box-shadow: 0 8px 28px rgba(13, 27, 42, 0.07);
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.hero-search:focus-within { border-color: var(--mint-deep); box-shadow: 0 0 0 4px color-mix(in srgb, var(--mint-deep) 20%, transparent), 0 8px 28px rgba(13, 27, 42, 0.07); }
.hero-search svg { width: 24px; height: 24px; flex-shrink: 0; fill: none; stroke: var(--ink-faint); stroke-width: 2; stroke-linecap: round; }
.hero-search input { flex: 1 1 auto; min-width: 0; height: 52px; border: 0; background: transparent; color: var(--ink); font-size: 19px; }
.hero-search input:focus { outline: none; }
.hero-search input::placeholder { color: var(--ink-faint); }
.hero-search input::-webkit-search-cancel-button { cursor: pointer; }
.hero-search-button {
  flex-shrink: 0; height: 48px; padding: 0 24px; border-radius: 999px; border: 0;
  background: var(--accent-solid); color: var(--on-accent-solid); font-size: 15px; font-weight: 700;
}
.hero-search-button:hover { background: var(--mint-deep); color: #ffffff; }
.hero-search-hint { margin: 0 0 24px; padding-left: 22px; color: var(--ink-faint); font-size: 13px; }

.metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(128px, 1fr)); gap: 14px; }
.metric { padding: 14px 16px; border-radius: var(--radius-md); background: var(--paper); border: 1px solid var(--line); color: var(--ink); text-decoration: none; transition: border-color 120ms ease, background-color 120ms ease; }
.metric:hover { background: var(--card-raised); border-color: var(--mint-deep); color: var(--ink); }
.metric strong { display: block; font-family: var(--serif); font-size: 2rem; font-weight: 600; line-height: 1; }
.metric span { display: block; margin-top: 6px; color: var(--ink-soft); font-size: 12.5px; letter-spacing: 0.02em; }
.metric-unsolved strong { color: var(--unsolved-fg); }
.metric-solved strong { color: var(--solved-fg); }
.status-bar { display: flex; height: 12px; margin: 20px 0 6px; border-radius: 999px; overflow: hidden; background: var(--paper-deep); }
.status-bar span { display: block; height: 100%; }
.bar-unsolved { background: var(--unsolved-line); }
.bar-solved { background: var(--solved-line); }
.top-tags { margin-top: 20px; }
.top-tags-label { display: block; margin-bottom: 10px; color: var(--ink-faint); font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase; }

.shuffle {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card-raised);
  color: var(--ink); font-size: 13px; font-weight: 700;
}
.shuffle:hover { border-color: var(--mint-deep); color: var(--mint-deep); }
.shuffle svg { width: 16px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shuffle.is-busy svg { animation: spin 0.5s linear; }
@keyframes spin { to { transform: rotate(180deg); } }

.problem-card { display: grid; gap: 12px; padding-left: 16px; border-left: 3px solid var(--line); }
.problem-card.status-unsolved { border-left-color: var(--unsolved-line); }
.problem-card.status-solved { border-left-color: var(--solved-line); }
.card-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.card-id { color: var(--ink-faint); font-family: var(--mono); font-size: 12px; }
.card-title { font-size: 1.4rem; }
.card-title a { color: inherit; text-decoration: none; }
.card-title a:hover { color: var(--mint-deep); }
.card-statement { color: var(--ink); font-size: 15px; max-height: 30rem; overflow: hidden; overflow-wrap: anywhere; }
.panel-random .card-statement { max-height: 14rem; }
.card-statement.is-clipped { mask-image: linear-gradient(black 78%, transparent); -webkit-mask-image: linear-gradient(black 78%, transparent); }
.card-statement p:last-child { margin-bottom: 0; }
.card-link { font-weight: 700; text-decoration: none; }
.random-slot { min-height: 240px; }
.random-slot.is-fading { opacity: 0.35; transition: opacity 120ms ease; }

.recent-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 0; border-top: 1px solid var(--line); }
.recent-list li { display: grid; grid-template-columns: 200px 1fr auto; gap: 16px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--line); }
.recent-list time { color: var(--ink-faint); font-family: var(--mono); font-size: 12.5px; }
.recent-list a { color: inherit; font-weight: 600; text-decoration: none; }
.recent-list a:hover { color: var(--mint-deep); }

/* ---------------------------------------------------------------------- */
/* Directory: sidebar of filters, list of results                           */
/* ---------------------------------------------------------------------- */

.directory-layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 36px; align-items: start; }
.filter-sidebar { position: sticky; top: 84px; max-height: calc(100vh - 100px); overflow-y: auto; scrollbar-width: thin; }
.filter-panel { display: grid; gap: 20px; padding: 18px 18px 20px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--card); }
.filter-panel label, .filter-panel legend { display: block; margin-bottom: 8px; color: var(--ink-faint); font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.filter-panel fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.filter-group { min-width: 0; }
.search-box { position: relative; }
.search-box svg { position: absolute; left: 12px; top: 50%; width: 17px; height: 17px; transform: translateY(-50%); fill: none; stroke: var(--ink-faint); stroke-width: 2; stroke-linecap: round; pointer-events: none; }
.search-box input, .select-filter select { width: 100%; height: 40px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card-raised); color: var(--ink); font-size: 14px; }
.search-box input { padding-left: 36px; }
.search-box input:focus { outline: none; border-color: var(--mint-deep); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint-deep) 20%, transparent); }
.select-filter select { padding-right: 34px; appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23516174' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
.facet-list { display: grid; gap: 2px; }
.facet-list button {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; width: 100%;
  padding: 6px 10px; border: 0; border-radius: var(--radius-sm); background: transparent;
  color: var(--ink-soft); font-size: 13.5px; font-weight: 600; line-height: 1.3; text-align: left;
}
.facet-list button:hover { background: var(--paper-deep); color: var(--ink); }
.facet-list button.is-active { background: var(--accent-solid); color: var(--on-accent-solid); }
.facet-name { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.facet-count { flex-shrink: 0; font-family: var(--mono); font-size: 11px; font-weight: 500; color: var(--ink-faint); }
.facet-list button.is-active .facet-count { color: inherit; opacity: 0.75; }
.facet-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-unsolved { background: var(--unsolved-fg); }
.dot-solved { background: var(--solved-fg); }
.clear-button { height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: transparent; color: var(--ink-soft); font-size: 13px; font-weight: 600; }
.clear-button:hover { border-color: var(--mint-deep); color: var(--mint-deep); }
.directory-results { min-width: 0; }
.results-toolbar { margin: 0 0 12px; color: var(--ink-soft); font-size: 14px; }

.problem-list { margin: 0; padding: 0; list-style: none; border-top: 1px solid var(--line); }
.problem-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px 24px; padding: 18px 4px 18px 14px; border-bottom: 1px solid var(--line); border-left: 3px solid transparent; }
.problem-row.status-unsolved { border-left-color: var(--unsolved-line); }
.problem-row.status-solved { border-left-color: var(--solved-line); }
.problem-row[hidden] { display: none; }
.row-title { display: inline-block; margin-bottom: 6px; color: inherit; font-family: var(--serif); font-size: 1.2rem; font-weight: 600; text-decoration: none; }
.row-title:hover { color: var(--mint-deep); }
.row-excerpt { margin: 0 0 8px; color: var(--ink-soft); font-size: 14px; }
.row-excerpt .math { font-size: 0.95em; }
.row-side { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
.empty-state { padding: 48px 0; text-align: center; color: var(--ink-soft); }
.plain-list { columns: 2; column-gap: 40px; padding-left: 20px; }
.plain-list li { break-inside: avoid; margin-bottom: 6px; }

/* Taxonomy pages */
.taxonomy-heading { display: flex; align-items: baseline; gap: 10px; margin: 34px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line); font-size: 1.35rem; color: var(--mint-deep); }
.taxonomy-heading:first-of-type { margin-top: 0; }
.taxonomy-heading span { font-family: var(--mono); font-size: 13px; color: var(--ink-faint); }
.tag-groups { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 22px 32px; }
.tag-group h3 { margin-bottom: 10px; padding-bottom: 6px; border-bottom: 1px dashed var(--line); font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-faint); }
.unused-tags { margin-top: 36px; color: var(--ink-soft); }
.unused-tags summary { cursor: pointer; font-weight: 600; margin-bottom: 12px; }
.unused-label { margin: 14px 0 8px; color: var(--ink-faint); font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.tag-page-related { margin: -6px 0 26px; padding: 16px 20px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--card); }

/* ---------------------------------------------------------------------- */
/* Problem page                                                             */
/* ---------------------------------------------------------------------- */

.problem-layout { width: min(880px, var(--shell)); margin: 0 auto; padding: 28px 0 56px; }
.problem { font-size: 16px; line-height: 1.3; }
.problem .crumbs { margin-bottom: 14px; font-size: 12.5px; }
.problem .tag-list { gap: 6px; }
.problem .tag { font-size: 12px; }
.problem-header { padding-bottom: 6px; margin-bottom: 18px; }
.problem-title { font-size: clamp(1.5rem, 2.6vw, 1.875rem); margin-bottom: 10px; }
.status-row { display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: center; margin-bottom: 12px; }
.problem-id { color: var(--ink-soft); font-size: 13px; }
.problem-id code { font-size: 12.5px; }
.problem-updated { color: var(--ink-faint); font-size: 13px; }
.taxonomy { display: grid; gap: 8px; margin: 0; }
.taxonomy-row { display: grid; grid-template-columns: 58px minmax(0, 1fr); gap: 10px; align-items: start; }
.taxonomy-row dt { padding-top: 6px; color: var(--ink-faint); font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; }
.taxonomy-row dd { margin: 0; min-width: 0; }
.problem-actions { display: flex; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; gap: 8px; max-width: 100%; margin-inline-start: auto; }
.action {
  display: inline-flex; align-items: center; gap: 7px; padding: 8px 14px;
  border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card-raised);
  color: var(--ink); font-size: 13.5px; font-weight: 700; text-decoration: none; line-height: 1;
}
.action:hover { border-color: var(--mint-deep); color: var(--mint-deep); }
.action svg { width: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.problem-section { margin-bottom: 16px; }
.problem-section p { margin-bottom: 0.8em; }
.problem-section > :last-child { margin-bottom: 0; }
.problem-section h2 {
  display: flex; align-items: center; gap: 12px; margin-bottom: 8px;
  font-family: var(--sans); font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mint-deep);
}
.problem-section h2::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.statement { padding: 14px 18px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--card); font-size: inherit; }
.statement > :last-child { margin-bottom: 0; }
.progress-list { margin: 0; padding-left: 22px; }
.progress-list > li { margin-bottom: 8px; }
.progress-list > li > :last-child { margin-bottom: 0; }
.cite, .eqref { color: var(--cite); text-decoration: none; font-weight: 600; }
.cite:hover, .eqref:hover { text-decoration: underline; color: var(--cite); }

.equation { display: block; max-width: 100%; overflow-x: auto; overflow-y: hidden; margin: 0.35em 0 0.9em; padding: 0.2em 0; -webkit-overflow-scrolling: touch; }
mjx-container[display="true"] { margin: 0.5em 0 !important; }
/* The wrapper supplies spacing for problem-page display equations. */
.problem .equation { margin: 0.5em 0 0.75em; }
.problem .equation:last-child { margin-bottom: 0; }
.problem .equation mjx-container[display="true"] { margin: 0 !important; }
mjx-container { max-width: 100%; }
.math { white-space: nowrap; }

.references { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 8px 12px; margin: 0; font-size: 14px; }
.references .reference { display: contents; }
.references dt { font-family: var(--mono); font-size: 12.5px; font-weight: 600; padding-top: 3px; }
.references dt a { color: var(--cite); text-decoration: none; }
.references dt a:hover { text-decoration: underline; }
.references dd { margin: 0; color: var(--ink); min-width: 0; overflow-wrap: anywhere; }
.reference:target dt, .reference:target dd { background: var(--highlight-bg); }
.reference-links { display: inline-flex; gap: 6px; margin-left: 8px; vertical-align: middle; }
.ref-link { padding: 2px 9px; border-radius: 999px; border: 1px solid color-mix(in srgb, var(--link) 45%, transparent); background: color-mix(in srgb, var(--link) 7%, transparent); font-size: 11px; font-weight: 700; letter-spacing: 0.04em; text-decoration: none; color: var(--link); }
.ref-link:hover { border-color: var(--mint-deep); color: var(--mint-deep); background: color-mix(in srgb, var(--mint-deep) 10%, transparent); }

.related-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.related-list li { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--card); }
.related-list a { font-weight: 600; text-decoration: none; color: inherit; }
.related-list a:hover { color: var(--mint-deep); }
.related-tags { color: var(--ink-faint); font-size: 12.5px; }

.problem-footer { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 16px; margin-top: 34px; padding-top: 24px; border-top: 1px solid var(--line); font-size: 13.5px; }
.problem-footer h2 { margin-bottom: 10px; font-family: var(--sans); font-size: 12px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.problem-footer > div { min-width: 0; padding: 16px 18px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--card); overflow-wrap: anywhere; }
.problem-footer p { margin: 0; color: var(--ink-soft); }
.edit-log ul { margin: 0 0 10px; padding: 0; list-style: none; }
.edit-log li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border-bottom: 1px dashed var(--line); }
.edit-log li span:first-child { color: var(--ink-soft); }
.contribute-box { border-color: var(--solved-line) !important; }

/* Dialogs */
.dialog { width: min(640px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--line-strong); border-radius: var(--radius-lg); background: var(--card-raised); color: var(--ink); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgba(13, 27, 42, 0.55); backdrop-filter: blur(3px); }
.dialog-frame { padding: 24px 26px 28px; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.dialog-head h2 { font-size: 1.3rem; }
.dialog h3 { margin: 18px 0 8px; font-family: var(--sans); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--ink-soft); }
.dialog-intro { color: var(--ink-soft); font-size: 14px; }
.dialog-close { width: 34px; height: 34px; border-radius: 50%; border: 1px solid var(--line-strong); background: transparent; color: inherit; font-size: 20px; line-height: 1; }
.copy-block { position: relative; padding: 14px 92px 14px 16px; border-radius: var(--radius-sm); border: 1px solid var(--line); background: var(--paper); }
.copy-button { position: absolute; top: 10px; right: 10px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card-raised); color: var(--ink); font-size: 12px; font-weight: 700; }
.copy-button:hover { border-color: var(--mint-deep); color: var(--mint-deep); }
.share-links { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.share-links a, .share-links button { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--card-raised); color: var(--ink); font-size: 13.5px; font-weight: 700; text-decoration: none; }
.share-links a:hover, .share-links button:hover { border-color: var(--mint-deep); color: var(--mint-deep); }

/* About */
.prose { max-width: 760px; font-size: 16px; }
.prose h2 { margin: 34px 0 12px; font-size: 1.4rem; }
.prose ul, .prose ol { padding-left: 22px; }
.prose li { margin-bottom: 6px; }

/* Contribute: the proposal form. One centered column like a problem page;
   fieldsets are cards whose legends match the problem-section headings. */
.contribute-layout { width: min(880px, var(--shell)); margin: 0 auto; padding: 28px 0 56px; }
.contribute-layout .crumbs { margin-bottom: 14px; font-size: 12.5px; }
.contribute-routes { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin: 0 0 28px; }
.route-card { padding: 18px 20px; border-radius: var(--radius-md); border: 1px solid var(--line); background: var(--card); }
.route-card h2 { margin-bottom: 6px; font-size: 1.1rem; }
.route-card p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.proposal-form { display: grid; gap: 18px; }
.proposal-form fieldset { min-width: 0; margin: 0; padding: 18px 22px 22px; border: 1px solid var(--line); border-radius: var(--radius-lg); background: var(--card); }
.proposal-form legend { padding: 0 6px; font-family: var(--sans); font-size: 11.5px; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--mint-deep); }
.form-row { display: grid; align-content: start; gap: 6px; min-width: 0; }
/* Rows stack with a gap; inside a multi-column grid they sit side by side, so their labels and boxes line up. */
fieldset > .form-row + .form-row, .form-grid-2 + .form-row { margin-top: 16px; }
.form-row > label, .form-label { font-weight: 600; font-size: 14.5px; }
.form-hint { margin: 0; color: var(--ink-soft); font-size: 13px; }
.form-hint code { font-size: 0.85em; }
.form-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 18px; }
.proposal-form input[type="text"], .proposal-form input[type="email"], .proposal-form input[type="search"], .proposal-form textarea {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--card-raised); color: var(--ink); font-size: 15px; line-height: 1.5;
}
.proposal-form textarea { min-height: 110px; resize: vertical; font-family: var(--mono); font-size: 13.5px; }
.proposal-form input:focus, .proposal-form textarea:focus { outline: none; border-color: var(--mint-deep); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint-deep) 20%, transparent); }
.proposal-form input[type="checkbox"] { width: 16px; height: 16px; margin: 0; accent-color: var(--mint-deep); flex-shrink: 0; }
.choice-count { color: var(--ink-faint); font-family: var(--mono); font-size: 11.5px; font-weight: 500; }
/* Dropdown pickers for fields and topics: a select, an optional box for a name of the
   contributor's own, and the chosen names as pills (fields solid, topics outlined). */
.picker { display: grid; gap: 10px; }
.picker select {
  width: 100%; max-width: 480px; height: 44px; padding: 0 40px 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong);
  background: var(--card-raised); color: var(--ink); font-size: 15px; appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%23516174' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 16px;
}
.picker select:focus { outline: none; border-color: var(--mint-deep); box-shadow: 0 0 0 3px color-mix(in srgb, var(--mint-deep) 20%, transparent); }
.picker select:disabled { opacity: 0.55; cursor: not-allowed; }
.picker-custom { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.picker-custom[hidden] { display: none; }
.picker-custom input { flex: 1 1 240px; max-width: 480px; }
.picker-chosen:empty { display: none; }
.picker-chosen .tag { padding-right: 4px; gap: 4px; }
.tag-new { border-style: dashed; }
.tag-remove {
  display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; margin-left: 2px;
  border: 0; border-radius: 50%; background: transparent; color: inherit; font-size: 15px; line-height: 1; opacity: 0.7; cursor: pointer;
}
.tag-remove:hover { opacity: 1; background: color-mix(in srgb, currentColor 16%, transparent); }
.form-row-inline { margin-top: 10px; justify-items: start; }
.button-small { padding: 8px 14px; font-size: 13px; }
.statement-preview { justify-self: stretch; margin-top: 4px; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); background: var(--paper); white-space: pre-wrap; overflow-wrap: anywhere; font-size: 15px; }
.statement-preview[hidden] { display: none; }
.consent { display: flex; align-items: flex-start; gap: 10px; font-size: 14px; font-weight: 400 !important; line-height: 1.5; cursor: pointer; }
.consent input { margin-top: 3px !important; }
.hp { position: absolute; left: -10000px; top: auto; width: 1px; height: 1px; overflow: hidden; }
.captcha-slot { display: grid; gap: 8px; min-height: 24px; }
.form-notice { padding: 12px 16px; border-radius: var(--radius-sm); border: 1px solid var(--highlight-line); background: var(--highlight-bg); font-size: 14px; }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.button-primary { background: var(--accent-solid); color: var(--on-accent-solid); border-color: var(--accent-solid); }
.button-primary:hover { background: var(--mint-deep); border-color: var(--mint-deep); color: #ffffff; }
.button:disabled { opacity: 0.55; cursor: not-allowed; transform: none; }
.form-status { min-height: 1.5em; margin: 0; font-size: 14px; color: var(--ink-soft); }
.form-status[data-kind="error"] { color: var(--unsolved-fg); font-weight: 600; }
.proposal-done { padding: 24px 26px; border-radius: var(--radius-lg); border: 1px solid var(--solved-line); background: var(--solved-bg); color: var(--ink); }
.proposal-done:focus { outline: none; }
.proposal-done h2 { margin-bottom: 10px; font-size: 1.4rem; }
.proposal-done p:last-child { margin-bottom: 0; }
.proposal-form[hidden], .proposal-done[hidden] { display: none; }

/* Footer */
.site-footer { margin-top: 40px; padding: 40px max(24px, calc((100vw - 1200px) / 2)) 48px; background: var(--navy); color: var(--on-navy); }
.footer-brand { display: flex; gap: 14px; align-items: center; margin-bottom: 20px; }
.footer-links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-bottom: 18px; }
.footer-links a { color: rgba(247, 242, 232, 0.85); font-size: 13.5px; font-weight: 600; text-decoration: none; }
.footer-links a:hover { color: var(--mint); }
.footer-note { margin: 0; color: rgba(247, 242, 232, 0.55); font-size: 13px; }
.footer-credit { margin-bottom: 8px; }
.footer-note a { color: rgba(247, 242, 232, 0.8); }

.toast { position: fixed; z-index: 1200; left: 50%; bottom: 24px; padding: 10px 18px; border-radius: 999px; background: var(--navy); color: var(--on-navy); font-size: 14px; font-weight: 600; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------------- */
/* Responsive                                                               */
/* ---------------------------------------------------------------------- */

@media (max-width: 1199px) {
  .site-header { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "brand tools" "nav nav"; row-gap: 4px; }
  .site-nav { margin-left: 2px; padding-bottom: 2px; }
}

@media (max-width: 960px) {
  .directory-layout { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .filter-sidebar { position: static; max-height: none; overflow: visible; }
  .filter-panel { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px 20px; align-items: start; }
  .search-field { grid-column: 1 / -1; }
  .facet-list { display: flex; flex-wrap: wrap; gap: 6px; }
  .facet-list button { width: auto; padding: 5px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--card-raised); font-size: 12.5px; }
  .facet-list button.is-active { border-color: var(--accent-solid); }
  .clear-button { justify-self: start; }
  .panels { grid-template-columns: minmax(0, 1fr); }
  .recent-list li { grid-template-columns: 1fr auto; }
  .recent-list time { grid-column: 1 / -1; }
}

@media (max-width: 900px) {
  .site-header { grid-template-columns: minmax(0, 1fr); grid-template-areas: "brand" "nav" "tools"; }
  .header-tools { justify-self: stretch; justify-content: flex-start; }
}

@media (max-width: 640px) {
  :root { --shell: calc(100vw - 32px); }
  body { font-size: 15.5px; }
  .site-header { padding-left: 16px; padding-right: 16px; }
  .brand-copy { display: none; }
  .site-nav { gap: 14px; }
  .random-control { padding-left: 4px; }
  .random-label { display: none; }
  .panel { padding: 20px 18px; }
  .hero-search { padding: 6px 6px 6px 14px; gap: 8px; }
  .hero-search svg { width: 20px; height: 20px; }
  .hero-search input { height: 44px; font-size: 16px; }
  .hero-search-button { height: 40px; padding: 0 16px; font-size: 14px; }
  .hero-search-hint { padding-left: 14px; }
  .taxonomy-row { grid-template-columns: minmax(0, 1fr); gap: 4px; }
  .taxonomy-row dt { padding-top: 0; }
  .problem-row { grid-template-columns: minmax(0, 1fr); }
  .row-side { flex-direction: row; align-items: center; justify-content: space-between; }
  .statement { padding: 14px; }
  .references { grid-template-columns: 1fr; gap: 4px; }
  .references dd { margin-bottom: 12px; }
  .plain-list { columns: 1; }
  .copy-block { padding-right: 16px; }
  .copy-button { position: static; margin-top: 10px; }
  .proposal-form fieldset { padding: 16px 14px 18px; }
  .picker select, .picker-custom input { max-width: none; }
}

@media print {
  .site-header, .site-footer, .problem-actions, .toast, .shuffle, .skip-link { display: none !important; }
  body { background: white; color: black; }
  .problem-layout { display: block; width: auto; padding: 0; }
  .statement, .panel { box-shadow: none; }
}
