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

:root {
    --bg: #0a0a0f;
    --surface: rgba(15, 15, 25, 0.85);
    --surface-hover: rgba(25, 25, 40, 0.9);
    --text: #f0f0f5;
    --text-dim: rgba(240, 240, 245, 0.55);
    --text-muted: rgba(240, 240, 245, 0.35);
    --accent: #6366f1;
    --accent-glow: rgba(99, 102, 241, 0.3);
    --border: rgba(255, 255, 255, 0.08);
    --radius: 16px;
    --radius-sm: 10px;
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', monospace;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

html, body {
    height: 100%;
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ── Navigation ──────────────────────────────────────── */
#nav {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: rgba(10, 10, 15, 0.6);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: opacity var(--transition);
}

.nav-brand {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, #a78bfa, #6366f1, #818cf8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-tabs {
    display: flex;
    gap: 4px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 3px;
}

.nav-tab {
    border: none;
    background: none;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 13px;
    font-weight: 500;
    padding: 6px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all var(--transition);
}

.nav-tab:hover { color: var(--text); }
.nav-tab.active {
    background: rgba(255, 255, 255, 0.12);
    color: var(--text);
}

/* ── Views ───────────────────────────────────────────── */
.view {
    display: none;
    height: 100vh;
    width: 100%;
}
.view.active { display: flex; }

/* ── Survey View ─────────────────────────────────────── */
#survey-view {
    flex-direction: column;
    position: relative;
}

.survey-color {
    flex: 1;
    transition: background-color 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 20px;
    position: relative;
}

.hex-label {
    font-family: var(--mono);
    font-size: 14px;
    font-weight: 500;
    padding: 5px 12px;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 0.05em;
    transition: opacity 0.3s;
}

.survey-panel {
    background: var(--surface);
    backdrop-filter: blur(30px);
    -webkit-backdrop-filter: blur(30px);
    border-top: 1px solid var(--border);
    padding: 28px 24px 32px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.survey-question {
    font-size: 22px;
    font-weight: 600;
    letter-spacing: -0.02em;
}

.survey-subtitle {
    font-size: 14px;
    color: var(--text-dim);
    margin-bottom: 4px;
}

#survey-form {
    width: 100%;
    max-width: 420px;
}

.input-wrapper {
    display: flex;
    gap: 8px;
    background: rgba(255, 255, 255, 0.07);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 4px 4px 4px 18px;
    transition: all var(--transition);
}

.input-wrapper:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 0 0 3px var(--accent-glow);
    background: rgba(255, 255, 255, 0.1);
}

#color-input {
    flex: 1;
    border: none;
    background: none;
    outline: none;
    color: var(--text);
    font-family: var(--font);
    font-size: 17px;
    font-weight: 400;
    padding: 10px 0;
    min-width: 0;
}

#color-input::placeholder {
    color: var(--text-muted);
    font-weight: 300;
}

#submit-btn {
    width: 44px;
    height: 44px;
    border-radius: 11px;
    border: none;
    background: var(--accent);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

#submit-btn:hover {
    background: #5558e6;
    transform: scale(1.05);
}

#submit-btn:active { transform: scale(0.95); }

.progress-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
}

.progress-dots {
    display: flex;
    gap: 6px;
}

.progress-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.12);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-dot.filled {
    background: var(--accent);
    box-shadow: 0 0 8px var(--accent-glow);
}

.progress-dot.current {
    background: rgba(255, 255, 255, 0.4);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); opacity: 0.4; }
    50% { transform: scale(1.3); opacity: 1; }
}

.progress-text {
    font-family: var(--mono);
    font-size: 12px;
    color: var(--text-muted);
}

/* ── Survey Complete ─────────────────────────────────── */
.survey-complete {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    background: var(--bg);
    z-index: 50;
    animation: fadeIn 0.5s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.complete-icon {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    background: linear-gradient(135deg, #10b981, #059669);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    font-weight: 700;
    animation: scaleIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    from { transform: scale(0); }
    to { transform: scale(1); }
}

.survey-complete h2 {
    font-size: 28px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.survey-complete p {
    color: var(--text-dim);
    font-size: 16px;
    text-align: center;
    max-width: 320px;
    line-height: 1.5;
}

.btn-primary {
    padding: 14px 32px;
    border-radius: 12px;
    border: none;
    background: var(--accent);
    color: white;
    font-family: var(--font);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 8px;
}

.btn-primary:hover { background: #5558e6; transform: translateY(-1px); }

.btn-secondary {
    padding: 10px 24px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: none;
    color: var(--text-dim);
    font-family: var(--font);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-secondary:hover { color: var(--text); border-color: rgba(255, 255, 255, 0.2); }

/* ── Explore View ────────────────────────────────────── */
#explore-view {
    padding-top: 56px;
    flex-direction: row;
}

.explore-container {
    display: flex;
    width: 100%;
    height: 100%;
}

.explore-sidebar {
    width: 320px;
    min-width: 280px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--surface);
    overflow: hidden;
}

.stats-bar {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-dim);
    line-height: 1.6;
}

.stats-bar strong {
    color: var(--text);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.search-box {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
}

.search-box input {
    width: 100%;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-family: var(--font);
    font-size: 14px;
    outline: none;
    transition: all var(--transition);
}

.search-box input:focus {
    border-color: rgba(99, 102, 241, 0.4);
    background: rgba(255, 255, 255, 0.08);
}

.search-box input::placeholder { color: var(--text-muted); }

.names-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.names-list::-webkit-scrollbar { width: 6px; }
.names-list::-webkit-scrollbar-track { background: transparent; }
.names-list::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.name-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    margin: 3px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-dim);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    user-select: none;
}

.name-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.15);
}

.name-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.name-chip .count {
    font-family: var(--mono);
    font-size: 11px;
    opacity: 0.6;
}

.explore-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 24px;
    min-width: 0;
}

.map-header {
    margin-bottom: 16px;
}

.map-header h2 {
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.02em;
    margin-bottom: 4px;
}

.map-subtitle {
    font-size: 13px;
    color: var(--text-muted);
}

.map-container {
    flex: 1;
    position: relative;
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border);
    background: #111;
    min-height: 300px;
}

#color-map {
    width: 100%;
    height: 100%;
    display: block;
}

.map-axes {
    position: absolute;
    inset: 0;
    pointer-events: none;
    font-size: 11px;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.5);
    text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

.axis-label {
    position: absolute;
    padding: 4px 6px;
}

.axis-x-start { bottom: 6px; left: 8px; }
.axis-x-mid1 { bottom: 6px; left: 18%; }
.axis-x-mid2 { bottom: 6px; left: 37%; }
.axis-x-mid3 { bottom: 6px; left: 52%; }
.axis-x-mid4 { bottom: 6px; left: 68%; }
.axis-x-end { bottom: 6px; right: 8px; }
.axis-y-start { top: 8px; right: 8px; }
.axis-y-end { bottom: 26px; right: 8px; }

/* ── Flash feedback ──────────────────────────────────── */
.flash-overlay {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.flash-text {
    font-size: 48px;
    font-weight: 700;
    color: white;
    text-shadow: 0 2px 20px rgba(0,0,0,0.5);
    animation: flashPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes flashPop {
    0% { transform: scale(0.5); opacity: 0; }
    40% { transform: scale(1.1); opacity: 1; }
    100% { transform: scale(1); opacity: 0; }
}

/* ── Responsive ──────────────────────────────────────── */
@media (max-width: 768px) {
    #explore-view { flex-direction: column; }

    .explore-container {
        flex-direction: column;
    }

    .explore-sidebar {
        width: 100%;
        min-width: unset;
        max-height: 35vh;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .explore-main {
        padding: 16px;
    }

    .map-container {
        min-height: 250px;
    }

    .survey-question { font-size: 19px; }
    .survey-subtitle { font-size: 13px; }
    #color-input { font-size: 16px; }
    .nav-brand { font-size: 16px; }
}

@media (max-width: 420px) {
    .survey-panel { padding: 20px 16px 24px; }
    .progress-dots { gap: 5px; }
    .progress-dot { width: 7px; height: 7px; }
}
