/* Visual baseado no app Beat: paleta vermelha (Tailwind red/gray), cards com
   borda suave, botões "elevados" e modo escuro em cinza. */

:root {
  --bg-from: #fef2f2;          /* red-50 */
  --bg-to: #fee2e2;            /* red-100 */
  --card: #ffffff;
  --card-border: #fecaca;      /* red-200 */
  --text: #0a0a0a;
  --muted: #6b7280;            /* gray-500 */
  --title: #991b1b;            /* red-800 */
  --heading: #b91c1c;          /* red-700 */
  --accent: #dc2626;           /* red-600 */
  --accent-soft: #fef2f2;      /* red-50 */
  --outline-border: #f87171;   /* red-400 */
  --outline-from: #fef2f2;
  --outline-to: #fee2e2;
  --outline-hover-from: #fee2e2;
  --outline-hover-to: #fecaca;
  --solid-from: #f87171;       /* red-400 */
  --solid-to: #ef4444;         /* red-500 */
  --solid-border: #ef4444;
  --input-bg: #ffffff;
  --input-border: #e5e5e5;
  --chip-bg: #ffffff;
  --well: #fef2f2;             /* red-50 */
  --good: #16a34a;             /* green-600 */
  --good-soft: #dcfce7;
  --bad: #dc2626;
  --bad-soft: #fee2e2;
  --warn: #d97706;
  --warn-soft: #fef3c7;
  --info: #2563eb;             /* blue-600 */
  --info-soft: #dbeafe;
  --shadow: 0 10px 15px -3px rgb(0 0 0 / .1), 0 4px 6px -4px rgb(0 0 0 / .1);
  --shadow-sm: 0 1px 3px 0 rgb(0 0 0 / .1), 0 1px 2px -1px rgb(0 0 0 / .1);
  --radius: 12px;
  --tabbar-h: 64px;
  color-scheme: light;
}

html.dark {
  --bg-from: #111827;          /* gray-900 */
  --bg-to: #1f2937;            /* gray-800 */
  --card: #0a0a0a;
  --card-border: #374151;      /* gray-700 */
  --text: #fafafa;
  --muted: #9ca3af;            /* gray-400 */
  --title: #fca5a5;            /* red-300 */
  --heading: #fca5a5;
  --accent: #f87171;
  --accent-soft: #1f2937;
  --outline-border: #f87171;
  --outline-from: #374151;     /* gray-700 */
  --outline-to: #1f2937;
  --outline-hover-from: #4b5563;
  --outline-hover-to: #374151;
  --input-bg: #111827;
  --input-border: #374151;
  --chip-bg: #1f2937;
  --well: #1f2937;
  --good-soft: #14532d;
  --bad-soft: #7f1d1d;
  --warn-soft: #78350f;
  --info-soft: #1e3a8a;
  --shadow: 0 10px 15px -3px rgb(0 0 0 / .4), 0 4px 6px -4px rgb(0 0 0 / .4);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body { margin: 0; min-height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-from), var(--bg-to)) fixed;
  background-color: var(--bg-from);
  min-height: 100dvh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  overscroll-behavior-y: none;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }
h2 { font-size: 18px; margin: 0 0 12px; color: var(--heading); font-weight: 600; letter-spacing: -.01em; }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.center-block { display: block; margin: 12px auto 0; }
.mt { margin-top: 8px; }
.warn { color: var(--warn); margin: 6px 0 0; }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 12px;
  padding: calc(12px + env(safe-area-inset-top)) 16px 12px;
  background: color-mix(in srgb, var(--bg-from) 85%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.topbar h1 { margin: 0; font-size: 28px; font-weight: 700; color: var(--title); flex: 1; letter-spacing: -.02em; }
.sun { display: none; }
html.dark .sun { display: block; }
html.dark .moon { display: none; }
.topbar { gap: 8px; }
.topbar h1 { font-size: 26px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Chave de idioma EN ⟷ PT (como no Beat: azul = EN, verde = PT) */
.lang-switch { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 700; color: #374151; cursor: pointer; }
html.dark .lang-switch { color: #d1d5db; }
.switch.lang { background: var(--info); }
html.dark .switch.lang { background: var(--info); }
.switch.lang:checked, html.dark .switch.lang:checked { background: var(--good); }

/* Painel de configurações (engrenagem) */
.settings-panel {
  position: absolute; top: calc(100% - 4px); right: 16px; z-index: 30;
  width: 320px; max-width: calc(100vw - 32px); overflow: hidden;
  border-radius: 8px; border: 2px solid #d1d5db; background: #e5e7eb;
  box-shadow: 0 25px 50px -12px rgb(0 0 0 / .25);
  animation: fade .15s ease-out;
}
html.dark .settings-panel { border-color: #4b5563; background: #374151; }
.settings-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; }
.settings-row + .settings-row { border-top: 2px solid #d1d5db; }
html.dark .settings-row + .settings-row { border-color: #4b5563; }
.settings-row label { font-size: 14px; font-weight: 600; color: #1f2937; cursor: pointer; }
html.dark .settings-row label { color: #e5e7eb; }
#settings-toggle[aria-expanded="true"] svg { transform: rotate(60deg); }
#settings-toggle svg { transition: transform .25s; }

main { max-width: 640px; margin: 0 auto; padding: 4px 16px 24px; }
.view { display: none; }
.view.active { display: block; animation: fade .18s ease-out; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* ---------- cards / painéis ---------- */
.panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  margin-bottom: 16px;
}

/* ---------- botões ---------- */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  width: 100%; min-height: 44px; padding: 10px 16px; margin-top: 10px;
  border-radius: 8px; border: 2px solid var(--outline-border);
  font-size: 15px; font-weight: 700;
  background: linear-gradient(to bottom, var(--outline-from), var(--outline-to));
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.btn:active { transform: translateY(2px); box-shadow: var(--shadow-sm); }
@media (hover: hover) { .btn:hover { background: linear-gradient(to bottom, var(--outline-hover-from), var(--outline-hover-to)); } }
.btn.primary {
  color: #fff; border-color: var(--solid-border);
  background: linear-gradient(to bottom, var(--solid-from), var(--solid-to));
}
@media (hover: hover) { .btn.primary:hover { background: linear-gradient(to bottom, #ef4444, #dc2626); } }
.btn.secondary { color: var(--heading); }
.btn.danger { color: #fff; border-color: #b91c1c; background: linear-gradient(to bottom, #ef4444, #b91c1c); }
.btn.big { min-height: 54px; font-size: 17px; }
.btn.small { width: auto; min-height: 38px; margin: 0; padding: 6px 12px; font-size: 14px; box-shadow: var(--shadow-sm); }
.file-btn { cursor: pointer; }

.icon-btn {
  position: relative; display: inline-grid; place-items: center;
  width: 40px; height: 40px; border-radius: 8px; flex-shrink: 0;
  border: 0; background: transparent; color: var(--heading);
}
.icon-btn.outline, .search-row .icon-btn {
  border: 2px solid var(--outline-border);
  background: linear-gradient(to bottom, var(--outline-from), var(--outline-to));
  box-shadow: var(--shadow-sm);
}
.icon-btn:active { transform: translateY(1px); }
.link-btn { border: 0; background: none; color: var(--accent); font-size: 15px; padding: 8px 4px; font-weight: 500; }
.link-btn.strong { font-weight: 700; }

.badge {
  position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 9px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; font-style: normal;
  display: grid; place-items: center; line-height: 1;
}

/* ---------- formulários ---------- */
.field { margin-bottom: 14px; }
.field > label, .filter-group > label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.field.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field.row > label { margin: 0; color: var(--text); font-size: 15px; font-weight: 500; }
.field.row input[type=number] { width: 80px; text-align: center; }
.field.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.field.two label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 6px; }
.input-row { display: flex; gap: 8px; align-items: center; }
.input-row input { flex: 1; min-width: 0; }

input:not([type=checkbox]):not([type=file]), select, textarea {
  width: 100%; padding: 10px 12px; border-radius: 8px;
  border: 1px solid var(--input-border); background: var(--input-bg);
  font-size: 16px; /* 16px evita zoom automático no iOS */
  outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--outline-border); box-shadow: 0 0 0 3px color-mix(in srgb, var(--outline-border) 25%, transparent); }
textarea { resize: vertical; }

.switch { appearance: none; width: 44px; height: 24px; border-radius: 12px; background: #d1d5db; position: relative; cursor: pointer; transition: background .2s; flex-shrink: 0; margin: 0; }
html.dark .switch { background: #4b5563; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-sm); transition: transform .2s; }
.switch:checked, html.dark .switch:checked { background: var(--info); }
.switch:checked::after { transform: translateX(20px); }

.seg { display: flex; gap: 6px; flex-wrap: wrap; }
.seg button {
  flex: 1; min-height: 40px; padding: 6px 10px; border-radius: 8px; font-size: 14px; font-weight: 600;
  border: 2px solid var(--input-border); background: var(--input-bg); white-space: nowrap;
}
.seg button.on { border-color: var(--outline-border); background: linear-gradient(to bottom, var(--outline-from), var(--outline-to)); color: var(--heading); }

/* ---------- chips ---------- */
.chips { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  border: 1.5px solid var(--input-border); background: var(--chip-bg);
  border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap;
}
.chip.on { border-color: var(--outline-border); background: var(--accent); color: #fff; }
.chip .n { opacity: .6; font-weight: 500; margin-left: 4px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- lista de palavras ---------- */
.search-row { display: flex; gap: 8px; margin: 4px 0 10px; }
.filters { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 14px; margin-bottom: 10px; box-shadow: var(--shadow-sm); }
.filter-group { margin-bottom: 12px; }
.word-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.word-item {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  padding: 14px 16px; box-shadow: var(--shadow-sm); cursor: pointer;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; align-items: start;
  transition: transform .1s;
}
.word-item:active { transform: scale(.99); }
.word-item .w { font-size: 17px; font-weight: 700; }
.word-item .pos { font-size: 12px; color: var(--muted); font-style: italic; margin-left: 6px; font-weight: 400; }
.word-item .m { grid-column: 1 / -1; color: var(--muted); font-size: 14px; }
.status { font-size: 11px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.status.new { background: var(--info-soft); color: var(--info); }
.status.learning { background: var(--warn-soft); color: var(--warn); }
.status.mastered { background: var(--good-soft); color: var(--good); }
html.dark .status { color: #fff; }

.fab {
  position: fixed; right: 20px; bottom: calc(var(--tabbar-h) + 20px + env(safe-area-inset-bottom));
  width: 60px; height: 60px; border-radius: 50%;
  border: 2px solid var(--solid-border); color: #fff; font-size: 34px; line-height: 1; font-weight: 300;
  background: linear-gradient(to bottom, var(--solid-from), var(--solid-to));
  box-shadow: 0 10px 25px -5px rgb(220 38 38 / .5);
  display: grid; place-items: center; padding-bottom: 4px; z-index: 5;
  transition: transform .15s;
}
.fab:active { transform: scale(.93); }

.empty { text-align: center; padding: 40px 16px; }
.empty-emoji { font-size: 56px; margin: 0 0 8px; }

/* ---------- estatísticas ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 8px; }
.stat { text-align: center; padding: 10px 4px; background: var(--well); border-radius: 8px; }
.stat b { display: block; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 24px; color: var(--heading); }
.stat span { font-size: 12px; color: var(--muted); line-height: 1.2; display: block; }

/* ---------- flashcard ---------- */
.progress { height: 6px; background: var(--card); border: 1px solid var(--card-border); border-radius: 3px; overflow: hidden; }
.progress > div { height: 100%; background: linear-gradient(to right, var(--solid-from), var(--solid-to)); width: 0; transition: width .3s; }
.flip-wrap { perspective: 1200px; margin: 12px 0 8px; }
.flashcard { position: relative; min-height: 340px; transform-style: preserve-3d; transition: transform .45s cubic-bezier(.3,.7,.3,1); cursor: pointer; }
.flashcard.flipped { transform: rotateY(180deg); }
.face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  background: var(--card); border: 1px solid var(--card-border); border-radius: 16px; box-shadow: var(--shadow);
  padding: 24px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; overflow-y: auto;
}
.face.back { transform: rotateY(180deg); justify-content: flex-start; }
.face .big-word { font-size: 32px; font-weight: 700; margin: 0; word-break: break-word; }
.face .phon { color: var(--muted); margin: 6px 0 0; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px; }
.face .posl { color: var(--heading); font-style: italic; font-size: 14px; margin-top: 8px; }
.face .meaning { font-size: 22px; font-weight: 700; color: var(--heading); margin: 4px 0 14px; }
.face .def { font-size: 15px; margin: 0 0 10px; }
.face .ex { font-size: 15px; font-style: italic; color: var(--muted); margin: 0 0 10px; border-left: 3px solid var(--card-border); padding-left: 10px; text-align: left; align-self: stretch; }
.face .ex mark { background: none; color: var(--heading); font-weight: 700; }
.face .note { font-size: 13px; background: var(--well); border-radius: 8px; padding: 8px 10px; align-self: stretch; text-align: left; }
.face .speak { margin-top: 14px; }
.face hr { border: 0; border-top: 1px solid var(--card-border); width: 100%; margin: 12px 0; }

.rate-buttons { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 8px; }
.rate-buttons.two { grid-template-columns: 1fr 1fr; }
.rate { border-radius: 10px; padding: 10px 4px; border: 2px solid; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: var(--shadow-sm); background: var(--card); }
.rate:active { transform: translateY(2px); }
.rate b { font-size: 14px; }
.rate.again { border-color: #f87171; color: #dc2626; }
.rate.good { border-color: #4ade80; color: #16a34a; }

/* ---------- jogo ---------- */
.play-game { display: flex; flex-direction: column; min-height: calc(100dvh - var(--tabbar-h) - 90px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); }
.play-hud { display: flex; justify-content: space-between; align-items: center; font-weight: 700; font-size: 15px; min-height: 32px; }
.play-hud > span:first-child, .play-hud > span:last-child { min-width: 80px; }
.play-hud > span:last-child { text-align: right; }
.hud-score { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 26px; color: var(--heading); }
.hud-score.bump { animation: bump .3s; }
@keyframes bump { 50% { transform: scale(1.35); } }
.play-card { background: var(--card); border: 1px solid var(--card-border); border-radius: 16px; box-shadow: var(--shadow); padding: 22px 16px; text-align: center; margin-top: 8px; }
.play-word-row { display: flex; align-items: center; justify-content: center; gap: 6px; }
.play-word { font-size: 28px; font-weight: 700; word-break: break-word; }
.play-hint { font-family: ui-monospace, Menlo, Consolas, monospace; letter-spacing: 3px; color: var(--muted); margin-top: 8px; min-height: 1.2em; font-size: 16px; }
.play-answer {
  margin-top: 12px; min-height: 52px; padding: 12px 14px; border-radius: 10px;
  background: var(--input-bg); border: 2px solid var(--input-border);
  font-size: 22px; font-weight: 600; text-align: center; word-break: break-word;
  transition: border-color .15s, background .15s;
}
.play-answer.ok { border-color: var(--good); background: var(--good-soft); }
.play-answer.almost { border-color: var(--warn); background: var(--warn-soft); }
.play-answer.bad { border-color: var(--bad); background: var(--bad-soft); animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.caret { display: inline-block; width: 2px; height: 1.05em; background: var(--accent); vertical-align: -3px; margin-left: 1px; animation: blink 1s steps(1) infinite; }
.play-answer.ok .caret, .play-answer.bad .caret, .play-answer.almost .caret { display: none; }
@keyframes blink { 50% { opacity: 0; } }
.play-feedback { min-height: 44px; padding: 8px 4px; text-align: center; font-size: 14px; }
.play-feedback b { color: var(--heading); }
.play-feedback .fb-ex { color: var(--muted); font-style: italic; display: block; margin-top: 2px; }

.keyboard { margin-top: auto; display: grid; gap: 6px; user-select: none; -webkit-user-select: none; touch-action: manipulation; }
.kb-row { display: flex; gap: 4px; justify-content: center; }
.key {
  flex: 1; max-width: 44px; height: 46px; border-radius: 6px; padding: 0;
  border: 1px solid var(--input-border); background: var(--card);
  font-size: 18px; font-weight: 500; box-shadow: 0 2px 0 var(--input-border);
  display: grid; place-items: center;
}
.key:active, .key.pressed { transform: translateY(2px); box-shadow: none; background: var(--well); }
.key.accent { height: 38px; font-size: 16px; background: var(--well); color: var(--heading); }
.key.wide { max-width: none; flex: 1.6; font-size: 14px; font-weight: 700; }
.key.space { max-width: none; flex: 4; font-size: 13px; color: var(--muted); }
.key.enter { max-width: none; flex: 2; color: #fff; border-color: var(--solid-border); background: linear-gradient(to bottom, var(--solid-from), var(--solid-to)); box-shadow: 0 2px 0 #b91c1c; font-size: 15px; font-weight: 700; }
.key.hint { color: var(--warn); }

.mistakes { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.mistakes li { background: var(--well); border-radius: 8px; padding: 10px 12px; font-size: 14px; }
.mistakes li b { display: block; }
.mistakes li s { color: var(--bad); }

/* ---------- barra de abas ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: var(--card); border-top: 1px solid var(--card-border);
}
.tabbar button { position: relative; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabbar button svg { width: 24px; height: 24px; }
.tabbar button.on { color: var(--accent); }
.tabbar .badge { top: 6px; right: calc(50% - 22px); }

/* ---------- folha (dialog) ---------- */
dialog.sheet {
  width: 100%; max-width: 640px; height: 100dvh; max-height: 100dvh; margin: 0 auto; padding: 0; border: 0;
  background: var(--bg-from); color: var(--text);
}
@media (min-width: 700px) { dialog.sheet { height: 90dvh; margin-top: 5dvh; border-radius: 16px; box-shadow: var(--shadow); } }
dialog.sheet[open] { animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
dialog::backdrop { background: rgb(0 0 0 / .45); }
.sheet form { display: flex; flex-direction: column; height: 100%; }
.sheet-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top)) 12px 8px; border-bottom: 1px solid var(--card-border); background: var(--card);
}
.sheet-head h2 { margin: 0; font-size: 17px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 16px calc(24px + env(safe-area-inset-bottom)); }

.suggestions { background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius); padding: 10px; margin-bottom: 14px; }
.suggestions p { margin: 0 0 8px; font-size: 13px; font-weight: 600; color: var(--muted); }
.sugg {
  display: block; width: 100%; text-align: left; border: 1px solid var(--input-border); background: var(--input-bg);
  border-radius: 8px; padding: 8px 10px; margin-bottom: 6px; font-size: 14px;
}
.sugg.on { border-color: var(--outline-border); background: var(--accent-soft); }
.sugg i { color: var(--heading); font-size: 12px; margin-right: 6px; }
.sugg small { display: block; color: var(--muted); font-style: italic; margin-top: 3px; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 24px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: #1f2937; color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow); transition: all .25s; max-width: calc(100vw - 32px); text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.face .ex .ex-tr { display: block; font-style: normal; font-size: 13px; margin-top: 4px; }
.sheet-head .head-spacer { display: block; width: 70px; }
.sheet-head .link-btn { width: 70px; text-align: left; }
.form-btn { max-width: 320px; margin: 12px auto 0; }
.rate { min-height: 48px; justify-content: center; }
.rate b { font-size: 15px; }
.rate.again.on { background: #dc2626; border-color: #dc2626; color: #fff; }
.rate.good.on { background: #16a34a; border-color: #16a34a; color: #fff; }

/* ---------- imagens ---------- */
.img-preview { position: relative; display: flex; align-items: flex-end; gap: 10px; margin-bottom: 8px; }
.img-preview img { width: 120px; height: 90px; object-fit: cover; border-radius: 8px; border: 1px solid var(--card-border); background: var(--well); }
.img-remove {
  position: absolute; top: -6px; left: 106px; width: 24px; height: 24px; border-radius: 50%;
  border: 0; background: var(--bad); color: #fff; font-size: 12px; line-height: 24px; padding: 0; box-shadow: var(--shadow-sm);
}
.img-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.img-grid button { padding: 0; border: 2px solid transparent; border-radius: 8px; overflow: hidden; background: var(--well); aspect-ratio: 4 / 3; }
.img-grid button.on { border-color: var(--outline-border); }
.img-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
#f-image-status { margin: 6px 0 0; }
.face .card-img { width: 100%; max-height: 130px; object-fit: cover; border-radius: 10px; margin-bottom: 12px; flex-shrink: 0; }
.word-item.has-img { grid-template-columns: 48px 1fr auto; }
.word-item .thumb { grid-row: 1 / span 2; width: 48px; height: 48px; object-fit: cover; border-radius: 8px; align-self: center; }
.word-item.has-img .m { grid-column: 2 / -1; }
.img-grid .no-img { display: grid; place-items: center; font-size: 13px; font-weight: 700; color: var(--muted); border: 2px dashed var(--input-border); background: var(--card); }
.img-grid .no-img.on { border-color: var(--outline-border); color: var(--heading); }

/* ---------- banner da BBC ---------- */
.bbc-banner {
  background: var(--card); border: 1px solid var(--card-border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 8px 0 10px; margin: 4px 0 12px; overflow: hidden;
}
.bbc-head { display: flex; align-items: center; gap: 8px; padding: 0 12px 6px; }
.bbc-badge { background: #bb1919; color: #fff; font-weight: 800; font-size: 11px; letter-spacing: .08em; padding: 3px 6px; border-radius: 3px; }
.bbc-title { flex: 1; font-size: 12px; color: var(--muted); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.bbc-count { font-size: 11px; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }

/* Uma palavra por vez */
.bbc-stage { overflow: hidden; padding: 0 12px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.bbc-card {
  display: block; width: 100%; min-height: 62px; padding: 2px 0 4px; border: 0; background: none;
  text-align: left; cursor: pointer; transition: transform .15s;
}
.bbc-w { display: block; font-size: 24px; font-weight: 800; color: var(--heading); letter-spacing: -.01em; }
.bbc-s {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: 13px; line-height: 1.35; color: var(--muted); margin-top: 2px;
}
.bbc-s mark { background: none; color: var(--heading); font-weight: 700; }
.bbc-card.in-next { animation: bbc-in-next .45s cubic-bezier(.2,.8,.2,1); }
.bbc-card.in-prev { animation: bbc-in-prev .45s cubic-bezier(.2,.8,.2,1); }
@keyframes bbc-in-next { from { opacity: 0; transform: translateX(48px); } to { opacity: 1; transform: none; } }
@keyframes bbc-in-prev { from { opacity: 0; transform: translateX(-48px); } to { opacity: 1; transform: none; } }

/* Barra de tempo (só no automático) */
.bbc-progress { height: 5px; margin: 8px 12px 0; border-radius: 2px; background: var(--well); overflow: hidden; }
.bbc-banner:not(.auto) .bbc-progress { display: none; }
#bbc-bar { height: 100%; width: 0; background: linear-gradient(to right, var(--solid-from), var(--solid-to)); }
#bbc-bar.run { animation: bbc-bar linear forwards; }
@keyframes bbc-bar { from { width: 0; } to { width: 100%; } }
@media (prefers-reduced-motion: reduce) { .bbc-card.in-next, .bbc-card.in-prev { animation: none; } }
.settings-row input:disabled { opacity: .4; }
/* Sem contorno de foco nem arraste de texto/imagem ao tocar ou arrastar o banner */
.bbc-card, .bbc-card:focus, .bbc-card:focus-visible, .bbc-stage:focus { outline: none; }
.bbc-card * { -webkit-user-drag: none; pointer-events: none; }
mark { background: none; color: inherit; }
.seg.period { display: grid; grid-template-columns: repeat(3, 1fr); }
.settings-row.column { flex-direction: column; align-items: stretch; gap: 8px; }
.settings-row .seg button { min-height: 34px; font-size: 13px; padding: 4px 6px; }
.seg button:disabled { opacity: .4; }
.cefr { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.cefr-group { display: flex; flex-direction: column; gap: 4px; }
.cefr-group > span { font-size: 11px; font-weight: 700; color: #6b7280; text-align: center; }
html.dark .cefr-group > span { color: #9ca3af; }
.cefr .seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.cefr .seg button { padding: 4px 0; font-weight: 700; }
.credits { margin-top: 4px; line-height: 1.4; }
.credits a { color: inherit; }
/* Itens do mesmo grupo (banner) sem linha divisória entre eles */
.settings-row.grouped, html.dark .settings-row.grouped { border-top: none; padding-top: 0; }

/* Marcações opcionais: "Difícil" (vermelho) e "Dominada" (verde), liga/desliga */
.mark-toggles { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 4px 0 0; }
.mark-toggle {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 8px 12px; border-radius: 10px; border: 2px solid; background: var(--card);
  font-size: 14px; box-shadow: var(--shadow-sm);
}
.mark-toggle.hard { border-color: #f87171; color: #dc2626; }
.mark-toggle.mastered { border-color: #4ade80; color: #16a34a; }
.mark-toggle .box { width: 18px; height: 18px; border-radius: 5px; border: 2px solid currentColor; display: grid; place-items: center; }
.mark-toggle.on { color: #fff; }
.mark-toggle.hard.on { background: #dc2626; border-color: #dc2626; }
.mark-toggle.mastered.on { background: #16a34a; border-color: #16a34a; }
.mark-toggle.on .box::after { content: "✓"; font-size: 12px; font-weight: 800; line-height: 1; }
.mark-toggle:active { transform: translateY(1px); }
html.dark .mark-toggle.hard:not(.on) { color: #f87171; }
html.dark .mark-toggle.mastered:not(.on) { color: #4ade80; }
/* Encerrar: vermelho, afastado dos botões de resposta para evitar toque sem querer */
.quit-btn { width: calc(50% - 4px); min-height: 44px; margin: 32px auto 0; }

/* ---------- abas das configurações ---------- */
.settings-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 2px solid #d1d5db; }
html.dark .settings-tabs { border-color: #4b5563; }
.settings-tabs button { border: 0; background: none; padding: 10px; font-size: 14px; font-weight: 700; color: #6b7280; border-bottom: 3px solid transparent; margin-bottom: -2px; }
.settings-tabs button.on { color: var(--heading); border-bottom-color: var(--accent); }
.settings-panel { max-height: calc(100dvh - 90px); overflow-y: auto; }
.backup-tab { padding: 12px 16px 16px; }
.backup-tab .btn { margin-top: 8px; box-shadow: var(--shadow-sm); }
.settings-hint { margin: 0 0 6px; font-size: 12px; color: #6b7280; }
.settings-hint.strong { color: #1f2937; font-weight: 600; }
html.dark .settings-hint { color: #9ca3af; }
html.dark .settings-hint.strong { color: #e5e7eb; }

/* ---------- gráficos ---------- */
:root { --viz-1: #2a78d6; --viz-2: #eb6834; --viz-grid: #e1e0d9; --viz-axis: #c3c2b7; }
html.dark { --viz-1: #3987e5; --viz-2: #d95926; --viz-grid: #2c2c2a; --viz-axis: #383835; }
.viz-1 { background: var(--viz-1); }
.viz-2 { background: var(--viz-2); }
.chart-sub { margin: -8px 0 10px; font-size: 12px; color: var(--muted); }
.chart-empty { margin: 4px 0; font-size: 14px; color: var(--muted); }
.chart-filters { display: grid; gap: 8px; margin: 4px 0 12px; }
.chart-filters .seg button { min-height: 36px; }
.stat-grid.four { grid-template-columns: repeat(4, 1fr); margin-bottom: 16px; }
.stat-grid.four .stat b { font-size: 20px; }

.legend { display: flex; gap: 14px; font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.legend span { display: flex; align-items: center; gap: 6px; }
.legend .sw { width: 10px; height: 10px; border-radius: 2px; }

/* Colunas: área de 140px, linhas de grade finas, colunas de até 24px com topo arredondado */
.cols { position: relative; height: 140px; display: grid; grid-template-columns: repeat(var(--n), 1fr); align-items: end; padding-left: 26px; }
.cols .grid { position: absolute; inset: 0 0 0 0; display: flex; flex-direction: column; justify-content: space-between; pointer-events: none; }
.cols .grid div { border-top: 1px solid var(--viz-grid); height: 0; position: relative; }
.cols .grid div:last-child { border-top-color: var(--viz-axis); }
.cols .grid span { position: absolute; left: 0; top: -7px; font-size: 10px; color: var(--muted); font-variant-numeric: tabular-nums; }
.col { position: relative; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; border: 0; background: none; padding: 0; cursor: pointer; }
.col .bar { position: relative; width: min(24px, 70%); display: flex; }
.col .stack { flex: 1; display: flex; flex-direction: column-reverse; gap: 2px; border-radius: 4px 4px 0 0; overflow: hidden; }
.col .seg { display: block; min-height: 2px; }
.col em { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); margin-bottom: 3px; font-style: normal; font-size: 11px; font-weight: 700; color: var(--text); line-height: 1; }
.col:hover .stack, .col:focus-visible .stack { filter: brightness(1.12); }
.col:focus-visible { outline: 2px solid var(--viz-1); outline-offset: 2px; }
.xlabels { display: grid; grid-template-columns: repeat(var(--n), 1fr); padding-left: 26px; margin-top: 4px; }
.xlabels span { font-size: 10px; color: var(--muted); text-align: center; white-space: nowrap; }

/* Barras horizontais: rótulo | trilho | valor */
.hbars { display: grid; gap: 10px; }
.hbar { display: grid; grid-template-columns: minmax(80px, 34%) 1fr auto; align-items: center; gap: 10px; outline: none; }
.hb-label { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hb-track { height: 14px; background: var(--well); border-radius: 0 4px 4px 0; }
.hb-fill { display: block; height: 100%; border-radius: 0 4px 4px 0; min-width: 2px; }
.hb-value { font-size: 13px; font-weight: 700; text-align: right; min-width: 44px; font-variant-numeric: tabular-nums; }
.hb-value small { display: block; font-size: 10px; font-weight: 500; color: var(--muted); }
.hbar:hover .hb-fill, .hbar:focus-visible .hb-fill { filter: brightness(1.12); }

.data-table { margin-top: 12px; font-size: 13px; }
.data-table summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.data-table table { width: 100%; border-collapse: collapse; margin-top: 8px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--viz-grid); }
.data-table th:first-child, .data-table td:first-child { text-align: left; }

.chart-tip {
  position: fixed; z-index: 200; pointer-events: none; opacity: 0; transition: opacity .12s;
  background: var(--card); color: var(--text); border: 1px solid var(--card-border); border-radius: 8px;
  padding: 8px 10px; font-size: 12px; line-height: 1.5; box-shadow: var(--shadow); max-width: 220px;
}
.chart-tip.show { opacity: 1; }
.chart-tip b { font-size: 14px; }
.chart-tip .k { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 6px; }
.rate:disabled { opacity: .35; box-shadow: none; cursor: not-allowed; transform: none; }
