/* ═══════════════════════════════════════════════════════════
   CRIDANSE — OpenAI-style theme
   ═══════════════════════════════════════════════════════════ */
:root {
    --bg: #0f0f10;
    --bg-elev: #17181a;
    --bg-hover: #1f2023;
    --bg-active: #26282c;
    --sidebar: #0a0a0b;
    --border: #2a2c30;
    --border-soft: #1e2024;
    --text: #ececf1;
    --text-dim: #a1a3a8;
    --text-mute: #6e7076;
    --accent: #10a37f;
    --accent-h: #0e8f70;
    --accent-soft: rgba(16,163,127,.15);
    --danger: #ef4146;
    --user-bubble: #2a2c30;
    --radius: 12px;
    --radius-lg: 22px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0,0,0,.4);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html.light {
    --bg: #ffffff;
    --bg-elev: #f7f7f8;
    --bg-hover: #ececf1;
    --bg-active: #e3e3e7;
    --sidebar: #f9f9fa;
    --border: #e5e5e7;
    --border-soft: #efeff1;
    --text: #0d0d0d;
    --text-dim: #565869;
    --text-mute: #8e8ea0;
    --accent: #10a37f;
    --accent-h: #0e8f70;
    --accent-soft: rgba(16,163,127,.1);
    --user-bubble: #ececf1;
    --shadow: 0 8px 32px rgba(0,0,0,.08);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; font-size: inherit; /*color: inherit; */}
::selection { background: var(--accent-soft); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ═══════════ LAYOUT ═══════════ */
.app { display: flex; height: 100vh; overflow: hidden; }

/* ═══════════ SIDEBAR ═══════════ */
.sidebar {
    width: 260px;
    background: var(--sidebar);
    border-right: 1px solid var(--border-soft);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    padding: 12px 8px;
    transition: transform .2s ease;
}
.sidebar-head {
    display: flex; align-items: center; gap: 8px;
    padding: 6px 10px 14px;
}
.brand {
    font-weight: 700; font-size: 16px; letter-spacing: .06em;
    color: var(--text);
}
.brand:hover { text-decoration: none; }

.new-chat-btn {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: transparent;
    color: var(--text);
    font-size: 14px;
    margin-bottom: 12px;
    transition: background .15s;
}
.new-chat-btn:hover { background: var(--bg-hover); text-decoration: none; }
.new-chat-btn svg { width: 16px; height: 16px; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nav-section-title {
    font-size: 11px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .08em; color: var(--text-mute);
    padding: 14px 10px 6px;
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 13.5px;
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    transition: background .12s, color .12s;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.nav-item svg { width: 16px; height: 16px; flex-shrink: 0; }

.sidebar-bottom {
    border-top: 1px solid var(--border-soft);
    padding-top: 10px;
    display: flex; flex-direction: column; gap: 2px;
    margin-top: 12px;
}

.user-card {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}
.avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 600; font-size: 13px;
    flex-shrink: 0;
}
.avatar-lg { width: 56px; height: 56px; font-size: 22px; }
.user-name { font-size: 13.5px; font-weight: 500; }
.user-plan { font-size: 11.5px; color: var(--text-mute); }

.lang-switch {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    font-size: 13px;
}
.lang-switch svg { width: 16px; height: 16px; }
.lang-switch select {
    background: transparent; border: none; color: inherit;
    font-size: 13px; cursor: pointer; flex: 1; outline: none;
}

/* ═══════════ MAIN ═══════════ */
.main {
    flex: 1; display: flex; flex-direction: column;
    overflow: hidden; position: relative;
}

/* ═══════════ HOME ═══════════ */
.home {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}
.anon-banner {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 16px;
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 24px;
    max-width: 640px;
}
.anon-banner svg { width: 16px; height: 16px; flex-shrink: 0; color: var(--accent); }

.home-title {
    font-size: 28px; font-weight: 600;
    text-align: center;
    margin-bottom: 28px;
    letter-spacing: -.02em;
}

.chat-input-form {
    width: 100%; max-width: 720px;
    display: flex; flex-direction: column; gap: 10px;
}
.chat-input {
    display: flex; align-items: flex-end; gap: 6px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 8px 8px 8px 14px;
    transition: border-color .15s, box-shadow .15s;
}
.chat-input:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.chat-input textarea {
    flex: 1;
    background: transparent;
    border: none; outline: none; resize: none;
    padding: 8px 0;
    font-size: 15px;
    line-height: 1.5;
    max-height: 200px;
    color: var(--text);
}
.chat-input textarea::placeholder { color: var(--text-mute); }

.icon-btn {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-dim);
    transition: background .12s, color .12s;
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; }
.icon-danger:hover { color: var(--danger); background: rgba(239,65,70,.1); }

.send-btn {
    width: 32px; height: 32px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--accent);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    transition: background .12s;
    flex-shrink: 0;
}
.send-btn:hover { background: var(--accent-h); }
.send-btn svg { width: 18px; height: 18px; }

.context-chip {
    display: flex; align-items: center; gap: 8px;
    align-self: flex-start;
    padding: 6px 10px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12.5px;
    color: var(--text-dim);
}
.context-chip svg { width: 14px; height: 14px; }
.chip-x {
    background: transparent; border: none; color: inherit;
    display: inline-flex; align-items: center;
    padding: 0; margin-left: 4px;
    opacity: .6;
}
.chip-x:hover { opacity: 1; color: var(--danger); }
.chip-x svg { width: 12px; height: 12px; }

/* ═══════════ RECENT ═══════════ */
.recent-block {
    width: 100%; max-width: 720px;
    margin-top: 48px;
}
.recent-title {
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .08em;
    color: var(--text-mute);
    margin-bottom: 12px;
}
.recent-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
}
.recent-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    color: var(--text);
    transition: background .12s, border-color .12s;
}
.recent-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
    text-decoration: none;
}
.recent-item svg { width: 16px; height: 16px; color: var(--text-mute); flex-shrink: 0; }
.recent-meta { min-width: 0; }
.recent-name { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent-date { font-size: 11px; color: var(--text-mute); }

/* ═══════════ CHAT VIEW ═══════════ */
.chat-view {
    flex: 1; display: flex; flex-direction: column; overflow: hidden;
}
.chat-scroll {
    flex: 1; overflow-y: auto;
    padding: 24px 20px;
}
.chat-messages {
    max-width: 760px; margin: 0 auto;
    display: flex; flex-direction: column; gap: 22px;
}
.chat-empty {
    text-align: center; color: var(--text-mute);
    padding: 60px 20px;
}
.chat-empty svg { width: 40px; height: 40px; margin-bottom: 12px; opacity: .5; }

.message { display: flex; gap: 12px; }
.message.user { justify-content: flex-end; }
.message.user .message-content {
    background: var(--user-bubble);
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 78%;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.message.assistant { align-items: flex-start; }
.message.assistant .message-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    flex-shrink: 0;
}
.message.assistant .message-avatar svg { width: 16px; height: 16px; }
.message-body { flex: 1; min-width: 0; }
.message.assistant .message-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    line-height: 1.65;
}
.message-actions { margin-top: 8px; }

.sources {
    margin-top: 10px;
    padding: 12px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}
.sources-title {
    font-size: 12px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-dim);
    display: flex; align-items: center; gap: 6px;
    margin-bottom: 8px;
}
.sources-title svg { width: 14px; height: 14px; }
.source-item {
    padding: 8px 0;
    border-top: 1px solid var(--border-soft);
}
.source-item:first-of-type { border-top: none; padding-top: 0; }
.source-head {
    display: flex; justify-content: space-between; gap: 10px;
    font-size: 12.5px; font-weight: 500;
    margin-bottom: 4px;
}
.source-score { color: var(--text-mute); font-variant-numeric: tabular-nums; }
.source-snippet { font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }

.chat-input-bar {
    border-top: 1px solid var(--border-soft);
    background: var(--bg);
    padding: 12px 20px 16px;
}
.context-row {
    max-width: 760px; margin: 0 auto 8px;
    display: flex; align-items: center; gap: 8px;
    font-size: 12px;
}
.context-label {
    display: inline-flex; align-items: center; gap: 6px;
    color: var(--text-mute);
    flex: 1;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.context-label svg { width: 14px; height: 14px; }

.chip-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: transparent;
    color: var(--text-dim);
    font-size: 12px;
    transition: background .12s, color .12s;
}
.chip-btn:hover { background: var(--bg-hover); color: var(--text); text-decoration: none; }
.chip-btn svg { width: 13px; height: 13px; }
.chip-danger:hover { color: var(--danger); border-color: var(--danger); }

/* ═══════════ PAGES ═══════════ */
.page {
    flex: 1; overflow-y: auto;
    padding: 32px 40px 60px;
    max-width: 1100px;
    width: 100%;
    margin: 0 auto;
}
.page-narrow { max-width: 640px; }
.page-head {
    display: flex; justify-content: space-between; align-items: center;
    gap: 16px; margin-bottom: 28px;
    flex-wrap: wrap;
}
.page-head.center { flex-direction: column; text-align: center; }
.page-head h1 { font-size: 24px; font-weight: 600; letter-spacing: -.02em; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.section { margin-top: 40px; }
.section h2 {
    font-size: 16px; font-weight: 600;
    margin-bottom: 16px;
    letter-spacing: -.01em;
}

.card {
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 20px;
}

/* ═══════════ BUTTONS ═══════════ */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 8px;
    padding: 9px 16px;
    border-radius: var(--radius-sm);
    font-size: 13.5px; font-weight: 500;
    border: 1px solid transparent;
    transition: background .12s, border-color .12s, color .12s;
    cursor: pointer;
    white-space: nowrap;
}
.btn:hover { text-decoration: none; }
.btn svg { width: 15px; height: 15px; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-h); }
.btn-secondary {
    background: var(--bg-elev); color: var(--text);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg-hover); }
.btn-ghost {
    background: transparent; color: var(--text-dim);
}
.btn-ghost:hover { background: var(--bg-hover); color: var(--text); }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ═══════════ FORMS ═══════════ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 12.5px; font-weight: 500;
    color: var(--text-dim);
    margin-bottom: 6px;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .12s, box-shadow .12s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid { display: flex; flex-direction: column; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; }
.inline-form input { flex: 1; padding: 8px 12px; background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-sm); }

.search-row { display: flex; gap: 8px; margin-bottom: 20px; }
.search-input {
    flex: 1;
    display: flex; align-items: center; gap: 8px;
    padding: 8px 12px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
}
.search-input svg { width: 16px; height: 16px; color: var(--text-mute); }
.search-input input {
    flex: 1; background: transparent; border: none; outline: none;
}

/* ═══════════ AUTH ═══════════ */
.auth-page {
    flex: 1; display: flex; align-items: center; justify-content: center;
    padding: 40px 20px;
    overflow-y: auto;
}
.auth-card {
    width: 100%; max-width: 400px;
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 32px;
}
.auth-card-wide { max-width: 620px; }
.auth-card h1 { font-size: 22px; font-weight: 600; margin-bottom: 6px; }
.auth-card .muted { color: var(--text-dim); font-size: 13.5px; margin-bottom: 24px; }
.auth-form { display: flex; flex-direction: column; }
.auth-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
    color: var(--text-mute);
    font-size: 12px;
}
.auth-divider::before {
    content: ''; position: absolute; left: 0; right: 0; top: 50%;
    border-top: 1px solid var(--border-soft);
}
.auth-divider span {
    background: var(--bg-elev); padding: 0 12px; position: relative;
}
.auth-footer {
    text-align: center;
    font-size: 13px; color: var(--text-dim);
    margin-top: 20px;
}

/* ═══════════ MODALS ═══════════ */
.modal {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.55);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center; justify-content: center;
    padding: 20px;
}
.modal.open { display: flex; }
.modal-card {
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    max-width: 440px;
    width: 100%;
    position: relative;
    box-shadow: var(--shadow);
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn .18s ease;
}
.modal-wide { max-width: 720px; }
@keyframes modalIn {
    from { opacity: 0; transform: scale(.96); }
    to { opacity: 1; transform: scale(1); }
}
.modal-x {
    position: absolute; top: 14px; right: 14px;
    width: 30px; height: 30px;
    display: flex; align-items: center; justify-content: center;
    background: transparent; border: none;
    border-radius: var(--radius-sm);
    color: var(--text-mute);
}
.modal-x:hover { background: var(--bg-hover); color: var(--text); }
.modal-x svg { width: 16px; height: 16px; }
.modal-icon {
    width: 48px; height: 48px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex; align-items: center; justify-content: center;
    margin-bottom: 16px;
}
.modal-icon svg { width: 22px; height: 22px; }
.modal-card h3 { font-size: 18px; font-weight: 600; margin-bottom: 8px; }
.modal-card p { color: var(--text-dim); font-size: 14px; margin-bottom: 20px; }
.modal-actions {
    display: flex; gap: 8px; flex-wrap: wrap;
    margin-top: 20px;
}
.modal-card .muted { color: var(--text-mute); font-size: 13px; margin-bottom: 16px; }

/* ═══════════ BOOK GRID ═══════════ */
.book-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}
.book-tile {
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    cursor: pointer;
    transition: border-color .12s, background .12s;
    display: flex; flex-direction: column; gap: 8px;
}
.book-tile:hover { border-color: var(--accent); background: var(--bg-hover); }
.book-tile img {
    width: 100%; aspect-ratio: 3/4; object-fit: cover;
    border-radius: var(--radius-sm);
}
.book-tile-placeholder {
    width: 100%; aspect-ratio: 3/4;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    color: var(--text-mute);
}
.book-tile-placeholder svg { width: 32px; height: 32px; }
.book-tile-title {
    font-size: 13px; font-weight: 500;
    overflow: hidden; text-overflow: ellipsis;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.book-tile-subject { font-size: 11.5px; color: var(--text-mute); }
.book-tile-actions { display: flex; gap: 4px; justify-content: center; flex-wrap: wrap; }
.badge {
    display: inline-block;
    padding: 1px 6px; border-radius: 4px;
    font-size: 10px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
}
.badge-ok { background: var(--accent-soft); color: var(--accent); }

/* ═══════════ TABLES ═══════════ */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13.5px;
    background: var(--bg-elev);
    border-radius: var(--radius);
    overflow: hidden;
}
.data-table th, .data-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border-soft);
}
.data-table th {
    font-size: 11.5px; font-weight: 600;
    text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-mute);
    background: var(--bg-hover);
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); }

/* ═══════════ CHATS LIST ═══════════ */
.chats-list { display: flex; flex-direction: column; gap: 6px; }
.chat-row {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 14px;
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
}
.chat-row-main {
    flex: 1; display: flex; gap: 12px; align-items: center;
    color: var(--text); min-width: 0;
}
.chat-row-main:hover { text-decoration: none; }
.chat-row-main svg { width: 18px; height: 18px; color: var(--text-mute); flex-shrink: 0; }
.chat-row-title { font-size: 13.5px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-row-date { font-size: 11.5px; color: var(--text-mute); }
.chat-row-actions { display: flex; gap: 8px; align-items: center; }
.chat-row-actions select {
    background: var(--bg-hover); border: 1px solid var(--border);
    color: var(--text-dim); padding: 4px 8px;
    border-radius: var(--radius-sm); font-size: 12px; cursor: pointer;
}

.projects-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.project-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 10px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12.5px;
}
.project-chip a { color: var(--text); }

/* ═══════════ PRICING ═══════════ */
.pricing-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.price-card {
    position: relative;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    display: flex; flex-direction: column;
    transition: border-color .15s, transform .15s;
}
.price-card:hover { border-color: var(--accent); transform: translateY(-2px); }
.price-card.current { border-color: var(--accent); }
.price-badge {
    position: absolute; top: -10px; left: 50%; transform: translateX(-50%);
    background: var(--accent); color: #fff;
    padding: 3px 12px; border-radius: 999px;
    font-size: 11px; font-weight: 600;
}
.price-name { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.price-value { font-size: 32px; font-weight: 700; margin-bottom: 12px; }
.price-value span { font-size: 14px; font-weight: 400; color: var(--text-mute); }
.price-desc { font-size: 13px; color: var(--text-dim); margin-bottom: 20px; min-height: 32px; }
.price-features { list-style: none; margin-bottom: 24px; flex: 1; }
.price-features li {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; padding: 6px 0;
    color: var(--text-dim);
}
.price-features svg { width: 14px; height: 14px; color: var(--accent); flex-shrink: 0; }

/* ═══════════ PROFILE ═══════════ */
.profile-head { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.profile-name { font-size: 18px; font-weight: 600; }
.profile-email { font-size: 13px; color: var(--text-mute); }
.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 20px;
}
.kv { display: flex; flex-direction: column; gap: 4px; }
.kv span { font-size: 12px; color: var(--text-mute); }
.kv b { font-size: 14px; font-weight: 500; }

.progress-bar {
    position: relative;
    height: 20px;
    background: var(--bg-hover);
    border-radius: 999px;
    overflow: hidden;
    min-width: 100px;
}
.progress-fill {
    height: 100%; background: var(--accent);
    transition: width .3s;
}
.progress-bar span {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 600; color: var(--text);
}

/* ═══════════ TEST RESULT ═══════════ */
.result-card { padding: 28px; }
.result-score { display: flex; gap: 20px; align-items: center; margin-bottom: 24px; }
.result-circle {
    width: 90px; height: 90px;
    border-radius: 50%;
    background: var(--accent-soft);
    border: 3px solid var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700; color: var(--accent);
    flex-shrink: 0;
}
.result-block {
    padding: 14px 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid var(--border-soft);
}
.result-block-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; font-weight: 600; margin-bottom: 10px;
}
.result-block-title svg { width: 16px; height: 16px; }
.result-strong { background: var(--accent-soft); border-color: var(--accent); }
.result-strong .result-block-title { color: var(--accent); }
.result-weak { background: rgba(239,65,70,.08); border-color: var(--danger); }
.result-weak .result-block-title { color: var(--danger); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    padding: 3px 10px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: 999px;
    font-size: 12px;
}
.chip-weak { border-color: var(--danger); color: var(--danger); }

/* ═══════════ TESTS ═══════════ */
.test-form { display: flex; flex-direction: column; gap: 20px; }
.test-question {
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 20px;
}
.test-question legend {
    font-weight: 600; font-size: 15px;
    padding: 0 8px;
}
.test-option {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background .12s;
    margin-bottom: 4px;
}
.test-option:hover { background: var(--bg-hover); }
.test-option input { accent-color: var(--accent); }

/* ═══════════ PDF VIEWER ═══════════ */
.pdf-wrap { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.pdf-wrap canvas {
    max-width: 100%;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: #fff;
}
.pdf-controls {
    display: flex; align-items: center; gap: 12px;
    font-size: 13px;
}

/* ═══════════ FILES ═══════════ */
.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
}
.file-tile {
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 12px;
    text-align: center;
    display: flex; flex-direction: column; gap: 6px;
    align-items: center;
}
.file-tile:hover { border-color: var(--accent); }
.file-tile img {
    width: 100%; aspect-ratio: 1/1; object-fit: cover;
    border-radius: var(--radius-sm);
}
.file-icon { font-size: 40px; }
.file-name { font-size: 12.5px; word-break: break-all; }
.file-size { font-size: 11px; color: var(--text-mute); }
.file-actions { display: flex; gap: 4px; justify-content: center; }

/* ═══════════ EMPTY STATE ═══════════ */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    background: var(--bg-elev);
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-dim);
}
.empty-state svg {
    width: 40px; height: 40px;
    margin-bottom: 12px;
    opacity: .4;
}
.empty-state p { margin-bottom: 16px; }

/* ═══════════ MISC ═══════════ */
.flash {
    margin: 12px 20px;
    padding: 12px 16px;
    background: var(--bg-elev);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 13.5px;
}
.muted { color: var(--text-mute); font-size: 13.5px; }
.only-mobile { display: none; }
.sidebar-overlay { display: none; }

/* ═══════════ SPINNER ═══════════ */
.spinner-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 9999;
    align-items: center; justify-content: center;
    flex-direction: column; gap: 16px;
}
.spinner-overlay.show { display: flex; }
.spinner {
    width: 40px; height: 40px;
    border: 3px solid rgba(255,255,255,.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.spinner-text { color: #fff; font-size: 13px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════ ADMIN ═══════════ */
.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 28px;
}
.stat-card {
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    padding: 20px;
}
.stat-value { font-size: 28px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-mute); text-transform: uppercase; letter-spacing: .06em; }
.admin-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}
.admin-button {
    display: flex; align-items: center; gap: 10px;
    padding: 16px;
    background: var(--bg-elev);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius);
    color: var(--text);
    font-weight: 500;
    transition: border-color .12s, background .12s, transform .12s;
}
.admin-button:hover {
    border-color: var(--accent); background: var(--bg-hover);
    transform: translateY(-1px); text-decoration: none;
}
.admin-button svg { width: 18px; height: 18px; color: var(--accent); }

/* ═══════════ MOBILE ═══════════ */
@media (max-width: 768px) {
    .only-mobile { display: inline-flex; }
    .sidebar {
        position: fixed; top: 0; bottom: 0; left: 0;
        z-index: 200;
        transform: translateX(-100%);
        box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 0;
        background: rgba(0,0,0,.5);
        z-index: 150;
    }
    .sidebar-overlay.show { display: block; }
    .page { padding: 20px 16px 40px; }
    .home { padding: 24px 16px; }
    .home-title { font-size: 22px; }
    .form-row { grid-template-columns: 1fr; }
    .kv-grid { grid-template-columns: 1fr; }
    .message.user .message-content { max-width: 88%; }
    .chat-scroll { padding: 16px 12px; }
    .chat-input-bar { padding: 10px 12px 14px; }
}