:root {
  color-scheme: light;
  --ground: #fbfaf6;
  --surface: #fbfaf6;
  --surface-raised: #f2efe7;
  --ink: #1b1b1a;
  --muted: #5c5550;
  --faint: #d8d2c2;
  --accent: #a6300e;
  --secondary: #3e4a5c;
  --button-ink: #fbfaf6;
  --radius: 0px;
  --radius-large: 0px;
  --shadow: none;
  --font-display: "Source Han Serif SC", "Noto Serif CJK SC", "Songti SC", serif;
  --font-body: "Source Han Sans SC", "Noto Sans CJK SC", "PingFang SC", sans-serif;
  --font-mono: "IBM Plex Mono", "SFMono-Regular", Consolas, monospace;
  --page-width: 1500px;
  --card-gap: 0px;
  --card-padding: 20px 0;
  --summary-display: block;
  --motion-fast: 130ms;
  --motion-layout: 320ms;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ground);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.55;
  transition: background-color var(--motion-layout) ease, color var(--motion-layout) ease;
}

button,
input,
select {
  font: inherit;
}

button,
a,
select,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

a {
  color: inherit;
}

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

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

[hidden] {
  display: none !important;
}

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

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  transform: translateY(-180%);
  background: var(--ink);
  color: var(--ground);
  padding: 10px 14px;
  text-decoration: none;
}

.skip-link:focus {
  transform: translateY(0);
}

.site-header {
  width: min(calc(100% - 48px), var(--page-width));
  margin: 0 auto;
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--faint);
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.wordmark-mark {
  width: 9px;
  height: 9px;
  background: var(--accent);
  border-radius: 50%;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.header-rule {
  width: 26px;
  height: 1px;
  background: var(--faint);
}

.page-shell {
  width: min(calc(100% - 48px), var(--page-width));
  margin: 0 auto;
  padding: 68px 0 120px;
}

.search-intro {
  display: grid;
  grid-template-columns: 190px minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 34px;
  align-items: end;
  padding-bottom: 56px;
  border-bottom: 1px solid var(--ink);
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.intro-copy h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(42px, 4.6vw, 76px);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 0.99;
  text-wrap: balance;
}

.intro-copy p {
  max-width: 620px;
  margin: 22px 0 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.75;
  text-wrap: pretty;
}

.search-form {
  min-height: 64px;
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  border-bottom: 2px solid var(--ink);
}

.search-form input {
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: clamp(17px, 1.5vw, 21px);
  padding: 18px 0;
  outline: 0;
}

.search-form input::placeholder {
  color: color-mix(in srgb, var(--muted) 68%, transparent);
}

.search-form kbd {
  min-width: 27px;
  height: 27px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--faint);
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.search-form button {
  height: 42px;
  margin-left: 14px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--ink);
  color: var(--button-ink);
  cursor: pointer;
  font-size: 13px;
  font-weight: 650;
  transition: opacity var(--motion-fast) ease, transform var(--motion-fast) ease;
}

.search-form button:hover {
  opacity: 0.82;
}

.search-form button:active {
  transform: translateY(1px);
}

.catalog-layout {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr);
  gap: 34px;
  padding-top: 34px;
}

.filters-panel {
  align-self: start;
  position: sticky;
  top: 24px;
}

.filter-heading {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 17px;
  border-bottom: 1px solid var(--faint);
  font-size: 12px;
  font-weight: 650;
}

.text-button {
  padding: 4px 0;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.text-button:hover {
  color: var(--accent);
}

.filter-field {
  display: block;
  margin-bottom: 24px;
}

.filter-field > span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
}

.filter-field select {
  width: 100%;
  height: 40px;
  padding: 0 28px 0 0;
  border: 0;
  border-bottom: 1px solid var(--faint);
  border-radius: var(--radius);
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
}

.tag-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag-option {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 29px;
  padding: 4px 8px;
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  color: var(--muted);
  font-size: 10px;
  transition: border-color var(--motion-fast) ease, color var(--motion-fast) ease, background var(--motion-fast) ease;
}

.tag-option span {
  color: color-mix(in srgb, var(--muted) 62%, transparent);
  font-family: var(--font-mono);
  font-size: 9px;
}

.tag-option:hover,
.tag-option[aria-pressed="true"] {
  border-color: var(--accent);
  color: var(--accent);
}

.data-note {
  margin: 32px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--faint);
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 11px;
  line-height: 1.7;
  text-wrap: pretty;
}

.results-region {
  min-width: 0;
}

.results-toolbar {
  min-height: 64px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  padding: 0 0 18px;
}

.results-toolbar h2 {
  margin: 6px 0 0;
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: 500;
}

.active-filter-summary {
  max-width: 50%;
  margin: 20px 0 0;
  color: var(--muted);
  font-size: 11px;
  text-align: right;
  text-wrap: pretty;
}

.results-list {
  display: grid;
  gap: var(--card-gap);
  border-top: 1px solid var(--ink);
}

.problem-card {
  display: grid;
  grid-template-columns: 154px minmax(0, 1fr);
  gap: 28px;
  padding: var(--card-padding);
  border-bottom: 1px solid var(--faint);
  background: var(--surface);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
  transition:
    color var(--motion-layout) ease,
    background-color var(--motion-layout) ease,
    border-color var(--motion-layout) ease,
    transform var(--motion-fast) ease;
  animation: row-in 280ms both;
  animation-delay: calc(var(--item-index) * 20ms);
}

@keyframes row-in {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.problem-identity {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.source-label {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.problem-id {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 11px;
}

.problem-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(17px, 1.45vw, 22px);
  font-weight: 550;
  line-height: 1.3;
  text-wrap: pretty;
}

.problem-metadata {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 0;
}

.problem-info-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  margin-top: 9px;
}

.difficulty-label,
.tag-chip {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 7px;
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  background: transparent;
  color: var(--muted);
  font-family: var(--font-body);
  font-size: 10px;
}

.difficulty-label {
  border-color: color-mix(in srgb, var(--secondary) 55%, var(--faint));
  color: var(--secondary);
}

.tag-chip {
  cursor: pointer;
}

.tag-chip:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.problem-summary {
  display: var(--summary-display);
  max-width: 800px;
  margin: 13px 0 0;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 13px;
  line-height: 1.72;
  text-wrap: pretty;
}

.problem-summary.is-missing {
  opacity: 0.64;
  font-style: italic;
}

.problem-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.problem-link {
  min-width: 82px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 10px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  color: var(--ink);
  font-size: 11px;
  font-weight: 650;
  text-decoration: none;
  transition: background var(--motion-fast) ease, color var(--motion-fast) ease, border-color var(--motion-fast) ease;
}

.problem-link:hover {
  background: var(--ink);
  color: var(--ground);
}

.problem-link.hydro-link {
  border-color: var(--accent);
  color: var(--accent);
}

.problem-link.hydro-link:hover {
  background: var(--accent);
  color: var(--button-ink);
}

.problem-link.is-disabled {
  border-style: dashed;
  border-color: var(--faint);
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.6;
}

.loading-row {
  display: grid;
  grid-template-columns: 154px minmax(0, 1fr);
  gap: 28px;
  padding: 28px 0;
  border-bottom: 1px solid var(--faint);
}

.loading-row span {
  height: 13px;
  background: linear-gradient(90deg, var(--surface-raised), var(--faint), var(--surface-raised));
  background-size: 220% 100%;
  animation: loading 1.25s linear infinite;
}

.loading-row span:nth-child(2) {
  height: 44px;
}

@keyframes loading {
  from { background-position: 100% 0; }
  to { background-position: -100% 0; }
}

.state-card {
  min-height: 280px;
  display: grid;
  place-items: center;
  align-content: center;
  padding: 48px 24px;
  border-bottom: 1px solid var(--faint);
  text-align: center;
}

.state-card h3 {
  margin: 8px 0 6px;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
}

.state-card p {
  margin: 0;
  color: var(--muted);
}

.state-card .state-code {
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
}

.state-action {
  margin-top: 22px;
  min-height: 40px;
  padding: 7px 15px;
  border: 1px solid var(--ink);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
}

.state-action:hover {
  background: var(--ink);
  color: var(--ground);
}

.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 14px;
  padding-top: 28px;
}

.pagination button {
  min-height: 40px;
  padding: 7px 14px;
  border: 1px solid var(--faint);
  border-radius: var(--radius);
  background: transparent;
  cursor: pointer;
  font-size: 12px;
}

.pagination button:not(:disabled):hover {
  border-color: var(--ink);
}

.pagination span {
  min-width: 90px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  text-align: center;
}
