:root {
    --color-bg: #faf7f2;
    --color-surface: #ffffff;
    --color-border: #ece7dc;
    --color-text: #1e2126;
    --color-text-muted: #7a756a;
    --color-primary: #0e6f5b;
    --color-primary-dark: #0b5c4b;
    --color-success: #1a9d5a;
    --color-success-bg: #e7f7ee;
    --color-danger: #c23b3b;
    --color-danger-dark: #9c2f2f;
    --color-danger-bg: #fdecea;
    --color-warning: #92400e;
    --color-warning-bg: #fef3c7;
    --color-info: #2f6fed;
    --color-info-bg: #e6f0fd;
    --sidebar-width: 248px;
    --sidebar-bg: #faf7f2;
    --sidebar-text: #7a756a;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(30, 26, 20, 0.06);

    /* Derived tokens — computed from the palette above via color-mix(), so
       every theme below (dark/emerald/warm) gets correct, theme-aware
       surfaces and accents automatically without redefining these. */
    --radius-sm: 9px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(30, 26, 20, 0.05);
    --shadow-md: 0 6px 16px -4px rgba(30, 26, 20, 0.12), 0 2px 4px rgba(30, 26, 20, 0.06);
    --shadow-lg: 0 12px 32px -8px rgba(30, 26, 20, 0.18);
    --surface-subtle: color-mix(in srgb, var(--color-text) 4%, var(--color-surface));
    --surface-subtle-strong: color-mix(in srgb, var(--color-text) 7%, var(--color-surface));
    --primary-soft: color-mix(in srgb, var(--color-primary) 12%, var(--color-surface));
    --primary-softer: color-mix(in srgb, var(--color-primary) 7%, var(--color-surface));
    --primary-border: color-mix(in srgb, var(--color-primary) 35%, var(--color-border));
    --focus-ring: 0 0 0 3px color-mix(in srgb, var(--color-primary) 30%, transparent);

    /* Sidebar tokens — this default (premium/light) theme uses a sidebar
       that blends into the page background, so hover/active states tint
       toward the primary color rather than lightening toward white. The
       dark/emerald/warm theme overrides below restore the white-mix
       versions of these three alongside their own dark --sidebar-bg. */
    --sidebar-fg-strong: var(--color-primary-dark);
    --sidebar-hover: color-mix(in srgb, var(--color-primary) 8%, transparent);
    --sidebar-active-bg: color-mix(in srgb, var(--color-primary) 14%, transparent);
    --sidebar-border: var(--color-border);
}

/* Theme palettes — switched via data-theme on <html>, set from Master
   Settings. Only the accent/sidebar/background variables change; layout,
   spacing and every other rule stays identical across themes. */
/* These three alternate themes keep the original dark sidebar, so they
   restore the white-mix hover/active/border/fg tokens the default
   (premium/light) theme above no longer sets. */
:root[data-theme="dark"] {
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-border: #334155;
    --color-text: #e5e7eb;
    --color-text-muted: #94a3b8;
    --color-primary: #3b82f6;
    --color-primary-dark: #2563eb;
    --sidebar-bg: #020617;
    --sidebar-text: #cbd5e1;
    --sidebar-fg-strong: #fff;
    --sidebar-hover: color-mix(in srgb, white 10%, transparent);
    --sidebar-active-bg: color-mix(in srgb, white 14%, transparent);
    --sidebar-border: color-mix(in srgb, white 10%, transparent);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 6px 16px -4px rgba(0, 0, 0, 0.45), 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.55);
}

:root[data-theme="emerald"] {
    --color-primary: #16a34a;
    --color-primary-dark: #15803d;
    --sidebar-bg: #064e3b;
    --sidebar-text: #d1fae5;
    --sidebar-fg-strong: #fff;
    --sidebar-hover: color-mix(in srgb, white 10%, transparent);
    --sidebar-active-bg: color-mix(in srgb, white 14%, transparent);
    --sidebar-border: color-mix(in srgb, white 10%, transparent);
}

:root[data-theme="warm"] {
    --color-primary: #d97706;
    --color-primary-dark: #b45309;
    --sidebar-bg: #451a03;
    --sidebar-text: #fde68a;
    --sidebar-fg-strong: #fff;
    --sidebar-hover: color-mix(in srgb, white 10%, transparent);
    --sidebar-active-bg: color-mix(in srgb, white 14%, transparent);
    --sidebar-border: color-mix(in srgb, white 10%, transparent);
}

/* Material Symbols icon font — bundled locally (public_html/assets/fonts/),
   not loaded from Google's CDN, so it works offline and needs no CSP change. */
@font-face {
    font-family: 'Material Symbols Outlined';
    font-style: normal;
    font-weight: 400;
    font-display: block;
    src: url('../fonts/material-symbols-outlined.woff2') format('woff2');
}

.material-symbols-outlined {
    font-family: 'Material Symbols Outlined';
    font-weight: normal;
    font-style: normal;
    font-size: 20px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    vertical-align: middle;
    -webkit-font-smoothing: antialiased;
    font-feature-settings: 'liga';
    -webkit-font-feature-settings: 'liga';
    -moz-font-feature-settings: 'liga';
}

.nav-icon { margin-inline-end: 0.6rem; font-size: 19px; opacity: 0.75; transition: opacity 0.15s ease; }
.group-label .nav-icon { font-size: 15px; margin-inline-end: 0.4rem; opacity: 0.55; }
.nav-icon.icon-only { margin-inline-end: 0; vertical-align: -4px; }

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

/* overflow-x lives on html only — setting it on body too makes body's
   overflow-y auto-compute (CSS overflow quirk), which turns body into a
   second scroll box that never actually scrolls, breaking `position: sticky`
   for every descendant (the sidebar, the help-page TOC) on any page tall
   enough to scroll. */
html {
    overflow-x: hidden;
}

::selection { background: color-mix(in srgb, var(--color-primary) 30%, transparent); }

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
    border-radius: var(--radius-sm);
}

h1, h2, h3, h4 { margin: 0 0 0.6em; font-weight: 700; letter-spacing: -0.01em; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.02rem; }

.app-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: var(--sidebar-width);
    flex-shrink: 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    padding: 1.1rem 0.6rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    border-inline-end: 1px solid var(--sidebar-border);
}

.nav-toggle {
    display: none;
    background: none;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 1.1rem;
    line-height: 1;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    margin-inline-end: 0.75rem;
    transition: background 0.15s ease;
}

.sidebar-backdrop {
    display: none;
}

.sidebar .brand {
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: -0.01em;
    color: var(--sidebar-fg-strong);
    padding: 0 0.65rem 0.9rem;
    margin: 0 0.6rem 0.6rem;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar nav a {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    margin: 0.05rem 0.6rem;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.15s ease, color 0.15s ease;
}

.sidebar nav a:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-fg-strong);
    text-decoration: none;
}

.sidebar nav a.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-fg-strong);
    text-decoration: none;
    font-weight: 700;
}

.sidebar nav a.active .nav-icon,
.sidebar nav a:hover .nav-icon {
    opacity: 1;
}

.sidebar nav .group-label {
    display: flex;
    align-items: center;
    padding: 0.85rem 0.75rem 0.35rem;
    margin: 0.3rem 0.6rem 0;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: color-mix(in srgb, var(--sidebar-text) 55%, transparent);
    border-top: 1px solid var(--sidebar-border);
}

.sidebar nav .group-label:first-of-type {
    border-top: none;
    margin-top: 0;
}

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.tab-nav {
    display: flex;
    gap: 0.25rem;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 1.25rem;
    overflow-x: auto;
}

.tab-link {
    background: none;
    border: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 0.65rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-text-muted);
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
    transition: background 0.15s ease, color 0.15s ease;
}

.tab-link:hover { color: var(--color-text); background: var(--surface-subtle); }

.tab-link.is-active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
    background: var(--primary-softer);
}

.tab-panel[hidden] { display: none; }

.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    padding: 0.65rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: var(--shadow-sm);
    position: relative;
    z-index: 5;
}

.topbar form { margin: 0; }

.topbar-user { display: flex; align-items: center; gap: 0.6rem; }

.avatar-chip {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.1rem;
    height: 2.1rem;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--color-primary-dark);
    font-weight: 700;
    font-size: 0.88rem;
}

.topbar-user-text { display: flex; flex-direction: column; line-height: 1.2; }
.topbar-user-name { font-weight: 600; font-size: 0.88rem; }
.topbar-user-role { color: var(--color-text-muted); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.04em; }

.language-switcher { display: flex; gap: 0.25rem; }
.language-switcher .btn.is-active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }

.content {
    padding: 1.5rem;
    flex: 1;
}

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

.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.25rem;
    margin-bottom: 1.25rem;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 1.1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.stat-card .value { font-size: 1.85rem; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-card .label { color: var(--color-text-muted); font-size: 0.85rem; }

.stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-sm);
    margin-bottom: 0.75rem;
}

.stat-icon .material-symbols-outlined {
    font-size: 20px;
    margin-inline-end: 0;
    opacity: 1;
}

.stat-icon-primary { background: var(--primary-soft); color: var(--color-primary-dark); }
.stat-icon-success { background: var(--color-success-bg); color: var(--color-success); }
.stat-icon-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.stat-icon-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.stat-icon-info { background: var(--color-info-bg); color: var(--color-info); }

table { border-collapse: collapse; width: 100%; }

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
}

.table-wrap .table { border: none; }

.table th, .table td {
    padding: 0.65rem 0.85rem;
    border-bottom: 1px solid var(--color-border);
    text-align: start;
    font-size: 0.92rem;
    font-variant-numeric: tabular-nums;
}

.table th {
    background: var(--surface-subtle);
    font-weight: 700;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
}

.table tbody tr { transition: background 0.12s ease; }
.table tbody tr:hover { background: var(--surface-subtle); }
.table tbody tr:last-child td { border-bottom: none; }

.btn {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.88rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.btn:hover { text-decoration: none; background: var(--surface-subtle-strong); }

.btn-primary { background: var(--color-primary); border-color: var(--color-primary); color: #fff; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--color-primary-dark); border-color: var(--color-primary-dark); color: #fff; }

.btn-danger { background: var(--color-danger); border-color: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-dark); border-color: var(--color-danger-dark); color: #fff; }

.btn-sm { padding: 0.3rem 0.65rem; font-size: 0.8rem; }

.form-group { margin-bottom: 1rem; }
.form-row { display: flex; gap: 1rem; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }

label { display: block; font-weight: 600; font-size: 0.85rem; margin-bottom: 0.35rem; }

input[type="text"], input[type="email"], input[type="password"], input[type="date"],
input[type="number"], input[type="tel"], input[type="month"], select, textarea {
    width: 100%;
    padding: 0.5rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.92rem;
    font-family: inherit;
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: var(--focus-ring);
}

input.is-invalid, select.is-invalid, textarea.is-invalid { border-color: var(--color-danger); }

.field-error { color: var(--color-danger); font-size: 0.8rem; display: block; margin-top: 0.25rem; }

.help-text { color: var(--color-text-muted); font-size: 0.8rem; margin-top: 0.25rem; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    border: 1px solid transparent;
}

.alert-success { background: var(--color-success-bg); color: var(--color-success); border-color: color-mix(in srgb, var(--color-success) 25%, transparent); }
.alert-error { background: var(--color-danger-bg); color: var(--color-danger); border-color: color-mix(in srgb, var(--color-danger) 25%, transparent); }
.alert-warning { background: var(--color-warning-bg); color: var(--color-warning); border-color: color-mix(in srgb, var(--color-warning) 25%, transparent); }
.alert-warning a { color: inherit; font-weight: 600; text-decoration: underline; }

.badge {
    display: inline-block;
    padding: 0.18rem 0.6rem;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.badge-success { background: var(--color-success-bg); color: var(--color-success); }
.badge-danger { background: var(--color-danger-bg); color: var(--color-danger); }
.badge-warning { background: var(--color-warning-bg); color: var(--color-warning); }
.badge-muted { background: var(--surface-subtle-strong); color: var(--color-text-muted); }

.pagination { display: flex; gap: 0.4rem; margin-top: 1rem; }
.pagination a, .pagination span {
    padding: 0.35rem 0.7rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    transition: background 0.15s ease;
}
.pagination a:hover { background: var(--surface-subtle); text-decoration: none; }
.pagination .current { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }

.text-muted { color: var(--color-text-muted); }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.flex { display: flex; }
.gap-1 { gap: 0.5rem; }
.items-center { align-items: center; }
.inline-form { display: inline; }

.empty-state {
    text-align: center;
    padding: 2.5rem 1rem;
    color: var(--color-text-muted);
}

.guardian-row { display: flex; gap: 0.5rem; margin-bottom: 0.5rem; flex-wrap: wrap; }
.guardian-row input { flex: 1; min-width: 140px; }

.dynamic-row { border: 1px dashed var(--color-border); border-radius: var(--radius); padding: 0.75rem; margin-bottom: 0.75rem; }

/* Help / user guide page */
.help-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.help-toc { position: sticky; top: 1rem; background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 1rem; }
.help-toc-group { text-transform: uppercase; font-size: 0.68rem; letter-spacing: 0.05em; color: var(--color-text-muted); margin: 0.9rem 0 0.3rem; }
.help-toc-group:first-child { margin-top: 0; }
.help-toc a { display: block; padding: 0.25rem 0.4rem; border-radius: 6px; font-size: 0.86rem; color: var(--color-text-muted); }
.help-toc a:hover { background: var(--color-bg); color: var(--color-text); text-decoration: none; }
.help-section { padding: 1.75rem 0; border-top: 1px solid var(--color-border); }
.help-section:first-child { padding-top: 0; border-top: none; }
.help-section h2 { margin: 0 0 0.4rem; }
.help-lede { color: var(--color-text-muted); margin-bottom: 1rem; max-width: 62ch; }
.help-steps { list-style: none; margin: 0 0 1rem; padding: 0; counter-reset: help-step; display: flex; flex-direction: column; gap: 0.5rem; }
.help-steps li { counter-increment: help-step; position: relative; padding-inline-start: 2rem; font-size: 0.92rem; }
.help-steps li::before {
    content: counter(help-step);
    position: absolute; inset-inline-start: 0; top: 0.05rem;
    width: 1.4rem; height: 1.4rem; border-radius: 50%;
    background: var(--color-bg); color: var(--color-primary);
    font-size: 0.72rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
}
.help-note { background: var(--color-bg); border-radius: var(--radius); padding: 0.8rem 1rem; font-size: 0.88rem; margin: 0 0 1rem; }
.help-shot { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--color-border); box-shadow: var(--shadow); }
.help-shot img { display: block; width: 100%; height: auto; }
.help-caption { margin-top: 0.5rem; font-size: 0.82rem; color: var(--color-text-muted); }
@media (max-width: 860px) {
    .help-layout { grid-template-columns: 1fr; }
    .help-toc { position: static; }
}

/* Responsive: below this width the sidebar becomes an off-canvas panel
   toggled by the hamburger button, instead of a fixed permanent column. */
@media (max-width: 860px) {
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .sidebar {
        position: fixed;
        top: 0;
        inset-inline-start: 0;
        width: 270px;
        max-width: 82vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 1000;
        box-shadow: var(--shadow-lg);
    }

    /* translateX is a physical-axis transform, not direction-aware like the
       inset-inline-start above — in RTL the sidebar sits on the right via
       inset-inline-start, so hiding it must slide it further right
       (+100%), not left (-100%), or it flies off the wrong edge. */
    html[dir="rtl"] .sidebar {
        transform: translateX(100%);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .sidebar-backdrop.is-open {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
        z-index: 900;
    }

    .content {
        padding: 1rem;
    }

    .topbar {
        padding: 0.6rem 1rem;
    }

    .topbar-user-role { display: none; }

    .stat-grid {
        grid-template-columns: 1fr 1fr;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }
}

/* AI chat widget — floating toggle + panel on the student/parent portals */
.ai-chat {
    position: fixed;
    inset-inline-end: 1.25rem;
    bottom: 1.25rem;
    z-index: 950;
}

.ai-chat-toggle {
    width: 3.2rem;
    height: 3.2rem;
    border-radius: 50%;
    border: none;
    background: var(--color-primary);
    color: #fff;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.15s ease, background 0.15s ease;
}

.ai-chat-toggle:hover {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.ai-chat-toggle .material-symbols-outlined {
    font-size: 26px;
    margin: 0;
}

.ai-chat-panel {
    position: absolute;
    inset-inline-end: 0;
    bottom: calc(100% + 0.75rem);
    width: min(340px, 88vw);
    height: min(460px, 70vh);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--primary-soft);
    color: var(--color-primary-dark);
    font-weight: 700;
    font-size: 0.92rem;
}

.ai-chat-header .material-symbols-outlined {
    margin-inline-end: 0.4rem;
    vertical-align: -5px;
}

.ai-chat-close {
    background: none;
    border: none;
    color: inherit;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
    padding: 0.15rem 0.4rem;
}

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.ai-chat-msg {
    max-width: 85%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius);
    font-size: 0.88rem;
    line-height: 1.4;
    white-space: pre-wrap;
}

.ai-chat-msg-bot {
    align-self: flex-start;
    background: var(--surface-subtle-strong);
    color: var(--color-text);
    border-bottom-start-radius: 4px;
}

.ai-chat-msg-user {
    align-self: flex-end;
    background: var(--color-primary);
    color: #fff;
    border-bottom-end-radius: 4px;
}

.ai-chat-msg-error {
    align-self: flex-start;
    background: var(--color-danger-bg);
    color: var(--color-danger);
    border-bottom-start-radius: 4px;
}

.ai-chat-form {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid var(--color-border);
}

.ai-chat-input {
    flex: 1;
    padding: 0.45rem 0.65rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    background: var(--color-surface);
    color: var(--color-text);
}

@media (max-width: 480px) {
    .ai-chat {
        inset-inline-end: 0.75rem;
        bottom: 0.75rem;
    }
}

/* Quick Tour — a manually-triggered walkthrough (topbar "Take a Tour"
   button). No separate backdrop element: the "spotlight" is a large,
   page-covering box-shadow on the highlighted element itself, a common
   lightweight trick that needs no extra DOM and always tracks the
   target's real position/size, including through window resizes. */
.tour-highlight {
    position: relative;
    z-index: 10000;
    border-radius: var(--radius-sm);
    box-shadow: 0 0 0 4px var(--color-primary), 0 0 0 9999px rgba(15, 23, 42, 0.65);
    transition: box-shadow 0.2s ease;
}
.tour-tooltip {
    position: fixed;
    z-index: 10001;
    max-width: 320px;
    background: var(--color-surface);
    color: var(--color-text);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    padding: 1rem 1.1rem;
    font-size: 0.9rem;
}
.tour-tooltip h4 {
    margin: 0 0 0.4rem 0;
    font-size: 1rem;
}
.tour-tooltip p {
    margin: 0 0 0.85rem 0;
    color: var(--color-text-muted);
    line-height: 1.45;
}
.tour-tooltip-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}
.tour-tooltip-step {
    font-size: 0.78rem;
    color: var(--color-text-muted);
}
.tour-tooltip-buttons {
    display: flex;
    gap: 0.4rem;
}
.footer-credit {
    padding: 0.75rem 1.5rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    border-top: 1px solid var(--color-border);
}
.footer-credit a {
    color: var(--color-text-muted);
    text-decoration: underline;
}
.footer-credit a:hover {
    color: var(--color-primary);
}
