/* FalaFluente — visual editorial: papel quente, tinta, um único verde de destaque.
   Fraunces (títulos/fala do professor) + DM Sans (interface). Ícones de linha próprios. */

:root {
  --bg: #f4f0e8;
  --surface: #fbf9f4;
  --surface-2: #ece6db;
  --ink: #1d1c19;
  --ink-2: #4a4740;
  --muted: #7a746a;
  --line: #ddd5c7;
  --accent: #1f5745;
  --accent-ink: #f7f4ee;
  --accent-soft: #dbe7df;
  --mark: #f2df9c;
  --ok: #2f6f4f;
  --bad: #a3442b;
  --bad-soft: #f3ddd4;
  --me: #e7e0d2;
  --t1: #a65f45; --t2: #3f5f7a; --t3: #6b6a3a;
  --shadow: 0 1px 0 rgba(29, 28, 25, .04), 0 10px 30px -18px rgba(29, 28, 25, .25);
  --serif: "Fraunces", "Iowan Old Style", Georgia, serif;
  --sans: "DM Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131311; --surface: #1b1a17; --surface-2: #26241f; --ink: #ece6da; --ink-2: #c4bdaf;
    --muted: #8f897d; --line: #302e28; --accent: #8cc7ab; --accent-ink: #10221a; --accent-soft: #1f3129;
    --mark: #5a4a17; --ok: #8cc7ab; --bad: #e08a6f; --bad-soft: #3a211a; --me: #2a2822;
    --t1: #c98a72; --t2: #7f9fbb; --t3: #a9a670; --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131311; --surface: #1b1a17; --surface-2: #26241f; --ink: #ece6da; --ink-2: #c4bdaf;
  --muted: #8f897d; --line: #302e28; --accent: #8cc7ab; --accent-ink: #10221a; --accent-soft: #1f3129;
  --mark: #5a4a17; --ok: #8cc7ab; --bad: #e08a6f; --bad-soft: #3a211a; --me: #2a2822;
  --t1: #c98a72; --t2: #7f9fbb; --t3: #a9a670; --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { background: var(--bg); color: var(--ink); font: 400 16px/1.5 var(--sans); -webkit-font-smoothing: antialiased; transition: background .25s, color .25s; }
#app { max-width: 540px; margin: 0 auto; min-height: 100dvh; }
button { font: inherit; color: inherit; cursor: pointer; background: none; border: 0; padding: 0; }
.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex: none; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 8px; }

/* Tipografia */
.display { font: 400 2.1rem/1.1 var(--serif); letter-spacing: -.015em; margin: .15rem 0 1.1rem; font-variation-settings: "opsz" 120; }
.display-sm { font: 400 1.45rem/1.2 var(--serif); margin: .2rem 0 .6rem; letter-spacing: -.01em; }
.eyebrow { font-size: .75rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 1.2rem 0 0; font-weight: 600; }
.lead { color: var(--ink-2); margin: -.4rem 0 1.4rem; }
.section { font: 600 .75rem/1 var(--sans); letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 2.2rem 0 .9rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }

/* Topo */
.topbar { position: sticky; top: 0; z-index: 10; display: flex; justify-content: space-between; align-items: center;
  padding: calc(env(safe-area-inset-top) + 12px) 20px 12px; background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.brand { font: 560 1.25rem/1 var(--serif); letter-spacing: -.01em; }
.brand em { font-style: italic; font-weight: 400; color: var(--accent); }
.top-actions { display: flex; align-items: center; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 5px 10px 5px 8px; border: 1px solid var(--line); border-radius: 99px; font-size: .85rem; color: var(--ink-2); }
.chip .i { width: 16px; height: 16px; color: var(--bad); }
.icon-btn { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; color: var(--ink-2); }
.icon-btn:active { background: var(--surface-2); }

main { padding: 0 20px calc(96px + env(safe-area-inset-bottom)); }
.view { display: none; }
.view.active { display: block; animation: rise .28s cubic-bezier(.2, .7, .2, 1); }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* Botões e campos */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 18px; border-radius: 99px;
  border: 1px solid var(--line); background: var(--surface); font-weight: 500; transition: transform .12s, background .2s; }
.btn:active { transform: scale(.98); }
.btn .i { width: 18px; height: 18px; }
.btn.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.block { width: 100%; margin-top: 12px; padding: 15px; font-size: 1rem; }
.btn.small { padding: 7px 14px; font-size: .88rem; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: transparent; margin-top: 28px; }
.field { display: block; margin: 16px 0; font-size: .85rem; font-weight: 500; color: var(--ink-2); }
.field input, .field select { display: block; width: 100%; margin-top: 7px; padding: 13px 14px; font: 400 1rem var(--sans);
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface); color: var(--ink); appearance: none; }
.field select { background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 20px) 55%, calc(100% - 15px) 55%; background-size: 5px 5px; background-repeat: no-repeat; }
.field.check { display: flex; gap: 12px; align-items: center; font-size: .95rem; color: var(--ink); }
.field.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); appearance: auto; }

/* Início */
.today { background: var(--surface); border-radius: 22px; padding: 18px 18px 8px; box-shadow: var(--shadow); border: 1px solid var(--line); }
.today-head { display: flex; justify-content: space-between; align-items: baseline; font-weight: 600; }
.today-min { font: 400 .95rem var(--sans); color: var(--muted); font-variant-numeric: tabular-nums; }
.progress { height: 4px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: 12px 0 6px; }
.progress > i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .5s; }
.steps { list-style: none; margin: 0; padding: 0; }
.steps li + li { border-top: 1px solid var(--line); }
.steps button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 13px 0; text-align: left; }
.steps .dot { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; flex: none; }
.steps .done .dot { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.steps .dot .i { width: 14px; height: 14px; stroke-width: 2.4; }
.steps .done .txt { color: var(--muted); text-decoration: line-through; }
.steps .txt { flex: 1; }
.steps .txt small { display: block; color: var(--muted); font-size: .8rem; }
.steps > li > button > .i { color: var(--muted); width: 18px; height: 18px; }

.teachers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.teacher { padding: 14px 8px 12px; border-radius: 18px; border: 1px solid var(--line); text-align: center; background: transparent; transition: background .2s, border-color .2s; }
.teacher.sel { background: var(--surface); border-color: var(--ink); box-shadow: var(--shadow); }
.teacher strong { display: block; font: 400 1.05rem var(--serif); margin-top: 8px; }
.teacher small { display: block; color: var(--muted); font-size: .74rem; line-height: 1.3; margin-top: 2px; }
.avatar { width: 46px; height: 46px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center;
  font: 400 1.35rem/1 var(--serif); color: #fbf8f2; flex: none; }

.missions { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.missions li { border-bottom: 1px solid var(--line); }
.missions button, .row-btn { width: 100%; display: flex; gap: 14px; align-items: center; padding: 16px 0; text-align: left; }
.row-num { font: 400 .95rem var(--serif); color: var(--muted); width: 24px; flex: none; font-variant-numeric: tabular-nums; }
.row-txt { flex: 1; min-width: 0; }
.row-txt strong { display: block; font-weight: 600; }
.row-txt small { display: block; color: var(--muted); font-size: .86rem; line-height: 1.35; margin-top: 2px; }
.done-tag { font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: var(--ok); font-weight: 600; }
.missions .i, .row-btn > .i { color: var(--muted); width: 18px; height: 18px; }
.rows { border-top: 1px solid var(--line); }
.rows > * { border-bottom: 1px solid var(--line); }

/* Conversa */
.chat-head { position: sticky; top: calc(env(safe-area-inset-top) + 64px); z-index: 8; display: flex; align-items: center; gap: 12px;
  padding: 6px 0 12px; background: var(--bg); border-bottom: 1px solid var(--line); }
.chat-head .avatar { width: 40px; height: 40px; font-size: 1.15rem; margin: 0; }
.chat-title { flex: 1; min-width: 0; }
.chat-title strong { display: block; font: 400 1.15rem/1.2 var(--serif); }
.chat-title small { display: block; color: var(--muted); font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#btn-speed.on { background: var(--accent-soft); color: var(--accent); }

.prep { padding-top: 4px; }
.chunk-list { display: grid; gap: 0; margin: 14px 0 6px; border-top: 1px solid var(--line); }
.chunk { display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.chunk .c-txt { flex: 1; }
.chunk b { display: block; font: 400 1.05rem/1.3 var(--serif); }
.chunk small { display: block; color: var(--muted); font-size: .84rem; }
.chunk .i { color: var(--accent); width: 20px; height: 20px; }

.messages { display: flex; flex-direction: column; gap: 18px; padding: 18px 0 250px; }
.msg-t { max-width: 94%; }
.msg-t .say { font: 400 1.22rem/1.42 var(--serif); letter-spacing: -.005em; }
.msg-t .pt { display: none; margin-top: 6px; color: var(--muted); font-size: .92rem; }
.msg-t.show-pt .pt { display: block; }
.msg-tools { display: flex; gap: 4px; margin-top: 8px; margin-left: -8px; }
.msg-tools button { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border-radius: 99px; font-size: .8rem; color: var(--muted); }
.msg-tools button:active, .msg-tools button.on { background: var(--surface-2); color: var(--ink); }
.msg-tools .i { width: 16px; height: 16px; }
.msg-u { align-self: flex-end; max-width: 84%; background: var(--me); padding: 10px 14px; border-radius: 18px 18px 4px 18px; color: var(--ink); }
.fix { font-size: .95rem; line-height: 1.5; padding: 2px 0; }
.fix .lbl { display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; margin-bottom: 3px; }
.fix .bad { text-decoration: line-through; text-decoration-color: var(--bad); color: var(--muted); }
.fix .good { font: 400 1.08rem var(--serif); background: linear-gradient(transparent 55%, var(--mark) 55%); padding: 0 2px; }
.fix .why { display: block; color: var(--ink-2); font-size: .88rem; margin-top: 2px; }
.fix button { vertical-align: middle; color: var(--accent); margin-left: 4px; }
.fix button .i { width: 18px; height: 18px; }
.newchunk .lbl { font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.newchunk .chunk-list { margin: 4px 0 0; }
.typing { color: var(--muted); font-style: italic; font-family: var(--serif); }
.mission-ok { align-self: center; color: var(--ok); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; padding: 6px 0; }
.err { color: var(--bad); background: var(--bad-soft); border-radius: 14px; padding: 10px 14px; font-size: .9rem; display: flex; align-items: center; gap: 10px; justify-content: space-between; }

.composer { position: fixed; left: 0; right: 0; bottom: calc(66px + env(safe-area-inset-bottom)); z-index: 7; max-width: 540px; margin: 0 auto;
  padding: 18px 20px 8px; background: linear-gradient(to top, var(--bg) 72%, color-mix(in srgb, var(--bg) 0%, transparent)); }
.live { display: flex; align-items: center; gap: 10px; min-height: 24px; color: var(--ink-2); font-size: .95rem; font-family: var(--serif); font-style: italic; }
.bars { display: none; gap: 3px; align-items: center; height: 18px; }
.bars i { width: 3px; height: 6px; border-radius: 3px; background: var(--accent); animation: wave 1s infinite ease-in-out; }
.bars i:nth-child(2) { animation-delay: .12s; } .bars i:nth-child(3) { animation-delay: .24s; } .bars i:nth-child(4) { animation-delay: .36s; } .bars i:nth-child(5) { animation-delay: .48s; }
@keyframes wave { 0%, 100% { height: 5px; } 50% { height: 18px; } }
.composer[data-state="listening"] .bars { display: inline-flex; }
.text-row { display: none; gap: 8px; margin: 6px 0 4px; }
.composer.typing-on .text-row { display: flex; }
.text-row input { flex: 1; min-width: 0; padding: 12px 16px; border-radius: 99px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; }
.controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; margin-top: 6px; }
.ctl { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .72rem; color: var(--muted); padding: 6px; }
.ctl.on { color: var(--accent); }
.mic { width: 72px; height: 72px; border-radius: 50%; display: grid; place-items: center; background: var(--ink); color: var(--bg);
  box-shadow: 0 8px 24px -10px rgba(0, 0, 0, .45); transition: transform .15s, background .25s; }
.mic .i { width: 28px; height: 28px; stroke-width: 1.8; }
.mic:active { transform: scale(.95); }
.mic:disabled { opacity: .35; }
.mic.rec, .composer[data-state="listening"] .mic { background: var(--accent); color: var(--accent-ink); animation: ring 1.6s infinite; }
@keyframes ring { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 45%, transparent); } 100% { box-shadow: 0 0 0 18px transparent; } }
.mic-label { text-align: center; color: var(--muted); font-size: .82rem; margin: 6px 0 0; min-height: 1.2em; }
.center-stack { display: flex; flex-direction: column; align-items: center; margin: 22px 0 6px; }

/* Treino */
.sub-head { display: flex; align-items: center; gap: 8px; margin: 8px 0 6px; margin-left: -8px; }
.sub-head strong { flex: 1; font: 400 1.2rem var(--serif); }
.drill-card { padding: 22px 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); min-height: 190px; }
.drill-card .eyebrow { margin-top: 0; }
.drill-target { font: 400 1.6rem/1.3 var(--serif); margin: 10px 0; letter-spacing: -.01em; }
.drill-target .w-ok { color: var(--ok); }
.drill-target .w-bad { color: var(--bad); text-decoration: underline; text-decoration-style: wavy; text-underline-offset: 4px; }
.drill-result { margin: 8px 0 0; font-size: .92rem; color: var(--ink-2); }
.tool-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; }
.tool-row .btn { padding: 10px 6px; font-size: .88rem; }
.timer { font: 400 4rem/1 var(--serif); text-align: center; margin: 20px 0 4px; font-variant-numeric: tabular-nums; }
.live-text { text-align: center; color: var(--ink-2); font-family: var(--serif); font-style: italic; min-height: 1.4em; }
.result-row { padding: 12px 0; }
.result-row b { font-weight: 600; }
.result-row div { color: var(--muted); font-size: .86rem; margin-top: 2px; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; border-top: 1px solid var(--line); margin-bottom: 8px; }
.stat { padding: 14px 0; border-bottom: 1px solid var(--line); }
.stat:nth-child(odd) { padding-right: 12px; border-right: 1px solid var(--line); }
.stat:nth-child(even) { padding-left: 16px; }
.stat b { display: block; font: 400 1.7rem/1.1 var(--serif); }
.stat small { color: var(--muted); font-size: .8rem; }
.sum-row { padding: 12px 0; }

/* Barra inferior */
.tabbar { position: fixed; bottom: 0; left: 0; right: 0; z-index: 9; max-width: 540px; margin: 0 auto; display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--line); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); }
.tabbar button { display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: .72rem; color: var(--muted); padding: 2px 0; }
.tabbar button.active { color: var(--ink); font-weight: 600; }
.tabbar button.active .i { color: var(--accent); stroke-width: 1.9; }
.tabbar.hidden { display: none; }

.toast { position: fixed; left: 50%; bottom: 190px; transform: translate(-50%, 8px); z-index: 30; background: var(--ink); color: var(--bg);
  padding: 11px 18px; border-radius: 99px; font-size: .9rem; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; max-width: 88%; text-align: center; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

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