/* ========== RESET & VARIABLES ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --radius: 10px;
    --transition: .2s ease;
}

[data-theme="dark"] {
    --bg: #0f0f0f;
    --surface: #1a1a1a;
    --surface2: #252525;
    --text: #f0f0f0;
    --text2: #999;
    --border: #333;
    --overlay: rgba(0,0,0,.7);
}
[data-theme="light"] {
    --bg: #f5f5f5;
    --surface: #fff;
    --surface2: #eee;
    --text: #111;
    --text2: #666;
    --border: #ddd;
    --overlay: rgba(0,0,0,.5);
}

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

/* ========== TOP BAR ========== */
.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    height: 52px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    z-index: 10;
    position: relative;
    flex-wrap: wrap;
    gap: 8px;
}
.topbar-left, .topbar-right { display: flex; align-items: center; gap: 12px; }
.logo { font-size: 1.1rem; font-weight: 700; white-space: nowrap; }
.harmony-selector { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.harmony-selector label { color: var(--text2); }
.harmony-selector select {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: .85rem;
    cursor: pointer;
}

.btn {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 12px;
    font-size: .8rem;
    cursor: pointer;
    transition: background var(--transition);
    white-space: nowrap;
}
.btn:hover { background: var(--border); }
.btn-icon { padding: 6px 8px; }
.btn-primary {
    background: #6366f1;
    color: #fff;
    border-color: #6366f1;
    margin-top: 12px;
    width: 100%;
    padding: 10px;
    font-size: .9rem;
}
.btn-primary:hover { background: #4f46e5; }
.btn-sm { font-size: .78rem; }

/* ========== PALETTE ========== */
.palette-container {
    display: flex;
    height: calc(100vh - 52px - 36px);
    width: 100%;
}

.color-bar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 32px;
    position: relative;
    cursor: pointer;
    transition: flex var(--transition);
    user-select: none;
}
.color-bar:hover { flex: 1.15; }
.color-bar.locked::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(45deg, transparent, transparent 10px, rgba(255,255,255,.03) 10px, rgba(255,255,255,.03) 20px);
    pointer-events: none;
}

.color-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    opacity: 0;
    transform: translateY(10px);
    transition: all .25s ease;
}
.color-bar:hover .color-info {
    opacity: 1;
    transform: translateY(0);
}

.color-hex {
    font-size: 1.1rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    background: rgba(0,0,0,.35);
    color: #fff;
    backdrop-filter: blur(4px);
    letter-spacing: .5px;
}

.color-actions {
    display: flex;
    gap: 6px;
}
.color-actions button {
    background: rgba(0,0,0,.35);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: .75rem;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background var(--transition);
}
.color-actions button:hover { background: rgba(0,0,0,.55); }
.color-actions button.lock-active { background: rgba(255,255,255,.3); }

.color-formats {
    display: flex;
    gap: 4px;
}
.color-formats button {
    background: rgba(0,0,0,.25);
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 3px 8px;
    font-size: .65rem;
    cursor: pointer;
    backdrop-filter: blur(4px);
}
.color-formats button:hover { background: rgba(0,0,0,.45); }

/* ========== HINT ========== */
.hint {
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
    color: var(--text2);
    background: var(--surface);
    border-top: 1px solid var(--border);
}
kbd {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 4px;
    padding: 1px 6px;
    font-size: .75rem;
    margin: 0 3px;
}

/* ========== FOOTER ========== */
.footer {
    position: fixed;
    bottom: 36px;
    left: 0; right: 0;
    text-align: center;
    font-size: .7rem;
    color: var(--text2);
    pointer-events: none;
    z-index: 5;
    display: none;
}
.footer a { color: var(--text2); pointer-events: all; text-decoration: underline; }

/* Show footer only when not hovering palette */
.palette-container:not(:hover) ~ .footer { display: block; }

/* ========== MODALS ========== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: var(--overlay);
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}
.modal-backdrop.active { opacity: 1; pointer-events: all; }

.modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(.95);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: min(560px, 92vw);
    max-height: 80vh;
    overflow-y: auto;
    z-index: 101;
    opacity: 0;
    pointer-events: none;
    transition: all .2s;
}
.modal.active { opacity: 1; pointer-events: all; transform: translate(-50%, -50%) scale(1); }
.modal-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1rem; }
.modal-close {
    background: none; border: none; color: var(--text); font-size: 1.4rem; cursor: pointer;
}
.modal-body { padding: 20px; }

/* Export */
.export-tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.export-tab {
    background: var(--surface2);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 6px 14px;
    font-size: .8rem;
    cursor: pointer;
}
.export-tab.active { background: #6366f1; color: #fff; border-color: #6366f1; }
.export-code {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 14px;
    font-size: .8rem;
    font-family: 'SF Mono', 'Fira Code', monospace;
    overflow-x: auto;
    white-space: pre;
    max-height: 300px;
    line-height: 1.5;
}

/* A11y */
.a11y-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
}
.a11y-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
}
.a11y-colors {
    display: flex; gap: 4px; justify-content: center; margin-bottom: 8px;
}
.a11y-swatch {
    width: 36px; height: 36px; border-radius: 6px; border: 1px solid var(--border);
}
.a11y-ratio { font-size: 1.1rem; font-weight: 700; margin: 4px 0; }
.a11y-badges { display: flex; gap: 4px; justify-content: center; }
.a11y-badge {
    font-size: .65rem; padding: 2px 8px; border-radius: 4px; font-weight: 600;
}
.a11y-pass { background: #22c55e; color: #fff; }
.a11y-fail { background: #ef4444; color: #fff; }

/* Saved */
.saved-list { display: flex; flex-direction: column; gap: 10px; }
.saved-item {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px;
    cursor: pointer;
    transition: background var(--transition);
}
.saved-item:hover { background: var(--border); }
.saved-swatches { display: flex; gap: 3px; }
.saved-swatch {
    width: 28px; height: 28px; border-radius: 4px; border: 1px solid rgba(0,0,0,.1);
}
.saved-name { flex: 1; font-size: .85rem; }
.saved-delete {
    background: none; border: none; color: var(--text2); cursor: pointer; font-size: 1rem;
}
.saved-delete:hover { color: #ef4444; }
.saved-empty { color: var(--text2); font-size: .85rem; text-align: center; padding: 20px; }

/* Toast */
.toast {
    position: fixed; bottom: 60px; left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 10px 20px;
    font-size: .85rem;
    z-index: 200;
    opacity: 0;
    transition: all .25s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ========== RESPONSIVE ========== */
@media (max-width: 700px) {
    .palette-container { flex-direction: column; }
    .color-bar { flex-direction: row; justify-content: center; padding-bottom: 0; }
    .color-bar:hover { flex: 1.3; }
    .color-info { flex-direction: row; flex-wrap: wrap; justify-content: center; }
    .topbar { height: auto; padding: 8px 12px; }
    .topbar-left, .topbar-right { flex-wrap: wrap; }
    .btn-sm { font-size: .7rem; padding: 4px 8px; }
}
