:root, [data-theme="dark"] {
    --bg-0:#111; --bg-1:#161616; --bg-2:#1c1c1c; --border:#2a2a2a;
    --text-1:#e8e8e8; --text-2:#aaa; --accent:#2563eb;
    --danger:#b94545; --success:#2e8540; --warning:#c08a2a;
    color-scheme:dark;
}
[data-theme="light"] {
    --bg-0:#fafafa; --bg-1:#fff; --bg-2:#f3f3f3; --border:#e2e2e2;
    --text-1:#1a1a1a; --text-2:#5f5f5f; --accent:#2563eb;
    --danger:#b94545; --success:#2e8540; --warning:#a87519;
    color-scheme:light;
}
*,*::before,*::after { box-sizing:border-box; margin:0; padding:0; }
html, body { height:100%; }
body {
    background:var(--bg-0); color:var(--text-1);
    font:15px/1.55 system-ui,-apple-system,"Segoe UI",Roboto,sans-serif;
}
.theme-toggle {
    background:transparent; border:1px solid var(--border); color:var(--text-2);
    border-radius:6px; padding:6px 10px; font-size:.85rem; cursor:pointer;
}
.theme-toggle:hover { color:var(--text-1); border-color:var(--text-2); }
input, select, textarea {
    color-scheme:dark; background:var(--bg-2); color:var(--text-1);
    border:1px solid var(--border); border-radius:6px;
    padding:8px 10px; font:inherit; width:100%;
}
input:focus, select:focus, textarea:focus { outline:none; border-color:var(--accent); }
a { color:var(--accent); text-decoration:none; }
a:hover { text-decoration:underline; }
h1 { font-size:1.6rem; font-weight:600; }
h2 { font-size:1.25rem; font-weight:600; }
h3 { font-size:1.05rem; font-weight:600; }
.muted { color:var(--text-2); }

.layout { display:grid; grid-template-columns:240px 1fr; min-height:100vh; }
.sidebar {
    background:var(--bg-1); border-right:1px solid var(--border);
    display:flex; flex-direction:column; padding:20px 16px;
}
.brand {
    color:var(--text-1); font-weight:600; font-size:1.1rem;
    padding-bottom:18px; border-bottom:1px solid var(--border); margin-bottom:14px;
}
.nav { display:flex; flex-direction:column; gap:2px; flex:1; }
.nav-link { display:block; color:var(--text-2); padding:8px 10px; border-radius:6px; font-size:.95rem; }
.nav-link:hover { background:var(--bg-2); color:var(--text-1); text-decoration:none; }
.nav-section { display:flex; flex-direction:column; gap:2px; }
/* User menu — sits at bottom of sidebar; click to expand */
.user-menu-wrap {
    position:relative; border-top:1px solid var(--border); padding-top:12px; margin-top:14px;
}
.user-trigger {
    display:flex; align-items:center; gap:10px; width:100%;
    background:transparent; border:1px solid transparent; border-radius:8px;
    padding:6px 8px; cursor:pointer; color:inherit; font:inherit;
    text-align:left;
}
.user-trigger:hover { background:var(--bg-2); border-color:var(--border); }
.user-trigger .avatar { width:32px; height:32px; flex-shrink:0; }
.user-trigger-meta { flex:1; min-width:0; line-height:1.2; }
.user-trigger-meta .user-name {
    font-size:.88rem; color:var(--text-1); font-weight:500;
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.user-trigger-meta .user-email {
    font-size:.72rem; color:var(--text-2);
    overflow:hidden; text-overflow:ellipsis; white-space:nowrap;
}
.user-trigger-caret { color:var(--text-2); font-size:.7rem; flex-shrink:0; }

.user-menu-pop {
    position:absolute; bottom:calc(100% + 6px); left:0; right:0;
    background:var(--bg-1); border:1px solid var(--border); border-radius:8px;
    box-shadow:0 8px 24px rgba(0,0,0,.4); padding:6px;
    display:flex; flex-direction:column; gap:2px;
}
/* hidden attribute must override the display:flex default — same fix
   applies to .chat-panel below. */
.user-menu-pop[hidden] { display:none; }
.user-menu-item {
    display:flex; align-items:center; gap:4px;
    padding:8px 10px; border-radius:5px;
    background:transparent; border:none; color:var(--text-2);
    font:inherit; font-size:.88rem; text-align:left; cursor:pointer; width:100%;
}
.user-menu-item:hover {
    background:var(--bg-2); color:var(--text-1); text-decoration:none;
}

.avatar { width:36px; height:36px; border-radius:50%; background:var(--bg-2); object-fit:cover; }

.main { padding:32px 36px; max-width:1100px; width:100%; }

/* Home page quick-access cards */
.home-grid {
    display:grid; grid-template-columns:repeat(auto-fit, minmax(240px, 1fr));
    gap:12px; margin-top:20px;
}
.home-card {
    display:block; padding:18px 18px 16px;
    background:var(--bg-1); border:1px solid var(--border); border-radius:10px;
    color:inherit; cursor:pointer; font:inherit; text-align:left;
    transition:border-color 120ms ease, background 120ms ease, transform 120ms ease;
}
.home-card:hover {
    border-color:var(--accent); background:var(--bg-2);
    text-decoration:none; transform:translateY(-1px);
}
.home-card-icon { font-size:1.6rem; margin-bottom:8px; }
.home-card-title { font-size:.98rem; font-weight:600; color:var(--text-1); margin-bottom:4px; }
.home-card-text  { font-size:.85rem; color:var(--text-2); line-height:1.45; }
.home-card code  { background:var(--bg-0); padding:1px 5px; border-radius:3px; font-size:.78rem; }
.main-auth { display:flex; align-items:center; justify-content:center; min-height:100vh; padding:24px; }

.btn {
    display:inline-block; padding:9px 16px; border-radius:6px;
    border:1px solid var(--border); background:var(--bg-2); color:var(--text-1);
    font:inherit; cursor:pointer;
}
.btn:hover { background:#232323; }
.btn-primary { background:var(--accent); border-color:var(--accent); color:#fff; }
.btn-primary:hover { filter:brightness(1.1); }

.flash { padding:10px 14px; border-radius:6px; margin-bottom:14px; border:1px solid var(--border); background:var(--bg-2); }
.flash-success { border-color:var(--success); }
.flash-error { border-color:var(--danger); }
.flash-warning { border-color:var(--warning); }

.verify-banner {
    display:flex; align-items:center; justify-content:space-between; gap:14px;
    padding:10px 14px; margin-bottom:14px; border-radius:6px;
    background:#2a2410; border:1px solid #d4a017; color:#f5d97a;
}
.verify-banner-btn {
    background:#d4a017; border:1px solid #d4a017; color:#1a1a1a;
    padding:5px 12px; border-radius:5px; font-size:.85rem; font-weight:600;
    cursor:pointer;
}
.verify-banner-btn:hover { filter:brightness(1.08); }

.auth-card {
    background:var(--bg-1); border:1px solid var(--border); border-radius:10px;
    padding:28px 28px 22px; width:100%; max-width:380px;
}
.auth-card h1 { margin-bottom:18px; font-size:1.25rem; }
.auth-form { display:flex; flex-direction:column; gap:12px; }
.auth-form label,
.form-stack label { display:flex; flex-direction:column; gap:6px; font-size:.9rem; color:var(--text-2); }
.auth-alt { margin-top:18px; font-size:.88rem; color:var(--text-2); text-align:center; }
.form-stack { display:flex; flex-direction:column; gap:14px; max-width:520px; margin-top:16px; }
.form-section-title { margin-top:12px; color:var(--text-1); }
.checkbox-inline { flex-direction:row !important; align-items:center; gap:8px; }
.checkbox-inline input { width:auto; }
