:root {
  --bg: #faf9f6;
  --bg-tinted: #f2f1ec;
  --surface: #ffffff;
  --ink: #14181f;
  --ink-muted: #525b68;
  --line: #e4e2da;
  --accent: #0f5c6e;
  --accent-soft: #e6f1f3;
  --accent-dark: #0a414e;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 12px 32px rgba(20, 24, 31, 0.06);
  --font-serif: "Instrument Serif", Georgia, serif;
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 24px;
}

/* Header */
.site-header {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(250, 249, 246, 0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 64px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 14.5px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 28px;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-muted);
}

.nav-links a:hover {
  color: var(--accent);
}

.lang-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-tinted);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.lang-btn {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 11px;
  border-radius: 999px;
  cursor: pointer;
}

.lang-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

/* Compact Archive Intro */
.archive-intro {
  padding: 44px 0 36px;
  border-bottom: 1px solid var(--line);
}

.intro-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.intro-title {
  margin: 0 0 8px;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(34px, 4.2vw, 48px);
  line-height: 1.1;
}

.intro-sub {
  margin: 0;
  max-width: 60ch;
  color: var(--ink-muted);
  font-size: 15px;
}

.intro-stats {
  display: flex;
  gap: 12px;
}

.stat-pill {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  min-width: 132px;
}

.stat-num {
  display: block;
  font-family: var(--font-serif);
  font-size: 28px;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 3px;
}

.stat-label {
  font-size: 12px;
  color: var(--ink-muted);
  font-weight: 500;
}

/* Sections */
.section {
  padding: 60px 0 72px;
}

.section-tinted {
  background: var(--bg-tinted);
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.section-head {
  margin-bottom: 28px;
}

.section-head-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: flex-end;
  gap: 18px;
}

.section-kicker {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.section-title {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: clamp(28px, 3.2vw, 38px);
  line-height: 1.15;
}

.section-lead {
  margin: 8px 0 0;
  max-width: 60ch;
  color: var(--ink-muted);
  font-size: 14.5px;
}

/* Buttons & Filters */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
}

.btn-secondary {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.btn-secondary:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.filter-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
}

.filter-btn.is-active,
.filter-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Before / After Case Grid */
.case-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 22px;
}

.case-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.ba-slider {
  position: relative;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  user-select: none;
  touch-action: pan-y;
  background: #1b222a;
}

.ba-layer {
  position: absolute;
  inset: 0;
}

.ba-layer img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.ba-before {
  clip-path: inset(0 50% 0 0);
}

.ba-divider {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #fff;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.ba-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: #fff;
  color: var(--ink);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.ba-range {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: ew-resize;
}

.ba-label {
  position: absolute;
  bottom: 10px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(20, 24, 31, 0.74);
  color: #fff;
  pointer-events: none;
}

.ba-label-before {
  left: 10px;
}

.ba-label-after {
  right: 10px;
}

.case-content {
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.case-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 3px 10px;
  border-radius: 999px;
  margin-bottom: 8px;
}

.case-title {
  margin: 0 0 6px;
  font-size: 16.5px;
  line-height: 1.35;
}

.case-summary {
  margin: 0 0 16px;
  font-size: 13.5px;
  color: var(--ink-muted);
  flex: 1;
}

.case-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.case-meta {
  font-size: 12px;
  color: var(--ink-muted);
}

.case-open-btn {
  border: 0;
  background: transparent;
  color: var(--accent);
  font-family: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 0;
}

.case-open-btn:hover {
  text-decoration: underline;
}

/* 3D STL Workspace */
.stl-workspace {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 22px;
  align-items: stretch;
}

.prep-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.prep-item {
  text-align: left;
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.prep-item:hover {
  border-color: #b4cbd1;
}

.prep-item.is-active {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(15, 92, 110, 0.14);
}

.prep-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.prep-tooth {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 2px 8px;
  border-radius: 999px;
}

.prep-scanner {
  font-size: 11.5px;
  color: var(--ink-muted);
}

.prep-item-title {
  display: block;
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink);
  margin-bottom: 4px;
}

.prep-item-note {
  display: block;
  font-size: 12.5px;
  color: var(--ink-muted);
}

.stl-viewer-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.stl-toolbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.stl-active-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stl-active-info .case-badge {
  margin-bottom: 0;
}

.stl-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.mat-switch {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-tinted);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.mat-btn {
  border: 0;
  background: transparent;
  color: var(--ink-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.mat-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-icon {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 6px 11px;
  border-radius: 8px;
  cursor: pointer;
}

.btn-icon:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.stl-canvas-wrap {
  position: relative;
  height: 440px;
  background: radial-gradient(circle at 50% 40%, #242e38 0%, #151b22 100%);
  cursor: grab;
}

.stl-canvas-wrap:active {
  cursor: grabbing;
}

.stl-canvas-wrap canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.stl-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(21, 27, 34, 0.72);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  z-index: 3;
}

.stl-loading[hidden] {
  display: none;
}

.stl-hint-overlay {
  position: absolute;
  left: 14px;
  bottom: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  color: rgba(255, 255, 255, 0.82);
  background: rgba(0, 0, 0, 0.42);
  pointer-events: none;
}

.stl-meta-bar {
  padding: 12px 18px;
  font-size: 13px;
  color: var(--ink-muted);
  border-top: 1px solid var(--line);
  background: var(--bg);
}

/* Footer */
.site-footer {
  padding: 26px 0 36px;
  font-size: 13px;
  color: var(--ink-muted);
}

.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
}

.footer-copy,
.footer-note {
  margin: 0;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(20, 24, 31, 0.58);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-panel {
  width: 100%;
  max-width: 760px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}

.modal-header {
  position: sticky;
  top: 0;
  background: var(--surface);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 14px;
  border-bottom: 1px solid var(--line);
  z-index: 2;
}

.modal-title {
  margin: 4px 0 0;
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 400;
  line-height: 1.2;
}

.modal-close {
  border: 1px solid var(--line);
  background: var(--bg);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--ink);
}

.modal-body {
  padding: 20px 24px 26px;
}

.modal-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.detail-box {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}

.detail-box h4 {
  margin: 0 0 6px;
  font-size: 12px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--accent);
}

.detail-box p {
  margin: 0;
  font-size: 13.5px;
  color: var(--ink-muted);
}

@media (max-width: 960px) {
  .case-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .prep-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .nav-links {
    display: none;
  }

  .case-grid,
  .prep-list,
  .modal-detail-grid {
    grid-template-columns: 1fr;
  }

  .stl-canvas-wrap {
    height: 340px;
  }
}
