:root {
  --ink: #19201d;
  --muted: #66706a;
  --paper: #fffdf8;
  --cream: #f3eee4;
  --teal: #135f5a;
  --teal-soft: #e2efec;
  --wine: #793e42;
  --gold: #c49a53;
  --line: #ded7ca;
  --shadow: 0 22px 55px rgba(44, 37, 26, .13);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 15%, rgba(196,154,83,.18), transparent 24rem),
    linear-gradient(145deg, #ede7da, #f8f5ee 55%, #e9e2d4);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow-x: hidden;
}

button, textarea { font: inherit; }
button { cursor: pointer; }

.shell { width: min(900px, calc(100% - 32px)); margin: 0 auto; padding: 34px 0 54px; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.eyebrow, .beat-label { margin: 0 0 5px; color: var(--teal); font-weight: 750; letter-spacing: .09em; text-transform: uppercase; font-size: .78rem; }
h1 { margin: 0; font-family: Georgia, serif; font-size: clamp(2rem, 6vw, 3.25rem); font-weight: 500; line-height: 1; }
h2 { margin: 0; font: 500 clamp(1.45rem, 4vw, 2rem)/1.1 Georgia, serif; }

.quiet-button, .help-button {
  border: 1px solid var(--line); background: rgba(255,255,255,.55); color: var(--ink);
  border-radius: 999px; padding: 9px 14px; min-height: 42px;
}
.quiet-button:hover, .help-button:hover { background: white; border-color: #b9afa0; }

.scene-card { background: var(--paper); border: 1px solid rgba(121,97,63,.16); border-radius: 22px; box-shadow: var(--shadow); overflow: hidden; }
.scene-heading { display: flex; justify-content: space-between; gap: 20px; padding: 25px 28px 18px; }
.progress-text { color: var(--muted); font-size: .9rem; white-space: nowrap; }
.progress-track { height: 4px; background: #ebe5da; }
.progress-track span { display: block; height: 100%; width: 16.67%; background: linear-gradient(90deg, var(--teal), #2d8a80); transition: width .4s ease; }
.setting { margin: 0; padding: 19px 28px; background: #f8f4ec; border-bottom: 1px solid #ebe4d8; color: #5e584f; font: italic 1rem/1.55 Georgia, serif; }
.scene-media { margin: 0; height: clamp(220px, 34vw, 330px); overflow: hidden; background: #29251f; border-bottom: 1px solid #d9d1c4; }
.scene-media[hidden] { display: none; }
.scene-media img { display: block; width: 100%; height: 100%; object-fit: cover; object-position: center; }

.readable-menu { padding: 22px 28px; border-bottom: 1px solid var(--line); background: #fbf7ee; }
.readable-menu[hidden] { display: none; }
.menu-title-row { display: flex; justify-content: space-between; align-items: end; gap: 22px; margin-bottom: 18px; }
.menu-title-row h3 { margin: 0; font: 500 1.45rem/1.15 Georgia, serif; }
.menu-title-row > p { max-width: 330px; margin: 0; color: var(--muted); font-size: .84rem; line-height: 1.4; }
.menu-columns { display: grid; grid-template-columns: 1.55fr 1fr; gap: 24px; }
.menu-columns h4 { margin: 0 0 9px; color: var(--wine); font: 700 .76rem/1.2 Inter, sans-serif; letter-spacing: .08em; text-transform: uppercase; }
.menu-options { display: grid; gap: 7px; }
.menu-option { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; min-height: 56px; padding: 10px 12px; border: 1px solid #d9d0c1; border-radius: 10px; color: var(--ink); background: rgba(255,255,255,.72); text-align: left; }
.menu-option:hover, .menu-option:focus-visible { border-color: var(--teal); background: white; outline: 2px solid rgba(19,95,90,.14); }
.menu-option span, .menu-option strong, .menu-option small { display: block; }
.menu-option strong { font-family: Georgia, serif; font-size: 1rem; }
.menu-option small { margin-top: 3px; color: var(--muted); font-size: .72rem; }
.menu-option b { color: var(--teal); font-size: .88rem; }

.conversation { min-height: 310px; max-height: 52vh; overflow-y: auto; padding: 26px 28px 8px; scroll-behavior: smooth; }
.message { display: grid; grid-template-columns: 42px 1fr; gap: 12px; margin-bottom: 22px; animation: arrive .22s ease-out; }
.avatar { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--teal-soft); color: var(--teal); font-weight: 800; }
.message.waiter .avatar { background: #ece6dc; color: #554b3e; }
.message.lidia { margin-left: 46px; padding: 14px; border-left: 3px solid var(--teal); background: #f1f7f5; border-radius: 0 12px 12px 0; }
.message.learner { margin-left: 80px; }
.message.learner .avatar { background: #efe4e5; color: var(--wine); }
.speaker { margin: 0 0 3px; color: var(--muted); font-weight: 750; font-size: .79rem; letter-spacing: .04em; text-transform: uppercase; }
.line { margin: 0; font-size: 1.08rem; line-height: 1.5; }
.translation { margin: 4px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.4; }
.success-note { margin: -8px 0 18px 54px; color: var(--teal); font-size: .9rem; font-weight: 650; }

.composer { border-top: 1px solid var(--line); padding: 20px 28px 24px; background: white; }
.composer.response-mode { padding-top: 14px; padding-bottom: 14px; }
.composer.response-mode > label,
.composer.response-mode > .input-row,
.composer.response-mode > .help-row { display: none; }
.composer.response-mode .speak-control { margin: 0; }
.composer.response-mode .speak-control small::after { content: " · Say ‘repeat’ or ‘va bene’"; }
.composer label { display: block; margin-bottom: 9px; font-weight: 700; }
.speak-control { width: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 12px; padding: 13px 16px; border: 1px solid #b8cec9; border-radius: 12px; color: var(--teal); background: var(--teal-soft); text-align: left; }
.speak-control:hover { background: #d7e9e5; }
.speak-control strong, .speak-control small { display: block; }
.speak-control small { margin-top: 2px; color: #57716c; font-size: .8rem; }
.mic-icon { width: 16px; height: 16px; display: grid; place-items: center; color: var(--wine); font-size: 1.35rem; line-height: 1; }
.speak-control.listening { color: white; background: var(--wine); border-color: var(--wine); box-shadow: 0 0 0 4px rgba(121,62,66,.13); }
.speak-control.listening small, .speak-control.listening .mic-icon { color: white; }
.speak-control.unsupported { display: none; }
.input-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; align-items: stretch; }
textarea { width: 100%; resize: vertical; min-height: 56px; max-height: 150px; border: 1px solid #bdb5a9; border-radius: 12px; padding: 14px; color: var(--ink); background: #fffefa; font-size: 1rem; line-height: 1.35; }
textarea:focus { outline: 3px solid rgba(19,95,90,.16); border-color: var(--teal); }
.send-button { border: 0; border-radius: 12px; padding: 0 22px; min-width: 105px; color: white; background: var(--teal); font-weight: 800; }
.send-button:hover { background: #0e4e4a; }
.send-button:disabled, textarea:disabled { opacity: .58; cursor: wait; }
.help-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.help-button { font-size: .87rem; min-height: 38px; padding: 7px 12px; }

.principle-card { display: flex; gap: 12px; align-items: flex-start; width: min(700px, 92%); margin: 18px auto 0; color: #4a514d; }
.principle-card span { display: grid; place-items: center; flex: 0 0 27px; height: 27px; border-radius: 50%; color: white; background: var(--teal); }
.principle-card p { margin: 2px 0 0; line-height: 1.45; font-size: .93rem; }

.debrief { padding: 2px 0 26px; }
.debrief h3 { margin: 24px 0 10px; font-family: Georgia, serif; font-size: 1.35rem; }
.accomplishments { display: grid; gap: 8px; padding: 0; list-style: none; }
.accomplishments li::before { content: "✓"; color: var(--teal); font-weight: 800; margin-right: 9px; }
.pair { padding: 12px 14px; border-radius: 10px; background: #f6f2eb; margin-bottom: 9px; line-height: 1.45; }
.pair strong { color: var(--teal); }
.replay-button { border: 0; border-radius: 12px; padding: 13px 18px; background: var(--teal); color: white; font-weight: 800; }
.turn-actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 26px 54px; }
.secondary-action { border: 1px solid var(--teal); border-radius: 12px; padding: 12px 17px; background: white; color: var(--teal); font-weight: 800; }
.secondary-action:hover { background: var(--teal-soft); }

@keyframes arrive { from { opacity: 0; transform: translateY(5px); } }

@media (max-width: 620px) {
  .shell { width: 100%; padding: 0 0 24px; }
  .topbar { align-items: center; padding: 16px 14px 14px; margin: 0; }
  .eyebrow { font-size: .7rem; letter-spacing: .06em; }
  h1 { font-size: 2.25rem; }
  .quiet-button { min-height: 38px; padding: 7px 11px; font-size: .86rem; }
  .scene-card { border-width: 1px 0; border-radius: 0; box-shadow: none; overflow: visible; }
  .scene-heading { padding-top: 18px; padding-bottom: 14px; }
  .scene-heading, .setting, .conversation, .composer { padding-left: 14px; padding-right: 14px; }
  h2 { font-size: 1.65rem; }
  .setting { padding-top: 15px; padding-bottom: 15px; font-size: .95rem; }
  .scene-media { height: auto; aspect-ratio: 16 / 9; }
  .readable-menu { padding: 18px 14px; }
  .menu-title-row { display: block; margin-bottom: 14px; }
  .menu-title-row > p { margin-top: 7px; }
  .menu-columns { grid-template-columns: 1fr; gap: 18px; }
  .menu-option { min-height: 60px; }
  .conversation { min-height: 0; max-height: none; overflow: visible; padding-top: 20px; }
  .input-row { grid-template-columns: 1fr; }
  .send-button { min-height: 48px; }
  .message.lidia, .message.learner { margin-left: 0; }
  .message { grid-template-columns: 36px minmax(0, 1fr); gap: 10px; margin-bottom: 18px; }
  .avatar { width: 36px; height: 36px; }
  .line, .translation { overflow-wrap: anywhere; }
  .success-note { margin-left: 46px; }
  .turn-actions { margin: 8px 0 22px 46px; }
  .turn-actions button { flex: 1 1 145px; min-height: 48px; }
  .composer { padding-top: 17px; padding-bottom: 18px; }
  .composer.response-mode { position: sticky; bottom: 0; z-index: 4; box-shadow: 0 -8px 24px rgba(44,37,26,.1); }
  .speak-control { min-height: 58px; }
  .help-row .help-button { flex: 1 1 calc(50% - 8px); }
  .principle-card { width: calc(100% - 28px); }
}

@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; animation: none !important; transition: none !important; } }
