:root {
  --primary: #4255ff;
  --primary-dark: #2f3bd9;
  --ink: #172033;
  --muted: #64748b;
  --line: #e2e8f0;
  --soft: #f8fafc;
  --card: #ffffff;
  --green: #059669;
  --red: #e11d48;
  --amber: #d97706;
  --violet: #7c3aed;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; background: #f6f7fb; color: var(--ink); }
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.topbar {
  position: sticky; top: 0; z-index: 20; height: 68px; background: rgba(255,255,255,.94);
  border-bottom: 1px solid var(--line); backdrop-filter: blur(12px);
}
.topbar-inner { max-width: 1120px; margin: 0 auto; padding: 0 20px; height: 100%; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 22px; font-weight: 900; color: var(--primary); }
.brand-mark { width: 38px; height: 38px; border-radius: 8px; background: var(--primary); color: white; display: grid; place-items: center; font-weight: 900; }
.nav { display: flex; gap: 6px; }
.nav button { border: 0; background: transparent; color: var(--muted); padding: 10px 14px; border-radius: 8px; font-weight: 800; }
.nav button.active { background: #eef2ff; color: var(--primary); }
.streak { border-radius: 999px; padding: 8px 12px; background: #fff7ed; color: #ea580c; font-weight: 900; }

.shell { max-width: 1120px; margin: 0 auto; padding: 28px 20px 56px; }
.page-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.head-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.eyebrow { margin: 0 0 5px; color: var(--muted); font-size: 13px; font-weight: 800; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 29px; line-height: 1.15; }
h2 { font-size: 24px; margin-bottom: 12px; }
.muted { color: var(--muted); }

.grid { display: grid; gap: 16px; }
.dashboard { grid-template-columns: 1.15fr .85fr; align-items: start; }
.cards-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.decks { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 8px 24px rgba(15,23,42,.05);
}
.panel { padding: 22px; }
.hero-study { min-height: 520px; display: flex; flex-direction: column; }
.task-list { display: grid; gap: 12px; }
.task-item {
  display: grid; grid-template-columns: 1fr minmax(220px, 300px) 104px; align-items: center; gap: 18px;
  padding: 18px; box-shadow: 0 8px 24px rgba(15,23,42,.04);
}
.task-item.done { background: #fbfdff; }
.task-main { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 14px; min-width: 0; }
.task-main h2 { margin: 0 0 6px; font-size: 20px; line-height: 1.25; }
.task-main p { margin: 0; color: var(--muted); line-height: 1.45; }
.task-progress { display: grid; gap: 8px; }
.task-count { display: flex; align-items: baseline; gap: 8px; justify-content: flex-end; }
.task-count strong { font-size: 34px; line-height: 1; font-weight: 950; color: var(--ink); }
.task-count span { color: var(--muted); font-size: 12px; font-weight: 900; }
.task-meta { color: var(--muted); font-size: 12px; font-weight: 750; text-align: right; }
.task-switcher { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: -4px 0 18px; }
.task-tab {
  min-height: 98px; border: 1px solid var(--line); border-radius: 8px; background: white; padding: 13px;
  display: flex; flex-direction: column; justify-content: space-between; gap: 10px; text-align: left; color: var(--ink);
  box-shadow: 0 8px 24px rgba(15,23,42,.04);
}
.task-tab:hover { border-color: #a5b4fc; background: #fbfcff; }
.task-tab.active { border-color: var(--primary); box-shadow: inset 0 0 0 1px var(--primary), 0 12px 26px rgba(66,85,255,.12); }
.task-tab > span { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.task-tab strong { font-size: 15px; line-height: 1.25; }
.task-tab small { color: var(--muted); line-height: 1.35; font-weight: 750; }
.progress-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.bar { height: 10px; flex: 1; background: #e5e7eb; border-radius: 999px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--primary); border-radius: inherit; transition: width .25s ease; }
.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 5px 10px; font-size: 12px; font-weight: 900; background: #eef2ff; color: var(--primary); }
.pill.vocab { background: #f3e8ff; color: #7c3aed; }
.pill.grammar { background: #fef3c7; color: #b45309; }
.pill.translation { background: #dcfce7; color: #15803d; }
.pill.reading { background: #e0f2fe; color: #0369a1; }
.question-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: 26px; }
.prompt { font-size: 25px; line-height: 1.42; font-weight: 900; margin-bottom: 24px; }
.options { display: grid; gap: 12px; }
.option {
  width: 100%; border: 2px solid var(--line); background: white; border-radius: 8px; padding: 14px;
  display: flex; gap: 12px; align-items: center; text-align: left; transition: .16s ease;
}
.option:hover { border-color: var(--primary); background: #f8f9ff; }
.option.selected { border-color: var(--primary); background: #eef2ff; }
.option.correct { border-color: #34d399; background: #ecfdf5; }
.option.wrong { border-color: #fb7185; background: #fff1f2; }
.key { width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line); display: grid; place-items: center; font-weight: 900; background: white; flex: 0 0 auto; }
.fill-input { width: 100%; border: 2px solid var(--line); border-radius: 8px; padding: 15px; outline: 0; font-weight: 800; }
.fill-input:focus { border-color: var(--primary); }
.feedback { margin-top: 18px; padding: 16px; border-radius: 8px; display: flex; gap: 10px; line-height: 1.55; }
.feedback.ok { background: #ecfdf5; color: #065f46; }
.feedback.bad { background: #fff1f2; color: #9f1239; }
.actions { margin-top: auto; padding-top: 22px; border-top: 1px solid #eef2f7; display: flex; gap: 12px; }
.btn {
  border: 0; border-radius: 8px; padding: 12px 16px; font-weight: 900; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn.primary { background: var(--primary); color: white; }
.btn.primary:hover { background: var(--primary-dark); }
.btn.dark { background: #111827; color: white; }
.btn.soft { background: #f1f5f9; color: #334155; }
.btn.outline { background: white; border: 1px solid var(--line); color: #334155; }
.btn.green { background: var(--green); color: white; }
.wide { width: 100%; }

.side-stack { display: grid; gap: 16px; }
.kpi { padding: 18px; }
.kpi-label { color: var(--muted); font-size: 12px; font-weight: 800; margin-bottom: 6px; }
.kpi-value { font-size: 27px; font-weight: 950; }
.deck-card { padding: 18px; min-height: 150px; display: flex; flex-direction: column; justify-content: space-between; }
.deck-card h3 { margin-bottom: 6px; }
.deck-count { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.search { flex: 1; min-width: 240px; border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; outline: 0; }
.select { border: 1px solid var(--line); border-radius: 8px; padding: 11px 13px; background: white; }
.table { overflow: hidden; }
.item-row { display: grid; grid-template-columns: 100px 1fr 155px 92px 34px; gap: 14px; align-items: center; padding: 15px 18px; border-top: 1px solid #eef2f7; }
.item-row:first-child { border-top: 0; }
.item-title { font-weight: 900; line-height: 1.35; }
.item-sub { color: var(--muted); font-size: 12px; margin-top: 4px; }
.due { font-size: 12px; font-weight: 900; border-radius: 8px; padding: 7px 9px; background: #f1f5f9; color: #475569; text-align: center; }
.due.today { background: #fff7ed; color: #ea580c; }

.banner { background: linear-gradient(135deg, #6d5dfc, #4255ff 54%, #0083b8); color: white; padding: 20px; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; gap: 18px; margin-bottom: 16px; }
.banner p { margin: 0; color: rgba(255,255,255,.82); }

.chart { height: 235px; display: flex; align-items: end; gap: 12px; padding-top: 28px; }
.bar-col { flex: 1; display: flex; flex-direction: column; gap: 8px; align-items: center; height: 100%; }
.bar-fill { width: 100%; max-width: 52px; background: #c7d2fe; border-radius: 8px 8px 0 0; min-height: 8px; }
.bar-fill.today { background: var(--primary); }
.bar-label { font-size: 12px; color: var(--muted); }

.modal-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .55); z-index: 50; display: grid; place-items: center; padding: 18px; }
.modal { width: min(720px, 100%); max-height: 92vh; overflow: auto; background: white; border-radius: 8px; box-shadow: 0 24px 80px rgba(15,23,42,.35); }
.modal-head { padding: 18px 22px; border-bottom: 1px solid #eef2f7; display: flex; justify-content: space-between; align-items: center; }
.modal-body { padding: 20px 22px; }
.modal-task-select { display: grid; gap: 8px; margin-bottom: 16px; }
.modal-task-select span { color: var(--muted); font-size: 12px; font-weight: 900; }
.modal-task-select .select { width: 100%; }
.steps { display: flex; gap: 10px; align-items: center; color: var(--muted); font-size: 12px; font-weight: 900; margin-bottom: 18px; }
.steps .active { color: var(--primary); }
.textarea { width: 100%; min-height: 150px; resize: vertical; border: 2px solid var(--line); border-radius: 8px; padding: 13px; outline: 0; line-height: 1.55; }
.textarea:focus, .field:focus { border-color: var(--primary); }
.drop { width: 100%; border: 2px dashed #cbd5e1; border-radius: 8px; padding: 26px; text-align: center; color: var(--muted); background: #fbfdff; }
.file-list { display: grid; gap: 8px; margin-top: 12px; }
.file-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--soft); }
.draft { border: 1px solid var(--line); border-radius: 8px; padding: 14px; display: grid; gap: 10px; }
.draft-head { display: flex; justify-content: space-between; gap: 10px; }
.field { width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; outline: 0; }
.hint { border-radius: 8px; padding: 12px; background: #f5f3ff; color: #5b21b6; font-size: 13px; line-height: 1.5; }
.success { background: #ecfdf5; color: #065f46; }
.error { background: #fff1f2; color: #9f1239; }
.spinner { width: 56px; height: 56px; border-radius: 50%; border: 5px solid #e0e7ff; border-top-color: var(--primary); animation: spin 1s linear infinite; margin: 32px auto 16px; }
@keyframes spin { to { transform: rotate(360deg); } }
.empty { text-align: center; color: var(--muted); padding: 34px; }

@media (max-width: 840px) {
  .topbar-inner { padding: 0 14px; }
  .brand span { display: none; }
  .nav button { padding: 9px 10px; }
  .dashboard, .cards-4, .decks { grid-template-columns: 1fr; }
  .task-item { grid-template-columns: 1fr; align-items: stretch; }
  .task-count, .task-meta { justify-content: flex-start; text-align: left; }
  .task-switcher { grid-template-columns: 1fr; }
  .page-head { align-items: stretch; flex-direction: column; }
  .head-actions { justify-content: flex-start; }
  .item-row { grid-template-columns: 1fr; gap: 8px; }
  .banner { align-items: stretch; flex-direction: column; }
  .prompt { font-size: 21px; }
}
