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

:root {
  --bg: #f4f0e8;
  --bg-panel: #fbf8f2;
  --bg-ink: #12202b;
  --bg-ink-soft: #1d3140;
  --text: #10202c;
  --text-muted: #5b6f7f;
  --text-on-dark: #f6f3ed;
  --border: rgba(16, 32, 44, 0.12);
  --accent: #bf6c32;
  --accent-soft: rgba(191, 108, 50, 0.14);
  --shadow-sm: 0 12px 30px rgba(14, 22, 31, 0.06);
  --shadow-lg: 0 26px 60px rgba(14, 22, 31, 0.14);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --font-sans: "Avenir Next", "Segoe UI", sans-serif;
  --font-serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", Georgia, serif;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(191, 108, 50, 0.12), transparent 26%),
    linear-gradient(180deg, #f8f4ee 0%, var(--bg) 100%);
  color: var(--text);
  font-family: var(--font-sans);
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  min-height: 100vh;
}

.eyebrow {
  letter-spacing: 0.16em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

.home-screen {
  min-height: 100vh;
  padding: 48px 28px 32px;
}

.home-screen__inner {
  max-width: 1320px;
  margin: 0 auto;
}

.hero-block {
  max-width: 760px;
  margin-bottom: 36px;
}

.hero-block h1 {
  margin-top: 16px;
  font-family: var(--font-serif);
  font-size: clamp(2.5rem, 4vw, 4.7rem);
  line-height: 0.96;
  letter-spacing: -0.04em;
}

.hero-copy {
  max-width: 620px;
  margin-top: 16px;
  font-size: 1.05rem;
  line-height: 1.65;
  color: var(--text-muted);
}

.home-notice {
  max-width: 760px;
  margin-bottom: 24px;
  padding: 16px 18px;
  border: 1px solid rgba(18, 32, 43, 0.12);
  border-radius: 18px;
  background: rgba(251, 248, 242, 0.92);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.home-notice[data-tone="error"] {
  border-color: rgba(185, 28, 28, 0.2);
  background: rgba(254, 242, 242, 0.96);
  color: #7f1d1d;
}

.home-search-panel {
  display: grid;
  grid-template-columns: minmax(0, 540px) auto;
  gap: 14px;
  align-items: end;
  margin-bottom: 30px;
}

.home-search-button {
  min-height: 54px;
  padding: 0 20px;
  border: 1px solid var(--bg-ink);
  border-radius: 18px;
  background: var(--bg-ink);
  color: var(--text-on-dark);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.home-search-button:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 34px rgba(14, 22, 31, 0.14);
  background: var(--bg-ink-soft);
}

.section-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 18px;
}

.section-card {
  position: relative;
  min-height: 260px;
  grid-column: span 4;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 22px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius-lg);
  background-color: var(--bg-ink);
  background-position: center;
  background-size: cover;
  color: var(--text-on-dark);
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  text-align: left;
}

.section-card::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  border: 1px solid rgba(255, 255, 255, 0.1);
  pointer-events: none;
}

.section-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 34px 70px rgba(14, 22, 31, 0.18);
}

.section-card:nth-child(1),
.section-card:nth-child(2) {
  min-height: 320px;
}

.section-card:nth-child(1) {
  grid-column: span 7;
}

.section-card:nth-child(2) {
  grid-column: span 5;
}

.section-card__meta,
.section-card__footer {
  position: relative;
  z-index: 1;
}

.section-card__label {
  max-width: 12ch;
  font-family: var(--font-serif);
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 0.98;
}

.section-card__summary {
  max-width: 30ch;
  margin-top: 12px;
  font-size: 0.98rem;
  line-height: 1.5;
  color: rgba(246, 243, 237, 0.82);
}

.section-card__footer {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(246, 243, 237, 0.86);
}

.section-card--head {
  background-color: #2b3135;
}

.section-card--shoulders {
  background-color: #243746;
}

.section-card--spine {
  background-color: #162833;
}

.section-card--hips {
  background-color: #26352b;
}

.section-card--knees {
  background-color: #372c23;
}

.section-card--ankle {
  background-color: #20373a;
}

.section-card--other {
  background-color: #3a2f39;
}

.home-footer {
  margin-top: 22px;
  padding-top: 12px;
  color: var(--text-muted);
}

.home-footer a {
  text-decoration: none;
}

.browser-screen {
  min-height: 100vh;
  padding: 18px 20px 24px;
}

.browser-header {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 20px;
  align-items: start;
  padding: 12px 8px 18px;
}

.browser-header__title h2 {
  margin-top: 6px;
  font-family: var(--font-serif);
  font-size: clamp(2rem, 3vw, 3.2rem);
  line-height: 0.98;
}

.browser-header__title p:last-child {
  margin-top: 10px;
  color: var(--text-muted);
}

.back-button,
.admin-link,
.section-tab,
.condition-option,
.image-card,
.filmstrip__item,
.overlay-close,
.nav-arrow {
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, color 0.16s ease;
}

.back-button,
.admin-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgba(251, 248, 242, 0.75);
  color: var(--text);
  text-decoration: none;
}

.back-button:hover,
.admin-link:hover {
  border-color: rgba(191, 108, 50, 0.55);
  background: #fff8f1;
  transform: translateY(-1px);
}

.section-tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  padding: 0 8px;
}

.section-tab {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.section-tab.is-active,
.section-tab:hover {
  background: var(--bg-ink);
  border-color: var(--bg-ink);
  color: var(--text-on-dark);
}

.browser-toolbar {
  padding: 18px 8px 22px;
}

.search-field {
  display: grid;
  gap: 10px;
  max-width: 540px;
}

.search-combobox {
  position: relative;
}

.search-field span {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.search-input {
  min-height: 54px;
  padding: 0 18px;
  border: 1px solid rgba(18, 32, 43, 0.16);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--text);
  outline: none;
  box-shadow: var(--shadow-sm);
}

.search-input:focus {
  border-color: rgba(191, 108, 50, 0.55);
  box-shadow: 0 0 0 4px rgba(191, 108, 50, 0.12);
}

.typeahead-panel {
  position: absolute;
  top: calc(100% + 10px);
  left: 0;
  right: 0;
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid rgba(18, 32, 43, 0.08);
  border-radius: 20px;
  background: rgba(251, 248, 242, 0.98);
  box-shadow: 0 28px 55px rgba(14, 22, 31, 0.14);
  backdrop-filter: blur(18px);
  z-index: 20;
}

.typeahead-option {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 16px;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.typeahead-option:hover,
.typeahead-option.is-active {
  border-color: rgba(191, 108, 50, 0.18);
  background: rgba(191, 108, 50, 0.08);
}

.typeahead-option__thumb {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  object-fit: cover;
  background: rgba(18, 32, 43, 0.08);
}

.typeahead-option__thumb--placeholder {
  display: block;
}

.typeahead-option__copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.typeahead-option__name {
  font-weight: 700;
}

.typeahead-option__meta {
  color: var(--text-muted);
  font-size: 0.82rem;
  line-height: 1.35;
}

.typeahead-empty {
  padding: 12px 14px;
  border-radius: 16px;
  color: var(--text-muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.browser-layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  gap: 18px;
  align-items: start;
}

.condition-panel,
.image-panel {
  background: rgba(251, 248, 242, 0.82);
  border: 1px solid rgba(18, 32, 43, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(10px);
}

.condition-panel {
  padding: 18px;
  position: sticky;
  top: 16px;
}

.image-panel {
  padding: 18px;
}

.panel-header,
.image-panel__header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 18px;
}

.panel-kicker {
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 700;
}

.panel-header h3,
.image-panel__header h3 {
  margin-top: 5px;
  font-size: 1.15rem;
}

.panel-meta {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.condition-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 2px;
}

.condition-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.condition-option:hover {
  background: rgba(18, 32, 43, 0.05);
}

.condition-option.is-active {
  background: var(--bg-ink);
  border-color: var(--bg-ink);
  color: var(--text-on-dark);
}

.condition-option__thumb {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border-radius: 12px;
  background: rgba(18, 32, 43, 0.1);
}

.condition-option__thumb--placeholder {
  display: block;
}

.condition-option__copy {
  min-width: 0;
  display: grid;
  gap: 3px;
}

.condition-option__name {
  min-width: 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.condition-option__section {
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: inherit;
  opacity: 0.72;
}

.condition-option__count {
  font-size: 0.82rem;
  color: inherit;
  opacity: 0.72;
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.image-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(18, 32, 43, 0.08);
  border-radius: 22px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  text-align: left;
}

.image-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 40px rgba(14, 22, 31, 0.12);
}

.image-card__thumb {
  width: 100%;
  aspect-ratio: 4 / 3.15;
  object-fit: cover;
  display: block;
  background: #dbe4ea;
}

.image-card__section {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(18, 32, 43, 0.78);
  color: var(--text-on-dark);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.image-card__body {
  padding: 14px 14px 16px;
}

.image-card__body h4 {
  font-size: 0.98rem;
  line-height: 1.3;
}

.image-card__body p {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.empty-state {
  padding: 44px 18px;
  border: 1px dashed rgba(18, 32, 43, 0.16);
  border-radius: 20px;
  color: var(--text-muted);
}

.empty-state h4 {
  color: var(--text);
  margin-bottom: 8px;
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 16px;
  padding:
    max(16px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(16px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  background: rgba(11, 18, 24, 0.97);
  color: var(--text-on-dark);
  z-index: 1000;
}

.overlay.active {
  display: grid;
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  min-width: 0;
  padding: 8px 12px 0;
  background: linear-gradient(180deg, rgba(11, 18, 24, 0.94), rgba(11, 18, 24, 0.25));
  z-index: 2;
}

.overlay-meta {
  display: flex;
  gap: 12px;
  align-items: baseline;
  flex-wrap: wrap;
}

.overlay-title {
  font-size: 1.15rem;
  font-weight: 700;
}

.overlay-view-label {
  color: rgba(246, 243, 237, 0.74);
}

.overlay-stage {
  position: relative;
  min-height: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.overlay-close,
.nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-on-dark);
  cursor: pointer;
}

.overlay-close {
  width: 44px;
  height: 44px;
  border-radius: 999px;
}

.overlay-close:hover,
.nav-arrow:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.28);
}

.image-container {
  position: relative;
  width: min(100%, calc(100vw - 140px));
  height: 100%;
  max-width: 1320px;
  min-height: 0;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-container img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  margin: 0 auto;
  object-fit: contain;
  border-radius: 12px;
}

.annotation-canvas {
  position: absolute;
  top: 0;
  left: 0;
  cursor: crosshair;
  touch-action: none;
}

.annotation-hint {
  position: absolute;
  bottom: -34px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  color: rgba(246, 243, 237, 0.64);
  font-size: 0.74rem;
}

.annotation-hint.hidden {
  opacity: 0;
}

.nav-arrow {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 50px;
  height: 50px;
  border-radius: 999px;
  font-size: 1.5rem;
  z-index: 2;
}

.nav-arrow.prev {
  left: 18px;
}

.nav-arrow.next {
  right: 18px;
}

.filmstrip {
  display: flex;
  gap: 10px;
  justify-content: center;
  padding: 0 56px;
  overflow-x: auto;
  overflow-y: hidden;
}

.filmstrip__item {
  min-width: 118px;
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.06);
  color: rgba(246, 243, 237, 0.8);
  cursor: pointer;
}

.filmstrip__item img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 10px;
}

.filmstrip__item span {
  font-size: 0.76rem;
  line-height: 1.3;
  text-align: left;
}

.filmstrip__item.is-active {
  border-color: rgba(191, 108, 50, 0.78);
  background: rgba(191, 108, 50, 0.16);
}

@media (max-width: 1120px) {
  .home-search-panel {
    grid-template-columns: 1fr;
  }

  .section-card,
  .section-card:nth-child(1),
  .section-card:nth-child(2) {
    grid-column: span 6;
    min-height: 280px;
  }

  .browser-layout {
    grid-template-columns: 1fr;
  }

  .condition-panel {
    position: static;
  }

  .condition-list {
    max-height: none;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  }
}

@media (max-width: 720px) {
  .home-screen {
    padding: 28px 16px 24px;
  }

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

  .section-card,
  .section-card:nth-child(1),
  .section-card:nth-child(2) {
    grid-column: auto;
    min-height: 232px;
  }

  .browser-screen {
    padding: 12px 12px 18px;
  }

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

  .typeahead-panel {
    left: -2px;
    right: -2px;
  }

  .browser-header__title h2 {
    font-size: 2.2rem;
  }

  .condition-list {
    grid-template-columns: 1fr;
  }

  .image-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }

  .typeahead-option {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 10px;
    padding: 9px 10px;
  }

  .typeahead-option__thumb {
    width: 44px;
    height: 44px;
  }

  .image-card__body h4,
  .image-card__body p {
    font-size: 0.86rem;
  }

  .nav-arrow {
    width: 42px;
    height: 42px;
  }

  .nav-arrow.prev {
    left: 12px;
  }

  .nav-arrow.next {
    right: 12px;
  }

  .image-container {
    width: min(100%, calc(100vw - 34px));
  }

  .image-container img {
    max-height: 100%;
  }

  .overlay-header {
    padding: 4px 2px 0;
  }

  .filmstrip {
    justify-content: flex-start;
    padding: 0 14px;
  }

  .filmstrip__item {
    min-width: 102px;
  }
}

@media (max-width: 900px) and (orientation: landscape), (max-height: 520px) {
  .overlay {
    gap: 10px;
    padding:
      max(10px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(10px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .overlay-header {
    padding-top: 0;
  }

  .overlay-title {
    font-size: 1rem;
  }

  .overlay-view-label {
    font-size: 0.86rem;
  }

  .image-container {
    width: min(100%, calc(100vw - 112px));
  }

  .filmstrip {
    padding: 0 48px;
    gap: 8px;
  }

  .filmstrip__item {
    min-width: 88px;
    gap: 4px;
    padding: 6px;
  }

  .filmstrip__item span {
    font-size: 0.68rem;
  }
}
