/* ============================================================
   ליסטה — light-first, colorful theme + dark mode toggle.
   Default: bright, lively surfaces with a violet/teal color
   pairing. Optional dark mode: near-black canvas, translucent
   borders. Every rule below is written against CSS custom
   properties so both themes share one ruleset — only the
   [data-theme="..."] blocks differ. Theme is applied as
   data-theme="light"|"dark" on <html>, toggled via auth.js and
   persisted in localStorage. All class names kept 1:1 with the
   previous stylesheet — no functional HTML/JS changes needed.
   ============================================================ */

/* Fonts are loaded via <link rel="preconnect"> + <link rel="stylesheet">
   in each page's <head>, NOT via @import here. An @import inside the
   stylesheet serializes the download chain (HTML -> style.css -> parse ->
   discover @import -> fonts), blocking render twice; the <head> links let
   the browser start both requests in parallel immediately. */

/* ---------------- LIGHT (default) ---------------- */
:root,
[data-theme="light"] {
    --surface-0: #f5f4fb;          /* page canvas */
    --surface-1: #ffffff;          /* header/panel */
    --surface-2: #ffffff;          /* cards, items */
    --surface-2-hover: #faf9ff;
    --surface-3: #ffffff;          /* popovers, modals */
    --overlay-backdrop: rgba(32,28,53,0.45);

    --line-subtle: rgba(90,70,160,0.10);
    --line-standard: rgba(90,70,160,0.16);
    --line-strong: rgba(90,70,160,0.28);

    --text-primary: #201c35;
    --text-secondary: #4c4768;
    --text-tertiary: #837f9c;
    --text-quaternary: #aba7c1;

    --accent: #6d4ff2;
    --accent-bright: #7d5cff;
    --accent-dim: #5638d6;
    --accent-wash: rgba(109,79,242,0.09);
    --accent-wash-strong: rgba(109,79,242,0.16);
    --accent-ink: #ffffff;

    --ok: #0f9d74;
    --ok-bright: #12b483;
    --ok-wash: rgba(15,157,116,0.10);
    --warn: #c97a12;
    --warn-wash: rgba(201,122,18,0.12);
    --err: #d94848;
    --err-wash: rgba(217,72,72,0.10);

    --hue-1: #6d4ff2; --hue-1-wash: rgba(109,79,242,0.10);
    --hue-2: #12a48a; --hue-2-wash: rgba(18,164,138,0.10);
    --hue-3: #e0891e; --hue-3-wash: rgba(224,137,30,0.10);
    --hue-4: #dd4f8a; --hue-4-wash: rgba(221,79,138,0.10);
    --hue-5: #2f80e0; --hue-5-wash: rgba(47,128,224,0.10);
    --hue-6: #7a9a1e; --hue-6-wash: rgba(122,154,30,0.10);

    --page-bg-image:
        radial-gradient(ellipse 820px 480px at 105% -8%, rgba(109,79,242,0.14) 0%, transparent 60%),
        radial-gradient(ellipse 760px 520px at -8% 18%, rgba(18,164,138,0.12) 0%, transparent 58%),
        radial-gradient(ellipse 600px 420px at 50% 100%, rgba(221,79,138,0.06) 0%, transparent 60%);

    --header-bg: linear-gradient(120deg, #5638d6 0%, #6d4ff2 45%, #2f80e0 100%);
    --header-text: #ffffff;
    --header-bg-size: 200% 200%;

    --shadow-1: 0 1px 2px rgba(32,28,53,.06), 0 2px 8px rgba(32,28,53,.05);
    --shadow-2: 0 6px 20px rgba(32,28,53,.10), 0 2px 6px rgba(32,28,53,.06);
    --shadow-float: 0 14px 32px rgba(109,79,242,.16), 0 2px 8px rgba(32,28,53,.06);
    --shadow-pop: 0 24px 60px rgba(32,28,53,.22);
    --gate-spinner-color: var(--text-tertiary);
}

/* ---------------- DARK (opt-in) ---------------- */
[data-theme="dark"] {
    --surface-0: #08090a;
    --surface-1: #0f1011;
    --surface-2: rgba(255,255,255,0.025);
    --surface-2-hover: rgba(255,255,255,0.045);
    --surface-3: #1f2023;
    --overlay-backdrop: rgba(3,3,4,0.72);

    --line-subtle: rgba(255,255,255,0.06);
    --line-standard: rgba(255,255,255,0.09);
    --line-strong: rgba(255,255,255,0.16);

    --text-primary: #f4f5f6;
    --text-secondary: #c7cbd4;
    --text-tertiary: #8a8f98;
    --text-quaternary: #5c6067;

    --accent: #6a6bf5;
    --accent-bright: #8385ff;
    --accent-dim: #5751d6;
    --accent-wash: rgba(106,107,245,0.14);
    --accent-wash-strong: rgba(106,107,245,0.24);
    --accent-ink: #ffffff;

    --ok: #33c07a;
    --ok-bright: #3fd88b;
    --ok-wash: rgba(51,192,122,0.14);
    --warn: #e0a638;
    --warn-wash: rgba(224,166,56,0.14);
    --err: #ef5a5a;
    --err-wash: rgba(239,90,90,0.14);

    --hue-1: #8385ff; --hue-1-wash: rgba(131,133,255,0.14);
    --hue-2: #3fd88b; --hue-2-wash: rgba(63,216,139,0.14);
    --hue-3: #e0a638; --hue-3-wash: rgba(224,166,56,0.14);
    --hue-4: #ef6fa8; --hue-4-wash: rgba(239,111,168,0.14);
    --hue-5: #5b9bf0; --hue-5-wash: rgba(91,155,240,0.14);
    --hue-6: #9fc23e; --hue-6-wash: rgba(159,194,62,0.14);

    --page-bg-image:
        radial-gradient(ellipse 900px 500px at 100% -10%, rgba(106,107,245,0.16) 0%, transparent 60%),
        radial-gradient(ellipse 700px 500px at -10% 10%, rgba(106,107,245,0.08) 0%, transparent 55%);

    --header-bg: rgba(15,16,17,0.75);
    --header-text: #f4f5f6;
    --header-bg-size: auto;

    --shadow-1: none;
    --shadow-2: 0 1px 0 rgba(255,255,255,0.02) inset;
    --shadow-float: 0 8px 28px rgba(0,0,0,0.45), 0 1px 0 rgba(255,255,255,0.03) inset;
    --shadow-pop: 0 16px 48px rgba(0,0,0,0.55);
    --gate-spinner-color: var(--text-tertiary);
}

:root {
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 24px;
}

* { box-sizing: border-box; }
*:focus-visible { outline: 2px solid var(--accent-bright); outline-offset: 2px; }
::selection { background: var(--accent-wash-strong); color: var(--text-primary); }

html { color-scheme: light dark; }

body {
    font-family: 'Inter', -apple-system, system-ui, "Segoe UI", Roboto, Arial, sans-serif;
    font-feature-settings: "cv01", "ss03";
    font-weight: 400;
    direction: rtl;
    text-align: right;
    background-color: var(--surface-0);
    background-image: var(--page-bg-image);
    background-attachment: fixed;
    background-repeat: no-repeat;
    color: var(--text-secondary);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.1px;
    transition: background-color .2s ease, color .2s ease;
}

.wrap {
    max-width: 640px;
    margin: 0 auto;
    padding: 18px 16px 56px;
}

/* ================= header ================= */
header.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 22px 20px 25px;
    background: var(--header-bg);
    background-size: var(--header-bg-size);
    animation: gradientShift 12s ease infinite;
    color: var(--header-text);
    border-bottom: 1px solid var(--line-subtle);
    box-shadow: var(--shadow-2);
    position: sticky;
    top: 0;
    z-index: 10;
    border-radius: 0 0 26px 26px;
    overflow: hidden;
}
[data-theme="dark"] header.topbar {
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: none;
    border-radius: 0;
}
@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}
header.topbar h1 {
    font-size: 20px;
    font-weight: 590;
    margin: 0;
    letter-spacing: -0.3px;
    color: var(--header-text);
    position: relative;
    z-index: 1;
}
header.topbar a.back {
    color: var(--header-text);
    text-decoration: none;
    font-size: 13.5px;
    font-weight: 510;
    padding: 8px 14px;
    border-radius: 100px;
    background: rgba(255,255,255,0.16);
    border: 1px solid rgba(255,255,255,0.22);
    backdrop-filter: blur(4px);
    transition: background .15s ease, transform .1s ease;
    position: relative;
    z-index: 1;
}
[data-theme="dark"] header.topbar a.back { background: rgba(255,255,255,0.03); border-color: var(--line-standard); }
header.topbar a.back:active { transform: scale(0.96); }
.settings-link { transition: transform .15s ease, opacity .15s ease; opacity: 0.95; position: relative; z-index: 1; }

/* ================= quick-add (usuals / templates) ================= */
.quick-add-row {
    display: flex;
    gap: 8px;
    margin: 10px 0 14px;
}
.quick-add-btn {
    flex: 1;
    padding: 11px 12px;
    border-radius: 14px;
    border: 1px solid var(--line-standard);
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: 13.5px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.quick-add-btn:active { transform: scale(0.97); }
@media (hover: hover) {
    .quick-add-btn:hover {
        border-color: var(--accent);
        background: var(--accent-wash);
    }
}

/* Bottom-sheet shell used by both pickers */
.sheet-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 12, 32, 0.55);
    z-index: 200;
    align-items: flex-end;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.sheet-overlay.open { display: flex; }
.sheet {
    background: var(--surface-3);
    width: 100%;
    max-width: 560px;
    max-height: 86vh;
    border-radius: 22px 22px 0 0;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -8px 30px rgba(0,0,0,0.25);
    animation: sheetUp .22s ease;
}
/* Let the sheet hug its content when there's little to show, instead of
   always standing at full height and stranding the action button at the
   bottom of the screen. */
@keyframes sheetUp {
    from { transform: translateY(16px); opacity: 0.85; }
    to   { transform: translateY(0); opacity: 1; }
}
.sheet-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px 10px;
    border-bottom: 1px solid var(--line-subtle);
}
.sheet-head h3 { margin: 0; font-size: 16.5px; font-weight: 700; }
.sheet-close {
    background: none;
    border: none;
    font-size: 19px;
    cursor: pointer;
    color: var(--text-tertiary);
    padding: 4px 8px;
    border-radius: 8px;
}
.sheet-search {
    margin: 12px 18px 4px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--line-standard);
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
}
.sheet-search:focus { outline: none; border-color: var(--accent); }
.sheet-body {
    flex: 0 1 auto;
    overflow-y: auto;
    padding: 10px 18px 14px;
    -webkit-overflow-scrolling: touch;
}
.sheet-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 18px calc(14px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--line-subtle);
}
.sheet-foot-stack { justify-content: stretch; }
.sheet-count { font-size: 13px; color: var(--text-tertiary); font-weight: 600; }
.sheet-primary {
    flex: 1;
    padding: 12px 18px;
    border-radius: 100px;
    border: none;
    background: var(--accent);
    color: #fff;
    font-size: 14.5px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    transition: transform .12s ease, opacity .15s ease;
}
.sheet-primary:active { transform: scale(0.97); }
.sheet-primary:disabled { opacity: 0.45; cursor: default; }
.sheet-group-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-tertiary);
    text-transform: none;
    margin: 14px 0 7px;
    letter-spacing: 0.01em;
}
.sheet-group-title:first-child { margin-top: 4px; }

/* Selectable item chips in the usuals palette */
.chip-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}
.usual-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 9px 13px;
    border-radius: 100px;
    border: 1.5px solid var(--line-standard);
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: 13.5px;
    font-family: inherit;
    cursor: pointer;
    transition: transform .1s ease, border-color .15s ease, background .15s ease;
}
.usual-chip:active { transform: scale(0.95); }
.usual-chip-text { font-weight: 600; }
.usual-chip-meta {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: 'JetBrains Mono', monospace;
}
.usual-chip.selected {
    border-color: var(--accent);
    background: var(--accent);
    color: #fff;
}
.usual-chip.selected .usual-chip-meta { color: rgba(255,255,255,0.8); }
/* Already on the active list: still selectable (you might genuinely want
   two), but clearly marked so it isn't an accidental duplicate. */
.usual-chip.on-list {
    opacity: 0.5;
    border-style: dashed;
}
.usual-chip.on-list.selected { opacity: 1; }

/* Template rows */
.template-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line-subtle);
}
.template-row:last-child { border-bottom: none; }
.template-info { min-width: 0; flex: 1; }
.template-name { font-size: 14.5px; font-weight: 700; }
.template-sub {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.template-actions { display: flex; gap: 6px; flex: none; }
.template-apply {
    padding: 8px 15px;
    border-radius: 100px;
    border: 1px solid var(--accent);
    background: var(--accent-wash);
    color: var(--accent);
    font-size: 13px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}
.template-del {
    padding: 8px 11px;
    border-radius: 100px;
    border: 1px solid var(--line-standard);
    background: none;
    cursor: pointer;
    font-size: 13px;
}

/* Manage-mode affordances in the usuals sheet */
.sheet-head-actions { display: flex; align-items: center; gap: 2px; }
.sheet-icon-btn {
    background: none;
    border: none;
    font-size: 17px;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 9px;
    opacity: 0.65;
    transition: opacity .15s ease, background .15s ease;
}
.sheet-icon-btn.active {
    opacity: 1;
    background: var(--accent-wash-strong);
}
.manage-hint {
    display: none;
    margin: 0 18px;
    padding: 9px 12px;
    border-radius: 11px;
    background: var(--accent-wash);
    color: var(--text-secondary);
    font-size: 12px;
    line-height: 1.5;
}
.manage-hint.show { display: block; }

.manage-list { display: flex; flex-direction: column; }
.manage-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 0;
    border-bottom: 1px solid var(--line-subtle);
}
.manage-row:last-child { border-bottom: none; }
/* A hidden product stays visible (greyed) in manage mode so it can be
   restored - hiding must never be a one-way door. */
.manage-row.is-hidden { opacity: 0.45; }
.manage-name {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.manage-qty {
    flex: none;
    width: 54px;
    padding: 7px 6px;
    border-radius: 9px;
    border: 1px solid var(--line-standard);
    background: var(--surface-2);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    text-align: center;
}
.manage-qty:focus { outline: none; border-color: var(--accent); }
.manage-btn {
    flex: none;
    padding: 7px 8px;
    border-radius: 9px;
    border: 1px solid var(--line-standard);
    background: var(--surface-2);
    font-size: 13px;
    cursor: pointer;
    line-height: 1;
    transition: border-color .15s ease, background .15s ease;
}
.manage-btn.on {
    border-color: var(--accent);
    background: var(--accent-wash-strong);
}
/* Destructive action reads as destructive - this one can't be undone,
   unlike the reversible hide button sitting right next to it. */
.manage-btn.danger {
    border-color: color-mix(in srgb, var(--err) 35%, transparent);
    background: var(--err-wash);
}
/* Pinned marker on a chip in normal pick mode */
.usual-chip.pinned { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.pin-dot { font-size: 10px; line-height: 1; }

/* Transient toast for routine feedback (e.g. "3 added, 2 already on the
   list") - an alert() would be far too heavy for this. */
.todo-toast {
    position: fixed;
    left: 50%;
    bottom: 26px;
    transform: translateX(-50%) translateY(12px);
    z-index: 300;
    max-width: calc(100% - 36px);
    padding: 11px 18px;
    border-radius: 100px;
    background: var(--text-primary);
    color: var(--surface-1);
    font-size: 13.5px;
    font-weight: 600;
    text-align: center;
    box-shadow: 0 6px 22px rgba(0,0,0,0.22);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease, transform .2s ease;
}
.todo-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ================= offline banner ================= */
/* Shown when the app is running on cached data (no network). Deliberately
   high-contrast amber and full-width - the user MUST notice it, because
   edits made in this state are not reaching the server. */
.offline-banner {
    position: relative;
    z-index: 60;
    padding: 9px 14px;
    background: #fef3c7;
    color: #78350f;
    border-bottom: 1px solid #fcd34d;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    line-height: 1.45;
}
[data-theme="dark"] .offline-banner {
    background: #422006;
    color: #fde68a;
    border-bottom-color: #78350f;
}

/* ================= auth bar ================= */
.auth-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 18px;
    background: var(--surface-1);
    border-bottom: 1px solid var(--line-subtle);
    font-size: 12.5px;
    color: var(--text-tertiary);
}
.auth-bar-user {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 510;
    color: var(--text-secondary);
}
.auth-bar-actions { display: flex; align-items: center; gap: 6px; }
.auth-bar-btn {
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    border-radius: 100px;
    padding: 5px 13px;
    font-size: 12px;
    font-weight: 510;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background .15s ease, border-color .15s ease, color .15s ease;
}

/* Theme toggle pill — sun/moon icon button, lives in the auth bar
   on every page (it's rendered by auth.js alongside the user chip). */
.theme-toggle-btn {
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    border-radius: 100px;
    width: 30px;
    height: 30px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    color: var(--text-secondary);
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.theme-toggle-btn:active { transform: scale(0.9) rotate(-12deg); }

/* ================= auth modal / gate ================= */
.auth-modal-backdrop {
    position: fixed; inset: 0; background: var(--overlay-backdrop);
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
    z-index: 3000; padding: 16px;
}
.auth-modal {
    position: relative;
    width: min(380px, 100%);
    background: var(--surface-3);
    border: 1px solid var(--line-standard);
    border-radius: var(--radius-lg);
    padding: 28px 22px 22px;
    box-shadow: var(--shadow-pop);
    display: flex; flex-direction: column; gap: 11px;
}
.auth-modal h3 {
    margin: 0 0 2px; font-size: 20px; font-weight: 590; color: var(--text-primary);
    letter-spacing: -0.3px;
}
.auth-modal p { margin: 0 0 6px; font-size: 13px; line-height: 1.6; color: var(--text-tertiary); }
.auth-input {
    width: 100%; padding: 12px 14px; border: 1px solid var(--line-standard); border-radius: var(--radius-sm);
    font-size: 15px; font-family: inherit; background: var(--surface-2); color: var(--text-primary);
    transition: border-color .15s ease, background .15s ease;
}
[data-theme="light"] .auth-input { background: #faf9ff; }
.auth-input::placeholder { color: var(--text-quaternary); }
.auth-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-wash); }
.auth-row { display: flex; gap: 8px; }
.auth-row .btn-primary, .auth-row .btn-ghost, .btn-primary {
    flex: 1; padding: 11px; border-radius: var(--radius-sm); font-weight: 590; font-size: 13.5px; cursor: pointer; border: none;
    transition: filter .15s ease, transform .1s ease, background .15s ease, box-shadow .15s ease;
}
.auth-row .btn-primary, .btn-primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px var(--accent-wash-strong); }
.auth-row .btn-ghost { background: var(--surface-2); color: var(--text-secondary); border: 1px solid var(--line-standard); }
.btn-primary:active, .auth-row .btn-primary:active { transform: scale(0.97); }
.auth-close {
    position: absolute; top: 12px; left: 14px; background: none; border: none;
    font-size: 17px; cursor: pointer; color: var(--text-quaternary);
}
.auth-status { font-size: 12.5px; color: var(--err); min-height: 16px; font-weight: 510; }

.auth-gate {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background-color: var(--surface-0);
    background-image: var(--page-bg-image);
    display: flex;
    align-items: center;
    justify-content: center;
}
.auth-gate-spinner {
    font-size: 14px;
    color: var(--gate-spinner-color);
    font-weight: 510;
}
.auth-gate-modal { margin: 16px; }

/* ================= brand / hero ================= */
.brand-tagline {
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13.5px;
    font-weight: 400;
    margin: 18px 0 20px;
    letter-spacing: -0.1px;
}

/* ================= cards ================= */
.card {
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    border-radius: var(--radius-lg);
    padding: 18px;
    margin-bottom: 14px;
    box-shadow: var(--shadow-1);
}

.settings-card { padding: 20px 18px; }
.settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}
.settings-row-title { font-size: 14.5px; font-weight: 590; color: var(--text-primary); margin-bottom: 4px; }
.settings-row-sub { font-size: 12.5px; color: var(--text-tertiary); line-height: 1.55; }

.switch {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    flex: none;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute; cursor: pointer; inset: 0;
    background: var(--line-strong);
    border: 1px solid var(--line-standard);
    border-radius: 26px;
    transition: background .2s;
}
/* Thumb sits at the physical left edge when off. Positioned/animated
   with physical left/right (not transform) so it's immune to the
   page's dir="rtl" — a transform: translateX value doesn't flip with
   writing direction the way one might expect, which is what caused
   the thumb to fly off the track before. */
.switch-slider::before {
    content: "";
    position: absolute;
    height: 18px; width: 18px;
    left: 2px; top: 2px;
    background: var(--surface-3);
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
    border-radius: 50%;
    transition: left .2s ease;
}
.switch input:checked + .switch-slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-slider::before { left: 20px; background: #fff; }

.section-title {
    font-size: 12px;
    font-weight: 590;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--text-quaternary);
    margin: 22px 2px 10px;
}

.reminder-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    transition: border-color .15s ease, background .15s ease;
}
.reminder-row-main { min-width: 0; }
.reminder-row-text { font-size: 14.5px; font-weight: 510; color: var(--text-primary); }
.reminder-row-meta { font-size: 12px; color: var(--text-tertiary); margin-top: 3px; }
.reminder-cancel-btn {
    flex: none;
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 15px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50%;
    transition: background .15s ease, color .15s ease;
}

/* ---- admin.html action buttons: same .reminder-row layout, just
   give the two action buttons (reset / delete) clearer, elegant,
   color-coded treatment instead of looking like plain text links. ---- */
.reminder-row .auth-bar-btn {
    padding: 6px 13px;
    color: var(--accent-dim);
    border-color: var(--accent-wash-strong);
    background: var(--accent-wash);
}
[data-theme="dark"] .reminder-row .auth-bar-btn { color: var(--accent-bright); }
.reminder-row .reminder-cancel-btn {
    width: 32px; height: 32px;
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
}

/* ================= big-link tiles ================= */
.big-link {
    display: block;
    position: relative;
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    border-radius: var(--radius-xl);
    padding: 24px 22px;
    margin-bottom: 14px;
    text-decoration: none;
    color: var(--text-primary);
    overflow: hidden;
    box-shadow: var(--shadow-1);
    transition: transform .18s cubic-bezier(.2,.8,.2,1), border-color .18s ease, background .18s ease, box-shadow .18s ease;
}
.big-link::after {
    content: "←";
    position: absolute;
    left: 22px; top: 50%;
    transform: translateY(-50%) translateX(-4px);
    color: var(--text-quaternary);
    font-size: 16px;
    opacity: 0;
    transition: opacity .18s ease, transform .18s ease;
}
.big-link:active { transform: scale(0.98); }
.big-link .title { font-size: 17px; font-weight: 590; letter-spacing: -0.2px; }
.big-link .sub { font-size: 12.5px; color: var(--text-tertiary); margin-top: 5px; font-weight: 400; }
.big-link.shopping {
    border-color: color-mix(in srgb, var(--ok) 35%, transparent);
    background: linear-gradient(135deg, var(--ok-wash), transparent 70%), var(--surface-2);
}

/* Toggle under the add-form: "add as one whole task, don't split into
   separate items" - a plain checkbox+label styled as an unobtrusive
   pill, matches the settings switch's visual language but lighter. */
.no-split-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: -6px 0 16px;
    padding: 8px 12px;
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    border-radius: 100px;
    font-size: 12.5px;
    color: var(--text-tertiary);
    cursor: pointer;
    user-select: none;
    width: fit-content;
    transition: border-color .15s ease, color .15s ease;
}
.no-split-toggle input[type=checkbox] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
    flex: none;
}
.no-split-toggle:has(input:checked) {
    border-color: var(--accent);
    color: var(--text-primary);
    background: var(--accent-wash);
}

/* ================= forms ================= */
form.add-form {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
    align-items: flex-end;
}
textarea, input[type=text] {
    flex: 1;
    min-width: 0;
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    color: var(--text-primary);
    border-radius: var(--radius-md);
    padding: 16px 18px;
    font-size: 15.5px;
    font-family: inherit;
    line-height: 1.4;
    resize: none;
    overflow: hidden;
    box-shadow: var(--shadow-1);
    transition: border-color .15s ease, background .15s ease, height .12s ease, box-shadow .15s ease;
}
[data-theme="light"] textarea, [data-theme="light"] input[type=text] { background: #ffffff; }
textarea::placeholder, input[type=text]::placeholder { color: var(--text-quaternary); }
textarea:focus, input[type=text]:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}
textarea { min-height: 60px; max-height: 55vh; }

/* ================= buttons ================= */
button {
    background: var(--accent);
    color: var(--accent-ink);
    border: none;
    border-radius: var(--radius-md);
    padding: 0 22px;
    height: 58px;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 590;
    cursor: pointer;
    box-shadow: 0 6px 18px var(--accent-wash-strong);
    transition: filter .15s ease, transform .1s ease, box-shadow .15s ease;
    letter-spacing: -0.1px;
}
button:active { transform: scale(0.97); }
button.secondary {
    background: var(--surface-2);
    color: var(--text-secondary);
    border: 1px solid var(--line-standard);
    box-shadow: none;
}
.view-toggle { margin: 4px 0 18px; }
.view-toggle button {
    width: 100%;
    height: 42px;
    font-weight: 510;
}
button.danger {
    background: var(--err-wash);
    color: var(--err);
    box-shadow: none;
    border: 1px solid color-mix(in srgb, var(--err) 30%, transparent);
}

.mic-btn {
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    color: var(--accent-bright);
    border-radius: var(--radius-md);
    width: 58px;
    height: 58px;
    min-width: 58px;
    font-size: 22px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    position: relative;
    transition: background .18s ease, border-color .18s ease, transform .12s ease;
}
.mic-btn:active { transform: scale(0.95); }
.mic-btn.recording {
    background: linear-gradient(145deg, #ff5c5c, #d92b2b);
    border-color: #d92b2b;
    color: #ffffff;
    box-shadow: 0 3px 18px rgba(217,43,43,0.5);
    animation: micPulse 1.4s ease-in-out infinite;
}
.mic-btn.recording::before {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: calc(var(--radius-md) + 6px);
    border: 2px solid rgba(217,43,43,0.5);
    animation: ringPulse 1.4s ease-out infinite;
}
@keyframes micPulse {
    0%, 100% { box-shadow: 0 3px 18px rgba(217,43,43,0.5); }
    50% { box-shadow: 0 3px 26px rgba(217,43,43,0.8); }
}
@keyframes ringPulse {
    0% { transform: scale(0.9); opacity: 0.9; }
    100% { transform: scale(1.35); opacity: 0; }
}

/* ================= list items ================= */
.category-block { margin-bottom: 22px; }
.category-title {
    font-size: 12px;
    font-weight: 590;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--accent);
    margin-bottom: 9px;
    padding-right: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.category-title::before {
    content: "";
    width: 5px; height: 5px; border-radius: 50%;
    background: var(--accent);
    display: inline-block;
}
/* Cycle six hues across successive categories for a lively,
   colorful shopping list instead of one repeated accent. */
.category-block:nth-of-type(6n+1) .category-title { color: var(--hue-1); }
.category-block:nth-of-type(6n+1) .category-title::before { background: var(--hue-1); }
.category-block:nth-of-type(6n+2) .category-title { color: var(--hue-2); }
.category-block:nth-of-type(6n+2) .category-title::before { background: var(--hue-2); }
.category-block:nth-of-type(6n+3) .category-title { color: var(--hue-3); }
.category-block:nth-of-type(6n+3) .category-title::before { background: var(--hue-3); }
.category-block:nth-of-type(6n+4) .category-title { color: var(--hue-4); }
.category-block:nth-of-type(6n+4) .category-title::before { background: var(--hue-4); }
.category-block:nth-of-type(6n+5) .category-title { color: var(--hue-5); }
.category-block:nth-of-type(6n+5) .category-title::before { background: var(--hue-5); }
.category-block:nth-of-type(6n+6) .category-title { color: var(--hue-6); }
.category-block:nth-of-type(6n+6) .category-title::before { background: var(--hue-6); }

.item-row {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    border-radius: var(--radius-md);
    padding: 13px 15px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-1);
    transition: opacity .2s ease, border-color .15s ease, background .15s ease;
}
.item-row .remind-inline { flex-basis: 100%; margin-top: 8px; }
.item-row.done {
    opacity: 0.5;
    background: transparent;
    box-shadow: none;
}
.item-row.done .txt-inner { text-decoration: line-through; color: var(--text-quaternary); }
.item-row .txt { flex: 1; font-size: 15.5px; min-width: 120px; color: var(--text-primary); font-weight: 400; }

.checkbox {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 1.5px solid var(--line-strong);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
    background: var(--surface-2);
    color: transparent;
    font-size: 14px;
    transition: all .15s ease;
}
.checkbox:hover { border-color: var(--accent); }
.checkbox.checked {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.del-btn, .edit-btn, .remind-btn {
    background: none;
    border: none;
    color: var(--text-tertiary);
    font-size: 15.5px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s ease, color .15s ease;
}
.del-btn:hover { color: var(--err); }

.remind-btn.active { color: var(--warn); background: var(--warn-wash); }
.remind-btn:not(.active) { color: var(--text-tertiary); }

.qty-toggle-btn {
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    color: var(--text-primary);
    font-size: 15px;
    cursor: pointer;
    padding: 6px;
    border-radius: 50%;
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-inline-start: auto;
    box-shadow: none;
    transition: background .15s ease, border-color .15s ease;
}
[data-theme="light"] .qty-toggle-btn { background: rgba(255,255,255,0.22); border-color: rgba(255,255,255,0.3); color: var(--header-text); }
.qty-toggle-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

/* ---- Compact quantity stepper. Previously forced onto its own
   full-width line (flex-basis:100%) which read as a long stray
   bar under the item text. Now it's a small inline pill that
   sits beside the text and only wraps if the row truly has no
   room, sized like a real segmented control. ---- */
.qty-control {
    display: inline-flex;
    align-items: center;
    gap: 0;
    flex: none;
    background: var(--accent-wash);
    border: 1px solid var(--line-standard);
    border-radius: 100px;
    padding: 2px;
    height: 28px;
    box-shadow: none;
    transition: transform .16s cubic-bezier(.34,1.56,.64,1), box-shadow .16s ease, border-color .16s ease, background .16s ease;
}
/* "Pop" state: focusing the quantity number (tapping the cube) grows
   the whole pill slightly and highlights it, so the +/- targets on
   either side become bigger and easier to hit right after tapping in. */
.qty-control:focus-within {
    transform: scale(1.18);
    background: var(--surface-2);
    border-color: var(--accent);
    box-shadow: 0 4px 16px var(--accent-wash-strong);
    z-index: 5;
    position: relative;
}
.qty-step {
    background: transparent;
    color: var(--accent);
    border: none;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    padding: 0;
    box-shadow: none;
    transition: background .12s ease, transform .1s ease;
}
.qty-step:active { transform: scale(0.88); }
.qty-control:focus-within .qty-step {
    width: 24px;
    height: 24px;
    font-size: 15px;
}
input.qty-input[type=text] {
    width: 30px;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 12.5px;
    font-weight: 590;
    padding: 0 1px;
    border-radius: 0;
    line-height: 1;
    overflow: visible;
    box-shadow: none;
    height: auto;
}
input.qty-input[type=text]:focus { outline: none; box-shadow: none; border: none; }

.item-row .remind-badge {
    font-size: 11.5px;
    font-weight: 590;
    color: var(--warn);
    white-space: nowrap;
    background: var(--warn-wash);
    padding: 2px 9px;
    border-radius: 100px;
    display: inline-block;
    margin-top: 4px;
}
.item-row input.edit-input {
    flex: 1;
    background: var(--surface-2);
    border: 1px solid var(--accent);
    color: var(--text-primary);
    border-radius: 10px;
    padding: 9px 12px;
    font-size: 15.5px;
    box-shadow: 0 0 0 3px var(--accent-wash);
    height: auto;
}
.item-row .edit-save {
    background: var(--accent);
    color: var(--accent-ink);
    border: none;
    border-radius: 100px;
    padding: 8px 16px;
    height: auto;
    font-size: 13.5px;
    font-weight: 590;
    cursor: pointer;
    box-shadow: none;
}

.empty {
    color: var(--text-quaternary);
    text-align: center;
    padding: 52px 16px;
    font-size: 14.5px;
}
.footer-actions {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}
.footer-actions button { height: auto; padding: 11px 18px; font-size: 13.5px; }
.small-link { color: var(--accent); font-size: 12.5px; text-decoration: none; font-weight: 510; }

/* ================= home: list rows ================= */
.list-row {
    display: flex;
    align-items: stretch;
    gap: 10px;
    margin-bottom: 14px;
    position: relative;
}
.list-icon-btn {
    flex-shrink: 0;
    width: 60px;
    height: auto;
    background: var(--surface-2);
    border: 1px solid var(--line-standard);
    border-radius: var(--radius-lg);
    font-size: 25px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-1);
    cursor: pointer;
    transition: transform .12s ease, border-color .15s ease, background .15s ease;
}
.list-icon-btn:active { transform: scale(0.94); }
.list-row-link {
    flex: 1;
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: flex-start;
}
/* The "last added" line sits inside the flex column above. Without this
   the title and the meta line would render side by side (the row is a
   flex container), and a tighter top margin keeps the two-line card the
   same visual weight as a one-line one. */
.list-row-link .sub { margin-top: 3px; }
.icon-picker-pop {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 6px;
    z-index: 20;
    background: var(--surface-3);
    border: 1px solid var(--line-standard);
    border-radius: var(--radius-lg);
    padding: 10px;
    box-shadow: var(--shadow-pop);
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 4px;
    width: 236px;
}
.icon-choice {
    background: none;
    border: none;
    font-size: 21px;
    padding: 8px;
    height: auto;
    border-radius: 10px;
    cursor: pointer;
    box-shadow: none;
    transition: background .12s ease;
}

/* ============================================================
   Pointer-device refinements — real hover feedback for mouse
   users (touch devices get :active only, matched above). Gated
   on (hover:hover) so nothing changes on phones/tablets.
   ============================================================ */
@media (hover: hover) and (pointer: fine) {
    .big-link:hover {
        transform: translateY(-3px);
        border-color: var(--accent);
        box-shadow: var(--shadow-float);
    }
    .big-link:hover::after { opacity: 1; transform: translateY(-50%) translateX(0); }
    .big-link.shopping:hover { border-color: color-mix(in srgb, var(--ok) 55%, transparent); }
    .list-icon-btn:hover { border-color: var(--accent); background: var(--accent-wash); transform: translateY(-1px); }
    .item-row:hover { border-color: var(--line-strong); background: var(--surface-2-hover); }
    .reminder-row:hover { border-color: var(--line-strong); }
    button:hover { filter: brightness(1.08); }
    button.secondary:hover { filter: none; background: var(--surface-2-hover); border-color: var(--line-strong); }
    button.danger:hover { filter: none; background: color-mix(in srgb, var(--err) 22%, transparent); }
    .del-btn:hover, .edit-btn:hover, .remind-btn:hover { background: var(--surface-2-hover); color: var(--text-primary); }
    .del-btn:hover { color: var(--err); }
    .qty-toggle-btn:hover { border-color: var(--accent); }
    .qty-step:hover { background: var(--accent-wash-strong); }
    .auth-bar-btn:hover { background: var(--surface-2-hover); border-color: var(--line-strong); }
    .theme-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }
    a.small-link:hover, .settings-link:hover { opacity: 1; filter: brightness(1.2); }
    header.topbar a.back:hover { background: rgba(255,255,255,0.26); }
    .icon-choice:hover { background: var(--surface-2-hover); transform: scale(1.08); }
    .reminder-cancel-btn:hover { background: var(--err-wash); color: var(--err); }
    .checkbox:hover { border-color: var(--accent); background: var(--accent-wash); }
    .mic-btn:hover:not(.recording) { border-color: var(--accent); background: var(--accent-wash); }
}

/* ============================================================
   Desktop / wide-viewport layout.
   ============================================================ */
@media (min-width: 860px) {
    .wrap { max-width: 900px; padding: 30px 32px 64px; }

    header.topbar { padding: 24px 40px 28px; }
    header.topbar h1 { font-size: 21px; }
    header.topbar a.back { padding: 9px 18px; }

    .auth-bar { padding: 9px 32px; }

    .card { padding: 22px 26px; }

    form.add-form { gap: 12px; }
    textarea, input[type=text] { font-size: 15.5px; }

    #tempLists { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 14px; }
    #tempLists .list-row { margin-bottom: 0; }
    .big-link.shopping { grid-column: 1 / -1; }

    .item-row { padding: 14px 18px; }
    .category-block { margin-bottom: 26px; }

    button { height: 50px; }
    form.add-form button[type=submit] { height: 58px; }
    .mic-btn { height: 58px; width: 58px; min-width: 58px; }
    .view-toggle button, .item-row .edit-save { height: auto; }
}

@media (min-width: 1200px) {
    .wrap { max-width: 1020px; }
    #tempLists { grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
}
