:root {
    /* ---- LIGHT THEME (default) ---- */
    /* Color Palette */
    --bg-base: #f4f1ec;
    --bg-surface: #ffffff;
    --bg-elevated: #faf7f2;
    --bg-hover: #efe9e1;
    --bg-overlay: rgba(40, 34, 30, 0.45);

    /* Text Colors */
    --text-primary: #221f1c;
    --text-secondary: #4f4842;
    --text-tertiary: #7a726a;
    --text-muted: #a49b91;

    /* Accent Colors */
    --accent: #a5675d;
    --accent-hover: #8f544b;
    --accent-muted: #cca69e;
    --accent-subtle: rgba(165, 103, 93, 0.1);
    --accent-glow: rgba(165, 103, 93, 0.22);

    /* Status Colors */
    --success: #3f7a52;
    --success-bg: rgba(63, 122, 82, 0.12);
    --error: #c1544f;
    --error-bg: rgba(193, 84, 79, 0.12);

    /* Borders */
    --border-subtle: rgba(34, 31, 28, 0.08);
    --border-light: rgba(34, 31, 28, 0.13);
    --border-medium: rgba(34, 31, 28, 0.2);

    /* Spacing */
    --space-2xs: 0.125rem;
    --space-xs:  0.25rem;
    --space-sm:  0.5rem;
    --space-md:  1rem;
    --space-lg:  1.5rem;
    --space-xl:  2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;

    /* Typography */
    --font-display: 'Crimson Text', Georgia, serif;
    --font-sans: 'Inter', -apple-system, system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', monospace;

    /* Animations */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

    /* Shadows */
    --shadow-soft:   0 2px 12px rgba(60, 50, 44, 0.08);
    --shadow-medium: 0 8px 28px rgba(60, 50, 44, 0.12);
    --shadow-large:  0 20px 50px rgba(60, 50, 44, 0.18);
    --shadow-glow:   0 0 40px var(--accent-glow);

    /* Layout */
    --header-height: 3.75rem;
    --content-max-width: 1280px;
    --card-radius: 0.75rem;
    --button-radius: 0.5rem;
    --ai-panel-width: 380px;

    color-scheme: light;
}

/* ============================================
   DARK THEME OVERRIDE
   ============================================ */
:root[data-theme="dark"] {
    --bg-base: #0a0908;
    --bg-surface: #121110;
    --bg-elevated: #1a1816;
    --bg-hover: #252220;
    --bg-overlay: rgba(10, 9, 8, 0.85);

    --text-primary: #faf8f6;
    --text-secondary: #b8b0a8;
    --text-tertiary: #8a827a;
    --text-muted: #605b56;

    --accent: #b8796f;
    --accent-hover: #c68d83;
    --accent-muted: #8e5a51;
    --accent-subtle: rgba(184, 121, 111, 0.08);
    --accent-glow: rgba(184, 121, 111, 0.2);

    --success: #4a7c59;
    --success-bg: rgba(74, 124, 89, 0.1);
    --error: #c65d5d;
    --error-bg: rgba(198, 93, 93, 0.1);

    --border-subtle: rgba(250, 248, 246, 0.06);
    --border-light: rgba(250, 248, 246, 0.1);
    --border-medium: rgba(250, 248, 246, 0.15);

    --shadow-soft:   0 4px 24px rgba(0, 0, 0, 0.12);
    --shadow-medium: 0 8px 40px rgba(0, 0, 0, 0.16);
    --shadow-large:  0 24px 64px rgba(0, 0, 0, 0.24);

    color-scheme: dark;
}

/* Smooth theme transition */
body, header, .filter-bar, .wardrobe-item, .modal-content,
.sheet-content, .outfit-builder-panel, .ai-chat-panel, .btn-secondary,
.menu-toggle, .form-group input, .form-group select, .form-group textarea {
    transition: background-color 0.3s var(--ease-out), border-color 0.3s var(--ease-out), color 0.3s var(--ease-out);
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3 {
    font-family: var(--font-display);
    font-weight: 400;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

h1 { font-size: 2.25rem; font-weight: 300; }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }

p { line-height: 1.7; color: var(--text-secondary); }

.hidden { display: none !important; }

/* ============================================
   AUTH SCREEN
   ============================================ */

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
    background:
        radial-gradient(ellipse at top, var(--bg-elevated) 0%, transparent 60%),
        radial-gradient(ellipse at bottom, var(--accent-subtle) 0%, transparent 60%),
        var(--bg-base);
}

.login-box {
    width: 100%;
    max-width: 400px;
    text-align: center;
    animation: authReveal 0.5s ease-out both;
}

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

.logo-mark {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-xl);
    background: linear-gradient(135deg, var(--accent) 0%, var(--accent-muted) 100%);
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-display);
    font-size: 2rem;
    font-weight: 300;
    color: white;
    box-shadow: var(--shadow-large);
    position: relative;
    overflow: hidden;
}

/* Static sheen (no infinite motion — the constant sweep read as the screen "moving") */
.logo-mark::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, rgba(255,255,255,0.14) 0%, transparent 45%);
    pointer-events: none;
}

.login-box h1 { margin-bottom: var(--space-sm); }
.login-box p { margin-bottom: var(--space-xl); }

.login-box input[type="password"] {
    width: 100%;
    padding: 1rem 1.25rem;
    background: var(--bg-surface);
    border: 2px solid var(--border-subtle);   /* fixed 2px so focus doesn't change box size */
    border-radius: var(--button-radius);
    color: var(--text-primary);
    /* 16px min avoids mobile focus-zoom/reflow "bounce" */
    font-size: 16px;
    font-family: var(--font-sans);
    margin-bottom: var(--space-md);
    margin-top: var(--space-xl);
    text-align: center;
    -webkit-appearance: none;
    appearance: none;
    /* No transition/animation on focus — prevents any bounce */
    transition: none;
}

.login-box input[type="password"]:focus,
.login-box input[type="password"]:focus-visible {
    outline: none;
    border-color: var(--accent);
    background: var(--bg-surface);
    box-shadow: none;
    transition: none;
    animation: none;
}

.login-box button { width: 100%; padding: 1rem; }

/* ============================================
   USER SELECTION
   ============================================ */

.user-selection-screen {
    min-height: 100vh;
    background: radial-gradient(ellipse at top, var(--bg-elevated) 0%, transparent 60%), var(--bg-base);
    padding: var(--space-2xl) var(--space-xl);
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-selection-container {
    max-width: 760px;
    width: 100%;
    animation: fadeInUp 0.6s var(--ease-out);
}

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

.user-selection-header {
    text-align: center;
    margin-bottom: var(--space-3xl);
}

.user-selection-header .logo-mark {
    width: 56px;
    height: 56px;
    font-size: 1.375rem;
    border-radius: 14px;
    margin-bottom: var(--space-lg);
}

.user-selection-header h1 { margin-bottom: var(--space-sm); }
.user-selection-header p  { color: var(--text-tertiary); }

.user-selection-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-xl);
}

.user-select-card {
    background: var(--bg-surface);
    border: 2px solid var(--border-subtle);
    border-radius: var(--card-radius);
    padding: var(--space-xl);
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    text-align: center;
    position: relative;
    overflow: hidden;
}

.user-select-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent), var(--accent-muted));
    transform: scaleX(0);
    transition: transform 0.3s var(--ease-out);
}

.user-select-card:hover {
    border-color: var(--accent-muted);
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

.user-select-card:hover::before { transform: scaleX(1); }

.user-select-avatar {
    width: 72px;
    height: 72px;
    margin: 0 auto var(--space-md);
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.75rem;
    font-weight: 600;
    color: white;
    box-shadow: var(--shadow-soft);
}

.user-select-name { font-size: 1.125rem; font-weight: 500; }
.user-select-meta { color: var(--text-tertiary); font-size: 0.8125rem; margin-top: var(--space-xs); }

/* ============================================
   BUTTONS
   ============================================ */

button {
    font-family: var(--font-sans);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    border: none;
}

button:active { transform: scale(0.97); }

.btn-primary {
    padding: 0.8rem 1.5rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    color: white;
    border-radius: var(--button-radius);
    font-size: 0.9375rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    box-shadow: var(--shadow-soft);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-medium), 0 8px 24px var(--accent-glow);
}

.btn-secondary {
    padding: 0.75rem 1.25rem;
    background: var(--bg-elevated);
    color: var(--text-primary);
    border: 1px solid var(--border-light);
    border-radius: var(--button-radius);
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.btn-secondary:hover {
    background: var(--bg-hover);
    border-color: var(--border-medium);
}

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    padding: 0;
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.btn-link:hover { opacity: 0.75; }

.btn-ghost {
    padding: var(--space-sm);
    background: transparent;
    color: var(--text-tertiary);
    border-radius: var(--button-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-ghost:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.btn-sm { padding: 0.5rem 0.875rem; font-size: 0.8125rem; }

.close-btn {
    width: 32px;
    height: 32px;
    padding: 0;
    flex-shrink: 0;
}

.required { color: var(--accent); font-weight: 700; }

/* ============================================
   NAVIGATION / HEADER
   ============================================ */

header {
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    padding: 0 var(--space-xl);
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 200;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.logo-mark.small {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    border-radius: 10px;
    margin: 0;
    flex-shrink: 0;
}

.nav-brand span {
    font-family: var(--font-display);
    font-size: 1.125rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* AI Header Button */
.ai-header-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: var(--accent-subtle);
    border: 1px solid var(--accent-muted);
    border-radius: var(--button-radius);
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 500;
    position: relative;
    transition: all 0.2s var(--ease-out);
}

.ai-header-btn:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--accent-glow);
}

.ai-header-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

.ai-btn-label { display: none; }

@media (min-width: 480px) {
    .ai-btn-label { display: inline; }
}

.ai-chat-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    border: 2px solid var(--bg-surface);
    animation: badgePulse 2s infinite;
}

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

.user-menu { position: relative; }

.menu-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 0.5rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 0.8125rem;
    max-width: 160px;
}

.menu-toggle span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.menu-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--border-light);
}

.dropdown {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--card-radius);
    min-width: 200px;
    box-shadow: var(--shadow-large);
    overflow: hidden;
    z-index: 300;
}

.dropdown-item {
    width: 100%;
    padding: 0.75rem 1.125rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    text-align: left;
    cursor: pointer;
    font-size: 0.875rem;
    transition: background 0.2s;
}

.dropdown-item:hover { background: var(--bg-hover); }
.dropdown-item.active { color: var(--accent); }

.dropdown hr {
    height: 1px;
    background: var(--border-subtle);
    border: none;
    margin: 0;
}

/* ============================================
   AI CHAT PANEL
   ============================================ */

.ai-chat-overlay {
    position: fixed;
    inset: 0;
    background: rgba(10, 9, 8, 0.6);
    backdrop-filter: blur(4px);
    z-index: 400;
    animation: fadeIn 0.25s var(--ease-out);
}

.ai-chat-panel {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--ai-panel-width);
    max-width: 100vw;
    background: var(--bg-surface);
    border-left: 1px solid var(--border-light);
    box-shadow: -8px 0 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    z-index: 500;
    animation: slideInRight 0.35s var(--ease-out);
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to   { transform: translateX(0); opacity: 1; }
}

.ai-chat-panel.closing {
    animation: slideOutRight 0.3s var(--ease-out) forwards;
}

@keyframes slideOutRight {
    from { transform: translateX(0); opacity: 1; }
    to   { transform: translateX(100%); opacity: 0; }
}

.ai-chat-header {
    padding: 1rem var(--space-md);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ai-chat-title {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--accent);
}

.ai-chat-controls {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
}

.ai-clear-btn { opacity: 0.6; }
.ai-clear-btn:hover { opacity: 1; }

.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: var(--space-md);
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    scroll-behavior: smooth;
}

/* Chat Bubbles */
.chat-bubble {
    display: flex;
    gap: var(--space-sm);
    align-items: flex-start;
    animation: bubbleIn 0.3s var(--ease-out);
}

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

.chat-bubble.user {
    flex-direction: row-reverse;
}

.chat-bubble-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.chat-bubble.user .chat-bubble-avatar {
    background: var(--bg-elevated);
    color: var(--text-tertiary);
}

.chat-bubble-content {
    max-width: calc(100% - 44px);
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.875rem;
    line-height: 1.65;
}

.chat-bubble.assistant .chat-bubble-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    border-radius: 4px 12px 12px 12px;
}

.chat-bubble.user .chat-bubble-content {
    background: var(--accent);
    color: white;
    border-radius: 12px 4px 12px 12px;
}

.chat-bubble-content strong { color: var(--text-primary); font-weight: 600; }
.chat-bubble.user .chat-bubble-content strong { color: white; }

.chat-bubble-content p { color: inherit; margin-bottom: 0.5rem; }
.chat-bubble-content p:last-child { margin-bottom: 0; }

.chat-bubble-content ul,
.chat-bubble-content ol {
    margin: 0.5rem 0;
    padding-left: 1.25rem;
}

.chat-bubble-content li { margin-bottom: 0.25rem; }

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 0.75rem 1rem;
}

.typing-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-muted);
    animation: typingBounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* Quick suggestions */
.ai-chat-suggestions {
    padding: 0 var(--space-md) var(--space-sm);
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.ai-chat-suggestions button {
    padding: 0.375rem 0.75rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-tertiary);
    font-size: 0.75rem;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-chat-suggestions button:hover {
    border-color: var(--accent-muted);
    color: var(--accent);
    background: var(--accent-subtle);
}

.ai-chat-suggestions.hidden { display: none; }

/* Input area */
.ai-chat-input-area {
    padding: var(--space-md);
    background: var(--bg-elevated);
    border-top: 1px solid var(--border-subtle);
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.ai-chat-input-area input {
    flex: 1;
    padding: 0.75rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    transition: all 0.2s var(--ease-out);
}

.ai-chat-input-area input:focus {
    outline: none;
    border-color: var(--accent-muted);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.ai-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.ai-send-btn:hover {
    background: var(--accent-hover);
    transform: scale(1.08);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mobile: AI panel becomes bottom sheet */
@media (max-width: 600px) {
    .ai-chat-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-height: 85vh;
        border-left: none;
        border-top: 1px solid var(--border-light);
        border-radius: 1.25rem 1.25rem 0 0;
        animation: slideInUp 0.35s var(--ease-out);
    }

    @keyframes slideInUp {
        from { transform: translateY(100%); }
        to   { transform: translateY(0); }
    }
}

/* ============================================
   FILTER BAR
   ============================================ */

.filter-bar {
    padding: 0.75rem var(--space-xl);
    display: flex;
    align-items: center;
    gap: var(--space-md);
    position: relative;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
}

.filter-chips {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    flex: 1;
}

.filter-chip {
    padding: 0.3rem 0.75rem;
    background: var(--accent-subtle);
    border: 1px solid var(--accent-muted);
    border-radius: 20px;
    color: var(--accent);
    font-size: 0.8125rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.filter-chip button {
    background: transparent;
    border: none;
    color: var(--accent);
    cursor: pointer;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.7;
}

.filter-chip button:hover { opacity: 1; }

.filter-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--button-radius);
    color: var(--text-secondary);
    font-size: 0.8125rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    white-space: nowrap;
    flex-shrink: 0;
}

.filter-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.filter-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: var(--space-xl);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    border-radius: var(--card-radius);
    padding: var(--space-lg);
    min-width: 300px;
    box-shadow: var(--shadow-large);
    z-index: 150;
}

.filter-group { margin-bottom: 1.125rem; }
.filter-group:last-child { margin-bottom: 0; }

.filter-group label {
    display: block;
    color: var(--text-tertiary);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.375rem;
}

.filter-group select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a827a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--accent-muted);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* ============================================
   MAIN CONTENT / WARDROBE GRID
   ============================================ */

main {
    padding: var(--space-xl);
    max-width: var(--content-max-width);
    margin: 0 auto;
    /* Extra bottom padding for FAB + outfit toggle */
    padding-bottom: 8rem;
}

.wardrobe-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-xl);
}

.wardrobe-header h2 {
    font-family: var(--font-display);
    font-size: 1.625rem;
}

.view-toggle {
    display: flex;
    gap: var(--space-xs);
    padding: var(--space-xs);
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
}

.view-toggle button {
    padding: 0.4rem 0.875rem;
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: calc(var(--button-radius) - 2px);
    font-size: 0.8125rem;
    transition: all 0.2s;
}

.view-toggle button.active {
    background: var(--bg-elevated);
    color: var(--accent);
    font-weight: 500;
}

.wardrobe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--space-lg);
}

.wardrobe-item {
    background: var(--bg-surface);
    border-radius: var(--card-radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    border: 1px solid var(--border-subtle);
}

.wardrobe-item:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-large);
    border-color: var(--border-light);
}

.wardrobe-item-image {
    aspect-ratio: 3/4;
    overflow: hidden;
    background: var(--bg-elevated);
    position: relative;
}

.wardrobe-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s var(--ease-out);
}

.wardrobe-item:hover .wardrobe-item-image img { transform: scale(1.06); }

.item-info { padding: 1rem; }

.item-info h3 {
    font-size: 0.9375rem;
    font-weight: 500;
    margin-bottom: 0.4rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.item-meta {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.item-tag {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.item-tag.color-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

.color-indicator {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 1px solid var(--border-light);
    flex-shrink: 0;
}

/* Empty state */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-tertiary);
}

.empty-state p { color: var(--text-tertiary); margin-top: var(--space-sm); }
.empty-state p:last-child { font-size: 0.875rem; margin-top: var(--space-xs); }

/* Saved Outfits */
.saved-outfits-section { margin-top: 0; }

.saved-outfits-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--space-lg);
}

.saved-outfit-card {
    background: var(--bg-elevated);
    border-radius: var(--card-radius);
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    border: 1px solid var(--border-subtle);
    position: relative;
}

.saved-outfit-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
    border-color: var(--border-light);
}

.saved-outfit-preview {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    aspect-ratio: 1;
    background: var(--bg-surface);
    position: relative;
    overflow: hidden;
}

.saved-outfit-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.more-items {
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    font-size: 0.8125rem;
    font-weight: 600;
}

.saved-outfit-info {
    padding: 0.875rem;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.saved-outfit-name {
    font-weight: 500;
    font-size: 0.875rem;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.saved-outfit-date {
    font-size: 0.6875rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.saved-outfit-info .btn-ghost {
    width: 28px;
    height: 28px;
    padding: 0;
    flex-shrink: 0;
    opacity: 0.5;
    font-size: 1.1rem;
    line-height: 1;
}

.saved-outfit-info .btn-ghost:hover { opacity: 1; color: var(--error); }

/* ============================================
   FAB
   ============================================ */

.fab {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 56px;
    height: 56px;
    border-radius: 18px;
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-large), 0 0 20px var(--accent-glow);
    z-index: 100;
    font-size: 22px;
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
}

.fab:hover {
    transform: scale(1.1) rotate(90deg);
    box-shadow: var(--shadow-large), 0 0 30px var(--accent-glow);
}

/* ============================================
   OUTFIT BUILDER TOGGLE
   ============================================ */

.outfit-builder-toggle {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0 1rem;
    height: 44px;
    border-radius: 22px;
    background: var(--bg-elevated);
    border: 1.5px solid var(--accent-muted);
    color: var(--accent);
    box-shadow: var(--shadow-medium);
    z-index: 100;
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    white-space: nowrap;
}

.outfit-builder-toggle:hover {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    transform: translateY(-2px);
}

.outfit-toggle-label {
    font-size: 0.8125rem;
    font-weight: 500;
}

/* ============================================
   OUTFIT BUILDER PANEL
   ============================================ */

.outfit-builder-panel {
    position: fixed;
    inset: 0;
    background: var(--bg-base);
    border-top: none;
    max-height: none;
    height: 100%;
    transform: translateY(100%);
    transition: transform 0.4s var(--ease-out);
    z-index: 600;
    display: flex;
    flex-direction: column;
}

.outfit-builder-panel.active { transform: translateY(0); }

.outfit-builder-header {
    padding: 0.85rem var(--space-lg);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-shrink: 0;
    box-shadow: var(--shadow-soft);
}

.outfit-builder-title {
    font-size: 1.0625rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    white-space: nowrap;
}
.outfit-builder-title svg { color: var(--accent); }

.outfit-builder-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.outfit-builder-content {
    overflow-y: auto;
    padding: var(--space-xl) var(--space-lg);
    flex: 1;
}

/* Center the builder content for readability on large screens */
.outfit-builder-content .outfit-rows {
    max-width: 720px;
    margin-left: auto;
    margin-right: auto;
}

.outfit-rows {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
}

.outfit-row {
    background: var(--bg-surface);
    border-radius: var(--card-radius);
    padding: var(--space-lg);
    border: 1px solid var(--border-subtle);
    box-shadow: var(--shadow-soft);
    transition: border-color 0.2s;
}

.outfit-row:hover { border-color: var(--border-light); }

.outfit-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.outfit-name-input {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-weight: 600;
    font-family: var(--font-sans);
    padding: 0.3rem 0.5rem;
    border-radius: var(--button-radius);
    transition: all 0.2s;
    flex: 1;
    min-width: 0;
}

.outfit-name-input:hover,
.outfit-name-input:focus {
    background: var(--bg-surface);
    border-color: var(--border-light);
    outline: none;
}

.outfit-row-actions {
    display: flex;
    gap: var(--space-xs);
    flex-shrink: 0;
}

.outfit-row-actions .btn-ghost {
    width: 28px;
    height: 28px;
    padding: 0;
}

.outfit-slots {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: var(--space-sm);
}

.outfit-slot {
    aspect-ratio: 3/4;
    background: var(--bg-elevated);
    border: 1.5px dashed var(--border-medium);
    border-radius: var(--card-radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    cursor: pointer;
    transition: all 0.25s var(--ease-out);
    position: relative;
    overflow: hidden;
}

/* "+" affordance for empty slots */
.outfit-slot:not(.filled)::before {
    content: '+';
    font-size: 1.5rem;
    font-weight: 300;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.2s;
}
.outfit-slot:not(.filled):hover::before { color: var(--accent); }

.outfit-slot:hover {
    border-color: var(--accent-muted);
    background: var(--bg-hover);
    transform: translateY(-2px);
}

.outfit-slot:active { transform: scale(0.97); }

.outfit-slot.filled {
    border-style: solid;
    border-color: var(--border-medium);
}

.outfit-slot-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.outfit-slot-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.75), transparent);
    color: white;
    padding: 0.3rem 0.25rem;
    font-size: 0.625rem;
    text-align: center;
    font-weight: 500;
}

.outfit-slot-placeholder {
    color: var(--text-muted);
    font-size: 0.6875rem;
    text-align: center;
    padding: 0 0.25rem;
}

.outfit-slot-remove {
    position: absolute;
    top: 3px;
    right: 3px;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.7);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
    color: white;
    font-size: 0.875rem;
    line-height: 1;
    border: none;
}

.outfit-slot.filled:hover .outfit-slot-remove { opacity: 1; }

.add-outfit-row {
    padding: 0.875rem;
    background: var(--bg-elevated);
    border: 1.5px dashed var(--border-light);
    border-radius: var(--card-radius);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
    color: var(--text-tertiary);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.add-outfit-row:hover {
    border-color: var(--accent-muted);
    color: var(--accent);
    background: var(--accent-subtle);
}

/* Accessories */
.accessory-thumb {
    position: relative;
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid var(--border-subtle);
    display: inline-block;
    margin: 2px;
    flex-shrink: 0;
}

.accessory-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.accessory-remove {
    position: absolute;
    top: 0; right: 0;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 0.75rem;
    line-height: 1;
    padding: 0 0.2rem;
    border-radius: 0 0 0 4px;
}

.accessories-wrap {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    width: 100%;
    height: 100%;
    align-content: center;
    justify-content: center;
    padding: 4px;
}

/* Fullscreen toggle button */
#expandOutfitBtn {
    width: 30px;
    height: 30px;
    padding: 0;
}

/* ============================================
   ITEM SELECTOR MODAL
   ============================================ */

.item-selector-modal {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl);
}

.item-selector-modal .modal-backdrop {
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s var(--ease-out);
    z-index: -1;
}

.item-selector-content {
    width: 100%;
    max-width: 780px;
    max-height: 82vh;
    background: var(--bg-surface);
    border-radius: var(--card-radius);
    overflow: hidden;
    animation: modalSlideUp 0.35s var(--ease-out);
    box-shadow: var(--shadow-large);
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(24px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.item-selector-header {
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.item-selector-subtitle {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.item-selector-filters {
    padding: var(--space-sm) var(--space-lg);
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    gap: var(--space-sm);
    flex-wrap: nowrap;
    overflow-x: auto;
    flex-shrink: 0;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.item-selector-filters::-webkit-scrollbar { display: none; }

.item-selector-filters button {
    padding: 0.375rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-secondary);
    font-size: 0.8125rem;
    white-space: nowrap;
    flex-shrink: 0;
    transition: all 0.2s;
}

.item-selector-filters button:hover {
    border-color: var(--accent-muted);
    color: var(--accent);
}

.item-selector-filters button.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

/* Picker layout is defined once, authoritatively, in the V12 block below. */
.item-selector-grid {
    padding: var(--space-md) var(--space-lg);
    overflow-y: auto;
    flex: 1;
}

.color-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid var(--border-light);
}

/* ============================================
   MODALS & SHEETS
   ============================================ */

.sheet, .modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-end;
}

.modal {
    align-items: center;
    justify-content: center;
    padding: var(--space-xl) var(--space-md);
}

.sheet-backdrop, .modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s var(--ease-out);
}

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

.sheet-content {
    position: relative;
    width: 100%;
    max-width: 600px;
    max-height: 88vh;
    margin: 0 auto;
    background: var(--bg-surface);
    border-radius: 1.25rem 1.25rem 0 0;
    overflow-y: auto;
    animation: slideUp 0.4s var(--ease-out);
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.modal-content {
    position: relative;
    width: 100%;
    max-width: 680px;
    max-height: 88vh;
    background: var(--bg-surface);
    border-radius: 1.125rem;
    overflow: hidden;
    animation: scaleIn 0.3s var(--ease-out);
    display: flex;
    flex-direction: column;
}

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

.modal-body {
    overflow-y: auto;
    flex: 1;
}

.sheet-header, .modal-header {
    position: sticky;
    top: 0;
    background: var(--bg-surface);
    padding: 1.125rem 1.5rem;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10;
    flex-shrink: 0;
}

/* ============================================
   FORMS
   ============================================ */

.add-form {
    padding: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    color: var(--text-tertiary);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 0.5rem;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    transition: all 0.2s var(--ease-out);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--accent-muted);
    background: var(--bg-hover);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.form-group select {
    width: 100%;
    padding: 0.75rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%238a827a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.25rem;
    transition: all 0.2s var(--ease-out);
}

.form-group select:focus {
    outline: none;
    border-color: var(--accent-muted);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.form-group select option {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
}

.form-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.form-actions button { flex: 1; }

/* Color input */
.color-input-group {
    display: flex;
    align-items: stretch;
    gap: var(--space-sm);
}

.color-text-input {
    flex: 1;
    min-width: 0;
}

.color-eyedropper-btn {
    flex-shrink: 0;
    width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s var(--ease-out);
}
.color-eyedropper-btn:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--accent-muted);
}

.color-picker-button {
    position: relative;
    flex-shrink: 0;
    width: 44px;
    border-radius: var(--button-radius);
    border: 1px solid var(--border-subtle);
    cursor: pointer;
    overflow: hidden;
}

.color-picker-input {
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    position: absolute;
    inset: 0;
}

.color-display-square {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.color-resolve-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.4rem;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: color 0.2s;
}
.color-resolve-hint::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--text-muted);
    flex-shrink: 0;
}
.color-resolve-hint.resolved { color: var(--success); }
.color-resolve-hint.resolved::before { background: var(--success); }
.color-resolve-hint.unresolved { color: var(--text-tertiary); }
.color-resolve-hint.unresolved::before { background: var(--accent-muted); }

/* Image Upload */
.image-upload-area { position: relative; }

.upload-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 2.5rem 2rem;
    background: var(--bg-elevated);
    border: 2px dashed var(--border-light);
    border-radius: var(--card-radius);
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
    text-align: center;
}

.upload-area span {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

.upload-hint {
    color: var(--text-muted) !important;
    font-size: 0.75rem !important;
}

.upload-area:hover {
    border-color: var(--accent-muted);
    background: var(--bg-hover);
}

.image-preview-container { position: relative; }

.image-preview {
    width: 100%;
    max-height: 280px;
    object-fit: cover;
    border-radius: var(--card-radius);
    display: block;
}

.image-preview-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-sm);
}

.image-preview-actions label {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.btn-remove-image {
    flex: 1;
    padding: 0.5rem;
    background: var(--error-bg);
    border: 1px solid var(--error);
    border-radius: var(--button-radius);
    color: var(--error);
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-remove-image:hover {
    background: var(--error);
    color: white;
}

.image-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 2rem;
    background: var(--bg-elevated);
    border-radius: var(--card-radius);
    color: var(--text-tertiary);
    font-size: 0.875rem;
}

/* ============================================
   DETAIL SHEET
   ============================================ */

.item-detail-modal { max-width: 480px; }
/* Wider on desktop to fit the two-column layout */
@media (min-width: 720px) {
    .item-detail-modal { max-width: 760px; }
}

.detail-content { padding: var(--space-lg); }

/* Two-column layout: photo left, info right (desktop). Stacks on mobile. */
.detail-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}
.detail-media { min-width: 0; }
.detail-panel {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

@media (min-width: 720px) {
    .detail-layout {
        flex-direction: row;
        align-items: stretch;
        gap: var(--space-xl);
    }
    .detail-media { flex: 0 0 46%; }
    .detail-panel { flex: 1; }
    /* photo fills the column height, info actions pinned to the bottom */
    .detail-panel .detail-actions { margin-top: auto; }
}

/* Full item photo — contained, never cropped */
.detail-image-wrap {
    width: 100%;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--card-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    max-height: 46vh;
}
.detail-image-wrap img {
    width: 100%;
    height: auto;
    max-height: 46vh;
    object-fit: contain;      /* show the WHOLE photo */
    display: block;
}
@media (min-width: 720px) {
    .detail-image-wrap { max-height: 60vh; height: 100%; }
    .detail-image-wrap img { max-height: 60vh; }
}

/* Empty-photo placeholder */
.detail-image-empty {
    flex-direction: column;
    gap: 0.5rem;
    aspect-ratio: 3 / 4;
    color: var(--text-muted);
    font-size: 0.85rem;
}

.detail-rows {
    display: flex;
    flex-direction: column;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 0.7rem 0;
    border-bottom: 1px solid var(--border-subtle);
    gap: var(--space-lg);
}
.detail-row:last-child { border-bottom: none; }

.detail-label {
    color: var(--text-tertiary);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    flex-shrink: 0;
}

.detail-value {
    text-align: right;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
}

/* Notes: stack full-width, left-aligned, easy to read */
.detail-row-notes {
    flex-direction: column;
    align-items: stretch;
    gap: 0.4rem;
}
.detail-row-notes .detail-value {
    text-align: left;
    font-weight: 400;
    color: var(--text-secondary);
}

.color-display {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    justify-content: flex-end;
}
.color-display .color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 1px solid var(--border-medium);
}

.detail-actions {
    display: flex;
    gap: var(--space-sm);
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-subtle);
}

.detail-actions button {
    flex: 1;
    padding: 0.7rem;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    cursor: pointer;
}
.detail-actions button svg { flex-shrink: 0; }

.btn-edit {
    background: var(--bg-elevated);
    border: 1px solid var(--accent-muted);
    color: var(--accent);
    border-radius: var(--button-radius);
    font-weight: 500;
}
.btn-edit:hover { background: var(--accent-subtle); }

.btn-danger {
    background: var(--error-bg);
    border: 1px solid var(--error);
    color: var(--error);
    border-radius: var(--button-radius);
    font-weight: 500;
}
.btn-danger:hover { background: var(--error); color: #fff; }

/* ============================================
   USER MANAGER
   ============================================ */

.user-manager-container { max-width: 100%; }

.user-cards-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

.user-card {
    background: var(--bg-elevated);
    border-radius: var(--card-radius);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
}

.user-card.current { border-color: var(--accent-muted); }

.user-card-header {
    background: var(--bg-surface);
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}

.user-card-header-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.user-card-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.125rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.user-card-title {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
    min-width: 0;
}

.user-name-input {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 500;
    font-family: var(--font-sans);
    padding: 0.25rem 0.5rem;
    border-radius: var(--button-radius);
    transition: all 0.2s;
    width: 100%;
}

.user-name-input:hover { background: var(--bg-hover); }
.user-name-input:focus { outline: none; background: var(--bg-hover); border-color: var(--accent-muted); }

.user-role-badge {
    font-size: 0.6875rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 2px 6px;
    background: var(--bg-elevated);
    border-radius: 4px;
    width: fit-content;
}

.user-card-actions {
    display: flex;
    gap: var(--space-sm);
    flex-shrink: 0;
}

.user-card-body {
    padding: var(--space-md);
}

.user-attributes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
}

.attribute-field {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.attribute-label {
    color: var(--text-tertiary);
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.attribute-input {
    padding: 0.625rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
}

.attribute-input:focus {
    outline: none;
    border-color: var(--accent-muted);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

.skin-tone-section {
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}

.skin-tone-picker {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-top: var(--space-sm);
}

.skin-tone-preview {
    width: 64px;
    height: 64px;
    border-radius: var(--card-radius);
    border: 2px solid var(--border-light);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.skin-tone-preview:hover { transform: scale(1.05); }

.skin-tone-input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.skin-tone-info { flex: 1; font-size: 0.8125rem; color: var(--text-secondary); }
.skin-tone-hex { color: var(--text-tertiary); font-family: var(--font-mono); font-size: 0.75rem; margin-top: 2px; }

.add-user-button {
    width: 100%;
    padding: var(--space-md);
    margin-top: var(--space-lg);
    background: var(--bg-elevated);
    border: 1.5px dashed var(--border-light);
    border-radius: var(--card-radius);
    color: var(--text-secondary);
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
}

.add-user-button:hover {
    background: var(--bg-hover);
    border-color: var(--accent-muted);
    color: var(--accent);
}

/* Category Manager */
.category-manager-list {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: var(--space-lg);
}

.category-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem var(--space-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    transition: all 0.2s;
}

.category-item:hover { background: var(--bg-hover); }

.category-item-name { font-size: 0.9rem; font-weight: 500; }

.category-item-remove {
    padding: 0.375rem 0.75rem;
    background: transparent;
    border: 1px solid var(--border-light);
    border-radius: var(--button-radius);
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    cursor: pointer;
    transition: all 0.2s;
}

.category-item-remove:hover {
    background: var(--error-bg);
    border-color: var(--error);
    color: var(--error);
}

.category-add-form {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md);
    background: var(--bg-elevated);
    border: 1.5px dashed var(--border-light);
    border-radius: var(--card-radius);
}

.category-add-form input {
    flex: 1;
    padding: 0.625rem 0.875rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
}

.category-add-form input:focus {
    outline: none;
    border-color: var(--accent-muted);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* ============================================
   UTILITIES
   ============================================ */

.loading {
    display: inline-block;
    width: 18px;
    height: 18px;
    border: 2px solid var(--border-light);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

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

/* Toast */
.toast {
    position: fixed;
    bottom: 6rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--bg-elevated);
    border: 1px solid var(--border-light);
    color: var(--text-primary);
    padding: 0.75rem 1.25rem;
    border-radius: 24px;
    box-shadow: var(--shadow-large);
    z-index: 10000;
    font-size: 0.875rem;
    font-weight: 500;
    animation: toastIn 0.3s var(--ease-out);
    white-space: nowrap;
}

.toast.success {
    background: var(--success-bg);
    border-color: var(--success);
    color: var(--success);
}

.toast.error {
    background: var(--error-bg);
    border-color: var(--error);
    color: var(--error);
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-hover); border-radius: 4px; }

/* No scroll helper */
body.no-scroll { overflow: hidden; }

/* ============================================
   RESPONSIVE — MOBILE
   ============================================ */

@media (max-width: 768px) {
    header { padding: 0 var(--space-md); }

    main {
        padding: var(--space-md);
        padding-bottom: 8rem;
    }

    .wardrobe-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: var(--space-md);
    }

    .wardrobe-item-image { aspect-ratio: 1; }

    .form-row { grid-template-columns: 1fr; }

    .outfit-slots {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-sm);
    }

    .item-selector-modal { padding: 0; align-items: flex-end; }

    .item-selector-content {
        max-height: 92vh;
        border-radius: 1.25rem 1.25rem 0 0;
        max-width: 100%;
    }

    .item-selector-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }

    .user-attributes { grid-template-columns: 1fr; }

    .user-card-header-content {
        flex-wrap: wrap;
    }

    .saved-outfits-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .outfit-builder-header {
        padding: 0.625rem var(--space-md);
        gap: var(--space-sm);
    }

    .outfit-builder-actions {
        gap: var(--space-xs);
    }
}

@media (max-width: 480px) {
    .wardrobe-header { flex-direction: column; align-items: flex-start; gap: var(--space-sm); }
    .view-toggle button { font-size: 0.75rem; padding: 0.375rem 0.625rem; }
    .outfit-slots { grid-template-columns: repeat(3, 1fr); }
    .nav-brand span { display: none; }
    .outfit-toggle-label { display: none; }
    .outfit-builder-toggle { width: 44px; height: 44px; padding: 0; border-radius: 50%; justify-content: center; }
    .modal { padding: 0; align-items: flex-end; }
    .modal-content { border-radius: 1.25rem 1.25rem 0 0; max-height: 95vh; max-width: 100%; }
    .add-form { padding: var(--space-md); }
}

/* ============================================
   V3 ADDITIONS — THEME TOGGLE, PASSWORDS,
   AI SAVE, CARD EXPORT, READABILITY, MOBILE
   ============================================ */

/* ---- Theme toggle button ---- */
.theme-toggle {
    width: 38px;
    height: 38px;
    padding: 0;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.theme-toggle:hover {
    background: var(--bg-hover);
    color: var(--accent);
    border-color: var(--border-light);
}
.theme-icon-moon { display: none; }
:root[data-theme="dark"] .theme-icon-sun  { display: none; }
:root[data-theme="dark"] .theme-icon-moon { display: inline; }

/* ---- Readability: softer body, clearer headings ---- */
body { line-height: 1.6; }
p { color: var(--text-secondary); }

/* Larger, clearer tap targets on interactive controls */
button, .btn-primary, .btn-secondary, .filter-btn, .view-toggle button {
    -webkit-tap-highlight-color: transparent;
}

/* Focus-visible accessibility ring */
a:focus-visible, button:focus-visible, input:focus-visible,
select:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---- Login: subheading + hint helpers ---- */
.login-box .login-sub {
    color: var(--text-tertiary);
    font-size: 0.9375rem;
    margin-bottom: var(--space-lg);
}
.login-error {
    color: var(--error);
    font-size: 0.8125rem;
    min-height: 1.1rem;
    margin-top: var(--space-sm);
    opacity: 0;
    transition: opacity 0.2s;
}
.login-error.show { opacity: 1; }
.login-back {
    margin-top: var(--space-lg);
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    background: none;
    border: none;
    cursor: pointer;
}
.login-back:hover { color: var(--accent); }

/* Profile-locked login variant — matches the main logo mark's placement */
.profile-login-avatar {
    width: 80px;
    height: 80px;
    margin: 0 auto var(--space-xl);
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    border-radius: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.875rem;
    font-weight: 600;
    color: #fff;
    box-shadow: var(--shadow-large);
    overflow: hidden;
    flex-shrink: 0;
}
.profile-login-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Lock badge on profile cards */
.user-select-card { position: relative; }
.user-lock-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--accent-subtle);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Password field in profile manager ---- */
.password-section {
    padding-top: var(--space-md);
    margin-top: var(--space-md);
    border-top: 1px solid var(--border-subtle);
}
.password-row {
    display: flex;
    gap: var(--space-sm);
    align-items: center;
    margin-top: var(--space-sm);
    flex-wrap: wrap;
}
.password-row input {
    flex: 1;
    min-width: 140px;
    padding: 0.625rem 0.75rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
}
.password-row input:focus {
    outline: none;
    border-color: var(--accent-muted);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}
.password-status {
    font-size: 0.75rem;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: var(--space-xs);
}
.password-status.set { color: var(--success); }
.password-status.unset { color: var(--text-muted); }

/* ---- AI: save-outfit suggestion card inside chat ---- */
.ai-outfit-suggestion {
    margin-top: var(--space-sm);
    padding: var(--space-sm) var(--space-md);
    background: var(--accent-subtle);
    border: 1px solid var(--accent-muted);
    border-radius: 10px;
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
}
.ai-outfit-suggestion-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--accent);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}
.ai-outfit-suggestion-items {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}
.ai-outfit-chip {
    font-size: 0.6875rem;
    padding: 0.2rem 0.55rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
    color: var(--text-secondary);
}
.ai-save-outfit-btn {
    align-self: flex-start;
    padding: 0.45rem 0.9rem;
    background: var(--accent);
    color: #fff;
    border-radius: var(--button-radius);
    font-size: 0.8125rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    border: none;
}
.ai-save-outfit-btn:hover { background: var(--accent-hover); }
.ai-save-outfit-btn:disabled { opacity: 0.55; cursor: default; }

/* ---- Export button on saved outfit cards ---- */
.saved-outfit-info .outfit-card-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    align-items: center;
}
.saved-outfit-info .btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: var(--button-radius);
    color: var(--text-tertiary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.65;
    transition: all 0.2s;
}
.saved-outfit-info .btn-icon:hover { opacity: 1; background: var(--bg-hover); color: var(--accent); }
.saved-outfit-info .btn-icon.danger:hover { color: var(--error); }

/* ---- Card export modal ---- */
.export-modal {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-lg);
}
.export-modal .modal-backdrop {
    position: absolute;
    inset: 0;
    background: var(--bg-overlay);
    backdrop-filter: blur(8px);
}
.export-content {
    position: relative;
    z-index: 1;
    background: var(--bg-surface);
    border-radius: var(--card-radius);
    padding: var(--space-lg);
    max-width: 420px;
    width: 100%;
    max-height: 92vh;
    overflow-y: auto;
    box-shadow: var(--shadow-large);
    animation: scaleIn 0.3s var(--ease-out);
    text-align: center;
}
.export-content h3 { margin-bottom: var(--space-xs); }
.export-content .export-sub {
    color: var(--text-tertiary);
    font-size: 0.8125rem;
    margin-bottom: var(--space-md);
}
.export-preview-wrap {
    display: flex;
    justify-content: center;
    margin-bottom: var(--space-md);
}
.export-preview-wrap img,
.export-preview-wrap canvas {
    width: 240px;
    max-width: 70vw;
    border-radius: 12px;
    box-shadow: var(--shadow-medium);
    display: block;
}
.export-actions {
    display: flex;
    gap: var(--space-sm);
}
.export-actions button { flex: 1; }
.export-loading {
    padding: 3rem 1rem;
    color: var(--text-tertiary);
    font-size: 0.875rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
}

/* ---- Password prompt modal (first login set) ---- */
.pw-prompt-body { padding: var(--space-lg); }
.pw-prompt-body p { margin-bottom: var(--space-md); font-size: 0.9rem; }
.pw-prompt-body input {
    width: 100%;
    padding: 0.75rem 0.875rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 0.9rem;
    font-family: var(--font-sans);
    margin-bottom: var(--space-md);
}
.pw-prompt-body input:focus {
    outline: none;
    border-color: var(--accent-muted);
    box-shadow: 0 0 0 2px var(--accent-subtle);
}

/* ---- Readability + spacing polish ---- */
.wardrobe-header h2 { letter-spacing: -0.015em; }
.item-info h3 { font-size: 1rem; }
.item-tag { font-size: 0.6875rem; }

/* Improve select contrast in light mode */
:root:not([data-theme="dark"]) .form-group select,
:root:not([data-theme="dark"]) .filter-group select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%237a726a' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
}

/* ---- Mobile refinements ---- */
@media (max-width: 480px) {
    h1 { font-size: 1.875rem; }
    .theme-toggle { width: 36px; height: 36px; }
    .export-preview-wrap img,
    .export-preview-wrap canvas { width: 200px; }
    .header-actions { gap: 0.35rem; }
}

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

/* ============================================
   V4 — SEARCH + UI/UX POLISH
   ============================================ */

/* ---- Search box in the filter bar ---- */
.search-box {
    position: relative;
    flex: 1;
    max-width: 420px;
    display: flex;
    align-items: center;
}
.search-box .search-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-muted);
    pointer-events: none;
}
.search-box input {
    width: 100%;
    padding: 0.55rem 2.2rem 0.55rem 2.35rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: 22px;
    color: var(--text-primary);
    font-size: 0.875rem;
    font-family: var(--font-sans);
    transition: all 0.2s var(--ease-out);
}
.search-box input::placeholder { color: var(--text-muted); }
.search-box input:focus {
    outline: none;
    border-color: var(--accent-muted);
    background: var(--bg-surface);
    box-shadow: 0 0 0 3px var(--accent-subtle);
}
.search-clear {
    position: absolute;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}
.search-clear:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ---- Filter bar wraps gracefully on small screens ---- */
.filter-bar { flex-wrap: wrap; }
@media (max-width: 600px) {
    .search-box { max-width: none; order: -1; flex-basis: 100%; }
}

/* ---- Card polish: subtle lift, cleaner borders ---- */
.wardrobe-item {
    box-shadow: var(--shadow-soft);
}
.wardrobe-item:hover {
    box-shadow: var(--shadow-medium);
}

/* Skeleton loading shimmer */
.skeleton-card {
    background: var(--bg-surface);
    border: 1px solid var(--border-subtle);
    border-radius: var(--card-radius);
    overflow: hidden;
}
.skeleton-img {
    aspect-ratio: 3/4;
    background: linear-gradient(100deg, var(--bg-elevated) 30%, var(--bg-hover) 50%, var(--bg-elevated) 70%);
    background-size: 200% 100%;
    animation: shimmerLoad 1.3s infinite;
}
.skeleton-line {
    height: 12px;
    margin: 0.85rem 1rem;
    border-radius: 6px;
    background: linear-gradient(100deg, var(--bg-elevated) 30%, var(--bg-hover) 50%, var(--bg-elevated) 70%);
    background-size: 200% 100%;
    animation: shimmerLoad 1.3s infinite;
}
.skeleton-line.short { width: 55%; }
@keyframes shimmerLoad {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@media (max-width: 768px) { .skeleton-img { aspect-ratio: 1; } }

/* ---- Wardrobe header count badge ---- */
.wardrobe-header h2 { display: flex; align-items: baseline; gap: 0.6rem; }
.item-count {
    font-family: var(--font-sans);
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: 0.1rem 0.55rem;
    border-radius: 20px;
}

/* ---- View toggle: clearer active state ---- */
.view-toggle button.active {
    box-shadow: var(--shadow-soft);
}

/* ---- FAB: friendlier (no full spin) ---- */
.fab:hover {
    transform: scale(1.08);
    box-shadow: var(--shadow-large), 0 0 30px var(--accent-glow);
}

/* ---- Buttons: consistent focus + disabled ---- */
.btn-primary:disabled, .btn-secondary:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none !important;
}

/* ---- Item cards: color chip contrast in light mode ---- */
.color-indicator, .color-dot { box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08); }

/* ---- Toasts: add a subtle icon spacing + wrap ---- */
.toast { max-width: min(90vw, 420px); white-space: normal; text-align: center; }

/* ---- Empty state button spacing ---- */
.empty-state .btn-primary { display: inline-flex; }

/* ---- Detail sheet image nicer framing ---- */
.detail-content img { box-shadow: var(--shadow-soft); }

/* ---- Smooth grid item entrance ---- */
.wardrobe-item { animation: cardIn 0.35s var(--ease-out) backwards; }
@keyframes cardIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Scrollbar in light mode ---- */
::-webkit-scrollbar-thumb { background: var(--border-medium); }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ============================================
   V5 — OCCASIONS: TAGS, BADGES, FILTERS, CARDS
   ============================================ */

/* ---- Occasion picker in the outfit builder ---- */
.outfit-occasion-picker {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-subtle);
}
.occasion-picker-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    flex-shrink: 0;
}
.occasion-chips {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
}
.occasion-chip {
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-light);
    color: var(--text-secondary);
    transition: all 0.18s var(--ease-out);
    white-space: nowrap;
}
.occasion-chip:hover {
    border-color: var(--chip-color);
    color: var(--chip-color);
}
.occasion-chip.selected {
    background: var(--chip-color);
    border-color: var(--chip-color);
    color: #fff;
}

/* ---- Saved outfits filter bar ---- */
.saved-outfits-filter-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: var(--space-lg);
}
.saved-outfits-filter-bar:empty { display: none; }
.outfit-filter-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.85rem;
    border-radius: 22px;
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-light);
    color: var(--text-secondary);
    transition: all 0.18s var(--ease-out);
}
.outfit-filter-chip:hover { border-color: var(--chip-color, var(--accent-muted)); color: var(--text-primary); }
.outfit-filter-chip.active {
    background: var(--chip-color, var(--accent));
    border-color: var(--chip-color, var(--accent));
    color: #fff;
}
.outfit-filter-chip.active .filter-chip-count { color: rgba(255,255,255,0.85); }
.outfit-filter-chip.active .filter-chip-dot { box-shadow: 0 0 0 2px rgba(255,255,255,0.5); }
.filter-chip-dot {
    width: 9px; height: 9px; border-radius: 50%;
    flex-shrink: 0;
}
.filter-chip-count {
    font-size: 0.6875rem;
    color: var(--text-muted);
    font-weight: 600;
}

/* ---- Redesigned saved outfit card ---- */
.saved-outfit-card {
    display: flex;
    flex-direction: column;
    border-top: 3px solid var(--card-accent, var(--border-light));
    box-shadow: var(--shadow-soft);
}
.saved-outfit-card:hover { box-shadow: var(--shadow-medium); }

.saved-outfit-preview { cursor: pointer; }

/* occasion badge over the preview */
.outfit-occasion-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.6875rem;
    font-weight: 600;
    color: #fff;
    letter-spacing: 0.02em;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
    z-index: 2;
}

.saved-outfit-body {
    padding: 0.85rem 0.9rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}
.saved-outfit-title-row { display: flex; align-items: center; }
.saved-outfit-name {
    font-family: var(--font-display);
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--text-primary);
    margin: 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.saved-outfit-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}
.saved-outfit-pieces {
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: 0.05rem 0.45rem;
    border-radius: 20px;
    flex-shrink: 0;
}
.saved-outfit-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.4rem;
    margin-top: 0.25rem;
    padding-top: 0.55rem;
    border-top: 1px solid var(--border-subtle);
}
.occasion-tag-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.32rem 0.6rem;
    border-radius: var(--button-radius);
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    color: var(--text-secondary);
    transition: all 0.18s var(--ease-out);
}
.occasion-tag-btn:hover { background: var(--bg-hover); color: var(--accent); border-color: var(--border-light); }
.saved-outfit-body .outfit-card-actions { display: flex; gap: 2px; }

/* ---- Occasion assign popover menu ---- */
.occasion-menu {
    position: fixed;
    z-index: 5000;
    width: 200px;
    background: var(--bg-surface);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    box-shadow: var(--shadow-large);
    padding: 0.4rem;
    animation: scaleIn 0.15s var(--ease-out);
}
.occasion-menu-title {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: 0.4rem 0.55rem 0.5rem;
}
.occasion-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.5rem 0.55rem;
    border-radius: 8px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.8125rem;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s;
}
.occasion-menu-item:hover { background: var(--bg-hover); }
.occasion-menu-item.selected { color: var(--accent); font-weight: 500; }
.occasion-menu-item.clear { color: var(--text-tertiary); border-top: 1px solid var(--border-subtle); margin-top: 0.25rem; }
.occasion-menu-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }

@media (max-width: 480px) {
    .outfit-occasion-picker { align-items: flex-start; flex-direction: column; gap: 0.4rem; }
}

/* ============================================
   V6 — ADD-ITEM MODAL MOBILE UX + COLOR PICKER
   ============================================ */

/* Make the add-item form actions sticky so Save/Cancel are always reachable */
#addItemModal .form-actions {
    position: sticky;
    bottom: 0;
    background: var(--bg-surface);
    margin-top: var(--space-lg);
    margin-left: calc(-1 * var(--space-lg));
    margin-right: calc(-1 * var(--space-lg));
    margin-bottom: calc(-1 * var(--space-lg));
    padding: var(--space-md) var(--space-lg);
    padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -6px 18px rgba(0,0,0,0.06);
    z-index: 5;
}

/* Eyedropper hidden on unsupported browsers gets a subtle fallback style handled in JS toast */

@media (max-width: 600px) {
    /* Bottom-sheet add modal fills height so content scrolls, footer stays put */
    #addItemModal { padding: 0; align-items: flex-end; }
    #addItemModal .modal-content {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        height: 92vh;
        border-radius: 1.25rem 1.25rem 0 0;
    }
    #addItemModal .modal-body { -webkit-overflow-scrolling: touch; }

    /* Compact, non-truncated upload area */
    #addItemModal .upload-area {
        flex-direction: row;
        justify-content: center;
        padding: 1.1rem 1rem;
        gap: var(--space-md);
    }
    #addItemModal .upload-area svg { width: 26px; height: 26px; flex-shrink: 0; }
    #addItemModal .upload-area > span:not(.upload-hint) { font-size: 0.9rem; }
    #addItemModal .upload-hint { font-size: 0.7rem !important; }

    /* Smaller preview so the form fields + buttons are visible sooner */
    #addItemModal .image-preview { max-height: 180px; }

    /* Slightly tighter form spacing on mobile */
    #addItemModal .form-group { margin-bottom: 1rem; }

    /* Two-column color group stays usable */
    .color-eyedropper-btn, .color-picker-button { width: 42px; }
}

/* Very small screens: stack the upload text under the icon again but compact */
@media (max-width: 360px) {
    #addItemModal .upload-area { flex-direction: column; gap: 0.35rem; padding: 1rem 0.75rem; }
}

/* AI suggestion occasion badge */
.ai-outfit-occasion {
    margin-left: auto;
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
    font-size: 0.625rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.03em;
    text-transform: uppercase;
}
.ai-outfit-suggestion-title { display: flex; align-items: center; gap: 0.35rem; }

/* ============================================
   V7 — FULL-SCREEN OUTFIT BUILDER + PICKER FIX
   + SAVED OUTFIT DETAIL + CREATE BUTTON
   ============================================ */

/* Builder header: back button + centered title layout */
.outfit-builder-back { flex-shrink: 0; }
.outfit-builder-header .outfit-builder-title { flex: 1; }
.outfit-builder-hint {
    max-width: 920px;
    margin: 0 auto var(--space-lg);
    color: var(--text-tertiary);
    font-size: 0.875rem;
    text-align: center;
}

/* Occasion picker inside a builder row: give it room */
.outfit-builder-panel .outfit-occasion-picker { margin-bottom: var(--space-lg); }

/* ---- ITEM PICKER: filter row only (layout defined in V12 block) ---- */
/* Filter row: consistent height, active state clearly visible */
.item-selector-filters {
    gap: 0.4rem;
    padding-top: 0.6rem;
    padding-bottom: 0.6rem;
    align-items: center;
}
.item-selector-filters button {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    line-height: 1;
    min-height: 32px;
}

/* Make the picker taller on desktop so more items are visible */
.item-selector-content { max-height: 88vh; }

@media (max-width: 600px) {
    .item-selector-grid {
        grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
        gap: var(--space-sm);
    }
    .item-selector-name { font-size: 0.75rem; }
}

/* ---- SAVED OUTFITS: create button + item detail ---- */
.saved-outfits-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}
.saved-outfits-toolbar .saved-outfits-filter-bar { margin-bottom: 0; flex: 1; }

.create-outfit-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
    white-space: nowrap;
}

/* Item list shown on each saved outfit card */
.saved-outfit-items {
    list-style: none;
    margin: 0.15rem 0 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}
.saved-outfit-item-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
    line-height: 1.3;
}
.saved-outfit-item-thumb {
    width: 26px;
    height: 26px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}
.saved-outfit-item-slot {
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    flex-shrink: 0;
    width: 46px;
}
.saved-outfit-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.saved-outfit-item-more {
    font-size: 0.72rem;
    color: var(--text-tertiary);
    padding-left: calc(26px + 0.5rem);
}

/* Empty-state create button inside outfits view */
.outfits-empty-cta { margin-top: 1.25rem; }

/* ============================================
   V8 — BIGGER OUTFIT CARDS, WHOLE-CARD CLICK,
   PICKER "ALL" FIX SUPPORT
   ============================================ */

/* Whole saved-outfit card is now clickable */
.saved-outfit-card { cursor: pointer; }
.saved-outfit-card:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}
/* Interactive children shouldn't look like part of the card click */
.saved-outfit-card .occasion-tag-btn,
.saved-outfit-card .btn-icon { cursor: pointer; }

/* Larger, more readable card body */
.saved-outfit-body {
    padding: 1.05rem 1.1rem 0.95rem;
    gap: 0.55rem;
}
.saved-outfit-name {
    font-size: 1.2rem;
    line-height: 1.3;
}
.saved-outfit-item-line { font-size: 0.85rem; }
.saved-outfit-item-thumb { width: 30px; height: 30px; }
.saved-outfit-item-slot { width: 52px; font-size: 0.62rem; }
.saved-outfit-item-more { padding-left: calc(30px + 0.5rem); font-size: 0.78rem; }
.saved-outfit-meta { font-size: 0.8rem; }

/* Give the preview a touch more presence on the bigger card */
.saved-outfit-preview { aspect-ratio: 4 / 3; }

@media (max-width: 480px) {
    .saved-outfit-name { font-size: 1.1rem; }
}

/* ============================================
   V9 — COLOR FAMILIES, OUTFIT DETAIL MODAL
   ============================================ */

/* Family filter chips in the wardrobe filter panel */
.fam-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
}
.fam-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    border-radius: 20px;
    font-size: 0.8125rem;
    font-weight: 500;
    background: var(--bg-surface);
    border: 1.5px solid var(--border-light);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.18s var(--ease-out);
}
.fam-chip:hover { border-color: var(--accent-muted); color: var(--text-primary); }
.fam-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}
.fam-chip.active .fam-count { color: rgba(255,255,255,0.85); }
.fam-swatch {
    width: 13px;
    height: 13px;
    border-radius: 4px;
    flex-shrink: 0;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.12);
    background-size: cover;
}
.fam-count { font-size: 0.6875rem; color: var(--text-muted); font-weight: 600; }

/* Wider filter panel so family chips fit nicely */
.filter-panel { min-width: 320px; max-width: 380px; }

/* ---- Saved outfit detail modal ---- */
.outfit-detail-content { max-width: 560px; }
.outfit-detail-meta {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    padding: var(--space-lg) var(--space-lg) var(--space-md);
}
.outfit-occasion-badge.static {
    position: static;
    box-shadow: none;
    font-size: 0.72rem;
    padding: 0.22rem 0.65rem;
}
.odt {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.78rem;
    color: var(--text-secondary);
}
.odt.subtle {
    color: var(--text-tertiary);
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    padding: 0.15rem 0.55rem;
    border-radius: 20px;
    font-size: 0.72rem;
}
.outfit-detail-items {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    padding: 0 var(--space-lg);
}
.outfit-detail-item {
    display: flex;
    gap: var(--space-md);
    align-items: center;
    padding: 0.6rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--card-radius);
}
.outfit-detail-thumb {
    width: 64px;
    height: 80px;
    object-fit: cover;
    border-radius: 8px;
    flex-shrink: 0;
    background: var(--bg-surface);
}
.outfit-detail-item-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 0.25rem; }
.outfit-detail-slot {
    font-size: 0.62rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--accent);
}
.outfit-detail-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    /* full name, wraps instead of truncating */
    white-space: normal;
    word-break: break-word;
}
.outfit-detail-tags { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.15rem; }
.outfit-detail-actions {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    padding: var(--space-lg);
    position: sticky;
    bottom: 0;
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    margin-top: var(--space-md);
}
.outfit-detail-actions button { flex: 1; min-width: 120px; }

/* Centered occasion menu variant */
.occasion-menu-centered {
    left: 50% !important;
    top: 50% !important;
    transform: translate(-50%, -50%);
    width: 260px;
}

@media (max-width: 480px) {
    .outfit-detail-actions button { min-width: 100%; }
}

/* ============================================
   V10 — FAMILY DOTS, AVATARS, ACTION SPACING
   ============================================ */

/* (family swatch badge on cards removed by request) */
.wardrobe-item-image { position: relative; }
.family-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    display: inline-block;
    background-size: cover;
    box-shadow: inset 0 0 0 1px rgba(0,0,0,0.15);
}

/* Space out saved-outfit action icons so delete isn't next to export */
.saved-outfit-footer .outfit-card-actions { gap: 0.6rem; }
.saved-outfit-footer .outfit-card-actions .btn-icon {
    width: 34px;
    height: 34px;
    border: 1px solid var(--border-subtle);
    background: var(--bg-elevated);
}
.saved-outfit-footer .outfit-card-actions .btn-icon:hover { background: var(--bg-hover); }
.saved-outfit-footer .outfit-card-actions .btn-icon.danger:hover {
    border-color: var(--error);
    background: var(--error-bg);
    color: var(--error);
}
/* Push delete a little further from the others */
.saved-outfit-footer .outfit-card-actions .btn-icon.danger { margin-left: 0.35rem; }

/* ---- Avatars: shared image styling ---- */
.header-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    color: #fff;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.header-avatar img,
.user-select-avatar img,
.profile-login-avatar img,
.user-card-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.user-select-avatar.has-image,
.profile-login-avatar.has-image,
.user-card-avatar.has-image,
.header-avatar.has-image { background: var(--bg-elevated); }

/* Editable avatar in the profile manager */
.user-card-avatar {
    position: relative;
    overflow: hidden;
}
.user-card-avatar.editable { cursor: pointer; }
.user-card-avatar-edit {
    position: absolute;
    inset: auto 0 0 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0,0,0,0.6), transparent);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 3px;
    color: #fff;
    opacity: 0;
    transition: opacity 0.2s;
}
.user-card-avatar.editable:hover .user-card-avatar-edit { opacity: 1; }

.user-title-sub {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    flex-wrap: wrap;
}
.avatar-remove-link {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 0.72rem;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.avatar-remove-link:hover { color: var(--error); }
.avatar-hint { font-size: 0.72rem; color: var(--text-muted); }

/* ============================================
   V11 — NAVBAR, ALIGNED CONTROLS, SINGLE BUILDER,
   CORNER ACTIONS, ACCESSORY MULTI-SELECT
   ============================================ */

/* ---- Header nav links ---- */
.main-nav {
    display: flex;
    gap: 0.25rem;
    margin: 0 auto 0 var(--space-xl);
}
.nav-link {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.5rem 0.9rem;
    background: transparent;
    border: none;
    border-radius: var(--button-radius);
    color: var(--text-tertiary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s var(--ease-out);
}
.nav-link:hover { background: var(--bg-elevated); color: var(--text-primary); }
.nav-link.active { background: var(--accent-subtle); color: var(--accent); }
.nav-link svg { flex-shrink: 0; }
@media (max-width: 640px) {
    .main-nav { margin-left: var(--space-md); gap: 0.15rem; }
    .nav-link span { display: none; }
    .nav-link { padding: 0.5rem; }
}

/* ---- Aligned search + filter controls (inside main) ---- */
#wardrobeControls { margin-bottom: var(--space-lg); }
.controls-bar {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}
.controls-bar .search-box {
    flex: 1;
    max-width: none;
}
.filter-wrap { position: relative; flex-shrink: 0; }
#wardrobeControls .filter-chips {
    margin-top: var(--space-md);
    flex-wrap: wrap;
}
#wardrobeControls .filter-chips:empty { margin-top: 0; }
/* Filter panel now anchored under the filter button */
.filter-wrap .filter-panel {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    left: auto;
}
@media (max-width: 560px) {
    .controls-bar { flex-wrap: wrap; }
    .controls-bar .search-box { flex-basis: 100%; }
    .filter-wrap { width: 100%; }
    .filter-wrap .filter-btn { width: 100%; justify-content: center; }
    .filter-wrap .filter-panel { left: 0; right: 0; min-width: 0; }
}

/* ---- Single-outfit builder ---- */
.outfit-row { box-shadow: none; border: none; background: transparent; padding: 0; }
.outfit-row:hover { border: none; }
.builder-field { margin-bottom: var(--space-lg); }
.builder-field-label {
    display: block;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    margin-bottom: 0.5rem;
}
.builder-field .outfit-name-input {
    width: 100%;
    padding: 0.7rem 0.9rem;
    background: var(--bg-elevated);
    border: 1px solid var(--border-subtle);
    border-radius: var(--button-radius);
    color: var(--text-primary);
    font-size: 1rem;
    font-family: var(--font-sans);
    font-weight: 500;
}
.builder-field .outfit-name-input:focus {
    outline: none;
    border-color: var(--accent-muted);
    box-shadow: 0 0 0 2px var(--accent-subtle);
    background: var(--bg-surface);
}
.builder-ai-btn {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.7rem;
    background: var(--accent-subtle);
    border: 1px solid var(--accent-muted);
    border-radius: var(--button-radius);
    color: var(--accent);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s var(--ease-out);
}
.builder-ai-btn:hover { background: var(--accent); color: #fff; border-color: var(--accent); }

/* Builder sticky footer action bar */
.outfit-builder-footer {
    display: flex;
    gap: var(--space-sm);
    padding: var(--space-md) var(--space-lg);
    padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    box-shadow: 0 -6px 18px rgba(0,0,0,0.06);
    flex-shrink: 0;
}
.outfit-builder-footer .btn-primary { flex: 1.6; }
.outfit-builder-footer .btn-secondary { flex: 1; }
.outfit-builder-footer > * { max-width: 720px; }
/* center the footer buttons row on wide screens */
.outfit-builder-footer {
    justify-content: center;
}
@media (min-width: 760px) {
    .outfit-builder-footer { padding-left: max(var(--space-lg), calc((100% - 720px) / 2)); padding-right: max(var(--space-lg), calc((100% - 720px) / 2)); }
}

/* ---- Corner action clusters ---- */
.corner-actions {
    position: fixed;
    bottom: 1.75rem;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}
.corner-left { left: 1.75rem; }
.corner-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    height: 48px;
    padding: 0 1.1rem;
    border-radius: 24px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--shadow-medium);
    transition: all 0.2s var(--ease-out);
    white-space: nowrap;
}
.corner-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-large); }
.corner-btn-primary {
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    color: #fff;
    border: none;
}
.corner-btn-secondary {
    background: var(--bg-surface);
    color: var(--accent);
    border: 1.5px solid var(--accent-muted);
}
.corner-btn svg { flex-shrink: 0; }

/* AI FAB bottom-right */
.ai-fab {
    position: fixed;
    bottom: 1.75rem;
    right: 1.75rem;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--accent-muted));
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-large), 0 0 20px var(--accent-glow);
    cursor: pointer;
    z-index: 100;
    transition: transform 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.ai-fab:hover { transform: scale(1.08); box-shadow: var(--shadow-large), 0 0 30px var(--accent-glow); }
.ai-fab.active { background: var(--accent); }
.ai-fab .ai-chat-badge {
    position: absolute;
    top: 2px; right: 2px;
    width: 12px; height: 12px;
    background: var(--error);
    border: 2px solid var(--bg-surface);
    border-radius: 50%;
}

/* Hide text labels on small screens, keep icons */
@media (max-width: 560px) {
    .corner-btn-label { display: none; }
    .corner-btn { width: 48px; height: 48px; padding: 0; justify-content: center; border-radius: 50%; }
    .corner-left { left: 1rem; bottom: 1rem; }
    .ai-fab { right: 1rem; bottom: 1rem; }
}

/* ---- Accessory multi-select in picker ---- */
.item-selector-modal.multi-select .item-selector-content { padding-bottom: 0; }
.item-select-check {
    position: absolute;
    top: 6px; right: 6px;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.35);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.15s var(--ease-out);
}
.item-selector-item.selected {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--accent);
}
.item-selector-item.selected .item-select-check {
    opacity: 1;
    transform: scale(1);
    background: var(--accent);
}
.item-selector-confirm {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    padding: var(--space-md) var(--space-lg);
    padding-bottom: max(var(--space-md), env(safe-area-inset-bottom));
    background: var(--bg-surface);
    border-top: 1px solid var(--border-subtle);
    flex-shrink: 0;
}
.item-selector-confirm .confirm-count {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
}
.item-selector-confirm .btn-primary { min-width: 160px; }

/* Item image needs relative for the check overlay */
.item-selector-image { position: relative; }

/* Adjust main bottom padding for corner clusters */
main { padding-bottom: 7rem; }

/* ============================================
   V12 — DEFINITIVE ITEM PICKER LAYOUT
   (supersedes earlier conflicting blocks)
   ============================================ */
.item-selector-grid {
    /* Layout is now handled by the inner .wpx-grid (see renderFilteredSelectorItems).
       Host is a plain scroll container so nothing conflicts. */
    display: block;
    overflow-y: auto;
    flex: 1;
}
.item-selector-item {
    display: block !important;         /* block, not flex — avoids flex sizing quirks */
    background: var(--bg-surface);
    border: 2px solid transparent;
    border-radius: var(--button-radius);
    overflow: hidden;
    cursor: pointer;
    opacity: 1;
    animation: none;
}
.item-selector-item:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px var(--accent-glow);
}
/* Bulletproof fixed-ratio image box: padding-bottom hack (no flex/aspect-ratio reliance).
   padding-bottom:125% => height is always 125% of the width, regardless of the image. */
.item-selector-image {
    position: relative !important;
    width: 100% !important;
    height: 0 !important;
    padding-bottom: 125% !important;
    background: var(--bg-elevated);
    overflow: hidden !important;
    display: block !important;
}
.item-selector-image img {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}
.item-selector-info {
    display: block;
    padding: 0.55rem 0.65rem 0.7rem;
    border-top: 1px solid var(--border-subtle);
    background: var(--bg-surface);
}
.item-selector-name {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-primary);
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}
.item-selector-color {
    display: flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.2rem;
    font-size: 0.6875rem;
    color: var(--text-tertiary);
}
@media (max-width: 600px) {
    .item-selector-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)) !important; gap: var(--space-sm); }
    .item-selector-name { font-size: 0.75rem; }
}

/* ============================================
   V13 — AI AUTOFILL BUTTON
   ============================================ */
.btn-autofill {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-top: var(--space-sm);
    padding: 0.65rem;
    background: var(--accent-subtle);
    border: 1px solid var(--accent-muted);
    border-radius: var(--button-radius);
    color: var(--accent);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.18s var(--ease-out);
}
.btn-autofill:hover:not(:disabled) { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-autofill:disabled { opacity: 0.65; cursor: default; }
.btn-autofill svg { flex-shrink: 0; }

/* ============================================
   V14 — LOGO GLYPH + MICRO-ANIMATIONS & POLISH
   ============================================ */

/* Custom hanger logo glyph inside the badge */
.logo-glyph {
    width: 52%;
    height: 52%;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.15));
}
.logo-mark.small .logo-glyph { width: 58%; height: 58%; }

/* Gentle entrance for the login/user-selection logo */
@keyframes logoPop {
    0% { transform: scale(0.6) rotate(-8deg); opacity: 0; }
    60% { transform: scale(1.06) rotate(2deg); }
    100% { transform: scale(1) rotate(0); opacity: 1; }
}
.login-box .logo-mark,
.user-selection-header .logo-mark { animation: logoPop 0.6s var(--ease-out) both; }

/* ---- Interactive press/hover feedback ---- */
.btn-primary, .btn-secondary, .nav-link, .corner-btn, .ai-fab,
.occasion-chip, .fam-chip, .outfit-filter-chip, .item-selector-filters button,
.theme-toggle, .filter-btn, .btn-icon {
    transition: transform 0.15s var(--ease-out), background-color 0.2s var(--ease-out),
                border-color 0.2s var(--ease-out), color 0.2s var(--ease-out), box-shadow 0.2s var(--ease-out);
}
.btn-primary:active, .btn-secondary:active, .corner-btn:active,
.occasion-chip:active, .fam-chip:active, .outfit-filter-chip:active,
.nav-link:active, .filter-btn:active { transform: scale(0.96); }
.ai-fab:active { transform: scale(0.92); }

/* Wardrobe items: staggered fade-in on render */
@keyframes cardRise {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}
.wardrobe-item {
    animation: cardRise 0.4s var(--ease-out) both;
}
.wardrobe-grid .wardrobe-item:nth-child(1) { animation-delay: 0.02s; }
.wardrobe-grid .wardrobe-item:nth-child(2) { animation-delay: 0.05s; }
.wardrobe-grid .wardrobe-item:nth-child(3) { animation-delay: 0.08s; }
.wardrobe-grid .wardrobe-item:nth-child(4) { animation-delay: 0.11s; }
.wardrobe-grid .wardrobe-item:nth-child(5) { animation-delay: 0.14s; }
.wardrobe-grid .wardrobe-item:nth-child(6) { animation-delay: 0.17s; }
.wardrobe-grid .wardrobe-item:nth-child(n+7) { animation-delay: 0.2s; }

.wardrobe-item:hover { transform: translateY(-4px); }
.wardrobe-item-image img { transition: transform 0.5s var(--ease-out); }
.wardrobe-item:hover .wardrobe-item-image img { transform: scale(1.05); }

/* Saved outfit cards: same rise + lift */
.saved-outfit-card { animation: cardRise 0.4s var(--ease-out) both; }
.saved-outfit-card:hover { transform: translateY(-4px); }

/* Occasion chip selected pop */
.occasion-chip.selected { animation: chipPop 0.25s var(--ease-out); }
@keyframes chipPop {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

/* Nav-link active underline sweep */
.nav-link { position: relative; }
.nav-link::after {
    content: '';
    position: absolute;
    left: 12px; right: 12px; bottom: 4px;
    height: 2px;
    border-radius: 2px;
    background: var(--accent);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.25s var(--ease-out);
}
.nav-link.active::after { transform: scaleX(1); }
@media (max-width: 640px) { .nav-link::after { display: none; } }

/* Modal / sheet entrance easing refinement */
.modal-content, .item-selector-content, .export-content, .outfit-detail-content {
    animation: modalIn 0.28s var(--ease-out) both;
}
@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.985); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Toast slide + fade */
.toast { animation: toastIn 0.3s var(--ease-out) both; }
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, 16px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Autofill button loading shimmer */
.btn-autofill.is-loading {
    background: linear-gradient(100deg, var(--accent-subtle) 30%, rgba(165,103,93,0.22) 50%, var(--accent-subtle) 70%);
    background-size: 200% 100%;
    animation: shimmerLoad 1.1s linear infinite;
    cursor: default;
}

/* AI FAB idle pulse to draw the eye (subtle) */
@keyframes aiPulse {
    0%, 100% { box-shadow: var(--shadow-large), 0 0 0 0 var(--accent-glow); }
    50% { box-shadow: var(--shadow-large), 0 0 0 8px transparent; }
}
.ai-fab { animation: aiPulse 3.5s ease-in-out infinite; }
.ai-fab:hover, .ai-fab.active { animation: none; }

/* Empty-state icon gentle float */
.empty-state svg { animation: floaty 4s ease-in-out infinite; }
@keyframes floaty {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

/* Slot fill feedback in builder */
.outfit-slot.filled { animation: slotFill 0.3s var(--ease-out); }
@keyframes slotFill {
    0% { transform: scale(0.9); }
    60% { transform: scale(1.04); }
    100% { transform: scale(1); }
}

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