:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --text: #111827;
  --muted: #6b7280;
  --primary: #4f46e5;
  --primary-soft: #eef2ff;
  --danger: #dc2626;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
  --radius: 24px;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
body { min-height: 100vh; }
#app { min-height: 100vh; }
.loading-screen { min-height: 100vh; display: grid; place-items: center; font-size: 1.1rem; color: var(--muted); }
.shell { padding: 24px; max-width: 1280px; margin: 0 auto; }
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 14px 18px; border: 1px solid var(--border); background: rgba(255,255,255,0.92);
  border-radius: 999px; backdrop-filter: blur(14px); position: sticky; top: 16px; z-index: 20; box-shadow: var(--shadow);
}
.brand-row { display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 40px; height: 40px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(135deg, #4f46e5, #7c3aed); color: white; font-weight: 700; }
.top-tabs { display: flex; flex-wrap: wrap; gap: 8px; }
.top-actions { display: flex; align-items: center; gap: 12px; }
.nav-pill, .flag-btn, .segment, .ghost-button, .secondary-button, .primary-button {
  border: 1px solid var(--border); background: white; color: var(--text); padding: 10px 14px; border-radius: 999px; transition: .2s ease;
}
.nav-pill.active, .segment.active, .flag-btn.active { background: var(--primary-soft); border-color: #c7d2fe; color: var(--primary); }
.flag-group { display: flex; gap: 8px; }
.flag-btn { width: 42px; height: 42px; padding: 0; font-size: 1.1rem; }
.ghost-button:hover, .secondary-button:hover, .nav-pill:hover, .flag-btn:hover, .segment:hover { transform: translateY(-1px); }
.primary-button { background: var(--primary); color: white; border-color: transparent; box-shadow: 0 10px 25px rgba(79,70,229,.25); }
.primary-button.big { font-size: 1rem; padding: 14px 18px; }
.primary-button.wide { width: 100%; }
.secondary-button { background: var(--primary-soft); color: var(--primary); }
.ghost-button.danger { color: var(--danger); }
.main-content { padding-top: 28px; }
.hero-card, .page-card, .auth-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
}
.hero-card { padding: 32px; display: grid; gap: 22px; }
.page-card { padding: 24px; }
.narrow-card { max-width: 820px; }
.auth-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: min(560px, 100%); padding: 28px; display: grid; gap: 18px; }
.auth-card-clean { align-content: start; }
.auth-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.auth-copy { display: grid; gap: 10px; }
.auth-copy h1 { margin: 0; font-size: clamp(2rem, 5vw, 3rem); line-height: 1.08; }
.auth-copy p { margin: 0; max-width: 44ch; }
.auth-flags { justify-content: flex-end; }
.auth-language-line { min-height: 46px; display: flex; align-items: center; padding: 0 14px; border: 1px solid var(--border); border-radius: 16px; background: #fafafa; }
.mini-stat, .stat-card { padding: 16px; background: #fafafa; border: 1px solid var(--border); border-radius: 18px; display: grid; gap: 8px; }
.mini-stat strong, .stat-card strong { font-size: 1.35rem; }
.muted { color: var(--muted); }
.small { font-size: .88rem; }
.eyebrow { display: inline-flex; padding: 6px 12px; border-radius: 999px; background: var(--primary-soft); color: var(--primary); font-size: .86rem; font-weight: 600; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.page-grid { display: grid; gap: 20px; grid-template-columns: 1.2fr .8fr; }
.page-grid.single-gap { grid-template-columns: 1fr; }
.field { display: grid; gap: 8px; }
.field.compact span { font-size: .86rem; color: var(--muted); }
.input { width: 100%; min-height: 46px; border-radius: 16px; border: 1px solid var(--border); padding: 0 14px; background: white; }
.textarea { min-height: 100px; padding: 14px; resize: vertical; }
.textarea.large { min-height: 180px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 16px; }
.action-row { display: flex; flex-wrap: wrap; gap: 10px; }
.action-row.center { justify-content: center; }
.install-card { display: grid; gap: 8px; border: 1px dashed #c7d2fe; background: #fafaff; border-radius: 18px; padding: 16px; }
.study-controls { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; align-items: end; }
.segmented { display: inline-flex; gap: 8px; flex-wrap: wrap; }
.study-meta { text-align: center; margin: 8px 0 16px; }
.flashcard {
  width: 100%; min-height: 320px; border: 1px solid var(--border); border-radius: 28px; background: linear-gradient(180deg, #ffffff 0%, #f9fbff 100%);
  padding: 28px; display: grid; place-items: center; text-align: center; box-shadow: inset 0 1px 0 rgba(255,255,255,.4);
}
.flash-face { max-width: 640px; display: grid; gap: 14px; }
.flash-label { display: inline-flex; justify-content: center; padding: 6px 12px; border-radius: 999px; background: #eef2ff; color: var(--primary); font-size: .82rem; font-weight: 600; }
.flash-face strong { font-size: clamp(1.8rem, 4vw, 3.2rem); line-height: 1.1; }
.flash-face p { margin: 0; color: var(--muted); font-size: 1rem; line-height: 1.55; }
.flash-face small { color: var(--muted); }
.status-pill { margin: 18px auto; width: fit-content; min-width: 84px; text-align: center; padding: 8px 14px; border-radius: 999px; background: #f3f4f6; color: var(--muted); }
.status-pill.learned { background: #dcfce7; color: #166534; }
.status-pill.hard { background: #fee2e2; color: #991b1b; }
.word-list, .admin-list { display: grid; gap: 12px; }
.word-card, .admin-item { display: flex; justify-content: space-between; gap: 12px; border: 1px solid var(--border); border-radius: 18px; padding: 14px; background: #fff; }
.word-head { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 6px; }
.chip { display: inline-flex; padding: 4px 10px; border-radius: 999px; background: #f3f4f6; color: var(--muted); font-size: .78rem; }
.chip.custom { background: #eef2ff; color: var(--primary); }
.stats-grid { display: grid; gap: 14px; grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stats-grid.admin-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.sticky-card { position: sticky; top: 110px; align-self: start; }
.clickable { cursor: pointer; }
.toast {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: #111827; color: white;
  padding: 12px 16px; border-radius: 999px; box-shadow: var(--shadow); z-index: 50;
}


.auth-form { display: grid; gap: 16px; }
.auth-message { border-radius: 16px; padding: 12px 14px; font-size: .96rem; border: 1px solid transparent; }
.auth-message.error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.auth-message.success { background: #ecfdf5; color: #166534; border-color: #bbf7d0; }
.field-error { color: var(--danger); font-size: .88rem; line-height: 1.4; }
.field-hint { color: var(--muted); font-size: .84rem; line-height: 1.4; }
.input-error { border-color: #fca5a5; box-shadow: 0 0 0 3px rgba(252, 165, 165, 0.18); }
button:disabled { opacity: .7; cursor: not-allowed; transform: none !important; }

@media (max-width: 960px) {
  .shell { padding: 16px; }
  .topbar { border-radius: 28px; flex-wrap: wrap; justify-content: center; }
  .top-tabs { justify-content: center; }
  .page-grid, .grid.two, .study-controls, .stats-grid, .stats-grid.admin-grid { grid-template-columns: 1fr; }
  .sticky-card { position: static; }
  .top-actions { width: 100%; justify-content: center; }
}

@media (max-width: 640px) {
  .auth-card, .hero-card, .page-card { padding: 18px; border-radius: 22px; }
  .topbar { padding: 14px; }
  .word-card, .admin-item { flex-direction: column; }
  .flashcard { min-height: 260px; padding: 20px; }
}

@media (max-width: 640px) {
  .auth-head { flex-direction: column; align-items: stretch; }
  .auth-flags { justify-content: flex-start; }
}


.empty-card { cursor: default; }
.empty-face { gap: 12px; }
.empty-face strong { font-size: 1.8rem; }
