﻿/* Local Font Hosting for Offline Support */
@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 300 600;
    font-display: swap;
    src: url('fonts/outfit-latin-ext.woff2') format('woff2');
    unicode-range: U+0100-02AF, U+0304, U+0308, U+0329, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20CF, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

@font-face {
    font-family: 'Outfit';
    font-style: normal;
    font-weight: 300 600;
    font-display: swap;
    src: url('fonts/outfit-regular.woff2') format('woff2');
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
    --primary-color: #007AFF;
    /* iOS Blue */
    --primary-hover: #0063ce;
    --bg-color: #F2F2F7;
    /* iOS System Grouped Background */
    --card-bg: #FFFFFF;
    --text-main: #000000;
    --text-muted: #8E8E93;
    --border-color: #C6C6C8;
    /* iOS Separator Color */
    --delete-color: #FF3B30;
    /* iOS Red */
    --shadow-sm: none;
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --font-family: -apple-system, BlinkMacSystemFont, 'Outfit', sans-serif;
    /* Prefer System Font */
    --radius: 12px;

    /* NEW: Expanded Token System */
    --text-secondary: #555555;
    --text-tertiary: #666666;
    --text-hint: #999999;
    --input-bg: #f9f9f9;
    --toggle-track: #E9E9EA;
    --toggle-track-on: #34C759;
    --hover-bg: #f0f0f0;
    --badge-warning-bg: #fff3cd;
    --badge-warning-text: #856404;
    --badge-warning-border: #ffeeba;
    --category-bg: #f9f9f9;
    --category-item-bg: #FFFFFF;
    --category-border: #eeeeee;
    --photo-placeholder-bg: #f0f0f0;
    --photo-border: #cccccc;
    --photo-border: #cccccc;
    --shadow-color: rgba(0, 0, 0, 0.05);
    --modal-backdrop: rgba(0, 0, 0, 0.5);
    --segmented-bg: #EEF0F2;
    --segmented-selected: #FFFFFF;
    --segmented-text: #000000;

    /* Additional Utility Colors */
    --accent-orange: #e67e22;
    --accent-blue: #3498db;
    --accent-green: #2ecc71;
    --accent-red: #e74c3c;
    --code-bg: #f8f9fa;
    --code-border: #ccc;
    --code-header-border: #ddd;
}

[data-theme="dark"] {
    --primary-color: #0A84FF;
    /* iOS Dark Blue (lighter/vibrant) */
    --primary-hover: #409CFF;
    --bg-color: #000000;
    /* True black for OLED background */
    --card-bg: #1C1C1E;
    /* iOS System Gray 6 (Elevated surface) */
    --text-main: #FFFFFF;
    --text-muted: #98989D;
    --text-secondary: #EBEBF5;
    --text-tertiary: #EBEBF599;
    --text-hint: #636366;
    --border-color: #38383A;
    /* iOS Dark Separator */
    --delete-color: #FF453A;
    /* iOS Dark Red */
    --input-bg: #2C2C2E;
    /* Input fields slightly lighter */
    --toggle-track: #39393D;
    --toggle-track-on: #30D158;
    --hover-bg: #2C2C2E;
    --badge-warning-bg: #443705;
    /* Adjusted for dark */
    --badge-warning-text: #FFD60A;
    --badge-warning-border: #5C4B08;
    --category-bg: #1C1C1E;
    --category-item-bg: #2C2C2E;
    --category-border: #38383A;
    --photo-placeholder-bg: #2C2C2E;
    --photo-border: #48484A;
    --shadow-color: rgba(0, 0, 0, 0.5);
    --modal-backdrop: rgba(0, 0, 0, 0.7);
    --segmented-bg: #2C2C2E;
    /* Keep container dark */
    --segmented-selected: #636366;
    /* Pill color */
    --segmented-text: #FFFFFF;

    /* Additional Utility Colors (Dark) */
    --accent-orange: #ff9f43;
    --accent-blue: #54a0ff;
    --accent-green: #2ed573;
    --accent-red: #ff6b6b;
    --code-bg: #2C2C2E;
    --code-border: #48484A;
    --accent-red: #ff6b6b;
    --code-bg: #2C2C2E;
    --code-border: #48484A;
    --code-header-border: #38383A;
}

/* Force White Text for Specific Elements in Dark Mode */
body[data-theme="dark"] span.list-name-text {
    color: #FFFFFF !important;
    opacity: 1 !important;
}

body[data-theme="dark"] header p span:not(.subtitle-label) {
    color: #FFFFFF !important;
    opacity: 1 !important;
}

/* Disable backdrop-filter in Dark Mode to prevent artifacts */
[data-theme="dark"] .modal {
    backdrop-filter: none !important;
    background-color: rgba(0, 0, 0, 0.85) !important;
    /* Slightly darker opaque bg */
}

[data-theme="dark"] .slider:before {
    background-color: #FFFFFF !important;
}

[data-theme="dark"] #debug-panel {
    color: #FFFFFF !important;
    background: #000000 !important;
    border: 1px solid #333 !important;
}

[data-theme="dark"] #debug-log div {
    color: #cccccc !important;
}

[data-theme="dark"] .input-group input {
    color: #FFFFFF !important;
}

[data-theme="dark"] .input-group input::placeholder {
    color: #bbbbbb !important;
}

body[data-theme="dark"] #app-status {
    color: #FFFFFF !important;
    opacity: 1 !important;
}

/* Scrollbar Fix regarding "Vertical Box" */
[data-theme="dark"] ::-webkit-scrollbar-track {
    background: transparent !important;
}

[data-theme="dark"] ::-webkit-scrollbar-corner {
    background: transparent !important;
}

[data-theme="dark"] body {
    scrollbar-color: var(--text-secondary) var(--bg-color);
    /* Firefox */
}

/* Segmented Control Z-Index Fix */
.segmented-control {
    position: relative;
    overflow: hidden;
    /* Contain the sliding background */
    z-index: 0;
    isolation: isolate;
    /* Create new stacking context */
}

.segmented-control label {
    z-index: 2;
}

.segmented-background {
    z-index: 1;
}

[data-theme="dark"] .segmented-control input:checked+label {
    color: #FFFFFF !important;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    width: 100%;
    overflow-x: hidden;
    overscroll-behavior-y: none;
    overscroll-behavior-x: none;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 1.5rem;
    position: relative;
    box-sizing: border-box;
    margin: 0;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
}

@media (max-width: 600px) {
    body {
        padding: 0.5rem 0;
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
        background: var(--bg-color);
        overflow-x: hidden;
        overscroll-behavior-x: none;
        touch-action: pan-y pinch-zoom;
        -webkit-overflow-scrolling: touch;
    }

    /* Prevent any element from exceeding viewport */
    * {
        max-width: 100%;
    }
}

.app-container {
    background: transparent;
    /* Remove container card look */
    width: 100%;
    max-width: 800px;
    padding: 0;
    box-shadow: none;
    animation: fadeIn 0.3s ease-out;
    overflow-x: hidden;
    /* Prevent container overflow */
    overflow-y: hidden;
    /* Hide vertical overflow on container to prevent double scrollbar with body */
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    text-align: center;
    margin-bottom: 0.75rem;
    background: var(--card-bg);
    padding: 0.75rem;
    padding-top: max(0.75rem, env(safe-area-inset-top));
    border-radius: var(--radius);
    box-shadow: 0 1px 3px var(--shadow-color);
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

#print-area {
    display: none;
}

header h1 {
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

.subtitle-label {
    color: var(--primary-color);
    font-weight: 600;
    margin-right: 4px;
}

header p {
    color: var(--text-secondary);
    /* Was text-muted, making it slightly brighter */
    font-size: 0.95rem;
    margin-top: 0.25rem;
}

header p span:not(.subtitle-label) {
    color: var(--text-main);
    /* Force list name to be bright in dark mode */
}

.header-main {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
    min-width: 0;
}

.header-top {
    display: flex;
    justify-content: center;
    /* Center Content */
    align-items: center;
    width: 100%;
    position: relative;
    /* For absolute positioning of profile button */
}

/* Ensure title doesn't have weird margins affecting centering */
.header-top h1 {
    margin: 0;
    z-index: 1;
    /* Ensure distinct from profile button if overlap */
}

/* Center column text needs safe margins so it doesn't collide with bell/profile */
.header-text-col {
    max-width: calc(100% - 80px);
    overflow: hidden;
}

.header-text-col #header-subtitle {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.75rem !important;
}

.header-actions {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    align-items: center;
    gap: 4px;
}

.profile-btn {
    /* No longer absolute — lives inside .header-actions flex container */
    cursor: pointer;
}

.header-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.header-buttons {
    display: flex;
    gap: 0px;
}

/* Ensure SVG Icons render correctly on all platforms */
.icon-svg {
    width: 24px;
    height: 24px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    vertical-align: middle;
}

.shopping-mode-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 0.2rem 0;
    min-width: 60px;
}

.toggle-label {
    font-size: 0.9rem;
    /* Increased to match buttons */
    font-weight: 600;
    color: var(--primary-color);
    margin-left: 0;
    /* Remove left margin since stacked */
}

/* Switch Styles */
.switch {
    position: relative;
    display: inline-block;
    width: 51px;
    height: 31px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--toggle-track);
    transition: .3s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 27px;
    width: 27px;
    left: 2px;
    bottom: 2px;
    background-color: var(--card-bg);
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

input:checked+.slider {
    background-color: var(--toggle-track-on);
    /* iOS Green for on */
}

input:focus+.slider {
    box-shadow: 0 0 1px var(--toggle-track-on);
}

input:checked+.slider:before {
    transform: translateX(20px);
}

/* Shopping Mode Visual Cues */
/* Shopping Mode Visual Cues */
/* body.shopping-mode-active { } - Removed empty rule */

.list-item.hidden-shopping {
    display: none !important;
}

.list-item.shopping-completed {
    opacity: 0.5;
    background-color: var(--input-bg);
}

.list-item.shopping-completed .item-text {
    text-decoration: line-through;
    color: var(--text-hint);
}

.input-group {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    background: var(--card-bg);
    padding: 1rem;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px var(--shadow-color);
}

input[type="text"] {
    flex: 1;
    padding: 0.75rem 0.5rem;
    padding-right: 2.5rem;
    /* Make room for the clear button */
    border: none;
    border-bottom: 1px solid var(--border-color);
    border-radius: 0;
    font-size: 1.1rem;
    font-family: var(--font-family);
    outline: none;
    background: transparent;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.input-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
}

.clear-input-btn {
    position: absolute;
    right: 5px;
    background: transparent;
    border: none;
    color: var(--text-hint);
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background-color 0.2s, color 0.2s;
}

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

input[type="text"]::placeholder {
    color: var(--text-hint);
}

input[type="text"]:focus {
    border-bottom-color: var(--primary-color);
}

button {
    border: none;
    cursor: pointer;
    font-family: var(--font-family);
    font-weight: 600;
    border-radius: 8px;
    /* Slightly tighter radius for buttons */
    transition: all 0.2s ease;
}

#add-btn,
#scan-btn {
    flex: 0 0 auto;
}

#add-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 0 1.2rem;
    font-size: 1rem;
}

.secondary-btn.active {
    background-color: var(--primary-color);
    color: white;
}

#add-btn:hover {
    background-color: var(--primary-hover);
}

.icon-svg {
    width: 1.2em;
    height: 1.2em;
    vertical-align: middle;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.list-container {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: flex-start;
}

.grocery-list {
    list-style: none;
    flex: 1;
    width: 100%;
    min-width: 0;
    display: flex;
    flex-direction: column;
    /* No gap, using borders */
    background: var(--card-bg);
    border-radius: var(--radius);
    overflow: hidden;
    /* For rounded corners on first/last items */
    box-shadow: 0 1px 3px var(--shadow-color);
    padding-bottom: 0;
}

@media (min-width: 768px) {
    .grocery-list {
        column-count: 2;
        column-gap: 1.5rem;
        display: block;
        /* Required for columns to work, overrides flex */
    }
}

/* iOS List Item Style */
.list-item {
    background: var(--card-bg);
    border: none;
    border-bottom: 1px solid var(--border-color);
    /* Separator */
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s ease;
    cursor: default;
    user-select: none;
    position: relative;
    /* Good touch target */
    break-inside: avoid;
    /* Prevent item from splitting across columns */
    min-width: 0;
    /* Flexbox safety */
}

.list-item:last-child {
    border-bottom: none;
}

.drag-handle {
    cursor: grab;
    flex: 0 0 32px;
    width: 32px;
    height: 32px;
    color: var(--text-hint);
    /* Subtle Gray */
    background: transparent;
    /* Remove purple box */
    display: none;
    /* Hidden by Default for Lockout */
    align-items: center;
    justify-content: center;
    touch-action: none;
    margin-left: 0.5rem;
    /* Space from controls */
}

/* "Bars" icon for drag handle */
/* "Bars" icon for drag handle */
.drag-handle::before {
    content: "\2261";
    /* Unicode Identical To (Hamburger) */
    font-size: 1.8rem;
    line-height: 1;
    font-weight: 300;
}

.list-item.dragging {
    opacity: 0.8;
    background: #f9f9f9;
    box-shadow: 0 2px 10px var(--shadow-color);
    z-index: 1000;
    border: none;
    /* Remove border when dragging */
}

/* Show Handle in Edit Mode */
.edit-mode-active .drag-handle {
    display: flex;
}

/* Shift content when handle appears to prevent jumpiness (Optional, but nice) */
/* Actually, standard iOS behavior pushes content. Flex handling does this auto. */

/* Touch specific dragging class */
.list-item.touch-dragging {
    position: fixed;
    pointer-events: none;
    z-index: 10000;
    box-shadow: 0 5px 15px var(--shadow-color);
    background: var(--card-bg);
    opacity: 0.95;
    border-radius: 8px;
}

.item-content {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex: 1;
    overflow: hidden;
    /* Prevent text spill */
    min-width: 0;
    /* Flexbox safety */
}

.checkbox-custom {
    appearance: none;
    width: 24px;
    height: 24px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s;
}

.checkbox-custom:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.checkbox-custom:checked::after {
    content: "\2713";
    /* Unicode Checkmark */
    position: absolute;
    color: var(--card-bg);
    /* Should be white/black depending on theme interaction, but usually white on blue */
    font-size: 14px;
    font-weight: 900;
    /* Make it bold */
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.item-text {
    font-size: 1.1rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.item-text.checked {
    color: var(--text-main);
    text-decoration: none;
    font-weight: 700;
    opacity: 1;
}


/* Quantity Stepper Controls */
.quantity-controls {
    display: flex;
    align-items: center;
    gap: 0;
    background: var(--toggle-track);
    border-radius: 8px;
    padding: 2px;
    margin-left: 0.5rem;
    flex-shrink: 0;
}

.qty-btn {
    width: 30px;
    height: 30px;
    border-radius: 6px;
    background: transparent;
    color: var(--primary-color);
    font-size: 1.2rem;
    font-weight: 600;
    line-height: 1;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border: none;
    -webkit-tap-highlight-color: transparent;
}

.qty-btn:active {
    background: rgba(0, 122, 255, 0.15);
}

.qty-display {
    font-size: 1rem;
    font-weight: 600;
    min-width: 1.8rem;
    text-align: center;
    color: var(--text-main);
    user-select: none;
}

[data-theme="dark"] .qty-display {
    color: #FFFFFF;
}

/* Swipe to Delete Styles */
.list-item {
    position: relative;
    overflow: hidden;
    padding: 0;
    border: none;
    background: var(--card-bg);
    /* Default to card background — red only shown during swipe */
    border-bottom: 1px solid var(--border-color);
    display: block;
}

/* Red background only appears during active swipe */
.list-item.swiping {
    background: var(--delete-color);
}

.swipe-wrapper {
    position: relative;
    width: 100%;
    min-height: 56px;
    background: var(--card-bg);
    z-index: 2;
    padding: 0.8rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.2s ease-out;
    will-change: transform;
}

.delete-background {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 1.5rem;
    color: var(--card-bg);
    font-weight: 600;
    font-size: 1rem;
    z-index: 1;
    pointer-events: none;
}

.delete-background::after {
    content: "Delete";
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
    .app-container {
        padding: 0 10px;
    }

    header {
        padding: 0.5rem 0.75rem;
        margin-bottom: 0.5rem;
    }

    .list-container {
        flex-direction: column;
        gap: 1rem;
    }

    /* Ensure drag handle is easy to grab */
    .drag-handle {
        width: 40px;
        height: 100%;
        display: none;
        /* Changed from flex to none to respect global default, or leave it to cascade? Better to be explicit or let global rule win? 
                        The global rule is .drag-handle { display: none }. 
                        This block is inside @media. 
                        If I set display: none here, does .edit-mode-active override it?
                        .edit-mode-active .drag-handle has specificity 0,2,0 (class, class).
                        .drag-handle inside media query has specificity 0,1,0 (class).
                        So .edit-mode-active SHOULD win. 
                        Safe to remove display: flex, or set to display: none.
                        Let's just remove the display line entirely so it inherits or uses global. */
        align-items: center;
        justify-content: flex-start;
    }
}

.controls {
    text-align: center;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    align-items: center;
}

.button-group {
    display: flex;
    gap: 0.5rem;
    justify-content: center;
    width: 100%;
}

.secondary-btn {
    background-color: var(--card-bg);
    border: none;
    color: var(--primary-color);
    padding: 0.6rem 0.5rem;
    font-size: 0.85rem;
    border-radius: 10px;
    flex: 1;
    font-weight: 500;
}

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

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

.primary-btn {
    background-color: var(--primary-color);
    color: var(--card-bg);
    border: none;
    padding: 0.8rem;
    font-size: 1rem;
    border-radius: 10px;
    flex: 1;
    font-weight: 500;
    cursor: pointer;
}

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

/* Print Styles */
/* Print Styles - JS Driven for iOS Compatibility */
@media print {
    body {
        background-color: white;
        color: black;
        padding: 0;
        display: block;
        font-family: 'Segoe UI', sans-serif;
        /* Clean font */
    }

    .app-container,
    .modal,
    #debug-panel {
        display: none !important;
    }

    #print-area {
        display: block !important;
        padding: 0.5in;
        width: 100%;
    }

    .print-header {
        text-align: center;
        border-bottom: 2px solid black;
        padding-bottom: 20px;
        margin-bottom: 30px;
    }

    .print-columns {
        column-count: 2;
        column-gap: 40px;
    }

    .print-category-block {
        break-inside: avoid;
        margin-bottom: 25px;
    }

    .print-cat-header {
        font-weight: 700;
        text-transform: uppercase;
        font-size: 0.9rem;
        border-bottom: 1px solid #ccc;
        margin-bottom: 10px;
        color: #333;
    }

    .print-item {
        display: flex;
        align-items: flex-start;
        margin-bottom: 8px;
        font-size: 11pt;
        line-height: 1.4;
    }

    .print-checkbox {
        font-size: 1.2rem;
        line-height: 1;
        margin-right: 10px;
        color: #333;
    }

    .print-text {
        flex: 1;
    }
}

/* =========================================
   Desktop Delete Button Styles
   ========================================= */

.item-controls-right {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    /* Space between Qty and Delete */
    margin-left: 0.5rem;
}

.delete-btn-desktop {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: #FF3B30;
    /* iOS Red */
    padding: 4px 8px;
    border-radius: 6px;
    opacity: 0;
    /* Hidden by default */
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.delete-btn-desktop:hover {
    background-color: rgba(255, 59, 48, 0.1);
    transform: scale(1.1);
}

/* Show on hover (Desktop) */
.list-item:hover .delete-btn-desktop {
    opacity: 1;
}

/* Item being deleted animation */
.list-item.deleting {
    transform: translateX(-100%);
    opacity: 0;
    transition: all 0.3s ease;
}

/* 
   Hide on Touch Devices 
   We use 'pointer: coarse' to detect touch screens accurately.
   On these devices, we rely exclusively on Swipe-to-Delete.
*/
@media (pointer: coarse) {
    .delete-btn-desktop {
        display: none !important;
    }

    /* Remove the extra gap since the button is gone */
    .item-controls-right {
        gap: 0;
    }
}

/* =========================================
   Auth Modal & Profile Styles
   ========================================= */

.profile-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--toggle-track);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    transition: background 0.2s ease;
}

@media (hover: hover) {
    .profile-btn:hover {
        background: #d1d1d6;
        transform: scale(1.05);
    }
}

.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: var(--modal-backdrop);
    backdrop-filter: blur(5px);
    align-items: center;
    justify-content: center;
    animation: fadeInModal 0.3s;
}

/* Ensure modal uses flex when displayed */
.modal[style*="display: block"] {
    display: flex !important;
}

@keyframes fadeInModal {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal-content {
    background-color: var(--card-bg);
    margin: auto;
    padding: 2rem;
    border: 1px solid var(--border-color);
    width: 90%;
    max-width: 400px;
    border-radius: 20px;
    box-shadow: 0 10px 30px var(--shadow-color);
    position: relative;
    text-align: center;
}

.modal-input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

.close-modal {
    color: var(--text-hint);
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    right: 20px;
    top: 10px;
    cursor: pointer;
}

.close-modal:hover,
.close-modal:focus {
    color: var(--text-main);
    text-decoration: none;
    cursor: pointer;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-top: 1.5rem;
}

.auth-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--photo-border);
    border-radius: 8px;
    font-size: 1rem;
    background: var(--input-bg);
    color: var(--text-main);
}

.secondary-btn {
    background: none;
    border: none;
    /* 1px solid #ddd; */
    padding: 5px 10px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    transition: background 0.2s;
    white-space: nowrap;
    /* Prevent text wrapping */
    justify-content: center;
    /* Center icon and text */
}

.primary-btn {
    background-color: var(--primary-color);
    color: var(--card-bg);
    padding: 12px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

#auth-toggle-link {
    color: var(--primary-color);
    cursor: pointer;
    font-weight: 600;
    text-decoration: underline;
}

#auth-toggle-link:hover {
    text-decoration: none;
}

/* =========================================
   Item Details & Photo Styles
   ========================================= */

.details-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.photo-container {
    width: 100%;
    max-width: 300px;
    height: 300px;
    background-color: var(--photo-placeholder-bg);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    margin-bottom: 1rem;
    border: 2px dashed var(--photo-border);
    position: relative;
}

.photo-placeholder {
    color: var(--text-hint);
    font-size: 1.2rem;
    text-align: center;
    line-height: 1.5;
}

#details-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* List Item Thumbnail Indicator */
.item-thumbnail-indicator {
    font-size: 1.2rem;
    margin-right: 0.5rem;
    cursor: pointer;
}

/* Clickable text for details */
.item-text {
    cursor: pointer;
}

.item-text:hover {
    text-decoration: underline;
    text-decoration-color: var(--photo-border);
}

/* =========================================
   Category Manager Styles
   ========================================= */

.category-header {
    padding: 8px 12px;
    background: var(--category-bg);
    color: var(--text-secondary);
    font-weight: bold;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: sticky;
    top: 0;
    z-index: 5;
    border-bottom: 1px solid var(--border-color);
}

.category-list-container {
    list-style: none;
    padding: 0;
    margin: 0;
    max-height: 50vh;
    overflow-y: auto;
    border: 1px solid var(--category-border);
    border-radius: 8px;
    background: var(--category-bg);
}

.category-manage-item {
    background: var(--category-item-bg);
    border-bottom: 1px solid var(--category-border);
    padding: 12px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: background 0.2s;
}

.category-manage-item:last-child {
    border-bottom: none;
}

.category-manage-item.sortable-ghost {
    opacity: 0.4;
    background: var(--hover-bg);
}

.category-handle {
    cursor: grab;
    padding-right: 15px;
    color: var(--text-hint);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
}

.category-handle::before {
    content: '=';
    margin-right: 5px;
}

.cat-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-tertiary);
}

.cat-delete-btn {
    background: none;
    border: none;
    color: #e74c3c;
    cursor: pointer;
    font-size: 1.1rem;
    padding: 5px;
    margin-left: 10px;
    color: var(--text-main);
    cursor: pointer;
    z-index: 2;
    transition: color 0.1s;
    /* Fast snap */
    border-radius: 6px;
}

/* Background pill for selected state */
/* Background pill for selected state */
.segmented-control .segmented-background {
    position: absolute;
    top: 3px;
    bottom: 3px;
    width: calc((100% - 6px) / 3);
    background-color: var(--segmented-selected);
    border-radius: 6px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    z-index: 1;
    transition: transform 0.2s cubic-bezier(0.2, 0, 0.2, 1);
    pointer-events: none;
    left: 3px;
    /* Start at left padding */
}

/* Fix "Sliver" by making the container background transparent in Dark Mode */
[data-theme="dark"] .segmented-control {
    background: transparent !important;
    border: none !important;
    padding: 3px;
    /* Keep padding for layout */
}

/* Specific Dark Mode Styling for the Pill itself */
[data-theme="dark"] .segmented-control .segmented-background {
    box-shadow: none !important;
    /* Remove shadow to prevent artifacts */
    border: 1px solid rgba(255, 255, 255, 0.2) !important;
    /* Add subtle border instead */
    background-color: var(--segmented-selected) !important;
}

/* Ensure Labels are above background */
.segmented-control label {
    z-index: 2;
    position: relative;
    /* Crucial for z-index to work */
    color: var(--text-secondary);
    /* Default text color */
}

.segmented-control input:checked+label {
    color: var(--segmented-text);
    /* Selected text color */
}

/* Move the background pill based on checked input */
/* Move the background pill based on checked input */
#theme-auto:checked~.segmented-background {
    transform: translateX(0);
}

#theme-light:checked~.segmented-background {
    transform: translateX(100%);
}

#theme-dark:checked~.segmented-background {
    transform: translateX(200%);
}

/* Selected text color boost */
.segmented-control input:checked+label {
    font-weight: 600;
}

/* =========================================
   Fixes for Account Modal (v1.6.34)
   ========================================= */

[data-theme="dark"] .auth-form input[type="email"],
[data-theme="dark"] .auth-form input[type="password"],
[data-theme="dark"] .auth-form input[type="text"] {
    color: #ffffff;
}

[data-theme="dark"] .auth-form input::placeholder {
    color: #aaaaaa;
}

/* Custom Scrollbar (Slim & Dark Mode Compatible) */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--photo-border);
    border-radius: 3px;
    border: 2px solid transparent;
    /* Creates padding effect */
    background-clip: content-box;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
    border: 2px solid transparent;
    background-clip: content-box;
}

::-webkit-scrollbar-corner {
    background: transparent;
}

/* List Switcher Items (Account Modal) */
.list-switcher-item {
    padding: 10px;
    margin-bottom: 6px;
    cursor: pointer;
    background: var(--input-bg);
    /* Changed from card-bg to input-bg for contrast */
    border-radius: 8px;
    border: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
    transition: background 0.2s, border-color 0.2s;
}

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

.list-switcher-item.active {
    background: var(--primary-color);
    /* Active item is now Primary Color */
    border-color: var(--primary-color);
    color: white;
    /* Text is white on primary */
    font-weight: 600;
}

.list-switcher-item.active .icon-svg {
    color: white;
    /* Icon is white on primary */
}

/* Header Layout Fix v1.6.53 */
.header-text-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    /* Center text horizontally */
}

/* Ensure Title is visible in Dark Mode */
.list-name-text {
    color: var(--text-main);
}

[data-theme="dark"] .list-name-text {
    color: #FFFFFF !important;
}

/* Fallback: Direct ID styling */
[data-theme="dark"] #app-title {
    color: #FFFFFF !important;
}

/* Ensure Subtitle is visible */
#header-subtitle {
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

[data-theme="dark"] #header-subtitle {
    color: #AAAAAA !important;
}

/* REMOVED .header-top override to respect original centering (lines 341-347) */

/* Barcode Scanning Animation */
.scanning-pulse {
    animation: pulse-border 1.5s infinite;
    pointer-events: none;
}

@keyframes pulse-border {
    0% {
        box-shadow: 0 0 0 0 rgba(26, 77, 143, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(26, 77, 143, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(26, 77, 143, 0);
    }
}

[data-theme="dark"] .scanning-pulse {
    animation: pulse-border-dark 1.5s infinite;
}

@keyframes pulse-border-dark {
    0% {
        box-shadow: 0 0 0 0 rgba(100, 150, 255, 0.4);
    }

    70% {
        box-shadow: 0 0 0 10px rgba(100, 150, 255, 0);
    }

    100% {
        box-shadow: 0 0 0 0 rgba(100, 150, 255, 0);
    }
}

/* --- Notification Bell & Badge --- */
.notif-bell-btn {
    position: relative;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    transition: background 0.2s;
    color: var(--text-main);
    -webkit-tap-highlight-color: transparent;
}

.notif-bell-btn:active {
    background: var(--hover-bg);
}

/* Position bell on the left side of header — NO animation here to avoid layout shift */
.header-bell-left {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    animation: none;
}

.notif-badge {
    position: absolute;
    top: 2px;
    right: 0;
    background: var(--accent-red);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    line-height: 1;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    animation: badgePop 0.3s ease-out;
}

@keyframes badgePop {
    0% {
        transform: scale(0);
    }

    60% {
        transform: scale(1.2);
    }

    100% {
        transform: scale(1);
    }
}

/* Notification Inbox Items */
.notif-item {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.notif-item:last-child {
    border-bottom: none;
}

.notif-item.unread {
    background: rgba(0, 122, 255, 0.06);
    border-left: 3px solid var(--primary-color);
}

[data-theme="dark"] .notif-item.unread {
    background: rgba(10, 132, 255, 0.12);
}

.notif-item-sender {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 3px;
}

.notif-item-message {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

.notif-item-time {
    font-size: 0.75rem;
    color: var(--text-hint);
    margin-top: 4px;
}

/* Notify button in members section */
.notify-member-btn {
    background: none;
    border: 1px solid var(--primary-color);
    color: var(--primary-color);
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    margin-left: 6px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.notify-member-btn:active {
    background: var(--primary-color);
    color: #fff;
}

/* ============================================================
   APPY MASCOT
   ============================================================ */

/* Gentle floating / hover animation */
@keyframes appy-float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-6px);
    }
}

/* Fade in + slide up entrance */
@keyframes appy-entrance {
    0% {
        opacity: 0;
        transform: translateY(15px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Celebration bounce */
@keyframes appy-celebrate {

    0%,
    100% {
        transform: scale(1) rotate(0deg);
    }

    25% {
        transform: scale(1.1) rotate(-5deg);
    }

    50% {
        transform: scale(1.05) rotate(3deg);
    }

    75% {
        transform: scale(1.1) rotate(-3deg);
    }
}

/* Subtle pulse for loading */
@keyframes appy-pulse {

    0%,
    100% {
        opacity: 0.7;
        transform: scale(1);
    }

    50% {
        opacity: 1;
        transform: scale(1.03);
    }
}

/* Base mascot container */
.appy-mascot {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    animation: appy-entrance 0.5s ease-out;
}

.appy-mascot lottie-player {
    object-fit: contain;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Appy's name label */
.appy-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: 0.5px;
    opacity: 0.85;
}

/* Appy's contextual message */
.appy-message {
    font-size: 0.8rem;
    color: var(--text-tertiary);
    text-align: center;
    max-width: 220px;
    line-height: 1.3;
}

/* --- Login Screen Appy --- */
.appy-login {
    margin: 10px auto 5px;
}

.appy-login lottie-player {
    width: 90px;
    height: 90px;
}

.appy-login .appy-name {
    font-size: 0.9rem;
}

/* --- Empty List Appy --- */
.appy-empty-list {
    margin: 30px auto 10px;
}

.appy-empty-list lottie-player {
    width: 80px;
    height: 80px;
}

/* --- Loading State --- */
.appy-loading {
    margin: 20px auto;
}

.appy-loading lottie-player {
    width: 50px;
    height: 50px;
}

.appy-loading .appy-message {
    font-size: 0.75rem;
}