/* =============================================================================
   Rivalic — app.css  ·  Pure obsidian dark mode, cyan/blue accents
   Vanilla CSS only. No frameworks, no external fonts.
   ============================================================================= */

:root {
    --bg:          #06080c;
    --bg-2:        #080b11;
    --surface:     #0e141d;
    --surface-2:   #121a24;
    --border:      #1c2735;
    --border-2:    #243244;
    --text:        #e7eef6;
    --muted:       #8a98ac;
    --muted-2:     #5f6c80;
    --cyan:        #22d3ee;
    --blue:        #3b82f6;
    --accent:      linear-gradient(135deg, #22d3ee 0%, #3b82f6 100%);
    --ok:          #34d399;
    --warn:        #fbbf24;
    --danger:      #f87171;
    --radius:      14px;
    --radius-sm:   10px;
    --shadow:      0 20px 60px -20px rgba(0,0,0,.7);
    --ring:        0 0 0 1px var(--border);
    --mono:        ui-monospace, "SF Mono", "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
    --sans:        -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
    margin: 0;
    font-family: var(--sans);
    color: var(--text);
    background: var(--bg);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
    overflow-x: hidden;
}

a { color: inherit; text-decoration: none; }
h1, h2, h3 { margin: 0; line-height: 1.15; letter-spacing: -0.02em; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }

/* Ambient glow behind hero */
.bg-aura {
    position: fixed; inset: -30% 0 auto 0; height: 80vh; z-index: 0; pointer-events: none;
    background:
        radial-gradient(60% 50% at 20% 0%, rgba(34,211,238,.16), transparent 70%),
        radial-gradient(55% 45% at 85% 10%, rgba(59,130,246,.18), transparent 70%);
    filter: blur(10px);
}

/* ─────────────────────────────  Buttons  ───────────────────────────── */
.btn {
    --pad-y: .7rem; --pad-x: 1.1rem;
    display: inline-flex; align-items: center; gap: .55rem; justify-content: center;
    padding: var(--pad-y) var(--pad-x);
    border-radius: var(--radius-sm);
    font-weight: 600; font-size: .95rem; cursor: pointer;
    border: 1px solid transparent; transition: transform .12s ease, box-shadow .2s ease, background .2s ease, border-color .2s ease;
    white-space: nowrap; user-select: none;
}
.btn:active { transform: translateY(1px); }
.btn-sm { --pad-y: .5rem; --pad-x: .85rem; font-size: .86rem; }
.btn-lg { --pad-y: .95rem; --pad-x: 1.5rem; font-size: 1.02rem; }
.btn-primary {
    background: var(--accent); color: #04121b; font-weight: 700;
    box-shadow: 0 8px 28px -8px rgba(34,211,238,.5);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 14px 38px -10px rgba(34,211,238,.6); }
.btn-ghost {
    background: rgba(255,255,255,.03); color: var(--text); border-color: var(--border-2);
}
.btn-ghost:hover { background: rgba(255,255,255,.06); border-color: var(--cyan); }
.btn-danger { background: rgba(248,113,113,.12); color: var(--danger); border-color: rgba(248,113,113,.4); }
.btn-danger:hover { background: rgba(248,113,113,.2); border-color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }

/* Experience-page action rows (live actions + settings) */
.action-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; margin-top: .8rem; }
.action-row .add-input { flex: 1; min-width: 140px; }
.action-status { min-height: 1.2em; margin-top: .7rem; }
.action-status.ok { color: var(--ok); }
.action-status.err { color: var(--danger); }
.danger-zone { border-color: rgba(248,113,113,.22); }

/* ─────────────────────────────  Top nav (onepager)  ───────────────────────────── */
.nav {
    position: relative; z-index: 2;
    display: flex; align-items: center; justify-content: space-between;
    max-width: 1180px; margin: 0 auto; padding: 1.3rem 1.5rem;
}
.brand { display: inline-flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; letter-spacing: -.02em; }
.brand-mark { display: block; border-radius: 8px; }
.nav-links { display: flex; align-items: center; gap: 1.6rem; }
.nav-links a:not(.btn) { color: var(--muted); font-size: .95rem; }
.nav-links a:not(.btn):hover { color: var(--text); }

/* ─────────────────────────────  Hero  ───────────────────────────── */
main { position: relative; z-index: 1; }
.hero {
    max-width: 880px; margin: 0 auto; padding: 4.5rem 1.5rem 3rem; text-align: center;
}
.eyebrow {
    display: inline-block; margin: 0 0 1.1rem; padding: .35rem .8rem; border-radius: 999px;
    font-size: .8rem; letter-spacing: .04em; color: var(--cyan);
    background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.22);
}
.hero-title { font-size: clamp(2.3rem, 6vw, 4rem); font-weight: 800; }
.grad-text {
    background: var(--accent); -webkit-background-clip: text; background-clip: text; color: transparent;
}
.hero-sub { max-width: 620px; margin: 1.4rem auto 0; color: var(--muted); font-size: 1.12rem; }
.hero-cta { display: flex; gap: .9rem; justify-content: center; flex-wrap: wrap; margin: 2.2rem 0 0; }
.stat-row {
    list-style: none; display: flex; gap: 2.5rem; justify-content: center; flex-wrap: wrap;
    margin: 3rem 0 0; padding: 0;
}
.stat-row li { display: flex; flex-direction: column; }
.stat-row strong { font-size: 1.4rem; background: var(--accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-row span { color: var(--muted-2); font-size: .85rem; }

/* ─────────────────────────────  Sections  ───────────────────────────── */
.section-title { font-size: clamp(1.6rem, 3.5vw, 2.2rem); text-align: center; margin-bottom: 2.5rem; }
.features { max-width: 1180px; margin: 0 auto; padding: 4rem 1.5rem; }
.feature-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.3rem; }
.card {
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 1.8rem;
    transition: transform .18s ease, border-color .2s ease, box-shadow .25s ease;
}
.card:hover { transform: translateY(-4px); border-color: var(--border-2); box-shadow: var(--shadow); }
.card-icon {
    width: 46px; height: 46px; display: grid; place-items: center; font-size: 1.3rem;
    border-radius: 12px; margin-bottom: 1rem; color: var(--cyan);
    background: rgba(34,211,238,.08); border: 1px solid rgba(34,211,238,.2);
}
.card h3 { font-size: 1.15rem; margin-bottom: .55rem; }
.card p { color: var(--muted); font-size: .96rem; margin: 0; }

.band { padding: 4rem 1.5rem; }
.band-inner {
    max-width: 820px; margin: 0 auto; text-align: center; padding: 3rem 2rem;
    background: radial-gradient(120% 120% at 50% 0%, rgba(59,130,246,.12), transparent 60%), var(--surface);
    border: 1px solid var(--border); border-radius: 20px;
}
.band-sub { color: var(--muted); max-width: 600px; margin: 0 auto 1.8rem; font-size: 1.05rem; }

.footer {
    max-width: 1180px; margin: 0 auto; padding: 2.5rem 1.5rem;
    display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
    border-top: 1px solid var(--border); color: var(--muted); font-size: .9rem;
}
.footer a { color: var(--muted); }
.footer a:hover { color: var(--cyan); }

/* ─────────────────────────────  Dashboard  ───────────────────────────── */
body.app { background: var(--bg); }
.dash { display: grid; grid-template-columns: 256px 1fr; min-height: 100vh; }

.sidebar {
    position: sticky; top: 0; height: 100vh;
    display: flex; flex-direction: column; gap: 1.5rem; padding: 1.4rem 1rem;
    background: var(--bg-2); border-right: 1px solid var(--border); z-index: 20;
}
.sidebar .brand { padding: .3rem .5rem .6rem; }
.side-nav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.side-link {
    display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: 10px;
    color: var(--muted); font-size: .95rem; font-weight: 500; transition: background .15s, color .15s;
}
.side-link .ico { width: 18px; text-align: center; opacity: .85; }
.side-link:hover { background: rgba(255,255,255,.04); color: var(--text); }
.side-link.is-active { background: rgba(34,211,238,.1); color: var(--cyan); box-shadow: inset 2px 0 0 var(--cyan); }
.side-logout {
    display: flex; align-items: center; gap: .75rem; padding: .7rem .8rem; border-radius: 10px;
    color: var(--muted); font-size: .95rem; border: 1px solid var(--border);
}
.side-logout:hover { color: var(--danger); border-color: rgba(248,113,113,.4); }

.main { display: flex; flex-direction: column; min-width: 0; }
.topbar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 1rem; padding: 1rem 1.6rem;
    background: rgba(8,11,17,.8); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border);
}
.menu-btn { display: none; background: none; border: 1px solid var(--border); color: var(--text); border-radius: 8px; width: 38px; height: 38px; font-size: 1.2rem; cursor: pointer; }
.topbar-title { font-weight: 700; font-size: 1.05rem; }
.user-chip { margin-left: auto; display: flex; align-items: center; gap: .65rem; }
.avatar {
    width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center;
    font-weight: 800; color: #04121b; background: var(--accent);
}
.user-meta { display: flex; flex-direction: column; line-height: 1.1; }
.user-meta small { font-size: .76rem; }

.content { padding: 1.8rem 1.6rem 3rem; max-width: 1100px; width: 100%; }
.welcome { margin-bottom: 1.8rem; }
.welcome h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: .3rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.3rem; margin-bottom: 1.3rem; }
.panel {
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
    border: 1px solid var(--border); border-radius: var(--radius); padding: 1.5rem;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: .4rem; }
.panel-head h2 { font-size: 1.1rem; }

.badge {
    font-size: .72rem; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
    padding: .25rem .55rem; border-radius: 999px; background: rgba(255,255,255,.06); color: var(--muted);
    border: 1px solid var(--border-2);
}
.badge-ok   { color: var(--ok);   background: rgba(52,211,153,.1);  border-color: rgba(52,211,153,.3); }
.badge-warn { color: var(--warn); background: rgba(251,191,36,.1);  border-color: rgba(251,191,36,.3); }
.badge-mut  { color: var(--muted-2); }

/* Add-by-Universe-ID bar */
.add-bar { display: flex; align-items: center; gap: .6rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.add-input {
    flex: 1; min-width: 220px; padding: .65rem .9rem; border-radius: var(--radius-sm);
    background: #05080d; border: 1px solid var(--border-2); color: var(--text);
    font: inherit; font-size: .92rem;
}
.add-input::placeholder { color: var(--muted-2); }
.add-input:focus { outline: none; border-color: var(--cyan); }
.add-status { min-width: 0; }
.add-status.ok { color: var(--ok); }
.add-status.err { color: var(--danger); }

/* Avatar image in the topbar chip */
.avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; display: block; }

/* Accordion folders */
.accordions { display: flex; flex-direction: column; gap: 1rem; }
.accordion { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.acc-head { display: flex; align-items: center; gap: .6rem; padding: .7rem .9rem; }
.acc-toggle {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: .75rem;
    background: none; border: 0; color: var(--text); font: inherit; cursor: pointer; text-align: left; padding: .2rem;
}
.acc-thumb { width: 38px; height: 38px; border-radius: 9px; overflow: hidden; flex: none; background: #05080d; display: grid; place-items: center; border: 1px solid var(--border); }
.acc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.acc-thumb-fallback { color: var(--muted-2); }
.acc-title { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.acc-chevron { margin-left: auto; color: var(--muted); transition: transform .25s ease; }
.accordion.open .acc-chevron { transform: rotate(180deg); }
.acc-sync { flex: none; }
.acc-body { display: grid; grid-template-rows: 0fr; transition: grid-template-rows .28s ease; }
.accordion.open .acc-body { grid-template-rows: 1fr; }
.acc-body-inner { overflow: hidden; min-height: 0; padding: 0 .9rem; }
.accordion.open .acc-body-inner { padding: .2rem .9rem 1rem; }
.folder-empty { padding: .2rem 0 .4rem; }

/* Experience gallery (dashboard) */
.exp-grid {
    margin-top: 1rem;
    display: grid; gap: 1.1rem;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}
.exp-tile {
    display: flex; flex-direction: column; position: relative;
    background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
    border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
    transition: transform .2s ease, border-color .2s ease, box-shadow .25s ease;
    opacity: 0; animation: fadeInUp .5s ease forwards;
}
.exp-tile:hover { transform: translateY(-5px); border-color: var(--cyan); box-shadow: 0 18px 44px -18px rgba(34,211,238,.45); }
.exp-thumb { aspect-ratio: 1 / 1; background: #05080d; overflow: hidden; display: grid; place-items: center; }
.exp-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .35s ease; }
.exp-tile:hover .exp-thumb img { transform: scale(1.06); }
.exp-thumb-fallback { font-size: 3rem; color: var(--muted-2); }
.exp-tile-body { padding: .85rem 1rem; display: flex; flex-direction: column; gap: .15rem; }
.exp-tile-name { font-weight: 700; line-height: 1.2; }
.exp-tile-meta { color: var(--muted); font-size: .82rem; }
.exp-tile-go {
    position: absolute; top: .7rem; right: .8rem; width: 30px; height: 30px;
    display: grid; place-items: center; border-radius: 50%; color: #04121b;
    background: var(--accent); font-weight: 800; opacity: 0; transform: translateX(-6px);
    transition: opacity .2s ease, transform .2s ease;
}
.exp-tile:hover .exp-tile-go { opacity: 1; transform: translateX(0); }

/* stagger the gallery fade-in (CSP-safe: no inline styles) */
.exp-tile:nth-child(1){animation-delay:.02s}.exp-tile:nth-child(2){animation-delay:.06s}
.exp-tile:nth-child(3){animation-delay:.10s}.exp-tile:nth-child(4){animation-delay:.14s}
.exp-tile:nth-child(5){animation-delay:.18s}.exp-tile:nth-child(6){animation-delay:.22s}
.exp-tile:nth-child(7){animation-delay:.26s}.exp-tile:nth-child(8){animation-delay:.30s}

/* Per-experience page */
.back-link { color: var(--muted); font-weight: 600; }
.back-link:hover { color: var(--cyan); }
.exp-hero { display: flex; gap: 1.4rem; align-items: center; flex-wrap: wrap; }
.exp-hero-img { width: 120px; height: 120px; border-radius: 18px; overflow: hidden; background: #05080d; flex: none; display: grid; place-items: center; border: 1px solid var(--border); }
.exp-hero-img img { width: 100%; height: 100%; object-fit: cover; }
.exp-hero-info h1 { font-size: clamp(1.5rem, 3vw, 2rem); margin-bottom: .3rem; }
.stat-pills { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .9rem; }
.pill { padding: .4rem .8rem; border-radius: 999px; background: rgba(255,255,255,.05); border: 1px solid var(--border-2); font-size: .85rem; color: var(--muted); }
.pill strong { color: var(--text); }
.pill-link { color: var(--cyan); }
.pill-link:hover { border-color: var(--cyan); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.1rem; margin-bottom: 1.3rem; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.3rem; display: flex; flex-direction: column; gap: .3rem; }
.stat-num { font-size: 1.9rem; font-weight: 800; background: var(--accent); -webkit-background-clip: text; background-clip: text; color: transparent; }
.stat-num.muted-2 { background: none; color: var(--muted-2); -webkit-text-fill-color: var(--muted-2); }
.stat-label { color: var(--muted); font-size: .88rem; }

/* Entrance animations */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: translateY(0); } }
.anim-in { opacity: 0; animation: fadeInUp .5s ease forwards; }
.anim-d1 { animation-delay: .08s; }
.anim-d2 { animation-delay: .16s; }
.anim-d3 { animation-delay: .24s; }

/* API key */
.key-row { display: flex; align-items: center; gap: .6rem; margin-top: 1rem; flex-wrap: wrap; }
.key-field {
    flex: 1; min-width: 220px; font-family: var(--mono); font-size: .92rem; letter-spacing: .04em;
    padding: .8rem 1rem; border-radius: var(--radius-sm); color: var(--cyan);
    background: #05080d; border: 1px solid var(--border-2); overflow-x: auto; white-space: nowrap;
}
.key-status { min-height: 1.2em; margin: .6rem 0 0; }

/* Modules */
.module-list { list-style: none; margin: 1rem 0 .6rem; padding: 0; display: flex; flex-direction: column; gap: .15rem; }
.module-item { display: flex; align-items: center; gap: .75rem; padding: .7rem .3rem; border-bottom: 1px solid var(--border); }
.module-item:last-child { border-bottom: 0; }
.module-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.module-dot.on  { background: var(--ok);  box-shadow: 0 0 10px rgba(52,211,153,.7); }
.module-dot.off { background: var(--muted-2); }
.module-name { flex: 1; font-weight: 600; }

/* UI builder placeholder */
.canvas-placeholder {
    margin-top: 1rem; border: 1.5px dashed var(--border-2); border-radius: var(--radius);
    min-height: 240px; display: grid; place-items: center; text-align: center;
    background: repeating-linear-gradient(45deg, rgba(255,255,255,.012) 0 12px, transparent 12px 24px);
}
.canvas-inner p { margin: .6rem 0 .2rem; font-weight: 600; }
.canvas-glyph { font-size: 2.4rem; color: var(--muted-2); }

/* Legal pages (privacy / terms) */
.legal { max-width: 760px; margin: 0 auto; padding: 3rem 1.5rem 4rem; position: relative; z-index: 1; }
.legal h1 { font-size: clamp(1.8rem, 4vw, 2.4rem); margin-bottom: .4rem; }
.legal h2 { font-size: 1.2rem; margin: 2rem 0 .5rem; }
.legal p { color: var(--muted); margin: 0; }
.legal a { color: var(--cyan); }

/* Error page */
.error-wrap { min-height: 90vh; display: grid; place-items: center; padding: 2rem; }
.error-card {
    text-align: center; max-width: 460px; padding: 3rem 2rem; background: var(--surface);
    border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow);
}
.error-glyph {
    width: 60px; height: 60px; margin: 0 auto 1.2rem; border-radius: 16px; display: grid; place-items: center;
    font-size: 1.8rem; font-weight: 800; color: var(--warn);
    background: rgba(251,191,36,.1); border: 1px solid rgba(251,191,36,.3);
}
.error-card h1 { font-size: 1.5rem; margin-bottom: .6rem; }
.error-card p { margin-bottom: 1.6rem; }
.ok-glyph {
    width: 60px; height: 60px; margin: 0 auto 1.2rem; border-radius: 16px; display: grid; place-items: center;
    font-size: 1.8rem; font-weight: 800; color: var(--ok);
    background: rgba(52,211,153,.1); border: 1px solid rgba(52,211,153,.3);
}
.connect-meta { list-style: none; padding: 0; margin: 0 0 1.2rem; display: flex; gap: 1.4rem; justify-content: center; flex-wrap: wrap; }
.connect-meta span { font-size: .8rem; display: block; }
.connect-meta strong { font-family: var(--mono); }
.connect-warn { color: var(--warn); font-size: .9rem; margin-bottom: 1.2rem; }

/* ─────────────────────────────  Responsive  ───────────────────────────── */
@media (max-width: 900px) {
    .feature-grid { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .grid-3 { grid-template-columns: 1fr; }
    .exp-hero { flex-direction: column; align-items: flex-start; }
    .dash { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0; width: 260px; transform: translateX(-100%);
        transition: transform .25s ease; box-shadow: var(--shadow);
    }
    .sidebar.open { transform: translateX(0); }
    .menu-btn { display: grid; place-items: center; }
}
@media (max-width: 560px) {
    .nav-links a:not(.btn) { display: none; }
    .stat-row { gap: 1.6rem; }
    .user-meta { display: none; }
    .content { padding: 1.2rem 1rem 2.5rem; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; scroll-behavior: auto !important; }
    /* Don't leave entrance-animated elements stuck invisible. */
    .anim-in, .exp-tile { animation: none !important; opacity: 1 !important; }
}
