/* ═══════════════════════════════════════════════════════════
   ChatMai — quiet surfaces and grouped controls
   Sarabun typography, neutral light and dark themes
   ═══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Sarabun:wght@300;400;500;600;700;800&display=swap');

:root {
    /* ── Typography ────────────────────────── */
    --font-sans:     'Sarabun', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-display:  'Sarabun', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --font-mono:     'SF Mono', 'Menlo', 'Consolas', monospace;

    /* ── Backgrounds (Apple-inspired Light) ── */
    --bg-app:        #f5f5f7;
    --bg-primary:    #ffffff;
    --bg-secondary:  #f2f2f7;
    --bg-surface:    #ffffff;
    --bg-elevated:   #ffffff;
    --bg-hover:      rgba(0, 0, 0, 0.04);
    --bg-tertiary:   #e5e5ea;
    --bg-chat:       #ffffff;

    /* ── Sidebar ──────────── */
    --sidebar-bg:    #f5f5f7;

    /* ── Text (Crisp Hierarchy) ─────────────── */
    --text-primary:  #1c1c1e;
    --text-secondary:#3a3a3c;
    /* #636366 passes 4.5:1 on #ffffff and #f5f5f7 */
    --text-muted:    #636366;
    --text-inverse:  #ffffff;

    /* ── Borders (Clean Tones) ────────────── */
    --border-default: #d1d1d6;
    --border-subtle:  #e5e5ea;
    --border-strong:  #c7c7cc;
    --border-accent:  #6366f1;

    /* ── Accent (Restrained Indigo) ──────── */
    --accent-primary: #6366f1;
    --accent-hover:   #4f46e5;
    --accent-light:   rgba(99, 102, 241, 0.1);

    /* ── Status Colors ────────────────────── */
    --accent-green:   #34c759;
    --accent-green-bg:#e6f8ec;
    --accent-red:     #ff3b30;
    --accent-red-bg:  #ffeceb;
    --accent-amber:   #ff9f0a;
    --accent-amber-bg:#fff4e5;
    --accent-blue:    #007aff;
    --accent-blue-bg: #e5f1ff;
    --accent-blue-text:#005bb5;
    --accent-green-text:#248a3d;
    --accent-red-text:#c92a22;
    --accent-amber-text:#b26f07;
    --on-accent:      #ffffff;
    --accent-solid:   #4f46e5;
    --accent-solid-hover: #4338ca;
    --link:           #4f46e5;
    --overlay:        rgba(0, 0, 0, 0.4);

    /* ── Shadows (Spatial Overlays only) ──────────── */
    --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md:     0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg:     0 12px 32px rgba(0, 0, 0, 0.12);
    --shadow-xl:     0 20px 48px rgba(0, 0, 0, 0.16);

    /* ── Radius ───────────── */
    --radius-sm:     0.5rem;
    --radius-md:     0.625rem;
    --radius-lg:     0.75rem;
    --radius-xl:     1rem;
    --radius-2xl:    1.25rem;
    --radius-full:   9999px;

    /* ── Spacing ──────────────────────────── */
    --space-xs:      8px;
    --space-sm:      12px;
    --space-md:      16px;
    --space-lg:      24px;
    --space-xl:      32px;

    /* ── Layout ────────────────────────────── */
    --sidebar-width:     260px;
    --sidebar-collapsed: 72px;
    --bottom-nav-height: 56px;

    /* ── Motion ────────────────────────────── */
    --transition-fast: 0.15s cubic-bezier(0.2, 0.8, 0.2, 1);
    --transition-base: 0.25s cubic-bezier(0.2, 0.8, 0.2, 1);

    /* ── Type scale ────────────────────────── */
    --text-xs:   0.75rem;
    --text-sm:   0.8125rem;
    --text-base: 0.875rem;
    --text-md:   1rem;
    --text-lg:   1.125rem;
    --text-xl:   1.375rem;
    --text-2xl:  1.75rem;

    /* ── Controls ──────────────────────────── */
    --control-h:    44px;
    --control-h-sm: 32px;
    --touch-min:    44px;
    --ring:         0 0 0 3px rgba(99, 102, 241, 0.3);
    color-scheme: light;
}

/* ── Dark theme (Apple-inspired Dark) ───────────────────────────────────────────── */
:root[data-theme="dark"] {
    --bg-app:        #101014;
    --bg-primary:    #1c1c20;
    --bg-secondary:  #242428;
    --bg-surface:    #1c1c20;
    --bg-elevated:   #2c2c30;
    --bg-hover:      rgba(255, 255, 255, 0.08);
    --bg-tertiary:   #323236;
    --bg-chat:       #18181c;
    --sidebar-bg:    #101014;
    --text-primary:  #f5f5f7;
    --text-secondary:#d1d1d6;
    --text-muted:    #98989d;
    --text-inverse:  #101014;
    --border-default:#38383a;
    --border-subtle: #2c2c2e;
    --border-strong: #48484a;
    --border-accent: #818cf8;
    --accent-primary:#7477f5;
    --accent-hover:  #a5b4fc;
    --accent-solid:  #5c53f2;
    --accent-solid-hover: #736bfa;
    --link:          #a5b4fc;
    --accent-light:  rgba(129, 140, 248, 0.15);
    --accent-green-bg:rgba(48, 209, 88, 0.15);
    --accent-red-bg: rgba(255, 69, 58, 0.15);
    --accent-amber-bg:rgba(255, 159, 10, 0.15);
    --accent-blue-bg:rgba(10, 132, 255, 0.15);
    --accent-blue-text:#66b3ff;
    --accent-green-text:#5cd67c;
    --accent-red-text:#ff7369;
    --accent-amber-text:#ffb84d;
    --on-accent:     #ffffff;
    --overlay:       rgba(0, 0, 0, 0.6);
    --shadow-sm:     0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-md:     0 4px 12px rgba(0, 0, 0, 0.6);
    --shadow-lg:     0 12px 32px rgba(0, 0, 0, 0.7);
    --shadow-xl:     0 20px 48px rgba(0, 0, 0, 0.8);
    --ring:          0 0 0 3px rgba(129, 140, 248, 0.4);
    color-scheme: dark;
}

/* ── Picker tokens ──────────────────────────────────────────
   css/cv-inputs.css (shared with ContentVelo, synced by tools/ui-rebuild/sync-brand.py)
   draws the select, date, time and colour popups, and reads only these. */
:root {
    --cvi-surface: var(--bg-surface);
    --cvi-subtle: var(--bg-secondary);
    --cvi-text: var(--text-primary);
    --cvi-heading: var(--text-primary);
    --cvi-muted: var(--text-secondary);
    --cvi-border: var(--border-default);
    --cvi-border-strong: var(--border-strong);
    --cvi-hover: var(--bg-hover);
    --cvi-track: var(--bg-tertiary);
    --cvi-accent: var(--accent-primary);
    --cvi-accent-hover: var(--accent-hover);
    --cvi-accent-text: var(--accent-hover);
    --cvi-on-accent: #ffffff;
    --cvi-ring: var(--accent-light);
    --cvi-danger: var(--accent-red);
    --cvi-overlay: rgba(28, 25, 23, 0.45);
    --cvi-shadow: var(--shadow-lg);
    --cvi-radius: var(--radius-md);
    --cvi-radius-sm: 0.5rem;
    --cvi-z: 2000;
    --cvi-chevron: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2378716c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 8l4 4 4-4'/%3E%3C/svg%3E");
    --cvi-calendar: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2378716c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Crect x='3.5' y='4.5' width='13' height='12' rx='2'/%3E%3Cpath d='M3.5 8.5h13M7 3v3M13 3v3'/%3E%3C/svg%3E");
    --cvi-clock: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='none' stroke='%2378716c' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='10' cy='10' r='6.5'/%3E%3Cpath d='M10 6.5V10l2.5 1.5'/%3E%3C/svg%3E");
}

/* Checkboxes and radios, drawn on the tokens instead of by the OS. `:where()` keeps this at
   zero specificity, so every toggle switch that hides its input and draws its own still wins. */
:where(input[type="checkbox"]:not(.navbar-toggler), input[type="radio"]) {
    appearance: none;
    -webkit-appearance: none;
    width: 1.125rem;
    height: 1.125rem;
    flex: none;
    border: 1.5px solid var(--border-strong);
    border-radius: 0.375rem;
    background: var(--bg-surface) no-repeat center / 0.875rem;
    cursor: pointer;
    vertical-align: middle;
    transition: background-color var(--transition-fast), border-color var(--transition-fast);
}
:where(input[type="radio"]) { border-radius: 50%; }
:where(input[type="checkbox"]:not(.navbar-toggler):checked, input[type="radio"]:checked) {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
}
:where(input[type="checkbox"]:not(.navbar-toggler):checked) {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='white' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M3 8.5l3.5 3.5L13 5'/%3E%3C/svg%3E");
}
:where(input[type="radio"]:checked) {
    background-image: radial-gradient(circle, #ffffff 0 34%, transparent 36%);
    background-size: 100% 100%;
}
:where(input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible) {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
}
:where(input[type="checkbox"]:disabled, input[type="radio"]:disabled) {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Global Reset ────────────────────────────────────────── */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-family: var(--font-sans);
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    color: var(--text-primary);
    background: var(--bg-app);
}

body {
    font-family: var(--font-sans);
    min-height: 100vh;
    min-height: 100dvh;
    line-height: 1.5;
    overflow: hidden;
    background: var(--bg-app);
    background-image: none !important;
    color: var(--text-primary);
}

/* ── Headings ────────────────────────────────────────────── */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    font-weight: 600;
    /* 1.2 clips the tone mark above an upper vowel (e.g. ที่, นี้) on Thai headings. */
    line-height: 1.35;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    margin-bottom: 0.5em;
}

h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.03em; }
h2 { font-size: 1.5rem; letter-spacing: -0.02em; }
h3 { font-size: 1.25rem; }
h4 { font-size: 0.8125rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-muted); }

/* ── Links ───────────────────────────────────────────────── */
a {
    color: var(--link);
    text-decoration: none;
    transition: all var(--transition-fast);
}

a:hover {
    color: var(--accent-hover);
}

/* ── Selection ───────────────────────────────────────────── */
::selection {
    background: var(--accent-light);
    color: var(--accent-primary);
}

/* ── Scrollbar ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
    background: var(--border-strong);
    border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Focus Ring ──────────────────────────────────────────── */
:focus-visible {
    outline: 2px solid var(--accent-primary);
    outline-offset: 2px;
    border-radius: var(--radius-sm);
}

/* ── Buttons ─────────────────────────────────────────────── */
button {
    font-family: var(--font-sans);
    cursor: pointer;
    border: none;
    background: none;
    font-size: inherit;
    color: inherit;
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--accent-solid);
    color: var(--on-accent);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
    text-decoration: none;
    min-height: var(--control-h);
}

.btn-primary:hover { background: var(--accent-solid-hover); color: var(--on-accent); }
.btn-primary:active { transform: scale(0.98); }

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    font-family: var(--font-sans);
    text-decoration: none;
}

.btn-secondary:hover { background: var(--border-strong); color: var(--text-primary); }

/* ── Inputs ──────────────────────────────────────────────── */
/* Text fields only. On a checkbox or radio this rule's background and padding beat the drawing
   above, which is zero-specificity on purpose, so a ticked box showed as an empty white pill
   (AI Settings' "24 hours", every day ticked, 2026-09-29). :where() keeps this at one element. */
input:where(:not([type="checkbox"], [type="radio"])), textarea, select {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-sm);
    padding: 10px 14px;
    font-size: 0.875rem;
    outline: none;
    transition: all var(--transition-base);
}

input:focus, textarea:focus, select:focus {
    border-color: var(--accent-primary);
    box-shadow: var(--ring);
}

input::placeholder, textarea::placeholder {
    color: var(--text-muted);
}

/* ── Badge ───────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    border: none;
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.badge-purple {
    background: var(--accent-light);
    color: var(--accent-primary);
}

/* ═══════════════════════════════════════════════════════════
   Chat Messages — Push to bottom
   ═══════════════════════════════════════════════════════════ */
#messages-container {
    display: flex !important;
    flex-direction: column !important;
}

#messages-container > :first-child {
    margin-top: auto !important;
}

/* ═══════════════════════════════════════════════════════════
   Global Layout — ChatMai Style
   ═══════════════════════════════════════════════════════════ */
.page {
    background: var(--bg-app) !important;
}

.sidebar {
    background: var(--sidebar-bg) !important;
    border-right: none !important;
}

.nav-wrapper {
    background: var(--sidebar-bg) !important;
}

/* Kill Bootstrap dark theme within the app shell only */
.page .navbar-dark,
.page .navbar-dark .navbar-brand,
.page .top-row.navbar,
.page .top-row.navbar-dark {
    background: transparent !important;
    --bs-navbar-color: var(--text-primary) !important;
}

.container-fluid {
    padding: 0;
}

/* ── Bento Dashboard Layout ───────────────────────────── */
.bento-dashboard {
    padding: 0 1.5rem 4rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

.page-header-sticky {
    position: sticky;
    top: 0;
    z-index: 50;
    background: var(--bg-app);
    padding: 1rem 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem 1rem;
    justify-content: space-between;
    align-items: center;
}

.header-content h1, .header-content h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.header-content .subtitle {
    color: var(--text-muted);
    margin: 0.25rem 0 0 0;
}

.bento-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(min(320px, 100%), 1fr));
    gap: 1.5rem;
    align-items: stretch;
}

/* A card never widens its column to fit a table or a long line: that made Team 664px wide on a
   390px phone, with the invite form and member table cut off (2026-09-29). Wide content scrolls
   inside its own box instead. */
.bento-grid > * {
    min-width: 0;
}

@media (min-width: 1024px) {
    .bento-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .bento-grid > .settings-card:last-child:nth-child(odd) {
        grid-column: 1 / -1;
    }
}

.settings-card {
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
}

.bento-grid .settings-card {
    height: 100%;
}

/* ── App-Scoped Layout (ChatMai Shell) ───────────────── */
.cm-page-header {
    padding: 1.25rem 0;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-default);
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: space-between;
    align-items: center;
}

.cm-page-header h1, .cm-page-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-primary);
}

.cm-section {
    margin-bottom: 2rem;
}

.cm-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}
/* Minimal Modal Polyfill */
.modal-dialog { width: 100%; max-width: 500px; margin: 1.75rem auto; pointer-events: none; }
.modal.modal-lg .modal-dialog { max-width: 800px; }
.modal-content { position: relative; display: flex; flex-direction: column; width: 100%; pointer-events: auto; background-color: var(--bg-elevated); color: var(--text-primary); background-clip: padding-box; border: 1px solid var(--border-default); border-radius: var(--radius-lg); outline: 0; box-shadow: 0 10px 25px rgba(0,0,0,0.15); }
.modal-header { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; padding: 1rem 1rem; border-bottom: 1px solid var(--border-default); border-top-left-radius: calc(.3rem - 1px); border-top-right-radius: calc(.3rem - 1px); }
.modal-title { margin-bottom: 0; line-height: 1.5; font-size: 1.25rem; font-weight: 600; }
.btn-close { box-sizing: content-box; width: 1em; height: 1em; padding: .25em .25em; color: var(--text-primary); background: transparent; border: 0; border-radius: .25rem; opacity: .5; cursor: pointer; font-size: 1.5rem; }
.btn-close:before { content: '\00d7'; }
.btn-close:hover { opacity: .75; text-decoration: none; }
.modal-body { position: relative; flex: 1 1 auto; padding: 1rem; overflow-y: auto; max-height: 70vh; }
.modal-footer { display: flex; flex-wrap: wrap; flex-shrink: 0; align-items: center; justify-content: flex-end; padding: .75rem; border-top: 1px solid var(--border-default); border-bottom-right-radius: calc(.3rem - 1px); border-bottom-left-radius: calc(.3rem - 1px); }
.modal-footer > * { margin: .25rem; }

/* ═══════════════════════════════════════════════════════════
   /welcome — the first screen of a tenant that has not started
   ═══════════════════════════════════════════════════════════
   Its own shell (WelcomeLayout), so none of the sidebar rules apply and nothing
   here needs to fight them. Three steps on the left, one panel on the right, and
   on a phone the rail collapses to a count and three dots. */

.welcome-shell {
    min-height: 100vh;
    background: var(--bg-app);
}

/* Centred once there is room for it. On a phone the content is taller than the viewport, so
   it starts at the top and scrolls; on a desktop it sits in the middle rather than hugging
   the header with 400px of nothing underneath. */
@media (min-width: 900px) {
    .welcome-shell {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .welcome { width: 100%; }
}

.welcome {
    max-width: 62rem;
    margin: 0 auto;
    padding: 2rem 1rem 4rem;
}

.welcome-head { margin-bottom: 2.5rem; }
.welcome-logo { display: block; border-radius: var(--radius-sm); margin-bottom: 1.25rem; }

.welcome-head h1 {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.welcome-sub {
    margin: 0.5rem 0 0;
    max-width: 34rem;
    color: var(--text-secondary);
    font-size: 0.9375rem;
}

.welcome-body {
    display: grid;
    gap: 2rem;
    grid-template-columns: 1fr;
}

.welcome-count {
    margin: 0 0 1.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.welcome-rail ol { list-style: none; margin: 0; padding: 0; }

/* The connector is a pseudo-element on each step rather than a border on the list,
   because it has to stop at the last one and a border does not know which step it
   is on. */
.welcome-step {
    position: relative;
    display: flex;
    gap: 0.875rem;
    padding-bottom: 1.5rem;
}

.welcome-step:last-child { padding-bottom: 0; }

.welcome-step::before {
    content: '';
    position: absolute;
    left: 1.0625rem;
    top: 2.25rem;
    bottom: 0.25rem;
    width: 2px;
    background: var(--border-default);
}

.welcome-step:last-child::before { display: none; }
.welcome-step.is-done::before { background: var(--accent-green); }

.welcome-dot {
    position: relative;
    z-index: 1;
    display: grid;
    place-items: center;
    width: 2.125rem;
    height: 2.125rem;
    flex: none;
    border-radius: 999px;
    border: 2px solid var(--border-default);
    background: var(--bg-surface);
    color: var(--text-muted);
    font-size: 0.8125rem;
    font-weight: 700;
}

.welcome-step.is-current .welcome-dot,
.welcome-dot.is-current {
    border-color: var(--accent-primary);
    background: var(--accent-light);
    color: var(--accent-primary);
}

.welcome-step.is-done .welcome-dot,
.welcome-dot.is-done {
    /* green-700: the white tick is 5.0:1 (it was 2.3:1 on --accent-green) */
    border-color: #15803d;
    background: #15803d;
    color: #fff;
}

.welcome-step-btn {
    text-align: left;
    padding: 0;
    min-width: 0;
    min-height: 2.75rem;
}

.welcome-step-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.welcome-step-note {
    display: block;
    margin-top: 0.125rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.welcome-dots {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.welcome-dots-row {
    display: flex;
    gap: 0.375rem;
    margin-left: auto;
}

 /* 44px, the touch floor. The ring is the whole control here, so it is the control that
    grows rather than an invisible pad around a small circle. */
.welcome-dots .welcome-dot {
    width: 2.75rem;
    height: 2.75rem;
    font-size: 0.8125rem;
}

/* The two responsive rules sit AFTER the blocks they override, because both are plain
   single-class selectors: at equal specificity the later rule wins, and when these were
   written first the .welcome-dots { display: flex } below them put the phone dots on the
   desktop and pushed the panel out of the rail's row. */
@media (min-width: 900px) {
    .welcome-body { grid-template-columns: 15rem minmax(0, 1fr); gap: 3rem; }
    .welcome-dots { display: none; }
}

@media (max-width: 899px) {
    .welcome-rail { display: none; }
}

.welcome-panel {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 1.5rem;
}

.welcome-eyebrow {
    margin: 0;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.welcome-panel h2 {
    margin: 0.5rem 0 0;
    font-size: 1.375rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.welcome-panel p {
    margin: 0.75rem 0 0;
    color: var(--text-secondary);
    font-size: 0.9375rem;
    line-height: 1.7;
}

.welcome-note {
    display: flex;
    gap: 0.5rem;
    align-items: flex-start;
    font-size: 0.8125rem !important;
    color: var(--text-muted) !important;
}

.welcome-note iconify-icon { flex: none; margin-top: 0.125rem; }

.welcome-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.welcome-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.625rem;
    border-radius: 999px;
    background: var(--accent-green-bg);
    color: var(--accent-green);
    font-size: 0.75rem;
    font-weight: 700;
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--text-secondary);
    font-size: 0.875rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.btn-ghost:hover { background: var(--bg-hover); color: var(--text-primary); }

.welcome-skip { margin-top: 2rem; text-align: center; }

.welcome-loading { display: grid; gap: 1rem; }

.welcome-skeleton {
    display: block;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    animation: welcome-pulse 1.4s ease-in-out infinite;
}

@keyframes welcome-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.55; }
}

@media (prefers-reduced-motion: reduce) {
    .welcome-skeleton { animation: none; }
}

/* ── Meena, on call ──────────────────────────────────────────
   A <details> styled as a floating face. The marker is removed on both the
   standards selector and the older WebKit pseudo-element, because a stray
   disclosure triangle beside a face is the whole illusion gone. The panel opens
   upwards: the control sits at the bottom of the viewport, so anything opening
   downwards opens off-screen. */
.meena {
    position: fixed;
    right: 1rem;
    bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
    z-index: 40;
}

.meena-fab {
    display: inline-flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.375rem 1rem 0.375rem 0.375rem;
    border-radius: 999px;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    box-shadow: var(--shadow-md);
    cursor: pointer;
    list-style: none;
    user-select: none;
}

.meena-fab::-webkit-details-marker { display: none; }
.meena-fab::marker { content: ''; }
.meena-fab:hover { border-color: var(--accent-primary); }

.meena-face {
    width: 3.25rem;
    height: 3.25rem;
    border-radius: 999px;
    object-fit: cover;
    flex: none;
}

.meena-fab-text {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.meena-panel {
    position: absolute;
    right: 0;
    bottom: calc(100% + 0.75rem);
    width: min(20rem, calc(100vw - 2rem));
    padding: 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    text-align: left;
    color: var(--text-primary);
}

/* With Meena AI the panel is a small chat: header, conversation that scrolls, question box,
   then the way to the real Meena. Its height is capped so the box stays on screen. */
.meena-panel--ai {
    width: min(23rem, calc(100vw - 2rem));
    display: flex;
    flex-direction: column;
    max-height: min(38rem, calc(100vh - 7rem));
    max-height: min(38rem, calc(100dvh - 7rem));
}

.meena[open] .meena-panel { animation: meena-in 160ms ease-out; }

@keyframes meena-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    .meena[open] .meena-panel { animation: none; }
}

.meena-head { display: flex; align-items: center; gap: 0.75rem; flex: none; }
.meena-titles { flex: 1 1 auto; min-width: 0; }
.meena-name { margin: 0; font-size: 0.875rem; font-weight: 700; color: var(--text-primary); }
.meena-role { margin: 0.125rem 0 0; font-size: 0.75rem; color: var(--text-muted); }

.meena-avatar { position: relative; flex: none; display: inline-flex; }
.meena-head .meena-face { width: 2.75rem; height: 2.75rem; }

/* The AI mark sits on the face in the header, so the assistant is never mistaken for Meena herself. */
.meena-ai-badge {
    position: absolute;
    right: -0.25rem;
    bottom: -0.125rem;
    padding: 0 0.3rem;
    border-radius: 999px;
    background: var(--accent-solid);
    color: var(--on-accent);
    border: 2px solid var(--bg-elevated);
    font-size: 0.625rem;
    font-weight: 700;
    line-height: 1.1rem;
    letter-spacing: 0.02em;
}

.meena-close {
    flex: none;
    display: grid;
    place-items: center;
    width: 2.25rem;
    height: 2.25rem;
    margin: -0.375rem -0.375rem 0 0;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
}
.meena-close iconify-icon { display: block; width: 22px; height: 22px; }
.meena-close:hover { background: var(--bg-hover); color: var(--text-primary); }
.meena-close:focus-visible { outline: none; box-shadow: var(--ring); }

.meena-pitch {
    margin: 0.75rem 0 0;
    font-size: 0.875rem;
    line-height: 1.65;
    color: var(--text-secondary);
}

.meena-disclose {
    flex: none;
    margin: 0.75rem 0 0;
    padding: 0.5rem 0.625rem;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    font-size: 0.75rem;
    line-height: 1.55;
    color: var(--text-secondary);
}

.meena-log {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-right: 0.125rem;
}
.meena-log[hidden] { display: none; }

.meena-msg {
    max-width: 92%;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.meena-msg p { margin: 0; }
.meena-msg-text { white-space: pre-line; }

.meena-msg--you {
    align-self: flex-end;
    background: var(--accent-solid);
    color: var(--on-accent);
    border-bottom-right-radius: 0.25rem;
}

.meena-msg--ai,
.meena-msg--notice {
    align-self: flex-start;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border-bottom-left-radius: 0.25rem;
}

.meena-msg--notice { background: var(--accent-amber-bg); }

.meena-msg-tag {
    display: block;
    margin-bottom: 0.125rem;
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-muted);
}

.meena-msg .meena-msg-hint { margin-top: 0.375rem; font-size: 0.8125rem; color: var(--text-secondary); }
.meena-msg .meena-ref { margin-top: 0.25rem; font-size: 0.6875rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }

.meena-msg--pending { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; color: var(--text-secondary); }

.meena-dots { display: inline-flex; gap: 0.2rem; }
.meena-dots i {
    width: 0.375rem;
    height: 0.375rem;
    border-radius: 999px;
    background: var(--text-muted);
    animation: meena-dot 1s ease-in-out infinite;
}
.meena-dots i:nth-child(2) { animation-delay: 0.15s; }
.meena-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes meena-dot {
    0%, 100% { opacity: 0.3; transform: none; }
    50% { opacity: 1; transform: translateY(-2px); }
}

@media (prefers-reduced-motion: reduce) {
    .meena-dots i { animation: none; opacity: 0.7; }
}

.meena-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem 0.75rem; margin-top: 0.375rem; }

.meena-link-btn,
.meena-line-send {
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
    padding: 0 0.25rem;
    border: 0;
    background: transparent;
    color: var(--link);
    font: inherit;
    font-size: 0.8125rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.meena-link-btn:focus-visible,
.meena-line-send:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

.meena-ask {
    flex: none;
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    margin-top: 0.75rem;
}
.meena-ask[hidden] { display: none; }

.meena-input {
    flex: 1 1 auto;
    min-width: 0;
    min-height: var(--touch-min);
    max-height: 7.5rem;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font: inherit;
    /* 16px: iOS zooms the page into any smaller field. */
    font-size: 1rem;
    line-height: 1.4;
    resize: none;
    field-sizing: content;
}
.meena-input::placeholder { color: var(--text-muted); }
.meena-input:focus { outline: none; border-color: var(--accent-primary); box-shadow: var(--ring); }

.meena-send { flex: none; min-height: var(--touch-min); }
.meena-send:disabled { opacity: 0.55; cursor: default; }

.meena-accuracy {
    flex: none;
    margin: 0.5rem 0 0;
    font-size: 0.6875rem;
    line-height: 1.5;
    color: var(--text-muted);
}

.meena-line { flex: none; }
.meena-panel--ai .meena-line { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border-subtle); }
.meena-line-lead { margin: 0 0 0.5rem; font-size: 0.8125rem; color: var(--text-secondary); }

.meena-cta { width: 100%; margin-top: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; }
.meena-panel--ai .meena-cta { margin-top: 0; }
.meena-cta iconify-icon { display: block; width: 18px; height: 18px; flex: none; }

/* Phones: a bottom sheet the width of the screen. When the on-screen keyboard is up,
   meena-help.js sets --meena-kb (the part of the layout viewport it covers) and
   --meena-vh (what is still visible), so the question box stays above the keyboard. */
@media (max-width: 640px) {
    .meena[open] .meena-fab { visibility: hidden; }

    .meena-panel,
    .meena-panel--ai {
        position: fixed;
        left: 0.5rem;
        right: 0.5rem;
        bottom: calc(var(--meena-kb, 0px) + 0.5rem + env(safe-area-inset-bottom, 0px));
        width: auto;
    }

    .meena-panel--ai {
        max-height: calc(var(--meena-vh, 100vh) - 1rem);
        max-height: calc(var(--meena-vh, 100dvh) - 1rem);
    }
}

/* The dashboard row that leads back to /welcome while setup is unfinished. One row,
   not a card stack: what is left is two steps, and the dashboard behind it is already
   worth reading or the customer would have been redirected instead. */
.welcome-resume {
    display: flex;
    align-items: center;
    gap: 0.875rem;
    padding: 0.875rem 1rem;
    margin-bottom: 1.25rem;
    background: var(--bg-surface);
    border: 1px solid var(--accent-primary);
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: all var(--transition-fast);
}

.welcome-resume:hover { box-shadow: var(--shadow-sm); }

.welcome-resume-icon {
    display: grid;
    place-items: center;
    width: 2.5rem;
    height: 2.5rem;
    flex: none;
    border-radius: var(--radius-sm);
    background: var(--accent-light);
    color: var(--accent-primary);
}

.welcome-resume-text { flex: 1; min-width: 0; }

.welcome-resume-title {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-primary);
}

.welcome-resume-count {
    display: block;
    margin-top: 0.125rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.welcome-resume-cta {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    flex: none;
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent-primary);
}

/* Inline heading and label icons written with the light accent (stroke="#6366f1") follow the theme's
   accent instead; CSS outranks the SVG presentation attribute. */
svg[stroke="#6366f1" i] {
    stroke: var(--accent-primary);
}
