:root {
  --forest-900: #1b2e22;
  --forest-700: #2f4a37;
  --forest-500: #4a7359;
  --moss-300: #9cbb9c;
  --parchment: #f3ede0;
  --clay: #b5652f;
  --ink: #1c1a15;
  --radius: 14px;
  --shadow: 0 8px 24px rgba(27, 46, 34, 0.25);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  font-family: "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  background: var(--forest-900);
  color: var(--parchment);
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.screen {
  flex: 1;
  display: none;
  flex-direction: column;
  padding: env(safe-area-inset-top) 20px env(safe-area-inset-bottom);
  animation: fade-in .35s ease;
}
.screen.active { display: flex; }

.screen::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(1000px 500px at 10% -10%, rgba(156, 187, 156, 0.14), transparent 70%),
    radial-gradient(800px 360px at 100% 0%, rgba(181, 101, 47, 0.14), transparent 68%);
  pointer-events: none;
  z-index: -1;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Header ---------- */
.brand-header {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 16px 4px 10px;
  flex-shrink: 0;
}
.brand-logo {
  width: min(280px, 78vw);
  height: auto;
  display: block;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
}
.brand-subtitle {
  margin: 0;
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--moss-300);
  font-family: system-ui, sans-serif;
}

/* ---------- Language screen ---------- */
#screen-lang {
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 28px;
}
.intro-copy {
  max-width: 320px;
}
.intro-copy .eyebrow {
  color: var(--clay);
  letter-spacing: .12em;
  text-transform: uppercase;
  font-size: 12px;
  font-family: system-ui, sans-serif;
}
.intro-copy h1 {
  font-size: 32px;
  margin: 8px 0 6px;
  line-height: 1.15;
}
.intro-copy p {
  color: var(--moss-300);
  font-size: 15px;
  margin: 0;
}

.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
  width: 100%;
  max-width: 340px;
}
.lang-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 18px 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(243,237,224,0.15);
  background: var(--forest-700);
  color: var(--parchment);
  font-family: system-ui, sans-serif;
  font-size: 15px;
  cursor: pointer;
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.lang-btn:active { transform: scale(.96); }
.lang-btn:hover, .lang-btn:focus-visible {
  background: var(--forest-500);
  border-color: var(--moss-300);
  outline: none;
}
.lang-flag { font-size: 26px; line-height: 1; }

/* ---------- Scan screen ---------- */
#screen-scan {
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 22px;
}
.scan-frame {
  position: relative;
  width: min(280px, 78vw);
  aspect-ratio: 1;
  border-radius: 20px;
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow);
}
.scan-frame video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.scan-corners::before, .scan-corners::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 12px;
  border: 2px solid var(--clay);
  pointer-events: none;
}
.scan-hint {
  color: var(--moss-300);
  font-size: 15px;
  font-family: system-ui, sans-serif;
  max-width: 260px;
}
.scan-status {
  min-height: 20px;
  font-size: 13px;
  color: var(--clay);
  font-family: system-ui, sans-serif;
}

/* ---------- Content screen ---------- */
#screen-content {
  gap: 16px;
  padding-top: 12px;
}
.content-card {
  flex: 1;
  overflow-y: auto;
  background: var(--parchment);
  color: var(--ink);
  border-radius: var(--radius);
  padding: 22px 20px 28px;
  box-shadow: var(--shadow);
}
.content-card h2 {
  font-size: 24px;
  margin: 0 0 4px;
  color: var(--forest-900);
}
.content-card .plafo-code {
  font-family: system-ui, sans-serif;
  font-size: 12px;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--clay);
  margin-bottom: 14px;
  display: block;
}
.content-card p {
  line-height: 1.6;
  font-size: 16.5px;
  white-space: pre-line;
}
.image-viewer {
  margin-top: 12px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(27, 46, 34, 0.12);
  background: #d9d4c9;
}
.image-toolbar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 8px 10px;
  background: #ebe6da;
  border-bottom: 1px solid rgba(27, 46, 34, 0.12);
  font-family: system-ui, sans-serif;
}
.image-toolbar button {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(27, 46, 34, 0.25);
  border-radius: 8px;
  background: #fff;
  color: var(--forest-900);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.image-toolbar span {
  min-width: 52px;
  text-align: center;
  color: var(--forest-900);
  font-size: 13px;
  font-weight: 600;
}
.image-stage {
  width: 100%;
  height: min(68dvh, 760px);
  overflow: auto;
  background: #fff;
}
.image-stage img {
  width: 100%;
  max-width: none;
  height: auto;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}
.content-card .empty-state {
  color: #6b6455;
  font-family: system-ui, sans-serif;
  font-size: 15px;
}

.audio-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--forest-700);
  border-radius: 999px;
  padding: 10px 16px;
}
.audio-bar button {
  width: 44px; height: 44px;
  border-radius: 50%;
  border: none;
  background: var(--clay);
  color: var(--parchment);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}
.audio-bar span {
  font-family: system-ui, sans-serif;
  font-size: 13px;
  color: var(--moss-300);
}

/* ---------- Bottom nav (shared) ---------- */
.bottom-nav {
  display: flex;
  gap: 12px;
  padding: 14px 0 10px;
  flex-shrink: 0;
}
.nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px;
  border-radius: var(--radius);
  border: 1px solid rgba(243,237,224,0.18);
  background: transparent;
  color: var(--parchment);
  font-family: system-ui, sans-serif;
  font-size: 14px;
  cursor: pointer;
}
.nav-btn.primary {
  background: var(--forest-500);
  border-color: transparent;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
}
