:root {
  --brand-50: #eef2ff;
  --brand-100: #e0e7ff;
  --brand-500: #6366f1;
  --brand-600: #4f46e5;
  --brand-700: #4338ca;
  --progress: #059669;
  --slate-50: #f8fafc;
  --slate-100: #f1f5f9;
  --slate-200: #e2e8f0;
  --slate-500: #64748b;
  --slate-700: #334155;
  --slate-900: #0f172a;
  --warning: #d97706;
  --danger: #dc2626;
  --radius-sm: .65rem;
  --radius-lg: 1.25rem;
  --shadow-soft: 0 1.25rem 3rem rgba(15, 23, 42, .1);
  --focus-ring: 0 0 0 .25rem rgba(79, 70, 229, .25);
  --content-width: 72rem;
  --content-narrow: 44rem;
  --sidebar-width: 17rem;
  --editor-min-height: 24rem;
  --bs-primary: var(--brand-600);
  --bs-primary-rgb: 79, 70, 229;
  --bs-link-color: var(--brand-700);
  --bs-link-hover-color: var(--brand-600);
}

html { scroll-behavior: smooth; }
body {
  background: var(--slate-50);
  color: var(--slate-900);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}
a { text-underline-offset: .2em; }
:focus-visible { outline: 3px solid var(--brand-500); outline-offset: 3px; }
.btn-primary {
  --bs-btn-bg: var(--brand-600);
  --bs-btn-border-color: var(--brand-600);
  --bs-btn-hover-bg: var(--brand-700);
  --bs-btn-hover-border-color: var(--brand-700);
  --bs-btn-active-bg: var(--brand-700);
  --bs-btn-active-border-color: var(--brand-700);
}
.btn { min-height: 2.75rem; display: inline-flex; align-items: center; justify-content: center; }
.app-container { max-width: var(--content-width); }
.content-narrow { max-width: var(--content-narrow); }
.brand-mark { color: var(--brand-700); font-size: 1.35rem; font-weight: 800; letter-spacing: -.03em; }
.skip-link {
  background: var(--slate-900);
  color: #fff;
  left: 1rem;
  padding: .7rem 1rem;
  position: fixed;
  top: -5rem;
  z-index: 2000;
}
.skip-link:focus { top: 1rem; }
.hero-section { background: radial-gradient(circle at 85% 20%, var(--brand-100), transparent 32%), linear-gradient(145deg, #fff, var(--slate-50)); }
.py-lg-7 { padding-top: 6rem; padding-bottom: 6rem; }
.section-space { padding: 4.5rem 0; }
.section-heading { max-width: 42rem; }
.eyebrow { color: var(--brand-700); font-size: .78rem; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; }
.hero-card,
.feature-card,
.plan-card,
.status-card,
.cta-panel {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
}
.hero-card { transform: rotate(1.5deg); }
.shadow-soft { box-shadow: var(--shadow-soft); }
.step-number {
  align-items: center;
  background: var(--brand-100);
  border-radius: 999px;
  color: var(--brand-700);
  display: inline-flex;
  font-weight: 800;
  height: 2.5rem;
  justify-content: center;
  width: 2.5rem;
}
.compact-feature { align-items: center; background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-sm); display: flex; gap: .65rem; padding: 1rem; }
.feature-check { color: var(--progress); font-weight: 900; }
.plan-price { color: var(--slate-900); font-size: 2rem; font-weight: 800; letter-spacing: -.04em; }
.plan-price span { color: var(--slate-500); font-size: 1rem; font-weight: 500; letter-spacing: 0; }
.cta-panel { background: linear-gradient(145deg, var(--brand-50), #fff); padding: 3rem 1.5rem; }
.status-card { box-shadow: 0 .5rem 1.5rem rgba(15, 23, 42, .06); }
.error-code { color: var(--brand-600); font-size: 4rem; font-weight: 900; line-height: 1; }
.htmx-indicator { opacity: 0; transition: opacity 150ms ease; }
.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator { opacity: 1; }
.htmx-request [data-hide-while-loading] { visibility: hidden; }

@media (max-width: 767.98px) {
  .section-space { padding: 3rem 0; }
  .py-lg-7 { padding-top: 3.5rem; padding-bottom: 3.5rem; }
  .hero-card { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

.auth-section { padding: 4rem 0; }
.auth-card,
.profile-card {
  background: #fff;
  border: 1px solid var(--slate-200);
  border-radius: var(--radius-lg);
  box-shadow: 0 .75rem 2rem rgba(15, 23, 42, .07);
  padding: clamp(1.25rem, 4vw, 2.5rem);
}
.verification-code { font-size: 1.4rem; letter-spacing: .5em; text-align: center; }
.avatar {
  align-items: center;
  background: var(--brand-100);
  border-radius: 999px;
  color: var(--brand-700);
  display: flex;
  font-size: 1.25rem;
  font-weight: 800;
  height: 4rem;
  justify-content: center;
  margin-bottom: 1.5rem;
  width: 4rem;
}
.form-control:focus,
.form-select:focus { border-color: var(--brand-500); box-shadow: var(--focus-ring); }
.invalid-feedback { font-weight: 600; }
@media (max-width: 575.98px) { .auth-section { padding: 2rem 0; } }

.app-frame { min-height: 100vh; }
.app-sidebar {
  background: #fff;
  border-right: 1px solid var(--slate-200);
  bottom: 0;
  flex-direction: column;
  left: 0;
  padding: 1.5rem 1rem;
  position: fixed;
  top: 0;
  width: var(--sidebar-width);
  z-index: 1020;
}
.app-sidebar .nav-link { color: var(--slate-700); min-height: 2.75rem; padding: .65rem .85rem; }
.app-sidebar .nav-link:hover { background: var(--slate-100); color: var(--brand-700); }
.app-sidebar .nav-link.active { background: var(--brand-100); color: var(--brand-700); font-weight: 700; }
.app-content { min-height: 100vh; }
.app-topbar { align-items: center; background: rgba(255,255,255,.94); border-bottom: 1px solid var(--slate-200); height: 4.5rem; padding: 0 2rem; position: sticky; top: 0; z-index: 1010; }
.app-main { margin: 0 auto; max-width: 96rem; padding: clamp(1.25rem, 4vw, 2.5rem); }
.avatar-small { align-items: center; background: var(--brand-100); border-radius: 999px; color: var(--brand-700); display: flex; font-size: .8rem; font-weight: 800; height: 2.5rem; justify-content: center; text-decoration: none; width: 2.5rem; }
.management-badge { background: #7c3aed; color: #fff; }
.admin-sidebar { border-top: .3rem solid #7c3aed; }
.empty-state { background: #fff; border: 1px dashed var(--slate-200); border-radius: var(--radius-lg); padding: 3rem 1.5rem; text-align: center; }
.empty-state-icon { color: var(--brand-600); font-size: 2rem; }
.progress-block + .progress-block { margin-top: 1.25rem; }
.progress { background: var(--slate-200); height: .75rem; }
.progress-bar { background: var(--progress); }
.exercise-card { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); padding: 1.5rem; }
.difficulty-beginner { background: #d1fae5; color: #065f46; }
.difficulty-intermediate { background: #fef3c7; color: #92400e; }
.difficulty-advanced { background: #fee2e2; color: #991b1b; }
.difficulty-unspecified { background: var(--slate-200); color: var(--slate-700); }
.clamp-3 { display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 3; overflow: hidden; }
@media (min-width: 992px) { .app-content { margin-left: var(--sidebar-width); } }
@media (max-width: 991.98px) { .app-main { padding-top: 1.5rem; } }

.dashboard-card,
.level-card { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); padding: 1.5rem; }
.score-chip { background: var(--brand-50); border-radius: 999px; color: var(--brand-700); padding: .4rem .7rem; white-space: nowrap; }
.level-link { align-items: center; border: 1px solid var(--slate-200); border-radius: var(--radius-sm); color: var(--slate-900); display: flex; gap: .75rem; padding: .85rem; text-decoration: none; }
.level-link:hover { border-color: var(--brand-500); color: var(--brand-700); }
.admin-callout { align-items: center; background: linear-gradient(110deg, #f5f3ff, #fff); display: flex; justify-content: space-between; }
.learning-path { display: grid; gap: 1rem; position: relative; }
.level-card { align-items: flex-start; display: flex; gap: 1rem; }
@media (max-width: 575.98px) { .admin-callout { align-items: flex-start; flex-direction: column; } }

.workspace-card,
.feedback-panel { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); padding: clamp(1.25rem, 3vw, 2rem); }
.prompt-text { background: var(--brand-50); border-left: .3rem solid var(--brand-500); border-radius: var(--radius-sm); font-size: 1.1rem; padding: 1rem 1.25rem; }
.writing-editor { min-height: var(--editor-min-height); resize: vertical; }
.feedback-panel { display: grid; gap: 1.5rem; }
.feedback-score { align-items: center; background: var(--brand-700); border-radius: var(--radius-lg); color: #fff; display: flex; flex-direction: column; justify-content: center; min-height: 9rem; }
.score-value { font-size: 3rem; font-weight: 900; line-height: 1; }
.feedback-note,.mistake-card { border: 1px solid var(--slate-200); border-radius: var(--radius-sm); padding: 1rem; }
.success-note { border-left: .3rem solid var(--progress); }
.improve-note { border-left: .3rem solid var(--warning); }
.preserve-whitespace { white-space: pre-wrap; overflow-wrap: anywhere; }
.mistake-grammar { background: #fee2e2; color: #991b1b; }
.mistake-structure { background: #ede9fe; color: #5b21b6; }
.mistake-coherence { background: #dbeafe; color: #1e40af; }
.mistake-vocabulary { background: #d1fae5; color: #065f46; }
.mistake-mechanics { background: #fef3c7; color: #92400e; }
@media (min-width: 768px) { .feedback-panel { grid-template-columns: 10rem 1fr; } .feedback-panel > :nth-child(n+3) { grid-column: 1 / -1; } }

.student-response { background: var(--slate-50); border-radius: var(--radius-sm); padding: 1rem; }
.hint-panel { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); padding: clamp(1.25rem, 3vw, 2rem); }
.hint-list { display: grid; gap: .75rem; padding-left: 1.5rem; }
.hint-list article { background: var(--slate-50); border-radius: var(--radius-sm); padding: 1rem; }
.model-answer { background: #ecfdf5; border: 1px solid #a7f3d0; border-radius: var(--radius-sm); padding: 1.25rem; }

.metric-card,.vocabulary-card { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); padding: 1.25rem; }
.metric-card { display: flex; flex-direction: column; gap: .5rem; height: 100%; }
.metric-card > span { color: var(--slate-500); }
.metric-card > strong { font-size: 2rem; }
.vocabulary-card[hidden], tr[hidden] { display: none !important; }

.current-plan { background: linear-gradient(120deg, var(--brand-700), #312e81); border-radius: var(--radius-lg); color: #fff; padding: clamp(1.5rem, 4vw, 2.5rem); }
.current-plan .eyebrow,.current-plan .text-secondary { color: #c7d2fe !important; }
.usage-summary { align-items: flex-end; display: flex; flex-direction: column; }
.usage-summary > strong { font-size: 2rem; }

.management-action { background: #fff; border: 1px solid var(--slate-200); border-radius: var(--radius-lg); color: var(--slate-900); display: flex; flex-direction: column; gap: .35rem; min-height: 8rem; padding: 1.5rem; text-decoration: none; }
.management-action:hover { border-color: #7c3aed; color: #5b21b6; }
[data-coupon-row][hidden] { display: none; }
