/* ========================================
   Color Palette Generator — Styles
   ======================================== */

/* ====== Theme Variables ====== */
:root {
    --bg: #0f0f1a;
    --bg-card: #1a1a2e;
    --bg-elevated: #242442;
    --text: #e8e8f0;
    --text-muted: #8888aa;
    --text-inverse: #1a1a2e;
    --accent: #6c5ce7;
    --accent-hover: #7d6ef0;
    --accent-glow: rgba(108, 92, 231, 0.3);
    --accent-subtle: rgba(108, 92, 231, 0.08);
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.16);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --overlay: rgba(0,0,0,0.6);
    --success: #00d26a;
    --success-bg: rgba(0, 210, 106, 0.15);
    --success-border: rgba(0, 210, 106, 0.3);
    --danger: #ff4757;
    --danger-bg: rgba(255, 71, 87, 0.15);
    --danger-border: rgba(255, 71, 87, 0.3);
    --wheel-center: #1a1a2e;
    --radius: 16px;
    --radius-sm: 10px;
    --radius-xs: 6px;
    --nav-height: 64px;
    --header-height: 56px;
    --hint-height: 32px;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', 'JetBrains Mono', monospace;
    color-scheme: dark;
}

/* Light theme */
[data-theme="light"] {
    --bg: #f5f5f8;
    --bg-card: #ffffff;
    --bg-elevated: #eeeef2;
    --text: #1a1a2e;
    --text-muted: #6b6b8a;
    --text-inverse: #ffffff;
    --accent: #6c5ce7;
    --accent-hover: #5a4bd6;
    --accent-glow: rgba(108, 92, 231, 0.2);
    --accent-subtle: rgba(108, 92, 231, 0.06);
    --border: rgba(0,0,0,0.08);
    --border-hover: rgba(0,0,0,0.16);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.15);
    --overlay: rgba(0,0,0,0.4);
    --wheel-center: #ffffff;
    color-scheme: light;
}

/* ====== Reset & Base ====== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background-color var(--transition-slow), color var(--transition-slow);
}

/* ========================================
   Header
   ======================================== */
.app-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    position: relative;
    z-index: 10;
    transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

.logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo-icon {
    font-size: 24px;
    transition: transform 0.3s ease;
}

.logo:hover .logo-icon {
    transform: rotate(-15deg) scale(1.1);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Icon Button */
.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    position: relative;
}

.icon-btn:hover:not(:disabled) {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border-hover);
}

.icon-btn:active:not(:disabled) {
    transform: scale(0.92);
}

.icon-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Theme toggle */
.theme-toggle {
    position: relative;
    overflow: hidden;
}

.theme-toggle svg {
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s;
}

.theme-toggle .sun-icon {
    position: absolute;
    opacity: 0;
    transform: rotate(90deg) scale(0);
}

[data-theme="light"] .theme-toggle .moon-icon {
    opacity: 0;
    transform: rotate(-90deg) scale(0);
}

[data-theme="light"] .theme-toggle .sun-icon {
    opacity: 1;
    transform: rotate(0) scale(1);
}

/* Primary Button */
.btn-primary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn-primary::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(rgba(255,255,255,0.1), transparent);
    opacity: 0;
    transition: opacity 0.2s;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px var(--accent-glow);
}

.btn-primary:hover::after {
    opacity: 1;
}

.btn-primary:active {
    transform: scale(0.96);
}

.btn-full {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
}

/* Secondary Button */
.btn-secondary {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.btn-secondary:active {
    transform: scale(0.96);
}

/* ========================================
   Tab Content
   ======================================== */
.tab-content {
    display: none;
    height: calc(100vh - var(--header-height) - var(--nav-height) - var(--hint-height));
    overflow: hidden;
    opacity: 0;
    transition: opacity 0.25s ease;
}

.tab-content.active {
    display: flex;
    opacity: 1;
}

/* Scrollable tabs */
#tab-harmony,
#tab-converter,
#tab-extract,
#tab-saved {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Scrollbar styling */
#tab-harmony::-webkit-scrollbar,
#tab-converter::-webkit-scrollbar,
#tab-extract::-webkit-scrollbar,
#tab-saved::-webkit-scrollbar {
    width: 4px;
}

#tab-harmony::-webkit-scrollbar-thumb,
#tab-converter::-webkit-scrollbar-thumb,
#tab-extract::-webkit-scrollbar-thumb,
#tab-saved::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

#tab-harmony::-webkit-scrollbar-track,
#tab-converter::-webkit-scrollbar-track,
#tab-extract::-webkit-scrollbar-track,
#tab-saved::-webkit-scrollbar-track {
    background: transparent;
}

/* ========================================
   Palette Container (Generate Tab)
   ======================================== */
.palette-container {
    display: flex;
    flex-direction: row;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Individual Color Strip */
.color-strip {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 16px 4px;
    position: relative;
    cursor: pointer;
    transition: flex 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0;
}

.color-strip:hover {
    flex: 1.3;
}

.color-strip.locked {
    position: relative;
}

.color-strip.locked::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 10px,
        rgba(0,0,0,0.03) 10px,
        rgba(0,0,0,0.03) 20px
    );
    pointer-events: none;
}

/* Lock indicator badge */
.color-strip.locked .lock-indicator {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 20px;
    padding: 4px 10px;
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    z-index: 3;
    animation: fadeSlideDown 0.3s ease;
}

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

/* Color info at bottom of strip */
.color-info {
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: var(--radius-sm);
    padding: 10px 8px;
    text-align: center;
    width: calc(100% - 8px);
    max-width: 140px;
    transition: var(--transition);
    z-index: 2;
}

.color-hex {
    font-size: 14px;
    font-weight: 700;
    font-family: var(--font-mono);
    letter-spacing: 0.5px;
    color: #fff;
    margin-bottom: 4px;
}

.color-values {
    font-size: 10px;
    color: rgba(255,255,255,0.65);
    line-height: 1.5;
}

/* Action buttons on strip */
.strip-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
    z-index: 2;
    opacity: 0;
    transform: translateY(8px);
    transition: var(--transition);
}

.color-strip:hover .strip-actions {
    opacity: 1;
    transform: translateY(0);
}

.strip-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.45);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.strip-btn:hover {
    background: rgba(0,0,0,0.7);
    transform: scale(1.1);
}

.strip-btn:active {
    transform: scale(0.9);
}

.strip-btn.locked-btn {
    background: rgba(255,255,255,0.25);
}

.strip-btn svg {
    width: 16px;
    height: 16px;
}

/* ========================================
   Bottom Navigation
   ======================================== */
.bottom-nav {
    height: var(--nav-height);
    display: flex;
    align-items: center;
    justify-content: space-around;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    padding: 0 4px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 10px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-sm);
    position: relative;
    letter-spacing: 0.2px;
}

.nav-item svg {
    transition: transform 0.2s ease;
}

.nav-item.active {
    color: var(--accent);
}

.nav-item.active svg {
    transform: scale(1.1);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 50%;
    transform: translateX(-50%);
    width: 24px;
    height: 3px;
    background: var(--accent);
    border-radius: 0 0 3px 3px;
}

.nav-item:hover:not(.active) {
    color: var(--text);
    background: var(--accent-subtle);
}

.nav-item:active {
    transform: scale(0.92);
}

/* ========================================
   Hint Bar
   ======================================== */
.hint-bar {
    height: var(--hint-height);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--text-muted);
    background: var(--bg);
    border-top: 1px solid var(--border);
    transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

kbd {
    display: inline-block;
    padding: 1px 6px;
    font-size: 11px;
    font-family: inherit;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 4px;
    margin: 0 2px;
}

/* ========================================
   Modal
   ======================================== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    transition: opacity 0.25s ease;
}

.modal.hidden {
    pointer-events: none;
    opacity: 0;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--overlay);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), background-color var(--transition-slow);
    z-index: 1;
    box-shadow: var(--shadow-lg);
}

.modal.hidden .modal-content {
    transform: translateY(100%);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--bg-card);
    z-index: 2;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg-elevated);
    color: var(--text);
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--danger-bg);
    color: var(--danger);
}

.modal-close:active {
    transform: scale(0.9);
}

/* ========================================
   Color Picker (Modal)
   ======================================== */
.picker-body {
    padding: 20px;
}

.picker-preview {
    width: 100%;
    height: 80px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    transition: background-color 0.15s;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
}

.picker-sliders {
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin-bottom: 20px;
}

.slider-group {
    display: flex;
    align-items: center;
    gap: 12px;
}

.slider-group label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    width: 80px;
    flex-shrink: 0;
}

.slider-value {
    font-size: 13px;
    font-family: var(--font-mono);
    color: var(--text);
    width: 40px;
    text-align: right;
    flex-shrink: 0;
}

.slider {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 8px;
    border-radius: 4px;
    outline: none;
    cursor: pointer;
    transition: height 0.15s;
}

.slider:hover {
    height: 10px;
}

.slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
}

.slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
    box-shadow: 0 2px 12px rgba(0,0,0,0.3);
}

.slider::-webkit-slider-thumb:active {
    transform: scale(1.2);
}

.slider::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--accent);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    cursor: pointer;
}

.slider-hue {
    background: linear-gradient(to right,
        hsl(0,100%,50%), hsl(30,100%,50%), hsl(60,100%,50%),
        hsl(90,100%,50%), hsl(120,100%,50%), hsl(150,100%,50%),
        hsl(180,100%,50%), hsl(210,100%,50%), hsl(240,100%,50%),
        hsl(270,100%,50%), hsl(300,100%,50%), hsl(330,100%,50%),
        hsl(360,100%,50%)
    );
}

.slider-sat {
    background: linear-gradient(to right, hsl(0,0%,50%), hsl(0,100%,50%));
}

.slider-light {
    background: linear-gradient(to right, hsl(0,100%,0%), hsl(0,100%,50%), hsl(0,100%,100%));
}

.picker-values {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 20px;
}

.value-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-xs);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
}

.value-row:hover {
    background: var(--accent-subtle);
    box-shadow: inset 0 0 0 1px var(--accent-glow);
}

.value-row:active {
    transform: scale(0.98);
}

.value-row span:first-child {
    color: var(--text-muted);
    font-weight: 500;
}

.value-row span:last-child {
    font-family: var(--font-mono);
}

/* ========================================
   Toast
   ======================================== */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--bg-card);
    color: var(--text);
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    z-index: 200;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: none;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.toast.show {
    transform: translateX(-50%) translateY(0);
}

/* ========================================
   Animations
   ======================================== */
@keyframes colorIn {
    from {
        opacity: 0;
        transform: scaleY(0.8);
    }
    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

.color-strip.animating {
    animation: colorIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-3px); }
    40% { transform: translateX(3px); }
    60% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
}

.btn-primary.shaking {
    animation: shake 0.4s ease-in-out;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

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

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

/* ========================================
   Harmony Tab
   ======================================== */
.harmony-panel {
    padding: 20px 16px 100px;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
}

.harmony-wheel-wrap {
    position: relative;
    width: 240px;
    height: 240px;
    margin: 0 auto 24px;
}

.harmony-wheel-wrap canvas {
    display: block;
    border-radius: 50%;
    box-shadow: 0 4px 20px rgba(0,0,0,0.2);
}

#harmony-dots {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.harmony-dot {
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.4);
    transform: translate(-50%, -50%);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.harmony-dot.base {
    width: 24px;
    height: 24px;
    border-width: 3px;
    z-index: 2;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.harmony-modes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-bottom: 20px;
}

.mode-chip {
    padding: 7px 14px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.mode-chip:hover {
    background: var(--bg-elevated);
    color: var(--text);
    border-color: var(--border-hover);
}

.mode-chip:active {
    transform: scale(0.95);
}

.mode-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
    box-shadow: 0 2px 8px var(--accent-glow);
}

.harmony-base-control {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.harmony-base-control label {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    width: 70px;
    flex-shrink: 0;
}

.harmony-result {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    min-height: 80px;
}

.harmony-swatch {
    flex: 1;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 8px 4px;
    min-height: 80px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s;
    position: relative;
    overflow: hidden;
}

.harmony-swatch:hover {
    transform: scale(1.04) translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.harmony-swatch:active {
    transform: scale(0.98);
}

.harmony-swatch-label {
    font-size: 11px;
    font-weight: 700;
    font-family: var(--font-mono);
    text-align: center;
    padding: 4px 6px;
    border-radius: 4px;
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    color: #fff;
}

/* ========================================
   Converter Tab
   ======================================== */
.converter-panel {
    padding: 20px 16px 100px;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
}

.converter-preview {
    width: 100%;
    height: 70px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    background: var(--accent);
    transition: background-color 0.15s;
    cursor: pointer;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.1);
    position: relative;
}

.converter-preview::after {
    content: 'Tap to load palette color';
    position: absolute;
    bottom: 8px;
    right: 12px;
    font-size: 10px;
    color: rgba(255,255,255,0.5);
    opacity: 0;
    transition: opacity 0.2s;
}

.converter-preview:hover::after {
    opacity: 1;
}

.converter-fields {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 28px;
}

.field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.field-group > label,
.field-group .field-row > div > label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.field-row {
    flex-direction: row !important;
    gap: 8px;
}

.field-row > div {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.conv-input {
    width: 100%;
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text);
    font-size: 14px;
    font-family: var(--font-mono);
    outline: none;
    transition: var(--transition);
}

.conv-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.conv-input::placeholder {
    color: var(--text-muted);
    opacity: 0.5;
}

.conv-small {
    padding: 8px 6px;
    font-size: 13px;
    text-align: center;
}

.conv-readonly {
    padding: 10px 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-xs);
    color: var(--text-muted);
    font-size: 14px;
}

/* Hide number spinners */
.conv-input[type="number"]::-webkit-inner-spin-button,
.conv-input[type="number"]::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}
.conv-input[type="number"] {
    -moz-appearance: textfield;
}

/* ========================================
   Contrast Checker
   ======================================== */
.section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-title::before {
    content: '';
    width: 3px;
    height: 18px;
    background: var(--accent);
    border-radius: 2px;
    flex-shrink: 0;
}

.contrast-section {
    margin-bottom: 28px;
}

.contrast-inputs {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 16px;
}

.contrast-field {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.contrast-field label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.contrast-vs {
    font-size: 12px;
    color: var(--text-muted);
    padding-bottom: 12px;
    font-weight: 600;
}

.contrast-swatch {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    flex-shrink: 0;
    border: 2px solid var(--border);
    margin-bottom: 2px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.contrast-result {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: background-color var(--transition-slow);
}

.contrast-ratio {
    text-align: center;
    margin-bottom: 12px;
}

.contrast-number {
    font-size: 40px;
    font-weight: 800;
    font-family: var(--font-mono);
    letter-spacing: -1px;
}

.contrast-label {
    font-size: 18px;
    color: var(--text-muted);
    font-weight: 600;
}

.contrast-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: center;
    margin-bottom: 14px;
}

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: var(--transition);
}

.badge-pass {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid var(--success-border);
}

.badge-fail {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid var(--danger-border);
}

.contrast-preview {
    padding: 14px;
    border-radius: 8px;
    text-align: center;
    font-size: 15px;
    line-height: 1.5;
    transition: var(--transition);
}

/* ========================================
   Tints & Shades
   ======================================== */
.tints-section {
    margin-bottom: 20px;
}

.tints-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
}

.tint-cell {
    aspect-ratio: 1;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s;
    position: relative;
}

.tint-cell:hover {
    transform: scale(1.08);
    z-index: 2;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

.tint-cell:active {
    transform: scale(0.95);
}

.tint-cell-label {
    font-size: 9px;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(0,0,0,0.35);
    color: #fff;
    backdrop-filter: blur(4px);
}

.tints-row-label {
    grid-column: 1 / -1;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 0 4px;
}

/* ========================================
   Extract Tab
   ======================================== */
.extract-panel {
    padding: 20px 16px 100px;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
}

.extract-upload {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 48px 24px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    min-height: 280px;
    background: var(--accent-subtle);
}

.extract-upload:hover,
.extract-upload.drag-over {
    border-color: var(--accent);
    background: rgba(108, 92, 231, 0.08);
}

.extract-upload.drag-over {
    background: rgba(108, 92, 231, 0.12);
    transform: scale(1.01);
}

.extract-upload-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.extract-upload-sub {
    font-size: 13px;
    color: var(--text-muted);
}

.extract-upload-buttons {
    display: flex;
    gap: 10px;
    margin-top: 8px;
}

.extract-results.hidden {
    display: none;
}

.extract-image-wrap {
    position: relative;
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-bottom: 20px;
    background: var(--bg-elevated);
    box-shadow: var(--shadow-md);
}

.extract-image-wrap canvas {
    width: 100%;
    height: auto;
    display: block;
}

.btn-icon-sm {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.6);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    backdrop-filter: blur(8px);
}

.btn-icon-sm:hover {
    background: rgba(255,71,87,0.8);
}

.btn-icon-sm:active {
    transform: scale(0.9);
}

.extract-colors {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.extract-swatch {
    flex: 1;
    min-width: 48px;
    min-height: 72px;
    border-radius: var(--radius-sm);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding: 6px 4px;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s;
    position: relative;
}

.extract-swatch:hover {
    transform: scale(1.06);
}

.extract-swatch:active {
    transform: scale(0.95);
}

.extract-swatch.selected {
    box-shadow: 0 0 0 3px var(--accent), 0 0 0 5px var(--bg);
}

.extract-swatch-label {
    font-size: 9px;
    font-weight: 700;
    font-family: var(--font-mono);
    padding: 2px 4px;
    border-radius: 3px;
    background: rgba(0,0,0,0.4);
    color: #fff;
    backdrop-filter: blur(4px);
}

.extract-swatch-pct {
    font-size: 8px;
    color: rgba(255,255,255,0.7);
    margin-top: 2px;
}

/* ========================================
   Saved Tab
   ======================================== */
.saved-panel {
    padding: 20px 16px 100px;
    max-width: 520px;
    margin: 0 auto;
    width: 100%;
}

.save-current-section {
    margin-bottom: 24px;
}

.save-current-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.save-preview-strip {
    display: flex;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.save-preview-strip > div {
    flex: 1;
    transition: flex 0.3s ease;
}

.save-preview-strip > div:hover {
    flex: 1.5;
}

/* Export Section */
.export-section {
    margin-bottom: 28px;
}

.export-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-elevated);
    color: var(--text);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.export-btn:hover {
    border-color: var(--accent);
    background: var(--accent-subtle);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.export-btn:active {
    transform: translateY(0) scale(0.98);
}

.export-icon {
    font-size: 18px;
    width: 28px;
    text-align: center;
    flex-shrink: 0;
}

/* Saved Palettes List */
.saved-list-section {
    margin-bottom: 28px;
}

.saved-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.saved-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
    padding: 32px 24px;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--accent-subtle);
}

.saved-item {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: var(--transition);
    border: 1px solid var(--border);
    animation: slideUp 0.3s ease;
}

.saved-item:hover {
    border-color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.saved-item-colors {
    display: flex;
    height: 40px;
}

.saved-item-colors > div {
    flex: 1;
    transition: flex 0.2s ease;
}

.saved-item-colors:hover > div:hover {
    flex: 1.5;
}

.saved-item-info {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
}

.saved-item-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.saved-item-date {
    font-size: 11px;
    color: var(--text-muted);
}

.saved-item-actions {
    display: flex;
    gap: 6px;
}

.saved-item-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.saved-item-btn:hover {
    background: var(--bg-card);
    color: var(--text);
}

.saved-item-btn:active {
    transform: scale(0.9);
}

.saved-item-btn.delete:hover {
    color: var(--danger);
    border-color: var(--danger-border);
    background: var(--danger-bg);
}

/* Trending Section */
.trending-section {
    margin-bottom: 28px;
}

.trending-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.trending-item {
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    overflow: hidden;
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid var(--border);
}

.trending-item:hover {
    border-color: var(--accent);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.trending-item:active {
    transform: translateY(0) scale(0.99);
}

.trending-item-colors {
    display: flex;
    height: 44px;
}

.trending-item-colors > div {
    flex: 1;
    transition: flex 0.2s ease;
}

.trending-item:hover .trending-item-colors > div:first-child {
    flex: 1.3;
}

.trending-item-info {
    padding: 10px 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.trending-item-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
}

.trending-item-apply {
    font-size: 11px;
    color: var(--accent);
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.2s;
}

.trending-item:hover .trending-item-apply {
    opacity: 1;
}

/* Save Modal */
.save-modal-body {
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.save-preview-mini {
    display: flex;
    height: 48px;
    border-radius: var(--radius-sm);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.save-preview-mini > div {
    flex: 1;
}

.save-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Export Modal */
.export-modal-body {
    padding: 20px;
}

.export-code {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    font-family: var(--font-mono);
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
    overflow-x: auto;
    margin-bottom: 16px;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 320px;
    overflow-y: auto;
    transition: background-color var(--transition-slow), border-color var(--transition-slow);
}

/* ========================================
   Responsive — Portrait phones
   ======================================== */
@media (max-width: 600px) {
    .palette-container {
        flex-direction: column;
    }

    .color-strip {
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        padding: 0 16px;
    }

    .color-strip:hover {
        flex: 1.2;
    }

    .color-info {
        width: auto;
        max-width: none;
        text-align: left;
        background: rgba(0,0,0,0.4);
        padding: 8px 12px;
    }

    .strip-actions {
        opacity: 1;
        transform: none;
        margin-bottom: 0;
        margin-right: 12px;
    }

    .color-hex {
        font-size: 16px;
    }

    .color-values {
        font-size: 11px;
    }

    .hint-bar {
        display: none;
    }

    .tab-content {
        height: calc(100vh - var(--header-height) - var(--nav-height));
    }

    .tints-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    .harmony-result {
        flex-wrap: wrap;
    }

    .harmony-swatch {
        min-width: calc(33% - 8px);
    }

    .nav-item {
        padding: 8px 6px;
        font-size: 9px;
    }

    .nav-item svg {
        width: 18px;
        height: 18px;
    }

    .converter-preview::after {
        display: none;
    }

    .trending-item-apply {
        opacity: 1;
    }

    .lock-indicator {
        font-size: 9px !important;
    }
}

/* ========================================
   Desktop enhancements
   ======================================== */
@media (min-width: 601px) {
    .modal-content {
        border-radius: var(--radius);
        max-width: 420px;
        margin-bottom: 10vh;
    }

    .modal {
        align-items: center;
    }

    .modal.hidden .modal-content {
        transform: translateY(20px);
    }
}

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

button:focus:not(:focus-visible) {
    outline: none;
}

/* ========================================
   Reduced motion
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ========================================
   Print styles
   ======================================== */
@media print {
    .bottom-nav, .app-header, .hint-bar {
        display: none !important;
    }
    .tab-content {
        height: auto !important;
        overflow: visible !important;
    }
    .palette-container {
        height: 200px !important;
    }
}

/* ========================================
   PWA Install Banner
   ======================================== */
.install-banner {
    position: fixed;
    bottom: calc(var(--nav-height) + 8px);
    left: 50%;
    transform: translateX(-50%) translateY(120px);
    z-index: 1000;
    width: calc(100% - 32px);
    max-width: 460px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
}

.install-banner.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
    pointer-events: auto;
}

.install-banner.hidden {
    display: none;
}

.install-banner-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    box-shadow: 0 8px 32px rgba(108, 92, 231, 0.25), 0 2px 8px rgba(0,0,0,0.15);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.install-banner-icon {
    font-size: 28px;
    flex-shrink: 0;
    line-height: 1;
}

.install-banner-text {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.install-banner-text strong {
    font-size: 14px;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.install-banner-text span {
    font-size: 12px;
    color: var(--text-muted);
}

.install-btn {
    flex-shrink: 0;
    padding: 8px 16px !important;
    font-size: 13px !important;
}

.install-dismiss {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.install-dismiss:hover {
    color: var(--text);
    background: var(--bg-elevated);
}

/* ========================================
   Offline Indicator
   ======================================== */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.show {
    transform: translateY(0);
}

.offline-indicator.hidden {
    transform: translateY(-100%);
}

.offline-indicator svg {
    flex-shrink: 0;
}

/* ========================================
   Standalone PWA adjustments
   ======================================== */
@media (display-mode: standalone) {
    .install-banner {
        display: none !important;
    }

    /* Safe area insets for notched phones */
    .app-header {
        padding-top: env(safe-area-inset-top, 0);
    }

    .bottom-nav {
        padding-bottom: env(safe-area-inset-bottom, 0);
    }

    body {
        padding-top: env(safe-area-inset-top, 0);
        padding-bottom: env(safe-area-inset-bottom, 0);
    }
}
