@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@500&display=swap');

:root{
  --ink: #0f3b32;
  --ink-soft: #1c5346;
  --paper: #f6f2e9;
  --paper-raised: #ffffff;
  --rust: #c15a34;
  --rust-soft: #e2a184;
  --gold: #d4a24c;
  --line: #e2dbc9;
  --text: #23291f;
  --text-mute: #5c6357;
  --ok: #2f7a4f;
  --bad: #b3402c;
  --radius: 14px;
  --display: 'Fraunces', Georgia, serif;
  --body: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*{ box-sizing: border-box; }
html,body{ height: 100%; }
body{
  margin:0;
  font-family: var(--body);
  background: var(--ink);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

#app{
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--paper);
  display:flex;
  flex-direction: column;
  position: relative;
}

/* ---------- Header ---------- */
.topbar{
  background: var(--ink);
  color: var(--paper);
  padding: 18px 20px 16px;
  position: sticky;
  top:0;
  z-index: 20;
  overflow: hidden;
}
.topbar-deco{
  position:absolute;
  border-radius:50%;
  pointer-events:none;
}
.topbar-deco.a{ width:96px; height:96px; top:-46px; right:-16px; background: rgba(212,162,76,.16); }
.topbar-deco.b{ width:36px; height:36px; top:26px; right:64px; background: rgba(255,255,255,.06); }
.topbar .brand{
  font-family: var(--display);
  font-weight:600;
  font-size: 1.05rem;
  letter-spacing: .02em;
  display:flex;
  align-items:center;
  gap:8px;
}
.brand .mark{
  width:22px; height:22px;
  background: var(--rust);
  border-radius: 6px;
  display:inline-block;
}
.topbar .sub{
  font-size:.72rem;
  color: var(--rust-soft);
  margin-top:2px;
  text-transform: uppercase;
  letter-spacing:.09em;
}
.days-left{
  position:absolute;
  right:20px; top:16px;
  text-align:right;
  font-family: var(--mono);
}
.days-left b{ font-size:1.3rem; color:var(--gold); display:block; line-height:1; }
.days-left span{ font-size:.62rem; color:var(--rust-soft); text-transform:uppercase; letter-spacing:.07em; }

/* ---------- Main ---------- */
main{
  flex:1;
  padding: 18px 18px calc(90px + var(--safe-bottom));
}
.view{ animation: fade .18s ease; }
@keyframes fade{ from{opacity:0; transform:translateY(4px);} to{opacity:1; transform:none;} }

h1,h2,h3{ font-family: var(--display); color: var(--ink); margin:0 0 6px; }
h1{ font-size:1.5rem; font-weight:700; }
h2{ font-size:1.15rem; font-weight:600; }
h3{ font-size:1rem; font-weight:600; }
p{ line-height:1.55; color: var(--text); }
.mute{ color: var(--text-mute); font-size:.88rem; }
.eyebrow{
  font-family: var(--mono);
  font-size:.68rem;
  text-transform:uppercase;
  letter-spacing:.1em;
  color: var(--rust);
  margin-bottom:6px;
  display:block;
}

/* ---------- Cards ---------- */
.card{
  background: var(--paper-raised);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 14px;
}
.card.tap{ cursor:pointer; transition: transform .12s ease, box-shadow .12s ease; }
.card.tap:active{ transform: scale(.98); }
.card-row{ display:flex; align-items:center; justify-content:space-between; gap:10px; }

/* ---------- Buttons ---------- */
.btn{
  font-family: var(--body);
  font-weight:600;
  font-size:.9rem;
  border:none;
  border-radius: 10px;
  padding: 12px 18px;
  cursor:pointer;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:6px;
  transition: transform .1s ease, opacity .15s;
}
.btn:active{ transform: scale(.97); }
.btn-primary{ background: var(--rust); color:#fff; }
.btn-ghost{ background: transparent; color: var(--ink); border:1.5px solid var(--line); }
.btn-block{ width:100%; }
.btn-sm{ padding:8px 12px; font-size:.78rem; }
.btn[disabled]{ opacity:.4; pointer-events:none; }

/* ---------- Progress ---------- */
.progress-track{
  height:8px; background: var(--line); border-radius:6px; overflow:hidden;
}
.progress-fill{ height:100%; background: var(--ok); border-radius:6px; transition: width .3s ease; }
.progress-fill.low{ background: var(--bad); }
.progress-fill.mid{ background: var(--gold); }

.eixo-row{ padding:12px 0; border-bottom:1px solid var(--line); }
.eixo-row:last-child{ border-bottom:none; }
.eixo-top{ display:flex; justify-content:space-between; align-items:center; font-size:.85rem; margin-bottom:2px; }
.eixo-top b{ font-weight:600; display:flex; align-items:center; gap:7px; }
.eixo-icon{ font-size:1rem; line-height:1; }
.eixo-pct{ font-family:var(--mono); color:var(--text-mute); font-size:.78rem; }

.ring{ color: var(--ok); flex-shrink:0; }
.ring.mid{ color: var(--gold); }
.ring.low{ color: var(--bad); }
.ring text{ font-family: var(--mono); fill: var(--ink); }

/* ---------- Grid / stats ---------- */
.stat-grid{ display:grid; grid-template-columns:repeat(3,1fr); gap:10px; margin: 12px 0 16px; }
.stat{
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px;
  padding: 12px 10px;
  text-align:center;
}
.stat b{ font-family: var(--display); font-size:1.4rem; display:block; color: var(--gold); }
.stat span{ font-size:.62rem; text-transform:uppercase; letter-spacing:.06em; color: var(--rust-soft); }

/* ---------- Bottom nav ---------- */
nav.tabbar{
  position: fixed;
  left:50%; transform: translateX(-50%);
  bottom:0;
  width:100%; max-width:560px;
  background: var(--ink);
  display:flex;
  padding: 8px 6px calc(8px + var(--safe-bottom));
  z-index: 30;
  border-top: 1px solid rgba(255,255,255,.08);
}
nav.tabbar button{
  flex:1;
  background:none; border:none;
  color: rgba(246,242,233,.55);
  font-family: var(--body);
  font-size:.64rem;
  font-weight:600;
  display:flex; flex-direction:column; align-items:center; gap:4px;
  padding:6px 2px;
  cursor:pointer;
  border-radius:10px;
}
nav.tabbar button svg{ width:20px; height:20px; }
nav.tabbar button.active{ color: var(--gold); background: rgba(212,162,76,.12); }

/* ---------- Mapas ---------- */
.ramo{ margin-bottom:14px; }
.ramo h3{ color: var(--ink-soft); border-left:3px solid var(--rust); padding-left:9px; }
.ramo ul{ margin:6px 0 0; padding-left:18px; }
.ramo li{ margin-bottom:5px; font-size:.92rem; line-height:1.5; }

.pegadinha{
  background: #fdf3e9;
  border:1px solid var(--rust-soft);
  border-radius: 12px;
  padding: 13px 14px;
  margin-bottom:10px;
}
.pegadinha .num{
  display:inline-block; background:var(--rust); color:#fff;
  font-family:var(--mono); font-size:.68rem; padding:2px 7px; border-radius:20px; margin-bottom:6px;
}

/* ---------- Flashcard ---------- */
.flashcard-wrap{ perspective: 1200px; margin: 10px 0 18px; }
.flashcard{
  position:relative;
  min-height: 220px;
  border-radius: 16px;
  cursor:pointer;
  transform-style: preserve-3d;
  transition: transform .5s cubic-bezier(.2,.8,.2,1);
}
.flashcard.flipped{ transform: rotateY(180deg); }
.face{
  position:absolute; inset:0;
  border-radius:16px;
  backface-visibility: hidden;
  padding: 22px;
  display:flex; flex-direction:column; justify-content:center;
}
.face.front{ background: var(--ink); color:var(--paper); }
.face.back{ background: var(--rust); color:#fff; transform: rotateY(180deg); }
.face .label{ font-family:var(--mono); font-size:.65rem; text-transform:uppercase; letter-spacing:.1em; opacity:.7; margin-bottom:10px; }
.face p{ color:inherit; font-size:1.02rem; margin:0; }
.flash-controls{ display:flex; gap:10px; margin-top:12px; }

/* ---------- Quiz ---------- */
.quiz-meta{ display:flex; justify-content:space-between; font-size:.78rem; color:var(--text-mute); margin-bottom:10px; font-family:var(--mono); }
.option{
  display:block;
  width:100%;
  text-align:left;
  background: var(--paper-raised);
  border:1.5px solid var(--line);
  border-radius:12px;
  padding: 12px 14px;
  margin-bottom:9px;
  font-family: var(--body);
  font-size:.9rem;
  cursor:pointer;
  color: var(--text);
}
.option b{ color: var(--rust); margin-right:6px; }
.option.correct{ border-color: var(--ok); background:#eef7f0; }
.option.wrong{ border-color: var(--bad); background:#fbeeec; }
.option.disabled{ pointer-events:none; }
.explain{
  background:#eef4f1;
  border-left:3px solid var(--ok);
  border-radius:8px;
  padding:12px 14px;
  margin-top:8px;
  font-size:.87rem;
  line-height:1.5;
}
.explain.wrong-box{ border-left-color: var(--bad); background:#fdeeec; }

.filter-chip{
  display:inline-flex; align-items:center;
  padding:7px 12px; margin:0 6px 8px 0;
  border-radius:20px; border:1.5px solid var(--line);
  font-size:.78rem; font-weight:600; color:var(--text-mute);
  background:#fff; cursor:pointer;
}
.filter-chip.active{ background: var(--ink); color: var(--paper); border-color: var(--ink); }

/* ---------- Discursiva ---------- */
.timer{
  font-family:var(--mono); font-size:2rem; color:var(--ink); text-align:center;
  margin: 6px 0 2px;
}
textarea{
  width:100%; min-height:220px;
  font-family: var(--body); font-size:.92rem; line-height:1.6;
  border:1.5px solid var(--line); border-radius:12px; padding:14px;
  resize:vertical; background:#fff; color:var(--text);
}
.checklist-item{ display:flex; align-items:flex-start; gap:10px; padding:10px 0; border-bottom:1px solid var(--line); }
.checklist-item:last-child{ border-bottom:none; }
.seg{ display:flex; gap:6px; }
.seg button{
  flex:1; padding:7px 0; border-radius:8px; border:1.5px solid var(--line);
  background:#fff; font-size:.72rem; font-weight:700; cursor:pointer; color:var(--text-mute);
}
.seg button.sel-sim{ background:var(--ok); color:#fff; border-color:var(--ok); }
.seg button.sel-parcial{ background:var(--gold); color:#fff; border-color:var(--gold); }
.seg button.sel-nao{ background:var(--bad); color:#fff; border-color:var(--bad); }

/* ---------- Planner ---------- */
.week-head{
  display:flex; justify-content:space-between; align-items:center;
  cursor:pointer; padding:4px 0;
}
.day-row{ display:flex; align-items:flex-start; gap:10px; padding:9px 0; border-bottom:1px solid var(--line); }
.day-row:last-child{ border-bottom:none; }
.day-row input[type=checkbox]{ margin-top:3px; width:18px; height:18px; accent-color: var(--ok); flex-shrink:0;}
.day-name{ font-family:var(--mono); font-size:.68rem; text-transform:uppercase; color:var(--rust); display:block; margin-bottom:2px;}
.day-row.done .day-task{ text-decoration: line-through; color: var(--text-mute); }

/* ---------- Misc ---------- */
.divider{ height:1px; background:var(--line); margin:16px 0; border:none; }
.badge{
  display:inline-block; font-family:var(--mono); font-size:.65rem;
  padding:3px 8px; border-radius:20px; background: var(--ink); color: var(--gold);
  text-transform:uppercase; letter-spacing:.05em;
}
.badge.alt{ background: var(--rust); color:#fff; }
.empty{ text-align:center; padding: 40px 16px; color: var(--text-mute); }
.back-link{ display:inline-flex; align-items:center; gap:5px; color:var(--ink-soft); font-weight:600; font-size:.85rem; margin-bottom:14px; cursor:pointer; }

::selection{ background: var(--rust-soft); }

@media (min-width:560px){
  #app{ box-shadow: 0 0 60px rgba(0,0,0,.25); }
}

/* ---------- Autenticação ---------- */
.logout-btn{
  position:absolute; right:20px; bottom:8px;
  background:none; border:none; cursor:pointer;
  font-family: var(--body); font-size:.62rem; font-weight:600;
  text-transform:uppercase; letter-spacing:.06em;
  color: rgba(246,242,233,.4);
  padding:2px 0;
}
#auth-screen{
  min-height:100vh;
  display:flex;
  align-items:center;
  justify-content:center;
  background: var(--ink);
  padding: 24px;
}
.auth-box{
  width:100%; max-width:380px;
  background: var(--paper);
  border-radius: var(--radius);
  padding: 28px 24px;
}
.auth-logo{
  display:block; width:170px; max-width:70%; margin:0 auto 10px;
}
.brand-sub{
  text-align:center; font-family: var(--body); font-weight:600; font-size:.82rem;
  color: var(--text-mute); margin-bottom:22px;
}
.brand-logo{
  height:26px; width:auto; display:inline-block;
}
#auth-content h1{ font-size:1.3rem; margin-bottom:4px; }
#auth-content label{
  display:block; font-size:.78rem; font-weight:600; color: var(--text-mute);
  margin: 14px 0 5px;
}
#auth-content input{
  width:100%; padding:11px 13px;
  border:1.5px solid var(--line); border-radius:10px;
  font-family: var(--body); font-size:.92rem; background:#fff; color:var(--text);
}
#auth-content .btn{ margin-top:18px; }
.auth-link{
  display:block; width:100%; text-align:center; margin-top:14px;
  background:none; border:none; cursor:pointer;
  color: var(--ink-soft); font-weight:600; font-size:.82rem;
}
.auth-error{ color: var(--bad); font-size:.85rem; margin:8px 0 0; }
.auth-ok{ color: var(--ok); font-size:.85rem; margin:8px 0 0; }
