:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --border: #e2e8f0;
  --border-strong: #cbd5e1;
  --text: #0f172a;
  --text-body: #334155;
  --text-muted: #475569;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --quiz-bg: #0f766e;
  --quiz-hover: #115e59;
  --fact-bg: #eff6ff;
  --fact-title: #1e40af;
  --fact-text: #1e3a8a;
  --viewer-bg: radial-gradient(circle at center, #ffffff 0%, #e2e8f0 100%);
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  --shadow-hover: 0 10px 20px rgba(15, 23, 42, 0.12);
  --correct-bg: #dcfce7;
  --correct-border: #16a34a;
  --correct-text: #14532d;
  --wrong-bg: #fee2e2;
  --wrong-border: #dc2626;
  --wrong-text: #7f1d1d;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface-alt: #334155;
  --border: #334155;
  --border-strong: #475569;
  --text: #f8fafc;
  --text-body: #e2e8f0;
  --text-muted: #cbd5e1;
  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --quiz-bg: #0d9488;
  --quiz-hover: #0f766e;
  --fact-bg: #172554;
  --fact-title: #93c5fd;
  --fact-text: #dbeafe;
  --viewer-bg: radial-gradient(circle at center, #334155 0%, #0f172a 100%);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-hover: 0 10px 20px rgba(0, 0, 0, 0.45);
  --correct-bg: #14532d;
  --correct-border: #22c55e;
  --correct-text: #dcfce7;
  --wrong-bg: #7f1d1d;
  --wrong-border: #ef4444;
  --wrong-text: #fee2e2;
}

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

html,
body {
  overflow-x: hidden;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  transition: background-color 0.2s ease, color 0.2s ease;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 1rem;
}

.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;
}

.site-header {
  background-color: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 1.25rem 0;
  margin-bottom: 2rem;
}

.header-inner {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.header-title h1 {
  margin: 0;
  font-size: 1.65rem;
  color: var(--text);
}

.subtitle {
  margin: 0.25rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.65rem;
}

.header-actions .search-box {
  flex: 1 1 200px;
}

.search-box input {
  width: 100%;
  padding: 0.7rem 0.95rem;
  font-size: 1rem;
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  background-color: var(--surface);
  color: var(--text);
}

.search-box input::placeholder {
  color: var(--text-muted);
}

.btn-theme {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  min-height: 42px;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  color: var(--text);
  background-color: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.btn-theme:hover,
.btn-theme:focus-visible {
  border-color: var(--primary);
}

.organ-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.5rem;
  margin-bottom: 3rem;
}

.card {
  display: flex;
  flex-direction: column;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover,
.card:focus-visible {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.card-img {
  width: 100%;
  height: auto;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background-color: var(--surface-alt);
  display: block;
}

.card-body {
  padding: 1rem 1.25rem 1.25rem;
}

.card-body h2 {
  margin: 0 0 0.5rem;
  font-size: 1.25rem;
  color: var(--text);
}

.card-body p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  background-color: var(--surface);
}

.detail-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.detail-header-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.back-link {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
  color: var(--primary);
  text-decoration: none;
  padding: 0.45rem 0.75rem;
  border-radius: 0.5rem;
  transition: background-color 0.2s ease;
}

.back-link:hover,
.back-link:focus-visible {
  background-color: var(--surface-alt);
}

.brand-name {
  font-weight: 700;
  color: var(--text);
}

.detail-main {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2rem;
  margin-bottom: 3rem;
}

.viewer-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

model-viewer {
  width: 100%;
  height: 60vh;
  min-height: 320px;
  max-height: 560px;
  background: var(--viewer-bg);
  border: 1px solid var(--border-strong);
  border-radius: 0.75rem;
  overflow: hidden;
}

.btn-ar {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  padding: 0.75rem 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  color: #ffffff;
  background-color: var(--primary);
  border: none;
  border-radius: 9999px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
  transition: background-color 0.2s ease, transform 0.15s ease;
}

.btn-ar:hover,
.btn-ar:focus-visible {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
}

.progress {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 60%;
  max-width: 260px;
  height: 8px;
  background-color: rgba(148, 163, 184, 0.3);
  border-radius: 9999px;
  overflow: hidden;
  pointer-events: none;
}

.progress.hide {
  display: none;
}

.progress-fill {
  width: 0%;
  height: 100%;
  background-color: var(--primary);
  transition: width 0.15s ease;
}

.ar-note {
  margin: 0;
  font-size: 0.875rem;
  color: var(--text-muted);
  text-align: center;
}

.hotspot {
  position: relative;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border-radius: 50%;
  border: 3px solid #ffffff;
  background-color: #ef4444;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.35);
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
}

.hotspot:hover,
.hotspot:focus-visible,
.hotspot.active {
  transform: scale(1.15);
  background-color: #dc2626;
}

.hotspot:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
}

.hotspot-label {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%);
  padding: 0.25rem 0.6rem;
  border-radius: 0.375rem;
  background-color: #0f172a;
  color: #ffffff;
  font-size: 0.78rem;
  font-weight: 600;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s ease;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.25);
}

.hotspot:hover .hotspot-label,
.hotspot:focus-visible .hotspot-label,
.hotspot.active .hotspot-label {
  opacity: 1;
}

.hotspot-info {
  background-color: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 4px solid #ef4444;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}

.hotspot-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.hotspot-info-header h2 {
  margin: 0;
  font-size: 1.05rem;
  color: var(--text);
}

.hotspot-info-close {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  background-color: var(--surface-alt);
  color: var(--text-body);
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.hotspot-info-close:hover,
.hotspot-info-close:focus-visible {
  background-color: var(--border);
  color: var(--text);
}

.hotspot-info p {
  margin: 0;
  color: var(--text-body);
  font-size: 0.95rem;
}

.detail-info {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
}

.detail-info h1 {
  margin: 0 0 0.75rem;
  font-size: 1.85rem;
  color: var(--text);
}

.detail-info h2 {
  margin: 1.5rem 0 0.5rem;
  font-size: 1.15rem;
  color: var(--text);
}

.detail-desc {
  margin: 0;
  color: var(--text-body);
}

.detail-list {
  margin: 0;
  padding-left: 1.25rem;
  color: var(--text-body);
}

.detail-list li + li {
  margin-top: 0.35rem;
}

.fact-box {
  margin-top: 1.25rem;
  padding: 1rem 1.25rem;
  background-color: var(--fact-bg);
  border-left: 4px solid var(--primary);
  border-radius: 0.5rem;
}

.fact-box h2 {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--fact-title);
}

.fact-box p {
  margin: 0;
  color: var(--fact-text);
}

.detail-actions {
  margin-top: 1.5rem;
}

.btn-quiz,
.btn-home {
  display: inline-block;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  font-family: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  color: #ffffff;
  background-color: var(--quiz-bg);
  border: none;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.btn-quiz:hover,
.btn-quiz:focus-visible,
.btn-home:hover,
.btn-home:focus-visible {
  background-color: var(--quiz-hover);
}

.credit-box {
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.9rem;
  color: var(--text-muted);
}

.credit-box h2 {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--text);
}

.credit-box p {
  margin: 0.25rem 0;
  word-break: break-word;
}

.credit-box a {
  color: var(--primary);
}

.not-found {
  min-height: calc(100vh - 140px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
}

.not-found-card {
  max-width: 460px;
  width: 100%;
  text-align: center;
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 2.5rem 1.5rem;
}

.not-found-code {
  margin: 0;
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}

.not-found-card h1 {
  margin: 0.75rem 0 0.5rem;
  font-size: 1.5rem;
  color: var(--text);
}

.not-found-card p {
  margin: 0 0 1.5rem;
  color: var(--text-muted);
}

.quiz-main {
  max-width: 720px;
  margin-bottom: 3rem;
}

.quiz-card {
  background-color: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.quiz-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.quiz-mode {
  font-weight: 600;
  color: var(--quiz-bg);
}

[data-theme="dark"] .quiz-mode {
  color: #5eead4;
}

.quiz-question {
  margin: 0 0 1.25rem;
  font-size: 1.35rem;
  color: var(--text);
}

.quiz-options {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.quiz-option {
  width: 100%;
  text-align: left;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background-color: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
}

.quiz-option:hover:not(:disabled),
.quiz-option:focus-visible:not(:disabled) {
  border-color: var(--primary);
}

.quiz-option:disabled {
  cursor: default;
}

.quiz-option.correct {
  background-color: var(--correct-bg);
  border-color: var(--correct-border);
  color: var(--correct-text);
  font-weight: 600;
}

.quiz-option.wrong {
  background-color: var(--wrong-bg);
  border-color: var(--wrong-border);
  color: var(--wrong-text);
}

.quiz-feedback {
  margin-top: 1.25rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border);
}

.quiz-status {
  margin: 0 0 0.4rem;
  font-weight: 700;
  font-size: 1.05rem;
}

.quiz-status.is-correct {
  color: #16a34a;
}

[data-theme="dark"] .quiz-status.is-correct {
  color: #4ade80;
}

.quiz-status.is-wrong {
  color: #dc2626;
}

[data-theme="dark"] .quiz-status.is-wrong {
  color: #f87171;
}

.quiz-explanation {
  margin: 0 0 1rem;
  color: var(--text-body);
}

.quiz-result {
  text-align: center;
  padding: 2.25rem 1.5rem;
}

.quiz-result h1 {
  margin: 0 0 0.75rem;
  color: var(--text);
}

.result-score {
  margin: 0 0 0.5rem;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--primary);
}

.result-high-score {
  margin: 0 0 1.5rem;
  font-size: 1rem;
  color: var(--text-muted);
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.75rem;
}

.btn-secondary {
  display: inline-block;
  padding: 0.75rem 1.25rem;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  background-color: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: 0.5rem;
  transition: background-color 0.2s ease;
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
  background-color: var(--border);
}

@media (min-width: 768px) {
  .header-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }

  .header-actions {
    flex-wrap: nowrap;
  }

  .search-box {
    width: 280px;
    flex-shrink: 0;
  }

  .organ-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .organ-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .detail-main {
    grid-template-columns: 1.15fr 1fr;
    align-items: start;
  }

  model-viewer {
    height: 68vh;
  }
}
