:root {
  --ink: #17231f;
  --muted: #63736d;
  --line: #dce5df;
  --paper: #fbfcf9;
  --wash: #f0f5ef;
  --accent: #106a53;
  --accent-deep: #07503e;
  --accent-pale: #d9eee3;
  --orange: #a94f12;
  --orange-pale: #fff0df;
  --shadow: 0 12px 35px rgba(32, 56, 47, 0.08);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Meiryo", sans-serif;
  color: var(--ink);
  background: var(--paper);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 87% 8%, rgba(159, 211, 183, 0.25), transparent 23rem),
    var(--paper);
  line-height: 1.65;
}

button,
select,
input {
  font: inherit;
}

button,
select,
input[type="radio"] {
  accent-color: var(--accent);
}

button {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(29, 129, 96, 0.35);
  outline-offset: 2px;
}

.site-header {
  background: linear-gradient(120deg, #103d32, #0b5e4a 65%, #0d7259);
  color: #fff;
}

.header-inner,
.page-shell,
.site-footer {
  width: min(1240px, calc(100% - 40px));
  margin: 0 auto;
}

.header-inner {
  padding: 42px 0 38px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 4px;
  color: inherit;
  font-family: "Arial", sans-serif;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.eyebrow {
  opacity: 0.72;
}

.section-kicker {
  color: var(--accent);
}

.title-row {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.45rem);
  letter-spacing: 0.025em;
  line-height: 1.25;
}

.lead {
  margin: 7px 0 0;
  color: rgba(255, 255, 255, 0.85);
  font-size: 0.98rem;
}

.local-badge {
  flex: none;
  border: 1px solid rgba(255, 255, 255, 0.42);
  border-radius: 999px;
  padding: 5px 11px;
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.78rem;
  text-decoration: none;
}

a.local-badge:hover {
  border-color: #fff;
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}

.page-shell {
  padding: 26px 0 58px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 22px;
  border: 1px solid #f0d2b7;
  border-radius: 10px;
  padding: 11px 14px;
  background: var(--orange-pale);
  color: #704019;
  font-size: 0.88rem;
}

.notice p {
  margin: 0;
}

.notice-icon {
  display: grid;
  width: 20px;
  height: 20px;
  flex: none;
  place-items: center;
  border-radius: 50%;
  background: var(--orange);
  color: #fff;
  font-weight: 800;
  line-height: 1;
}

.overview {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  margin-bottom: 28px;
}

.overview h2,
.filter-heading h2,
.results-toolbar h2 {
  margin: 0;
  font-size: 1.32rem;
  line-height: 1.4;
}

.overview > div > p:last-child {
  max-width: 680px;
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 0.91rem;
}

.stat-list {
  display: grid;
  min-width: 350px;
  grid-template-columns: repeat(3, 1fr);
  margin: 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
}

.stat-list > div {
  min-width: 0;
  padding: 12px 14px;
}

.stat-list > div + div {
  border-left: 1px solid var(--line);
}

.stat-list dt {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.stat-list dd {
  margin: 2px 0 0;
  color: var(--accent-deep);
  font-size: 1.13rem;
  font-weight: 800;
  line-height: 1.2;
}

.workspace {
  display: grid;
  align-items: start;
  grid-template-columns: minmax(230px, 280px) minmax(0, 1fr);
  gap: 28px;
}

.filter-panel,
.results-panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.filter-panel {
  position: sticky;
  top: 16px;
  padding: 20px;
}

.filter-heading,
.results-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.text-button {
  border: 0;
  padding: 3px 0;
  background: transparent;
  color: var(--accent);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.filter-fields {
  display: grid;
  gap: 14px;
  margin-top: 20px;
}

.filter-fields > label,
.session-fieldset {
  display: grid;
  gap: 5px;
  min-width: 0;
  border: 0;
  padding: 0;
}

.filter-fields span,
.session-fieldset legend {
  padding: 0;
  color: #3a4e46;
  font-size: 0.79rem;
  font-weight: 700;
}

select,
input[type="search"] {
  width: 100%;
  min-height: 40px;
  border: 1px solid #c9d8cf;
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.9rem;
}

select:disabled {
  background: #f2f5f2;
  color: #87948e;
}

input[type="search"]::placeholder {
  color: #9aa8a1;
}

.session-options {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 8px;
}

.session-options label {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: #3f514a;
  font-size: 0.82rem;
}

.tag-search-label small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.45;
}

.filter-help {
  margin: 21px 0 0;
  border-top: 1px solid var(--line);
  padding-top: 13px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.5;
}

.results-panel {
  min-height: 480px;
  padding: 23px;
}

.results-toolbar {
  margin-bottom: 20px;
}

.result-status {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.toolbar-actions {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.primary-button,
.secondary-button,
.pdf-link,
.answer-button,
.tag-button {
  border-radius: 8px;
  font-weight: 700;
  transition: background-color 150ms ease, border-color 150ms ease, color 150ms ease, transform 150ms ease;
}

.primary-button,
.secondary-button,
.answer-button {
  min-height: 38px;
  padding: 7px 12px;
  font-size: 0.84rem;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.secondary-button {
  border: 1px solid #b8cbc0;
  background: #fff;
  color: var(--accent-deep);
}

.secondary-button:hover {
  border-color: var(--accent);
  background: var(--accent-pale);
}

.question-list {
  display: grid;
  gap: 16px;
}

.question-card {
  overflow: hidden;
  border: 1px solid #dbe5df;
  border-radius: 11px;
  background: #fff;
}

.question-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 17px 11px;
  background: #f8fbf8;
}

.question-identity {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 9px;
  color: #345248;
  font-size: 0.8rem;
  font-weight: 700;
}

.question-number {
  color: var(--accent-deep);
  font-size: 0.93rem;
}

.year-label {
  color: var(--muted);
  font-weight: 500;
}

.warning-stack {
  display: flex;
  flex: none;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 5px;
}

.warning-badge {
  border: 1px solid #edcba4;
  border-radius: 999px;
  padding: 2px 7px;
  background: var(--orange-pale);
  color: #8a450f;
  font-size: 0.69rem;
  font-weight: 800;
  white-space: nowrap;
}

.question-card-body {
  padding: 4px 17px 16px;
}

.question-text {
  margin: 10px 0 14px;
  color: #1d2b26;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 1rem;
  line-height: 1.82;
  white-space: pre-wrap;
}

.question-text.is-missing {
  color: var(--muted);
  font-family: inherit;
  font-size: 0.9rem;
}

.choice-list {
  display: grid;
  gap: 4px;
  margin: -3px 0 15px;
  padding-left: 1.65em;
  list-style-type: upper-alpha;
  color: #2c3d36;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", serif;
  font-size: 0.96rem;
  line-height: 1.7;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0 0 14px;
}

.tag-button {
  border: 1px solid #c7dfd2;
  padding: 3px 8px;
  background: #f2f9f4;
  color: #176248;
  font-size: 0.72rem;
}

.tag-button:hover {
  border-color: var(--accent);
  background: var(--accent-pale);
}

.uncategorized-tag {
  border-radius: 999px;
  padding: 3px 8px;
  background: #f1f3f2;
  color: var(--muted);
  font-size: 0.72rem;
}

.question-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #e6ece8;
  padding-top: 13px;
}

.answer-button {
  border: 1px solid var(--accent);
  background: #fff;
  color: var(--accent-deep);
}

.answer-button:hover {
  background: var(--accent-pale);
}

.answer-area {
  margin: 12px 0 0;
  border-left: 4px solid var(--accent);
  padding: 9px 12px;
  background: #eff8f2;
  color: #154737;
  font-size: 0.88rem;
}

.answer-area strong {
  margin-right: 7px;
}

.answer-explanation {
  margin: 9px 0 0;
  padding-top: 9px;
  border-top: 1px solid #cce1d5;
  line-height: 1.7;
}

.answer-references {
  margin: 9px 0 0;
  font-size: 0.78rem;
  line-height: 1.6;
}

.answer-reference-link {
  color: #246b50;
}

.answer-reference-link:hover {
  color: var(--accent-deep);
}

.pdf-link,
.pdf-link-disabled {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 5px 9px;
  border: 1px solid #cbd8d1;
  color: #456259;
  font-size: 0.75rem;
  text-decoration: none;
}

.pdf-link:hover {
  border-color: var(--accent);
  background: #f4faf5;
  color: var(--accent-deep);
}

.pdf-link-disabled {
  border-style: dashed;
  background: #f6f7f6;
  color: #9ba7a1;
  cursor: not-allowed;
}

.more-actions {
  display: flex;
  justify-content: center;
  margin-top: 21px;
}

.empty-state,
.data-state {
  margin-top: 6px;
  border: 1px dashed #bfd0c6;
  border-radius: 10px;
  padding: 35px 20px;
  background: #f8fbf8;
  color: var(--muted);
  text-align: center;
}

.data-state {
  margin-bottom: 16px;
  border-color: #e4c9a9;
  background: #fff9f1;
  color: #77552e;
  text-align: left;
}

.empty-state h3 {
  margin: 0;
  color: #40544b;
  font-size: 1rem;
}

.empty-state p:not(.empty-state-mark) {
  margin: 5px 0 16px;
  font-size: 0.86rem;
}

.empty-state-mark {
  margin: 0 0 2px;
  color: var(--accent);
  font-size: 2rem;
  line-height: 1;
}

.is-hidden {
  display: none !important;
}

.site-footer {
  border-top: 1px solid var(--line);
  padding: 20px 0 36px;
  color: var(--muted);
  font-size: 0.75rem;
}

.site-footer p {
  margin: 0;
}

.noscript-message {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: 360px;
  margin: 0;
  border: 1px solid #e0bb93;
  border-radius: 8px;
  padding: 12px;
  background: #fff5e8;
  color: #6c411a;
  font-size: 0.85rem;
}

@media (max-width: 900px) {
  .overview {
    align-items: stretch;
    flex-direction: column;
  }

  .stat-list {
    min-width: 0;
    max-width: 520px;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .filter-panel {
    position: static;
  }

  .filter-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .tag-search-label {
    grid-column: 1 / -1;
  }
}

@media (max-width: 620px) {
  .header-inner,
  .page-shell,
  .site-footer {
    width: min(100% - 24px, 1240px);
  }

  .header-inner {
    padding: 30px 0 27px;
  }

  .title-row,
  .results-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .local-badge {
    align-self: flex-start;
  }

  .toolbar-actions {
    justify-content: flex-start;
  }

  .stat-list > div {
    padding: 10px;
  }

  .stat-list dt {
    font-size: 0.66rem;
  }

  .stat-list dd {
    font-size: 1rem;
  }

  .filter-fields {
    grid-template-columns: 1fr;
  }

  .results-panel,
  .filter-panel {
    padding: 16px;
  }

  .question-card-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 13px 14px 9px;
  }

  .warning-stack {
    justify-content: flex-start;
  }

  .question-card-body {
    padding: 3px 14px 14px;
  }

  .question-text {
    font-size: 0.95rem;
  }
}
