/* ═══════════════════════════════════════════
   ChronoSwarm — "Lumina" Warm Luxury Theme
   ═══════════════════════════════════════════ */

:root {
    /* Warm dark foundation */
    --bg-deep: #0e0c14;
    --bg-surface: rgba(18, 16, 26, 0.78);
    --bg-card: rgba(24, 20, 36, 0.72);
    --bg-elevated: rgba(35, 30, 50, 0.55);

    /* Warm accent palette */
    --gold: #f0b040;
    --gold-dim: rgba(240, 176, 64, 0.15);
    --gold-glow: rgba(240, 176, 64, 0.35);
    --rose: #e8789f;
    --rose-dim: rgba(232, 120, 159, 0.15);
    --teal: #4ecdc4;
    --teal-dim: rgba(78, 205, 196, 0.12);
    --lavender: #b8a9e8;
    --coral: #ff7b6b;
    --mint: #7ceda0;

    /* Borders */
    --border-soft: rgba(255, 255, 255, 0.06);
    --border-warm: rgba(240, 176, 64, 0.12);
    --border-focus: rgba(240, 176, 64, 0.35);

    /* Text */
    --text-bright: #f5f0ff;
    --text-mid: #a89ec0;
    --text-dim: #5e5478;

    /* Fonts */
    --font-heading: 'Sora', system-ui, sans-serif;
    --font-body: 'DM Sans', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'Consolas', monospace;

    /* Curves */
    --ease-smooth: cubic-bezier(0.25, 0.8, 0.25, 1);
    --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
    --ease-expo: cubic-bezier(0.16, 1, 0.3, 1);

    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 24px;
    --radius-pill: 50px;
}

/* ─── Reset ─── */
*, *::before, *::after {
    margin: 0; padding: 0; box-sizing: border-box;
}

body {
    background: var(--bg-deep);
    color: var(--text-bright);
    font-family: var(--font-body);
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    user-select: none;
    -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ─── Canvas ─── */
#canvas-container {
    position: fixed;
    inset: 0;
    z-index: 1;
}

/* ─── Ambient Gradient Mesh ─── */
.ambient-mesh {
    position: fixed;
    inset: 0;
    z-index: 2;
    pointer-events: none;
    overflow: hidden;
}

.mesh-orb {
    position: absolute;
    border-radius: 50%;
    filter: blur(120px);
    opacity: 0.12;
    animation: orbFloat 20s infinite ease-in-out;
}

.orb-1 {
    width: 500px; height: 500px;
    background: var(--gold);
    top: -15%; right: -8%;
    animation-delay: 0s;
}

.orb-2 {
    width: 400px; height: 400px;
    background: var(--rose);
    bottom: -10%; left: -5%;
    animation-delay: -7s;
}

.orb-3 {
    width: 350px; height: 350px;
    background: var(--lavender);
    top: 40%; left: 30%;
    animation-delay: -14s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(30px, -20px) scale(1.1); }
    66% { transform: translate(-20px, 15px) scale(0.95); }
}

/* ═══════ UI ROOT ═══════ */
#ui-root {
    position: fixed;
    inset: 0;
    z-index: 10;
    pointer-events: none;
}

#ui-root > * {
    pointer-events: auto;
}

/* ═══════ TOPBAR ═══════ */
#topbar {
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    background: linear-gradient(180deg, rgba(14, 12, 20, 0.88) 0%, transparent 100%);
    z-index: 20;
    animation: fadeSlideDown 0.6s var(--ease-expo) both;
}

@keyframes fadeSlideDown {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

.topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 12px var(--gold-glow);
    animation: dotPulse 3s infinite ease-in-out;
}

@keyframes dotPulse {
    0%, 100% { box-shadow: 0 0 8px var(--gold-glow); transform: scale(1); }
    50% { box-shadow: 0 0 18px var(--gold); transform: scale(1.15); }
}

.brand-name {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-bright);
}

.brand-name em {
    font-style: normal;
    color: var(--gold);
}

.brand-sub {
    font-size: 9px;
    font-weight: 400;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--text-dim);
    display: block;
    margin-top: 1px;
}

/* Center formation pill */
.topbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

#formation-pill {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 18px;
    border-radius: var(--radius-pill);
    background: var(--gold-dim);
    border: 1px solid var(--border-warm);
    transition: all 0.4s var(--ease-smooth);
}

.formation-icon {
    color: var(--gold);
    font-size: 10px;
    animation: spin 6s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.formation-name {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 1px;
    color: var(--gold);
}

/* Status chip */
.topbar-right {
    display: flex;
    align-items: center;
}

.status-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: var(--radius-pill);
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.3px;
    border: 1px solid var(--border-soft);
    background: rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

.chip-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.chip-off .chip-dot { background: var(--coral); box-shadow: 0 0 4px var(--coral); }
.chip-off .badge-text { color: var(--coral); }
.chip-off { border-color: rgba(255, 123, 107, 0.15); }

.chip-on .chip-dot { background: var(--mint); box-shadow: 0 0 6px var(--mint); animation: blink 1.4s infinite; }
.chip-on .badge-text { color: var(--mint); }
.chip-on { border-color: rgba(124, 237, 160, 0.15); }

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ═══════ SHAPE DOCK ═══════ */
#shape-dock {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    animation: riseUp 0.7s var(--ease-expo) 0.2s both;
}

@keyframes riseUp {
    from { opacity: 0; transform: translateX(-50%) translateY(40px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

.dock-inner {
    display: flex;
    align-items: end;
    gap: 4px;
    padding: 8px 14px;
    background: var(--bg-surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(255, 255, 255, 0.02) inset;
}

.dock-divider {
    width: 1px;
    height: 28px;
    background: var(--border-soft);
    margin: 0 4px;
    align-self: center;
}

.dock-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.35s var(--ease-bounce);
    position: relative;
}

.dock-icon {
    width: 42px; height: 42px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: all 0.35s var(--ease-bounce);
}

.dock-label {
    font-family: var(--font-mono);
    font-size: 8px;
    font-weight: 500;
    letter-spacing: 0.3px;
    color: var(--text-dim);
    transition: all 0.3s ease;
    opacity: 0;
    transform: translateY(4px);
}

.dock-item:hover {
    transform: translateY(-6px);
}

.dock-item:hover .dock-icon {
    background: rgba(255, 255, 255, 0.06);
    border-color: var(--border-soft);
    color: var(--text-mid);
}

.dock-item:hover .dock-label {
    opacity: 1;
    transform: translateY(0);
    color: var(--text-mid);
}

.dock-item.active {
    transform: translateY(-8px);
}

.dock-item.active .dock-icon {
    background: var(--gold-dim);
    border-color: var(--gold);
    color: var(--gold);
    box-shadow: 0 4px 20px var(--gold-glow);
}

.dock-item.active .dock-label {
    opacity: 1;
    transform: translateY(0);
    color: var(--gold);
}

/* Active indicator dot */
.dock-item.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    transform: translateX(-50%);
    width: 4px; height: 4px;
    border-radius: 50%;
    background: var(--gold);
    box-shadow: 0 0 8px var(--gold);
}

/* ═══════ DRAWERS ═══════ */
.drawer {
    position: absolute;
    top: 58px;
    bottom: 86px;
    z-index: 15;
    display: flex;
    transition: all 0.45s var(--ease-expo);
}

.drawer-l {
    left: 0;
    flex-direction: row;
}

.drawer-r {
    right: 0;
    flex-direction: row-reverse;
}

.drawer-content {
    width: 256px;
    height: 100%;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
    scrollbar-width: none;
    transition: all 0.45s var(--ease-expo);
}

.drawer-content::-webkit-scrollbar { display: none; }

/* Collapsed state */
.drawer.collapsed .drawer-content {
    width: 0;
    padding: 0;
    opacity: 0;
    overflow: hidden;
    pointer-events: none;
}

.drawer-toggle {
    width: 38px;
    height: 38px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    color: var(--text-dim);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
    margin: 4px;
    align-self: flex-start;
}

.drawer-toggle:hover {
    border-color: var(--gold);
    color: var(--gold);
    background: var(--gold-dim);
}

/* ═══════ CARDS ═══════ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-md);
    padding: 14px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    transition: border-color 0.3s ease;
}

.card:hover {
    border-color: var(--border-warm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border-soft);
}

.card-title {
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-mid);
    display: flex;
    align-items: center;
    gap: 6px;
}

.card-title i {
    color: var(--gold);
    font-size: 12px;
}

/* ═══════ STAT GRID ═══════ */
.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.stat-box {
    padding: 10px;
    border-radius: var(--radius-sm);
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-soft);
    text-align: center;
    transition: border-color 0.2s ease;
}

.stat-box:hover {
    border-color: var(--border-warm);
}

.stat-val {
    font-family: var(--font-heading);
    font-size: 16px;
    font-weight: 700;
    color: var(--text-bright);
    display: block;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.stat-green { color: var(--mint); }
.stat-gold { color: var(--gold); }

.stat-key {
    font-family: var(--font-mono);
    font-size: 8px;
    letter-spacing: 0.5px;
    color: var(--text-dim);
    text-transform: uppercase;
    margin-top: 2px;
    display: block;
}

/* ═══════ CAMERA ═══════ */
.cam-feed {
    position: relative;
    width: 100%;
    padding-bottom: 75%;
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-soft);
    margin-bottom: 8px;
}

#webcam {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

#hand-canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    transform: scaleX(-1);
    z-index: 2;
}

.cam-msg {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-dim);
    background: rgba(14, 12, 20, 0.92);
    z-index: 3;
}

.cam-msg i {
    font-size: 18px;
}

/* Toggle pill */
.toggle-pill {
    position: relative;
    display: inline-block;
    width: 34px; height: 18px;
    cursor: pointer;
}

.toggle-pill input { opacity: 0; width: 0; height: 0; }

.toggle-track {
    position: absolute;
    inset: 0;
    border-radius: 20px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--border-soft);
    transition: all 0.3s ease;
}

.toggle-knob {
    position: absolute;
    width: 12px; height: 12px;
    border-radius: 50%;
    background: var(--text-dim);
    top: 2px; left: 2px;
    transition: all 0.3s var(--ease-bounce);
}

.toggle-pill input:checked + .toggle-track {
    background: var(--gold-dim);
    border-color: var(--gold);
}

.toggle-pill input:checked + .toggle-track .toggle-knob {
    transform: translateX(16px);
    background: var(--gold);
    box-shadow: 0 0 6px var(--gold-glow);
}

/* Mini checkbox */
.mini-check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 10px;
    color: var(--text-dim);
    cursor: pointer;
}

.mini-check input { display: none; }

.mini-check-box {
    width: 14px; height: 14px;
    border-radius: 4px;
    border: 1px solid var(--border-soft);
    background: rgba(0, 0, 0, 0.2);
    position: relative;
    transition: all 0.2s ease;
}

.mini-check-box::after {
    content: '';
    position: absolute;
    left: 4px; top: 1px;
    width: 4px; height: 7px;
    border: solid transparent;
    border-width: 0 1.5px 1.5px 0;
    transform: rotate(45deg);
    transition: border-color 0.2s ease;
}

.mini-check input:checked + .mini-check-box {
    border-color: var(--gold);
    background: var(--gold-dim);
}

.mini-check input:checked + .mini-check-box::after {
    border-color: var(--gold);
}

/* ═══════ GESTURES ═══════ */
.gesture-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}

.g-row {
    display: grid;
    grid-template-columns: 24px 1fr auto;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.25s ease;
    border: 1px solid transparent;
}

.g-row:hover {
    background: rgba(255, 255, 255, 0.03);
}

.g-row.active {
    background: var(--gold-dim);
    border-color: var(--border-warm);
}

.g-emoji { font-size: 14px; text-align: center; }

.g-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-bright);
}

.g-key {
    font-family: var(--font-mono);
    font-size: 8px;
    color: var(--text-dim);
    background: rgba(0, 0, 0, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

.g-tip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 8px;
    background: var(--gold-dim);
    border: 1px dashed var(--border-warm);
    font-size: 9px;
    color: var(--gold);
    line-height: 1.4;
}

.g-tip i { font-size: 11px; flex-shrink: 0; }

/* ═══════ CONTROLS ═══════ */
.ctrl-group {
    margin-bottom: 14px;
}

.ctrl-group:last-child { margin-bottom: 0; }

.ctrl-group-label {
    font-family: var(--font-heading);
    font-size: 9px;
    font-weight: 600;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--text-dim);
    margin-bottom: 8px;
}

.slider-row {
    margin-bottom: 10px;
}

.slider-row:last-child { margin-bottom: 0; }

.slider-row label {
    display: block;
    font-size: 10px;
    color: var(--text-mid);
    margin-bottom: 5px;
    font-weight: 500;
}

.slider-row input[type="range"] {
    width: calc(100% - 54px);
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    outline: none;
    vertical-align: middle;
    transition: background 0.2s ease;
}

.slider-row input[type="range"]:hover {
    background: rgba(255, 255, 255, 0.1);
}

.slider-row input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border-radius: 50%;
    background: var(--gold);
    cursor: pointer;
    box-shadow: 0 0 8px var(--gold-glow);
    transition: all 0.2s var(--ease-bounce);
}

.slider-row input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 0 14px var(--gold);
}

.slider-readout {
    display: inline-block;
    font-family: var(--font-mono);
    font-size: 10px;
    font-weight: 600;
    color: var(--gold);
    min-width: 44px;
    text-align: right;
    vertical-align: middle;
    margin-left: 6px;
}

/* ═══════ PALETTE CHIPS ═══════ */
.palette-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.palette-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-soft);
    background: rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: all 0.3s var(--ease-bounce);
}

.palette-chip:hover {
    border-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.palette-chip.active {
    border-color: var(--gold);
    background: var(--gold-dim);
    box-shadow: 0 2px 12px var(--gold-glow);
}

.chip-preview {
    width: 28px; height: 28px;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s var(--ease-bounce);
}

.palette-chip:hover .chip-preview {
    transform: scale(1.12);
}

.palette-chip.active .chip-preview {
    transform: scale(1.15);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.4);
}

.chip-name {
    font-family: var(--font-mono);
    font-size: 8px;
    color: var(--text-dim);
    letter-spacing: 0.3px;
    transition: color 0.2s ease;
}

.palette-chip.active .chip-name {
    color: var(--gold);
}

/* ═══════ PROMPT OVERLAY ═══════ */
.prompt-overlay {
    position: fixed;
    inset: 0;
    background: rgba(8, 6, 12, 0.88);
    z-index: 100;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: auto;
}

.prompt-card {
    position: relative;
    max-width: 400px;
    width: calc(100% - 40px);
    padding: 40px 32px;
    text-align: center;
    background: var(--bg-card);
    border: 1px solid var(--border-warm);
    border-radius: var(--radius-lg);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    overflow: hidden;
    box-shadow: 0 16px 60px rgba(0, 0, 0, 0.5), 0 0 40px var(--gold-dim);
}

.prompt-shimmer {
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: conic-gradient(from 0deg, transparent, var(--gold-dim), transparent, transparent);
    animation: shimmerSpin 6s linear infinite;
    pointer-events: none;
    z-index: 0;
}

@keyframes shimmerSpin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.prompt-card > * { position: relative; z-index: 1; }

.prompt-emoji {
    font-size: 42px;
    animation: gentleBob 3s infinite ease-in-out;
}

@keyframes gentleBob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

.prompt-card h2 {
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--text-bright);
}

.prompt-card p {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-mid);
    max-width: 320px;
}

.prompt-btns {
    display: flex;
    gap: 10px;
    width: 100%;
    margin-top: 4px;
}

.btn-warm, .btn-muted {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s var(--ease-bounce);
    border: 1px solid transparent;
}

.btn-warm {
    background: linear-gradient(135deg, rgba(240, 176, 64, 0.18), rgba(232, 120, 159, 0.12));
    border-color: var(--gold);
    color: var(--gold);
}

.btn-warm:hover {
    background: linear-gradient(135deg, rgba(240, 176, 64, 0.3), rgba(232, 120, 159, 0.2));
    box-shadow: 0 4px 20px var(--gold-glow);
    transform: translateY(-1px);
}

.btn-muted {
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-soft);
    color: var(--text-mid);
}

.btn-muted:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-bright);
    border-color: rgba(255, 255, 255, 0.12);
}

/* ═══════ SCROLLBARS ═══════ */
::-webkit-scrollbar { width: 3px; height: 3px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.06); border-radius: 4px; }

/* ═══════ RESPONSIVE ═══════ */
@media (max-width: 768px) {
    .drawer-content { width: 220px; }

    .dock-icon { width: 36px; height: 36px; font-size: 14px; }
    .dock-label { display: none; }
    .dock-inner { padding: 6px 10px; gap: 2px; }
    .dock-divider { margin: 0 2px; }

    .topbar-center { display: none; }
    #topbar { padding: 0 12px; }
    .brand-name { font-size: 14px; }
    .brand-sub { display: none; }
}

@media (max-width: 480px) {
    .drawer { display: none; }
    .dock-icon { width: 32px; height: 32px; font-size: 12px; }
}
