/* ===== Veyari V5 — design tokens ===== */
:root {
    --surface-0: #FAFAFD;
    --surface-1: #FFFFFF;
    --surface-2: #F4F2FB;
    --surface-glass: rgba(255, 255, 255, 0.55);
    --surface-glass-strong: rgba(255, 255, 255, 0.75);
    --accent: #7F77DD;
    --accent-2: #C084FC;
    --accent-3: #4F46E5;
    --ok: #22C55E;
    --bad: #EF4444;
    --warn: #F59E0B;
    --ink-1: #1A1730;
    --ink-2: #5B5675;
    --ink-3: #8E89A8;
    --border: rgba(26, 23, 48, 0.08);
    --border-strong: rgba(26, 23, 48, 0.18);
    --shadow-sm: 0 1px 2px rgba(26, 23, 48, 0.06);
    --shadow-md: 0 8px 24px rgba(26, 23, 48, 0.08);
    --shadow-lg: 0 24px 60px rgba(26, 23, 48, 0.12);
    --shadow-accent: 0 12px 32px rgba(127, 119, 221, 0.25);
    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --radius-full: 9999px;
    --duration: 200ms;
    --easing: cubic-bezier(0.2, 0.8, 0.2, 1);
}

html.dark {
    --surface-0: #0B0A1A;
    --surface-1: #15132B;
    --surface-2: #1C1A38;
    --surface-glass: rgba(28, 24, 56, 0.45);
    --surface-glass-strong: rgba(28, 24, 56, 0.7);
    --accent: #9C95F2;
    --accent-2: #D4B5FF;
    --accent-3: #818CF8;
    --ok: #4ADE80;
    --bad: #F87171;
    --warn: #FBBF24;
    --ink-1: #F2EEFF;
    --ink-2: #A8A0C9;
    --ink-3: #6E6890;
    --border: rgba(242, 238, 255, 0.08);
    --border-strong: rgba(242, 238, 255, 0.18);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.32);
    --shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.42);
    --shadow-accent: 0 12px 32px rgba(127, 119, 221, 0.35);
}

/* ===== Base ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: light; }
html.dark { color-scheme: dark; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    color: var(--ink-1);
    background: var(--surface-0);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.font-mono, .veyari-text {
    font-family: 'JetBrains Mono', 'SF Mono', Menlo, ui-monospace, monospace;
    letter-spacing: -0.01em;
}

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

button { font-family: inherit; cursor: pointer; }

input, textarea, select {
    font-family: inherit;
    color: var(--ink-1);
}

::selection { background: color-mix(in oklab, var(--accent) 35%, transparent); color: var(--ink-1); }

/* ===== Gradient mesh background ===== */
.gradient-mesh {
    position: fixed;
    inset: -200px;
    z-index: -1;
    pointer-events: none;
    filter: blur(100px);
    opacity: 0.55;
    overflow: hidden;
}
.gradient-mesh::before,
.gradient-mesh::after,
.gradient-mesh > span {
    content: '';
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    will-change: transform;
    animation: meshDrift 60s ease-in-out infinite;
}
.gradient-mesh::before {
    top: -10%;
    left: -10%;
    background: radial-gradient(circle at center, var(--accent), transparent 60%);
}
.gradient-mesh::after {
    bottom: -10%;
    right: -10%;
    background: radial-gradient(circle at center, var(--accent-2), transparent 60%);
    animation-delay: -20s;
    animation-direction: reverse;
}
.gradient-mesh > span {
    top: 30%;
    left: 50%;
    background: radial-gradient(circle at center, var(--accent-3), transparent 60%);
    animation-delay: -40s;
}
@keyframes meshDrift {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(120px, -80px) scale(1.15); }
    66% { transform: translate(-80px, 120px) scale(0.9); }
}
@media (prefers-reduced-motion: reduce) {
    .gradient-mesh::before, .gradient-mesh::after, .gradient-mesh > span { animation: none; }
}

/* ===== Glass surface ===== */
.glass {
    background: var(--surface-glass);
    backdrop-filter: blur(20px) saturate(160%);
    -webkit-backdrop-filter: blur(20px) saturate(160%);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
}
.glass-strong {
    background: var(--surface-glass-strong);
    backdrop-filter: blur(28px) saturate(180%);
    -webkit-backdrop-filter: blur(28px) saturate(180%);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
}

/* ===== Typography ===== */
.gradient-text {
    background: linear-gradient(120deg, var(--accent), var(--accent-2));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}
.eyebrow {
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    font-weight: 700;
    color: var(--ink-3);
}
.h-display { font-size: clamp(2rem, 4vw, 3rem); font-weight: 800; line-height: 1.05; letter-spacing: -0.02em; }
.h-section { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid transparent;
    transition: all var(--duration) var(--easing);
    cursor: pointer;
    user-select: none;
    background: transparent;
    color: var(--ink-1);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-3));
    color: white;
    border-color: transparent;
    box-shadow: var(--shadow-accent);
}
.btn-primary:hover { box-shadow: 0 16px 40px rgba(127, 119, 221, 0.4); }

.btn-secondary {
    background: var(--surface-1);
    color: var(--ink-1);
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--surface-2); }

.btn-ghost {
    background: transparent;
    color: var(--ink-2);
}
.btn-ghost:hover { background: var(--surface-2); color: var(--ink-1); }

.btn-icon {
    padding: 0.5rem;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: var(--radius-md);
}

.btn-sm { padding: 0.5rem 0.875rem; font-size: 0.85rem; }
.btn-lg { padding: 1rem 1.75rem; font-size: 1.05rem; }
.btn-block { width: 100%; }

/* ===== Inputs ===== */
.input, .textarea, .select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    color: var(--ink-1);
    transition: border-color var(--duration) var(--easing), box-shadow var(--duration) var(--easing);
    outline: none;
}
.input:focus, .textarea:focus, .select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in oklab, var(--accent) 25%, transparent);
}
.textarea { resize: vertical; min-height: 8rem; }

/* ===== Chips ===== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.75rem;
    border-radius: var(--radius-full);
    background: var(--surface-2);
    color: var(--ink-2);
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid transparent;
    transition: all var(--duration) var(--easing);
    cursor: pointer;
}
.chip:hover { color: var(--ink-1); background: var(--surface-1); border-color: var(--border); }
.chip-active {
    background: color-mix(in oklab, var(--accent) 20%, transparent);
    color: var(--accent);
    border-color: color-mix(in oklab, var(--accent) 35%, transparent);
}

.chip-tense    { background: color-mix(in oklab, #3B82F6 18%, transparent); color: #3B82F6; }
.chip-aspect   { background: color-mix(in oklab, #8B5CF6 18%, transparent); color: #8B5CF6; }
.chip-mood     { background: color-mix(in oklab, #EC4899 18%, transparent); color: #EC4899; }
.chip-particle { background: color-mix(in oklab, var(--ok)  20%, transparent); color: var(--ok); }
.chip-plural   { background: color-mix(in oklab, var(--warn) 18%, transparent); color: var(--warn); }
.chip-derivation,
.chip-nominalizer { background: color-mix(in oklab, var(--accent-2) 22%, transparent); color: var(--accent); }
.chip-size     { background: color-mix(in oklab, #14B8A6 18%, transparent); color: #14B8A6; }
.chip-unknown  { background: color-mix(in oklab, var(--ink-3) 16%, transparent); color: var(--ink-2); }

/* ===== Card ===== */
.card {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform var(--duration) var(--easing), box-shadow var(--duration) var(--easing);
}
.card-hover:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

/* ===== Toast ===== */
#toast-host {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}
.toast {
    min-width: 260px;
    max-width: 360px;
    padding: 0.875rem 1.125rem;
    border-radius: var(--radius-md);
    background: var(--surface-1);
    border: 1px solid var(--border-strong);
    color: var(--ink-1);
    box-shadow: var(--shadow-lg);
    pointer-events: auto;
    transform: translateX(120%);
    opacity: 0;
    transition: transform 300ms var(--easing), opacity 300ms var(--easing);
    font-size: 0.9rem;
    display: flex;
    gap: 0.625rem;
    align-items: flex-start;
}
.toast.show { transform: translateX(0); opacity: 1; }
.toast-icon { flex-shrink: 0; width: 1.25rem; height: 1.25rem; }
.toast-success { border-color: color-mix(in oklab, var(--ok) 35%, transparent); }
.toast-success .toast-icon { color: var(--ok); }
.toast-error   { border-color: color-mix(in oklab, var(--bad) 35%, transparent); }
.toast-error .toast-icon   { color: var(--bad); }
.toast-warn    { border-color: color-mix(in oklab, var(--warn) 35%, transparent); }
.toast-warn .toast-icon    { color: var(--warn); }

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: color-mix(in oklab, var(--surface-0) 75%, transparent);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 200ms var(--easing);
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal-body {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow: auto;
    padding: 1.75rem;
    transform: translateY(20px) scale(0.96);
    transition: transform 250ms var(--easing);
}
.modal-overlay.show .modal-body { transform: translateY(0) scale(1); }

/* ===== Skeleton ===== */
.skeleton {
    background: linear-gradient(90deg, var(--surface-2), var(--surface-1), var(--surface-2));
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}
@keyframes shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (prefers-reduced-motion: reduce) {
    .skeleton { animation: none; }
}

/* ===== Layout ===== */
.app-shell { min-height: 100vh; display: flex; flex-direction: column; }
.app-header {
    position: sticky; top: 0; z-index: 50;
    background: color-mix(in oklab, var(--surface-0) 85%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
}
.container { max-width: 1200px; margin: 0 auto; padding: 0 1.25rem; }
.app-main { flex: 1; padding: 2rem 1.25rem 6rem; }
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 50;
    padding: 0.5rem 0.5rem max(0.5rem, env(safe-area-inset-bottom));
    background: var(--surface-glass-strong);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid var(--border);
}
@media (max-width: 768px) {
    .bottom-nav { display: flex; justify-content: space-around; }
    .top-nav-links { display: none; }
}

/* ===== Header nav ===== */
.nav-link {
    color: var(--ink-2);
    font-weight: 600;
    font-size: 0.95rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    transition: color var(--duration) var(--easing), background var(--duration) var(--easing);
    text-decoration: none;
    position: relative;
}
.nav-link:hover { color: var(--ink-1); text-decoration: none; }
.nav-link.active {
    color: var(--accent);
}
.nav-link.active::after {
    content: '';
    position: absolute;
    left: 0.75rem; right: 0.75rem;
    bottom: -1px;
    height: 2px;
    background: linear-gradient(90deg, var(--accent), var(--accent-2));
    border-radius: var(--radius-full);
}

.bottom-nav .nav-link { font-size: 0.7rem; flex-direction: column; gap: 0.15rem; padding: 0.4rem 0.5rem; }
.bottom-nav .nav-link svg { width: 1.25rem; height: 1.25rem; }
.bottom-nav .nav-link.active::after { display: none; }
.bottom-nav .nav-link.active { background: color-mix(in oklab, var(--accent) 12%, transparent); }

/* ===== Hidden utility ===== */
.hidden { display: none !important; }

/* ===== Focus ring (a11y) ===== */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

/* ===== Streak / XP header pills ===== */
.stat-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-full);
    background: var(--surface-1);
    border: 1px solid var(--border);
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--ink-1);
}
.stat-pill svg { width: 1rem; height: 1rem; }
.stat-pill-flame svg { color: #F97316; }
.stat-pill-xp svg { color: var(--accent); }

/* ===== Misc helpers ===== */
.text-muted { color: var(--ink-2); }
.text-dim { color: var(--ink-3); }
.text-accent { color: var(--accent); }
.text-success { color: var(--ok); }
.text-error { color: var(--bad); }
.text-warn { color: var(--warn); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }
.text-center { text-align: center; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }
.w-full { width: 100%; }
.grid { display: grid; }
.grid-2 { grid-template-columns: 1fr 1fr; }
.grid-auto { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
@media (max-width: 768px) {
    .grid-2 { grid-template-columns: 1fr; }
}
