:root {
  --bg: #f4f7fb; --surface: #fff; --text: #1d2433; --muted: #6b7486; --line: #e4e9f1;
  --brand: #1ba1e2; --brand-dark: #0b7fb8; --brand-soft: #e3f4fd;
  --green: #22a565; --orange: #f08c1a; --red: #e5484d;
  --radius: 14px; --shadow: 0 6px 24px rgba(20, 40, 80, .10);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.45; }
a { color: var(--brand-dark); }
.hidden { display: none !important; }

.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.logo { font-weight: 800; font-size: 20px; text-decoration: none; color: var(--text); white-space: nowrap; }
.logo span { color: var(--brand); }
nav { display: flex; align-items: center; gap: 14px; }
nav a { text-decoration: none; color: var(--text); font-weight: 600; font-size: 15px; white-space: nowrap; }
nav a.active { color: var(--brand); }
.badge { background: var(--red); color: #fff; border-radius: 999px; padding: 1px 7px; font-size: 12px; margin-left: 2px; }

main { max-width: 980px; margin: 0 auto; padding: 20px 16px 80px; }

.btn { border: 0; border-radius: 999px; padding: 11px 20px; font-weight: 700; font-size: 15px; cursor: pointer;
  background: var(--brand); color: #fff; transition: .15s; }
.btn:hover { background: var(--brand-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.small { padding: 7px 14px; font-size: 14px; }
.btn.ghost { background: var(--brand-soft); color: var(--brand-dark); }
.btn.ghost:hover { background: #cfeafa; }
.btn.block { width: 100%; }
.btn.green { background: var(--green); }
.btn.outline { background: transparent; border: 1.5px solid var(--line); color: var(--text); }

input, textarea { width: 100%; font: inherit; padding: 12px 14px; border: 1.5px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); }
input:focus, textarea:focus { outline: none; border-color: var(--brand); }
label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 6px; }
.error { color: var(--red); font-size: 14px; min-height: 20px; margin-top: 8px; }
.muted { color: var(--muted); }

/* Início */
.hero { text-align: center; padding: 28px 0 10px; }
.hero h1 { font-size: clamp(26px, 5vw, 40px); margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0 auto 22px; max-width: 560px; }
.url-form { display: flex; gap: 8px; max-width: 640px; margin: 0 auto; }
.url-form input { border-radius: 999px; padding-left: 20px; }
.manual { max-width: 640px; margin: 12px auto 0; font-size: 14px; }
.manual summary { cursor: pointer; color: var(--muted); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 30px; }
.video-card { position: relative; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; color: var(--text); transition: transform .15s; }
.video-card:hover { transform: translateY(-3px); }
.video-card img { width: 100%; aspect-ratio: 16/9; object-fit: cover; display: block; }
.video-card div { padding: 10px 12px; font-weight: 600; font-size: 14px; }
.video-card small { display: block; color: var(--muted); font-weight: 400; margin-top: 2px; }
.section-title { margin: 36px 0 0; font-size: 18px; }

/* Assistir */
.watch { max-width: 560px; margin: 0 auto; }
.player-wrap { position: sticky; top: 57px; z-index: 10; background: #000; border-radius: var(--radius) var(--radius) 0 0; overflow: hidden; }
.player-ratio { position: relative; aspect-ratio: 16/9; }
.player-ratio > * { position: absolute; inset: 0; width: 100%; height: 100%; }
.controls { position: sticky; top: calc(57px + 56.25vw); display: flex; justify-content: center; gap: 10px; padding: 8px; background: var(--surface); border-bottom: 1px solid var(--line); z-index: 9; }
@media (min-width: 560px) { .controls { top: calc(57px + 315px); } }
.round { width: 46px; height: 46px; border-radius: 50%; border: 0; background: var(--surface); box-shadow: 0 2px 8px rgba(0,0,0,.15); font-size: 20px; cursor: pointer; display: grid; place-items: center; }
.round.on { background: var(--brand-soft); outline: 2px solid var(--brand); }
.round .speed { font-size: 11px; font-weight: 700; color: var(--brand-dark); }
.transcript { background: var(--surface); border-radius: 0 0 var(--radius) var(--radius); box-shadow: var(--shadow); padding: 6px 0; }
.line { display: flex; gap: 8px; align-items: flex-start; padding: 9px 14px; font-size: 18px; border-left: 3px solid transparent; transition: background .2s; }
.line.active { background: var(--brand-soft); border-left-color: var(--brand); }
.line .say { flex: none; border: 0; background: none; cursor: pointer; font-size: 17px; color: var(--brand); padding: 2px; opacity: .7; }
.line .say:hover { opacity: 1; }
.w { cursor: pointer; border-radius: 4px; padding: 0 1px; }
.w:hover { background: #fff3c4; }
.w.saved { border-bottom: 2px solid var(--green); }
.w.picked { background: #ffe58a; }
.video-title { padding: 12px 4px; }
.video-title h2 { margin: 0; font-size: 18px; }

/* Painel da palavra */
.sheet { position: fixed; inset: auto 0 0 0; z-index: 40; display: flex; justify-content: center; padding: 0 10px 10px; pointer-events: none; }
.sheet-card { pointer-events: auto; position: relative; width: 100%; max-width: 540px; max-height: 70vh; overflow: auto; background: var(--surface);
  border-radius: 18px; box-shadow: 0 -6px 40px rgba(0,0,0,.25); padding: 20px; animation: up .2s ease-out; }
@keyframes up { from { transform: translateY(30px); opacity: 0; } }
.close { position: absolute; top: 8px; right: 12px; border: 0; background: none; font-size: 28px; cursor: pointer; color: var(--muted); }
.word-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.word-head h3 { margin: 0; font-size: 28px; }
.phon { color: var(--muted); }
.speak { border: 0; background: var(--brand-soft); color: var(--brand-dark); border-radius: 999px; padding: 6px 12px; cursor: pointer; font-weight: 600; }
.translation { font-size: 22px; font-weight: 700; color: var(--brand-dark); margin: 8px 0; }
.sentence { background: var(--bg); border-radius: 10px; padding: 10px 12px; margin: 10px 0; }
.sentence mark { background: #ffe58a; border-radius: 3px; }
.sentence .pt { color: var(--muted); font-size: 14px; margin-top: 4px; }
.defs { margin: 8px 0 14px; padding: 0; list-style: none; font-size: 15px; }
.defs li { margin: 6px 0; }
.pos { display: inline-block; font-size: 12px; font-weight: 700; text-transform: uppercase; color: var(--orange); margin-right: 6px; }
.defs em { color: var(--muted); display: block; font-size: 14px; }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 50; background: rgba(15, 25, 45, .5); display: grid; place-items: center; padding: 16px; }
.modal-card { position: relative; width: 100%; max-width: 400px; background: var(--surface); border-radius: 18px; padding: 26px 22px; box-shadow: var(--shadow); }
.modal-card h2 { margin: 0 0 6px; }
.tabs { display: flex; gap: 6px; background: var(--bg); padding: 4px; border-radius: 999px; margin: 14px 0; }
.tabs button { flex: 1; border: 0; background: none; padding: 8px; border-radius: 999px; font-weight: 700; cursor: pointer; color: var(--muted); }
.tabs button.on { background: var(--surface); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,.1); }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 14px 0; }
#googleBtn { display: flex; justify-content: center; min-height: 44px; }
.code-input { text-align: center; font-size: 28px; letter-spacing: 10px; font-weight: 700; }
.linkbtn { border: 0; background: none; color: var(--brand-dark); cursor: pointer; font: inherit; text-decoration: underline; padding: 0; }

/* Cards */
.stats { display: flex; gap: 12px; flex-wrap: wrap; margin: 10px 0 20px; }
.stat { flex: 1; min-width: 140px; background: var(--surface); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.stat b { display: block; font-size: 28px; }
.card-list { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.card-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.card-row:last-child { border-bottom: 0; }
.card-row .grow { flex: 1; min-width: 0; }
.card-row .grow small { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { border: 0; background: none; cursor: pointer; font-size: 18px; padding: 4px; }

/* Estudo */
.study { max-width: 520px; margin: 0 auto; }
.progress { height: 6px; background: var(--line); border-radius: 999px; overflow: hidden; margin-bottom: 16px; }
.progress div { height: 100%; background: var(--green); transition: width .3s; }
.flash { background: var(--surface); border-radius: 20px; box-shadow: var(--shadow); padding: 28px 22px; text-align: center; min-height: 320px; display: flex; flex-direction: column; }
.flash h2 { font-size: 38px; margin: 6px 0; }
.flash .sentence { text-align: left; }
.flash .answer { border-top: 1px dashed var(--line); margin-top: 14px; padding-top: 14px; }
.flash .grow { flex: 1; }
.grades { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 16px; }
.grades button { border: 0; border-radius: 12px; padding: 12px 4px; font-weight: 700; cursor: pointer; color: #fff; font-size: 14px; }
.grades small { display: block; font-weight: 400; opacity: .85; font-size: 12px; }
.g0 { background: var(--red); } .g1 { background: var(--orange); } .g2 { background: var(--green); } .g3 { background: var(--brand); }
.mini-player { margin-top: 12px; border-radius: 12px; overflow: hidden; aspect-ratio: 16/9; background: #000; }
.mini-player iframe { width: 100%; height: 100%; border: 0; }
.empty { text-align: center; padding: 40px 10px; }
.empty .big { font-size: 56px; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 999px; z-index: 60; font-weight: 600; font-size: 14px; }
.spinner { width: 28px; height: 28px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 20px auto; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  nav { gap: 10px; } nav a { font-size: 14px; }
  .logo { font-size: 17px; }
  .url-form { flex-direction: column; }
  .line { font-size: 17px; }
  main { padding-top: 12px; }
  .watch { margin: 0 -16px; } .player-wrap { border-radius: 0; } .transcript { border-radius: 0; }
}
#googleBtn:empty { display: none; }
.del-video { position: absolute; top: 8px; right: 8px; z-index: 2; border: 0; border-radius: 999px; background: rgba(255,255,255,.92);
  width: 34px; height: 34px; cursor: pointer; font-size: 16px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.del-video:hover { background: #ffe1e1; }
