@import url("/css/tokens.css");

* { box-sizing: border-box; }
html { color-scheme: dark; scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  color: var(--t1);
  background:
    radial-gradient(circle at 12% -10%, rgba(45,212,191,.09), transparent 32rem),
    radial-gradient(circle at 105% 30%, rgba(45,212,191,.035), transparent 28rem),
    var(--bg);
  font: 400 15px/1.55 var(--fb);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .18;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.07'/%3E%3C/svg%3E");
  z-index: -1;
}
button, input, select, textarea { font: inherit; }
button, a, input, select, textarea { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }
a { color: inherit; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 3px; }
[hidden] { display: none !important; }

.skip-link { position: fixed; left: 1rem; top: -4rem; z-index: 100; background: var(--teal); color: var(--teal-ink); padding: .7rem 1rem; border-radius: var(--r14); }
.skip-link:focus { top: 1rem; }
.app-shell { min-height: 100dvh; }
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 68px; padding: env(safe-area-inset-top) 1rem 0;
  background: color-mix(in srgb, var(--bg) 84%, transparent);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent);
}
.brand-lockup { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.brand-mark { width: 28px; height: 28px; color: var(--teal); flex: none; }
.brand-name, #screen-title { font: 700 1.28rem/1 var(--fd); letter-spacing: -.035em; }
.top-actions { display: flex; align-items: center; gap: .5rem; }
#offline-banner {
  position: sticky; top: 68px; z-index: var(--z-banner);
  display: flex; align-items: center; justify-content: center; gap: .55rem;
  padding: .55rem 1rem; color: var(--am); background: rgba(245,158,11,.1);
  border-bottom: 1px solid rgba(245,158,11,.24); font-size: .82rem;
}
.sync-badge {
  display: inline-flex; align-items: center; gap: .45rem;
  min-height: 31px; padding: .35rem .7rem; border: 1px solid var(--line);
  border-radius: 999px; color: var(--t3); background: var(--s1);
  font: 400 .68rem/1 var(--fm); text-transform: uppercase; letter-spacing: .04em;
}
.sync-badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.sync-badge.ok { color: var(--teal); }
.sync-badge.pending { color: var(--am); }
.sync-badge.offline { color: var(--am); }
.sync-badge.auth { color: var(--ro); }
.sync-badge.syncing::before { animation: pulse 1s infinite; }

#view { width: min(100%, 760px); margin: 0 auto; padding: 1.25rem 1rem 2.5rem; }
.page-head { margin: .35rem 0 1.5rem; }
.eyebrow, .meta, .group-label, .tag {
  color: var(--t3); font: 400 .7rem/1.35 var(--fm); text-transform: uppercase; letter-spacing: .07em;
}
.page-head h1, .hero h1 { margin: .3rem 0 .35rem; font: 750 clamp(1.9rem, 7vw, 2.65rem)/1.02 var(--fd); letter-spacing: -.055em; text-wrap: balance; }
.page-head p, .hero p { margin: 0; color: var(--t2); max-width: 62ch; text-wrap: pretty; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin: 1.8rem 0 .75rem; }
.section-head h2 { margin: 0; font: 700 1.08rem/1.2 var(--fd); }
.section-head a, .text-link { color: var(--teal); font-weight: 600; text-decoration: none; }

.card, .panel {
  position: relative; padding: 1rem; border: 1px solid var(--line); border-radius: var(--r18);
  background: linear-gradient(150deg, color-mix(in srgb, var(--s2) 88%, transparent), var(--s1));
}
.card + .card { margin-top: .75rem; }
.card h2, .card h3 { margin: 0 0 .45rem; font-family: var(--fd); letter-spacing: -.02em; }
.card p { margin: .3rem 0; }
.hero {
  position: relative; overflow: hidden; padding: 1.35rem; border: 1px solid var(--line2); border-radius: var(--r22);
  background: radial-gradient(circle at 95% 0, rgba(45,212,191,.16), transparent 18rem), linear-gradient(145deg,var(--s2),var(--s1));
}
.hero::after { content: ""; position: absolute; width: 180px; height: 180px; right: -95px; top: -110px; border: 1px solid var(--line2); border-radius: 50%; }
.hero h2 { margin: .45rem 0 .3rem; font: 750 1.65rem/1.12 var(--fd); letter-spacing: -.045em; max-width: 18ch; }
.hero-list { display: grid; gap: .55rem; margin: 1.1rem 0; color: var(--t2); }
.hero-list span { display: flex; gap: .55rem; align-items: center; }
.hero-list .ic { color: var(--teal); }
.grid-2, .stat-grid { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .75rem; }
.stat-box { padding: 1rem; border-left: 2px solid var(--line2); background: rgba(13,19,26,.62); }
.stat-box .n { font: 700 1.65rem/1 var(--fd); font-variant-numeric: tabular-nums; }
.stat-box .l { margin-top: .35rem; color: var(--t3); font-size: .75rem; }

button, .button {
  min-height: 44px; border: 1px solid var(--line2); border-radius: var(--r14);
  padding: .7rem 1rem; color: var(--t1); background: transparent; font-weight: 600;
  transition: transform .18s var(--ease), border-color .18s, background .18s, color .18s;
}
button:hover, .button:hover { border-color: var(--teal); background: rgba(45,212,191,.06); }
button:active, .button:active { transform: scale(.98); }
.btn-primary, .btn-accent {
  border-color: transparent; color: var(--teal-ink); background: linear-gradient(140deg,var(--teal),var(--teal-2));
  box-shadow: 0 12px 35px rgba(14,148,136,.18);
}
.btn-primary:hover, .btn-accent:hover { color: var(--teal-ink); filter: brightness(1.08); }
.btn-secondary, .btn-ghost { color: var(--t2); }
.btn-danger, .btn-err { color: var(--ro); border-color: rgba(244,63,94,.28); }
.btn-success, .btn-ok { color: var(--em); border-color: rgba(52,211,153,.28); }
.btn-row { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .65rem; }
.btn-block { width: 100%; }

.ic { width: 1.1em; height: 1.1em; fill: currentColor; vertical-align: -.18em; flex: none; }
.tag, .pill { display: inline-flex; align-items: center; gap: .35rem; width: fit-content; padding: .3rem .55rem; border: 1px solid var(--line); border-radius: 7px; color: var(--teal); background: rgba(45,212,191,.07); }
.pill { color: var(--t2); font: 400 .7rem/1 var(--fm); }
.pill.warn { color: var(--am); border-color: rgba(245,158,11,.25); background: rgba(245,158,11,.07); }
.pill.err { color: var(--ro); border-color: rgba(244,63,94,.25); background: rgba(244,63,94,.07); }
.pill.good { color: var(--em); border-color: rgba(52,211,153,.25); background: rgba(52,211,153,.07); }
.muted { color: var(--t3); }
.center { text-align: center; }
.spacer { height: .85rem; }

.list { display: grid; gap: .65rem; }
.row {
  width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .95rem 1rem; text-align: left; border: 1px solid var(--line); border-radius: var(--r18); background: var(--s1);
}
.row-main { display: grid; gap: .2rem; min-width: 0; }
.row-title { font: 650 1rem/1.25 var(--fd); overflow: hidden; text-overflow: ellipsis; }
.row-sub { color: var(--t3); font: .7rem/1.3 var(--fm); }
.chip-row { display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none; padding-bottom: .2rem; }
.chip-row::-webkit-scrollbar { display: none; }
.chip { white-space: nowrap; min-height: 36px; padding: .45rem .75rem; border-radius: 999px; color: var(--t2); }
.chip.active { color: var(--teal); border-color: var(--teal); background: rgba(45,212,191,.08); }

.field { display: grid; gap: .42rem; margin: 0 0 1rem; color: var(--t2); font-weight: 500; }
input, select, textarea {
  width: 100%; min-height: 46px; padding: .75rem .85rem; color: var(--t1); border: 1px solid var(--line2);
  border-radius: var(--r14); background: var(--s2); outline: 0;
}
textarea { min-height: 108px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(45,212,191,.1); }
.drop-zone { display: grid; place-items: center; gap: .35rem; min-height: 108px; text-align: center; border: 1px dashed var(--line2); border-radius: var(--r18); background: rgba(45,212,191,.025); }

.confidence-zone { margin-top: 1rem; }
.confidence-hint { color: var(--t2); text-align: center; }
.confidence-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: .55rem; }
.conf-btn { display: grid; justify-items: center; gap: .45rem; padding: .8rem .35rem; color: var(--t2); font-size: .72rem; }
.signal { display: flex; align-items: end; gap: 3px; height: 22px; }
.signal i { width: 5px; border-radius: 2px; background: var(--s3); border: 1px solid var(--line2); }
.signal i:nth-child(1) { height: 8px; }.signal i:nth-child(2) { height: 15px; }.signal i:nth-child(3) { height: 22px; }
.conf-btn[data-conf="chute"] .signal i:nth-child(1),
.conf-btn[data-conf="intuicao"] .signal i:nth-child(-n+2),
.conf-btn[data-conf="certeza"] .signal i { background: var(--teal); border-color: var(--teal); }
.review-card { display: grid; gap: 1.2rem; min-height: 230px; place-content: center; padding: 1.5rem; text-align: center; border: 1px solid var(--line2); border-radius: var(--r22); background: var(--s1); font: 700 1.35rem/1.35 var(--fd); }
.review-card .back { padding-top: 1.2rem; border-top: 1px solid var(--line); color: var(--t2); font: 400 1rem/1.55 var(--fb); }
.session-head { margin-bottom: .9rem; }
.progress { height: 4px; overflow: hidden; border-radius: 999px; background: var(--s3); }
.progress > div { height: 100%; background: var(--teal); transition: width .3s var(--ease); }
.progress-line { color: var(--t3); font: .7rem/1 var(--fm); }
.option { width: 100%; min-height: 54px; margin-bottom: .55rem; text-align: left; background: var(--s1); }
.option.selected { border-color: var(--teal); background: rgba(45,212,191,.08); }
.option.correct { color: var(--em); border-color: var(--em); }
.option.wrong { color: var(--ro); border-color: var(--ro); }
.feedback { margin-top: 1rem; padding: 1rem; border-radius: var(--r18); }
.feedback.good { border: 1px solid rgba(52,211,153,.3); background: rgba(52,211,153,.07); }
.feedback.bad { border: 1px solid rgba(244,63,94,.3); background: rgba(244,63,94,.07); }
.flag-misconception { display: flex; gap: .65rem; align-items: flex-start; padding: .85rem; margin-bottom: .8rem; color: var(--cr); border: 1px solid rgba(239,68,68,.3); border-radius: var(--r14); background: rgba(239,68,68,.07); }
.explain { margin-top: .8rem; color: var(--t2); }

.empty, .error-state { display: grid; justify-items: center; gap: .7rem; min-height: 300px; place-content: center; padding: 2rem; text-align: center; }
.empty-ic { display: grid; place-items: center; width: 64px; height: 64px; color: var(--teal); border: 1px solid var(--line); border-radius: 50%; background: var(--s1); }
.empty-ic .ic { width: 28px; height: 28px; }
.skeleton { overflow: hidden; position: relative; background: var(--s2); border-radius: var(--r18); min-height: 86px; }
.skeleton::after { content: ""; position: absolute; inset: 0; transform: translateX(-100%); background: linear-gradient(90deg,transparent,rgba(167,182,191,.08),transparent); animation: shimmer 1.5s infinite; }
.skeleton + .skeleton { margin-top: .75rem; }

.timeline { display: grid; gap: .8rem; margin-top: .9rem; }
.timeline-step { display: grid; grid-template-columns: 24px 1fr; gap: .7rem; color: var(--t3); }
.timeline-step.done { color: var(--em); }.timeline-step.active { color: var(--teal); }.timeline-step.error { color: var(--ro); }
.recording { display: grid; justify-items: center; gap: 1rem; padding: 1.2rem; border: 1px solid var(--line2); border-radius: var(--r18); background: var(--s1); }
.timer { font: 400 2rem/1 var(--fm); color: var(--teal); font-variant-numeric: tabular-nums; }
.wave { display: flex; align-items: center; gap: 4px; height: 42px; }
.wave i { width: 4px; height: 35%; border-radius: 4px; background: var(--teal); animation: wave 1s ease-in-out infinite alternate; }
.wave i:nth-child(2n) { animation-delay: -.35s; }.wave i:nth-child(3n) { animation-delay: -.65s; }

.md { color: var(--t2); max-width: 65ch; }
.md h1, .md h2, .md h3 { color: var(--t1); font-family: var(--fd); letter-spacing: -.025em; }
.md h2 { margin: 1.6rem 0 .5rem; }.md p { margin: .6rem 0; }.md li { margin: .3rem 0; }
.md blockquote { margin: 1rem 0; padding: .75rem 1rem; border-left: 2px solid var(--am); background: rgba(245,158,11,.05); }
.digest-grid { display: grid; gap: .75rem; }
.digest-card { padding: 1rem; border: 1px solid var(--line); border-radius: var(--r18); background: var(--s1); }
.digest-card.exam { border-color: rgba(245,158,11,.3); }
.topic-map { width: 100%; min-height: 220px; overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r22); background: radial-gradient(circle at center, rgba(45,212,191,.06), transparent 65%), var(--s1); }
.topic-map svg { display: block; width: 100%; min-width: 560px; height: auto; }
.topic-edge { stroke: var(--line2); stroke-width: 1.5; }
.topic-node circle { fill: var(--s3); stroke: var(--t3); stroke-width: 2; }
.topic-node text { fill: var(--t2); font: 12px var(--fb); text-anchor: middle; }
.topic-node.mastered circle { fill: rgba(245,158,11,.18); stroke: var(--am); }
.topic-node.learning circle { fill: rgba(45,212,191,.15); stroke: var(--teal); }
.topic-node.weak circle { fill: rgba(244,63,94,.08); stroke: var(--ro); }
.topic-legend { display: flex; flex-wrap: wrap; gap: .7rem; margin-top: .65rem; color: var(--t3); font-size: .72rem; }
.topic-legend span { display: inline-flex; align-items: center; gap: .35rem; }
.topic-legend i { width: 9px; height: 9px; border: 2px solid currentColor; border-radius: 50%; }

.tabbar {
  position: fixed; inset: auto 0 0; z-index: var(--z-nav); height: calc(var(--nav-h) + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(5,1fr); padding: .45rem .3rem env(safe-area-inset-bottom);
  background: color-mix(in srgb,var(--s1) 92%,transparent); backdrop-filter: blur(20px); border-top: 1px solid var(--line);
}
.tabbar a { display: grid; place-items: center; align-content: center; gap: .18rem; color: var(--t3); text-decoration: none; font-size: .64rem; border-radius: 12px; }
.tabbar a .ic { width: 21px; height: 21px; }
.tabbar a.active { color: var(--teal); background: rgba(45,212,191,.07); }
.desktop-rail { display: none; }

@keyframes shimmer { to { transform: translateX(100%); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes wave { to { height: 100%; opacity: .6; } }
@media (prefers-reduced-motion: no-preference) {
  #view.enter { animation: enter .28s var(--ease); }
  @keyframes enter { from { opacity: 0; transform: translateY(8px); } }
}
@media (prefers-reduced-motion: reduce) { *,*::before,*::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; } }
@media (min-width: 900px) {
  body { padding: 0 0 0 224px; }
  .topbar { padding-left: 1.5rem; }
  .tabbar { display: none; }
  .desktop-rail { position: fixed; inset: 0 auto 0 0; z-index: var(--z-nav); display: flex; flex-direction: column; width: 224px; padding: 1.4rem 1rem; border-right: 1px solid var(--line); background: var(--s1); }
  .desktop-rail .brand-lockup { margin: .25rem .55rem 2rem; }
  .desktop-rail nav { display: grid; gap: .4rem; }
  .desktop-rail a { display: flex; align-items: center; gap: .75rem; min-height: 46px; padding: .7rem .8rem; color: var(--t3); border-radius: var(--r14); text-decoration: none; }
  .desktop-rail a.active { color: var(--teal); background: rgba(45,212,191,.07); }
  #view { width: min(100% - 2rem, 980px); padding-top: 2rem; }
  .grid-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .stat-grid { grid-template-columns: repeat(4,minmax(0,1fr)); }
}
