/* ==========================================================================
   boneCV — Design System v2
   Minimal, neutral, professional. One stylesheet for the whole app.
   Tokens → base → layout (shell) → components → pages → utilities.
   ========================================================================== */

/* ---------- 1. Tokens ---------- */
:root {
    --font: 'Inter', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    --font-serif: 'Source Serif 4', 'Source Serif Pro', Georgia, 'Times New Roman', serif;
    --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;

    --r-sm: 6px;
    --r: 8px;
    --r-lg: 12px;
    --r-xl: 16px;

    --sidebar-w: 252px;
    --topbar-h: 56px;
    --toolbar-h: 60px;

    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-soft: rgba(37, 99, 235, 0.10);
    --accent-ring: rgba(37, 99, 235, 0.35);
    --accent-fg: #ffffff;

    --ease: cubic-bezier(.2, .8, .2, 1);
    --dur: .16s;

    color-scheme: light;
}

html[data-theme="light"], html:not([data-theme]) {
    --bg: #f6f6f7;
    --surface: #ffffff;
    --surface-2: #fafafa;
    --surface-hover: #f3f3f5;
    --surface-active: #ececef;
    --border: #e7e7ea;
    --border-strong: #d6d6db;
    --text: #0b0b0d;
    --text-2: #55555e;
    --text-3: #8b8b94;
    --danger: #dc2626;
    --danger-hover: #b91c1c;
    --danger-soft: #fef2f2;
    --danger-border: #fecaca;
    --success: #15803d;
    --success-soft: #f0fdf4;
    --warning: #b45309;
    --preview-bg: #e9e9ec;
    --overlay: rgba(10, 10, 12, 0.36);
    --shadow-xs: 0 1px 1px rgba(0, 0, 0, .03);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
    --shadow: 0 1px 3px rgba(0, 0, 0, .06), 0 1px 2px rgba(0, 0, 0, .04);
    --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .22), 0 2px 6px rgba(0, 0, 0, .05);
    --paper-shadow: 0 1px 2px rgba(0, 0, 0, .06), 0 8px 30px rgba(0, 0, 0, .08);
    color-scheme: light;
}

html[data-theme="dark"] {
    --bg: #09090b;
    --surface: #111113;
    --surface-2: #141416;
    --surface-hover: #19191c;
    --surface-active: #202024;
    --border: #232327;
    --border-strong: #303036;
    --text: #ededf0;
    --text-2: #a3a3ad;
    --text-3: #6e6e78;
    --danger: #f87171;
    --danger-hover: #ef4444;
    --danger-soft: rgba(248, 113, 113, .08);
    --danger-border: rgba(248, 113, 113, .28);
    --success: #4ade80;
    --success-soft: rgba(74, 222, 128, .08);
    --warning: #fbbf24;
    --preview-bg: #0c0c0e;
    --overlay: rgba(0, 0, 0, 0.6);
    --shadow-xs: none;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4);
    --shadow: 0 1px 3px rgba(0, 0, 0, .5);
    --shadow-lg: 0 20px 50px -12px rgba(0, 0, 0, .7), 0 0 0 1px rgba(255, 255, 255, .04);
    --paper-shadow: 0 0 0 1px rgba(255, 255, 255, .04), 0 12px 40px rgba(0, 0, 0, .6);
    color-scheme: dark;
}

html[data-contrast="high"] {
    --text-2: var(--text);
    --text-3: var(--text-2);
    --border: var(--border-strong);
}
html[data-contrast="high"][data-theme="light"] { --text-2: #2a2a30; --text-3: #4a4a52; --border-strong: #9a9aa3; --border: #b4b4bc; }
html[data-contrast="high"][data-theme="dark"] { --text-2: #d6d6dc; --text-3: #a8a8b2; --border-strong: #55555e; --border: #46464e; }

/* ---------- 2. Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
* { -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 0.875rem;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    font-feature-settings: 'cv11', 'ss01', 'ss03';
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100vh;
    min-height: 100dvh;
}
h1, h2, h3, h4, p { margin: 0; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; }
img, svg { display: block; }
[hidden] { display: none !important; }
::selection { background: var(--accent-soft); }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: var(--r-sm); }

.ic { width: 1.125em; height: 1.125em; flex-shrink: 0; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
.ic-sm { width: 14px; height: 14px; }
.ic-md { width: 16px; height: 16px; }
.ic-lg { width: 20px; height: 20px; }

.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; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--text-2); }
.subtle { color: var(--text-3); }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 3. Shell: sidebar / topbar / main ---------- */
.sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 60;
    width: var(--sidebar-w);
    display: flex; flex-direction: column;
    background: var(--surface);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .28s var(--ease);
    padding-bottom: env(safe-area-inset-bottom);
}
.sidebar.open { transform: none; box-shadow: var(--shadow-lg); }
.sb-backdrop {
    position: fixed; inset: 0; z-index: 55; background: var(--overlay);
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.sb-backdrop.show { opacity: 1; pointer-events: auto; }
body.menu-open { overflow: hidden; }

.sb-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 16px 16px 12px; padding-top: calc(16px + env(safe-area-inset-top)); }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 650; font-size: 15px; letter-spacing: -0.01em; }
.brand-mark { width: 28px; height: 28px; border-radius: 7px; flex-shrink: 0; }
.brand small { font-weight: 500; color: var(--text-3); font-size: 11px; margin-left: 2px; letter-spacing: 0; }
.sb-close { display: inline-flex; }

.sb-cta { padding: 4px 12px 8px; }
.sb-nav { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.sb-group { padding: 14px 10px 6px; font-size: 11px; font-weight: 600; color: var(--text-3); letter-spacing: .02em; }
.nav-link {
    display: flex; align-items: center; gap: 10px;
    height: 34px; padding: 0 10px; border-radius: var(--r);
    color: var(--text-2); font-weight: 500; font-size: 13.5px;
    transition: background var(--dur), color var(--dur);
    width: 100%; text-align: left;
}
.nav-link .ic { width: 17px; height: 17px; color: var(--text-3); transition: color var(--dur); }
.nav-link:hover { background: var(--surface-hover); color: var(--text); }
.nav-link:hover .ic { color: var(--text-2); }
.nav-link.is-active { background: var(--surface-active); color: var(--text); font-weight: 600; }
.nav-link.is-active .ic { color: var(--accent); }
.nav-link .count { margin-left: auto; font-size: 11.5px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.sb-foot { border-top: 1px solid var(--border); padding: 10px 8px 12px; }
.sb-profile { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--r); transition: background var(--dur); }
.sb-profile:hover { background: var(--surface-hover); }
.avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0; overflow: hidden;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--surface-active); color: var(--text-2); font-weight: 600; font-size: 13px;
    border: 1px solid var(--border);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.sb-profile .p-name { font-weight: 600; font-size: 13px; line-height: 1.25; }
.sb-profile .p-sub { font-size: 12px; color: var(--text-3); line-height: 1.25; }
.sb-meta { display: flex; align-items: center; gap: 8px; padding: 8px 8px 0; }
.sb-version { font-size: 11px; color: var(--text-3); margin-left: auto; font-variant-numeric: tabular-nums; }

.topbar {
    position: sticky; top: 0; z-index: 40;
    height: calc(var(--topbar-h) + env(safe-area-inset-top));
    padding: env(safe-area-inset-top) 12px 0;
    display: flex; align-items: center; gap: 8px;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px); backdrop-filter: saturate(1.4) blur(12px);
    border-bottom: 1px solid var(--border);
}
.topbar .brand { margin-right: auto; }

.main { min-height: 100vh; min-height: 100dvh; }

@media (min-width: 1024px) {
    .sidebar { transform: none; box-shadow: none !important; }
    .sb-backdrop, .topbar, .sb-close { display: none !important; }
    .main { margin-left: var(--sidebar-w); }
}

/* ---------- 4. Page scaffolding ---------- */
.page { max-width: 1120px; margin: 0 auto; padding: 28px 20px 64px; }
.page-narrow { max-width: 880px; }
@media (min-width: 768px) { .page { padding: 40px 40px 80px; } }
.page-header { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 28px; }
.page-title { font-size: 24px; font-weight: 650; letter-spacing: -0.022em; line-height: 1.2; }
@media (min-width: 768px) { .page-title { font-size: 28px; } }
.page-sub { color: var(--text-2); font-size: 14px; margin-top: 6px; max-width: 60ch; }
.eyebrow { font-size: 12px; font-weight: 600; color: var(--text-3); margin-bottom: 8px; letter-spacing: .01em; }

.section { margin-top: 36px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-title { font-size: 14px; font-weight: 600; letter-spacing: -0.005em; }
.section-link { font-size: 13px; color: var(--text-2); display: inline-flex; align-items: center; gap: 4px; font-weight: 500; }
.section-link:hover { color: var(--text); }

/* ---------- 5. Components ---------- */
/* Buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 14px; border-radius: var(--r);
    font-size: 13.5px; font-weight: 550; line-height: 1; white-space: nowrap;
    border: 1px solid transparent; user-select: none;
    transition: background var(--dur), border-color var(--dur), color var(--dur), box-shadow var(--dur), transform .08s;
}
.btn:active { transform: translateY(0.5px); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn .ic { width: 16px; height: 16px; }
.btn-primary { background: var(--accent); color: var(--accent-fg); box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(255,255,255,.08); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-danger-outline { color: var(--danger); border-color: var(--danger-border); background: transparent; }
.btn-danger-outline:hover { background: var(--danger-soft); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: var(--r-sm); }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn-icon.btn-sm { width: 30px; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > .lbl { font-size: 12.5px; font-weight: 550; color: var(--text-2); }
.field > .hint { font-size: 12px; color: var(--text-3); }
.input, .select, .textarea {
    width: 100%; min-width: 0;
    height: 36px; padding: 0 11px;
    font-size: 14px; color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--r);
    box-shadow: var(--shadow-xs);
    transition: border-color var(--dur), box-shadow var(--dur);
    -webkit-appearance: none; appearance: none;
}
.textarea { height: auto; min-height: 84px; padding: 9px 11px; line-height: 1.55; resize: vertical; }
.select { padding-right: 32px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238b8b94' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; cursor: pointer; }
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: color-mix(in srgb, var(--border-strong) 60%, var(--text-3)); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.input-icon { position: relative; }
.input-icon > .ic { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); width: 16px; height: 16px; pointer-events: none; }
.input-icon > .input { padding-left: 34px; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 12px; }
@media (min-width: 480px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; }

input[type="range"] { -webkit-appearance: none; appearance: none; height: 4px; border-radius: 4px; background: var(--border-strong); outline: none; accent-color: var(--accent); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 16px; height: 16px; border-radius: 50%; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: var(--shadow); cursor: pointer; }

/* Segmented control */
.seg { display: inline-flex; padding: 3px; gap: 2px; background: var(--surface-hover); border: 1px solid var(--border); border-radius: var(--r); max-width: 100%; overflow-x: auto; }
.seg button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 28px; padding: 0 12px; border-radius: 6px; font-size: 13px; font-weight: 550;
    color: var(--text-2); white-space: nowrap; transition: background var(--dur), color var(--dur), box-shadow var(--dur);
}
.seg button .ic { width: 15px; height: 15px; }
.seg button:hover { color: var(--text); }
.seg button.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
html[data-theme="dark"] .seg button.is-on { background: var(--surface-active); }
.seg-block { display: flex; width: 100%; }
.seg-block button { flex: 1; }

/* Option cards (template/type pickers) */
.opt-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.opt-list { display: grid; gap: 6px; }
.opt {
    display: flex; align-items: center; gap: 10px; text-align: left;
    padding: 10px 12px; border-radius: var(--r);
    background: var(--surface); border: 1px solid var(--border-strong);
    font-size: 13px; font-weight: 550; color: var(--text-2);
    transition: border-color var(--dur), background var(--dur), color var(--dur), box-shadow var(--dur);
}
.opt-grid .opt { justify-content: center; }
.opt:hover { color: var(--text); background: var(--surface-hover); }
.opt.active { border-color: var(--accent); color: var(--text); box-shadow: 0 0 0 1px var(--accent) inset; background: var(--accent-soft); }
.opt .dot { width: 8px; height: 8px; border-radius: 50%; border: 1.5px solid var(--border-strong); flex-shrink: 0; }
.opt.active .dot { border-color: var(--accent); background: var(--accent); box-shadow: 0 0 0 2px var(--surface) inset; }

/* Swatches */
.swatches { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.swatch {
    width: 24px; height: 24px; border-radius: 50%; cursor: pointer; position: relative;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,.12);
    transition: transform var(--dur);
}
.swatch:hover { transform: scale(1.08); }
.swatch.is-on::after, .swatch.active::after { content: ''; position: absolute; inset: -4px; border-radius: 50%; border: 2px solid var(--text); }

/* Switch */
.switch { position: relative; display: inline-block; width: 36px; height: 20px; flex-shrink: 0; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; z-index: 1; }
.switch .track { position: absolute; inset: 0; border-radius: 999px; background: var(--border-strong); transition: background var(--dur); }
.switch .thumb { position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .2s var(--ease); }
.switch input:checked ~ .track { background: var(--accent); }
.switch input:checked ~ .thumb { transform: translateX(16px); }
.switch input:focus-visible ~ .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Cards / panels */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.card-title { font-size: 13.5px; font-weight: 600; }

.badge { display: inline-flex; align-items: center; gap: 5px; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 11.5px; font-weight: 550; color: var(--text-2); background: var(--surface-hover); border: 1px solid var(--border); white-space: nowrap; }
.badge .ic { width: 12px; height: 12px; }
.kbd { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 4px; font-size: 11px; font-family: var(--font); color: var(--text-3); border: 1px solid var(--border-strong); background: var(--surface-2); }

/* Type marks (document type icon chip) */
.type-ic { width: 32px; height: 32px; border-radius: var(--r); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--surface-hover); border: 1px solid var(--border); color: var(--text-2); }
.type-ic .ic { width: 16px; height: 16px; }

/* Lists / tables */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); overflow: hidden; }
.list-row { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--border); transition: background var(--dur); }
.list-row:first-child { border-top: 0; }
a.list-row:hover, .list-row.clickable:hover { background: var(--surface-2); cursor: pointer; }
.list-row .t { font-weight: 550; font-size: 13.5px; }
.list-row .s { font-size: 12.5px; color: var(--text-3); }

.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; font-weight: 550; color: var(--text-3); padding: 10px 16px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background var(--dur); }
.table tbody tr:hover { background: var(--surface-2); cursor: pointer; }
.table .actions { display: flex; justify-content: flex-end; gap: 2px; }

/* Empty state */
.empty { text-align: center; padding: 48px 24px; }
.empty .type-ic { width: 44px; height: 44px; border-radius: var(--r-lg); margin: 0 auto 14px; }
.empty .type-ic .ic { width: 20px; height: 20px; }
.empty h3 { font-size: 15px; font-weight: 600; }
.empty p { color: var(--text-2); font-size: 13.5px; margin: 6px auto 0; max-width: 42ch; }
.empty .actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

/* Callout */
.callout { display: flex; gap: 12px; padding: 14px 16px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface-2); font-size: 13px; color: var(--text-2); }
.callout .ic { color: var(--text-3); width: 17px; height: 17px; margin-top: 1px; }
.callout b { color: var(--text); font-weight: 600; }

/* Divider */
.hr { height: 1px; background: var(--border); border: 0; margin: 0; }

/* ---------- 6. Overlays: dialog, sheet, toast, help, banners ---------- */
.overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; background: var(--overlay); opacity: 0; transition: opacity .18s; }
.overlay.open { opacity: 1; }
.dialog {
    width: min(440px, 100%); background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
    transform: translateY(6px) scale(.985); transition: transform .22s var(--ease);
}
.overlay.open .dialog { transform: none; }
.dialog-body { padding: 22px 22px 18px; }
.dialog-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; }
.dialog-msg { color: var(--text-2); font-size: 13.5px; margin-top: 6px; line-height: 1.55; }
.dialog-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 22px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--r-xl) var(--r-xl); }

.sheet { width: min(520px, 100%); }
.sheet .dialog-body { padding: 18px; }
.sheet-opt { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: var(--r-lg); border: 1px solid var(--border); margin-top: 8px; transition: background var(--dur), border-color var(--dur); }
.sheet-opt:hover, .sheet-opt:focus-visible { background: var(--surface-2); border-color: var(--border-strong); }
.sheet-opt .type-ic { width: 40px; height: 40px; }
.sheet-opt .t { font-weight: 600; font-size: 14px; }
.sheet-opt .s { font-size: 12.5px; color: var(--text-3); }
.sheet-opt > .ic { margin-left: auto; color: var(--text-3); }
@media (max-width: 640px) {
    .overlay.is-sheet { align-items: flex-end; padding: 0; }
    .overlay.is-sheet .dialog { border-radius: var(--r-xl) var(--r-xl) 0 0; transform: translateY(100%); padding-bottom: env(safe-area-inset-bottom); }
    .overlay.is-sheet.open .dialog { transform: none; }
}

.toast {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 200;
    display: flex; align-items: center; gap: 10px;
    max-width: min(420px, calc(100vw - 32px));
    padding: 10px 14px; border-radius: var(--r-lg);
    background: var(--text); color: var(--bg);
    font-size: 13.5px; font-weight: 500; box-shadow: var(--shadow-lg);
    transform: translate(-50%, 12px); opacity: 0; transition: opacity .2s, transform .25s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast .ic { width: 16px; height: 16px; }
.toast.success .ic { color: #4ade80; }
.toast.error .ic { color: #f87171; }
html[data-theme="dark"] .toast.success .ic { color: var(--success); filter: saturate(1.2) brightness(.7); }
html[data-theme="dark"] .toast.error .ic { color: #dc2626; }

.banner {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 150;
    display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px);
    padding: 10px 10px 10px 14px; border-radius: var(--r-lg);
    background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow-lg);
    transform: translate(-50%, 12px); opacity: 0; transition: opacity .2s, transform .25s var(--ease);
}
.banner.show { opacity: 1; transform: translate(-50%, 0); }
.banner .b-t { font-size: 13.5px; font-weight: 600; }
.banner .b-s { font-size: 12px; color: var(--text-3); }
@media (min-width: 1024px) { .banner, .toast { left: calc(50% + var(--sidebar-w) / 2); } }

/* Help drawer */
.drawer-wrap { position: fixed; inset: 0; z-index: 90; pointer-events: none; }
.drawer-wrap .drawer-back { position: absolute; inset: 0; background: var(--overlay); opacity: 0; transition: opacity .2s; }
.drawer {
    position: absolute; top: 0; right: 0; height: 100%; width: min(440px, 100%);
    display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--border);
    box-shadow: var(--shadow-lg); transform: translateX(100%); transition: transform .3s var(--ease); pointer-events: auto;
}
.drawer-wrap.open { pointer-events: auto; }
.drawer-wrap.open .drawer-back { opacity: 1; }
.drawer-wrap.open .drawer { transform: none; }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 14px 16px; padding-top: calc(14px + env(safe-area-inset-top)); border-bottom: 1px solid var(--border); }
.drawer-head .t { font-weight: 600; font-size: 15px; flex: 1; }
.drawer-tabs { padding: 12px 16px 0; }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px; }
.drawer-foot { display: flex; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }

.mn-lead { color: var(--text-2); font-size: 13px; margin-bottom: 14px; }
.mn-toc { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.mn-sec { padding: 18px 0; border-top: 1px solid var(--border); scroll-margin-top: 8px; }
.mn-sec:first-of-type { border-top: 0; }
.mn-h { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.mn-h .type-ic { width: 28px; height: 28px; }
.mn-h .t { font-weight: 600; font-size: 14px; }
.mn-intro { color: var(--text-2); font-size: 13px; margin: 0 0 10px 38px; }
.mn-steps { list-style: none; counter-reset: s; margin: 0 0 0 38px; padding: 0; display: grid; gap: 8px; }
.mn-steps li { counter-increment: s; position: relative; padding-left: 26px; font-size: 13px; line-height: 1.55; }
.mn-steps li::before { content: counter(s); position: absolute; left: 0; top: 1px; width: 18px; height: 18px; border-radius: 50%; border: 1px solid var(--border-strong); color: var(--text-2); font-size: 11px; font-weight: 600; display: flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.mn-tip { margin: 12px 0 0 38px; }
@media (max-width: 640px) { .mn-intro, .mn-steps, .mn-tip { margin-left: 0; } }

.chat { display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 86%; padding: 9px 12px; border-radius: var(--r-lg); font-size: 13.5px; line-height: 1.5; }
.msg.bot { align-self: flex-start; background: var(--surface-hover); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.msg.me { align-self: flex-end; background: var(--accent); color: var(--accent-fg); border-bottom-right-radius: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); font-size: 12.5px; font-weight: 500; color: var(--text-2); transition: background var(--dur), color var(--dur); }
.chip:hover { background: var(--surface-hover); color: var(--text); }
.chip .ic { width: 13px; height: 13px; }

/* ---------- 7. Dashboard ---------- */
.create-grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 720px) { .create-grid { grid-template-columns: repeat(3, 1fr); } }
.create-card {
    display: flex; flex-direction: column; gap: 14px; padding: 18px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--shadow-xs);
    transition: border-color var(--dur), box-shadow var(--dur), transform var(--dur);
}
.create-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }
.create-card .cc-top { display: flex; align-items: center; justify-content: space-between; }
.create-card .cc-arrow { color: var(--text-3); transition: transform var(--dur), color var(--dur); }
.create-card:hover .cc-arrow { transform: translateX(2px); color: var(--text); }
.create-card h3 { font-size: 14.5px; font-weight: 600; }
.create-card p { font-size: 13px; color: var(--text-2); margin-top: 3px; }
.create-card .type-ic { width: 36px; height: 36px; }

.dash-grid { display: grid; gap: 24px; grid-template-columns: 1fr; }
@media (min-width: 1024px) { .dash-grid { grid-template-columns: minmax(0, 1fr) 320px; } }

.stats { display: grid; grid-template-columns: repeat(2, 1fr); }
.stat { padding: 16px; border-top: 1px solid var(--border); }
.stat:nth-child(odd) { border-right: 1px solid var(--border); }
.stat:nth-child(-n+2) { border-top: 0; }
.stat .v { font-size: 22px; font-weight: 600; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 12px; color: var(--text-3); margin-top: 2px; }

.principles { display: grid; grid-template-columns: 1fr; border: 1px solid var(--border); border-radius: var(--r-lg); background: var(--surface); overflow: hidden; }
@media (min-width: 720px) { .principles { grid-template-columns: repeat(3, 1fr); } }
.principle { padding: 18px; display: flex; gap: 12px; border-top: 1px solid var(--border); }
.principle:first-child { border-top: 0; }
@media (min-width: 720px) { .principle { border-top: 0; border-left: 1px solid var(--border); } .principle:first-child { border-left: 0; } }
.principle .ic { color: var(--text-2); width: 18px; height: 18px; margin-top: 1px; }
.principle .t { font-weight: 600; font-size: 13.5px; }
.principle .d { color: var(--text-2); font-size: 13px; margin-top: 2px; }

/* ---------- 8. Settings ---------- */
.set-section { display: grid; grid-template-columns: 1fr; gap: 16px; padding: 28px 0; border-top: 1px solid var(--border); }
.set-section:first-of-type { border-top: 0; padding-top: 4px; }
@media (min-width: 860px) { .set-section { grid-template-columns: 240px minmax(0, 1fr); gap: 40px; } }
.set-section > header h2 { font-size: 14px; font-weight: 600; }
.set-section > header p { font-size: 13px; color: var(--text-2); margin-top: 4px; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 14px 16px; border-top: 1px solid var(--border); }
.set-row:first-child { border-top: 0; }
.set-row .t { font-weight: 550; font-size: 13.5px; }
.set-row .d { font-size: 12.5px; color: var(--text-3); margin-top: 1px; }
.set-row.stack-sm { flex-wrap: wrap; }
.photo-pick {
    width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0; overflow: hidden; position: relative; cursor: pointer;
    display: flex; align-items: center; justify-content: center; color: var(--text-3);
    background: var(--surface-hover); border: 1px dashed var(--border-strong); transition: border-color var(--dur);
}
.photo-pick:hover { border-color: var(--text-3); }
.photo-pick img { width: 100%; height: 100%; object-fit: cover; }
.photo-pick input { display: none; }
.danger-card { border-color: var(--danger-border); }
.danger-card .set-row .t { color: var(--text); }

/* ---------- 9. Editor layout (CV / Kontratë / Kërkesë) ---------- */
.editor-shell { display: flex; flex-direction: column; min-height: calc(100dvh - var(--topbar-h) - env(safe-area-inset-top)); }
@media (min-width: 1024px) { .editor-shell { height: 100vh; height: 100dvh; min-height: 0; } }

.toolbar {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    min-height: var(--toolbar-h); padding: 10px 16px;
    background: var(--surface); border-bottom: 1px solid var(--border);
}
.toolbar .doc-meta { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.toolbar .doc-title { font-weight: 600; font-size: 14.5px; letter-spacing: -0.01em; line-height: 1.25; }
.toolbar .doc-status { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; line-height: 1.25; }
.toolbar .doc-status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); }
.toolbar .doc-status.saved .dot { background: var(--success); }
.toolbar .doc-status.dirty .dot { background: var(--warning); }
.toolbar .tb-actions { display: flex; align-items: center; gap: 6px; }
.toolbar .view-tabs { display: none; }
@media (max-width: 1023px) {
    .toolbar { position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 30; padding: 8px 12px; }
    .toolbar .view-tabs { display: flex; order: 3; width: 100%; }
    .toolbar .btn-label { display: none; }
    .toolbar .btn:not(.btn-icon) { padding: 0 11px; }
}

.panes { flex: 1; display: grid; grid-template-columns: 1fr; min-height: 0; }
@media (min-width: 1024px) { .panes { grid-template-columns: 440px minmax(0, 1fr); } }
@media (min-width: 1440px) { .panes { grid-template-columns: 480px minmax(0, 1fr); } }

.form-pane { background: var(--bg); overflow-y: auto; padding: 16px 16px 40px; border-right: 1px solid var(--border); }
.preview-pane { background: var(--preview-bg); overflow: auto; padding: 24px 16px 48px; }
@media (min-width: 1024px) { .form-pane { padding: 20px 20px 48px; } .preview-pane { padding: 32px; } }
@media (max-width: 1023px) {
    .editor-shell[data-view="form"] .preview-pane { display: none; }
    .editor-shell[data-view="preview"] .form-pane { display: none; }
    .form-pane { border-right: 0; }
}

.fsec { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); margin-bottom: 12px; box-shadow: var(--shadow-xs); }
.fsec-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.fsec-head .ic { color: var(--text-3); width: 16px; height: 16px; }
.fsec-head h2 { font-size: 13.5px; font-weight: 600; flex: 1; }
.fsec-head .n { font-size: 12px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.fsec-body { padding: 14px; display: grid; gap: 12px; }
.fsec-sub { font-size: 12px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .06em; margin-top: 4px; }

.repeat { display: grid; gap: 10px; }
.repeat-item { border: 1px solid var(--border); border-radius: var(--r); padding: 12px; display: grid; gap: 10px; background: var(--surface-2); }
.repeat-item-head { display: flex; align-items: center; gap: 8px; margin: -2px 0 0; }
.repeat-item-head .idx { font-size: 12px; font-weight: 600; color: var(--text-3); font-variant-numeric: tabular-nums; flex: 1; }
.repeat-empty { font-size: 13px; color: var(--text-3); padding: 2px 0; }
.icon-btn { width: 28px; height: 28px; border-radius: var(--r-sm); display: inline-flex; align-items: center; justify-content: center; color: var(--text-3); transition: background var(--dur), color var(--dur); }
.icon-btn:hover { background: var(--surface-active); color: var(--text); }
.icon-btn.danger:hover { background: var(--danger-soft); color: var(--danger); }
.icon-btn:disabled { opacity: .35; pointer-events: none; }
.icon-btn .ic { width: 15px; height: 15px; }

.range-row { display: flex; align-items: center; gap: 12px; }
.range-row input[type="range"] { flex: 1; }
.range-row .v { width: 40px; text-align: right; font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; }

.photo-row { display: flex; align-items: center; gap: 14px; }
.photo-row .photo-pick { width: 72px; height: 72px; border-radius: var(--r-lg); }

/* Paper stage */
.paper-frame { margin: 0 auto; position: relative; }
.paper-frame > #paper { transform-origin: top left; position: absolute; top: 0; left: 0; }

/* ---------- 10. Text scale & motion preferences ---------- */
html[data-scale="sm"] body { zoom: .94; }
html[data-scale="lg"] body { zoom: 1.07; }
html[data-scale="xl"] body { zoom: 1.15; }
@media print { body { zoom: 1 !important; } }

html[data-motion="reduce"] *, html[data-motion="reduce"] *::before, html[data-motion="reduce"] *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; scroll-behavior: auto !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .001ms !important; animation-duration: .001ms !important; } }

/* ---------- 11. Print: hide application chrome ---------- */
@media print {
    .sidebar, .sb-backdrop, .topbar, .toolbar, .form-pane, .toast, .banner, .overlay, .drawer-wrap, .no-print { display: none !important; }
    .main { margin: 0 !important; }
}
