:root {
  color-scheme: light;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --canvas: #f5f5f7;
  --surface: #ffffff;
  --surface-soft: #fbfbfd;
  --line: #d8d8dc;
  --soft-line: #e8e8ed;
  --accent: #0066cc;
  --accent-soft: #e8f2ff;
  --unknown: #77777c;
  --radius: 18px;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}

button,
select,
input { font: inherit; }

button,
select { color: inherit; }

button { cursor: pointer; }

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 max(24px, calc((100vw - 1440px) / 2));
  background: rgba(245, 245, 247, 0.88);
  border-bottom: 1px solid rgba(29, 29, 31, 0.08);
  backdrop-filter: saturate(180%) blur(18px);
}

.brand {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  color: inherit;
  font-size: 13px;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.brand-mark {
  width: 15px;
  height: 15px;
  background: var(--ink);
  border: 1.5px solid currentColor;
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px var(--canvas);
}

.header-meta {
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.08em;
}

main {
  width: min(1440px, calc(100% - 48px));
  margin-inline: auto;
}

.selector-shell { padding: 52px 0 20px; }

.selector-heading,
.comparison-toolbar {
  display: flex;
  gap: 32px;
  align-items: end;
  justify-content: space-between;
}

.selector-heading h1,
.comparison-toolbar h2 {
  margin: 0;
  font-size: clamp(30px, 3.2vw, 48px);
  font-weight: 620;
  letter-spacing: -0.045em;
  line-height: 1;
}

.category-control {
  display: grid;
  gap: 7px;
  width: min(320px, 38vw);
  color: var(--muted);
  font-size: 10px;
  font-weight: 560;
}

select {
  width: 100%;
  padding: 11px 38px 11px 13px;
  appearance: none;
  background-color: var(--surface);
  background-image:
    linear-gradient(45deg, transparent 50%, currentColor 50%),
    linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 50%,
    calc(100% - 11px) 50%;
  background-repeat: no-repeat;
  background-size: 5px 5px, 5px 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

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

.category-control select {
  color: var(--ink);
  font-size: 13px;
}

.selector-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-top: 28px;
}

.selector-card {
  min-width: 0;
  padding: 19px;
  background: var(--surface);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.025);
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.selector-card:focus-within {
  border-color: #b9cde4;
  box-shadow: 0 8px 28px rgba(27, 64, 110, 0.07);
}

.slot-index {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 17px;
  color: #96969b;
  font-size: 9px;
  font-weight: 680;
  letter-spacing: 0.12em;
}

.clear-slot {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  padding: 0;
  color: #8e8e93;
  background: #f2f2f4;
  border: 0;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
}

.clear-slot:hover {
  color: var(--ink);
  background: #e8e8ed;
}

.selector-card label {
  display: grid;
  gap: 6px;
  margin-top: 11px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 560;
}

.selector-card select {
  padding: 11px 28px 11px 0;
  background-color: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  font-size: 15px;
  font-weight: 520;
}

.selected-state {
  display: flex;
  gap: 7px;
  align-items: center;
  min-height: 18px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 10px;
}

.state-dot {
  width: 6px;
  height: 6px;
  background: #30a46c;
  border-radius: 50%;
}

.selector-footer {
  display: flex;
  gap: 18px;
  justify-content: flex-end;
  margin-top: 14px;
}

.text-button,
.text-link {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  padding: 8px 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 560;
  text-decoration: none;
}

.text-button:hover,
.text-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.comparison-shell { padding: 30px 0 100px; }

.comparison-toolbar {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.comparison-toolbar h2 { font-size: clamp(25px, 2.4vw, 36px); }

.difference-toggle {
  display: inline-flex;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}

.difference-toggle strong { font-weight: 560; }

.difference-toggle input {
  position: absolute;
  opacity: 0;
}

.difference-toggle span {
  position: relative;
  width: 36px;
  height: 20px;
  background: #d1d1d6;
  border-radius: 999px;
  transition: 160ms ease;
}

.difference-toggle span::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  content: "";
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.22);
  transition: 160ms ease;
}

.difference-toggle input:checked + span { background: var(--accent); }
.difference-toggle input:checked + span::after { transform: translateX(16px); }

.comparison-summary {
  display: grid;
  grid-template-columns: minmax(160px, 0.72fr) repeat(var(--compare-count, 3), minmax(200px, 1fr));
  margin-top: 28px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius) var(--radius) 0 0;
}

.summary-label,
.summary-camera {
  min-width: 0;
  padding: 22px 18px;
}

.summary-label {
  display: flex;
  align-items: end;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.1em;
}

.summary-camera { border-left: 1px solid var(--soft-line); }

.summary-camera small {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.summary-camera strong {
  display: block;
  overflow: hidden;
  font-size: clamp(17px, 1.6vw, 23px);
  font-weight: 600;
  letter-spacing: -0.035em;
  line-height: 1.2;
  text-overflow: ellipsis;
}

.summary-camera em {
  display: inline-flex;
  margin-top: 12px;
  padding: 4px 7px;
  color: #606066;
  background: #f1f1f3;
  border-radius: 999px;
  font-size: 9px;
  font-style: normal;
  font-weight: 600;
}

.comparison-content {
  min-height: 360px;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--soft-line);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
}

.spec-group + .spec-group { border-top: 10px solid var(--canvas); }

.group-heading,
.comparison-row {
  display: grid;
  grid-template-columns: minmax(160px, 0.72fr) repeat(var(--compare-count, 3), minmax(200px, 1fr));
}

.group-heading {
  margin: 0;
  background: var(--surface-soft);
  border-bottom: 1px solid var(--soft-line);
}

.group-heading span {
  grid-column: 1 / -1;
  padding: 16px 18px 12px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.comparison-row + .comparison-row { border-top: 1px solid var(--soft-line); }

.row-label,
.spec-cell {
  min-width: 0;
  padding: 18px;
}

.row-label {
  color: var(--muted);
  font-size: 11px;
  font-weight: 520;
  line-height: 1.5;
}

.spec-cell { border-left: 1px solid var(--soft-line); }

.spec-value {
  display: block;
  font-size: 13px;
  font-weight: 560;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.spec-note {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
}

.state-chip {
  display: inline-flex;
  padding: 4px 7px;
  color: var(--unknown);
  background: #f1f1f3;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 650;
}

.source-button {
  display: inline-flex;
  margin-top: 10px;
  padding: 0;
  color: var(--accent);
  background: transparent;
  border: 0;
  font-size: 9px;
  font-weight: 600;
}

.source-button:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.loading-state,
.empty-state,
.error-state {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  text-align: center;
}

.loading-state p,
.empty-state p,
.error-state p {
  margin: 14px 0 0;
  font-size: 11px;
}

.loading-line {
  width: 100px;
  height: 2px;
  overflow: hidden;
  background: var(--line);
}

.loading-line::after {
  display: block;
  width: 45%;
  height: 100%;
  content: "";
  background: var(--accent);
  animation: loading 1.1s ease-in-out infinite alternate;
}

@keyframes loading { to { transform: translateX(125%); } }

footer {
  display: flex;
  justify-content: space-between;
  width: min(1440px, calc(100% - 48px));
  margin-inline: auto;
  padding: 24px 0 30px;
  color: #96969b;
  border-top: 1px solid var(--line);
  font-size: 9px;
  letter-spacing: 0.06em;
}

.sources-page {
  padding: 42px 0 100px;
}

.back-link {
  display: inline-flex;
  color: var(--accent);
  font-size: 12px;
  font-weight: 560;
  text-decoration: none;
}

.back-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.sources-page > h1 {
  margin: 26px 0 32px;
  font-size: clamp(34px, 4vw, 54px);
  font-weight: 620;
  letter-spacing: -0.05em;
}

.sources-content {
  display: grid;
  gap: 18px;
}

.source-camera {
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
}

.source-camera-header {
  display: flex;
  gap: 24px;
  align-items: center;
  justify-content: space-between;
  padding: 28px;
  border-bottom: 1px solid var(--soft-line);
}

.source-camera-header small {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.source-camera-header h2 {
  margin: 0;
  font-size: clamp(23px, 2.4vw, 34px);
  font-weight: 610;
  letter-spacing: -0.04em;
}

.source-camera-header > span {
  flex: 0 0 auto;
  padding: 5px 8px;
  color: var(--muted);
  background: #f1f1f3;
  border-radius: 999px;
  font-size: 9px;
  font-weight: 600;
}

.reference-section,
.raw-section {
  padding: 28px;
}

.raw-section {
  padding-top: 4px;
}

.reference-section h3,
.raw-section > h3 {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 680;
  letter-spacing: 0.08em;
}

.reference-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.reference-card {
  display: flex;
  min-width: 0;
  min-height: 126px;
  padding: 15px;
  color: inherit;
  background: var(--surface-soft);
  border: 1px solid var(--soft-line);
  border-radius: 12px;
  flex-direction: column;
  text-decoration: none;
}

.reference-card:hover {
  border-color: #b9cde4;
}

.reference-card > span,
.reference-card > small {
  color: var(--muted);
  font-size: 9px;
}

.reference-card strong {
  margin: 8px 0 3px;
  font-size: 13px;
  font-weight: 600;
}

.reference-card p {
  margin: auto 0 0;
  padding-top: 12px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.5;
}

.source-group {
  border-top: 1px solid var(--soft-line);
}

.source-group:last-child {
  border-bottom: 1px solid var(--soft-line);
}

.source-group summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  list-style: none;
}

.source-group summary::-webkit-details-marker {
  display: none;
}

.source-group summary::after {
  content: "+";
  color: var(--muted);
  font-size: 17px;
  font-weight: 400;
}

.source-group[open] summary::after {
  content: "−";
}

.source-group summary span {
  display: none;
}

.raw-table {
  border-top: 1px solid var(--soft-line);
}

.raw-row {
  display: grid;
  grid-template-columns: minmax(130px, 0.55fr) minmax(280px, 1.8fr) minmax(110px, 0.55fr);
}

.raw-row + .raw-row {
  border-top: 1px solid var(--soft-line);
}

.raw-label,
.raw-copy,
.raw-source {
  min-width: 0;
  padding: 15px 12px;
}

.raw-label {
  color: var(--muted);
  font-size: 10px;
}

.raw-copy {
  border-left: 1px solid var(--soft-line);
  border-right: 1px solid var(--soft-line);
}

.raw-copy strong {
  display: block;
  font-size: 12px;
  font-weight: 520;
  line-height: 1.65;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.raw-copy small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
}

.raw-source a,
.raw-source span {
  color: var(--accent);
  font-size: 9px;
  font-weight: 560;
  line-height: 1.5;
  text-decoration: none;
}

.raw-source a:hover {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.source-dialog {
  width: min(620px, calc(100vw - 32px));
  max-height: min(760px, calc(100vh - 32px));
  padding: 0;
  color: var(--ink);
  background: var(--surface);
  border: 0;
  border-radius: 20px;
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.24);
}

.source-dialog::backdrop {
  background: rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(8px);
}

.dialog-frame {
  position: relative;
  padding: clamp(26px, 5vw, 48px);
}

.dialog-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--muted);
  background: #f1f1f3;
  border: 0;
  border-radius: 50%;
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
}

.source-dialog h2 {
  margin: 0 0 26px;
  font-size: 27px;
  font-weight: 610;
  letter-spacing: -0.04em;
}

.dialog-block {
  padding: 16px 0;
  border-top: 1px solid var(--soft-line);
}

.dialog-block dt {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.dialog-block dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.7;
  overflow-wrap: anywhere;
}

.dialog-block a {
  color: var(--accent);
  text-underline-offset: 3px;
}

.toast {
  position: fixed;
  z-index: 50;
  right: 20px;
  bottom: 20px;
  padding: 11px 14px;
  color: #fff;
  background: rgba(29, 29, 31, 0.94);
  border-radius: 10px;
  font-size: 11px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: 160ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .site-header {
    height: 50px;
    padding-inline: 16px;
  }

  main,
  footer { width: min(100% - 24px, 1440px); }

  .selector-shell { padding: 30px 0 22px; }

  .selector-heading,
  .comparison-toolbar {
    align-items: start;
    flex-direction: column;
  }

  .selector-heading h1 { font-size: 30px; }
  .category-control { width: 100%; }

  .selector-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin-top: 18px;
  }

  .selector-card:nth-child(3) { display: none; }

  .selector-card {
    padding: 14px;
    border-radius: 14px;
  }

  .slot-index { margin-bottom: 18px; }
  .selector-card select { font-size: 13px; }
  .comparison-shell { padding: 36px 0 70px; }
  .comparison-toolbar { gap: 20px; }

  .comparison-summary,
  .group-heading,
  .comparison-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .summary-label { display: none; }
  .summary-camera:first-of-type { border-left: 0; }
  .summary-camera:nth-child(n + 4) { display: none; }

  .group-heading span,
  .row-label { grid-column: 1 / -1; }

  .row-label {
    padding: 13px 14px 8px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--soft-line);
  }

  .spec-cell {
    padding: 14px;
    border-left: 0;
  }

  .spec-cell + .spec-cell { border-left: 1px solid var(--soft-line); }
  .spec-cell:nth-child(n + 4) { display: none; }

  footer {
    gap: 8px;
    flex-direction: column;
  }

  .sources-page {
    padding-top: 28px;
  }

  .source-camera-header,
  .reference-section,
  .raw-section {
    padding: 20px;
  }

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

  .reference-card {
    min-height: 100px;
  }

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

  .raw-label {
    padding-bottom: 6px;
    background: var(--surface-soft);
  }

  .raw-copy {
    padding-top: 10px;
    border: 0;
  }

  .raw-source {
    padding-top: 0;
  }
}

@media (max-width: 420px) {
  .selector-card { padding: 12px; }

  .clear-slot {
    width: 20px;
    height: 20px;
  }

  .summary-label,
  .summary-camera,
  .row-label,
  .spec-cell { padding-inline: 12px; }
}

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