:root {
  --bg: #071423;
  --panel: #0e2238;
  --panel-2: #15314d;
  --text: #f4f8fc;
  --muted: #a8bbce;
  --primary: #2f86ff;
  --green: #39c58a;
  --orange: #ffb454;
  --red: #ff6b6b;
  --purple: #8b7cff;
  --line: rgba(255, 255, 255, .09);
  --shadow: 0 20px 60px rgba(0, 0, 0, .22);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 20% 0%, #10375d 0, var(--bg) 35%); color: var(--text); line-height: 1.6; }
a { color: #86baff; text-decoration: none; }
a:hover { color: #b6d5ff; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .62; }
.container { width: min(1180px, calc(100% - 32px)); margin-inline: auto; }
.page { min-height: calc(100vh - 150px); padding-block: 36px 60px; }
.narrow { width: min(680px, calc(100% - 32px)); }
.hidden { display: none !important; }
.muted { color: var(--muted); }
.center { text-align: center; }
.full { width: 100%; }
.eyebrow { color: var(--green); font-size: .78rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
h1, h2, h3 { line-height: 1.2; margin-top: 0; }
h1 { font-size: clamp(2rem, 5vw, 3.8rem); letter-spacing: -.04em; }
h2 { font-size: clamp(1.35rem, 3vw, 2rem); }
p { margin-top: .4rem; }
code { color: var(--orange); }

.site-header { position: sticky; top: 0; z-index: 20; background: rgba(7, 20, 35, .88); border-bottom: 1px solid var(--line); backdrop-filter: blur(18px); }
.nav-wrap { min-height: 70px; display: flex; align-items: center; gap: 22px; }
.brand { color: #fff; font-weight: 900; font-size: 1.25rem; white-space: nowrap; }
.brand span { display: inline-grid; place-items: center; width: 38px; height: 38px; margin-right: 8px; border-radius: 10px; background: var(--green); color: #062017; }
.main-nav { display: flex; align-items: center; gap: 18px; margin-left: auto; font-size: .92rem; }
.main-nav a { color: #dce9f6; }
.logout-form { margin: 0; }
.site-footer { border-top: 1px solid var(--line); background: rgba(5, 15, 26, .8); color: var(--muted); }
.footer-wrap { min-height: 80px; display: flex; justify-content: space-between; align-items: center; gap: 20px; font-size: .9rem; }

.btn { display: inline-flex; align-items: center; justify-content: center; min-height: 42px; padding: 9px 17px; border: 1px solid transparent; border-radius: 11px; font-weight: 750; transition: .2s ease; }
.btn:hover { transform: translateY(-1px); }
.btn-primary { background: linear-gradient(135deg, var(--primary), #5e6cff); color: #fff; box-shadow: 0 10px 30px rgba(47, 134, 255, .2); }
.btn-primary:hover { color: #fff; filter: brightness(1.08); }
.btn-ghost { background: rgba(255, 255, 255, .04); color: var(--text); border-color: var(--line); }
.btn-danger { background: var(--red); color: #240707; }
.btn-large { min-height: 52px; padding-inline: 24px; }
.panel { padding: 24px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgba(21, 49, 77, .8), rgba(14, 34, 56, .92)); box-shadow: var(--shadow); }
.compact { padding-block: 15px; }
.alert { padding: 13px 16px; margin-bottom: 14px; border-radius: 11px; border: 1px solid var(--line); }
.alert-error { color: #ffd7d7; background: rgba(255, 107, 107, .15); }
.alert-success { color: #c8ffe7; background: rgba(57, 197, 138, .15); }
.status { min-height: 24px; margin-top: 12px; color: var(--green); }
.status.error { color: var(--red); }
.quota-action { margin-left: 12px; }

.hero { min-height: 560px; display: grid; grid-template-columns: 1.25fr .75fr; align-items: center; gap: 50px; }
.hero p { max-width: 720px; font-size: 1.2rem; color: var(--muted); }
.hero-actions { display: flex; gap: 12px; margin-top: 26px; }
.hero-card { padding: 32px; text-align: center; border: 1px solid rgba(139, 124, 255, .35); border-radius: 26px; background: linear-gradient(160deg, rgba(139, 124, 255, .2), rgba(14, 34, 56, .85)); box-shadow: var(--shadow); }
.teacher-orb { display: grid; place-items: center; width: 100px; height: 100px; margin: 0 auto 18px; border-radius: 32px; background: rgba(139, 124, 255, .25); font-size: 3rem; }
.mini-stats { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 20px; }
.mini-stats span, .chip { padding: 6px 11px; border-radius: 999px; background: rgba(255,255,255,.06); color: #dce9f6; font-size: .82rem; }
.feature-grid, .action-grid, .teacher-grid, .stat-grid { display: grid; gap: 16px; margin-bottom: 22px; }
.feature-grid { grid-template-columns: repeat(4, 1fr); }
.feature-grid .panel { margin: 0; }
.feature-grid p { color: var(--muted); }
.action-grid { grid-template-columns: repeat(4, 1fr); }
.action-card { min-height: 185px; padding: 24px; border: 1px solid var(--line); border-radius: 18px; color: var(--text); transition: .2s; }
.action-card:hover { color: #fff; transform: translateY(-4px); }
.action-card span { font-size: 2rem; }
.action-card p { color: var(--muted); }
.action-card.blue { background: linear-gradient(145deg, rgba(47,134,255,.24), var(--panel)); }
.action-card.green { background: linear-gradient(145deg, rgba(57,197,138,.22), var(--panel)); }
.action-card.purple { background: linear-gradient(145deg, rgba(139,124,255,.24), var(--panel)); }
.action-card.orange { background: linear-gradient(145deg, rgba(255,180,84,.2), var(--panel)); }
.stat-grid { grid-template-columns: repeat(4, 1fr); }
.stat-card { padding: 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.stat-card span { display: block; color: var(--muted); }
.stat-card strong { display: block; margin-top: 5px; font-size: 2rem; color: var(--green); }
.chip-list { display: flex; flex-wrap: wrap; gap: 8px; }
.quota-panel { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.quota-panel h2 { margin: 5px 0; }

.auth-card { max-width: 560px; margin: 25px auto; }
.form-stack { display: grid; gap: 15px; }
label { display: grid; gap: 6px; color: #dce9f6; font-weight: 650; font-size: .92rem; }
input, select, textarea { width: 100%; min-height: 45px; padding: 10px 13px; border: 1px solid var(--line); border-radius: 11px; outline: none; background: rgba(3, 13, 23, .55); color: var(--text); }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(47, 134, 255, .12); }
textarea { resize: vertical; }
.check-row { grid-template-columns: 22px 1fr; align-items: start; font-weight: 450; color: var(--muted); }
.check-row input { min-height: auto; margin-top: 5px; }
.inline-form, .form-grid { display: flex; align-items: end; gap: 14px; flex-wrap: wrap; }
.inline-form label, .form-grid label { flex: 1 1 200px; }
.selection-panel .btn { margin-bottom: 0; }
.page-head { display: flex; justify-content: space-between; align-items: end; margin-bottom: 24px; }
.page-head h1 { margin: 4px 0; }
.page-head p { color: var(--muted); margin-bottom: 0; }
.page-actions { display: flex; flex-wrap: wrap; gap: 10px; }
.custom-topic-box { margin-top: 16px; padding: 13px 15px; border: 1px dashed rgba(134, 186, 255, .35); border-radius: 12px; background: rgba(47, 134, 255, .06); }
.custom-topic-box summary { width: fit-content; color: #a9ceff; font-weight: 750; cursor: pointer; }
.custom-topic-form { margin-top: 14px; }
.custom-topic-form .status { margin-bottom: 0; }
.catalog-note { margin-top: 15px; padding: 11px 13px; border-radius: 10px; color: var(--orange); background: rgba(255, 180, 84, .1); }

.teacher-grid { grid-template-columns: repeat(3, 1fr); }
.teacher-card { --teacher: var(--primary); position: relative; padding: 24px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); }
.teacher-card.selected { border-color: var(--teacher); box-shadow: 0 0 0 2px color-mix(in srgb, var(--teacher), transparent 65%); }
.teacher-card h2 { color: var(--teacher); margin-bottom: 6px; }
.teacher-card p { min-height: 74px; color: var(--muted); }
.teacher-emoji { font-size: 2.4rem; margin-bottom: 12px; }

.lesson-output { min-height: 380px; }
.output-head, .quiz-head { display: flex; justify-content: space-between; align-items: start; gap: 20px; padding-bottom: 15px; border-bottom: 1px solid var(--line); }
.output-head span, .quiz-head span { color: var(--green); font-weight: 750; }
.ai-content { padding-top: 22px; white-space: pre-wrap; overflow-wrap: anywhere; }
.question-meta { color: var(--green); font-weight: 750; font-size: .88rem; }
.choices { display: grid; gap: 11px; margin-block: 20px; }
.choice { display: flex; grid-template-columns: none; align-items: center; gap: 12px; padding: 13px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); cursor: pointer; }
.choice:hover { border-color: rgba(47,134,255,.6); }
.choice input { width: 20px; min-height: auto; }
.hint { margin: 14px 0; padding: 13px; border-radius: 11px; background: rgba(255,180,84,.12); color: #ffe0b7; }
.quiz-controls { display: flex; justify-content: space-between; gap: 12px; margin-top: 20px; }
.result-row { padding: 14px; margin: 10px 0; border-radius: 12px; border-left: 4px solid var(--green); background: rgba(57,197,138,.08); }
.result-row.wrong { border-left-color: var(--orange); background: rgba(255,180,84,.08); }
.motivation { padding: 14px 16px; border: 1px solid rgba(57,197,138,.28); border-radius: 12px; background: rgba(57,197,138,.1); color: #d7ffec; }
.level-card { padding: 15px; border: 1px solid rgba(255,180,84,.25); border-radius: 13px; background: rgba(255,180,84,.07); }
.level-card h3 { margin: 4px 0; }
.level-card p { margin-bottom: 0; color: var(--muted); font-size: .9rem; }
.level-grid, .content-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-bottom: 22px; }
.stars, .star-line { color: var(--orange); font-size: 1.15rem; letter-spacing: .06em; }
.public-card { display: flex; flex-direction: column; align-items: start; margin: 0; }
.public-card p { flex: 1; color: var(--muted); }
.public-card .star-line { margin-bottom: 16px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 32px 0 16px; }
.section-head h2 { margin: 4px 0 0; }
.public-lesson { margin-inline: auto; }
.public-lesson .lead { padding-bottom: 16px; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 1.08rem; }
.lesson-text { white-space: normal; overflow-wrap: anywhere; }
.history-list small { display: block; margin-top: 3px; color: var(--muted); font-weight: 450; }
.compact-form { min-width: 460px; flex-wrap: nowrap; }
.compact-form select { min-width: 120px; }
.question-review { margin-top: 8px; max-width: 620px; white-space: normal; }
.question-review summary { color: #a9ceff; cursor: pointer; }
.question-review ol { margin-block: 8px; padding-left: 25px; }
.question-review .correct-option { color: var(--green); font-weight: 750; }
.bulk-toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; margin: 16px 0; }
.bulk-toolbar .check-row { margin-right: auto; }
.review-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.review-card { padding: 16px; border: 1px solid var(--line); border-radius: 13px; background: rgba(255,255,255,.02); }
.review-card details summary { cursor: pointer; color: #a9ceff; }
.review-content { max-height: 420px; overflow-y: auto; }
.lesson-rating { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.rating-buttons { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 12px; }
.rating-star { padding: 9px 13px; border: 1px solid var(--line); border-radius: 999px; background: rgba(255,255,255,.025); color: var(--muted); cursor: pointer; }
.rating-star:hover, .rating-star.selected { border-color: var(--orange); background: rgba(255,180,84,.12); color: var(--orange); }

.chat-layout { display: grid; grid-template-columns: 270px 1fr; gap: 18px; }
.conversation-list { margin: 0; }
.conversation-list h3 { margin-top: 20px; }
.conversation-link { display: block; padding: 11px; margin-top: 7px; border-radius: 10px; color: var(--text); background: rgba(255,255,255,.025); }
.conversation-link.active { background: rgba(47,134,255,.16); }
.conversation-link span { display: block; color: var(--muted); font-size: .78rem; }
.chat-panel { margin: 0; }
.chat-selectors { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 15px; }
.messages { min-height: 430px; max-height: 60vh; overflow-y: auto; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: rgba(3,13,23,.35); }
.message { width: min(84%, 740px); padding: 13px 15px; margin: 10px 0; border-radius: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.message.user { margin-left: auto; background: linear-gradient(135deg, #246ec7, #5364d8); }
.message.assistant { background: var(--panel-2); }
.message-role { margin-bottom: 4px; font-size: .75rem; font-weight: 800; color: #b9d5f2; }
.feedback-row { display: flex; gap: 8px; margin-top: 10px; }
.feedback-row button { padding: 5px 9px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.04); color: var(--muted); }
.chat-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 10px; margin-top: 13px; }
.empty-state { padding: 70px 20px; text-align: center; color: var(--muted); }

.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 11px 9px; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .04em; }
.score { color: var(--orange); font-weight: 800; }
.score.low { color: var(--red); }
.score.high { color: var(--green); }
.history-list > div { display: grid; grid-template-columns: 1fr 1fr auto; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-list span { color: var(--muted); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.admin-grid .panel { margin: 0 0 20px; }
.prose { max-width: 900px; }
.prose li { margin-bottom: 7px; }
.key-status { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.key-status h2 { margin: 5px 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.video-wrap { position: relative; width: 100%; aspect-ratio: 16 / 9; overflow: hidden; border-radius: 14px; background: #020913; }
.video-wrap iframe { width: 100%; height: 100%; border: 0; }

@media (max-width: 980px) {
  .main-nav { max-width: 65vw; overflow-x: auto; padding-block: 10px; }
  .main-nav a { white-space: nowrap; }
  .hero { grid-template-columns: 1fr; padding-block: 55px; }
  .feature-grid, .action-grid, .stat-grid, .level-grid, .content-grid { grid-template-columns: repeat(2, 1fr); }
  .teacher-grid { grid-template-columns: repeat(2, 1fr); }
  .chat-layout { grid-template-columns: 1fr; }
  .conversation-list { order: 2; }
}

@media (max-width: 680px) {
  .container { width: min(100% - 20px, 1180px); }
  .page { padding-top: 24px; }
  .nav-wrap { flex-wrap: wrap; padding-block: 10px; gap: 8px; }
  .main-nav { order: 3; width: 100%; max-width: 100%; margin: 0; }
  .logout-form { margin-left: auto; }
  .hero { min-height: auto; gap: 28px; }
  .hero-actions { flex-direction: column; }
  .feature-grid, .action-grid, .stat-grid, .teacher-grid, .admin-grid, .level-grid, .content-grid, .review-grid { grid-template-columns: 1fr; }
  .panel { padding: 17px; border-radius: 15px; }
  .form-grid, .inline-form { align-items: stretch; flex-direction: column; }
  .form-grid label, .inline-form label { flex-basis: auto; }
  .chat-selectors, .chat-form { grid-template-columns: 1fr; }
  .messages { min-height: 360px; }
  .message { width: 94%; }
  .footer-wrap { flex-direction: column; align-items: start; justify-content: center; padding-block: 18px; }
  .history-list > div { grid-template-columns: 1fr auto; }
  .history-list span { grid-column: 1 / -1; }
  .key-status { align-items: stretch; flex-direction: column; }
  .quota-panel { align-items: stretch; flex-direction: column; }
  .page-head { align-items: stretch; flex-direction: column; gap: 14px; }
}
