:root {
  color-scheme: light;
  --ink: #172b39;
  --muted: #748491;
  --canvas: #f3f6f6;
  --card: #fff;
  --line: #e4ebeb;
  --brand: #16766e;
  --brand-dark: #105e58;
  --brand-soft: #e1f2ef;
  --gold: #dfaa55;
  --red: #c55353;
  --green: #19845e;
  --shadow: 0 14px 38px rgb(24 49 58 / 7%);
  font-family: "DM Sans", "Noto Sans Devanagari", "Nirmala UI", Mangal, system-ui, sans-serif;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --ink: #edf5f3;
  --muted: #9aacae;
  --canvas: #111d23;
  --card: #192930;
  --line: #2a3d43;
  --brand: #56b8a7;
  --brand-dark: #74d1bd;
  --brand-soft: #1c3e3d;
  --gold: #e4ba76;
  --red: #ff8380;
  --green: #6ed0a5;
  --shadow: 0 14px 38px rgb(0 0 0 / 18%);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; background: var(--canvas); color: var(--ink); font-size: 15px; line-height: 1.55; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
a.card, a.brand, a.list-row { color: inherit; text-decoration: none; }
.topic-content > div:not(.toolbar) a, .chat-bubble a { text-decoration: underline; text-underline-offset: 2px; }
.boot { min-height: 100vh; display: grid; place-items: center; color: var(--muted); }
.spinner { width: 22px; height: 22px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; display: inline-block; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.login-wrap { min-height: 100vh; display: grid; grid-template-columns: minmax(360px, 1.05fr) minmax(400px, .95fr); background: var(--card); }
.login-art { position: relative; overflow: hidden; display: flex; flex-direction: column; justify-content: space-between; padding: clamp(32px, 6vw, 82px); color: #f5fffd; background: linear-gradient(145deg, #133b48 0%, #126f68 66%, #d5a95f 165%); }
.login-art::before, .login-art::after { content: ""; position: absolute; border: 1px solid rgb(255 255 255 / 12%); border-radius: 50%; width: 520px; height: 520px; right: -240px; top: 10%; }
.login-art::after { width: 740px; height: 740px; top: 1%; right: -340px; }
.brand { display: inline-flex; align-items: center; gap: 12px; font: 700 17px Manrope, sans-serif; letter-spacing: -.025em; position: relative; z-index: 1; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border: 1px solid rgb(255 255 255 / 30%); border-radius: 14px; background: rgb(255 255 255 / 12%); font-weight: 800; }
.login-copy { position: relative; z-index: 1; max-width: 590px; margin: 55px 0; }
.eyebrow { text-transform: uppercase; letter-spacing: .13em; font-size: 11px; font-weight: 700; opacity: .76; }
.login-copy h1 { margin: 14px 0; max-width: 560px; font: 800 clamp(34px, 5vw, 66px)/1.08 Manrope, sans-serif; letter-spacing: -.055em; }
.login-copy p { max-width: 450px; color: rgb(244 255 252 / 77%); font-size: 17px; }
.login-facts { display: flex; gap: clamp(20px, 5vw, 52px); position: relative; z-index: 1; }
.login-facts strong { display: block; font: 800 22px Manrope; }
.login-facts span { color: rgb(244 255 252 / 72%); font-size: 12px; }
.login-panel { display: grid; place-items: center; padding: 28px; }
.login-box { width: min(100%, 420px); }
.login-box h2 { font: 800 28px Manrope; letter-spacing: -.04em; margin: 0 0 4px; }
.subtle { color: var(--muted); margin-top: 0; }
.segmented { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--canvas); margin: 26px 0 22px; }
.segmented button { flex: 1; border: 0; background: transparent; border-radius: 9px; color: var(--muted); padding: 10px 12px; }
.segmented button.active { background: var(--card); color: var(--ink); box-shadow: 0 2px 8px rgb(0 0 0 / 7%); font-weight: 700; }
.field { display: grid; gap: 7px; margin: 15px 0; }
.field label { color: var(--muted); font-size: 12px; font-weight: 700; letter-spacing: .025em; }
.field input, .field select, .field textarea, .input { background: var(--card); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); outline: none; padding: 11px 13px; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 13%, transparent); }
.field textarea { min-height: 105px; resize: vertical; }
.btn { display: inline-flex; gap: 8px; justify-content: center; align-items: center; border: 1px solid transparent; border-radius: 10px; padding: 10px 15px; min-height: 42px; font-weight: 700; text-decoration: none; transition: transform .16s ease, background .16s ease, border .16s ease; }
.btn:hover { transform: translateY(-1px); }
.btn.primary { background: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); }
.btn.secondary { background: var(--card); color: var(--ink); border-color: var(--line); }
.btn.ghost { color: var(--muted); background: transparent; border-color: transparent; }
.btn.danger { color: #fff; background: var(--red); }
.btn.small { min-height: 34px; padding: 6px 10px; font-size: 12px; }
.btn.wide { width: 100%; }
.login-error { color: var(--red); min-height: 22px; font-size: 13px; }
.theme-toggle { position: fixed; right: 20px; top: 18px; z-index: 10; }
.app-shell { min-height: 100vh; }
.sidebar { position: fixed; inset: 0 auto 0 0; width: 246px; padding: 25px 16px 20px; display: flex; flex-direction: column; background: var(--card); border-right: 1px solid var(--line); z-index: 5; }
.sidebar .brand { color: var(--ink); padding: 0 9px 26px; font-size: 15px; }
.sidebar .brand-mark { background: var(--brand-soft); border: 0; color: var(--brand); }
.nav-label { margin: 14px 10px 8px; font-size: 10px; color: var(--muted); font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }
.nav-list { display: grid; gap: 4px; }
.nav-link { display: flex; align-items: center; gap: 12px; min-height: 43px; padding: 9px 11px; border-radius: 10px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 13px; }
.nav-link:hover, .nav-link.active { background: var(--brand-soft); color: var(--brand); }
.nav-icon { width: 21px; font-size: 17px; text-align: center; }
.sidebar-bottom { margin-top: auto; border-top: 1px solid var(--line); padding-top: 15px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 9px 7px 14px; }
.avatar { display: grid; place-items: center; flex: 0 0 36px; width: 36px; height: 36px; border-radius: 12px; color: var(--brand); background: var(--brand-soft); font-weight: 800; }
.sidebar-user strong { display: block; font-size: 12px; }
.sidebar-user small { color: var(--muted); }
.sidebar-actions { display: flex; gap: 5px; }
.sidebar-actions .btn { flex: 1; font-size: 12px; min-height: 35px; padding: 6px; }
.main { margin-left: 246px; padding: 34px clamp(24px, 4vw, 58px) 72px; max-width: 1600px; }
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; margin: 0 0 25px; }
.page-head h1 { font: 800 clamp(24px, 3vw, 34px)/1.18 Manrope, "Noto Sans Devanagari", sans-serif; letter-spacing: -.045em; margin: 2px 0 6px; }
.page-head p { margin: 0; color: var(--muted); }
.page-kicker { color: var(--brand); font-size: 11px; font-weight: 800; letter-spacing: .13em; text-transform: uppercase; }
.card { border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: var(--shadow); }
.card.pad { padding: 21px; }
.grid { display: grid; gap: 16px; }
.grid.cols-2 { grid-template-columns: repeat(2,minmax(0,1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3,minmax(0,1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4,minmax(0,1fr)); }
.hero-card { padding: clamp(22px,3vw,34px); color: white; background: linear-gradient(115deg,#145b5a,#16766e 65%,#378d79); border: 0; overflow: hidden; position: relative; }
.hero-card::after { content: "15"; position: absolute; right: 4%; top: -37px; font: 800 200px/.9 Manrope; color: rgb(255 255 255 / 7%); }
.hero-card h2 { position: relative; z-index: 1; margin: 6px 0; font: 800 clamp(24px,4vw,36px) Manrope; letter-spacing: -.04em; }
.hero-card p { position: relative; z-index: 1; margin: 0; color: rgb(255 255 255 / 75%); }
.hero-row { display: flex; align-items: center; gap: 24px; position: relative; z-index: 1; margin-top: 19px; }
.countdown { display: flex; gap: 10px; }
.countdown span { background: rgb(255 255 255 / 13%); padding: 9px 12px; border-radius: 10px; text-align: center; min-width: 58px; }
.countdown strong { display: block; font: 800 20px Manrope; }
.countdown small { font-size: 10px; text-transform: uppercase; opacity: .72; }
.stat-card { padding: 18px; }
.stat-card .stat-label { color: var(--muted); font-size: 12px; font-weight: 600; }
.stat-value { font: 800 29px Manrope; letter-spacing: -.04em; margin-top: 9px; }
.stat-caption { color: var(--muted); font-size: 11px; }
.section-title { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin: 29px 0 13px; }
.section-title h2 { margin: 0; font: 800 18px Manrope, "Noto Sans Devanagari"; letter-spacing: -.025em; }
.list { display: grid; gap: 10px; }
.list-row { padding: 15px 17px; display: flex; align-items: center; gap: 15px; justify-content: space-between; border: 1px solid var(--line); border-radius: 13px; background: var(--card); }
.list-main { min-width: 0; flex: 1; }
.list-main strong { display: block; }
.list-main small { display: block; color: var(--muted); margin-top: 3px; }
.pill { display: inline-flex; align-items: center; padding: 4px 8px; border-radius: 99px; color: var(--brand); background: var(--brand-soft); font-size: 10px; font-weight: 800; text-transform: uppercase; letter-spacing: .05em; }
.pill.gold { background: #fbf0db; color: #98661f; }
.pill.red { background: color-mix(in srgb,var(--red) 12%,transparent); color: var(--red); }
.pill.gray { background: var(--canvas); color: var(--muted); }
.progress-track { height: 7px; border-radius: 8px; background: var(--line); overflow: hidden; }
.progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--brand); }
.empty { text-align: center; padding: 36px 18px; color: var(--muted); }
.empty strong { color: var(--ink); display: block; margin-bottom: 5px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tabs { display: flex; gap: 7px; overflow-x: auto; margin: 0 0 18px; }
.tab { border: 1px solid var(--line); border-radius: 9px; background: var(--card); color: var(--muted); padding: 9px 14px; font-weight: 700; white-space: nowrap; }
.tab.active { color: var(--brand); border-color: var(--brand); background: var(--brand-soft); }
.study-layout { display: grid; grid-template-columns: 280px minmax(0,1fr); gap: 22px; align-items: start; }
.study-sidebar { padding: 16px; max-height: calc(100vh - 130px); overflow: auto; position: sticky; top: 20px; }
.study-group { margin: 8px 0 13px; }
.study-group h3 { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 12px 8px 6px; }
.topic-link { display: block; padding: 8px 9px; margin: 2px 0; border-radius: 8px; color: var(--muted); text-decoration: none; font-size: 12px; }
.topic-link:hover, .topic-link.active { background: var(--brand-soft); color: var(--brand); }
.topic-content { padding: clamp(20px,4vw,38px); min-width: 0; overflow-wrap: anywhere; }
.topic-content h1,.topic-content h2,.topic-content h3 { font-family: Manrope,"Noto Sans Devanagari",sans-serif; line-height: 1.3; }
.topic-content h2 { margin-top: 1.7em; }
.topic-content table { width: 100%; border-collapse: collapse; display: block; overflow-x: auto; }
.topic-content th,.topic-content td { border: 1px solid var(--line); padding: 9px 11px; min-width: 110px; text-align: left; }
.topic-content th { background: var(--brand-soft); }
.topic-content .box { padding: 14px 17px; border-radius: 10px; background: var(--brand-soft); margin: 14px 0; }
.question-layout { display: grid; grid-template-columns: minmax(0,1fr) 270px; align-items: start; gap: 18px; }
.question-card { padding: clamp(18px,3vw,28px); min-height: 300px; }
.question-card h2 { font-size: 18px; line-height: 1.5; margin: 10px 0 18px; }
.question-option { display: flex; width: 100%; text-align: left; gap: 12px; align-items: flex-start; background: var(--card); color: var(--ink); border: 1px solid var(--line); border-radius: 11px; padding: 13px; margin: 9px 0; }
.question-option:hover { border-color: var(--brand); }
.question-option.selected { border-color: var(--brand); background: var(--brand-soft); }
.question-option.right { border-color: var(--green); background: color-mix(in srgb,var(--green) 11%,transparent); }
.question-option.wrong { border-color: var(--red); background: color-mix(in srgb,var(--red) 10%,transparent); }
.option-letter { display: grid; place-items: center; width: 26px; height: 26px; flex: 0 0 26px; border-radius: 8px; background: var(--canvas); color: var(--muted); font-size: 12px; font-weight: 800; }
.palette { padding: 17px; }
.palette-grid { display: grid; grid-template-columns: repeat(5,1fr); gap: 7px; margin-top: 12px; }
.palette-btn { min-width: 0; border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--muted); min-height: 37px; font-size: 12px; padding: 0 2px; }
.palette-btn.answered { color: #fff; border-color: var(--brand); background: var(--brand); }
.palette-btn.marked { color: #fff; border-color: var(--gold); background: var(--gold); }
.palette-btn.current { outline: 2px solid var(--ink); outline-offset: 1px; }
.timer { font: 800 22px Manrope; color: var(--brand); }
.analysis-bars { display: grid; gap: 11px; }
.analysis-row { display: grid; grid-template-columns: minmax(0,1fr) 42px; grid-template-rows: auto 7px; align-items: center; column-gap: 9px; row-gap: 5px; font-size: 12px; }
.analysis-row > span:first-child { grid-column: 1; grid-row: 1; min-width: 0; }
.analysis-row > .progress-track { grid-column: 1; grid-row: 2; }
.analysis-row > strong { grid-column: 2; grid-row: 1 / span 2; justify-self: end; }
.review-card { margin: 11px 0; padding: 18px; }
.review-card h3 { font-size: 15px; line-height: 1.5; margin: 8px 0 13px; }
.review-options { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
.review-option { border: 1px solid var(--line); border-radius: 8px; padding: 9px; font-size: 12px; }
.review-option.correct { border-color: var(--green); color: var(--green); background: color-mix(in srgb,var(--green) 9%,transparent); }
.review-option.chosen-wrong { border-color: var(--red); color: var(--red); background: color-mix(in srgb,var(--red) 9%,transparent); }
.notice { border-radius: 11px; border: 1px solid color-mix(in srgb,var(--gold) 45%,var(--line)); background: color-mix(in srgb,var(--gold) 12%,var(--card)); padding: 12px 15px; margin: 12px 0; }
.chat-log { display: grid; gap: 13px; }
.chat-bubble { max-width: min(90%,780px); padding: 14px 17px; border-radius: 15px; background: var(--canvas); white-space: pre-wrap; }
.chat-bubble.user { justify-self: end; color: white; background: var(--brand); }
.chat-compose { display: flex; gap: 9px; margin-top: 15px; }
.chat-compose textarea { flex: 1; min-height: 48px; max-height: 150px; resize: vertical; }
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; }
.data th,.data td { padding: 12px; border-bottom: 1px solid var(--line); text-align: left; white-space: nowrap; }
.data th { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.mobile-nav { display: none; }
.toast-region { position: fixed; z-index: 99; right: 20px; bottom: 20px; display: grid; gap: 8px; max-width: min(360px,calc(100vw - 32px)); }
.toast { color: var(--ink); background: var(--card); box-shadow: var(--shadow); border: 1px solid var(--line); border-left: 4px solid var(--brand); border-radius: 10px; padding: 12px 15px; font-size: 13px; animation: fadein .2s ease; }
.toast-error { border-left-color: var(--red); }
@keyframes fadein { from { opacity: 0; transform: translateY(7px); } }
.modal-backdrop { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 18px; background: rgb(10 25 30 / 54%); }
.modal { max-width: 560px; width: 100%; max-height: 90vh; overflow: auto; background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 24px; box-shadow: var(--shadow); }
.modal h2 { margin-top: 0; }

@media (max-width: 950px) {
  .grid.cols-4 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .question-layout { grid-template-columns: minmax(0,1fr) 220px; }
  .study-layout { grid-template-columns: 235px minmax(0,1fr); gap: 13px; }
}
@media (max-width: 720px) {
  .login-wrap { grid-template-columns: 1fr; }
  .login-art { min-height: 370px; padding: 28px 25px; }
  .login-copy { margin: 38px 0; }
  .login-copy h1 { font-size: 38px; }
  .login-facts { gap: 28px; }
  .login-panel { padding: 32px 22px 52px; }
  .sidebar { display: none; }
  .main { margin: 0; padding: 24px 17px 92px; }
  .mobile-nav { position: fixed; display: flex; bottom: 0; left: 0; right: 0; z-index: 15; gap: 2px; padding: 7px 5px max(7px,env(safe-area-inset-bottom)); border-top: 1px solid var(--line); background: color-mix(in srgb,var(--card) 95%,transparent); backdrop-filter: blur(14px); }
  .mobile-nav a { flex: 1; text-align: center; text-decoration: none; color: var(--muted); font-size: 9px; font-weight: 700; padding: 5px 2px; border-radius: 8px; }
  .mobile-nav a.active { color: var(--brand); background: var(--brand-soft); }
  .mobile-nav span { display: block; font-size: 17px; line-height: 1.2; }
  .grid.cols-3 { grid-template-columns: repeat(2,minmax(0,1fr)); }
  .study-layout { display: flex; flex-direction: column; }
  .study-sidebar { position: static; max-height: 240px; width: 100%; }
  .question-layout { display: flex; flex-direction: column; }
  .question-layout > * { width: 100%; }
  .palette-grid { grid-template-columns: repeat(8,minmax(0,1fr)); }
  .hero-row { align-items: flex-start; flex-direction: column; gap: 15px; }
  .page-head { flex-direction: column; }
  .theme-toggle { top: 9px; right: 10px; }
  .analysis-row > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}
@media (max-width: 430px) {
  .grid.cols-2,.grid.cols-3,.grid.cols-4 { grid-template-columns: 1fr 1fr; gap: 9px; }
  .stat-card { padding: 13px; }
  .stat-value { font-size: 24px; }
  .countdown { gap: 6px; }
  .countdown span { min-width: 53px; padding: 8px; }
  .review-options { grid-template-columns: 1fr; }
  .list-row { padding: 12px; gap: 8px; }
  .list-row > .btn { padding: 8px; }
  .page-head { margin-bottom: 18px; }
}
