/* Caderno de estudo contemporâneo: papel quente, tinta azul, margem vermelha. */
:root {
  --paper: #f7f3ea;
  --sheet: #fffdf8;
  --ink: #1b2438;
  --ink-soft: #4a5468;
  --pen: #1d3f8f;
  --pen-dark: #142e6b;
  --margin: #c8473d;
  --rule: rgba(29, 63, 143, 0.09);
  --line: #ddd5c4;
  --marker: #ffe48a;
  --good: #1f6b45;
  --again: #9a3b12;
  --radius: 14px;
  --tap: 52px;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, "Book Antiqua", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 17px/1.55 var(--sans);
  min-height: 100vh;
}
.wrap { max-width: 720px; margin: 0 auto; padding: 0 16px; }
main { padding-bottom: 48px; outline: none; }
a { color: var(--pen); text-underline-offset: 3px; }
h1, h2, .h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: clamp(1.7rem, 6vw, 2.3rem); margin: 0.6em 0 0.35em; }
h2 { font-size: 1.3rem; margin: 1.6em 0 0.5em; }
.h3 { font-size: 1.15rem; margin: 0.2em 0 0.6em; }
p { margin: 0.5em 0; }
[tabindex="-1"]:focus { outline: none; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 3px; border-radius: 6px; }

.skip { position: absolute; left: -999px; top: 8px; background: var(--sheet); padding: 8px 12px; z-index: 10; }
.skip:focus { left: 8px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--ink-soft); }
.small { font-size: 0.9rem; }
.loading { padding: 40px 0; color: var(--ink-soft); }

/* Cabeçalho */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  max-width: 720px; margin: 0 auto; padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top));
}
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; color: var(--ink); text-decoration: none; min-height: 44px; }
.brand-mark {
  display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 9px;
  background: var(--pen); color: #fff; font: italic 600 18px/1 var(--serif);
}
.site-header nav { display: flex; gap: 4px; }
.site-header nav a {
  display: inline-flex; align-items: center; min-height: 44px; padding: 0 12px;
  border-radius: 999px; text-decoration: none; color: var(--ink); font-weight: 550;
}
.site-header nav a:hover { background: rgba(29, 63, 143, 0.08); }

/* Botões */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 10px 20px; border-radius: 12px;
  border: 2px solid transparent; font: 600 1rem/1.2 var(--sans);
  text-decoration: none; cursor: pointer; text-align: center;
  transition: background-color .15s, transform .05s;
  -webkit-tap-highlight-color: transparent;
}
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: .6; }
.btn-primary { background: var(--pen); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--pen-dark); }
.btn-secondary { background: var(--sheet); color: var(--pen); border-color: var(--pen); }
.btn-secondary:hover:not(:disabled) { background: #eef2fb; }
.btn-ghost { background: transparent; color: var(--pen); border-color: var(--line); }
.btn-link { background: none; color: var(--pen); text-decoration: underline; min-height: 44px; padding: 8px 4px; }
.btn-small { min-height: 44px; padding: 6px 14px; font-size: .95rem; }
.btn-hero { width: 100%; font-size: 1.2rem; min-height: 64px; }
.btn-toggle { background: var(--sheet); color: var(--ink); border-color: var(--line); }
.btn-toggle[aria-pressed="true"] { background: var(--marker); border-color: #d9b93c; }
.icon { width: 22px; height: 22px; flex: none; }

.btn-listen {
  width: 100%; min-height: 72px; font-size: 1.25rem;
  background: var(--pen); color: #fff; border-radius: 16px;
  box-shadow: 0 3px 0 var(--pen-dark);
}
.btn-listen .icon { width: 28px; height: 28px; }
.btn-listen:hover:not(:disabled) { background: var(--pen-dark); }
.btn-listen:disabled { background: #8d97ad; box-shadow: none; }
.is-speaking { animation: pulse 1.2s ease-in-out infinite; }
.btn-listen.is-speaking { background: var(--pen-dark); }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(29, 63, 143, .18); } }
@media (prefers-reduced-motion: reduce) { .is-speaking { animation: none; outline: 3px solid var(--marker); } }

.btn-good { background: #e5f2ea; color: var(--good); border-color: #9ccbb0; flex: 1; }
.btn-again { background: #fbece3; color: var(--again); border-color: #e2b39b; flex: 1; }

.say-chip {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 36px; margin: 2px 1px; padding: 2px 10px;
  border: 1.5px solid #c9cfe0; border-radius: 999px; background: #eef1fa;
  color: var(--pen-dark); font: italic 1em/1.3 var(--serif); cursor: pointer; vertical-align: baseline;
}
.say-chip .icon { width: 16px; height: 16px; }
.say-chip:hover:not(:disabled) { background: #e1e7f7; }
.say-chip:disabled { cursor: default; color: var(--ink); background: transparent; border-style: dashed; }
.say-chip.is-speaking { background: var(--marker); border-color: #d9b93c; }
.fr-inline { font-style: italic; font-family: var(--serif); }

/* Painéis e listas */
.panel {
  background: var(--sheet); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; margin: 16px 0;
}
.panel h2 { margin-top: .2em; }
.panel summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px;
  margin: 4px 0 8px; padding: 12px 14px; border-radius: 12px;
  background: #fff4d6; border: 1px solid #e6c76a; color: #4a3a07;
}
.banner p { margin: 0; flex: 1 1 260px; }
.banner-link { font-weight: 600; }
.warn { color: var(--again); font-weight: 550; }

.hero { padding: 8px 0 4px; }
.lead { font-size: 1.08rem; color: var(--ink-soft); }
.hero-actions { margin: 20px 0 8px; }
.hero-sub { color: var(--ink-soft); margin: 10px 2px 0; }
.review-panel .btn { margin-top: 6px; }

.deck-list, .ref-list, .phrase-list { list-style: none; margin: 0; padding: 0; }
.deck-list { display: grid; gap: 10px; }
.deck-link {
  display: grid; grid-template-columns: auto 1fr; column-gap: 12px; align-items: center;
  min-height: 64px; padding: 12px 16px; border-radius: var(--radius);
  background: var(--sheet); border: 1px solid var(--line); color: var(--ink); text-decoration: none;
  box-shadow: inset 4px 0 0 var(--margin);
}
.deck-link:hover { border-color: var(--pen); }
.deck-num {
  grid-row: span 2; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%;
  border: 2px solid var(--pen); color: var(--pen); font: 600 1rem/1 var(--serif);
}
.deck-title { font-weight: 650; grid-column: 2; }
.deck-meta { color: var(--ink-soft); font-size: .92rem; grid-column: 2; }
.ref-list li a { display: block; padding: 12px 0; min-height: 44px; border-bottom: 1px solid var(--line); font-weight: 600; }
.ref-list .muted { font-weight: 400; }

.crumbs { margin: 8px 0 0; }
.crumbs a { display: inline-flex; min-height: 44px; align-items: center; font-weight: 600; }
.eyebrow { text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; font-weight: 700; color: var(--margin); margin: 0; }
.deck-head .eyebrow { margin-top: 8px; }

.mode-grid { display: grid; gap: 12px; margin: 20px 0; }
@media (min-width: 640px) { .mode-grid { grid-template-columns: repeat(3, 1fr); } }
.mode-card {
  display: flex; flex-direction: column; gap: 6px; padding: 16px; min-height: 120px;
  border-radius: var(--radius); background: var(--sheet); border: 2px solid var(--line);
  color: var(--ink); text-decoration: none;
}
.mode-card:hover { border-color: var(--pen); }
.mode-name { font: 600 1.2rem/1.2 var(--serif); color: var(--pen); }
.mode-desc { font-size: .95rem; color: var(--ink-soft); }
.mode-count { margin-top: auto; font-size: .88rem; font-weight: 600; }

.phrase-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.phrase-list .pt { margin: 2px 0 0; color: var(--ink-soft); font-size: .95rem; }
.fr-list { font: 1.1rem/1.35 var(--serif); }

/* Sessão */
.session-bar { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.back { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; }
.mode-tabs { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 6px; padding: 6px 0; }
.mode-tabs a {
  display: flex; align-items: center; justify-content: center; text-align: center; line-height: 1.15;
  min-height: 44px; padding: 4px 8px;
  border-radius: 999px; border: 1.5px solid var(--line); background: var(--sheet);
  color: var(--ink); text-decoration: none; font-weight: 600; font-size: .95rem;
}
.mode-tabs a[aria-current="page"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.session-pos { font-weight: 650; margin: 10px 0 6px; font-size: 1.02rem; }
.session-pos span { color: var(--pen); }
.progress { height: 6px; border-radius: 3px; background: #e7e0d0; overflow: hidden; margin-bottom: 14px; }
.progress span { display: block; height: 100%; background: var(--pen); transition: width .25s; }

.sheet {
  position: relative; background: var(--sheet); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 20px 18px 22px 30px;
  background-image: linear-gradient(to bottom, transparent 35px, var(--rule) 35px, var(--rule) 36px, transparent 36px);
  background-size: 100% 36px; background-position: 0 14px;
  box-shadow: 0 1px 0 #fff inset, 0 8px 24px -18px rgba(27, 36, 56, .35);
}
.sheet::before { content: ""; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px; background: var(--margin); opacity: .55; }
.instr { color: var(--ink-soft); font-size: .95rem; margin-top: 0; }
.phrase { margin: 18px 0 8px; }
.fr-big {
  font: 600 clamp(1.7rem, 7.2vw, 2.5rem)/1.25 var(--serif); color: var(--ink);
  background: linear-gradient(transparent 62%, var(--marker) 62%, var(--marker) 92%, transparent 92%);
  -webkit-box-decoration-break: clone; box-decoration-break: clone; padding: 0 2px;
  overflow-wrap: anywhere;
}
.intent { font: 600 clamp(1.5rem, 6.4vw, 2.1rem)/1.3 var(--serif); margin: 18px 0 6px; overflow-wrap: anywhere; }
.meaning { font-size: 1.12rem; color: var(--ink-soft); }
.tag {
  display: inline-block; padding: 1px 8px; margin: 2px 2px 2px 0; border-radius: 6px;
  background: #efe9db; color: var(--ink); font-size: .82rem; font-weight: 600; vertical-align: middle;
}
.tag-vous { background: #e3e9f8; color: var(--pen-dark); }
.tag-tu { background: #fbe7d9; color: #7a3410; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 18px 0 4px; }
.actions.stack { flex-direction: column; }
.actions.stack .btn { width: 100%; }
.actions-quiet { margin-top: 10px; }
.btn-reveal { width: 100%; min-height: 64px; font-size: 1.1rem; }
.answer { margin-top: 18px; padding-top: 14px; border-top: 2px dashed var(--line); }
.assess { display: flex; gap: 10px; margin-top: 16px; }
.assess .btn { white-space: nowrap; padding: 10px 12px; }

.dialogue { display: grid; gap: 12px; margin-top: 12px; }
.bubble { padding: 12px 14px; border-radius: 14px; background: #f1ede2; border: 1px solid var(--line); max-width: 92%; }
.bubble-me { background: #e9eefb; border-color: #c6d1ef; justify-self: end; }
.bubble.faded { opacity: .82; }
.bubble .btn { margin-top: 8px; }
.speaker { margin: 0 0 4px; font-size: .78rem; text-transform: uppercase; letter-spacing: .07em; font-weight: 700; color: var(--ink-soft); }
.fr-line { font: 1.25rem/1.4 var(--serif); }
.gloss { margin: 4px 0 0; color: var(--ink-soft); font-size: .98rem; }
.your-turn { padding: 14px; border: 2px dashed #c6d1ef; border-radius: 14px; display: grid; gap: 10px; }
.your-turn p { margin: 0; }
.hint { background: var(--marker); padding: 6px 10px; border-radius: 8px; }
.situation { font-size: 1.1rem; line-height: 1.7; }

.step-nav {
  display: grid; grid-template-columns: 1fr 1.6fr; gap: 10px;
  margin-top: 16px; padding-bottom: env(safe-area-inset-bottom);
}
.done .actions { margin-top: 20px; }

/* Dicas e rotina */
.tip p { line-height: 1.75; }
.examples { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--line); }
.routine-steps { padding-left: 1.2em; display: grid; gap: 10px; }
.routine-steps li strong { display: block; color: var(--pen); }
.field { display: grid; gap: 6px; margin: 14px 0; border: 0; padding: 0; font-weight: 600; }
.field legend { padding: 0; margin-bottom: 6px; }
select {
  width: 100%; min-height: 48px; padding: 8px 10px; border-radius: 10px;
  border: 1.5px solid var(--line); background: #fff; font: 1rem var(--sans); color: var(--ink);
}
.radio { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; margin-right: 18px; font-weight: 500; }
.radio input { width: 22px; height: 22px; accent-color: var(--pen); }
.help { padding-left: 1.1em; }
.help li { margin: 8px 0; }
code { background: #efe9db; padding: 1px 5px; border-radius: 4px; }
