:root {
  --backdrop: #E7E2D9;
  --bone: #F5F2EC;
  --bone-card: #FCFBF8;
  --bone-soft: #ECE6DC;
  --bone-hover: #E3DCD0;
  --ink: #242220;
  --body: #423F3B;
  --muted: #7C7770;
  --rule: #DDD6C9;
  --crimson: #A6434C;
  --font-serif: "Cormorant Garamond", "Baskerville", "Didot", Georgia, serif;
  --font-sans: "DM Sans", -apple-system, BlinkMacSystemFont, "Helvetica Neue", sans-serif;
  --font-mono: "IBM Plex Mono", "SF Mono", ui-monospace, monospace;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--backdrop);
  color: var(--ink);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
}

.viewport-backdrop {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

/* Crisp Mobile Frame */
.app-shell {
  width: 100%;
  max-width: 402px;
  height: min(832px, calc(100vh - 36px));
  min-height: 660px;
  background: var(--bone);
  border: 1px solid rgba(36, 34, 32, 0.08);
  border-radius: 28px;
  box-shadow: 0 30px 80px rgba(36, 34, 32, 0.14), 0 2px 10px rgba(36, 34, 32, 0.05);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Vector Icon Sizes */
.ico {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}
.ico-sm {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

/* Screens */
.screen {
  display: none;
  flex-direction: column;
  height: 100%;
  padding: 18px 20px 22px;
  gap: 14px;
  position: relative;
}

.screen.active {
  display: flex;
  animation: fadeIn 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

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

/* Refined Top Navigation Bar */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 38px;
  flex-shrink: 0;
}

.brand-mark,
.step-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--crimson);
}

.status-pill-light,
.temp-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bone-soft);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.04em;
  color: var(--body);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  flex-shrink: 0;
}

.live-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--crimson);
}

/* Refined Mobile Icon & Nav Buttons */
.nav-icon-btn {
  appearance: none;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: none;
  background: var(--bone-soft);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 150ms ease, transform 120ms ease;
}

.nav-icon-btn:hover {
  background: var(--bone-hover);
}
.nav-icon-btn:active {
  transform: scale(0.94);
}

.nav-pill-btn {
  appearance: none;
  height: 34px;
  padding: 0 12px 0 8px;
  border-radius: 999px;
  border: none;
  background: var(--bone-soft);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  transition: background-color 150ms ease, transform 120ms ease;
}

.nav-pill-btn:hover {
  background: var(--bone-hover);
}
.nav-pill-btn:active {
  transform: scale(0.96);
}

/* ======================================
   SCREEN 1: ENTER
====================================== */
.enter-hero {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 26px;
}

.ambient-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 0.94;
  border-radius: 16px;
  background: #202325;
  overflow: hidden;
  box-shadow: 0 14px 36px rgba(36, 34, 32, 0.12);
}

#ambientCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.ambient-caption {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 12px;
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  color: rgba(245, 242, 236, 0.85);
}

.enter-copy {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 2px;
}

.serif-hero {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 400;
  font-size: 46px;
  line-height: 1.04;
  letter-spacing: -0.01em;
  color: var(--ink);
}

.serif-hero em {
  font-style: italic;
}

.quiet-sub {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
}

/* ======================================
   SCREEN 2: COMPOSE
====================================== */
.compose-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 12px;
}

.stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.12;
  border-radius: 16px;
  background: #202325;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 12px 32px rgba(36, 34, 32, 0.10);
}

#thermalCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}

#thermalCanvas.dragging {
  cursor: grabbing;
}

/* Frosted Glass Canvas Pills */
.glass-pill {
  position: absolute;
  top: 12px;
  left: 12px;
  appearance: none;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(22, 22, 20, 0.48);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(245, 242, 236, 0.85);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 160ms ease, transform 120ms ease;
}

.glass-pill.is-on {
  background: rgba(245, 242, 236, 0.90);
  color: var(--ink);
  border-color: transparent;
}

.glass-pill:active {
  transform: scale(0.95);
}

.glass-status {
  position: absolute;
  top: 12px;
  right: 12px;
  height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  background: rgba(22, 22, 20, 0.48);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: rgba(245, 242, 236, 0.86);
  font-family: var(--font-mono);
  font-size: 10.5px;
  letter-spacing: 0.06em;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  pointer-events: none;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(245, 242, 236, 0.5);
  transition: background-color 200ms ease;
}

.glass-status.active .pulse-dot {
  background: #F0B67F;
  box-shadow: 0 0 8px #F0B67F;
}

/* Kinetic Replay Banner inside Canvas */
.replay-banner {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 9px 14px;
  border-radius: 12px;
  background: rgba(245, 242, 236, 0.93);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--ink);
  font-size: 12.5px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  pointer-events: none;
}

.replay-banner[hidden] {
  display: none;
}

.replay-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--crimson);
  flex-shrink: 0;
}

.gesture-cue {
  text-align: center;
  font-size: 12.5px;
  color: var(--muted);
  min-height: 18px;
}

.bottom-row {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.flex-1 {
  flex: 1;
}

/* ======================================
   SCREEN 3: FEEL
====================================== */
.feel-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 18px;
}

.feel-stage-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1.05;
  border-radius: 16px;
  background: #202325;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 12px 32px rgba(36, 34, 32, 0.10);
}

#feelCanvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: crosshair;
}

.develop-bar-track {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: rgba(245, 242, 236, 0.16);
  transition: opacity 400ms ease;
}

.develop-bar-fill {
  height: 100%;
  width: 0%;
  background: #E2A25D;
}

.feel-crosshair {
  position: absolute;
  pointer-events: none;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.feel-crosshair[hidden] {
  display: none;
}

.crosshair-ring {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1.75px solid rgba(255, 255, 255, 0.94);
  background: rgba(255, 255, 255, 0.16);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.crosshair-tag {
  white-space: nowrap;
  padding: 4px 9px;
  border-radius: 999px;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: #F5F2EC;
  background: rgba(22, 22, 20, 0.80);
  backdrop-filter: blur(8px);
}

.feel-readout-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 2px;
}

.feel-temp-big {
  font-family: var(--font-serif);
  font-size: 32px;
  line-height: 1.1;
  color: var(--ink);
}

.feel-zone-sub {
  font-size: 13px;
  color: var(--muted);
}

/* ======================================
   SCREEN 4: PRINT & TODAY'S WALL
====================================== */
/* iOS-style Segmented Control */
.seg-control {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 999px;
  background: var(--bone-soft);
  width: 214px;
}

.seg-thumb {
  position: absolute;
  top: 3px;
  left: 3px;
  width: calc(50% - 3px);
  height: calc(100% - 6px);
  border-radius: 999px;
  background: var(--bone-card);
  box-shadow: 0 2px 6px rgba(36, 34, 32, 0.10);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.seg-control.on-wall .seg-thumb {
  transform: translateX(100%);
}

.seg-btn {
  position: relative;
  z-index: 1;
  appearance: none;
  border: none;
  background: transparent;
  padding: 6px 8px;
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color 180ms ease;
}

.seg-btn.active {
  color: var(--ink);
}

.print-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 12px;
  overflow: hidden;
}

.print-view[hidden],
.wall-view[hidden] {
  display: none;
}

.print-stage-scroll {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 2px 1px;
}

/* Refined Collectible Fine-Art Archival Print Card */
.edition-card {
  background: var(--bone-card);
  border-radius: 16px;
  border: 1px solid rgba(36, 34, 32, 0.08);
  padding: 16px 16px 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 16px 40px rgba(36, 34, 32, 0.08), 0 1px 3px rgba(36, 34, 32, 0.04);
}

.edition-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.edition-title-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.edition-brand {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.16em;
  color: var(--crimson);
}

.edition-sub {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.edition-badge {
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--bone);
  border: 1px solid var(--rule);
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.edition-mat {
  padding: 6px;
  background: #F4EFE6;
  border: 1px solid rgba(36, 34, 32, 0.06);
  border-radius: 10px;
}

.edition-plate {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  background: #202325;
  overflow: hidden;
}

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

.edition-footer {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.edition-quote {
  font-family: var(--font-serif);
  font-style: italic;
  font-size: 19px;
  line-height: 1.2;
  color: var(--ink);
}

.edition-metrics {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--bone);
}

.metric-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.metric-k {
  font-family: var(--font-mono);
  font-size: 8.5px;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.metric-v {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.metric-crimson {
  color: var(--crimson);
}

.metric-sep {
  width: 1px;
  height: 22px;
  background: var(--rule);
}

.spectrum-hairline {
  height: 4px;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #1E2836 0%, #2E6464 38%, #C98245 72%, #C54E46 100%);
}

/* Native Mobile Setting Row + iOS Toggle Switch */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 11px 14px;
  border-radius: 14px;
  background: var(--bone-card);
  border: 1px solid rgba(36, 34, 32, 0.07);
}

.setting-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink);
}

.setting-hint {
  font-size: 11.5px;
  color: var(--muted);
}

.ios-switch {
  appearance: none;
  width: 46px;
  height: 27px;
  border-radius: 999px;
  border: none;
  background: #D5CEC2;
  padding: 2px;
  cursor: pointer;
  position: relative;
  transition: background-color 200ms ease;
  flex-shrink: 0;
}

.ios-switch[aria-checked="true"] {
  background: var(--crimson);
}

.ios-switch-knob {
  display: block;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.18);
  transition: transform 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.ios-switch[aria-checked="true"] .ios-switch-knob {
  transform: translateX(19px);
}

.action-pair {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* Today's Wall */
.wall-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: hidden;
}

.wall-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.wall-head-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.serif-sub {
  font-family: var(--font-serif);
  font-size: 24px;
  line-height: 1.1;
  color: var(--ink);
}

.wall-hint {
  font-size: 12px;
  color: var(--muted);
}

.wall-grid {
  flex: 1;
  overflow-y: auto;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding-bottom: 10px;
  align-content: start;
}

.wall-tile {
  appearance: none;
  text-align: left;
  background: var(--bone-card);
  border: 1px solid rgba(36, 34, 32, 0.08);
  border-radius: 14px;
  padding: 8px 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(36, 34, 32, 0.05);
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.wall-tile:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(36, 34, 32, 0.09);
}

.wall-tile.is-yours {
  border-color: rgba(166, 67, 76, 0.45);
}

.wall-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 9px;
  object-fit: cover;
  background: #202325;
}

.wall-tile-meta {
  display: flex;
  justify-content: space-between;
  padding: 0 2px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  color: var(--muted);
}

.wall-tile.is-yours .wall-tile-meta span:first-child {
  color: var(--crimson);
  font-weight: 500;
}

.wall-tile-cta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 2px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--ink);
}

/* Core Tactile Buttons */
.bottom-cta {
  flex-shrink: 0;
}

.btn-primary,
.btn-secondary,
.btn-soft-icon {
  appearance: none;
  border-radius: 14px;
  font-family: var(--font-sans);
  font-size: 14.5px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: background-color 150ms ease, transform 120ms ease;
}

.btn-primary {
  height: 48px;
  padding: 0 20px;
  border: none;
  background: var(--ink);
  color: var(--bone);
}

.btn-primary:hover {
  background: #383531;
}
.btn-primary:active {
  transform: scale(0.98);
}

.btn-secondary {
  height: 48px;
  padding: 0 18px;
  border: 1px solid var(--rule);
  background: var(--bone-card);
  color: var(--ink);
}

.btn-secondary:hover {
  background: var(--bone-soft);
}
.btn-secondary:active {
  transform: scale(0.97);
}

.btn-soft-icon {
  width: 48px;
  height: 48px;
  border: 1px solid var(--rule);
  background: var(--bone-card);
  color: var(--ink);
}

.btn-soft-icon:hover {
  background: var(--bone-soft);
}
.btn-soft-icon:active {
  transform: scale(0.95);
}

.btn-full {
  width: 100%;
}

/* Mobile Native-Style Share Sheet */
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(24, 22, 20, 0.42);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-end;
  z-index: 50;
}

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

.share-sheet {
  width: 100%;
  background: var(--bone);
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  padding: 10px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 -16px 40px rgba(0, 0, 0, 0.18);
  animation: slideUp 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.sheet-grabber {
  width: 38px;
  height: 4px;
  border-radius: 999px;
  background: #CFC7BA;
  margin: 0 auto 2px;
}

.sheet-preview-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--rule);
}

.sheet-thumb {
  width: 48px;
  height: 48px;
  border-radius: 10px;
  object-fit: cover;
  background: #202325;
}

.sheet-preview-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sheet-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
}

.sheet-sub {
  font-size: 11.5px;
  color: var(--muted);
}

.sheet-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sheet-row-btn {
  appearance: none;
  width: 100%;
  padding: 12px 14px;
  border-radius: 13px;
  border: 1px solid rgba(36, 34, 32, 0.06);
  background: var(--bone-card);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: background-color 140ms ease;
}

.sheet-row-btn:hover {
  background: var(--bone-soft);
}

.sheet-row-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--bone-soft);
  color: var(--ink);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Floating Toast */
.toast {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  padding: 9px 16px;
  border-radius: 999px;
  background: var(--ink);
  color: var(--bone);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.22);
  z-index: 60;
}

.toast[hidden] {
  display: none;
}

/* Mobile Full-Bleed */
@media (max-width: 480px) {
  .viewport-backdrop {
    padding: 0;
    background: var(--bone);
  }
  .app-shell {
    max-width: 100%;
    height: 100dvh;
    min-height: 100dvh;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
  .serif-hero {
    font-size: 40px;
  }
}
