:root {
    --bg: #f8f4ec;
    --ink: #20201b;
    --muted: #4d4d43;
    --panel: rgba(255, 255, 255, 0.72);
    --panel-solid: #ffffff;
    --line: rgba(32, 32, 27, 0.12);
    --gold: #f2ab27;
    --teal: #009688;
    --coral: #f46d43;
    --sky: #78a8ff;
    --radius: 18px;
    --shadow: 0 20px 40px rgba(40, 38, 31, 0.08);
    --header-bg: rgba(248, 244, 236, 0.78);
    --hero-bg: linear-gradient(125deg, #f9d596 0%, #ffecc6 45%, #dcf5ef 100%);
    --hero-border: #e7d8b2;
    --hero-eyebrow: #855b0b;
    --hero-sub: #4a4338;
    --body-bg: radial-gradient(circle at 10% 10%, #fdf8e9 0%, transparent 28%),
               radial-gradient(circle at 85% 16%, #dff6f2 0%, transparent 24%),
               linear-gradient(130deg, #fbf9f1 0%, #f6efe4 100%);
    --flash-success-bg: #d8f4ef;
    --flash-success-ink: #03433b;
    --flash-error-bg: #ffe4df;
    --flash-error-ink: #6f190a;
    --orb-a: #facf73;
    --orb-b: #9be2da;
}

[data-theme="dark"] {
    --bg: #121212;
    --ink: #e8e5de;
    --muted: #9b9690;
    --panel: rgba(30, 30, 30, 0.88);
    --panel-solid: #1e1e1e;
    --line: rgba(255, 255, 255, 0.09);
    --gold: #f2ab27;
    --teal: #26bfb0;
    --coral: #f46d43;
    --sky: #78a8ff;
    --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
    --header-bg: rgba(18, 18, 18, 0.88);
    --hero-bg: linear-gradient(125deg, #2c2010 0%, #1c2a28 100%);
    --hero-border: rgba(255, 255, 255, 0.08);
    --hero-eyebrow: #d4a845;
    --hero-sub: #9b9690;
    --body-bg: radial-gradient(circle at 10% 10%, #1e1a0f 0%, transparent 28%),
               radial-gradient(circle at 85% 16%, #0e1e1c 0%, transparent 24%),
               linear-gradient(130deg, #121212 0%, #0e0e0e 100%);
    --flash-success-bg: #0d2e28;
    --flash-success-ink: #7de2d0;
    --flash-error-bg: #2c0f0a;
    --flash-error-ink: #f4a99a;
    --orb-a: rgba(242, 171, 39, 0.12);
    --orb-b: rgba(38, 191, 176, 0.1);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Sora", sans-serif;
    color: var(--ink);
    background: var(--body-bg);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
}

h1,
h2,
h3,
h4 {
    font-family: "Fraunces", serif;
    margin-top: 0;
}

.bg-orb {
    position: fixed;
    width: 380px;
    height: 380px;
    border-radius: 999px;
    filter: blur(80px);
    z-index: -1;
    opacity: 0.35;
}

.orb-a {
    background: var(--orb-a);
    top: -140px;
    right: -60px;
}

.orb-b {
    background: var(--orb-b);
    left: -120px;
    bottom: -160px;
}

.container {
    width: min(1120px, calc(100% - 2rem));
    margin: 0 auto;
}

.site-header {
    position: sticky;
    top: 0;
    backdrop-filter: blur(8px);
    background: var(--header-bg);
    border-bottom: 1px solid var(--line);
    z-index: 10;
    transition: background 0.3s ease;
}

.nav-wrap {
    display: flex;
    align-items: center;
    padding: 0.65rem 0;
    gap: 1.2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: var(--ink);
    flex-shrink: 0;
}

.brand-mark {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    display: block;
    flex-shrink: 0;
    /* Crisp rendering at all sizes */
    image-rendering: crisp-edges;
    filter: drop-shadow(0 2px 5px rgba(20, 31, 45, 0.28));
    transform: translateZ(0);
    transition: transform 0.22s ease, filter 0.22s ease;
}

.brand:hover .brand-mark {
    transform: translateY(-1px) scale(1.02);
    filter: drop-shadow(0 4px 10px rgba(20, 31, 45, 0.32));
}

.brand-name {
    font-family: "Fraunces", Georgia, serif;
    font-weight: 700;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    color: var(--ink);
}

.brand-name-light {
    font-weight: 500;
    color: var(--muted);
}

/* ── Tab navigation ───────────────────────────────────── */
.tab-nav {
    display: flex;
    gap: 0.3rem;
    flex: 1;
    justify-content: center;
    flex-wrap: wrap;
}

.tab-link {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.88rem;
    letter-spacing: 0.01em;
    color: var(--muted);
    padding: 0.42rem 0.95rem;
    border-radius: 999px;
    transition: background 0.18s, color 0.18s;
    white-space: nowrap;
}

.tab-link:hover {
    background: rgba(0,0,0,0.05);
    color: var(--ink);
}

.tab-active {
    background: linear-gradient(120deg, #f2ab27, #f08f45);
    color: #2c1f04 !important;
}

/* ── Secondary navigation row ─────────────────────────── */
.subnav-row {
    display: flex;
    gap: 0.35rem;
    align-items: center;
    padding: 0 0 0.55rem;
    overflow-x: auto;
    scrollbar-width: thin;
}

.subnav-link {
    text-decoration: none;
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
    padding: 0.34rem 0.7rem;
    border-radius: 999px;
    border: 1px solid transparent;
    transition: background 0.18s, color 0.18s, border-color 0.18s;
}

.subnav-link:hover {
    color: var(--ink);
    background: rgba(0, 0, 0, 0.05);
}

.subnav-active {
    color: #2c1f04;
    background: rgba(242, 171, 39, 0.28);
    border-color: rgba(242, 171, 39, 0.42);
}

/* ── Nav end (right side) ─────────────────────────────── */
.nav-end {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.nav-auth-links {
    gap: 0.5rem;
}

.btn-sm {
    padding: 0.42rem 0.82rem;
    font-size: 0.88rem;
    border-radius: 8px;
    text-decoration: none;
}

/* ── User dropdown ────────────────────────────────────── */
.user-menu {
    position: relative;
}

.user-chip-btn {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.35rem 0.7rem 0.35rem 0.35rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.88rem;
    color: var(--ink);
    transition: box-shadow 0.18s;
}

.user-chip-btn:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f2ab27, #f46d43);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    flex-shrink: 0;
}

.user-chip-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-caret {
    transition: transform 0.2s;
    color: var(--muted);
}

.user-menu.open .user-caret {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: var(--panel-solid);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.14);
    padding: 0.5rem;
    z-index: 100;
    animation: rise-in 160ms ease;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    text-decoration: none;
    color: var(--ink);
    font-size: 0.9rem;
    padding: 0.52rem 0.7rem;
    border-radius: 8px;
    transition: background 0.14s;
}

.dropdown-item:hover {
    background: rgba(0,0,0,0.05);
}

.di-icon {
    font-size: 1rem;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
}

.dropdown-divider {
    height: 1px;
    background: var(--line);
    margin: 0.4rem 0.3rem;
}

.dropdown-logout-form {
    margin: 0;
}

.dropdown-logout-btn {
    width: 100%;
    text-align: left;
    padding: 0.52rem 0.7rem;
    border-radius: 8px;
    background: none;
    color: var(--coral);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.14s;
}

.dropdown-logout-btn:hover {
    background: rgba(244, 109, 67, 0.1);
}

.page-shell {
    padding: 1.6rem 0 3.5rem;
}

.hero {
    background: var(--hero-bg);
    border-radius: calc(var(--radius) + 8px);
    border: 1px solid var(--hero-border);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1rem;
    animation: rise-in 500ms ease;
    transition: background 0.3s ease;
}

.slim-hero {
    margin-bottom: 1.4rem;
}

.eyebrow {
    text-transform: uppercase;
    font-size: 0.76rem;
    letter-spacing: 0.08em;
    margin-bottom: 0.4rem;
    color: var(--hero-eyebrow);
    font-weight: 600;
}

.hero h1 {
    margin-bottom: 0.4rem;
    font-size: clamp(1.3rem, 3.1vw, 2rem);
}

.hero-sub {
    margin: 0;
    color: var(--hero-sub);
}

.flash-stack {
    display: grid;
    gap: 0.7rem;
    margin-bottom: 1rem;
}

.flash {
    padding: 0.8rem 1rem;
    border-radius: 12px;
    font-weight: 500;
}

.flash-success {
    background: var(--flash-success-bg);
    color: var(--flash-success-ink);
}

.flash-error {
    background: var(--flash-error-bg);
    color: var(--flash-error-ink);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.9rem;
    margin: 1rem 0;
}

.stat-card {
    border-radius: var(--radius);
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 1rem;
    animation: rise-in 600ms ease;
}

.stat-card p {
    margin: 0;
    color: var(--muted);
    font-size: 0.86rem;
}

.stat-card h2 {
    margin: 0.4rem 0 0;
    font-size: 1.5rem;
}

.accent-a { border-top: 4px solid var(--teal); }
.accent-b { border-top: 4px solid var(--gold); }
.accent-c { border-top: 4px solid var(--coral); }
.accent-d { border-top: 4px solid var(--sky); }

.layout-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.panel {
    background: var(--panel);
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    padding: 1.1rem;
    animation: rise-in 700ms ease;
}

.panel-head h3 {
    margin-bottom: 0.2rem;
    font-size: clamp(1.02rem, 2vw, 1.28rem);
    line-height: 1.25;
}

.panel-head p {
    margin: 0;
    color: var(--muted);
    font-size: 0.92rem;
}

.task-stack {
    display: grid;
    gap: 0.8rem;
    margin-top: 1rem;
}

.task-card,
.mini-task {
    border-radius: 14px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.78);
    padding: 0.9rem;
}

.task-topline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
}

.task-card h4,
.mini-task h4 {
    margin: 0;
}

.task-card p,
.mini-task p {
    margin: 0.45rem 0;
    color: #3f3a32;
    font-size: 0.92rem;
}

.task-done {
    opacity: 0.72;
    border-style: dashed;
}

.level-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #e8f7f4;
    color: #065f52;
    border: 1px solid #8ed0c6;
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 600;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.9rem;
    margin-top: 1rem;
}

label {
    display: grid;
    gap: 0.35rem;
    font-size: 0.88rem;
    color: #3d392f;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    border: 1px solid #c9bda9;
    border-radius: 10px;
    padding: 0.62rem 0.72rem;
    background: #fffdfa;
}

input:focus,
select:focus,
textarea:focus {
    outline: 2px solid #87d2c8;
    border-color: transparent;
}

.full-row {
    grid-column: 1 / -1;
}

button {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(120deg, #f2ab27, #f08f45);
    color: #2c1f04;
    padding: 0.52rem 0.82rem;
    font-size: 0.86rem;
    line-height: 1.2;
}

.btn-light {
    background: #f0f5fa;
    color: #1e2738;
    padding: 0.46rem 0.72rem;
    font-size: 0.85rem;
    line-height: 1.2;
}

/* .auth-chip kept for any legacy references */
.auth-chip {
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.auth-panel {
    max-width: 560px;
    margin: 2rem auto;
}

.tiny-note {
    margin-top: 0.9rem;
    color: var(--muted);
    font-size: 0.88rem;
}

.lab-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.48rem;
    margin: 0.7rem 0;
}

.lab-actions .btn-light,
.lab-actions .btn-primary {
    padding: 0.4rem 0.66rem;
    font-size: 0.81rem;
}

.lab-editor {
    width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.84rem;
    line-height: 1.55;
    white-space: pre;
    tab-size: 4;
    border-radius: 10px;
    background: #fffefb;
}

.lesson-doc {
    margin: 0.7rem 0;
    border: 1px solid #d8e5df;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.84);
    overflow: hidden;
}

.lesson-doc-head {
    padding: 0.45rem 0.72rem;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: #315146;
    border-bottom: 1px solid #d8e5df;
    background: #ecf8f3;
}

.lesson-markdown {
    padding: 0.9rem 0.95rem;
    color: #2c332f;
}

.lesson-markdown > *:first-child {
    margin-top: 0;
}

.lesson-markdown h1,
.lesson-markdown h2,
.lesson-markdown h3,
.lesson-markdown h4 {
    margin: 1rem 0 0.42rem;
    line-height: 1.28;
}

.lesson-markdown h2 {
    font-size: 1.06rem;
}

.lesson-markdown h3 {
    font-size: 0.98rem;
}

.lesson-markdown p,
.lesson-markdown li {
    font-size: 0.9rem;
    line-height: 1.62;
}

.lesson-markdown pre {
    margin: 0.72rem 0;
    border-radius: 10px;
    background: #0f1724;
    overflow-x: auto;
    border: 1px solid rgba(24, 122, 221, 0.24);
}

.lesson-markdown pre code {
    display: block;
    padding: 0.72rem 0.82rem;
    font-size: 0.8rem;
    line-height: 1.56;
    white-space: pre;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.lesson-markdown :not(pre) > code {
    background: #edf0fb;
    color: #24307e;
    border: 1px solid #d9ddf3;
    border-radius: 6px;
    padding: 0.08rem 0.36rem;
    font-size: 0.82rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.lab-output,
.lab-solution {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.8rem;
    background: #fffdfa;
    overflow: auto;
    white-space: pre-wrap;
    font-size: 0.86rem;
}

.lab-viz {
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 0.6rem;
    background: #fffdfa;
    margin-top: 0.65rem;
}

.lab-viz-canvas {
    width: 100%;
    max-height: 320px;
}

/* ── Chat FAB ─────────────────────────────────────────── */
.chat-fab {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f2ab27, #f46d43);
    color: white;
    border: none;
    box-shadow: 0 4px 20px rgba(242, 107, 56, 0.42);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chat-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 26px rgba(242, 107, 56, 0.55);
}

.chat-fab.open {
    background: linear-gradient(135deg, #e09520, #d9572e);
    transform: scale(0.95);
}

/* ── Chat drawer ──────────────────────────────────────── */
.chat-drawer[hidden] { display: none !important; }
.chat-drawer {
    position: fixed;
    right: 1.25rem;
    bottom: 5.2rem;
    width: min(360px, calc(100vw - 2.5rem));
    height: 420px;
    min-width: 280px;
    min-height: 200px;
    max-width: 92vw;
    max-height: 86vh;
    background: var(--panel-solid);
    border: 1px solid var(--line);
    box-shadow: 0 12px 48px rgba(0,0,0,0.18);
    border-radius: 18px;
    z-index: 49;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: rise-in 220ms ease;
}

.chat-resize-grip {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 22px;
    height: 22px;
    cursor: se-resize;
    z-index: 2;
    border-radius: 0 0 18px 0;
    background: linear-gradient(135deg, transparent 50%, rgba(0,0,0,0.15) 50%);
    transition: opacity 0.2s;
    opacity: 0.5;
}
.chat-resize-grip:hover { opacity: 1; }
.chat-drawer.minimized .chat-resize-grip,
.chat-drawer.maximized .chat-resize-grip { display: none; }

.chat-drawer.minimized {
    width: 280px;
    min-height: auto;
}

.chat-drawer.minimized .chat-messages,
.chat-drawer.minimized .chat-input-row {
    display: none;
}

.chat-drawer.maximized {
    right: 1rem;
    bottom: 1rem;
    width: min(760px, calc(100vw - 2rem));
    height: min(78vh, 720px);
}

/* maximized messages fills naturally via flex:1 */

.chat-drawer-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--line);
    background: linear-gradient(90deg, rgba(242,171,39,0.12), rgba(244,109,67,0.08));
    cursor: grab;
    user-select: none;
}

.chat-drawer.dragging .chat-drawer-head {
    cursor: grabbing;
}

.chat-drawer-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: "Fraunces", serif;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--ink);
}

.chat-drawer-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #26c281;
    box-shadow: 0 0 0 3px rgba(38, 194, 129, 0.25);
    flex-shrink: 0;
}

.chat-model-badge {
    font-family: "Sora", sans-serif;
    font-size: 0.68rem;
    font-weight: 500;
    color: var(--muted);
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 0.1rem 0.45rem;
}

.chat-head-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-head-btn,
.chat-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}

.chat-head-btn:hover,
.chat-close:hover {
    background: var(--coral);
    color: white;
    border-color: var(--coral);
}

.chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.chat-message {
    padding: 0.52rem 0.75rem;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.5;
    max-width: 90%;
    animation: rise-in 200ms ease;
}

.chat-message.user {
    background: linear-gradient(120deg, #fff1cf, #ffe8a8);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    border: 1px solid rgba(233, 157, 22, 0.3);
}

.chat-message.assistant {
    background: linear-gradient(120deg, rgba(45, 149, 255, 0.1), rgba(18, 200, 156, 0.09));
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    border: 1px solid rgba(16, 123, 229, 0.22);
}

.chat-message.thinking {
    color: var(--muted);
    font-style: italic;
}

.chat-h {
    margin: 0 0 0.35rem;
    font-size: 0.95rem;
    font-family: "Fraunces", serif;
}

.chat-li {
    margin: 0.14rem 0;
}

.chat-inline-code {
    background: rgba(89, 99, 216, 0.16);
    border: 1px solid rgba(89, 99, 216, 0.3);
    color: #24307e;
    border-radius: 6px;
    font-size: 0.82rem;
    padding: 0.08rem 0.35rem;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.chat-code-block {
    margin: 0.45rem 0;
    border-radius: 10px;
    border: 1px solid rgba(24, 122, 221, 0.24);
    background: linear-gradient(180deg, #0f1724, #111c2d);
    color: #deecff;
    overflow: hidden;
}

.chat-code-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.42rem 0.55rem 0.2rem;
}

.chat-code-lang {
    display: inline-block;
    margin: 0;
    padding: 0.08rem 0.42rem;
    border-radius: 999px;
    font-size: 0.68rem;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    color: #ffd080;
    border: 1px solid rgba(255, 207, 129, 0.35);
    background: rgba(255, 206, 127, 0.12);
}

.chat-run-label {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: auto;
    font-size: 0.7rem;
    color: #b7c7e4;
}

.chat-run-lang {
    border: 1px solid rgba(173, 196, 230, 0.45);
    border-radius: 7px;
    background: rgba(18, 31, 52, 0.72);
    color: #e6f0ff;
    font-size: 0.72rem;
    padding: 0.13rem 0.28rem;
}

.chat-code-btn {
    border: 1px solid rgba(173, 196, 230, 0.45);
    background: rgba(173, 196, 230, 0.12);
    color: #e6f0ff;
    border-radius: 7px;
    font-size: 0.72rem;
    padding: 0.14rem 0.48rem;
    cursor: pointer;
}

.chat-code-btn:hover:not(:disabled) {
    background: rgba(173, 196, 230, 0.26);
}

.chat-code-btn:disabled {
    opacity: 0.6;
    cursor: wait;
}

.chat-code-block pre {
    margin: 0;
    padding: 0.65rem 0.8rem 0.8rem;
    overflow: auto;
}

.chat-code-block code {
    display: block;
    white-space: pre;
    font-size: 0.8rem;
    line-height: 1.5;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.chat-code-output {
    margin: 0.2rem 0.55rem 0.55rem;
    border-radius: 8px;
    border: 1px solid rgba(179, 202, 238, 0.35);
    background: rgba(9, 18, 33, 0.45);
    color: #dce8ff;
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.76rem;
    line-height: 1.45;
    white-space: pre-wrap;
    max-height: 220px;
    overflow: auto;
    padding: 0.5rem 0.62rem;
}

.chat-code-output.pending {
    border-color: rgba(255, 207, 129, 0.45);
    color: #ffe0aa;
}

.chat-code-output.success {
    border-color: rgba(125, 228, 189, 0.45);
    color: #ccffe7;
}

.chat-code-output.error {
    border-color: rgba(255, 152, 152, 0.55);
    color: #ffc6c6;
}

.chat-code-viz {
    margin: 0.2rem 0.55rem 0.55rem;
    border-radius: 10px;
    border: 1px solid rgba(173, 196, 230, 0.35);
    background: rgba(8, 20, 37, 0.58);
    padding: 0.5rem;
}

.chat-code-chart {
    width: 100%;
    max-height: 260px;
}

.chat-code-block .hljs {
    background: transparent;
    color: inherit;
    padding: 0;
}

.chat-input-row {
    display: flex;
    gap: 0.45rem;
    padding: 0.65rem 0.75rem;
    border-top: 1px solid var(--line);
}

.chat-input-row input {
    flex: 1;
    border-radius: 999px;
    padding: 0.52rem 0.9rem;
    font-size: 0.88rem;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
}

.chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #f2ab27, #f46d43);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.15s;
}

.chat-send-btn:hover {
    transform: scale(1.1);
}

.table-tools {
    margin-bottom: 0.7rem;
}

.table-wrap {
    width: 100%;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid var(--line);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 690px;
    background: rgba(255, 255, 255, 0.8);
}

th,
td {
    text-align: left;
    padding: 0.74rem;
    border-bottom: 1px solid #ece4d9;
    font-size: 0.9rem;
}

th {
    background: #fff3db;
    color: #4c3510;
}

.schedule-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.day-panel {
    display: grid;
    gap: 0.7rem;
}

.summary-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.9rem;
    margin-bottom: 1rem;
}

.summary-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.78), rgba(255, 250, 236, 0.76));
}

.question-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
    align-items: end;
    margin-top: 0.9rem;
}

.question-bank-grid {
    display: grid;
    gap: 1rem;
    margin-top: 1rem;
}

.question-card {
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.85), rgba(236, 247, 244, 0.7));
}

.question-topline {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.7rem;
}

.question-id {
    margin: 0;
    color: #35503f;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-weight: 700;
}

.question-meta {
    color: #4e5a4d;
    font-size: 0.9rem;
}

.option-list {
    margin: 0.9rem 0;
    padding: 0.7rem;
    border: 1px solid #c6e2dc;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.78);
}

.option-list p {
    margin: 0.35rem 0;
}

.question-diagram {
    margin: 0.8rem 0;
    border-radius: 12px;
    border: 1px solid #d9d0be;
    background: #fffdfa;
    padding: 0.7rem;
}

.question-diagram svg {
    width: 100%;
    height: auto;
}

.diagram-label {
    margin: 0 0 0.5rem;
    font-size: 0.78rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #6a5b3f;
}

.answer-panel {
    margin-top: 0.8rem;
    border-radius: 12px;
    padding: 0.7rem;
    border: 1px solid #b7dfd9;
    background: #e9f8f5;
}

.hidden-answer {
    display: none;
}

.question-repo-cta {
    margin-top: 1rem;
}

.repo-level-grid {
    margin: 1rem 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
}

.repo-level-card {
    border-radius: 12px;
    border: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.8);
    padding: 0.8rem;
}

.repo-level-card h4 {
    margin-bottom: 0.4rem;
}

.repo-level-card p {
    margin: 0;
    color: #474033;
    font-size: 0.9rem;
}

.cta-link {
    display: inline-block;
    text-decoration: none;
}

.cta-inline-link {
    display: inline-block;
    margin-top: 0.5rem;
    color: #0d5f52;
    font-weight: 600;
    text-decoration: none;
}

.cta-inline-link:hover {
    text-decoration: underline;
}

.sync-now-form {
    margin-top: 0.75rem;
}

.material-card {
    background: linear-gradient(155deg, rgba(255, 255, 255, 0.86), rgba(235, 252, 248, 0.72));
}

.keypoints-box,
.practice-box {
    margin: 0.8rem 0;
    border: 1px solid #d2e8e3;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.82);
    padding: 0.65rem 0.8rem;
}

.keypoints-box h4,
.practice-box h4 {
    margin-bottom: 0.35rem;
}

.keypoints-box pre {
    margin: 0;
    white-space: pre-wrap;
    font-family: "Sora", sans-serif;
    color: #3f3b32;
    line-height: 1.45;
}

.material-meta {
    color: #4f5849;
    font-size: 0.85rem;
    margin-top: 0.7rem;
}

.material-card .question-topline {
    flex-wrap: wrap;
    justify-content: flex-start;
}

.material-card .level-chip,
.material-card .class-chip {
    margin-left: 0.25rem;
}

.dynamic-viz {
    margin-top: 0.75rem;
    border: 1px solid #d8e4f0;
    border-radius: 12px;
    background: linear-gradient(145deg, #ffffff, #f4f9ff);
    overflow: hidden;
}

.dynamic-viz svg {
    display: block;
    width: 100%;
    height: auto;
}

.dynamic-viz--focus {
    border-color: #93c5fd;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.14) inset;
}

.paper-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.8rem;
    align-items: end;
    margin-top: 0.9rem;
}

.settings-grid {
    max-width: 620px;
}

.feedback-widget {
    margin-top: 0.7rem;
    border: 1px solid #d6cec0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.82);
    overflow: hidden;
}

.feedback-widget summary {
    cursor: pointer;
    padding: 0.55rem 0.75rem;
    font-weight: 600;
    color: #4e4333;
    background: #faf4e6;
}

.feedback-form {
    display: grid;
    gap: 0.6rem;
    padding: 0.7rem;
}

.feedback-row-cell {
    background: #fcf8ef;
}

.model-catalog-grid {
    margin-top: 0.8rem;
    display: grid;
    gap: 0.8rem;
}

.model-card-choice {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 0.7rem;
    align-items: start;
    border: 1px solid #d9d0c2;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.84);
    padding: 0.75rem;
}

.model-card-choice input[type="radio"] {
    margin-top: 0.4rem;
}

.model-card-body h4 {
    margin: 0;
}

.model-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.6rem;
}

.model-meta,
.model-source {
    margin: 0.3rem 0;
    font-size: 0.84rem;
    color: #5a5548;
}

.cost-badge {
    border-radius: 999px;
    padding: 0.18rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.cost-free {
    background: #dcf8e8;
    color: #0f6240;
    border: 1px solid #99dbbc;
}

.cost-paid {
    background: #ffe4d9;
    color: #842f17;
    border: 1px solid #ffc0aa;
}

.recommended-note {
    margin: 0.35rem 0;
    color: #0d5f52;
    font-size: 0.83rem;
    font-weight: 600;
}

/* API Key Status Panel */
.api-key-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1rem;
    margin-top: 1.2rem;
}

.api-key-card {
    border-radius: var(--radius);
    border: 1.5px solid var(--border);
    padding: 1rem 1.1rem;
    background: var(--panel);
}

.api-connected { border-color: #99dbbc; background: #f0fdf6; }
.api-missing   { border-color: #e5c7c0; background: #fff8f6; }

.api-key-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.api-provider-name {
    font-weight: 700;
    font-size: 0.95rem;
}

.api-badge {
    border-radius: 999px;
    padding: 0.15rem 0.5rem;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
}

.api-badge-ok      { background: #dcf8e8; color: #0f6240; border: 1px solid #99dbbc; }
.api-badge-missing { background: #ffe4d9; color: #842f17; border: 1px solid #ffc0aa; }

/* ── Model reason badges ──────────────────────────────── */
.reason-badge {
    display: inline-block;
    border-radius: 999px;
    padding: 0.15rem 0.55rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    margin-top: 0.25rem;
}
.reason-available   { background: #dcf8e8; color: #0f6240; border: 1px solid #99dbbc; }
.reason-disabled    { background: #fef9c3; color: #7a5f00; border: 1px solid #f0d060; }
.reason-unavailable { background: #ffe4d9; color: #842f17; border: 1px solid #ffc0aa; }

.ollama-download-wrap {
    margin-top: 0.6rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid #e7ddcc;
    border-radius: 10px;
    background: #fffef9;
}

.ollama-progress-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.78rem;
    color: #6a5632;
    margin-bottom: 0.35rem;
}

.ollama-progress-bar {
    height: 8px;
    border-radius: 999px;
    background: #efe7d6;
    overflow: hidden;
}

.ollama-progress-fill {
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #f4aa46, #df7a1b);
    transition: width 180ms ease;
}

.ollama-progress-msg {
    margin: 0.45rem 0 0;
    font-size: 0.76rem;
    color: #7b6752;
    line-height: 1.3;
    word-break: break-word;
}

.api-key-env  { font-size: 0.78rem; color: var(--muted); margin: 0 0 0.3rem; }
.api-key-hint { font-size: 0.75rem; color: #8a3e2e; margin: 0; }

/* ── Theme Toggle ─────────────────────────────────────── */
.theme-switcher {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.8rem;
}

.theme-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--muted);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.theme-btn:hover {
    color: var(--ink);
    border-color: var(--teal);
}

.theme-btn[aria-pressed="true"],
.theme-btn.active {
    background: var(--teal);
    color: #fff;
    border-color: var(--teal);
}

/* Dark-mode overrides for elements with hard-coded colours */
[data-theme="dark"] .chat-drawer {
    background: #1e1e1e;
}

[data-theme="dark"] .chat-message.user {
    background: #2c2010;
}

[data-theme="dark"] .chat-message.assistant {
    background: rgba(255,255,255,0.06);
}

[data-theme="dark"] .chat-inline-code {
    background: rgba(129, 162, 255, 0.2);
    border-color: rgba(129, 162, 255, 0.34);
    color: #dce7ff;
}

[data-theme="dark"] .chat-code-block {
    border-color: rgba(118, 157, 228, 0.36);
    background: linear-gradient(180deg, #101726, #0d1521);
}

[data-theme="dark"] .user-dropdown {
    background: #1e1e1e;
}

[data-theme="dark"] .lab-output {
    background: #1a1a1a;
    color: var(--ink);
}

[data-theme="dark"] .lab-viz {
    background: #1a1a1a;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background: #1e1e1e;
    color: var(--ink);
    border-color: var(--line);
}

@keyframes rise-in {
    from {
        transform: translateY(12px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 980px) {
    .nav-wrap {
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 0.7rem;
    }

    .tab-nav {
        order: 3;
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 0.2rem;
    }

    .subnav-row {
        padding-bottom: 0.5rem;
    }

    .stat-grid,
    .summary-cards {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .question-filter-grid,
    .paper-filter-grid,
    .repo-level-grid {
        grid-template-columns: 1fr;
    }

    .layout-grid,
    .schedule-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 620px) {
    .brand-name {
        font-size: 1.02rem;
    }

    .tab-link {
        font-size: 0.82rem;
        padding: 0.34rem 0.72rem;
    }

    .user-chip-name {
        display: none;
    }

    .chat-fab {
        right: 0.85rem;
        bottom: 0.95rem;
    }

    .chat-drawer {
        right: 0.75rem;
        bottom: 4.8rem;
        width: calc(100vw - 1.5rem);
    }

    .chat-drawer.maximized {
        right: 0.75rem;
        bottom: 0.75rem;
        width: calc(100vw - 1.5rem);
        height: min(82vh, 720px);
    }

    .stat-grid,
    .summary-cards,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .container {
        width: min(1120px, calc(100% - 1rem));
    }

    .hero,
    .panel {
        padding: 0.9rem;
    }
}

/* ── Class chip ─────────────────────────────────────────────────────────── */
.class-chip {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
    padding: 0.2rem 0.55rem;
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* Level chip colour variants */
.level-chip--level-1 { background: #dcfce7; color: #14532d; border-color: #86efac; }
.level-chip--level-2 { background: #fef9c3; color: #713f12; border-color: #fde047; }
.level-chip--level-3 { background: #fee2e2; color: #7f1d1d; border-color: #fca5a5; }

/* ── Question filter grid (5 cols + button) ─────────────────────────────── */
.question-filter-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr)) auto;
}

.qb-count {
    margin: 0.6rem 0 0;
    font-size: 0.88rem;
    color: #4e5a4d;
}

.class-chip--jee-main {
    background: #dbeafe;
    color: #1e3a8a;
    border-color: #93c5fd;
}
.class-chip--jee-advanced {
    background: #ede9fe;
    color: #5b21b6;
    border-color: #c4b5fd;
}

.exam-chapter h4 {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.exam-chapter h4 a {
    color: inherit;
    text-decoration: none;
}
.exam-chapter h4 a:hover {
    text-decoration: underline;
}
.topic-count {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.12rem 0.45rem;
    border-radius: 999px;
    background: rgba(15, 118, 110, 0.12);
    color: #0f766e;
}
.topic-path-list {
    margin: 0.35rem 0 0;
    padding-left: 1.1rem;
    display: grid;
    gap: 0.2rem;
}
.topic-path-list a {
    font-size: 0.82rem;
    color: var(--muted);
    text-decoration: none;
}
.topic-path-list a:hover {
    color: #0f766e;
    text-decoration: underline;
}

/* ── Reaction bar ────────────────────────────────────────────────────────── */
.reaction-bar {
    margin-top: 0.8rem;
}

.reaction-form {
    display: flex;
    gap: 0.5rem;
}

.btn-reaction {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.3rem 0.7rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    border: 1px solid transparent;
}

.btn-like {
    background: #f0fdf4;
    color: #166534;
    border-color: #86efac;
}

.btn-like:hover {
    background: #bbf7d0;
    transform: scale(1.05);
}

.btn-dislike {
    background: #fff1f2;
    color: #9f1239;
    border-color: #fca5a5;
}

.btn-dislike:hover {
    background: #fecdd3;
    transform: scale(1.05);
}

/* ── Pagination bar ──────────────────────────────────────────────────────── */
.pagination-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 0.4rem;
    margin: 1.5rem 0 2rem;
}

.page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.2rem;
    padding: 0.4rem 0.7rem;
    border-radius: 8px;
    border: 1px solid #c9bda9;
    background: #fffdfa;
    color: #3d392f;
    font-size: 0.88rem;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.15s;
}

.page-btn:hover {
    background: #f2ab27;
    border-color: #f08f45;
    color: #2c1f04;
}

.page-btn--active {
    background: linear-gradient(120deg, #f2ab27, #f08f45);
    color: #2c1f04;
    border-color: #f08f45;
    cursor: default;
}

.page-btn--disabled {
    opacity: 0.4;
    cursor: default;
}

.page-btn--ellipsis {
    border: none;
    background: transparent;
    cursor: default;
}

/* ── Background Agents UI ─────────────────────────────────────── */
.agent-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-top: 0.75rem;
}

.agent-card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 1rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.agent-card-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.agent-desc {
    font-size: 0.82rem;
    color: var(--muted);
    margin: 0;
}

.agent-meta {
    font-size: 0.78rem;
    color: var(--muted);
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.agent-error {
    color: #c0392b;
    font-size: 0.78rem;
}

.agent-interval-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.25rem;
}

.agent-interval-form label {
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.status-badge {
    display: inline-block;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
}

.badge-ok { background: #d4edda; color: #155724; }
.badge-running { background: #cce5ff; color: #004085; }
.badge-error { background: #f8d7da; color: #721c24; }
.badge-idle { background: #e6e6e6; color: #555; }

.loading-hint {
    color: var(--muted);
    font-size: 0.85rem;
}

.empty-state {
    color: var(--muted);
    font-style: italic;
}

/* ── Self Healer Queue ────────────────────────────────────────── */
.healer-action-card {
    border-left: 4px solid var(--line);
    background: var(--panel);
    border-radius: 6px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
}

.healer-action-card.sev-critical { border-left-color: #c0392b; }
.healer-action-card.sev-warning { border-left-color: #e67e22; }
.healer-action-card.sev-info { border-left-color: #3498db; }
.healer-action-card.ha-resolved { opacity: 0.65; }

.ha-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.35rem;
}

.sev-badge {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    background: #ececec;
    color: #555;
}

.ha-fix {
    background: #f4f4f4;
    border-radius: 5px;
    padding: 0.5rem 0.75rem;
    font-size: 0.78rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 100px;
    overflow-y: auto;
}

.ha-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-top: 0.5rem;
}

.ha-meta {
    font-size: 0.75rem;
    color: var(--muted);
}

/* ── Agent Content Queue ─────────────────────────────────────── */
.content-queue-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 0.6rem;
    background: var(--panel);
}

.cq-head {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    margin-bottom: 0.35rem;
}

.cq-type {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    background: #e8f4fd;
    color: #2980b9;
    padding: 2px 7px;
    border-radius: 4px;
}

.cq-preview {
    font-size: 0.83rem;
    color: var(--muted);
    margin: 0 0 0.4rem;
    max-height: 60px;
    overflow: hidden;
}

.cq-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.cq-meta {
    font-size: 0.75rem;
    color: var(--muted);
}

/* ── Kinematics laboratory ───────────────────────────────────── */
.k-hero-stills {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.85rem;
    margin: 0 0 1.2rem;
}

.k-hero-stills figure,
.material-still {
    margin: 0.85rem 0 0;
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--line);
    background: #081018;
}

.k-hero-stills img,
.material-still img {
    display: block;
    width: 100%;
    height: 180px;
    object-fit: cover;
}

.k-hero-stills figcaption {
    padding: 0.45rem 0.7rem 0.6rem;
    font-size: 0.78rem;
    color: #cfe7f3;
}

.k-lab {
    padding-top: 1rem;
}

.k-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-bottom: 0.9rem;
}

.k-tab {
    border: 1px solid var(--line);
    background: var(--panel);
    color: var(--ink);
    border-radius: 999px;
    padding: 0.38rem 0.78rem;
    font: inherit;
    font-size: 0.82rem;
    cursor: pointer;
}

.k-tab.is-active {
    background: #12323a;
    color: #d7eef5;
    border-color: #2ee6c6;
}

.k-pane {
    display: none;
}

.k-pane.is-active {
    display: block;
}

.k-sim-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(220px, 1fr);
    gap: 1rem;
    align-items: start;
}

.k-canvas {
    width: 100%;
    height: 360px;
    display: block;
    border-radius: 14px;
    background: #0b1520;
    border: 1px solid #1b3344;
}

.k-canvas-wide {
    height: 300px;
}

.k-controls {
    display: grid;
    gap: 0.7rem;
}

.k-controls label {
    display: grid;
    gap: 0.28rem;
    font-size: 0.84rem;
    color: var(--muted);
}

.k-controls input[type="range"],
.k-controls select {
    width: 100%;
}

.k-btn-row {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.k-formula {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.45;
    color: var(--muted);
}

.k-card-cta,
.exam-lab-cta {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin: 0.7rem 0;
}

@media (max-width: 900px) {
    .k-hero-stills,
    .k-sim-grid {
        grid-template-columns: 1fr;
    }

    .k-hero-stills img {
        height: 160px;
    }
}

@media (max-width: 700px) {
    .question-filter-grid {
        grid-template-columns: 1fr 1fr;
    }
}

