/* 5cbot LLM Server dashboard — design system with light/dark themes.
 *
 * The active theme is set as <html data-theme="light|dark"> by an inline
 * script in lib/layout.php (localStorage, falling back to the OS setting).
 * Admin pages get <body class="area-admin"> and a distinct accent so the
 * administration area is never confused with the user workspace.
 */

:root,
:root[data-theme="light"] {
    --bg: #f4f6fb;
    --bg-gradient: radial-gradient(1200px 600px at 80% -10%, rgba(79, 124, 255, 0.10), transparent 60%);
    --panel: #ffffff;
    --panel-2: #f0f3f9;
    --border: #dde3ee;
    --text: #1c2333;
    --muted: #5d6980;
    --accent: #3461e0;
    --accent-soft: rgba(52, 97, 224, 0.10);
    --admin-accent: #7c3aed;
    --admin-accent-soft: rgba(124, 58, 237, 0.10);
    --ok: #15803d;
    --ok-soft: rgba(21, 128, 61, 0.12);
    --warn: #b45309;
    --warn-soft: rgba(180, 83, 9, 0.12);
    --bad: #dc2626;
    --bad-soft: rgba(220, 38, 38, 0.10);
    --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 16px rgba(16, 24, 40, 0.06);
    --input-bg: #ffffff;
    --code-bg: #f0f3f9;
    color-scheme: light;
}

:root[data-theme="dark"] {
    --bg: #0e1117;
    --bg-gradient: radial-gradient(1200px 600px at 80% -10%, rgba(79, 124, 255, 0.12), transparent 60%);
    --panel: #171b24;
    --panel-2: #1f2430;
    --border: #2a3040;
    --text: #e7eaf1;
    --muted: #98a1b3;
    --accent: #6c8cff;
    --accent-soft: rgba(108, 140, 255, 0.14);
    --admin-accent: #a78bfa;
    --admin-accent-soft: rgba(167, 139, 250, 0.14);
    --ok: #4ade80;
    --ok-soft: rgba(74, 222, 128, 0.14);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, 0.14);
    --bad: #f87171;
    --bad-soft: rgba(248, 113, 113, 0.13);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 6px 20px rgba(0, 0, 0, 0.30);
    --input-bg: #11141c;
    --code-bg: #11141c;
    color-scheme: dark;
}

* { box-sizing: border-box; }

html { height: 100%; }

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    font-family: "Segoe UI Variable", "Segoe UI", -apple-system, BlinkMacSystemFont, Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    background: var(--bg);
    background-image: var(--bg-gradient);
    background-attachment: fixed;
    color: var(--text);
    overflow-x: hidden;
    transition: background-color 0.2s ease, color 0.2s ease;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; }
h2 { font-size: 1.1rem; margin: 0 0 0.75rem; }
h3 { font-size: 0.95rem; margin: 1.25rem 0 0.5rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }

/* ── Topbar ──────────────────────────────────────────────────────────── */

.topbar {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.topbar-row {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.55rem 1.25rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.55rem;
    color: var(--text);
    font-weight: 700;
    line-height: 1;
}
.brand:hover { text-decoration: none; }

.brand-mark {
    display: inline-grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--accent), var(--admin-accent));
    color: #fff;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: -0.02em;
}

.brand-logo {
    display: block;
    width: auto;
    height: 36px;
    object-fit: contain;
}

.brand-name span { color: var(--muted); font-weight: 500; }

.chip {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.chip-admin { background: var(--admin-accent-soft); color: var(--admin-accent); border: 1px solid var(--admin-accent); }

.spacer { flex: 1; }

.theme-toggle {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel-2);
    color: var(--text);
    font-size: 1rem;
    cursor: pointer;
}
.theme-toggle:hover { border-color: var(--accent); }
:root[data-theme="light"] .icon-sun { display: none; }
:root[data-theme="dark"] .icon-moon { display: none; }

.avatar {
    display: inline-grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 700;
    flex-shrink: 0;
}
/* Profile button */
.profile-btn {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel-2);
    color: var(--text);
    cursor: pointer;
    transition: border-color .15s;
}
.profile-btn:hover { border-color: var(--accent); }
.profile-icon { width: 20px; height: 20px; }

/* Profile dropdown */
.profile-wrap { position: relative; }
.profile-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    width: 224px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,.12);
    z-index: 120;
    overflow: hidden;
}
.pd-head {
    display: flex;
    align-items: center;
    gap: .65rem;
    padding: .75rem 1rem;
}
.avatar-lg {
    display: inline-grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: .9rem;
    font-weight: 700;
}
.pd-meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
.pd-meta strong { font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-meta small { font-size: .72rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pd-sep { height: 1px; background: var(--border); }
.pd-row {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .48rem 1rem;
    font-size: .84rem;
    color: var(--text);
    text-decoration: none;
    width: 100%;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    box-sizing: border-box;
}
.pd-row:hover { background: var(--accent-soft); text-decoration: none; color: var(--text); }
.area-admin .pd-row:hover { background: var(--admin-accent-soft); }
.pd-logout:hover { background: var(--bad-soft) !important; color: var(--bad) !important; }
.pd-switch { color: var(--accent); font-weight: 600; }
.pd-switch:hover { background: var(--accent-soft); color: var(--accent); }
.pd-lang { flex: 1; font-size: .82rem; border: none; background: transparent; color: inherit; font-family: inherit; cursor: pointer; }

/* ── Main navigation: Workspace vs Administration ────────────────────── */

.mainnav {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.25rem;
    overflow-x: auto;
    scrollbar-width: none;
}
.mainnav::-webkit-scrollbar { display: none; }

.nav-group {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.25rem;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--panel-2);
}

.nav-group-label {
    padding: 0 0.55rem;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.nav-group a {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 0.32rem 0.75rem;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.88rem;
    font-weight: 500;
}
.nav-group a:hover { background: var(--accent-soft); text-decoration: none; }
.nav-group a.active { background: var(--accent); color: #fff; }

.nav-group-admin { border-color: var(--admin-accent); }
.nav-group-admin .nav-group-label { color: var(--admin-accent); }
.nav-group-admin a:hover { background: var(--admin-accent-soft); }
.nav-group-admin a.active { background: var(--admin-accent); color: #fff; }

.nav-divider { width: 1px; height: 26px; background: var(--border); }

.nav-switch {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    padding: .35rem .75rem;
    border-radius: 6px;
    font-size: .82rem;
    font-weight: 600;
    text-decoration: none;
    color: var(--accent);
    background: var(--accent-soft);
    transition: background .15s;
    white-space: nowrap;
}
.nav-switch:hover { background: var(--accent); color: #fff; }
.area-admin .nav-switch { color: var(--admin-accent); background: var(--admin-accent-soft); }
.area-admin .nav-switch:hover { background: var(--admin-accent); color: #fff; }

/* Hamburger button — hidden on desktop, shown on mobile */
.hamburger {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    width: 34px;
    height: 34px;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--panel-2);
    cursor: pointer;
}
.hamburger span {
    display: block;
    height: 2px;
    background: var(--text);
    border-radius: 2px;
    transition: transform 0.2s ease, opacity 0.2s ease;
}
.hamburger.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }

/* Accent ribbon so admin pages are recognizable at a glance. */
.area-admin .topbar { border-bottom: 2px solid var(--admin-accent); }
.area-user .topbar { border-bottom: 2px solid var(--accent); }

/* ── Layout ──────────────────────────────────────────────────────────── */

.container {
    width: 100%;
    max-width: 1140px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 2.5rem;
    flex: 1;
    min-width: 0;
}

.footer {
    padding: 1rem 1.25rem;
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 0.8rem;
    text-align: center;
}

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem 1.4rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow);
    overflow-x: auto;
    min-width: 0;
}

.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; align-items: end; }

/* ── User dashboard hero ─────────────────────────────────────────────── */
.hero-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
    flex-wrap: wrap;
    background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 10%, var(--panel)), var(--panel));
}
.hero-card-main { flex: 1; min-width: 260px; }
.hero-greeting { margin: 0 0 0.9rem; font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }
.hero-stats { display: flex; gap: 1.75rem; flex-wrap: wrap; }
.hero-stat { display: flex; flex-direction: column; }
.hero-stat-value { font-size: 1.6rem; font-weight: 700; letter-spacing: -0.02em; }
.hero-stat-label { font-size: 0.78rem; color: var(--muted); }
.hero-cta { flex-shrink: 0; padding: 0.7rem 1.4rem; font-size: 0.95rem; }

/* ── Playground split-panel layout ──────────────────────────────────── */
/* Playground is the one page that wants the full viewport width/height
   instead of the centered 1140px .container — page_header()'s $mainClass
   param adds this class to both <body> and <main>.
   body needs a *definite* height (not just min-height) here: a flex chain
   only shrinks/scrolls its content instead of growing the whole page when
   every ancestor in the chain has a bounded height. Without this, a long
   prompt/response just grows <body> past the viewport instead of scrolling
   inside .chat-thread, and toggling the sidebar (which reflows text wrap
   width) changes content height and so changes the page height too. */
body.container-pg {
    height: 100vh;
    overflow: hidden;
}
.container.container-pg {
    max-width: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem 1.5rem;
    min-height: 0;
}
.pg-card {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.pg-header {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
    padding-bottom: .6rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: .5rem;
    flex-shrink: 0;
}
.pg-header-left { display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.pg-header-left h2 { margin: 0; font-size: 1.05rem; }
.pg-header-left code { font-size: .72rem; }
.pg-header-right { display: flex; align-items: center; gap: .4rem; margin-inline-start: auto; }
.pg-header-right .segmented { margin-right: .35rem; }

.pg-main {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    transition: grid-template-columns .25s ease;
}

.pg-chat-panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    position: relative;
    padding-right: 1rem;
}

.pg-sidebar {
    width: 280px;
    flex-shrink: 0;
    overflow-y: auto;
    overflow-x: hidden;
    border-left: 1px solid var(--border);
    padding-left: 1rem;
    transition: width .25s ease, padding .25s ease, border .25s ease;
}
.pg-sidebar h3 {
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    margin: .85rem 0 .35rem;
}
.pg-sidebar h3:first-child { margin-top: 0; }
.pg-sidebar label { font-size: .82rem; }
.pg-sidebar input[type="number"],
.pg-sidebar input[type="text"],
.pg-sidebar select { font-size: .82rem; padding: .3rem .5rem; }
.pg-sidebar input[type="range"] { width: 100%; accent-color: var(--accent); display: block; margin-top: .2rem; }
.pg-sidebar textarea {
    /* Unlike the param inputs above, #system-prompt isn't wrapped in a
       <label> (it follows a standalone <h3>), so it misses the shared
       `label textarea` base styling and needs it restated here. */
    display: block;
    width: 100%;
    font-size: .82rem;
    padding: .35rem .5rem;
    min-height: 60px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-family: inherit;
}
.pg-sidebar textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

.pg-sidebar-closed .pg-sidebar {
    width: 0;
    padding-left: 0;
    border-left: none;
    overflow: hidden;
}
.pg-sidebar-closed .pg-main {
    grid-template-columns: 1fr 0;
}

#sidebar-toggle {
    background: none;
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: .3rem .45rem;
    color: var(--muted);
    transition: color .15s;
}
#sidebar-toggle:hover { color: var(--text); }

/* ── Input area ─────────────────────────────────────────────────────── */
.pg-input-area {
    display: flex;
    gap: .5rem;
    align-items: flex-end;
    margin-top: auto;
    flex-shrink: 0;
}
.pg-input-area textarea {
    flex: 1;
    resize: none;
    min-height: 44px;
    max-height: 160px;
    font-size: .9rem;
    padding: .55rem .75rem;
    border-radius: 10px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    color: var(--text);
    font-family: inherit;
}
.pg-input-area textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Token estimate sits in its own row so it never fights the textarea/send
   button for width as the message grows. */
.pg-input-meta {
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
    margin-top: .3rem;
}
.pg-input-area .pg-send-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 1.1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity .15s;
}
.pg-send-btn:disabled { opacity: .45; cursor: not-allowed; }
.pg-send-btn:not(:disabled):hover { opacity: .85; }
/* Restart-in-progress state: spinner + a text label ("Restarting model…")
   don't fit in a fixed 44px circle — flexbox squishes the spinner's width
   to make room, flattening it into an oval. Widen into a pill instead. */
.pg-send-btn.pg-send-btn-wide {
    width: auto;
    height: 32px;
    border-radius: 999px;
    padding: 0 .9rem;
    font-size: .8rem;
    gap: .4rem;
    white-space: nowrap;
}

/* Responsive: stack sidebar below chat on narrow screens */
@media (max-width: 768px) {
    /* Sidebar stacks below the chat here instead of scrolling internally
       side-by-side, so give up the fixed-viewport/internal-scroll trick and
       let the page scroll normally like everywhere else. */
    body.container-pg { height: auto; overflow: visible; }
    .container.container-pg { padding: .5rem .75rem 1.5rem; }
    .pg-card { flex: none; min-height: auto; }
    .pg-main { grid-template-columns: 1fr; }
    .pg-chat-panel { padding-right: 0; min-height: 60vh; }
    .pg-sidebar {
        width: 100%;
        border-left: none;
        border-top: 1px solid var(--border);
        padding-left: 0;
        padding-top: .75rem;
        margin-top: .5rem;
        max-height: 40vh;
    }
    .pg-sidebar-closed .pg-sidebar { width: 100%; padding-top: 0; margin-top: 0; border-top: none; }
    .pg-header-right .segmented { display: none; }
    .pg-header { gap: .4rem; }
}

.pg-attach-row {
    display: flex;
    gap: .4rem;
    flex-shrink: 0;
    margin-bottom: .4rem;
}
.pg-attach-row .pg-image-thumbs,
.pg-attach-row .pg-file-chips { width: auto; flex: 1; }

/* ── Drop zone overlay ──────────────────────────────────────────────── */
.pg-drop-zone {
    display: none;
    position: absolute;
    inset: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--accent, #6366f1) 10%, transparent);
    border: 2px dashed var(--accent, #6366f1);
    border-radius: 12px;
    pointer-events: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: .5rem;
}
.pg-drop-zone.active { display: flex; }
.pg-drop-icon { font-size: 2.4rem; opacity: .7; }
.pg-drop-text { font-size: .95rem; font-weight: 600; color: var(--accent); }
.pg-drop-sub { font-size: .78rem; color: var(--muted); }

/* ── Playground toolbar / mode toggle ────────────────────────────────── */
.pg-toolbar { display: flex; gap: .75rem; margin-bottom: .75rem; flex-wrap: wrap; align-items: center; }
.pg-toolbar select { width: auto; }

.segmented {
    display: inline-flex;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 2px;
    gap: 2px;
}
.segmented-btn {
    border: none;
    background: transparent;
    color: var(--muted);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.segmented-btn.active { background: var(--accent); color: #fff; }
.segmented-btn:not(.active):hover { background: var(--panel); }

/* ── Playground chat thread ──────────────────────────────────────────── */
.chat-thread {
    flex: 1;
    margin-bottom: .5rem;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: .85rem;
    background: var(--panel-2);
    min-height: 0;
}
.chat-msg { display: flex; gap: .6rem; margin-bottom: .75rem; align-items: flex-start; }
.chat-msg:last-child { margin-bottom: 0; }
.chat-msg-user { justify-content: flex-end; }
.chat-avatar {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--accent);
    color: #fff;
    font-size: .75rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-bubble { max-width: 80%; border-radius: 10px; padding: .5rem .75rem; }
.chat-bubble-assistant { background: var(--panel); border: 1px solid var(--border); }
.chat-bubble-user { background: var(--accent-soft, var(--panel)); }
.chat-msg-head { display: flex; align-items: center; gap: .4rem; margin-bottom: .15rem; }
.chat-msg-user .chat-msg-head { justify-content: flex-end; }
.chat-role-label { font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .02em; color: var(--muted); }
.chat-msg-body { font-size: .9rem; line-height: 1.45; word-wrap: break-word; }
.chat-msg-actions { display: flex; gap: .6rem; margin-top: .35rem; }
.chat-msg-user .chat-msg-actions { justify-content: flex-end; }
.chat-msg-action {
    background: none;
    border: none;
    padding: 0;
    font-size: .68rem;
    color: var(--muted);
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.chat-msg-action:hover { color: var(--text); }
.chat-stream-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ok);
    animation: chat-stream-pulse 1.1s ease-in-out infinite;
}
@keyframes chat-stream-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .25; }
}

.pg-generate-row { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; flex-wrap: wrap; }
.pg-token-counter { font-size: .78rem; color: var(--muted); }

.pg-chip-row { display: flex; gap: .4rem; flex-wrap: wrap; margin-top: .6rem; }
.pg-chip {
    border: 1px solid var(--border);
    background: var(--panel-2);
    color: var(--text);
    border-radius: 999px;
    font-size: .78rem;
    padding: .3rem .8rem;
    cursor: pointer;
    transition: background .15s ease;
}
.pg-chip:hover { background: var(--panel); }

.pg-inline-bench {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: .5rem;
    font-size: .8rem;
    color: var(--muted);
    flex-shrink: 0;
}
.pg-inline-bench strong { color: var(--text); }

.pg-image-attach { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.pg-image-thumbs { display: flex; gap: .4rem; flex-wrap: wrap; width: 100%; }
.pg-image-thumb { position: relative; width: 64px; height: 64px; }
.pg-image-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--border);
}
.pg-image-thumb-remove {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    line-height: 16px;
    text-align: center;
    border-radius: 50%;
    background: var(--danger, #dc2626);
    color: #fff;
    font-size: .7rem;
    cursor: pointer;
    border: 2px solid var(--panel);
}
.chat-msg-body img.pg-chat-img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 8px;
    display: block;
    margin-top: .4rem;
}

.pg-file-chips { display: flex; gap: .4rem; flex-wrap: wrap; width: 100%; }
.pg-file-chip {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    border: 1px solid var(--border);
    background: var(--panel-2);
    border-radius: 999px;
    padding: .3rem .5rem .3rem .7rem;
    font-size: .8rem;
}
.pg-file-chip-remove {
    cursor: pointer;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    line-height: 16px;
    text-align: center;
    background: var(--danger, #dc2626);
    color: #fff;
    font-size: .65rem;
}
.chat-msg-body .pg-chat-file-chip {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    border: 1px solid var(--border);
    background: var(--panel-2);
    border-radius: 6px;
    padding: .2rem .5rem;
    font-size: .8rem;
    margin-top: .3rem;
}

/* Markdown rendering in chat messages and response panel */
.chat-msg-body pre, #response pre {
    background: var(--panel);
    border-radius: 6px;
    padding: .75rem 1rem;
    overflow-x: auto;
    margin: .5rem 0;
    font-size: .875rem;
    line-height: 1.5;
}
.chat-msg-body code, #response code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: .875rem;
}
.chat-msg-body :not(pre) > code, #response :not(pre) > code {
    background: var(--panel);
    padding: .15em .35em;
    border-radius: 3px;
}
.chat-msg-body ul, .chat-msg-body ol, #response ul, #response ol {
    padding-left: 1.5rem;
    margin: .4rem 0;
}
.chat-msg-body li, #response li { margin: .15rem 0; }
.chat-msg-body h2, .chat-msg-body h3, .chat-msg-body h4,
#response h2, #response h3, #response h4 {
    margin: .75rem 0 .25rem;
    font-weight: 600;
}
.chat-msg-body a, #response a { color: var(--accent); }
.chat-msg-body strong, #response strong { font-weight: 600; }

.kv { display: flex; justify-content: space-between; padding: 0.2rem 0; font-size: 0.9rem; }
.kv .k { color: var(--muted); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }

.kv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 0.15rem 1.5rem;
    margin: 0 0 0.75rem;
}
.kv-grid .kv { border-bottom: 1px dashed var(--border); }

.metrics-charts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}

.details-toggle .details-caret { display: inline-block; transition: transform 0.15s ease; }
.details-toggle.open .details-caret { transform: rotate(180deg); }

/* ── Status timeline (model request review) ─────────────────────────── */
.status-timeline {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin: 0.75rem 0 1rem;
}
.status-timeline .tl-step {
    flex: 1;
    text-align: center;
    position: relative;
    font-size: 0.75rem;
    color: var(--muted);
}
.status-timeline .tl-dot {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--panel-2);
    border: 2px solid var(--border);
    margin: 0 auto 0.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: var(--muted);
}
.status-timeline .tl-step::before {
    content: "";
    position: absolute;
    top: 9px;
    left: -50%;
    width: 100%;
    height: 2px;
    background: var(--border);
    z-index: 0;
}
.status-timeline .tl-step:first-child::before { display: none; }
.status-timeline .tl-step.done .tl-dot { background: var(--ok-soft); border-color: var(--ok); color: var(--ok); }
.status-timeline .tl-step.done::before { background: var(--ok); }
.status-timeline .tl-step.current .tl-dot { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.status-timeline .tl-step.rejected .tl-dot { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.status-timeline .tl-step.rejected::before { background: var(--bad); }
.status-timeline .tl-step.done span, .status-timeline .tl-step.current span { color: var(--text); font-weight: 600; }

.status-dots { display: inline-flex; gap: 3px; vertical-align: middle; margin-left: 0.35rem; }
.status-dots .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--border); }
.status-dots .dot.done { background: var(--ok); }
.status-dots .dot.rejected { background: var(--bad); }

/* The stage the request is currently at (or stopped at) — shown next to the
   dots so the pipeline position is legible without hovering. */
.status-step-label { font-size: 0.72rem; color: var(--muted); margin-left: 0.35rem; vertical-align: middle; }
.status-step-label.rejected { color: var(--bad); }

.big { font-size: 2.2rem; font-weight: 700; margin: 0.25rem 0; letter-spacing: -0.02em; }

/* ── Tables ──────────────────────────────────────────────────────────── */

table { width: 100%; border-collapse: collapse; min-width: 0; }
th, td { text-align: left; padding: 0.55rem 0.65rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; vertical-align: top; white-space: nowrap; }
td { white-space: normal; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; }
tbody tr:hover { background: var(--panel-2); }
tbody tr:last-child td { border-bottom: none; }

/* ── Forms ───────────────────────────────────────────────────────────── */

label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--muted); }
label input, label select, label textarea {
    display: block;
    width: 100%;
    margin-top: 0.3rem;
    padding: 0.55rem 0.7rem;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-size: 0.95rem;
    font-family: inherit;
}
label input:focus, label select:focus, label textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 1rem; height: 1rem; }
textarea { resize: vertical; min-height: 6rem; }

.checkbox-label { display: flex; align-items: center; gap: 0.5rem; }
.checkbox-label input { display: inline-block; width: auto; margin: 0; }

button, .btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    background: var(--accent);
    color: #fff;
    border: 1px solid transparent;
    border-radius: 9px;
    cursor: pointer;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    transition: filter 0.12s ease;
}
button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Components that style their own <button> (dialog/tab/menu/custom-select/
   toast close buttons) must be allowlisted here — this rule's specificity
   beats their single-class selectors and would paint them accent-purple. */
.area-admin button:not(.danger):not(.secondary):not(.ghost):not(.theme-toggle):not(.profile-btn):not(.notification-bell):not(.hamburger):not(.modal-close):not(.pd-row):not(.gg-src-tab-btn):not(.hf-sel-trigger):not(.toast-close),
.area-admin .btn:not(.danger):not(.secondary):not(.ghost) { background: var(--admin-accent); }

button.secondary, .btn.secondary { background: var(--panel-2); color: var(--text); border-color: var(--border); }
button.danger, .btn.danger { background: var(--bad); }
button.ghost, .btn.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.ghost:hover, .btn.ghost:hover { border-color: var(--accent); color: var(--accent); }

/* ── Feedback ────────────────────────────────────────────────────────── */

.error, .alert-error {
    color: var(--bad);
    background: var(--bad-soft);
    border: 1px solid var(--bad);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
}
.success, .alert-success {
    color: var(--ok);
    background: var(--ok-soft);
    border: 1px solid var(--ok);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
}
p.error:empty, p.success:empty { display: none; }

.alert-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    color: var(--accent);
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: 10px;
    padding: 0.6rem 0.9rem;
}
.alert-info .alert-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: 2px 6px;
    line-height: 1;
    font-size: 1rem;
    flex: none;
}

.star-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    color: var(--muted);
    display: inline-flex;
    align-items: center;
}
.star-btn:hover { color: var(--warn); }
.star-btn.is-favorite { color: var(--warn); }
.star-btn.is-favorite svg { fill: currentColor; }

.muted { color: var(--muted); }

.badge {
    display: inline-block;
    padding: 0.12rem 0.55rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--muted);
}
.badge-ready { background: var(--ok-soft); color: var(--ok); border-color: var(--ok); }
.badge-starting { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.badge-failed { background: var(--bad-soft); color: var(--bad); border-color: var(--bad); }
.badge-stopping { background: var(--warn-soft); color: var(--warn); border-color: var(--warn); }
.badge-super-admin { background: var(--admin-accent-soft); color: var(--admin-accent); border-color: var(--admin-accent); }

.progress {
    height: 10px;
    border-radius: 999px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    overflow: hidden;
}
.progress > div {
    height: 100%;
    border-radius: 999px;
    background: linear-gradient(90deg, var(--accent), var(--admin-accent));
    transition: width 0.4s ease;
}

code, pre {
    background: var(--code-bg);
    border: 1px solid var(--border);
    border-radius: 7px;
    padding: 0.12rem 0.4rem;
    font-family: ui-monospace, "Cascadia Code", Consolas, "SF Mono", Menlo, monospace;
    font-size: 0.85em;
}
pre { padding: 0.85rem; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }

/* ── Login / landing page ────────────────────────────────────────────── */

.hero {
    display: block;
    max-width: 820px;
    margin: 0 auto;
    text-align: center;
    padding: 4.5rem 0 3.5rem;
}

.hero-copy .eyebrow {
    display: inline-block;
    margin-bottom: 1rem;
    padding: 0.3rem 0.85rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.76rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero-copy h1 {
    margin: 0 0 1.25rem;
    font-size: clamp(2.2rem, 5vw, 3.2rem);
    line-height: 1.1;
    letter-spacing: -0.03em;
}
.hero-copy h1 .accent {
    background: linear-gradient(90deg, var(--accent), var(--admin-accent));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}
.hero-copy .lede {
    color: var(--muted);
    font-size: 1.1rem;
    line-height: 1.6;
    max-width: 58ch;
    margin: 0 auto 2rem;
}

.hero-cta {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-bottom: 2.75rem;
}
.hero-cta .btn { padding: 0.65rem 1.5rem; font-size: 1rem; }

.feature-list {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.25rem;
    margin: 0;
    padding: 0;
    list-style: none;
    text-align: left;
}
.feature-list li {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 1.15rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
}
.feature-icon {
    flex: none;
    display: inline-grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 1.1rem;
}
.feature-icon svg { width: 20px; height: 20px; }
.feature-list strong { display: block; font-size: 0.92rem; }
.feature-list small { color: var(--muted); font-size: 0.84rem; line-height: 1.45; }

/* Sign-in dropdown (landing page navbar) */
.signin-dropdown { position: relative; }
.signin-panel {
    display: none;
    position: absolute;
    top: calc(100% + 0.6rem);
    right: 0;
    width: 300px;
    padding: 1.25rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.12);
    z-index: 200;
}
[data-theme="dark"] .signin-panel { box-shadow: 0 8px 24px rgba(0,0,0,0.35); }
.signin-panel.open { display: block; }
.signin-panel label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.7rem; }
.signin-panel button[type="submit"] { width: 100%; padding: 0.6rem; font-size: 0.92rem; margin-top: 0.3rem; }
.signin-panel .error { margin-bottom: 0.8rem; font-size: 0.85rem; }

/* ── Landing page (index.php — research-group project page) ─────────── */

html { scroll-behavior: smooth; }
.landing section[id] { scroll-margin-top: 70px; }

.landing-nav { display: flex; align-items: center; gap: 0.15rem; flex-wrap: wrap; }
.landing-nav a {
    padding: 0.35rem 0.65rem;
    border-radius: 8px;
    color: var(--text);
    font-size: 0.86rem;
    font-weight: 500;
}
.landing-nav a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* Hero background: neural-network / circuit node pattern */
.landing-hero {
    position: relative;
    overflow: hidden;
}
.landing-hero::before {
    content: '';
    position: absolute;
    inset: 0;
    z-index: 0;
    background-image:
        radial-gradient(circle 3px at center, var(--accent) 2.5px, transparent 3px),
        linear-gradient(0deg, transparent 49.3%, var(--accent) 49.3%, var(--accent) 50.7%, transparent 50.7%),
        linear-gradient(90deg, transparent 49.3%, var(--accent) 49.3%, var(--accent) 50.7%, transparent 50.7%);
    background-size: 56px 56px;
    background-position: 28px 28px, 0 0, 0 0;
    opacity: 0.10;
}
[data-theme="dark"] .landing-hero::before { opacity: 0.12; }
.landing-hero::after {
    content: '';
    position: absolute;
    z-index: 1;
    top: 5%;
    left: 20%;
    width: 60%;
    height: 80%;
    background: radial-gradient(ellipse at center, var(--accent) 0%, transparent 65%);
    opacity: 0.12;
    filter: blur(70px);
    pointer-events: none;
}
[data-theme="dark"] .landing-hero::after { opacity: 0.15; }
.landing-hero > .container { position: relative; z-index: 2; }

.landing-hero .hero { padding-top: 2.5rem; }

.landing-section { padding: 3.5rem 0; }
.section-alt { background: var(--panel-2); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-title { text-align: center; margin-bottom: 2.25rem; }
.section-title span {
    display: inline-block;
    margin-bottom: 0.5rem;
    padding: 0.2rem 0.8rem;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}
.section-title h2 { margin: 0; font-size: 1.7rem; letter-spacing: -0.02em; }

.text-panel {
    max-width: 60rem;
    margin: 0 auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow);
}
.text-panel p { margin: 0 0 1rem; }
.text-panel p:last-child { margin-bottom: 0; }

.workflow-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 1rem;
    margin-top: 1.5rem;
}
.workflow-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem 1.3rem;
    box-shadow: var(--shadow);
}
.workflow-icon, .access-icon, .info-icon {
    display: inline-grid;
    place-items: center;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 1.25rem;
    margin-bottom: 0.6rem;
}
.workflow-icon svg, .access-icon svg, .info-icon svg { width: 22px; height: 22px; }
.workflow-item h3, .info-card h3 {
    margin: 0 0 0.4rem;
    font-size: 1rem;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text);
}
.workflow-item p, .info-card p { margin: 0; color: var(--muted); font-size: 0.9rem; }

.access-panel {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
    max-width: 60rem;
    margin: 0 auto;
}
.access-option {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.4rem;
    box-shadow: var(--shadow);
    color: var(--text);
    transition: border-color 0.15s ease, transform 0.15s ease;
}
.access-option:hover { border-color: var(--accent); transform: translateY(-2px); text-decoration: none; }
.access-option strong { font-size: 1.02rem; }
.access-option > span:last-child { color: var(--muted); font-size: 0.88rem; }

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
    max-width: 60rem;
    margin: 0 auto;
}
.info-card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.4rem;
    box-shadow: var(--shadow);
}

.team-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
    gap: 1rem;
    max-width: 64rem;
    margin: 0 auto;
}
.team-card {
    display: flex;
    gap: 1rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.25rem;
    box-shadow: var(--shadow);
}
.team-card-supervisor { border-color: var(--admin-accent); }
.team-photo { flex: none; }
.team-photo img, .team-avatar-fallback {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}
.team-avatar-fallback {
    display: inline-grid;
    place-items: center;
    background: var(--accent-soft);
    color: var(--accent);
    font-size: 1.4rem;
    font-weight: 700;
}
.team-body h3 { margin: 0 0 0.15rem; font-size: 1.02rem; text-transform: none; letter-spacing: 0; color: var(--text); }
.team-role { margin: 0 0 0.5rem; color: var(--accent); font-size: 0.84rem; font-weight: 600; }
.team-card-supervisor .team-role { color: var(--admin-accent); }
.team-period { color: var(--muted); font-weight: 500; }
.team-bio { margin: 0; color: var(--muted); font-size: 0.88rem; }

.past-team { max-width: 64rem; margin: 1.25rem auto 0; }
.past-team summary {
    cursor: pointer;
    color: var(--muted);
    font-weight: 600;
    padding: 0.5rem 0;
}
.past-team[open] summary { margin-bottom: 1rem; }

.publication-list {
    list-style: none;
    margin: 0 auto;
    padding: 0;
    max-width: 60rem;
    display: grid;
    gap: 0.75rem;
}
.publication-list li {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.2rem;
    box-shadow: var(--shadow);
}
.publication-list .badge { margin-right: 0.5rem; }
.publication-text { font-size: 0.92rem; }
.publication-actions { margin-left: 0.5rem; white-space: nowrap; }
.publication-actions a { font-weight: 600; font-size: 0.85rem; margin-right: 0.6rem; }

/* Notification bell */
.notification-bell {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1.2rem;
    position: relative;
    padding: 4px 8px;
    color: var(--text);
}
.notification-badge {
    position: absolute;
    top: -2px;
    right: 0;
    background: var(--bad);
    color: #fff;
    font-size: .65rem;
    font-weight: 700;
    border-radius: 50%;
    min-width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.notification-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow);
    width: 340px;
    z-index: 100;
    max-height: 400px;
    overflow: hidden;
}

/* Spinner */
.spinner {
    display: inline-block;
    flex-shrink: 0;
    width: 1em;
    height: 1em;
    border: 2px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .6s linear infinite;
    vertical-align: middle;
    margin-right: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* .spinner's accent-colored arc is meant to stand out against a light
   panel background — on the send button (accent-filled circle) it's the
   same blue as the button itself and disappears, leaving only a faint
   ring. Use white-on-accent contrast there instead. */
.pg-send-btn .spinner {
    border-color: rgba(255, 255, 255, .35);
    border-top-color: #fff;
}

/* ── Lucide Icons ──────────────────────────────────────────────────────── */
.nav-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    vertical-align: -2px;
    margin-right: 4px;
}
.btn-icon {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    vertical-align: -2px;
    margin-right: 3px;
}
.notification-bell svg {
    width: 20px;
    height: 20px;
    vertical-align: middle;
}
.theme-toggle svg {
    width: 18px;
    height: 18px;
}

/* Pagination */
.pagination {
    display: flex;
    align-items: center;
    gap: .5rem;
    margin-top: 1rem;
    flex-wrap: wrap;
}

/* Toast notifications — shadcn-inspired */
.toast-viewport {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column-reverse;
    gap: .5rem;
    max-width: 420px;
    width: 100%;
    pointer-events: none;
}
.toast {
    pointer-events: auto;
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .75rem 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.12), 0 1px 3px rgba(0,0,0,.06);
    animation: toastSlideIn .3s cubic-bezier(.21,1.02,.73,1);
    transition: opacity .2s, transform .2s;
}
.toast.toast-out { opacity: 0; transform: translateX(100%); }
.toast-icon { font-size: 1.15rem; line-height: 1; flex-shrink: 0; margin-top: .1rem; }
.toast-body { flex: 1; min-width: 0; }
.toast-title { font-weight: 600; font-size: .875rem; line-height: 1.3; }
.toast-desc { font-size: .8rem; color: var(--muted); margin-top: .15rem; line-height: 1.35; }
.toast-close {
    flex-shrink: 0; background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 1rem; padding: 0 0 0 .25rem; line-height: 1;
}
.toast-close:hover { color: var(--text); }
.toast-progress {
    position: absolute; bottom: 0; left: 0; height: 2px; border-radius: 0 0 8px 8px;
    transition: width linear;
}
.toast-success { border-left: 3px solid var(--ok); }
.toast-success .toast-icon { color: var(--ok); }
.toast-success .toast-progress { background: var(--ok); }
.toast-error { border-left: 3px solid var(--bad); }
.toast-error .toast-icon { color: var(--bad); }
.toast-error .toast-progress { background: var(--bad); }
.toast-warning { border-left: 3px solid var(--warn); }
.toast-warning .toast-icon { color: var(--warn); }
.toast-warning .toast-progress { background: var(--warn); }
.toast-info { border-left: 3px solid var(--accent); }
.toast-info .toast-icon { color: var(--accent); }
.toast-info .toast-progress { background: var(--accent); }
@keyframes toastSlideIn { from { opacity: 0; transform: translateY(8px) scale(.96); } to { opacity: 1; transform: none; } }
@media (max-width: 480px) { .toast-viewport { left: 1rem; right: 1rem; bottom: 1rem; } }

.faq-list { max-width: 56rem; margin: 0 auto; display: grid; gap: 0.6rem; }
.faq-item {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.faq-item summary {
    cursor: pointer;
    padding: 0.9rem 1.2rem;
    font-weight: 600;
    list-style: none;
    position: relative;
    padding-right: 2.5rem;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
    content: '+';
    position: absolute;
    right: 1.1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--accent);
}
.faq-item[open] summary::after { content: '\2212'; }
.faq-item p { margin: 0; padding: 0 1.2rem 1rem; color: var(--muted); font-size: 0.92rem; }

.landing-footer { display: block; text-align: center; }
.landing-footer .container { display: flex; flex-direction: column; gap: 0.25rem; padding: 0.5rem 1.25rem; }

@media (max-width: 880px) {
    .hero { padding: 2.5rem 0 2rem; }
    .feature-list { grid-template-columns: 1fr; }
    .landing-nav { display: none; }
    .landing-section { padding: 2.5rem 0; }
    .signin-panel { right: -0.5rem; width: 280px; }

    /* Collapse dashboard nav behind hamburger */
    .hamburger { display: flex; }
    .profile-dropdown { right: -0.5rem; }

    .mainnav {
        display: none;
        flex-direction: column;
        gap: 0.6rem;
        padding: 0.75rem 1.25rem 1rem;
        border-top: 1px solid var(--border);
    }
    .mainnav.open { display: flex; }

    .nav-group {
        flex-wrap: wrap;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .topbar-row { gap: 0.5rem; padding: 0.5rem 0.75rem; }
    .brand-name span { display: none; }
    .container { padding: 1rem 0.75rem 2rem; }
    .card { padding: 1rem; border-radius: 10px; }
    .grid { grid-template-columns: 1fr; }
}

/* ── i18n: language switcher ─────────────────────────────────────────────── */
.visually-hidden {
    position: absolute !important;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden; clip: rect(0, 0, 0, 0);
    white-space: nowrap; border: 0;
}
.lang-switcher { display: inline-flex; align-items: center; }
.lang-select {
    background: var(--surface, transparent);
    color: inherit;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.3rem 0.5rem;
    font: inherit;
    font-size: 0.85rem;
    cursor: pointer;
}
.lang-select:focus { outline: 2px solid var(--accent, #4f46e5); outline-offset: 1px; }

/* ── i18n: RTL support (Arabic) ──────────────────────────────────────────── */
[dir="rtl"] body,
[dir="rtl"] .container { text-align: right; }
[dir="rtl"] .topbar-row { flex-direction: row-reverse; }
[dir="rtl"] .mainnav { flex-direction: row-reverse; }
[dir="rtl"] .user-meta { text-align: right; }
[dir="rtl"] .nav-switch .icon,
[dir="rtl"] .spacer { /* spacer still grows */ }
[dir="rtl"] .notification-dropdown { left: 0.75rem; right: auto; }
[dir="rtl"] .profile-dropdown { left: 0; right: auto; }
[dir="rtl"] table th,
[dir="rtl"] table td { text-align: right; }
[dir="rtl"] .toast-viewport { left: 1rem; right: auto; }
[dir="rtl"] .progress-bar > span { float: right; }
/* Flip directional icons in nav switches */
[dir="rtl"] .nav-switch { unicode-bidi: plaintext; }
[dir="rtl"] .nav-icon { margin-right: 0; margin-left: 4px; }
[dir="rtl"] .btn-icon { margin-right: 0; margin-left: 3px; }
/* Keep code/log output and inline-code LTR even under RTL */
[dir="rtl"] pre,
[dir="rtl"] code,
[dir="rtl"] .code,
[dir="rtl"] input[type="text"].ltr,
[dir="rtl"] .force-ltr { direction: ltr; text-align: left; }

/* ── Cookie consent banner ─────────────────────────────────────────────── */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 9998;
    background: var(--panel);
    border-top: 1px solid var(--border);
    box-shadow: 0 -2px 12px rgba(0,0,0,.1);
    padding: .9rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
    font-size: .88rem;
    animation: cookieSlideUp .35s ease;
}
.cookie-banner[hidden] { display: none; }
.cookie-banner p { margin: 0; color: var(--text); max-width: 600px; }
.cookie-banner a { color: var(--accent); }
.cookie-banner .btn { white-space: nowrap; }
@keyframes cookieSlideUp { from { transform: translateY(100%); } to { transform: none; } }

/* ── Settings tab bar (shared between grouped pages) ───────────────────── */
.settings-tabs {
    display: flex;
    gap: 0;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: var(--panel-2);
    padding: .25rem;
    margin-bottom: 1.25rem;
    overflow-x: auto;
    flex-wrap: wrap;
}
.settings-tabs a {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: .4rem .9rem;
    border-radius: 8px;
    color: var(--text);
    font-size: .88rem;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    transition: background .12s, color .12s;
}
.settings-tabs a:hover { background: var(--accent-soft); text-decoration: none; }
.settings-tabs a.active { background: var(--accent); color: #fff; }
.area-admin .settings-tabs a.active { background: var(--admin-accent); }
.area-admin .settings-tabs a:hover:not(.active) { background: var(--admin-accent-soft); }

/* ── 3.3 Loading states for async buttons ──────────────────────────────── */
button.btn-loading, .btn.btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.65;
}
button.btn-loading::after, .btn.btn-loading::after {
    content: '';
    display: inline-block;
    width: .85em;
    height: .85em;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    margin-left: .4rem;
    vertical-align: middle;
}

/* ── 3.4 Settings / form grid mobile overflow ──────────────────────────── */
.grid {
    overflow-x: auto;
}

/* ── 3.2 ARIA: focus-visible for tab-like elements ─────────────────────── */
[role="tab"]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 500;
    padding: 1rem;
}
.modal-overlay[hidden] { display: none; }
.modal-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 1.5rem 1.75rem;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 480px;
}
.modal-box:focus { outline: none; }
.modal-close:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* dialog.js builds .modal-box as a native <dialog> (see that file for why) —
   .modal-overlay above only applies when .modal-box is used as a plain div
   child of it (playground.php/evaluations.php/bioasq_viewer.php's own
   standalone modals); a <dialog> needs its own backdrop instead. */
dialog.modal-box {
    margin: auto;
}
dialog.modal-box::backdrop {
    background: rgba(0, 0, 0, 0.45);
}

/* ── RAG upload page (user/rag_upload.php) ─────────────────────────────── */
.rag-progress-card {
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1rem 1.15rem;
    background: var(--panel);
    margin-bottom: .85rem;
}
.rag-progress-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: .6rem;
}
.rag-progress-title { font-size: 1.02rem; font-weight: 700; margin: 0 0 .2rem; }
.rag-progress-subtitle { font-size: .74rem; color: var(--muted); font-family: monospace; }
.rag-progress-pct-big { font-size: 1.7rem; font-weight: 800; color: var(--accent); line-height: 1; text-align: right; }
.rag-progress-pct-label { font-size: .7rem; color: var(--muted); text-align: right; margin-top: .15rem; white-space: nowrap; }

.rag-progress-bar-track {
    height: 8px;
    border-radius: 999px;
    background: var(--panel-2);
    overflow: hidden;
    margin-bottom: 1rem;
}
.rag-progress-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }

.rag-file-stream-label {
    font-size: .7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    margin: 0 0 .5rem;
}

.rag-file-card {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem .8rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--panel-2);
    margin-bottom: .5rem;
    transition: opacity .2s ease;
}
.rag-file-card:last-child { margin-bottom: 0; }
.rag-file-card.is-queued { opacity: .55; }
.rag-file-icon {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.rag-file-card.is-queued .rag-file-icon { background: var(--panel); color: var(--muted); }
.rag-file-card.is-failed .rag-file-icon { background: var(--bad-soft); color: var(--bad); }
.rag-file-icon svg { width: 17px; height: 17px; }
.rag-file-main { flex: 1; min-width: 0; }
.rag-file-top-row { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; }
.rag-file-name {
    font-weight: 600;
    font-size: .85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.rag-file-pct { font-size: .8rem; font-weight: 700; color: var(--accent); flex-shrink: 0; }
.rag-file-card.is-queued .rag-file-pct { color: var(--muted); }
.rag-file-card.is-failed .rag-file-pct { color: var(--bad); }
.rag-file-sub-row { display: flex; justify-content: space-between; align-items: center; gap: .6rem; margin-top: .3rem; }
.rag-file-bar-track { flex: 1; height: 5px; border-radius: 999px; background: var(--panel); overflow: hidden; }
.rag-file-card.is-queued .rag-file-bar-track,
.rag-file-card.is-failed .rag-file-bar-track { background: var(--border); }
.rag-file-bar-fill { height: 100%; background: var(--accent); border-radius: 999px; transition: width .4s ease; }
.rag-file-card.is-failed .rag-file-bar-fill { background: var(--bad); }
.rag-file-status-label {
    font-size: .66rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .03em;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Custom favorited-model picker — replaces a native <select> so a
   favorited model can show a star, which <option> elements can't render
   consistently across browsers. */
.rag-model-picker { position: relative; display: inline-block; }
.rag-model-picker-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    min-width: 190px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: .4rem .65rem;
    font-size: .82rem;
    color: var(--text);
    cursor: pointer;
    font-family: inherit;
}
.rag-model-picker-btn:hover { border-color: var(--accent); }
.rag-model-picker-caret { color: var(--muted); font-size: .7rem; }
.rag-model-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 220px;
    max-height: 260px;
    overflow-y: auto;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .12);
    z-index: 60;
}
.rag-model-option {
    display: flex;
    align-items: center;
    gap: .55rem;
    width: 100%;
    padding: .45rem .7rem;
    font-size: .82rem;
    background: none;
    border: none;
    text-align: left;
    cursor: pointer;
    color: var(--text);
    font-family: inherit;
    box-sizing: border-box;
}
.rag-model-option:hover { background: var(--accent-soft); }
.rag-model-option.is-selected { font-weight: 700; }
.rag-model-group-label {
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted);
    padding: .5rem .7rem .25rem;
}
.rag-star { color: var(--warn); flex-shrink: 0; line-height: 1; }
.rag-star.is-empty { color: var(--border); }

/* .card's base overflow-x:auto forces overflow-y to auto too (a CSS rule:
   overflow-y computes to auto whenever overflow-x isn't visible) — that
   clips this page's absolutely-positioned .rag-model-dropdown to the
   card's box instead of letting it float over the page below it, which is
   what produced the extra, unwanted scrollbar/truncation. This card never
   holds wide tabular content that needed the horizontal scroll in the
   first place, so turning it off here is safe. */
.card.rag-sessions-card { overflow: visible; }

/* ── RAG upload drop zone ──────────────────────────────────────────────── */
.rag-dropzone {
    border: 2px dashed var(--border);
    border-radius: 14px;
    padding: 2rem 1.5rem;
    text-align: center;
    background: var(--panel-2);
    transition: border-color .15s ease, background .15s ease;
}
.rag-dropzone.is-dragover { border-color: var(--accent); background: var(--accent-soft); }
.rag-dropzone-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--accent-soft);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto .75rem;
}
.rag-dropzone-icon svg { width: 24px; height: 24px; }
.rag-dropzone-title { font-weight: 700; font-size: 1rem; margin: 0 0 .3rem; }
.rag-dropzone-sub { font-size: .8rem; color: var(--muted); margin: 0 auto 1rem; max-width: 420px; }
.rag-dropzone-actions { display: flex; gap: .6rem; justify-content: center; flex-wrap: wrap; }
.rag-dropzone-selected { margin-top: .65rem; font-size: .78rem; color: var(--muted); }
