:root {
  --bg: #f3efe5;
  --surface: rgba(255, 252, 247, 0.9);
  --surface-strong: #fffaf1;
  --ink: #1f2a2a;
  --muted: #586564;
  --line: rgba(31, 42, 42, 0.12);
  --accent: #005f73;
  --accent-soft: rgba(0, 95, 115, 0.12);
  --accent-alt: #bb3e03;
  --danger: #9b2226;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(31, 42, 42, 0.12);
  font-family: "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(238, 155, 0, 0.22), transparent 30%),
    radial-gradient(circle at right, rgba(10, 147, 150, 0.18), transparent 35%),
    linear-gradient(180deg, #fff7e9 0%, var(--bg) 100%);
}

button,
input,
select {
  font: inherit;
}

.page-shell {
  padding: 20px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.62fr) 320px;
  gap: 16px;
  align-items: stretch;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 12px;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}

.hero h1 {
  margin: 0;
  font-size: clamp(1.55rem, 2.2vw, 2.15rem);
  line-height: 1.12;
}

.hero-kicker {
  margin: 0 0 10px;
  color: var(--muted);
  font-size: 0.95rem;
  letter-spacing: 0.01em;
}

.hero-copy {
  color: var(--muted);
  margin: 12px 0 0;
}

.panel {
  backdrop-filter: blur(8px);
  background: var(--surface);
  border: 1px solid rgba(255, 255, 255, 0.45);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-main,
.hero-card,
.hero-stack {
  min-height: 120px;
}

.hero-main {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-meta-links {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

.hero-stack {
  display: grid;
  gap: 12px;
}

.mini-panel {
  padding: 14px;
}

.hero-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.hero-links,
.hero-meta-links {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-links a,
.hero-meta-links a,
.page-footer a {
  color: var(--accent);
  text-decoration: none;
}

.hero-links a:hover,
.hero-meta-links a:hover,
.page-footer a:hover {
  text-decoration: underline;
}

.stat-label,
.stat-note {
  color: var(--muted);
}

.stat-value {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 8px 0;
  line-height: 1.35;
}

.layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
}

.controls {
  display: block;
}

.main-panel {
  display: grid;
  gap: 16px;
  align-content: start;
}

.controls > .panel {
  min-height: 980px;
  display: none;
  flex-direction: column;
}

.controls > .panel.is-active-panel {
  display: flex;
}

.panel {
  padding: 16px;
}

.panel h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.button-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.button-group button {
  border: 0;
  border-radius: 999px;
  padding: 8px 10px;
  background: rgba(31, 42, 42, 0.06);
  color: var(--ink);
  cursor: pointer;
}

.button-group button.is-active {
  background: var(--accent);
  color: white;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.field span {
  color: var(--muted);
  font-size: 0.92rem;
}

.field input,
.field select {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--surface-strong);
  padding: 11px 12px;
}

.selected-list,
.search-results {
  display: grid;
  gap: 10px;
}

.selected-list {
  max-height: 380px;
  overflow: auto;
}

.filter-panel {
  display: none;
  gap: 10px;
  margin-bottom: 10px;
  padding: 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.68);
}

.filter-panel.is-open {
  display: grid;
}

.compact-filter {
  margin-bottom: 10px;
}

.inline-tools {
  display: flex;
  justify-content: flex-start;
  margin: 2px 0 10px;
}

.top-tools {
  margin-top: 12px;
  margin-bottom: 0;
}

.toggle-filter-button {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.7);
  color: var(--muted);
  cursor: pointer;
}

.toggle-filter-button.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  border-color: rgba(0, 95, 115, 0.22);
}

.filter-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}

.filter-header button {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(31, 42, 42, 0.06);
  color: var(--muted);
  cursor: pointer;
}

.active-filters,
.condition-groups,
.condition-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.condition-group {
  display: grid;
  gap: 8px;
  width: 100%;
  padding-top: 4px;
  border-top: 1px solid rgba(31, 42, 42, 0.06);
}

.condition-group-label {
  color: var(--muted);
  font-size: 0.82rem;
}

.filter-chip,
.condition-chip {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(31, 42, 42, 0.05);
  color: var(--ink);
  cursor: pointer;
}

.filter-chip.is-active,
.condition-chip.is-active {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.condition-chip.is-muted {
  opacity: 0.55;
}

.result-item,
.selected-item,
.summary-card {
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.78);
  padding: 12px;
}

.result-item {
  display: grid;
  gap: 8px;
}

.result-item button,
.selected-item button,
.selection-pill button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
}

.result-item button {
  justify-self: start;
  background: var(--accent-soft);
  color: var(--accent);
}

.selected-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
}

.selected-item button,
.selection-pill button {
  background: rgba(155, 34, 38, 0.12);
  color: var(--danger);
}

.meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.detail-copy {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.selected-item {
  align-items: flex-start;
}

.selected-item .condition-tags,
.result-item .condition-tags,
.summary-card .condition-tags,
.selection-pill .condition-tags {
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(31, 42, 42, 0.06);
}

.year-badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 4px 10px;
  background: rgba(0, 95, 115, 0.12);
  color: var(--accent);
  font-weight: 700;
}

.is-hidden {
  display: none;
}

.chart-panel {
  min-height: 580px;
}

.chart-header {
  display: grid;
  grid-template-columns: 170px minmax(180px, 240px) minmax(420px, 1fr);
  gap: 6px;
  align-items: flex-start;
}

.chart-header p {
  color: var(--muted);
}

.hover-card {
  max-width: none;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.chart-legend {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
  min-height: 36px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  font-size: 0.84rem;
}

.legend-swatch {
  display: block;
  width: 32px;
  height: 8px;
  flex: 0 0 32px;
}

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

.hover-lines {
  display: grid;
  gap: 4px;
}

.hover-line {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.hover-day-label {
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.hover-day-spacer {
  display: block;
}

.hover-diff {
  color: var(--accent);
  font-weight: 700;
}

.hover-line span:last-child {
  white-space: nowrap;
}

.chart-shell {
  margin-top: 10px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.9), rgba(255,255,255,0.7)),
    repeating-linear-gradient(
      90deg,
      transparent 0,
      transparent 59px,
      rgba(31, 42, 42, 0.04) 60px
    );
  overflow: hidden;
}

#chart {
  display: block;
  width: 100%;
  height: auto;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.summary-card h3 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.summary-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.summary-link,
.dialog-close {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.82);
  color: var(--accent);
  cursor: pointer;
}

.reference-dialog {
  width: min(760px, calc(100vw - 32px));
  border: 0;
  border-radius: 20px;
  padding: 0;
  box-shadow: 0 24px 80px rgba(31, 42, 42, 0.22);
}

.reference-dialog::backdrop {
  background: rgba(31, 42, 42, 0.45);
}

.reference-dialog-header,
.reference-dialog-body {
  padding: 18px 20px;
}

.reference-dialog-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
}

.reference-dialog-header h2 {
  margin: 4px 0 0;
}

.reference-dialog-body {
  display: grid;
  gap: 16px;
  max-height: min(70vh, 760px);
  overflow: auto;
}

.reference-section {
  display: grid;
  gap: 10px;
}

.reference-section h3 {
  margin: 0;
}

.reference-list {
  display: grid;
  gap: 8px;
}

.reference-item {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(31, 42, 42, 0.03);
}

.pair-grid {
  display: grid;
  gap: 12px;
}

.pair-card {
  border-radius: 14px;
  border: 1px solid var(--line);
  padding: 12px;
  background: rgba(255, 255, 255, 0.7);
}

.search-results.compact {
  flex: 0 0 auto;
  min-height: 0;
  max-height: 420px;
  overflow: auto;
}

.selection-pill {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(31, 42, 42, 0.05);
}

.empty-state {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 12px;
}

.page-footer {
  margin-top: 16px;
  padding: 0 4px 24px;
  color: var(--muted);
  font-size: 0.92rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.page-footer-links {
  display: flex;
  gap: 12px;
}

.page-footer-brand {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(88, 101, 100, 0.82);
}

.legal-shell {
  max-width: 1180px;
  margin: 0 auto;
}

.legal-header,
.legal-section {
  margin-bottom: 16px;
}

.legal-layout {
  display: grid;
  gap: 16px;
}

.legal-list {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.legal-source-list {
  display: grid;
  gap: 12px;
}

.guide-tab-buttons,
.guide-subtab-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.guide-tab-buttons button,
.guide-subtab-buttons button {
  border: 0;
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(31, 42, 42, 0.06);
  color: var(--ink);
  cursor: pointer;
}

.guide-tab-buttons button.is-active,
.guide-subtab-buttons button.is-active {
  background: var(--accent);
  color: white;
}

.guide-tab-panel,
.guide-subtab-panel {
  display: none;
}

.guide-tab-panel.is-active,
.guide-subtab-panel.is-active {
  display: block;
}

.guide-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.guide-card {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  padding: 12px;
}

.guide-card h3,
.guide-card p {
  margin: 0 0 8px;
}

.guide-steps {
  margin: 0;
  padding-left: 20px;
  line-height: 1.8;
}

.guide-steps.compact {
  line-height: 1.6;
}

.guide-figure {
  border: 1px dashed var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.6);
  padding: 16px;
}

.guide-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.guide-screenshot {
  margin: 16px 0 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.82);
}

.guide-screenshot img {
  display: block;
  width: 100%;
  height: auto;
}

.guide-screenshot figcaption {
  padding: 12px 14px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.guide-figure-body p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.source-item {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  padding: 12px;
}

.source-item h3,
.source-item p {
  margin: 0 0 8px;
}

@media (max-width: 1100px) {
  .hero,
  .layout {
    grid-template-columns: 1fr;
  }

  .chart-header {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 720px) {
  .page-shell {
    padding: 16px;
  }

  .field-row {
    grid-template-columns: 1fr;
  }

  .hero-copy {
    white-space: normal;
  }
}
