:root {
  --emerald: #1a8f6a;
  --emerald-bright: #2ecc96;
  --emerald-deep: #061410;
  --emerald-mid: #0c2219;
  --emerald-card: #0f2a1f;
  --emerald-glow: rgba(26, 143, 106, 0.22);
  --emerald-border: rgba(46, 204, 150, 0.22);
  --gold: #d4af6a;
  --gold-light: #f0dfa0;
  --gold-pale: #e8d5a3;
  --gold-dim: rgba(212, 175, 106, 0.45);
  --gold-soft: rgba(212, 175, 106, 0.12);
  --text: #f2ece0;
  --text-muted: rgba(242, 236, 224, 0.5);
  --radius: 2px;
  --radius-lg: 4px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: "Outfit", system-ui, sans-serif;
  font-weight: 300;
  color: var(--text);
  background: var(--emerald-deep);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Film grain overlay */
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  opacity: 0.035;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* Ambient */
.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  animation: drift 22s ease-in-out infinite alternate;
}

.orb--emerald {
  width: min(60vw, 380px);
  height: min(60vw, 380px);
  background: var(--emerald);
  top: -15%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0.18;
}

.orb--gold {
  width: min(50vw, 300px);
  height: min(50vw, 300px);
  background: var(--gold);
  bottom: 5%;
  right: -15%;
  opacity: 0.1;
  animation-delay: -8s;
}

.orb--emerald-soft {
  width: min(40vw, 240px);
  height: min(40vw, 240px);
  background: var(--emerald-bright);
  bottom: 30%;
  left: -12%;
  opacity: 0.12;
  animation-delay: -14s;
}

@keyframes drift {
  from { transform: translate(0, 0) scale(1); }
  to   { transform: translate(16px, -12px) scale(1.05); }
}

.orb--emerald {
  animation-name: driftCenter;
}

@keyframes driftCenter {
  from { transform: translateX(-50%) scale(1); }
  to   { transform: translateX(calc(-50% + 16px)) scale(1.05); }
}

/* Layout */
.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding:
    calc(28px + var(--safe-top))
    calc(24px + var(--safe-right))
    calc(28px + var(--safe-bottom))
    calc(24px + var(--safe-left));
  max-width: 720px;
  margin: 0 auto;
}

/* Header */
.header {
  text-align: center;
  margin-bottom: 36px;
}

.header__ornament {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 20px;
}

.header__ornament span {
  display: block;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold-dim), transparent);
}

.header__ornament span:nth-child(1),
.header__ornament span:nth-child(3) {
  width: 40px;
}

.header__ornament span:nth-child(2) {
  width: 6px;
  height: 6px;
  background: var(--gold);
  transform: rotate(45deg);
  flex-shrink: 0;
}

.header__title {
  margin: 0;
  font-family: "Cormorant Garamond", Georgia, serif;
  font-size: clamp(2.1rem, 6.5vw, 3rem);
  font-weight: 300;
  line-height: 1.08;
  letter-spacing: 0.02em;
  color: var(--text);
}

.header__title em {
  display: block;
  margin-top: 4px;
  font-style: italic;
  font-weight: 400;
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 60%, var(--emerald-bright) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.header__agent {
  margin: 18px 0 0;
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

/* Navigation */
.nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  margin-bottom: 28px;
  border: 1px solid var(--emerald-border);
  background: rgba(6, 20, 16, 0.6);
}

.nav__btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 18px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.4s, color 0.4s;
  font-family: inherit;
  position: relative;
}

.nav__btn + .nav__btn {
  border-left: 1px solid var(--emerald-border);
}

.nav__btn--active {
  background: linear-gradient(180deg, rgba(26, 143, 106, 0.15) 0%, rgba(6, 20, 16, 0.4) 100%);
  color: var(--text);
}

.nav__btn--active::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 20%;
  right: 20%;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.nav__num {
  font-family: "Cormorant Garamond", serif;
  font-size: 1.6rem;
  font-weight: 600;
  line-height: 1;
  color: var(--gold);
  letter-spacing: 0.05em;
}

.nav__btn:not(.nav__btn--active) .nav__num {
  color: var(--gold-dim);
}

.nav__label {
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* Panels */
.main {
  flex: 1;
}

.panel {
  animation: fadeUp 0.5s ease;
}

.panel--active {
  display: block;
}

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

.panel__inner {
  position: relative;
  padding: 36px 28px;
  background: var(--emerald-card);
  border: 1px solid var(--emerald-border);
  box-shadow:
    0 32px 80px rgba(0, 0, 0, 0.45),
    inset 0 1px 0 rgba(212, 175, 106, 0.08);
}

.panel__frame {
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(212, 175, 106, 0.1);
  pointer-events: none;
}

.panel__badge {
  display: inline-block;
  margin-bottom: 20px;
  padding: 5px 16px;
  font-size: 0.58rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--emerald-bright);
  border: 1px solid var(--emerald-border);
  background: rgba(26, 143, 106, 0.08);
}

.panel__title {
  margin: 0 0 12px;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.85rem, 5vw, 2.4rem);
  font-weight: 400;
  line-height: 1.15;
  color: var(--gold-light);
  letter-spacing: 0.02em;
}

.panel__lead {
  margin: 0 0 32px;
  font-size: 0.9rem;
  font-weight: 300;
  line-height: 1.65;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Password gate */
.gate__label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gold);
}

.gate__field {
  position: relative;
  margin-bottom: 10px;
}

.gate__input {
  width: 100%;
  padding: 18px 52px 18px 20px;
  font-family: "Outfit", monospace, sans-serif;
  font-size: 0.95rem;
  font-weight: 300;
  color: var(--text);
  background: var(--emerald-deep);
  border: 1px solid var(--emerald-border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
  -webkit-appearance: none;
  appearance: none;
  letter-spacing: 0.06em;
}

.gate__input::placeholder {
  color: rgba(242, 236, 224, 0.2);
}

.gate__input:focus {
  border-color: var(--gold-dim);
  box-shadow: 0 0 0 1px var(--gold-soft), 0 0 24px var(--emerald-glow);
}

.gate__input--error {
  border-color: var(--gold);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}

.gate__toggle {
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--gold-dim);
  cursor: pointer;
  transition: color 0.2s;
}

.gate__toggle:hover,
.gate__toggle:focus-visible {
  color: var(--gold);
}

.gate__error {
  margin: 0 0 18px;
  padding: 14px 16px;
  font-size: 0.85rem;
  font-weight: 300;
  letter-spacing: 0.02em;
  color: var(--gold-pale);
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 106, 0.25);
  border-radius: var(--radius);
}

.gate__error[hidden] {
  display: none;
}

.gate__submit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 18px 28px;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--emerald-deep);
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow 0.3s, transform 0.2s, opacity 0.2s;
  box-shadow: 0 4px 24px rgba(212, 175, 106, 0.2);
}

.gate__submit:hover {
  box-shadow: 0 8px 36px rgba(212, 175, 106, 0.35);
  transform: translateY(-1px);
}

.gate__submit:active {
  transform: translateY(0);
}

.gate__submit:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Revealed hint */
.reveal {
  margin-top: 32px;
  padding-top: 32px;
  border-top: 1px solid rgba(212, 175, 106, 0.15);
  animation: revealIn 0.7s ease;
}

.reveal[hidden] {
  display: none;
}

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

.reveal__seal {
  display: inline-flex;
  margin-bottom: 24px;
  padding: 7px 20px;
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  color: var(--gold);
  border: 1px solid var(--gold);
  opacity: 0.85;
}

.reveal__text {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.55rem, 4.5vw, 2.1rem);
  font-weight: 300;
  font-style: italic;
  line-height: 1.5;
  color: var(--text);
  letter-spacing: 0.01em;
}

/* Hint 4 — voice module */
.ios-guide {
  margin-bottom: 24px;
  padding: 18px 20px;
  border: 1px solid var(--emerald-border);
  background: rgba(26, 143, 106, 0.08);
}

.ios-guide[hidden] {
  display: none;
}

.ios-guide__title {
  margin: 0 0 12px;
  font-size: 0.62rem;
  font-weight: 500;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--emerald-bright);
}

.ios-guide__steps {
  margin: 0 0 12px;
  padding-left: 1.2rem;
  font-size: 0.88rem;
  font-weight: 300;
  line-height: 1.65;
  color: var(--text);
}

.ios-guide__steps li + li {
  margin-top: 6px;
}

.ios-guide__mic {
  color: var(--gold);
}

.ios-guide__note {
  margin: 0;
  font-size: 0.75rem;
  font-weight: 300;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.voice__dictate {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 18px 24px;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--emerald-deep);
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow 0.3s, transform 0.2s;
  box-shadow: 0 4px 24px rgba(212, 175, 106, 0.2);
}

.voice__dictate:hover {
  box-shadow: 0 8px 36px rgba(212, 175, 106, 0.35);
  transform: translateY(-1px);
}

.voice__record--secondary {
  margin-top: 10px;
  padding: 14px 20px;
  font-size: 0.62rem;
  color: var(--gold-light);
  background: transparent;
  border: 1px solid var(--gold-dim);
  box-shadow: none;
}

.voice__record--secondary:hover {
  background: var(--gold-soft);
  box-shadow: none;
}

.voice__record[hidden] {
  display: none;
}

.voice__record {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 18px 24px;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--emerald-deep);
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow 0.3s, transform 0.2s;
  box-shadow: 0 4px 24px rgba(212, 175, 106, 0.2);
}

.voice__record:hover {
  box-shadow: 0 8px 36px rgba(212, 175, 106, 0.35);
  transform: translateY(-1px);
}

.voice__record--active {
  color: var(--text);
  background: transparent;
  border: 1px solid var(--emerald-bright);
  box-shadow: 0 0 24px var(--emerald-glow);
  animation: recordPulse 1.4s ease-in-out infinite;
}

@keyframes recordPulse {
  0%, 100% { box-shadow: 0 0 16px var(--emerald-glow); }
  50%      { box-shadow: 0 0 32px rgba(46, 204, 150, 0.35); }
}

.voice__record-icon {
  display: flex;
  color: inherit;
}

.voice__hint {
  margin: 12px 0 24px;
  font-size: 0.78rem;
  font-weight: 300;
  text-align: center;
  color: var(--text-muted);
  letter-spacing: 0.04em;
}

.transcript__label {
  margin: 0 0 10px;
  font-size: 0.6rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--emerald-bright);
}

.transcript__box {
  min-height: 88px;
  padding: 0;
  margin-bottom: 16px;
  background: var(--emerald-deep);
  border: 1px solid var(--emerald-border);
}

.transcript__input {
  display: block;
  width: 100%;
  min-height: 88px;
  padding: 18px 20px;
  font-family: "Cormorant Garamond", serif;
  font-size: 1.15rem;
  font-weight: 400;
  line-height: 1.55;
  color: var(--text);
  background: transparent;
  border: none;
  outline: none;
  resize: vertical;
}

.transcript__input::placeholder {
  font-family: "Outfit", sans-serif;
  font-size: 0.88rem;
  font-weight: 300;
  font-style: italic;
  color: var(--text-muted);
}

.transcript__box--live {
  border-color: var(--gold-dim);
  box-shadow: 0 0 20px var(--emerald-glow);
}

.voice__check {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  margin-bottom: 8px;
  padding: 16px 24px;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-light);
  background: transparent;
  border: 1px solid var(--gold-dim);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.3s, background 0.3s;
}

.voice__check:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
}

.analysis {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 16px;
  margin-bottom: 20px;
  border: 1px solid var(--emerald-border);
  background: rgba(26, 143, 106, 0.06);
}

.analysis[hidden] {
  display: none;
}

.analysis__spinner {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--gold-dim);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.analysis__text {
  margin: 0;
  font-size: 0.72rem;
  font-weight: 400;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--gold);
}

.voice__error {
  margin: 0 0 18px;
  padding: 14px 16px;
  font-size: 0.85rem;
  font-weight: 300;
  color: var(--gold-pale);
  background: var(--gold-soft);
  border: 1px solid rgba(212, 175, 106, 0.25);
  border-radius: var(--radius);
}

.voice__error[hidden] {
  display: none;
}

.voice__error--hint {
  color: var(--emerald-bright);
  background: rgba(26, 143, 106, 0.1);
  border-color: var(--emerald-border);
}

.voice__deposit {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 20px 28px;
  font-family: inherit;
  font-size: 0.68rem;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--emerald-deep);
  background: linear-gradient(135deg, var(--gold-light) 0%, var(--gold) 100%);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: box-shadow 0.3s, transform 0.2s;
  box-shadow: 0 6px 32px rgba(212, 175, 106, 0.3);
  animation: revealIn 0.6s ease;
}

.voice__deposit:hover {
  box-shadow: 0 10px 40px rgba(212, 175, 106, 0.45);
  transform: translateY(-1px);
}

.voice__deposit[hidden] {
  display: none;
}

.loading {
  margin-top: 8px;
  padding-top: 8px;
  animation: revealIn 0.5s ease;
}

.loading[hidden] {
  display: none;
}

.loading__title {
  margin: 0 0 18px;
  font-size: 0.65rem;
  font-weight: 400;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  text-align: center;
  color: var(--gold);
}

.loading__bar {
  height: 3px;
  background: rgba(212, 175, 106, 0.15);
  border-radius: 2px;
  overflow: hidden;
}

.loading__fill {
  width: 0%;
  height: 100%;
  background: linear-gradient(90deg, var(--emerald-bright), var(--gold));
  transition: width 0.15s linear;
}

.loading__percent {
  margin: 12px 0 0;
  font-size: 0.75rem;
  font-weight: 300;
  text-align: center;
  letter-spacing: 0.12em;
  color: var(--text-muted);
}

.final {
  margin-top: 8px;
  padding-top: 28px;
  border-top: 1px solid rgba(212, 175, 106, 0.15);
  text-align: center;
  animation: revealIn 0.7s ease;
}

.final[hidden] {
  display: none;
}

.final__seal {
  display: inline-flex;
  margin-bottom: 22px;
  padding: 7px 20px;
  font-size: 0.55rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  color: var(--gold);
  border: 1px solid var(--gold);
}

.final__text {
  margin: 0;
  font-family: "Cormorant Garamond", serif;
  font-size: clamp(1.4rem, 4vw, 1.85rem);
  font-weight: 300;
  font-style: italic;
  line-height: 1.5;
  color: var(--gold-light);
}

/* Footer */
.footer {
  margin-top: 40px;
  text-align: center;
}

.footer__line {
  display: block;
  width: 64px;
  height: 1px;
  margin: 0 auto 16px;
  background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.footer p {
  margin: 0;
  font-size: 0.58rem;
  font-weight: 400;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: var(--gold-dim);
}

/* iPhone */
@media (max-width: 430px) {
  .app {
    padding:
      calc(20px + var(--safe-top))
      calc(18px + var(--safe-right))
      calc(24px + var(--safe-bottom))
      calc(18px + var(--safe-left));
  }

  .header {
    margin-bottom: 28px;
  }

  .panel__inner {
    padding: 28px 22px;
  }

  .nav__btn {
    padding: 16px 8px;
  }
}

/* iPad 13" */
@media (min-width: 768px) {
  .app {
    max-width: 580px;
    padding-top: calc(48px + var(--safe-top));
  }

  .header {
    margin-bottom: 44px;
  }

  .nav {
    max-width: 400px;
    margin-left: auto;
    margin-right: auto;
    margin-bottom: 36px;
  }

  .panel__inner {
    padding: 44px 48px;
  }

  .gate__submit {
    max-width: 300px;
    margin: 0 auto;
  }

  .reveal__text {
    font-size: 2.2rem;
  }
}

@media (min-width: 1024px) and (orientation: landscape) {
  .app {
    max-width: 640px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .panel,
  .reveal,
  .gate__input--error {
    animation: none;
  }
}
