@font-face {
  font-family: "TheMetSans";
  src: url("/fonts/TheMetSans-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #F6F1EA;
  --fg: #2C2925;
  --accent-amber: #D4943A;
  --accent-sage: #6B8F71;
  --accent-steel: #5B7B95;
  --accent-clay: #C17756;
  --accent-dusk: #8B6B8B;
  --gray: #9B9590;
  --gray-light: #C4BEB6;
  --border: #E4DED5;
  --surface: #FFFDF9;
  --radius: 100px;
  --radius-card: 20px;
  --font-display: "Instrument Serif", Georgia, serif;
  --font-body: "TheMetSans", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { overflow-x: hidden; }
body {
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-body);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}

/* ── Desktop gate ──────────────────────────────── */
#desktop-gate {
  display: none;
  position: fixed; inset: 0; z-index: 1000;
  background: var(--bg);
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 2rem;
}
#desktop-gate p {
  font-family: var(--font-body);
  font-style: normal;
  font-size: 1.6rem;
  color: var(--gray);
}
@media (min-width: 600px) {
  #desktop-gate { display: flex; }
}

/* ── Decorative blobs ──────────────────────────── */
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(50px);
  pointer-events: none;
  z-index: 0;
}

/* Base blob colors (home page: warm amber/sage/dusk) */
.blob-1 {
  width: 280px; height: 280px;
  background: radial-gradient(circle, rgba(220,150,50,0.7) 0%, rgba(220,150,50,0.2) 50%, transparent 75%);
  top: 8%; right: -10%;
  animation: blobDrift1 12s ease-in-out infinite;
}
.blob-2 {
  width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(100,150,110,0.55) 0%, rgba(100,150,110,0.15) 50%, transparent 75%);
  bottom: 20%; left: -5%;
  animation: blobDrift2 14s ease-in-out infinite;
}
.blob-3 {
  width: 220px; height: 220px;
  background: radial-gradient(circle, rgba(150,110,160,0.5) 0%, rgba(150,110,160,0.12) 50%, transparent 75%);
  bottom: 5%; right: 8%;
  animation: blobDrift3 16s ease-in-out infinite;
}

#start-state .blob {
  filter: blur(62px);
}
#start-state .blob-1 {
  width: 330px; height: 330px;
  background: radial-gradient(circle, rgba(220,150,50,0.58) 0%, rgba(220,150,50,0.18) 52%, transparent 76%);
  top: 5%; right: -20%;
  animation-duration: 18s;
}
#start-state .blob-2 {
  width: 285px; height: 285px;
  background: radial-gradient(circle, rgba(100,150,110,0.44) 0%, rgba(100,150,110,0.13) 52%, transparent 76%);
  bottom: 15%; left: -18%;
  animation-duration: 20s;
}
#start-state .blob-3 {
  width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(150,110,160,0.4) 0%, rgba(150,110,160,0.11) 52%, transparent 76%);
  bottom: -3%; right: 0;
  animation-duration: 22s;
}

/* Language page: coral / sky blue / soft yellow */
#language-state .blob-1 {
  background: radial-gradient(circle, rgba(210,120,100,0.65) 0%, rgba(210,120,100,0.18) 50%, transparent 75%);
  top: 5%; right: -8%;
}
#language-state .blob-2 {
  background: radial-gradient(circle, rgba(100,160,200,0.5) 0%, rgba(100,160,200,0.12) 50%, transparent 75%);
  bottom: 25%; left: -10%;
}
#language-state .blob-3 {
  background: radial-gradient(circle, rgba(220,195,80,0.5) 0%, rgba(220,195,80,0.12) 50%, transparent 75%);
  bottom: 3%; right: 15%;
}

/* Loading page: soft blue / amber / lilac */
#loading-state .blob-1 {
  background: radial-gradient(circle, rgba(100,140,210,0.6) 0%, rgba(100,140,210,0.18) 50%, transparent 75%);
  top: 12%; left: -8%;
}
#loading-state .blob-2 {
  background: radial-gradient(circle, rgba(220,165,60,0.55) 0%, rgba(220,165,60,0.15) 50%, transparent 75%);
  bottom: 18%; right: -10%;
}
#loading-state .blob-3 {
  background: radial-gradient(circle, rgba(175,140,195,0.5) 0%, rgba(175,140,195,0.12) 50%, transparent 75%);
  bottom: 5%; left: 10%;
}

/* Blob animations — wide, organic drifts */
@keyframes blobDrift1 {
  0%   { transform: translate(0, 0) scale(1); }
  25%  { transform: translate(18px, -25px) scale(1.08); }
  50%  { transform: translate(-10px, -15px) scale(0.95); }
  75%  { transform: translate(12px, 10px) scale(1.05); }
  100% { transform: translate(0, 0) scale(1); }
}
@keyframes blobDrift2 {
  0%   { transform: translate(0, 0) scale(1); }
  25%  { transform: translate(-15px, 20px) scale(1.06); }
  50%  { transform: translate(20px, 8px) scale(0.92); }
  75%  { transform: translate(-8px, -18px) scale(1.1); }
  100% { transform: translate(0, 0) scale(1); }
}
@keyframes blobDrift3 {
  0%   { transform: translate(0, 0) scale(1); }
  25%  { transform: translate(12px, 15px) scale(0.94); }
  50%  { transform: translate(-18px, -10px) scale(1.08); }
  75%  { transform: translate(8px, -22px) scale(1.02); }
  100% { transform: translate(0, 0) scale(1); }
}

/* ── Shared back button ────────────────────────── */
.back-btn {
  position: absolute; top: 1.2rem; left: 1.2rem;
  background: none; border: none;
  font-family: var(--font-body);
  font-size: 1.4rem; color: var(--fg);
  cursor: pointer; padding: 0.4rem 0.6rem;
  opacity: 0.35; transition: opacity 0.2s;
  -webkit-appearance: none; appearance: none;
  z-index: 5; border-radius: 8px;
}
.back-btn:active { opacity: 0.7; }

/* ── Shared state label ────────────────────────── */
.state-label {
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 400;
  font-size: 2rem;
  color: var(--fg);
  margin-bottom: 1.8rem;
  animation: fadeUp 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Start state ───────────────────────────────── */
#start-state {
  display: none; position: fixed; inset: 0; z-index: 10;
  background: var(--bg);
  flex-direction: column; align-items: center; justify-content: center;
  padding: 2rem 1.5rem; text-align: center; overflow: hidden;
}
#home-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 400;
  font-size: 5.75rem;
  color: var(--fg);
  line-height: 0.84;
  letter-spacing: 0;
  margin: 0;
  max-width: 6.5ch;
  position: absolute; z-index: 1;
  top: 48%; left: 50%;
  translate: -50% -50%;
  animation: fadeUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}
#start-go-btn {
  min-width: 10rem;
  padding: 0.82rem 1.85rem;
  background: var(--fg); color: var(--surface);
  border: 1px solid rgba(44, 41, 37, 0.25);
  border-radius: var(--radius);
  font-family: var(--font-body);
  font-weight: 700; font-size: 1.8rem;
  cursor: pointer;
  transition: transform 0.18s, opacity 0.18s, box-shadow 0.18s;
  -webkit-appearance: none; appearance: none;
  letter-spacing: 0.01em;
  box-shadow: 0 7px 18px rgba(44, 41, 37, 0.18);
  position: absolute; z-index: 1;
  top: calc(48% + 11.25rem); left: 50%;
  translate: -50% 0;
  animation: fadeUp 0.8s 0.2s cubic-bezier(0.16, 1, 0.3, 1) both;
}
#start-go-btn:active {
  transform: translateY(2px) scale(0.98);
  opacity: 0.9;
  box-shadow: 0 3px 10px rgba(44, 41, 37, 0.14);
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Camera identify state ─────────────────────── */
body.camera-page {
  background: var(--bg);
  color: var(--fg);
  justify-content: flex-start;
  min-height: 100dvh;
  overflow: hidden;
  position: fixed;
  width: 100%;
}

#camera-state {
  position: fixed;
  top: var(--camera-viewport-top, 0px);
  left: 0;
  right: 0;
  z-index: 10;
  height: var(--camera-viewport-height, 100dvh);
  display: flex; flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: max(3rem, calc(env(safe-area-inset-top) + 2rem)) 1.35rem max(1.1rem, env(safe-area-inset-bottom));
  background: var(--bg);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  overflow-anchor: none;
  scroll-padding-bottom: max(2.75rem, calc(env(safe-area-inset-bottom) + 2rem));
  -webkit-overflow-scrolling: touch;
}

#camera-state::before,
#camera-state::after {
  content: "";
  flex: 1 1 0;
  min-height: 0;
}

#camera-state.accession-open {
  padding-bottom: max(3.5rem, calc(env(safe-area-inset-bottom) + 3rem));
}

#camera-state .blob-1 {
  background: radial-gradient(circle, rgba(200,110,130,0.55) 0%, rgba(200,110,130,0.16) 50%, transparent 75%);
  top: 2%; right: -8%;
}

#camera-state .blob-2 {
  background: radial-gradient(circle, rgba(120,190,160,0.45) 0%, rgba(120,190,160,0.12) 50%, transparent 75%);
  bottom: 24%; left: -12%;
}

#camera-state .blob-3 {
  background: radial-gradient(circle, rgba(210,180,80,0.42) 0%, rgba(210,180,80,0.11) 50%, transparent 75%);
  bottom: 2%; right: 8%;
}

#camera-header {
  position: relative;
  flex: 0 0 auto;
  min-height: auto;
  width: 100%;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 0.9rem;
  z-index: 1;
}

#camera-header .back-btn {
  position: fixed;
  color: var(--fg);
  top: 1.2rem;
  left: 1.2rem;
  transform: none;
}

#camera-title {
  font-family: var(--font-body);
  font-style: normal;
  font-size: 1.78rem;
  font-weight: 400;
  line-height: 1.05;
  color: var(--fg);
  text-align: center;
  padding: 0 3.1rem;
  max-width: 360px;
}

#camera-viewfinder {
  position: relative;
  flex: 0 0 auto;
  width: 100%;
  max-width: 390px;
  height: clamp(390px, 58dvh, 560px);
  min-height: 0;
  overflow: hidden;
  border-radius: 20px;
  background: var(--surface);
  border: 1.5px solid var(--border);
  box-shadow: 0 12px 44px rgba(44, 41, 37, 0.12);
  z-index: 1;
  touch-action: none;
}

#camera-state.accession-open #camera-viewfinder {
  height: 220px;
  height: clamp(180px, 30svh, 280px);
}

#camera-video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform-origin: center center;
  background: #000;
}

#camera-canvas {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
  z-index: 2;
}

#camera-viewfinder.photo-frozen #camera-canvas {
  display: block;
}

#accession-fallback {
  width: min(340px, calc(100vw - 3rem));
  display: flex; flex-direction: column;
  align-items: stretch;
  gap: 1rem;
  position: relative;
  z-index: 1;
}

#accession-fallback[hidden] {
  display: none;
}

#accession-fallback h1 {
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1.8rem;
  font-weight: 400;
  line-height: 1.12;
  text-align: center;
}

#camera-controls {
  flex: 0 0 auto;
  display: flex; flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding-top: 1.2rem;
  position: relative;
  z-index: 1;
}

#camera-shutter-btn {
  width: 74px; height: 74px;
  border-radius: 50%;
  border: 3px solid var(--fg);
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
  box-shadow: 0 8px 26px rgba(44, 41, 37, 0.16);
}

#camera-shutter-btn span {
  width: 54px; height: 54px;
  border-radius: 50%;
  background: var(--fg);
  display: block;
  transition: transform 0.15s, opacity 0.15s;
}

#camera-shutter-btn:active span {
  transform: scale(0.9);
}

#camera-shutter-btn.loading span {
  width: 34px; height: 34px;
  border: 3px solid rgba(44, 41, 37, 0.18);
  border-top-color: var(--fg);
  background: transparent;
  transform-origin: center;
  transition: opacity 0.15s;
  animation: camera-spin 0.85s linear infinite;
}

@keyframes camera-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

#accession-toggle-btn {
  margin-top: 0.45rem;
  border: 1px solid var(--fg);
  border-radius: 999px;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.82rem;
  font-weight: 400;
  padding: 0.48rem 0.72rem;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
}

.accession-form {
  width: min(320px, calc(100vw - 3rem));
  display: flex; flex-direction: column;
  gap: 0.5rem;
  scroll-margin-block: 1rem max(3.5rem, calc(env(safe-area-inset-bottom) + 3rem));
}

.accession-form[hidden] {
  display: none;
}

.accession-form label {
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 400;
  text-align: center;
}

.accession-row {
  display: flex; gap: 0.45rem;
}

.accession-row input {
  min-width: 0;
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1rem;
  padding: 0.75rem 0.85rem;
  -webkit-appearance: none; appearance: none;
}

.accession-row input:focus {
  outline: none;
  border-color: rgba(44, 41, 37, 0.55);
  box-shadow: 0 0 0 3px rgba(44, 41, 37, 0.08);
}

.accession-row button {
  border: none;
  border-radius: 12px;
  background: var(--fg);
  color: var(--surface);
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 500;
  padding: 0.75rem 0.95rem;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
}

/* ── Scan result state ─────────────────────────── */
body.scan-result-page {
  background: var(--bg);
  color: var(--fg);
  min-height: 100dvh;
}

#scan-result-state {
  position: fixed; inset: 0; z-index: 10;
  display: flex; flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  padding: max(2.5rem, env(safe-area-inset-top)) 1.4rem max(1.5rem, env(safe-area-inset-bottom));
  background: var(--bg);
  text-align: center;
}

#scan-match {
  display: flex; flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 330px;
}

#scan-match-img {
  display: block;
  width: auto;
  height: auto;
  max-width: 116px;
  max-height: 116px;
  border-radius: 8px;
  margin-bottom: 0.9rem;
}

#scan-match-title {
  font-family: var(--font-body);
  font-style: normal;
  font-weight: 400;
  font-size: 2.15rem;
  line-height: 1.08;
  color: var(--fg);
  overflow-wrap: anywhere;
}

#scan-room-context {
  color: var(--fg);
  font-family: var(--font-body);
  font-size: 1.12rem;
  font-weight: 400;
  line-height: 1.25;
}

#scan-actions {
  width: 100%;
  max-width: 330px;
  display: flex; flex-direction: column;
  gap: 0.85rem;
  margin-top: 1.75rem;
}

#scan-actions button {
  width: 100%;
  min-height: 4.25rem;
  border: none;
  border-radius: 14px;
  color: #fff;
  font-family: var(--font-body);
  font-size: 1.34rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  padding: 0.9rem 1rem;
  cursor: pointer;
  -webkit-appearance: none; appearance: none;
  overflow-wrap: anywhere;
}

#scan-artwork-choice {
  background: #B87825;
}

#scan-room-choice {
  background: #4E7454;
}

#scan-room-choice:disabled {
  background: var(--border);
  color: var(--gray);
}

#scan-result-state .back-btn {
  top: max(1rem, env(safe-area-inset-top));
  left: 1rem;
}

#camera-error {
  position: fixed;
  left: 1rem; right: 1rem;
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 20;
  display: none;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: var(--fg);
  color: var(--surface);
  text-align: center;
  font-size: 0.95rem;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.28);
}

#camera-error.visible {
  display: block;
}

/* ── Language state ────────────────────────────── */
#language-state {
  display: none; position: fixed; inset: 0; z-index: 10;
  background: var(--bg);
  flex-direction: column; align-items: center; justify-content: flex-start;
  padding: max(5rem, calc(env(safe-area-inset-top) + 4rem)) 1.4rem max(2rem, env(safe-area-inset-bottom));
  text-align: center;
  width: 100%;
  max-width: 100vw;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
#language-state::-webkit-scrollbar { display: none; }
#language-state .state-label {
  position: relative;
  z-index: 1;
  margin-bottom: 1.2rem;
}
#language-state .back-btn {
  position: fixed;
  top: 1.2rem;
  left: 1.2rem;
}
#language-grid {
  display: flex; flex-direction: column; gap: 0.5rem;
  width: min(300px, calc(100vw - 3rem));
  max-width: 300px;
  padding-bottom: 0.5rem;
  animation: fadeUp 0.5s 0.05s cubic-bezier(0.16, 1, 0.3, 1) both;
  position: relative;
  z-index: 1;
}

.lang-btn {
  display: flex; align-items: center; gap: 0.5rem;
  min-height: 3.25rem;
  padding: 0.72rem 0.95rem;
  border: 1.5px solid var(--border); border-radius: 12px;
  background: var(--surface);
  font-family: var(--font-body); color: var(--fg);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.15s;
  -webkit-appearance: none; appearance: none;
  text-align: left; width: 100%;
  min-width: 0;
}
.lang-btn:active { transform: scale(0.98); }
.lang-btn.selected {
  border-color: var(--fg);
  background: var(--fg);
  color: var(--surface);
}
.lang-native {
  font-family: "Noto Sans", var(--font-body);
  font-weight: 500;
  font-size: 1.02rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.lang-btn[data-lang="ar"] .lang-native {
  font-family: "Noto Sans Arabic", "Noto Sans", var(--font-body);
}
.lang-btn[data-lang="hi"] .lang-native {
  font-family: "Noto Sans Devanagari", "Noto Sans", var(--font-body);
}
.lang-btn[data-lang="th"] .lang-native {
  font-family: "Noto Sans Thai", "Noto Sans", var(--font-body);
}
.lang-btn[data-lang="zh-CN"] .lang-native {
  font-family: "Noto Sans SC", "Noto Sans", var(--font-body);
}
.lang-btn[data-lang="zh-TW"] .lang-native {
  font-family: "Noto Sans TC", "Noto Sans", var(--font-body);
}
.lang-btn[data-lang="ja"] .lang-native {
  font-family: "Noto Sans JP", "Noto Sans", var(--font-body);
}
.lang-btn[data-lang="ko"] .lang-native {
  font-family: "Noto Sans KR", "Noto Sans", var(--font-body);
}
.lang-english {
  font-weight: 400;
  font-size: 0.9rem;
  opacity: 0.4;
  margin-left: auto;
  min-width: 0;
  text-align: right;
  overflow-wrap: anywhere;
}
.lang-btn.selected .lang-english { opacity: 0.6; }

/* ── Loading ───────────────────────────────────── */
#loading-state {
  display: none; position: fixed; inset: 0; z-index: 10;
  background: var(--bg); text-align: center;
  flex-direction: column; align-items: center; justify-content: center;
  gap: 1.45rem;
  padding: 2rem 1.5rem;
}
.loader-dots {
  display: flex;
  gap: 0.72rem;
  align-items: center;
}
.loader-dots span {
  width: 0.82rem; height: 0.82rem; border-radius: 50%;
  background: var(--fg);
  animation: dotPulse 1.4s ease-in-out infinite;
}
.loader-dots span:nth-child(2) { animation-delay: 0.15s; }
.loader-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dotPulse {
  0%, 80%, 100% { opacity: 0.15; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}
#loading-state p {
  font-family: var(--font-body);
  color: var(--fg);
  opacity: 0.45;
  font-size: clamp(1.45rem, 5vw, 1.8rem);
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
}

/* ── Cards state ───────────────────────────────── */
#cards-state {
  display: none; position: fixed; inset: 0; z-index: 10;
  background: var(--bg);
  flex-direction: column; align-items: center; overflow: hidden;
  min-height: 100dvh;
}
#cards-header {
  padding: 1.5rem 4.25rem 0.3rem;
  text-align: center; flex-shrink: 0; width: 100%;
}
#cards-title {
  font-family: var(--font-body);
  font-style: normal; font-weight: 400;
  font-size: 1.9rem; color: var(--fg);
  line-height: 1.15;
  max-width: 100%;
  overflow-wrap: anywhere;
}
#cards-artist {
  font-family: var(--font-body);
  font-weight: 300; font-size: 1rem;
  color: var(--gray);
  margin-top: 0.25rem; letter-spacing: 0.02em;
  overflow-wrap: anywhere;
}
/* ── Card carousel ─────────────────────────────── */
#cards-container {
  flex: 1 1 auto; width: 100%;
  min-height: 0;
  display: flex; align-items: center;
  overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  padding: 0.8rem 0 max(4.6rem, calc(env(safe-area-inset-bottom) + 4rem));
}
#cards-container::-webkit-scrollbar { display: none; }

.prompt-card {
  flex: 0 0 80%; scroll-snap-align: center;
  margin: 0 2.5%; min-height: 55vh;
  position: relative; transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: pointer;
  touch-action: pan-x pan-y;
}
.prompt-card:first-child { margin-left: 10%; }
.prompt-card:last-child { margin-right: 10%; }
.prompt-card.flipped { transform: rotateY(180deg); }

.card-front, .card-back {
  position: absolute; inset: 0;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: var(--radius-card);
  padding: 2.2rem 1.2rem;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  text-align: center;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.14), 0 4px 16px rgba(0, 0, 0, 0.06);
}
.card-back { transform: rotateY(180deg); }

/* ── Card color themes (gradients) ─────────────── */
.prompt-card[data-color="amber"] .card-front { background: linear-gradient(145deg, #E8A849, #CF8A2E); }
.prompt-card[data-color="amber"] .card-back { background: linear-gradient(145deg, #C88930, #B87825); }
.prompt-card[data-color="sage"] .card-front { background: linear-gradient(145deg, #7A9E7E, #5E8563); }
.prompt-card[data-color="sage"] .card-back { background: linear-gradient(145deg, #5E8563, #4E7454); }
.prompt-card[data-color="steel"] .card-front { background: linear-gradient(145deg, #6B8DA6, #4F7590); }
.prompt-card[data-color="steel"] .card-back { background: linear-gradient(145deg, #4F7590, #3F6580); }
.prompt-card[data-color="clay"] .card-front { background: linear-gradient(145deg, #C8836A, #B06B50); }
.prompt-card[data-color="clay"] .card-back { background: linear-gradient(145deg, #B06B50, #A05A3C); }
.prompt-card[data-color="dusk"] .card-front { background: linear-gradient(145deg, #9B7EA0, #806385); }
.prompt-card[data-color="dusk"] .card-back { background: linear-gradient(145deg, #806385, #6B4F6F); }

/* ── Card content ──────────────────────────────── */
.card-prompt {
  font-family: var(--font-body);
  font-weight: 400; font-size: 1.6rem;
  color: #fff; line-height: 1.45;
  max-width: 340px; letter-spacing: 0.005em;
}
.card-back-label {
  font-family: var(--font-body);
  font-weight: 500; font-size: 0.85rem;
  text-transform: uppercase; letter-spacing: 0.14em;
  color: rgba(255, 255, 255, 0.35);
  margin-bottom: 1rem;
}
.card-insight {
  font-family: var(--font-body);
  font-weight: 300; font-size: 1.38rem;
  color: rgba(255, 255, 255, 0.88);
  line-height: 1.5; max-width: 340px;
}

/* ── Room examples on card back ────────────────── */
.card-example-list {
  display: flex; flex-direction: column; gap: 1rem;
  width: 100%; max-width: 300px;
}
.card-example-item {
  color: inherit; font-family: var(--font-body); width: 100%;
  text-align: left;
}
.card-example-heading {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 0.4rem;
}
.card-example-img {
  display: block;
  width: auto; height: auto;
  max-width: 76px; max-height: 62px;
  object-fit: contain; flex-shrink: 0;
  border: 0; border-radius: 0;
  background: transparent;
}
.card-example-img--bounded {
  width: 76px; height: 62px;
  object-fit: cover;
}
.card-example-title {
  font-weight: 700; font-size: 1.32rem;
  color: rgba(255, 255, 255, 0.94);
  line-height: 1.15;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
  min-width: 0;
}
.card-example-description {
  font-family: var(--font-body);
  font-weight: 300; font-size: 1.16rem;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.45;
}

/* ── Card controls ─────────────────────────────── */
#cards-controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: max(1.05rem, calc(env(safe-area-inset-bottom) + 0.65rem));
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 1.5rem;
  text-align: center;
  pointer-events: none;
}
.ai-disclaimer {
  font-family: var(--font-body);
  font-size: clamp(1.08rem, 3.7vw, 1.28rem);
  font-weight: 600;
  line-height: 1.2;
  color: var(--fg);
  opacity: 0.35;
  letter-spacing: 0.02em;
  pointer-events: none;
}

@media (max-height: 620px) {
  #cards-container {
    padding-bottom: max(4.15rem, calc(env(safe-area-inset-bottom) + 3.7rem));
  }
  #cards-controls {
    bottom: max(0.75rem, calc(env(safe-area-inset-bottom) + 0.4rem));
  }
  .ai-disclaimer {
    font-size: 1rem;
  }
}

@media (max-width: 340px) {
  #cards-header {
    padding-left: 3.75rem;
    padding-right: 3.75rem;
  }
  #cards-title {
    font-size: 1.65rem;
  }
}

/* ── Card back scrollable for room mode ────────── */
.card-back.card-back--room {
  justify-content: flex-start;
  padding-top: 1.8rem; padding-bottom: 1.4rem;
  overflow-y: auto; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.card-back.card-back--room::-webkit-scrollbar { display: none; }

/* ── Error state ───────────────────────────────── */
#error-msg {
  display: none; position: fixed;
  bottom: 2rem; left: 1.5rem; right: 1.5rem;
  z-index: 100; padding: 0.85rem 1.2rem;
  background: var(--accent-clay); border: none;
  border-radius: 12px; color: #fff;
  text-align: center;
  font-family: var(--font-body);
  font-size: 1.1rem; font-weight: 400;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}
