/* ═══════════════════════════════════════════════════
   TreeVerse v5 — Premium Green Design System
   ═══════════════════════════════════════════════════ */

/* ── CSS Variables: Dark Theme (default) ── */
:root {
    --bg: #060f08;
    --bg-2: #0a1a0d;
    --surface: rgba(255,255,255,.045);
    --surface-hover: rgba(255,255,255,.08);
    --surface-active: rgba(74,222,128,.10);
    --border: rgba(255,255,255,.07);
    --border-hover: rgba(255,255,255,.16);
    --border-accent: rgba(74,222,128,.28);
    --text: #f0fdf4;
    --text-2: rgba(240,253,244,.60);
    --text-3: rgba(240,253,244,.32);
    --text-4: rgba(240,253,244,.18);
    --accent: #4ade80;
    --accent-2: #22c55e;
    --accent-dim: #16a34a;
    --accent-glow: rgba(74,222,128,.13);
    --accent-glow-strong: rgba(74,222,128,.28);
    --accent-glow-xl: rgba(74,222,128,.06);
    --danger: #f87171;
    --danger-glow: rgba(248,113,113,.15);
    --radius: 14px;
    --radius-sm: 10px;
    --radius-xs: 8px;
    --radius-full: 100px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,.3);
    --shadow-md: 0 8px 32px rgba(0,0,0,.4);
    --shadow-lg: 0 20px 60px rgba(0,0,0,.5);
    --transition: .2s cubic-bezier(.4,0,.2,1);
    --transition-slow: .35s cubic-bezier(.4,0,.2,1);
    --font-body: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
    --font-display: 'Space Grotesk', var(--font-body);
}

/* ── Light Theme ── */
[data-theme="light"] {
    --bg: #f0fdf4;
    --bg-2: #dcfce7;
    --surface: rgba(0,0,0,.05);
    --surface-hover: rgba(0,0,0,.085);
    --surface-active: rgba(22,163,74,.10);
    --border: rgba(0,0,0,.10);
    --border-hover: rgba(0,0,0,.20);
    --border-accent: rgba(22,163,74,.35);
    --text: #052e0f;
    --text-2: rgba(5,46,15,.62);
    --text-3: rgba(5,46,15,.38);
    --text-4: rgba(5,46,15,.20);
    --accent: #16a34a;
    --accent-2: #15803d;
    --accent-dim: #14532d;
    --accent-glow: rgba(22,163,74,.12);
    --accent-glow-strong: rgba(22,163,74,.25);
    --accent-glow-xl: rgba(22,163,74,.06);
    --shadow-sm: 0 2px 8px rgba(0,0,0,.08);
    --shadow-md: 0 8px 32px rgba(0,0,0,.12);
    --shadow-lg: 0 20px 60px rgba(0,0,0,.16);
}

/* ── Reset ── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

body {
    font-family: var(--font-body);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background var(--transition-slow), color var(--transition-slow);
}

/* ── Ambient Background ── */
.ambient {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    overflow: hidden;
}
.orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(130px);
    opacity: .28;
    transition: opacity var(--transition-slow);
}
[data-theme="light"] .orb { opacity: .15; }
.orb-1 {
    width: 700px; height: 700px;
    background: radial-gradient(circle, #166534 0%, transparent 68%);
    top: -18%; left: -12%;
    animation: drift 28s ease-in-out infinite;
}
.orb-2 {
    width: 550px; height: 550px;
    background: radial-gradient(circle, #065f46 0%, transparent 68%);
    bottom: -22%; right: -12%;
    animation: drift 34s ease-in-out infinite reverse;
}
.orb-3 {
    width: 420px; height: 420px;
    background: radial-gradient(circle, #14532d 0%, transparent 68%);
    top: 45%; left: 52%;
    animation: drift 22s ease-in-out infinite 6s;
}
@keyframes drift {
    0%,100% { transform: translate(0,0) scale(1); }
    33% { transform: translate(48px,-36px) scale(1.06); }
    66% { transform: translate(-24px,24px) scale(.94); }
}

.noise {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 0;
    opacity: .022;
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
    background-repeat: repeat;
    background-size: 200px;
}

/* ── Top Bar ── */
.topbar {
    position: relative;
    z-index: 20;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    padding: 18px 32px;
    max-width: 960px;
    margin: 0 auto;
}
.topbar-left { display: flex; align-items: center; }
.topbar-center { display: flex; justify-content: center; }
.topbar-right { display: flex; align-items: center; gap: 10px; justify-content: flex-end; }

.brand {
    font-family: var(--font-display);
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -.5px;
    background: linear-gradient(135deg, var(--accent) 0%, #86efac 60%, #bbf7d0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-decoration: none;
    user-select: none;
}

/* Clock */
.clock {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-3);
    font-variant-numeric: tabular-nums;
    transition: color var(--transition);
}
.clock:hover { color: var(--text-2); }
#clock-time { font-weight: 600; color: var(--text-2); font-size: 14px; }
.clock-sep { opacity: .4; }

/* Icon button */
.icon-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    border-radius: var(--radius-xs);
    background: var(--surface);
    border: 1px solid var(--border);
    color: var(--text-3);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text); border-color: var(--border-hover); }

/* Theme Toggle */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
[data-theme="light"] .theme-toggle .icon-sun { display: block; }
[data-theme="light"] .theme-toggle .icon-moon { display: none; }

/* Language Switch */
.lang-switch {
    display: flex;
    gap: 2px;
    background: var(--surface);
    padding: 3px;
    border-radius: var(--radius-xs);
    border: 1px solid var(--border);
}
.lang-btn {
    padding: 5px 12px;
    background: transparent;
    border: none;
    color: var(--text-3);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: var(--transition);
    font-family: var(--font-body);
}
.lang-btn.active { background: var(--surface-active); color: var(--text); }
.lang-btn:hover:not(.active) { color: var(--text-2); }

/* ── Hero ── */
.hero {
    position: relative;
    z-index: 1;
    max-width: 720px;
    margin: 0 auto;
    padding: 52px 24px 60px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.title {
    font-family: var(--font-display);
    font-size: clamp(38px, 6.5vw, 60px);
    font-weight: 700;
    letter-spacing: -1.8px;
    line-height: 1.08;
    margin-bottom: 14px;
}
.title-accent {
    background: linear-gradient(135deg, var(--accent) 0%, #86efac 50%, #bbf7d0 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.subtitle {
    font-size: 16px;
    color: var(--text-2);
    margin-bottom: 10px;
    font-weight: 400;
}
.daily-quote {
    font-size: 12px;
    color: var(--text-3);
    font-style: italic;
    margin-bottom: 44px;
    max-width: 400px;
    line-height: 1.6;
    transition: opacity var(--transition);
}
.daily-quote::before { content: '"'; opacity: .5; }
.daily-quote::after  { content: '"'; opacity: .5; }

/* ── Search Bar ── */
.search-wrap { width: 100%; margin-bottom: 32px; position: relative; }

.search-bar { width: 100%; }

.search-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    padding: 6px 6px 6px 18px;
    transition: var(--transition);
    backdrop-filter: blur(24px);
    position: relative;
}
.search-inner:focus-within {
    border-color: var(--border-accent);
    box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-md);
    background: var(--surface-hover);
}
.search-inner.search-submitting {
    animation: submit-pulse .4s ease;
}
@keyframes submit-pulse {
    0%   { box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-md); }
    50%  { box-shadow: 0 0 0 10px var(--accent-glow-strong), var(--shadow-lg); }
    100% { box-shadow: 0 0 0 4px var(--accent-glow), var(--shadow-md); }
}

.search-icon { color: var(--text-3); flex-shrink: 0; transition: var(--transition); }
.search-inner:focus-within .search-icon { color: var(--accent); }

.search-input {
    flex: 1;
    background: transparent;
    border: none;
    font-size: 16px;
    color: var(--text);
    outline: none;
    padding: 12px 0;
    font-family: var(--font-body);
    min-width: 0;
}
.search-input::placeholder { color: var(--text-3); }

.kbd-hint {
    padding: 4px 8px;
    font-size: 11px;
    font-family: var(--font-body);
    color: var(--text-3);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    line-height: 1;
    flex-shrink: 0;
    transition: var(--transition);
}
.search-inner:focus-within .kbd-hint { opacity: 0; pointer-events: none; width: 0; padding: 0; overflow: hidden; }

/* Clear button */
.search-clear {
    display: none;
    align-items: center;
    justify-content: center;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--surface);
    border: none;
    color: var(--text-3);
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
}
.search-clear:hover { background: var(--surface-hover); color: var(--text-2); }
.search-input:not(:placeholder-shown) ~ .search-clear { display: flex; }

/* Go button */
.search-go {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px; height: 44px;
    border-radius: var(--radius-sm);
    background: linear-gradient(145deg, var(--accent-2), var(--accent));
    border: none;
    color: #052e0f;
    cursor: pointer;
    flex-shrink: 0;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}
.search-go::before {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(145deg, rgba(255,255,255,.2), transparent);
    opacity: 0;
    transition: var(--transition);
}
.search-go:hover { transform: scale(1.06); box-shadow: 0 0 28px var(--accent-glow-strong); }
.search-go:hover::before { opacity: 1; }
.search-go:active { transform: scale(.96); }

/* ── Dropdown (Suggestions + History) ── */
.search-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    left: 0; right: 0;
    background: var(--bg-2);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    z-index: 100;
    overflow: hidden;
    animation: dropdown-in .18s cubic-bezier(.4,0,.2,1);
    backdrop-filter: blur(24px);
}
@keyframes dropdown-in {
    from { opacity: 0; transform: translateY(-8px); }
    to   { opacity: 1; transform: translateY(0); }
}

.dropdown-section { padding: 8px 0; }
.dropdown-section + .dropdown-section { border-top: 1px solid var(--border); }

.dropdown-label {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .06em;
}
.dropdown-label svg { flex-shrink: 0; opacity: .7; }
.dropdown-label span { flex: 1; }

.clear-history-btn {
    background: none;
    border: none;
    font-size: 11px;
    color: var(--text-3);
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    transition: var(--transition);
    font-family: var(--font-body);
}
.clear-history-btn:hover { color: var(--danger); background: var(--danger-glow); }

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 16px;
    background: none;
    border: none;
    color: var(--text-2);
    font-size: 14px;
    text-align: left;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
    position: relative;
}
.dropdown-item:hover { background: var(--surface-hover); color: var(--text); }
.dropdown-item.active { background: var(--accent-glow); color: var(--accent); }
.dropdown-item svg { flex-shrink: 0; color: var(--text-3); }
.dropdown-item .item-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dropdown-item .del-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 20px; height: 20px;
    border-radius: 50%;
    background: var(--surface);
    border: none;
    color: var(--text-3);
    cursor: pointer;
    flex-shrink: 0;
    font-size: 12px;
    transition: var(--transition);
}
.dropdown-item:hover .del-btn { display: flex; }
.dropdown-item .del-btn:hover { background: var(--danger-glow); color: var(--danger); }

/* ── Search Meta ── */
.search-meta {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 7px;
    margin-top: 10px;
    font-size: 12px;
    color: var(--text-3);
    flex-wrap: wrap;
}
.meta-via { opacity: .7; }
.engine-active-name { color: var(--accent); font-weight: 600; transition: color var(--transition); }
.meta-sep { opacity: .25; }
.meta-hint { opacity: .5; font-size: 11px; }

.meta-btn {
    padding: 3px 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
    color: var(--text-3);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
}
.meta-btn:hover { color: var(--text-2); border-color: var(--border-hover); }
.meta-btn.active {
    background: var(--accent-glow);
    border-color: var(--border-accent);
    color: var(--accent);
}

/* ── Categories ── */
.categories {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    margin-bottom: 24px;
}
.cat-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-full);
    color: var(--text-3);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
}
.cat-btn:hover { color: var(--text-2); background: var(--surface); border-color: var(--border); }
.cat-btn.active {
    color: var(--accent);
    background: var(--accent-glow);
    border-color: var(--border-accent);
}
.cat-icon { flex-shrink: 0; opacity: .7; }
.cat-btn.active .cat-icon { opacity: 1; }

/* ── Engine Grid ── */
.engines { width: 100%; margin-bottom: 20px; }
.engine-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}
.engine-group[hidden] { display: none; }

.engine {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
    position: relative;
    overflow: visible;
    user-select: none;
}
.engine:hover {
    background: var(--surface-hover);
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    z-index: 2;
}
.engine:active { transform: translateY(-1px) scale(.97); }
.engine.active {
    border-color: var(--border-accent);
    background: var(--surface-active);
    box-shadow: 0 0 0 1px var(--border-accent), 0 4px 20px var(--accent-glow-strong);
}
/* Multi-select mode */
.engines.multi-mode .engine { cursor: default; }
.engines.multi-mode .engine:hover { transform: translateY(-2px); }
.engines.multi-mode .engine.checked {
    border-color: var(--border-accent);
    background: var(--surface-active);
    box-shadow: 0 0 0 1px var(--border-accent);
}
.engines.multi-mode .engine::after {
    content: '';
    position: absolute;
    top: 8px; right: 8px;
    width: 14px; height: 14px;
    border: 1.5px solid var(--border-hover);
    border-radius: 4px;
    background: var(--surface);
    transition: var(--transition);
}
.engines.multi-mode .engine.checked::after {
    background: var(--accent);
    border-color: var(--accent);
    background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 10 10' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='2,5 4,7.5 8,3' fill='none' stroke='%23052e0f' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: contain;
}

.e-icon {
    width: 42px; height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    background: var(--c, #666);
    flex-shrink: 0;
    transition: var(--transition);
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.engine:hover .e-icon { transform: scale(1.1) translateY(-1px); }
.engine.active .e-icon { box-shadow: 0 4px 16px color-mix(in srgb, var(--c) 40%, transparent); }

.e-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-2);
    text-align: center;
    line-height: 1.2;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    width: 100%;
    transition: var(--transition);
}
.engine.active .e-name { color: var(--accent); }

/* Favorite star button */
.e-fav-btn {
    position: absolute;
    top: 6px; left: 7px;
    font-size: 10px;
    line-height: 1;
    color: var(--text-4);
    cursor: pointer;
    transition: var(--transition);
    z-index: 3;
    padding: 2px;
    border-radius: 3px;
    opacity: 0;
}
.engine:hover .e-fav-btn { opacity: 1; }
.engine.favorited .e-fav-btn { opacity: 1; color: #fbbf24; text-shadow: 0 0 6px rgba(251,191,36,.5); }
.e-fav-btn:hover { color: #fbbf24; opacity: 1; }

/* Tooltip (JS-positioned) */
.tooltip {
    position: fixed;
    z-index: 9999;
    padding: 6px 10px;
    background: var(--bg-2);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-xs);
    font-size: 11.5px;
    color: var(--text-2);
    white-space: nowrap;
    pointer-events: none;
    box-shadow: var(--shadow-sm);
    animation: tooltip-in .15s ease;
}
@keyframes tooltip-in {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Favorited engines get a subtle glow dot */
.engine.favorited::before {
    content: '';
    position: absolute;
    top: 6px; right: 6px;
    width: 5px; height: 5px;
    border-radius: 50%;
    background: #fbbf24;
    box-shadow: 0 0 6px rgba(251,191,36,.7);
}
.engines.multi-mode .engine.favorited::before { display: none; }

/* ── Custom Engine Add button ── */
.add-engine-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: 28px;
}
.add-engine-btn {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 20px;
    background: var(--surface);
    border: 1px dashed var(--border-hover);
    border-radius: var(--radius-full);
    color: var(--text-3);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
}
.add-engine-btn:hover {
    color: var(--accent);
    border-color: var(--border-accent);
    background: var(--accent-glow);
}

/* ── Quick Links ── */
.quick {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 14px;
    margin-bottom: 40px;
}
.quick a {
    color: var(--text-3);
    text-decoration: none;
    font-size: 13px;
    transition: var(--transition);
    padding: 4px 2px;
    border-bottom: 1px solid transparent;
}
.quick a:hover { color: var(--accent); border-bottom-color: var(--accent); }
.q-dot { width: 3px; height: 3px; background: var(--text-3); border-radius: 50%; opacity: .35; }

/* ── Footer ── */
.foot {
    position: relative;
    z-index: 1;
    text-align: center;
    padding: 20px;
}
.foot p { font-size: 12px; color: var(--text-3); }

/* ── Modal ── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.65);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fade-in .2s ease;
}
.modal-overlay[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--bg-2);
    border: 1px solid var(--border-hover);
    border-radius: 18px;
    width: 100%;
    max-width: 440px;
    box-shadow: var(--shadow-lg);
    animation: modal-in .25s cubic-bezier(.34,1.56,.64,1);
    overflow: hidden;
}
@keyframes modal-in {
    from { opacity: 0; transform: scale(.9) translateY(20px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 22px 0;
}
.modal-header h3 {
    font-family: var(--font-display);
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -.3px;
}
.modal-body { padding: 18px 22px; display: flex; flex-direction: column; gap: 14px; }
.modal-footer {
    padding: 0 22px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; font-weight: 500; color: var(--text-3); }
.form-group input,
.form-group select {
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-body);
    outline: none;
    transition: var(--transition);
    width: 100%;
}
.form-group input:focus,
.form-group select:focus { border-color: var(--border-accent); box-shadow: 0 0 0 3px var(--accent-glow); }
.form-group input[type="color"] {
    padding: 4px 6px;
    height: 40px;
    cursor: pointer;
}
.form-row { display: grid; grid-template-columns: 2fr 1fr 2fr; gap: 10px; }

.modal-preview {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}
.preview-label { font-size: 12px; color: var(--text-3); font-weight: 500; }

.btn {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
    border: 1px solid transparent;
}
.btn-ghost {
    background: var(--surface);
    color: var(--text-2);
    border-color: var(--border);
}
.btn-ghost:hover { background: var(--surface-hover); color: var(--text); }
.btn-primary {
    background: linear-gradient(145deg, var(--accent-2), var(--accent));
    color: #052e0f;
    border-color: transparent;
}
.btn-primary:hover { transform: scale(1.03); box-shadow: 0 4px 16px var(--accent-glow-strong); }

/* ── Context Menu ── */
.ctx-menu {
    position: fixed;
    z-index: 2000;
    background: var(--bg-2);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-sm);
    padding: 5px;
    min-width: 170px;
    box-shadow: var(--shadow-lg);
    animation: dropdown-in .15s ease;
    backdrop-filter: blur(20px);
}
.ctx-menu[hidden] { display: none; }

.ctx-item {
    display: flex;
    align-items: center;
    gap: 9px;
    width: 100%;
    padding: 9px 12px;
    background: none;
    border: none;
    border-radius: 7px;
    color: var(--text-2);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    font-family: var(--font-body);
    text-align: left;
}
.ctx-item:hover { background: var(--surface-hover); color: var(--text); }
.ctx-item.ctx-danger { color: var(--danger); }
.ctx-item.ctx-danger:hover { background: var(--danger-glow); }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── Toast ── */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(80px);
    background: var(--bg-2);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-full);
    padding: 10px 20px;
    font-size: 13px;
    color: var(--text);
    box-shadow: var(--shadow-md);
    z-index: 3000;
    transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .3s ease;
    opacity: 0;
    white-space: nowrap;
    backdrop-filter: blur(16px);
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* ── Entrance Animations ── */
@keyframes anim-up {
    from { opacity: 0; transform: translateY(24px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes anim-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}
@keyframes anim-engines {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.anim-topbar  { animation: anim-fade .5s ease .05s both; }
.anim-title   { animation: anim-up .6s cubic-bezier(.4,0,.2,1) .15s both; }
.anim-subtitle { animation: anim-up .6s cubic-bezier(.4,0,.2,1) .25s both; }
.anim-quote   { animation: anim-up .6s cubic-bezier(.4,0,.2,1) .32s both; }
.anim-search  { animation: anim-up .6s cubic-bezier(.4,0,.2,1) .38s both; }
.anim-cats    { animation: anim-up .6s cubic-bezier(.4,0,.2,1) .46s both; }
.anim-engines { animation: anim-engines .7s cubic-bezier(.4,0,.2,1) .54s both; }
.anim-quick   { animation: anim-fade .6s ease .64s both; }

/* Engine card staggered reveal on category switch */
.engine { animation: engine-reveal .3s cubic-bezier(.4,0,.2,1) both; }
@keyframes engine-reveal {
    from { opacity: 0; transform: translateY(8px) scale(.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .topbar { padding: 14px 16px; }
    .topbar-center { display: none; }
    .topbar { grid-template-columns: 1fr auto; }
    .hero { padding: 28px 14px 40px; }
    .title { margin-bottom: 10px; }
    .subtitle { font-size: 14px; margin-bottom: 8px; }
    .daily-quote { font-size: 11px; margin-bottom: 32px; }
    .engine-group { grid-template-columns: repeat(4, 1fr); gap: 6px; }
    .engine { padding: 14px 6px 10px; gap: 6px; }
    .e-icon { width: 36px; height: 36px; font-size: 13px; }
    .e-name { font-size: 10px; }
    .cat-btn { padding: 7px 12px; font-size: 12px; gap: 4px; }
    .cat-icon { display: none; }
    .search-input { font-size: 15px; }
    .modal { max-width: 100%; margin: 0 8px; border-radius: 16px; }
    .form-row { grid-template-columns: 1fr 1fr; }
    .form-row .form-group:last-child { grid-column: 1 / -1; }
    .shortcuts-hint { display: none; }
    .meta-sep:last-of-type { display: none; }
}

@media (max-width: 380px) {
    .engine-group { grid-template-columns: repeat(3, 1fr); }
    .engine { padding: 12px 4px 8px; }
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-3); }

/* ── Selection ── */
::selection { background: var(--accent-2); color: #052e0f; }

/* ── Focus visible ── */
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Reduced motion ── */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
    .orb { animation: none; }
}
