:root {
    --ink: #172033;
    --muted: #667085;
    --line: #d9e1ec;
    --surface: #ffffff;
    --page: #f5f7fb;
    --blue: #0a58ca;
    --cyan: #12b8f2;
    --green: #138a54;
    --red: #c24135;
    --shadow: 0 18px 45px rgba(21, 32, 54, 0.12);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--page);
    font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { color: inherit; }

.page-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.topbar {
    height: 72px;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.92);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    font-weight: 800;
}

.brand img { height: 42px; max-width: 160px; object-fit: contain; }

.nav-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.btn {
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--ink);
    border-radius: 8px;
    min-height: 40px;
    padding: 9px 14px;
    font-weight: 750;
    text-decoration: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn.primary { border-color: var(--blue); background: var(--blue); color: #fff; }
.btn.green { border-color: var(--green); background: var(--green); color: #fff; }
.btn.danger { border-color: var(--red); color: var(--red); }
.btn.ghost { background: transparent; }

.hero {
    min-height: calc(100vh - 72px);
    display: grid;
    grid-template-columns: minmax(0, 1.05fr) minmax(320px, 0.95fr);
    gap: 34px;
    align-items: center;
    padding: 48px clamp(18px, 5vw, 76px);
}

.hero h1 {
    font-size: clamp(38px, 5vw, 76px);
    line-height: 1;
    margin: 0 0 18px;
    letter-spacing: 0;
}

.hero p {
    color: var(--muted);
    font-size: 18px;
    line-height: 1.65;
    max-width: 720px;
}

.hero-panel,
.auth-card,
.panel,
.plan-card,
.admin-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.hero-panel { padding: 20px; }
.metric-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.metric { padding: 16px; border: 1px solid var(--line); border-radius: 8px; }
.metric b { display: block; font-size: 24px; margin-bottom: 6px; }
.metric span { color: var(--muted); font-size: 13px; }

.auth-wrap {
    min-height: calc(100vh - 72px);
    display: grid;
    place-items: center;
    padding: 28px 16px;
}

.auth-card { width: min(460px, 100%); padding: 26px; }
.auth-card h1, .panel h2, .admin-card h2 { margin: 0 0 10px; }
.muted { color: var(--muted); }
.error { color: var(--red); font-weight: 700; }
.success { color: var(--green); font-weight: 700; }

.field { display: grid; gap: 7px; margin: 14px 0; }
.field label { font-size: 13px; color: #344054; font-weight: 750; }
.input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 12px 13px;
    min-height: 44px;
    background: #fff;
    color: var(--ink);
    font: inherit;
}

textarea { min-height: 150px; resize: vertical; }

.app {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 18px;
    height: 100vh;
    overflow-y: auto;
    position: sticky;
    top: 0;
}

.side-section { margin-top: 22px; }
.sidebar .side-section:first-child { margin-top: 12px; }
.side-title { font-size: 12px; color: var(--muted); text-transform: uppercase; font-weight: 800; margin: 0 0 10px; }
.history-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    color: #3f4b5f;
    text-decoration: none;
    min-width: 0;
}
.history-link:hover, .history-link.active { background: #edf6ff; color: var(--blue); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main-content { min-width: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
.chat-header {
    min-height: 72px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 22px;
    border-bottom: 1px solid var(--line);
    background: rgba(255,255,255,.92);
}
.chat-header h1 { font-size: 20px; margin: 0; }
.token-pill { border: 1px solid var(--line); border-radius: 999px; padding: 8px 12px; background: #fff; font-size: 13px; font-weight: 800; white-space: nowrap; }

.profile-menu-wrap {
    position: relative;
    display: inline-flex;
}

.profile-icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 999px;
    border: 1px solid rgba(10, 88, 202, .24);
    background: var(--blue);
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 900;
    font-size: 18px;
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(10, 88, 202, .16);
}

.profile-icon-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 28px rgba(10, 88, 202, .22);
}

.profile-dropdown {
    display: none;
    position: absolute;
    right: 0;
    top: 50px;
    z-index: 1000;
    min-width: 150px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(21, 32, 54, 0.18);
    overflow: hidden;
}

.profile-dropdown[hidden] { display: none !important; }
.profile-dropdown.show { display: block; }

.profile-dropdown a {
    display: block;
    padding: 11px 13px;
    text-decoration: none;
    font-weight: 800;
}

.profile-dropdown a:hover {
    background: #f8fafc;
}

.chat-container {
    flex: 1;
    padding: 24px clamp(18px, 3vw, 44px);
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding-bottom: 118px;
}

.welcome { max-width: 980px; margin: 20px auto; width: 100%; }
.quick-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 18px; }
.chip {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 8px;
    padding: 13px;
    cursor: pointer;
    text-align: left;
    font-weight: 800;
    color: var(--ink);
}
.chip:hover { border-color: var(--cyan); color: var(--blue); }

.msg {
    max-width: min(860px, 92%);
    padding: 14px 16px;
    border-radius: 8px;
    line-height: 1.55;
}
.msg.user { background: #e8f3ff; align-self: flex-end; color: #0b459c; }
.msg.bot { background: #fff; border: 1px solid var(--line); align-self: flex-start; }
.msg.bot h3 { margin-top: 6px; }

.composer {
    position: fixed;
    left: 344px;
    right: 24px;
    bottom: 22px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    padding: 10px;
}
.composer input { border: 0; outline: 0; min-height: 44px; font: inherit; padding: 0 8px; }

.plans { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin-top: 20px; }
.plan-card { padding: 20px; box-shadow: none; }
.price { font-size: 32px; font-weight: 900; margin: 8px 0; }

.admin-wrap { padding: 24px; max-width: 1180px; margin: 0 auto; }
.admin-wrap h1 { color: var(--ink); }
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.admin-card { padding: 20px; box-shadow: none; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { border-bottom: 1px solid var(--line); padding: 10px; text-align: left; vertical-align: top; }

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    font-size: 12px;
    font-weight: 850;
    white-space: nowrap;
}

.status-pill.success {
    background: #dcfce7;
    color: #166534;
}

.status-pill.warning {
    background: #fff7ed;
    color: #9a3412;
}

.status-pill.danger {
    background: #fee2e2;
    color: #b91c1c;
}

.material-preview {
    margin-top: 6px;
    color: var(--muted);
}

.material-preview summary {
    cursor: pointer;
    color: var(--blue);
    font-weight: 750;
}
.exam-row-form {
    display: grid;
    grid-template-columns: minmax(220px, 1.4fr) minmax(150px, .8fr) 110px auto;
    gap: 8px;
    align-items: center;
}

.exam-row-form .nav-actions {
    flex-wrap: nowrap;
    justify-content: flex-end;
}

@media (max-width: 900px) {
    .hero, .app, .admin-grid { grid-template-columns: 1fr; }
    .app { height: auto; overflow: visible; }
    .hero { min-height: auto; padding-top: 30px; }
    .sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--line); }
    .main-content { height: auto; min-height: 100vh; }
    .composer { left: 12px; right: 12px; bottom: 12px; }
    .quick-grid, .plans { grid-template-columns: 1fr; }
    .chat-header { align-items: flex-start; flex-direction: column; }
}

@media print {
    .sidebar, .chat-header, .composer, .no-print { display: none !important; }
    .app, .main-content { display: block; height: auto; }
    .chat-container { padding: 0; overflow: visible; }
    .msg { max-width: 100%; box-shadow: none; border: 0; }
    .msg.user { display: none; }
}

/* Selct AI exam cockpit */
:root {
    --accent: #f97316;
    --teal: #0f9f8f;
    --sun: #fbbf24;
    --violet: #5b5bd6;
    --soft-blue: #e9f3ff;
    --soft-orange: #fff4e8;
}

.app {
    background:
        linear-gradient(135deg, rgba(15, 159, 143, .08), rgba(249, 115, 22, .08)),
        radial-gradient(circle at top right, rgba(251, 191, 36, .18), transparent 34%),
        var(--page);
}

.sidebar {
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 52%, #fff7ed 100%);
}

.gemini-sidebar { padding-bottom: 14px; }
.new-chat-btn { margin-bottom: 14px; }
.sidebar-block { margin-top: 12px; }
.compact-input { min-height: 40px; padding: 9px 11px; }
.chat-history-list {
    max-height: 330px;
    overflow-y: auto;
    padding-right: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(217, 225, 236, .75);
}

.affiliate-box {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    display: grid;
    gap: 8px;
}

.copy-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
    align-items: center;
}

.icon-copy-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.icon-copy-btn svg,
.voice-btn svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-copy-btn:hover {
    border-color: var(--blue);
    color: var(--blue);
    background: #edf6ff;
}

.mini-profile {
    display: grid;
    gap: 4px;
    text-decoration: none;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.mini-profile strong { font-size: 15px; }
.mini-profile small { color: var(--muted); }
.account-links .token-summary,
.token-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin: 8px 0 10px;
}

.account-links .token-summary div,
.token-summary div {
    border: 1px solid var(--line);
    border-radius: 8px;
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    padding: 10px;
    min-height: 72px;
    box-shadow: 0 8px 20px rgba(21, 32, 54, 0.05);
}

.account-links .token-summary span,
.token-summary span {
    display: block;
    color: var(--muted);
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.account-links .token-summary b,
.token-summary b {
    display: block;
    color: var(--blue);
    font-size: 24px;
    line-height: 1.1;
    margin-top: 4px;
}

.account-links .token-summary em,
.token-summary em {
    display: block;
    margin-top: 2px;
    color: var(--muted);
    font-size: 11px;
    font-style: normal;
    font-weight: 750;
}
.tight-actions { gap: 8px; }
.logout-btn { width: 100%; margin-top: 12px; }

.profile-mini {
    display: grid;
    gap: 4px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
}

.profile-mini strong { font-size: 16px; }
.profile-mini small { color: var(--muted); overflow-wrap: anywhere; }

.history-row {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 34px;
    align-items: center;
    gap: 4px;
    margin-bottom: 6px;
}

.icon-menu {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid transparent;
    background: transparent;
    cursor: pointer;
    font-weight: 900;
}

.icon-menu:hover { background: #fff; border-color: var(--line); }

.portal-menu {
    display: none;
    position: fixed;
    z-index: 1000;
    min-width: 148px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 18px 45px rgba(21, 32, 54, 0.18);
    overflow: hidden;
}

.portal-menu button {
    width: 100%;
    border: 0;
    background: #fff;
    padding: 10px 12px;
    text-align: left;
    cursor: pointer;
    font-weight: 700;
}

.portal-menu button:hover { background: #f8fafc; }
.danger-text { color: var(--red); }

.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1100;
    background: rgba(15, 23, 42, .36);
    align-items: center;
    justify-content: center;
    padding: 18px;
}

.modal-backdrop.show { display: flex; }

.modal-box {
    width: min(430px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 24px 70px rgba(15, 23, 42, .24);
    padding: 18px;
}

.modal-box h3 { margin: 0 0 8px; font-size: 20px; }
.modal-box p { margin: 0 0 14px; }
.modal-actions { justify-content: flex-end; margin-top: 14px; }

.toast {
    position: fixed;
    right: 22px;
    bottom: 22px;
    z-index: 1200;
    background: #101828;
    color: #fff;
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: var(--shadow);
    opacity: 0;
    transform: translateY(8px);
    pointer-events: none;
    transition: .18s ease;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.chat-header {
    background:
        linear-gradient(90deg, rgba(255,255,255,.96), rgba(233,243,255,.96)),
        linear-gradient(120deg, rgba(249,115,22,.10), transparent);
}

.chat-titlebar {
    display: flex;
    align-items: center;
    gap: 12px;
}

.study-badge {
    display: inline-flex;
    align-items: center;
    border-radius: 999px;
    padding: 6px 10px;
    background: var(--soft-orange);
    color: #9a3412;
    font-size: 12px;
    font-weight: 900;
}

.chat-container {
    background:
        linear-gradient(180deg, rgba(255,255,255,.25), rgba(255,255,255,0)),
        repeating-linear-gradient(0deg, rgba(10,88,202,.035), rgba(10,88,202,.035) 1px, transparent 1px, transparent 36px);
    scroll-behavior: smooth;
    align-items: stretch;
}

.msg {
    font-size: 16px;
    line-height: 1.45;
}

.msg.user {
    background: linear-gradient(135deg, #0a58ca, #0f9f8f);
    color: #fff;
    max-width: min(900px, 78%);
}

.msg.bot {
    width: min(1040px, 96%);
    border-left: 5px solid var(--teal);
    box-shadow: 0 12px 30px rgba(23, 32, 51, .08);
}

.msg.bot.question-result {
    width: min(1280px, 100%);
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.msg.bot:has(.question-card) {
    width: min(1280px, 100%);
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
}

.msg.bot .content-body h3 {
    margin: 6px 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: linear-gradient(90deg, #e9f3ff, #fff4e8);
    color: #0b459c;
}

.msg.bot .content-body h4 {
    margin: 14px 0 8px;
    color: #0f766e;
}

.msg.bot .content-body p {
    margin: 4px 0;
}

.msg.bot .content-body b,
.msg.bot .content-body strong {
    color: #111827;
}

.msg.bot .content-body ol,
.msg.bot .content-body ul {
    padding-left: 20px;
    margin: 6px 0;
}

.msg.bot .content-body li {
    margin: 4px 0;
}

.msg.search-hit {
    outline: 3px solid rgba(251, 191, 36, .95);
    box-shadow: 0 0 0 8px rgba(251, 191, 36, .18);
}

.content-body table {
    width: 100%;
    border-collapse: collapse;
    margin: 14px 0;
}

.content-body th,
.content-body td {
    border: 1px solid var(--line);
    padding: 10px;
    vertical-align: top;
}

.resource-box {
    margin-top: 12px;
    padding: 12px 14px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-left: 4px solid var(--accent);
    border-radius: 8px;
}

.resource-links {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
}

.resource-icon-link {
    min-width: 42px;
    height: 42px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: 0 8px 18px rgba(23, 32, 51, .08);
    font-size: 14px;
    font-weight: 850;
}

.resource-icon-link svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.resource-icon-link.youtube {
    background: #ef4444;
    border-color: #ef4444;
    color: #ffffff;
}

.resource-icon-link.youtube svg path:first-child {
    fill: #ffffff;
}

.resource-icon-link.youtube svg path:last-child {
    fill: rgba(255, 255, 255, .22);
}

.resource-icon-link.google {
    background: #ffffff;
    border-color: #cfe0ff;
    color: #2563eb;
    font-weight: 900;
}

.resource-icon-link:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.answer-box,
.question-card {
    border: 1px solid var(--line);
    border-left: 5px solid var(--blue);
    border-radius: 8px;
    background: #ffffff;
    padding: 12px;
    margin: 16px 0;
    position: relative;
}

.question-card {
    background:
        linear-gradient(135deg, rgba(233,243,255,.9), rgba(255,255,255,.96)),
        #fff;
    padding: 18px 20px;
    box-shadow: 0 14px 35px rgba(23, 32, 51, .08);
}

.option-line {
    margin: 4px 0 !important;
    line-height: 1.45 !important;
}

.question-card .question-card {
    border: 0;
    border-left: 0;
    background: transparent;
    padding: 0;
    margin: 0;
    box-shadow: none;
}

.question-line {
    font-weight: 650;
    color: #071a3d;
    font-size: 17px;
    line-height: 1.5;
    margin-bottom: 10px !important;
}

.question-line b {
    color: #0f766e;
}

.question-card br + br,
.answer-box br + br,
.resource-box br + br {
    display: none;
}

.question-card p,
.answer-box p,
.resource-box p {
    margin: 7px 0;
    line-height: 1.55;
}

.answer-box {
    border-left-color: var(--green);
    background: #f0fdf4;
    margin-top: 12px;
    padding: 13px 15px;
}

.result-actions {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.soft-warning {
    border: 1px solid #fed7aa;
    border-left: 4px solid var(--accent);
    background: #fff7ed;
    color: #9a3412;
    border-radius: 8px;
    padding: 10px 12px;
    font-weight: 750;
}

.content-body a {
    color: #0a58ca;
    font-weight: 850;
    text-decoration: none;
}

.content-body a:hover { text-decoration: underline; }

.format-note {
    display: inline-flex;
    margin: 8px 0 12px;
    padding: 7px 10px;
    border-radius: 999px;
    background: #ecfeff;
    color: #155e75;
    font-size: 13px;
    font-weight: 900;
}

.composer {
    grid-template-columns: auto 1fr auto;
    border: 1px solid rgba(15,159,143,.3);
    border-radius: 14px;
    padding: 12px;
}

.voice-btn {
    width: 42px;
    min-height: 42px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--soft-blue);
    cursor: pointer;
    font-weight: 900;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--blue);
}

.composer input {
    font-size: 16px;
}

.muted-pill {
    background: #f8fafc;
    color: #475569;
}

.voice-btn.listening {
    background: #fee2e2;
    color: var(--red);
}

.save-note-btn {
    float: right;
    margin-left: 12px;
    border: 1px solid var(--line);
    background: #fff7ed;
    color: #9a3412;
    border-radius: 8px;
    min-height: 34px;
    padding: 6px 10px;
    cursor: pointer;
    font-weight: 800;
}

.save-note-btn.fav {
    background: #fff;
    color: #0b459c;
}

.save-actions {
    float: right;
    display: inline-flex;
    gap: 6px;
    margin-left: 12px;
}

.question-actions {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    margin-bottom: 4px;
}

.heart-btn {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    border: 1px solid #ffd6d6;
    background: #fff;
    color: #dc2626;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
}

.heart-btn:hover {
    background: #fff1f2;
    transform: translateY(-1px);
}

.loading-row {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--muted);
    font-weight: 800;
}

.msg.bot.loading-message {
    width: auto;
    min-width: 280px;
    padding: 14px 18px;
    border-left-color: var(--blue);
    box-shadow: 0 12px 26px rgba(23, 32, 51, .07);
}

.loader {
    width: 18px;
    height: 18px;
    border: 3px solid #dbeafe;
    border-top-color: var(--blue);
    border-radius: 999px;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.saved-note-card .content-body {
    line-height: 1.42;
}

.saved-note-card .content-body p {
    margin: 6px 0;
}

.chat-search {
    min-width: 220px;
    max-width: 280px;
}

.chat-search input {
    min-height: 40px;
}

.language-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 7px 10px;
    background: #fff;
    font-size: 13px;
    font-weight: 800;
}

.subject-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.subject-card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px;
    background: linear-gradient(160deg, #fff, #f8fbff);
    cursor: pointer;
    text-align: left;
    font-weight: 850;
}

.subject-card:hover { border-color: var(--teal); transform: translateY(-1px); }

.watermark {
    display: none;
}

@media print {
    .watermark {
        display: block;
        position: fixed;
        left: 50%;
        bottom: 22px;
        transform: translateX(-50%);
        color: rgba(23,32,51,.38);
        font-weight: 900;
        z-index: 9999;
    }
}

@media (max-width: 900px) {
    body { overflow: auto; }
    .chat-container {
        padding: 14px 12px;
        padding-bottom: 104px;
        gap: 10px;
    }

    .composer {
        grid-template-columns: auto 1fr auto;
        bottom: 8px;
        left: 8px;
        right: 8px;
        padding: 8px;
        gap: 6px;
    }

    .composer .language-chip { display: none; }
    .msg { max-width: 100%; width: 100%; font-size: 15px; }
    .msg.bot.question-result { width: 100%; }
    .question-card { padding: 10px; margin: 8px 0; }
    .question-card { padding: 13px; }
    .answer-box, .resource-box { padding: 10px; }
    .question-line { font-size: 16px; }
    .profile-mini { grid-template-columns: 1fr; }
    .sidebar { max-height: 44vh; overflow-y: auto; padding: 14px; }
    .chat-search { width: 100%; max-width: none; }
    .chat-header { padding: 12px; gap: 8px; }
    .chat-header h1 { font-size: 18px; }
    .token-pill { padding: 7px 10px; }
    .profile-icon-btn { width: 40px; height: 40px; }
    .voice-btn { width: 40px; min-height: 40px; }
    .composer input { min-width: 0; font-size: 15px; }
    .composer .btn { padding: 8px 11px; min-height: 40px; }
    .exam-row-form {
        grid-template-columns: 1fr;
        padding: 8px 0;
    }
    .exam-row-form .nav-actions {
        justify-content: flex-start;
    }
}

.admin-wrap {
    width: min(1220px, calc(100% - 32px));
    overflow-y: auto;
    height: 100vh;
}

.topbar + .admin-wrap,
.app > .admin-wrap {
    background:
        linear-gradient(135deg, rgba(233,243,255,.82), rgba(255,244,232,.86)),
        var(--page);
    border-radius: 8px;
    margin-top: 0;
}

.admin-sidebar {
    background: linear-gradient(180deg, #ffffff, #eef9ff 58%, #fff7ed);
}
