:root {
  --bg: #f4ece3;
  --bg-2: #efe4d6;
  --paper: #fffaf3;
  --ink: #1c1410;
  --ink-soft: #6b5748;
  --line: rgba(28, 20, 16, 0.08);
  --terracotta: #c2410c;
  --terracotta-deep: #9a3412;
  --sand: #e8d5c4;
  --olive: #3f5c45;
  --gold: #c4a35a;
  --good: #2f6b4f;
  --good-bg: #e5f3ea;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --hard: #b45309;
  --shadow: 0 12px 40px rgba(92, 40, 16, 0.1);
  --radius: 22px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --nav-h: calc(64px + var(--safe-bottom));
  --font: "Outfit", "Segoe UI", sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 10% -10%, #fbe7d4 0%, transparent 50%),
    radial-gradient(900px 500px at 110% 0%, #ead7c3 0%, transparent 46%),
    var(--bg);
  color: var(--ink);
  height: 100vh;
  height: 100dvh;
  height: 100svh;
  min-height: 100svh;
}
button, input { font-family: inherit; }
button { cursor: pointer; border: 0; background: none; color: inherit; }
a { color: inherit; }

#app {
  height: 100vh;
  height: 100dvh;
  height: 100svh;
  min-height: 0;
  max-width: 480px;
  margin: 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.boot {
  flex: 1;
  min-height: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  color: var(--terracotta-deep);
}
.boot-mark {
  width: 72px; height: 72px; margin: 0 auto;
  border-radius: 22px;
  background: linear-gradient(145deg, #ea580c, #9a3412);
  color: #fffaf3;
  display: grid; place-items: center;
  font-family: var(--serif);
  font-size: 42px;
  font-weight: 700;
  box-shadow: var(--shadow);
}
.boot p { font-family: var(--serif); font-size: 22px; }

.screen {
  flex: 1;
  min-height: 0;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  padding: calc(12px + var(--safe-top)) 16px calc(var(--nav-h) + 12px);
}
.screen.no-nav { padding-bottom: calc(14px + var(--safe-bottom)); }
.screen.enter { animation: rise 0.35s ease; }
.study-body.swap { animation: cardIn 0.3s ease; }

@keyframes rise {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}
@keyframes cardIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: none; }
}
@keyframes popIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
.topbar h1, .brand {
  font-family: var(--serif);
  font-size: 24px;
  font-weight: 650;
  letter-spacing: -0.03em;
}
.icon-btn {
  width: 42px; height: 42px;
  border-radius: 14px;
  background: var(--paper);
  box-shadow: 0 1px 0 var(--line);
  display: grid; place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.spacer { flex: 1; }
.muted { color: var(--ink-soft); }
.small { font-size: 13px; }

.greeting { margin-bottom: 10px; }
.greeting .hello {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.15;
  letter-spacing: -0.03em;
}
.greeting p { margin-top: 4px; color: var(--ink-soft); font-size: 14px; }

.hero {
  background: linear-gradient(160deg, #c2410c 0%, #9a3412 58%, #7c2d12 100%);
  color: #fffaf3;
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  position: relative;
  overflow: hidden;
  margin-bottom: 12px;
}
.hero::after {
  content: "";
  position: absolute;
  right: -30px; top: -40px;
  width: 160px; height: 160px;
  border-radius: 50%;
  background: rgba(255,255,255,0.08);
}
.hero-kicker {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
  font-weight: 600;
}
.hero h2 {
  font-family: var(--serif);
  font-size: 22px;
  margin: 4px 0 10px;
  font-weight: 650;
}
.progress {
  height: 8px;
  background: rgba(255,255,255,0.2);
  border-radius: 99px;
  overflow: hidden;
}
.progress > span {
  display: block; height: 100%;
  background: #fde68a;
  border-radius: 99px;
}
.hero-meta {
  display: flex; justify-content: space-between;
  margin-top: 10px; font-size: 13px; opacity: 0.9;
}

.stats-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.stat {
  background: var(--paper);
  border-radius: 14px;
  padding: 8px 8px;
  text-align: center;
  box-shadow: 0 1px 0 var(--line);
}
.stat b {
  display: block;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 650;
}
.stat span { font-size: 11px; color: var(--ink-soft); }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.tile {
  background: var(--paper);
  border-radius: 18px;
  padding: 12px;
  text-align: left;
  box-shadow: var(--shadow);
  min-height: 92px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: transform 0.15s ease;
}
.tile:active { transform: scale(0.98); }
.tile-wide {
  width: 100%;
  min-height: 58px;
  margin-top: 8px;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  justify-content: flex-start;
}
.tile-wide .emoji { font-size: 22px; }
.tile-wide h3 { margin-top: 0; }
.tile .emoji { font-size: 22px; }
.tile h3 { font-size: 15px; margin-top: 8px; }
.tile p { font-size: 12px; color: var(--ink-soft); margin-top: 2px; }

.btn {
  display: block;
  width: 100%;
  border-radius: 16px;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 15px;
}
.btn-primary {
  background: var(--ink);
  color: #fffaf3;
}
.btn-ghost {
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 1px 0 var(--line);
}
.btn-good { background: var(--good); color: white; }
.btn-bad { background: var(--bad); color: white; }
.btn-easy { background: var(--olive); color: white; }
.btn:disabled { opacity: 0.45; }

.nav {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: 0;
  width: min(480px, 100%);
  background: rgba(255, 250, 243, 0.92);
  backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  padding: 6px 6px calc(6px + var(--safe-bottom));
  z-index: 20;
}
.nav button {
  display: grid;
  place-items: center;
  gap: 2px;
  font-size: 11px;
  color: var(--ink-soft);
  padding: 6px 0;
  font-weight: 500;
}
.nav button.active { color: var(--terracotta-deep); }
.nav .glyph { font-size: 18px; }

.install-banner {
  margin: 8px 0 4px;
  background: #fff4e5;
  border: 1px dashed #e8b86d;
  border-radius: 16px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.4;
}
.install-banner b { display: block; margin-bottom: 4px; }

.level-pills {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 8px;
  scrollbar-width: none;
}
.level-pills::-webkit-scrollbar { display: none; }
.pill {
  flex-shrink: 0;
  padding: 8px 12px;
  border-radius: 999px;
  background: var(--paper);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-soft);
}
.pill.on {
  background: var(--ink);
  color: #fffaf3;
}
.pill.lock { opacity: 0.5; }

.speak-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 10px 16px;
  margin: 6px 0 10px;
  border-radius: 16px;
  background: var(--ink);
  color: #fffaf3;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: var(--shadow);
  flex-shrink: 0;
}
.speak-bar .speak-icon { font-size: 22px; line-height: 1; }
.speak-bar.playing { background: var(--terracotta-deep); }

.practice-row {
  display: flex;
  gap: 8px;
  margin: 8px 0 12px;
  flex-shrink: 0;
}
.practice-row .speak-bar,
.practice-row .mic-btn {
  flex: 1;
  min-height: 48px;
  margin: 0;
  font-size: 15px;
  padding: 10px 12px;
}
.speak-bar.compact .speak-icon { font-size: 18px; }

.trans-input {
  min-height: 96px;
  resize: vertical;
  font-size: 17px;
  line-height: 1.4;
}

.chat-screen {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.chat-screen .chat-log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
  -webkit-overflow-scrolling: touch;
}
.chat-bubble {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 16px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.chat-bubble.user {
  align-self: flex-end;
  background: var(--ink);
  color: #fffaf3;
  border-bottom-right-radius: 6px;
}
.chat-bubble.assistant {
  align-self: flex-start;
  background: var(--paper);
  box-shadow: 0 1px 0 var(--line);
  border-bottom-left-radius: 6px;
  cursor: pointer;
}
.chat-bubble.pending { opacity: 0.6; }
.chat-compose {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  margin-top: 8px;
}
.chat-draft {
  flex: 1;
  min-height: 52px;
  margin: 0;
  font-size: 16px;
  resize: none;
}
.chat-screen .speech-live,
.chat-screen .listen-note,
.chat-screen .mic-btn,
.chat-screen .chat-compose {
  flex-shrink: 0;
}

.card-scene {
  perspective: 900px;
  margin: 0 0 10px;
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
}
.card-scene::before {
  content: "";
  position: absolute;
  inset: 14px 10px -10px;
  background: var(--paper);
  border-radius: 28px;
  opacity: 0.45;
  box-shadow: 0 1px 0 var(--line);
}
.swipe-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  min-height: 0;
  flex: 1;
  display: flex;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: grab;
  will-change: transform;
}
.swipe-wrap:active { cursor: grabbing; }
.flip-card {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  transform-style: preserve-3d;
  transition: transform 0.55s cubic-bezier(.2,.8,.2,1);
}
.flip-card.flipped { transform: rotateY(180deg); }
.face {
  position: absolute;
  inset: 0;
  background: var(--paper);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 20px 18px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 10px;
}
.face.back { transform: rotateY(180deg); }
.stamp {
  position: absolute;
  z-index: 6;
  pointer-events: none;
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 8px 12px;
  border: 4px solid;
  border-radius: 12px;
  opacity: 0;
}
.stamp-yes {
  top: 28px;
  left: 18px;
  color: var(--good);
  border-color: var(--good);
  transform: rotate(-16deg);
}
.stamp-no {
  top: 28px;
  right: 18px;
  color: var(--bad);
  border-color: var(--bad);
  transform: rotate(16deg);
}
.stamp-easy {
  top: 22px;
  left: 50%;
  color: var(--olive);
  border-color: var(--olive);
  transform: translateX(-50%) rotate(-4deg);
}
.swipe-hint {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  font-weight: 650;
  color: var(--ink-soft);
  padding: 0 4px 6px;
  flex-shrink: 0;
}
.swipe-hint span { flex: 1; text-align: center; }
.swipe-hint .no { color: var(--bad); text-align: left; }
.swipe-hint .yes { color: var(--good); text-align: right; }
.swipe-hint .easy { color: var(--olive); }
.tag {
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--terracotta);
  background: #f8e8dc;
  padding: 4px 10px;
  border-radius: 999px;
}
.word {
  font-family: var(--serif);
  font-size: clamp(28px, 7.5vw, 42px);
  line-height: 1.1;
  letter-spacing: -0.03em;
}
.lemma {
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 2px;
}
.example {
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.4;
  max-width: 32ch;
}
.screen.study-vocab {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  overscroll-behavior: none;
}
.screen.study-vocab .session-top,
.screen.study-vocab .thin-progress {
  flex-shrink: 0;
}
.screen.study-vocab .study-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.screen.study-speak .study-body {
  overflow-y: auto;
}
.screen.study-speak .card-scene,
.screen.study-speak .swipe-wrap,
.screen.study-speak .flip-card {
  min-height: 180px;
}

.session-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.session-count { font-weight: 600; font-size: 14px; margin-left: auto; }
.thin-progress {
  height: 6px;
  background: var(--sand);
  border-radius: 99px;
  overflow: hidden;
  margin-bottom: 8px;
}
.thin-progress > span {
  display: block; height: 100%;
  background: var(--terracotta);
  transition: width 0.35s ease;
}

.prompt-scene {
  perspective: 1100px;
  margin: 8px 0 10px;
}
.prompt-flip {
  display: block;
  position: relative;
  width: 100%;
  min-height: 140px;
  padding: 0;
  background: none;
  text-align: center;
  transform-style: preserve-3d;
  transition: transform 0.42s cubic-bezier(.2,.75,.2,1);
}
.prompt-flip.flipped { transform: rotateY(180deg); }
.prompt-flip:not(:disabled) { cursor: pointer; }
.prompt-flip:disabled { cursor: default; }
.prompt-face {
  background: var(--paper);
  border-radius: 28px;
  box-shadow: var(--shadow);
  padding: 18px 16px;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  min-height: 140px;
}
.prompt-face.back {
  position: absolute;
  inset: 0;
  transform: rotateY(180deg);
}

.prompt-card {
  background: var(--paper);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px 16px;
  text-align: center;
  margin: 8px 0 10px;
  width: 100%;
}
.prompt-card:not(:disabled) { cursor: pointer; }
.prompt-card:disabled { cursor: default; }
.card-de {
  margin-top: 14px;
  font-size: 17px;
  line-height: 1.4;
  color: var(--terracotta-deep);
  font-style: italic;
}
.trans-hint { margin-top: 12px; opacity: 0.75; }
.topic.featured {
  background: linear-gradient(160deg, #fff6ea, #f8e8dc);
  box-shadow: var(--shadow);
  border: 1px solid #ead2b8;
}
.topic.featured h3::before { content: "★ "; color: var(--terracotta); }
.sentence {
  font-family: var(--serif);
  font-size: 22px;
  line-height: 1.3;
  letter-spacing: -0.02em;
}
.blank {
  display: inline-block;
  min-width: 4.5ch;
  border-bottom: 2px solid var(--terracotta);
  color: var(--terracotta);
  font-weight: 700;
}
.options {
  display: grid;
  gap: 8px;
}
.option {
  background: var(--paper);
  border-radius: 14px;
  padding: 11px 14px;
  text-align: left;
  font-size: 16px;
  font-weight: 600;
  box-shadow: 0 1px 0 var(--line);
  border: 2px solid transparent;
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
}
.option.correct {
  background: var(--good-bg);
  border-color: var(--good);
  color: var(--good);
}
.option.wrong {
  background: var(--bad-bg);
  border-color: var(--bad);
  color: var(--bad);
}
.option:disabled { cursor: default; }

.rate-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}
.feedback {
  margin: 8px 0 14px;
  padding: 12px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.4;
}
.pop-in { animation: popIn 0.28s ease; }
.answer-slot:empty { display: none; }
.feedback.ok { background: var(--good-bg); color: var(--good); }
.feedback.no { background: var(--bad-bg); color: var(--bad); }

.topic {
  background: var(--paper);
  border-radius: 16px;
  padding: 12px;
  margin-bottom: 8px;
  text-align: left;
  width: 100%;
  box-shadow: 0 1px 0 var(--line);
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 2px 12px;
  align-items: center;
}
.topic h3 { font-size: 16px; }
.topic p { font-size: 13px; color: var(--ink-soft); grid-column: 1; }
.topic .lvl {
  font-size: 11px;
  font-weight: 700;
  color: var(--terracotta-deep);
}
.topic.locked { opacity: 0.45; }

.lesson {
  background: var(--paper);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px 18px 20px;
  min-height: 0;
}
.lesson h2 {
  font-family: var(--serif);
  font-size: 26px;
  margin: 8px 0 14px;
}
.lesson .body {
  font-size: 16px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 12px;
  font-size: 15px;
}
.table td {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
.table td:first-child { color: var(--ink-soft); width: 42%; }
.dots {
  display: flex; gap: 6px; justify-content: center; margin: 10px 0;
}
.dots i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--sand);
  display: block;
}
.dots i.on { background: var(--terracotta); width: 18px; border-radius: 99px; }

.list {
  display: grid; gap: 8px;
}
.row {
  background: var(--paper);
  border-radius: 16px;
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}
.row .es { font-weight: 650; }
.row .de { color: var(--ink-soft); font-size: 13px; text-align: right; }

.settings-card {
  background: var(--paper);
  border-radius: 20px;
  padding: 6px 8px;
  margin-bottom: 14px;
}
.setting {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 10px;
  gap: 12px;
  width: 100%;
  text-align: left;
  border-bottom: 1px solid var(--line);
}
.setting:last-child { border-bottom: 0; }
.select {
  background: var(--bg-2);
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 600;
  border: 0;
}

.empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--ink-soft);
}
.empty .big {
  font-family: var(--serif);
  font-size: 28px;
  color: var(--ink);
  margin-bottom: 8px;
}

.danger { color: var(--bad); }

.section-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 12px 0 8px;
}

.result-hero {
  text-align: center;
  padding: 12px 8px 6px;
}
.result-hero .score {
  font-family: var(--serif);
  font-size: 48px;
  letter-spacing: -0.04em;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-2);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
}

.type-input {
  width: 100%;
  margin-top: 10px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 16px;
  font-family: var(--serif);
  font-size: 20px;
  text-align: center;
  background: var(--bg);
  color: var(--ink);
}
.type-input:focus {
  outline: none;
  border-color: var(--terracotta);
}
.card-tools {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin: 8px 0 4px;
  flex-shrink: 0;
}
.tool-btn {
  background: var(--bg-2);
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}
.forms-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  background: rgba(28, 20, 16, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px calc(20px + var(--safe-bottom));
}
.forms-sheet {
  width: 100%;
  max-width: 420px;
  max-height: min(80dvh, 640px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
  border-radius: 24px;
  padding: 16px 18px 22px;
  box-shadow: 0 18px 50px rgba(28, 20, 16, 0.28);
}
.forms-sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 4px;
  position: sticky;
  top: 0;
  background: var(--paper);
  z-index: 1;
  padding-bottom: 6px;
}
.forms-sheet .table { margin-top: 4px; }
.forms-sheet .table td:last-child {
  font-weight: 650;
  text-align: right;
}
.forms-sec {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ink-soft);
  margin: 14px 0 6px;
}
.forms-sec:first-of-type { margin-top: 2px; }
.mnemonic-hook {
  font-family: Fraunces, Georgia, serif;
  font-weight: 650;
  font-size: 18px;
  line-height: 1.3;
  margin: 4px 0 10px;
  color: var(--terracotta-deep, #9a3412);
}
.mnemonic-body {
  font-size: 15px;
  line-height: 1.45;
}
.mnemonic-body p { margin: 0 0 10px; }
.mnemonic-body p:last-child { margin-bottom: 0; }
.tool-btn.forms-open,
.tool-btn.mnemonic-open {
  background: var(--terracotta);
  color: #fffaf3;
  padding: 7px 12px;
  font-size: 12px;
}
.tool-btn.mnemonic-open {
  background: var(--terracotta-deep, #9a3412);
}
.tool-btn.rec-on {
  background: var(--bad);
  color: #fffaf3;
}
.listen-note {
  text-align: center;
  font-size: 15px;
  line-height: 1.35;
  color: var(--terracotta-deep);
  margin: 4px 0 8px;
  min-height: 1.35em;
}
.mic-btn {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border-radius: 16px;
  background: var(--ink);
  color: #fffaf3;
  font-size: 16px;
  font-weight: 700;
  flex-shrink: 0;
  box-shadow: var(--shadow);
}
.mic-btn.rec-on,
.mic-btn.busy-on {
  background: var(--bad);
  animation: pulse-rec 1.1s ease infinite;
}
@keyframes pulse-rec {
  50% { transform: scale(0.99); opacity: 0.92; }
}

.lang-switch {
  display: flex;
  background: var(--paper);
  border-radius: 14px;
  padding: 3px;
  box-shadow: 0 1px 0 var(--line);
}
.lang-switch button {
  min-width: 40px;
  height: 36px;
  border-radius: 11px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.lang-switch button.on {
  background: var(--ink);
  color: #fffaf3;
}

.dir-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.dir-btn {
  background: var(--paper);
  border-radius: 16px;
  padding: 10px 12px;
  text-align: left;
  box-shadow: var(--shadow);
  min-height: 0;
  border: 2px solid transparent;
}
.dir-btn b {
  display: block;
  font-size: 15px;
  letter-spacing: -0.02em;
}
.dir-btn span {
  display: block;
  margin-top: 4px;
  font-size: 12px;
  color: var(--ink-soft);
}
.dir-btn.on {
  border-color: var(--terracotta);
  background: #fff6ea;
}
.dir-btn.on b { color: var(--terracotta-deep); }

.field {
  display: block;
  padding: 12px 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink-soft);
}
.field .type-input { margin-top: 8px; font-size: 18px; }
.add-card .setting { border-bottom: 0; }

.speech-steps {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}
.speech-step {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: var(--ink-soft);
}
.speech-step i {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--sand);
  flex-shrink: 0;
}
.speech-step.on { color: var(--terracotta-deep); font-weight: 650; }
.speech-step.on i { background: var(--terracotta); box-shadow: 0 0 0 4px rgba(194, 65, 12, 0.15); }
.speech-step.done { color: var(--good); }
.speech-step.done i { background: var(--good); }
.speech-step.err { color: var(--bad); }
.speech-step.err i { background: var(--bad); }

.speech-live {
  background: var(--paper);
  border-radius: 18px;
  padding: 12px 14px;
  margin: 4px 0 10px;
  box-shadow: 0 1px 0 var(--line);
}
.speech-live-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
}
.speech-live p {
  margin-top: 6px;
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 1.35;
}
.speech-live .progress { margin-top: 10px; background: var(--sand); }
.speech-live .progress > span { background: var(--terracotta); }
.speech-live[data-phase="recording"] { border: 1px solid #f3c0bb; background: #fff6f4; }
.speech-live[data-phase="busy"] { border: 1px solid #ead2b8; }
.speech-live[data-phase="loading"] { border: 1px solid #ead2b8; }

body[data-lang="it"] {
  --terracotta: #2d6a4f;
  --terracotta-deep: #1b4332;
}
body[data-lang="it"] .hero {
  background: linear-gradient(160deg, #40916c 0%, #2d6a4f 58%, #1b4332 100%);
}
body[data-lang="it"] .nav button.active { color: #1b4332; }
body[data-lang="it"] .dir-btn.on {
  border-color: #2d6a4f;
  background: #eef6f1;
}
body[data-lang="it"] .boot-mark {
  background: linear-gradient(145deg, #52b788, #1b4332);
}

@media (min-width: 900px) {
  body {
    background: #e7d8c8;
    overflow: hidden;
  }
  #app {
    margin-top: 24px;
    height: calc(100svh - 48px);
    min-height: 0;
    border-radius: 32px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(80, 30, 10, 0.18);
    background: var(--bg);
  }
  .nav { width: 480px; }
}

@media (max-height: 740px) {
  .greeting { margin-bottom: 8px; }
  .greeting .hello { font-size: 22px; }
  .hero { padding: 12px 14px; margin-bottom: 8px; }
  .hero h2 { font-size: 18px; margin: 2px 0 8px; }
  .stats-row { margin-bottom: 8px; }
  .stat { padding: 6px; }
  .stat b { font-size: 18px; }
  .tile { min-height: 74px; padding: 10px; }
  .tile-wide { min-height: 50px; margin-top: 6px; }
  .tile .emoji, .tile-wide .emoji { font-size: 18px; }
  .tile h3 { margin-top: 4px; font-size: 14px; }
  .dir-btn { padding: 8px 10px; }
  .prompt-flip, .prompt-face { min-height: 120px; }
  .prompt-face { padding: 14px 14px; }
  .sentence { font-size: 20px; }
  .option { padding: 9px 12px; font-size: 15px; }
  .speak-bar { min-height: 44px; font-size: 15px; }
  .lesson h2 { font-size: 22px; margin: 6px 0 10px; }
  .trans-input { min-height: 80px; }
}
