/* Wishwell — Modern Wish-List UI (mobile + desktop) */
:root {
    --mint: #d4f0ea;
    --mint-deep: #9fd5cb;
    --pink: #fce4ea;
    --pink-deep: #efb0bf;
    --lavender: #e8e0f5;
    --cream: #faf6ef;
    --peach: #fde8d0;
    --sky: #d4eaf7;
    --lilac: #e8e0f5;
    --rose: #fce4ec;
    --yellow: #fff3c4;
    --bg: #f5f7f6;
    --bg-card: #ffffff;
    --bg-input: #f4f6f5;
    --border: #e8eceb;
    --border-soft: #eef1f0;
    --text: #1a1f1e;
    --text-muted: #7a8480;
    --text-soft: #9aa3a0;
    --primary: #3d9b8f;
    --primary-hover: #2d7a70;
    --primary-soft: #e6f5f2;
    --primary-text: #1e4a44;
    --accent: #e8a0b0;
    --danger: #e05a5a;
    --success: #3d9b6a;
    --warning: #e0a040;
    --radius: 16px;
    --radius-sm: 12px;
    --radius-lg: 20px;
    --radius-pill: 999px;
    --shadow: 0 2px 12px rgba(30, 50, 45, 0.06);
    --shadow-md: 0 4px 20px rgba(30, 50, 45, 0.08);
    --shadow-lg: 0 8px 32px rgba(30, 50, 45, 0.1);
    --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    --nav-h: 72px;
    --sidebar-w: 240px;
    --top-h: 56px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
html {
    overflow-x: hidden;
    max-width: 100%;
}
body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    min-height: 100vh;
    min-height: 100dvh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
    max-width: 100%;
    position: relative;
}
body.has-nav { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px); }
body.no-nav { padding-bottom: 0; }
a { color: var(--primary); text-decoration: none; transition: color .15s; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; display: block; }
button, input, select, textarea { font-family: inherit; font-size: inherit; }
button { cursor: pointer; border: none; background: none; }
ul, ol { list-style: none; }

/* ========== LAYOUT SHELL ========== */
.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}
.main {
    flex: 1;
    width: 100%;
    max-width: 100%;
    padding: 0 0 24px;
}

/* ========== SIDEBAR (desktop) ========== */
.sidebar {
    display: none;
    position: fixed;
    left: 0; top: 0; bottom: 0;
    width: var(--sidebar-w);
    background: #fff;
    border-right: 1px solid var(--border);
    flex-direction: column;
    z-index: 100;
    padding: 20px 14px;
}
.sidebar-brand { padding: 4px 10px 24px; }
.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
    font-weight: 700;
    font-size: 1.15rem;
}
.logo:hover { color: var(--text); }
.logo-mark {
    width: 32px; height: 32px;
    background: linear-gradient(135deg, #3d9b8f, #5bb5a8);
    color: #fff;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.95rem;
}
.logo-text { letter-spacing: -0.02em; }
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.92rem;
    transition: all .15s;
}
.sidebar-link:hover {
    background: var(--bg);
    color: var(--text);
}
.sidebar-link.active {
    background: var(--primary-soft);
    color: var(--primary-text);
}
.sidebar-link svg { flex-shrink: 0; opacity: 0.85; }
.sidebar-footer {
    padding-top: 16px;
    border-top: 1px solid var(--border);
}
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    border-radius: var(--radius-sm);
    color: var(--text);
}
.sidebar-user:hover { background: var(--bg); color: var(--text); }
.sidebar-user-info { display: flex; flex-direction: column; min-width: 0; }
.sidebar-user-name { font-weight: 600; font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user-meta { font-size: 0.75rem; color: var(--text-muted); }

/* ========== MOBILE TOP ========== */
.mobile-top {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-soft);
    height: var(--top-h);
}
.mobile-top-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 16px;
    max-width: 640px;
    margin: 0 auto;
}
.logo-mobile {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    color: var(--text);
    font-size: 1.05rem;
}
.logo-mobile .logo-mark { width: 28px; height: 28px; font-size: 0.85rem; border-radius: 8px; }
.avatar-btn {
    width: 36px; height: 36px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    color: var(--primary-text);
    font-weight: 600;
    font-size: 0.9rem;
}
.avatar-btn img { width: 100%; height: 100%; object-fit: cover; }

/* ========== BOTTOM NAV (mobile) ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid var(--border);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    align-items: start;
    justify-items: center;
    z-index: 1000;
    padding-top: 8px;
    margin: 0;
    transform: none;
}
.bn-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    color: var(--text-soft);
    font-size: 0.68rem;
    font-weight: 500;
    width: 100%;
    max-width: 72px;
    padding: 4px 4px;
    transition: color .15s;
    text-align: center;
}
.bn-item svg { stroke-width: 1.8; }
.bn-item.active { color: var(--primary); }
.bn-item.active svg { stroke-width: 2.2; }
.bn-fab {
    width: 52px; height: 52px;
    margin-top: -22px;
    background: linear-gradient(135deg, #3d9b8f, #4db0a3);
    color: #fff !important;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.6rem;
    font-weight: 300;
    box-shadow: 0 4px 16px rgba(61, 155, 143, 0.4);
    flex-shrink: 0;
    justify-self: center;
}
.bn-fab:hover { color: #fff; transform: scale(1.05); }

/* ========== CONTAINER ========== */
.container {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 0 16px;
}
.page-content {
    width: 100%;
    max-width: 560px;
    margin: 0 auto;
    padding: 0 16px;
}

/* ========== PAGE HERO / HEADER ========== */
.page-header {
    padding: 20px 16px 8px;
}
.page-header-inner {
    max-width: 560px;
    margin: 0 auto;
}
.hello {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 16px;
}
.hello-text h1, .hello-name {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}
.hello-text .subtitle {
    color: var(--text-muted);
    font-size: 0.88rem;
    margin-top: 2px;
}
.hello-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.icon-btn {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    transition: all .15s;
}
.icon-btn:hover { background: var(--bg); color: var(--text); }
.icon-btn.bell { position: relative; }

.search-bar {
    position: relative;
    margin-bottom: 16px;
}
.search-bar input,
.search-bar input[type="search"],
.desktop-search input,
.desktop-search input[type="search"] {
    width: 100%;
    /* Extra left padding so text never sits under the magnifying-glass icon */
    padding: 12px 16px 12px 44px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.92rem;
    color: var(--text);
    transition: box-shadow .15s, border-color .15s;
    box-sizing: border-box;
}
.search-bar input:focus,
.search-bar input[type="search"]:focus,
.desktop-search input:focus,
.desktop-search input[type="search"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 155, 143, 0.15);
    background: var(--bg-card);
    color: var(--text);
}
.search-bar input::placeholder,
.desktop-search input::placeholder { color: var(--text-soft); }
.search-bar .search-icon,
.desktop-search .search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-soft);
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    z-index: 1;
}
.search-bar .search-icon svg,
.desktop-search .search-icon svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* ========== QUICK ACCESS ========== */
.quick-access {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 24px;
}
.qa-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 14px 10px;
    text-align: center;
    border: 1px solid var(--border-soft);
    transition: transform .15s, box-shadow .15s;
}
.qa-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.qa-icon {
    width: 44px; height: 44px;
    border-radius: 14px;
    display: flex; align-items: center; justify-content: center;
    margin: 0 auto 8px;
    font-size: 1.25rem;
}
.qa-card.mint .qa-icon { background: var(--mint); }
.qa-card.pink .qa-icon { background: var(--pink); }
.qa-card.sky .qa-icon { background: var(--sky); }
.qa-card.peach .qa-icon { background: var(--peach); }
.qa-card.lilac .qa-icon { background: var(--lilac); }
.qa-label { font-size: 0.78rem; font-weight: 500; color: var(--text-muted); }
.qa-count { font-size: 1.1rem; font-weight: 700; color: var(--text); margin-top: 2px; }

/* ========== SECTION ========== */
.section {
    margin-bottom: 28px;
}
.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
}
.section-title {
    font-size: 1.05rem;
    font-weight: 650;
    color: var(--text);
    letter-spacing: -0.01em;
}
.section-link {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--primary);
}

/* ========== LIST CARDS (Your Lists) ========== */
.lists-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.lists-scroll::-webkit-scrollbar { display: none; }
.list-tile {
    flex: 0 0 150px;
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-soft);
    transition: transform .15s, box-shadow .15s;
    color: var(--text);
}
.list-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); color: var(--text); }
.list-tile-img {
    height: 90px;
    background: var(--cream);
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.list-tile-img img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.list-tile-img .placeholder {
    font-size: 2rem;
    opacity: 0.4;
}
.list-tile-body {
    padding: 10px 12px 12px;
}
.list-tile-title {
    font-weight: 600;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.list-tile-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

.lists-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.list-card {
    background: var(--bg-card);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    transition: box-shadow .18s, transform .18s;
    display: flex;
    flex-direction: column;
}
.list-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.list-card-img {
    height: 130px;
    background: linear-gradient(160deg, #f0f5f3, #e8f0ed);
    display: block;
    overflow: hidden;
    flex-shrink: 0;
}
.list-card-img img {
    width: 100%; height: 100%;
    object-fit: cover;
    transition: transform .25s ease;
}
.list-card:hover .list-card-img img { transform: scale(1.04); }
.list-card-body {
    padding: 12px 14px 14px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.list-card-title {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 4px;
}
.list-card-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 10px;
}
.list-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: auto;
}

.create-list-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px;
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.92rem;
    background: transparent;
    transition: all .15s;
    margin-top: 12px;
}
.create-list-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-soft);
}

/* ========== ITEM GRID ========== */
.items-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}
.items-toolbar .count {
    font-size: 0.88rem;
    color: var(--text-muted);
}
.toolbar-actions {
    display: flex;
    gap: 8px;
}
.filter-btn, .sort-btn {
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.82rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}
.filter-btn:hover, .sort-btn:hover { border-color: var(--primary); color: var(--primary); }

.items-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
.item-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    overflow: hidden;
    border: 1px solid var(--border-soft);
    transition: box-shadow .15s;
    position: relative;
}
.item-card:hover { box-shadow: var(--shadow-md); }
.item-card-img {
    height: 130px;
    background: linear-gradient(160deg, #f5f7f6, #eef2f0);
    position: relative;
    overflow: hidden;
}
.item-card-img img {
    width: 100%; height: 100%;
    object-fit: cover;
}
.item-badge {
    position: absolute;
    top: 8px; left: 8px;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.item-badge.reserved {
    background: rgba(224, 90, 90, 0.9);
    color: #fff;
}
.item-badge.available {
    background: rgba(61, 155, 106, 0.9);
    color: #fff;
}
.item-badge.claimed {
    background: rgba(224, 160, 64, 0.9);
    color: #fff;
}
.item-card-body {
    padding: 10px 12px 12px;
}
.item-card-title {
    font-weight: 600;
    font-size: 0.88rem;
    line-height: 1.3;
    margin-bottom: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.item-card-price {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}
.item-card-store {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.item-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-soft);
}
.item-likes {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    color: var(--text-muted);
}
.item-actions-mini {
    display: flex;
    gap: 4px;
}

/* ========== FRIENDS ========== */
.friends-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.friend-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-soft);
    transition: box-shadow .15s;
}
.friend-row:hover { box-shadow: var(--shadow); }
.friend-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    color: var(--primary-text);
    flex-shrink: 0;
}
.friend-avatar img { width: 100%; height: 100%; object-fit: cover; }
.friend-info { flex: 1; min-width: 0; }
.friend-name { font-weight: 600; font-size: 0.95rem; }
.friend-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 1px; }
.friend-actions { display: flex; gap: 6px; flex-shrink: 0; }

.requests-section {
    margin-bottom: 24px;
}
.requests-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    background: var(--primary);
    color: #fff;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    margin-left: 6px;
}

/* ========== SETTINGS ========== */
.settings-profile {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-soft);
    margin-bottom: 20px;
}
.settings-profile .avatar-lg {
    width: 56px; height: 56px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-text);
}
.settings-profile .avatar-lg img { width: 100%; height: 100%; object-fit: cover; }
.settings-profile-info h2 { font-size: 1.1rem; font-weight: 650; }
.settings-profile-info p { font-size: 0.85rem; color: var(--text-muted); }

.settings-group {
    margin-bottom: 24px;
}
.settings-group-title {
    font-size: 0.72rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    margin-bottom: 8px;
    padding-left: 4px;
}
.settings-list {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-soft);
    overflow: hidden;
}
.settings-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    color: var(--text);
    border-bottom: 1px solid var(--border-soft);
    transition: background .12s;
}
.settings-item:last-child { border-bottom: none; }
.settings-item:hover { background: var(--bg); color: var(--text); }
.settings-item-icon {
    width: 36px; height: 36px;
    border-radius: 10px;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    color: var(--text-muted);
    flex-shrink: 0;
}
.settings-item-label { flex: 1; font-weight: 500; font-size: 0.92rem; }
.settings-item-arrow { color: var(--text-soft); }
.settings-item .toggle {
    position: relative;
    width: 44px; height: 26px;
    background: #d0d5d3;
    border-radius: var(--radius-pill);
    transition: background .2s;
    flex-shrink: 0;
}
.settings-item .toggle.on { background: var(--primary); }
.settings-item .toggle::after {
    content: '';
    position: absolute;
    top: 3px; left: 3px;
    width: 20px; height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.settings-item .toggle.on::after { transform: translateX(18px); }

/* ========== CARDS & FORMS ========== */
.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-soft);
    padding: 18px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}
.card-title {
    font-size: 1rem;
    font-weight: 650;
    margin-bottom: 12px;
}
.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.form-group { margin-bottom: 14px; }
.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}
.form-group input:not([type="checkbox"]):not([type="radio"]),
.form-group select,
.form-group textarea,
input[type="text"],
input[type="password"],
input[type="email"],
input[type="url"],
input[type="number"],
input[type="tel"],
textarea,
select {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    transition: border-color .15s, box-shadow .15s, background .15s;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:not([type="checkbox"]):not([type="radio"]):focus,
.form-group select:focus,
.form-group textarea:focus,
input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="tel"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(61, 155, 143, 0.12);
    background: var(--bg-card);
    color: var(--text);
}
.form-group input:disabled,
input:disabled,
textarea:disabled,
select:disabled {
    background: var(--bg);
    color: var(--text-muted);
    opacity: 0.85;
    cursor: not-allowed;
}
.form-group input::placeholder,
input::placeholder,
textarea::placeholder {
    color: var(--text-soft);
}
.form-group textarea { min-height: 90px; resize: vertical; }
.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }
.price-eq-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin: 4px 0 14px;
    min-height: 1.2em;
    line-height: 1.3;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    cursor: pointer;
    line-height: 1.25;
    user-select: none;
    pointer-events: auto;
    position: relative;
    z-index: 1;
}
.checkbox-label > span {
    display: inline-flex;
    align-items: center;
    line-height: 1.25;
    margin: 0;
    padding: 0;
}
.checkbox-label input[type="checkbox"],
.checkbox-label input[type="radio"] {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px;
    margin: 0;
    padding: 0 !important;
    flex-shrink: 0;
    align-self: center;
    cursor: pointer;
    pointer-events: auto;
    -webkit-appearance: checkbox !important;
    appearance: auto !important;
    accent-color: var(--primary);
    border: none;
    background: transparent !important;
    box-shadow: none !important;
    position: relative;
    z-index: 2;
}
.checkbox-label span,
.checkbox-label {
    vertical-align: middle;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-weight: 550;
    font-size: 0.9rem;
    transition: all .15s;
    border: none;
    cursor: pointer;
    white-space: nowrap;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover { background: var(--primary-hover); color: #fff; }
.btn-secondary {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--border-soft); }
.btn-danger {
    background: #fef0f0;
    color: var(--danger);
}
.btn-danger:hover { background: #fce0e0; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-block { width: 100%; }
.btn-icon {
    width: 40px; height: 40px;
    border-radius: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.2rem;
    color: var(--text);
}
.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}
.btn-ghost:hover { color: var(--text); background: var(--bg); }

/* ========== ALERTS ========== */
.alert {
    margin: 12px 16px;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    max-width: 560px;
}
.alert-success { background: #e8f5ee; color: #1e5a3a; border: 1px solid #c5e8d4; }
.alert-error { background: #fef0f0; color: #8a2a2a; border: 1px solid #f5d0d0; }
.alert-info { background: #e8f0fe; color: #1e3a6a; border: 1px solid #c5d4f0; }

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-muted);
}
.empty-state p { margin-bottom: 8px; }

/* ========== MODALS ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 28, 0.5);
    z-index: 2000;
    display: none;
    /* flex puts the sheet at the bottom without absolute positioning tricks */
    flex-direction: column;
    justify-content: flex-end;
    align-items: center;
    padding: 0;
    margin: 0;
    border: 0;
    overflow: hidden !important;
    overscroll-behavior: none;
    touch-action: none; /* block scroll chaining on the dimmed area */
    box-sizing: border-box;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}
.modal-overlay.active { display: flex; }
.modal {
    position: relative;
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    max-height: 90dvh;
    background: #fff;
    border-radius: 20px 20px 0 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 0;
    margin: 0;
    box-sizing: border-box;
    /* allow vertical pan only inside the sheet */
    touch-action: pan-y;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}
body.modal-open .bottom-nav {
    visibility: hidden !important;
    pointer-events: none !important;
}
body.modal-open {
    overflow: hidden !important;
    /* do NOT use position:fixed on body — it fights the file-picker on Android/Samsung */
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 0 0 auto;
    padding: 16px 20px 12px;
    background: #fff;
    border-bottom: 1px solid var(--border-soft);
    z-index: 2;
}
.modal-header h2 { font-size: 1.15rem; font-weight: 650; }
.modal-close {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--bg);
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    color: var(--text-muted);
    flex-shrink: 0;
    border: none;
    cursor: pointer;
}
.modal-close:hover { background: var(--border); color: var(--text); }
.modal-body,
.modal > form {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    touch-action: pan-y;
    padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
    margin: 0;
}
.cropper-container { max-height: 320px; margin-bottom: 12px; }
.cropper-actions { display: flex; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
#cropModal.modal-overlay { z-index: 2100; }
#cropModal .cropper-container {
    max-height: min(50vh, 360px);
    background: var(--bg);
    border-radius: var(--radius-sm);
    overflow: hidden;
}
/* Semi-transparent placeholder for empty price fields */
input[type="number"]::placeholder {
    color: var(--text-soft);
    opacity: 0.7;
}

/* ========== AVATARS ========== */
.avatar-sm {
    width: 32px; height: 32px;
    border-radius: 50%;
    object-fit: cover;
}
.avatar-placeholder {
    width: 32px; height: 32px;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-text);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    font-size: 0.85rem;
}

/* ========== UTILS ========== */
.flex { display: flex; }
.gap-2 { gap: 8px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mb-2 { margin-bottom: 16px; }
.text-muted { color: var(--text-muted); }
.text-center { text-align: center; }
.w-full { width: 100%; }
.hidden { display: none !important; }

/* ========== STATS (desktop) ========== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 18px 20px;
    border: 1px solid var(--border-soft);
}
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.03em;
    color: var(--text);
}
.stat-card .stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ========== DESKTOP (≥ 900px) ========== */
@media (min-width: 900px) {
    body.has-nav {
        padding-bottom: 0;
        padding-left: var(--sidebar-w);
    }
    .sidebar { display: flex; }
    .mobile-top { display: none; }
    .bottom-nav { display: none; }

    .main {
        padding: 28px 32px 40px;
        max-width: 1100px;
    }
    .container, .page-content, .page-header-inner {
        max-width: 100%;
        padding-left: 0;
        padding-right: 0;
    }
    .page-header { padding: 0 0 8px; }
    .alert { margin: 0 0 16px; max-width: none; }

    .lists-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
    .items-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }
    .list-card-img { height: 140px; }
    .item-card-img { height: 160px; }

    .stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 16px;
    }

    .modal-overlay {
        padding: 24px;
        justify-content: center;
        touch-action: auto;
    }
    .modal {
        border-radius: var(--radius-lg);
        max-height: min(85vh, 720px);
        width: min(100%, 480px);
    }

    /* Desktop page header with action */
    .page-header-desktop {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 24px;
    }
    .page-header-desktop h1 {
        font-size: 1.5rem;
        font-weight: 700;
        letter-spacing: -0.03em;
    }

    .desktop-toolbar {
        display: flex;
        align-items: center;
        gap: 12px;
    }
    .desktop-search {
        position: relative;
        width: 260px;
    }
    .desktop-search input,
    .desktop-search input[type="search"] {
        width: 100%;
        padding: 10px 14px 10px 44px;
        border-radius: var(--radius-pill);
        border: 1px solid var(--border);
        background: var(--bg-card);
        font-size: 0.9rem;
        color: var(--text);
        box-sizing: border-box;
    }
    .desktop-search input:focus,
    .desktop-search input[type="search"]:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px rgba(61, 155, 143, 0.12);
        background: var(--bg-card);
        color: var(--text);
    }
    .desktop-search .search-icon {
        position: absolute;
        left: 14px;
        top: 50%;
        transform: translateY(-50%);
        color: var(--text-soft);
        pointer-events: none;
        display: flex;
        align-items: center;
        justify-content: center;
        width: 20px;
        height: 20px;
        z-index: 1;
    }

    /* Friends table-like on desktop */
    .friends-list .friend-row {
        padding: 14px 18px;
    }

    /* Settings two-column on desktop */
    .settings-layout {
        display: grid;
        grid-template-columns: 200px 1fr;
        gap: 32px;
        align-items: start;
    }
    .settings-nav {
        position: sticky;
        top: 28px;
    }
    .settings-nav a {
        display: block;
        padding: 10px 14px;
        border-radius: var(--radius-sm);
        color: var(--text-muted);
        font-weight: 500;
        font-size: 0.9rem;
        margin-bottom: 2px;
    }
    .settings-nav a:hover, .settings-nav a.active {
        background: var(--primary-soft);
        color: var(--primary-text);
    }
}

@media (min-width: 1100px) {
    .items-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .lists-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Auth pages */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: linear-gradient(160deg, #e8f5f2 0%, #f5f7f6 50%, #f0f4f8 100%);
}
.auth-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: var(--radius-lg);
    padding: 32px 28px;
    box-shadow: var(--shadow-lg);
}
.auth-card h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 6px;
    text-align: center;
}
.auth-card .auth-sub {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 24px;
}
.auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}
.auth-logo .logo-mark {
    width: 48px; height: 48px;
    font-size: 1.2rem;
    border-radius: 14px;
}

/* Lightbox */
#lightbox.modal-overlay {
    background: rgba(10, 14, 13, 0.82);
    cursor: zoom-out;
    padding: 24px;
    justify-content: center;
    align-items: center;
    touch-action: none;
    overflow: hidden;
}
#lightbox .modal {
    background: transparent;
    box-shadow: none;
    max-width: 92vw;
    max-height: 90vh;
    width: auto;
    padding: 0;
    border-radius: 0;
    overflow: visible;
    cursor: default;
    touch-action: none;
}
#lightbox img,
#lightbox #lightboxImg {
    max-height: 82vh;
    max-width: 92vw;
    width: auto;
    height: auto;
    margin: 0 auto;
    border-radius: var(--radius);
    display: block;
    cursor: default;
    box-shadow: 0 8px 40px rgba(0,0,0,0.45);
    transform-origin: center center;
    will-change: transform;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
}
#lightbox .modal-close {
    position: absolute;
    right: -8px;
    top: -36px;
    color: #fff !important;
    font-size: 2rem;
    background: transparent;
    border: none;
    cursor: pointer;
    line-height: 1;
    z-index: 2;
}

/* Legacy class bridges for existing markup */
.page-hero {
    padding: 20px 16px 12px;
}
.page-hero-inner { max-width: 560px; margin: 0 auto; }
.page-hero h1, .hello-name {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}
.page-hero .subtitle { color: var(--text-muted); font-size: 0.88rem; margin-top: 2px; }
.page-hero-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.page-hero.mint, .page-hero.pink, .page-hero.peach, .page-hero.lavender, .page-hero.cream {
    background: transparent;
}
.cat-row {
    display: flex; gap: 10px; overflow-x: auto; padding: 4px 0 8px; margin: 12px 0;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.cat-row::-webkit-scrollbar { display: none; }
.cat-chip { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 6px; min-width: 68px; }
.cat-chip .icon {
    width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center;
    justify-content: center; font-size: 1.3rem; box-shadow: var(--shadow);
}
.cat-chip span { font-size: 0.72rem; font-weight: 500; color: var(--text-muted); }
.cat-chip.mint .icon { background: var(--mint); }
.cat-chip.pink .icon { background: var(--pink); }
.cat-chip.peach .icon { background: var(--peach); }
.cat-chip.sky .icon { background: var(--sky); }
.cat-chip.lilac .icon { background: var(--lilac); }

.collection-row {
    display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px;
    -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.collection-row::-webkit-scrollbar { display: none; }
.collection-tile {
    flex: 0 0 130px;
    border-radius: var(--radius);
    padding: 16px 14px;
    display: flex; flex-direction: column; gap: 6px;
    color: var(--text);
    transition: transform .15s;
}
.collection-tile:hover { transform: translateY(-2px); color: var(--text); }
.collection-tile .emoji { font-size: 1.5rem; }
.collection-tile .label { font-weight: 600; font-size: 0.88rem; }
.collection-tile .count { font-size: 0.75rem; color: var(--text-muted); }
.collection-tile.mint { background: var(--mint); }
.collection-tile.pink { background: var(--pink); }
.collection-tile.peach { background: var(--peach); }
.collection-tile.blue { background: var(--sky); }
.collection-tile.purple { background: var(--lilac); }
.collection-tile.yellow { background: var(--yellow); }

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

.top-bar { display: none; } /* replaced by sidebar / mobile-top */

@media (min-width: 900px) {
    .page-hero { padding: 0 0 12px; }
    .page-hero-inner { max-width: 100%; }
    .grid-2 { grid-template-columns: repeat(3, 1fr); }
}

/* Product / item cards — marketplace-style */
.product-card {
    background: var(--bg-card);
    border-radius: 14px;
    overflow: hidden;
    border: 1px solid var(--border-soft);
    transition: box-shadow .18s, transform .18s;
    display: flex;
    flex-direction: column;
}
.product-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.product-card .thumb {
    height: 160px;
    background: linear-gradient(160deg, #f7f8fa, #eef1f4);
    position: relative;
    overflow: hidden;
}
.product-card .thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    cursor: pointer;
    transition: transform .25s ease;
}
.product-card:hover .thumb img { transform: scale(1.04); }
.product-card .thumb .placeholder {
    height: 100%;
    display: flex; align-items: center; justify-content: center;
    font-size: 2.5rem; opacity: 0.35;
}
.product-card .heart {
    position: absolute;
    top: 8px; right: 8px;
    width: 32px; height: 32px;
    border-radius: 50%;
    background: rgba(255,255,255,0.95);
    display: flex; align-items: center; justify-content: center;
    font-size: 0.85rem;
    box-shadow: 0 2px 8px rgba(0,0,0,.12);
    border: none;
    cursor: pointer;
    z-index: 2;
}
.product-card .heart:hover { background: #fff; }
.product-card .body {
    padding: 10px 12px 12px;
    display: flex;
    flex-direction: column;
    flex: 1;
    gap: 4px;
}
.product-card .title {
    font-weight: 600;
    font-size: 0.86rem;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    min-height: 2.3em;
}
.product-card .price-row {
    display: flex;
    flex-direction: column;
    gap: 1px;
    margin-top: 2px;
}
.product-card .price {
    font-weight: 700;
    font-size: 1.12rem;
    line-height: 1.25;
    color: var(--text);
}
.product-card .price-eq,
.product-card .eq {
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.product-card .item-note {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin: 2px 0 0;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.product-card .meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.product-card .sku-badge {
    display: inline-block;
    background: #f0f2f5;
    border-radius: 6px;
    padding: 2px 7px;
    font-size: 0.7rem;
    color: #555;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
[data-theme="dark"] .product-card .sku-badge {
    background: rgba(255,255,255,0.08);
    color: var(--text-muted);
}
.product-card .card-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: auto;
    padding-top: 8px;
}
.product-card .btn-shop {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #7b5cff;
    color: #fff !important;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 8px 10px;
    border-radius: 999px;
    text-decoration: none;
    border: none;
    cursor: pointer;
    transition: background .15s, transform .1s;
}
.product-card .btn-shop:hover {
    background: #6848e8;
    color: #fff !important;
}
.product-card .btn-icon-action {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--bg-card);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    flex-shrink: 0;
    padding: 0;
    transition: background .15s, color .15s, border-color .15s;
}
.product-card .btn-icon-action:hover {
    background: #f3f0ff;
    color: #7b5cff;
    border-color: #cbb8ff;
}
.product-card .btn-icon-danger:hover {
    background: #fdeaea;
    color: #d64545;
    border-color: #f0b4b4;
}
.product-card .actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.copy-item-name {
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 0.95rem;
}
/* Legacy alias */
.product-card .btn-add {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: #7b5cff;
    color: #fff !important;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 8px 12px;
    border-radius: 999px;
    text-decoration: none;
    margin-top: 6px;
}
.filters {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}
.filters select {
    padding: 8px 12px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.85rem;
    color: var(--text-muted);
}
.item-count-label {
    font-size: 0.88rem;
    color: var(--text-muted);
    margin-bottom: 12px;
}
.grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (min-width: 900px) {
    .grid { grid-template-columns: repeat(3, 1fr); gap: 16px; }
}
@media (min-width: 1100px) {
    .grid { grid-template-columns: repeat(4, 1fr); }
}
.friend-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-soft);
}
.friend-item:last-child { border-bottom: none; }
.profile-avatar {
    width: 72px; height: 72px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 10px;
}
.profile-avatar-placeholder {
    width: 72px; height: 72px;
    border-radius: 50%;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-size: 2rem;
    margin: 0 auto 10px;
}
.profile-name { font-size: 1.2rem; font-weight: 650; text-align: center; }
.profile-handle, .profile-bio { text-align: center; color: var(--text-muted); font-size: 0.88rem; }
.settings-section-title {
    font-size: 0.72rem;
    font-weight: 650;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    margin: 16px 0 8px;
    padding-left: 4px;
}

/* ========== DARK THEME ========== */
[data-theme="dark"] {
    --mint: #1a3d38;
    --mint-deep: #2a5c54;
    --pink: #3d2a30;
    --pink-deep: #5a3a42;
    --lavender: #2e2a3d;
    --cream: #1e2220;
    --peach: #3d3228;
    --sky: #1e2e38;
    --lilac: #2a2838;
    --rose: #3a2830;
    --yellow: #3a3420;
    --bg: #121514;
    --bg-card: #1c211f;
    --bg-input: #161a18;
    --border: #2a322f;
    --border-soft: #242a28;
    --text: #e8eeec;
    --text-muted: #8a9692;
    --text-soft: #6a7672;
    --primary: #4db8a8;
    --primary-hover: #6ad0c0;
    --primary-soft: #1a332f;
    --primary-text: #a8e8dc;
    --accent: #e8a0b0;
    --danger: #e07070;
    --success: #5aba8a;
    --warning: #e0b050;
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .sidebar {
    background: #161a18;
    border-right-color: var(--border);
}
[data-theme="dark"] .mobile-top {
    background: rgba(22, 26, 24, 0.92);
    border-bottom-color: var(--border);
}
[data-theme="dark"] .bottom-nav {
    background: #161a18;
    border-top-color: var(--border);
}
[data-theme="dark"] .bn-fab {
    box-shadow: 0 4px 16px rgba(77, 184, 168, 0.35);
}
[data-theme="dark"] .search-bar input,
[data-theme="dark"] .desktop-search input {
    background: var(--bg-card);
    color: var(--text);
}
[data-theme="dark"] .form-group input,
[data-theme="dark"] .form-group select,
[data-theme="dark"] .form-group textarea,
[data-theme="dark"] input[type="text"],
[data-theme="dark"] input[type="password"],
[data-theme="dark"] input[type="email"],
[data-theme="dark"] input[type="url"],
[data-theme="dark"] input[type="number"],
[data-theme="dark"] input[type="search"],
[data-theme="dark"] input[type="tel"],
[data-theme="dark"] textarea,
[data-theme="dark"] select {
    background: var(--bg-input);
    color: var(--text);
    border-color: var(--border);
    color-scheme: dark;
}
[data-theme="dark"] .form-group input:focus,
[data-theme="dark"] .form-group select:focus,
[data-theme="dark"] .form-group textarea:focus,
[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] input[type="password"]:focus,
[data-theme="dark"] input[type="email"]:focus,
[data-theme="dark"] input[type="url"]:focus,
[data-theme="dark"] input[type="number"]:focus,
[data-theme="dark"] input[type="search"]:focus,
[data-theme="dark"] textarea:focus,
[data-theme="dark"] select:focus {
    background: var(--bg-card);
    color: var(--text);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(77, 184, 168, 0.2);
}
/* Prevent browser autofill from forcing white backgrounds in dark mode */
[data-theme="dark"] input:-webkit-autofill,
[data-theme="dark"] input:-webkit-autofill:hover,
[data-theme="dark"] input:-webkit-autofill:focus,
[data-theme="dark"] textarea:-webkit-autofill,
[data-theme="dark"] select:-webkit-autofill {
    -webkit-text-fill-color: var(--text) !important;
    -webkit-box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
    box-shadow: 0 0 0 1000px var(--bg-input) inset !important;
    caret-color: var(--text);
    transition: background-color 99999s ease-out 0s;
}
[data-theme="dark"] .modal {
    background: var(--bg-card);
}
[data-theme="dark"] .modal-header {
    background: var(--bg-card);
    border-bottom-color: var(--border);
}
[data-theme="dark"] .auth-page {
    background: linear-gradient(160deg, #0e1210 0%, #121514 50%, #0e1418 100%);
}
[data-theme="dark"] .auth-card {
    background: var(--bg-card);
}
[data-theme="dark"] .alert-success { background: #1a2e24; color: #8ad4a8; border-color: #2a4a38; }
[data-theme="dark"] .alert-error { background: #2e1a1a; color: #e0a0a0; border-color: #4a2a2a; }
[data-theme="dark"] .alert-info { background: #1a2430; color: #90b0e0; border-color: #2a3a50; }
[data-theme="dark"] .btn-danger { background: #2e1a1a; color: #e08080; }
[data-theme="dark"] .btn-danger:hover { background: #3a2020; }
[data-theme="dark"] .btn-secondary { background: var(--bg); color: var(--text); border-color: var(--border); }
[data-theme="dark"] .product-card .heart { background: rgba(30, 35, 33, 0.9); }
[data-theme="dark"] .item-badge.reserved { background: rgba(180, 60, 60, 0.9); }
[data-theme="dark"] .item-badge.available { background: rgba(40, 130, 90, 0.9); }

/* ========== NOTIFICATIONS ========== */
.notif-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.notif-row {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 14px 12px 14px 16px;
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 1px solid var(--border-soft);
    color: var(--text);
    transition: background .15s, box-shadow .15s;
    position: relative;
}
.notif-row:hover {
    box-shadow: var(--shadow);
    color: var(--text);
}
.notif-row.unread {
    background: var(--primary-soft);
    border-color: transparent;
}
.notif-row-link {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    flex: 1;
    min-width: 0;
    color: inherit;
    text-decoration: none;
}
.notif-row-link:hover { color: inherit; }
.notif-avatar {
    width: 44px; height: 44px;
    border-radius: 50%;
    overflow: hidden;
    background: var(--primary-soft);
    display: flex; align-items: center; justify-content: center;
    font-weight: 600;
    color: var(--primary-text);
    flex-shrink: 0;
}
.notif-avatar img { width: 100%; height: 100%; object-fit: cover; }
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; font-size: 0.92rem; line-height: 1.35; }
.notif-text { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.notif-time { font-size: 0.75rem; color: var(--text-soft); margin-top: 4px; }
.notif-dot {
    width: 10px; height: 10px;
    border-radius: 50%;
    background: var(--primary);
    flex-shrink: 0;
    margin-top: 6px;
}
.notif-delete {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    color: var(--text-soft);
    font-size: 1.25rem;
    line-height: 1;
    text-decoration: none;
    opacity: 0.55;
    transition: opacity .15s, background .15s, color .15s;
    margin-top: 4px;
}
.notif-delete:hover {
    opacity: 1;
    background: #fce0e0;
    color: #c04040;
}
[data-theme="dark"] .notif-delete:hover {
    background: #2e1a1a;
    color: #e08080;
}

/* Badge on nav */
.nav-badge {
    position: absolute;
    top: -2px; right: 8px;
    min-width: 16px; height: 16px;
    padding: 0 4px;
    background: var(--danger);
    color: #fff;
    border-radius: var(--radius-pill);
    font-size: 0.65rem;
    font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    line-height: 1;
}
.bn-item { position: relative; }
.sidebar-link { position: relative; }
.sidebar-link .nav-badge { top: 8px; right: 10px; }

/* Language / theme switcher chips */
.pref-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.pref-chip {
    padding: 8px 14px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--bg-card);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-muted);
    cursor: pointer;
    transition: all .15s;
}
.pref-chip:hover { border-color: var(--primary); color: var(--primary); }
.pref-chip.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary-text);
}

/* Settings toggle for dark mode */
.settings-item .toggle {
    cursor: pointer;
}

/* ===== Custom file upload buttons ===== */
.file-upload {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
}
/* Input lives inside the label and covers the whole button — reliable first-tap on mobile */
.file-upload-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 18px;
    border-radius: var(--radius, 12px);
    border: 1.5px dashed var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.92rem;
    font-weight: 550;
    cursor: pointer;
    transition: border-color .15s, background .15s, color .15s;
    text-align: center;
    line-height: 1.3;
    position: relative;
    overflow: hidden;
    /* Prevent text selection / callout on long-press or repeated taps */
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
}
.file-upload-btn input[type="file"] {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
    border: 0;
    z-index: 2;
}
.file-upload-btn:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-text, var(--primary));
}
.file-upload-btn:active {
    transform: scale(0.99);
}
.file-upload-icon {
    font-size: 1.1rem;
    line-height: 1;
    pointer-events: none;
}
.file-upload .file-name {
    font-size: 0.82rem;
    color: var(--text-muted);
    text-align: center;
    word-break: break-all;
    pointer-events: none;
}
[data-theme="dark"] .file-upload-btn {
    background: var(--bg-card);
    border-color: var(--border);
}
[data-theme="dark"] .file-upload-btn:hover {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* Desktop-only helpers (hide duplicate mobile actions) */
.desktop-only { display: none !important; }
@media (min-width: 900px) {
    .desktop-only { display: flex !important; }
}

/* Mobile top bar — logo only, no action icons */
.mobile-top-inner {
    justify-content: flex-start;
}

/* ===== Search inputs: icon must never overlap text (final overrides) ===== */
.search-bar input[type="search"],
.search-bar input,
.desktop-search input[type="search"],
.desktop-search input {
    padding-left: 44px !important;
    padding-right: 16px;
}
.search-bar .search-icon,
.desktop-search .search-icon {
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1;
}


/* Wishlist detail cover / banner */
.list-cover {
    width: 100%;
    margin: 0 0 8px;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    overflow: hidden;
    background: var(--bg-card);
    position: relative;
}
.list-cover img {
    width: 100%;
    height: 160px;
    object-fit: cover;
    display: block;
}
@media (min-width: 900px) {
    .list-cover {
        max-width: 720px;
        margin: 0 auto 16px;
        border-radius: var(--radius-lg);
    }
    .list-cover img { height: 220px; }
}

/* Admin button group — stack on mobile */
.admin-btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 4px;
}
.admin-btn-group form {
    display: block;
    width: 100%;
}
.admin-btn-group .btn {
    width: 100%;
}
@media (min-width: 480px) {
    .admin-btn-group form {
        width: auto;
        display: inline-block;
    }
    .admin-btn-group .btn {
        width: auto;
    }
}

/* Copyable link */
.copyable-link {
    position: relative;
    margin-top: 6px;
}
.copyable-input {
    width: 100%;
    font-size: 0.85rem;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--bg-input);
    color: var(--text);
    cursor: pointer;
    user-select: all;
}
.copyable-input:focus {
    outline: 2px solid var(--primary);
    border-color: var(--primary);
}
.copy-hint {
    display: block;
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 4px;
}
.copyable-link.copied .copy-hint {
    color: var(--success);
}

/* Auth page theme/lang controls */
.auth-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    gap: 8px;
}
.auth-lang, .auth-theme {
    display: flex;
    gap: 4px;
}
.auth-chip {
    padding: 4px 10px;
    border-radius: var(--radius-pill);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-input);
    border: 1px solid var(--border);
    transition: all .15s;
}
.auth-chip:hover { color: var(--text); border-color: var(--primary); }
.auth-chip.active {
    background: var(--primary-soft);
    color: var(--primary-text);
    border-color: var(--primary);
}

/* Link mode radios */
.link-mode-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 6px;
}
.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    cursor: pointer;
}
.radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* Admin table */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.admin-table th,
.admin-table td {
    padding: 10px 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.admin-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}
.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.admin-actions form { display: inline; }
@media (max-width: 600px) {
    .admin-table th:nth-child(4),
    .admin-table td:nth-child(4),
    .admin-table th:nth-child(7),
    .admin-table td:nth-child(7) {
        display: none;
    }
}


/* Ensure fixed bottom nav is never clipped / shifted on long pages (e.g. Settings) */
.app-shell {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}
.main {
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}
.container {
    overflow-x: hidden;
}
/* Extra breathing room at end of settings so last cards clear the FAB */
body.has-nav .container {
    padding-bottom: 24px;
}

/* Soft SPA navigation progress bar */
#spaProgress {
    position: fixed;
    top: 0;
    left: 0;
    height: 3px;
    width: 0;
    z-index: 9999;
    background: linear-gradient(90deg, var(--primary, #3d9b8f), #7ec8be);
    pointer-events: none;
    opacity: 0;
    transition: width .35s ease, opacity .25s ease;
}
#spaProgress.spa-active {
    opacity: 1;
    width: 75%;
    transition: width .6s cubic-bezier(.4,0,.2,1), opacity .15s ease;
}
#spaProgress.spa-done {
    opacity: 0;
    width: 100%;
    transition: width .2s ease, opacity .35s ease .15s;
}

/* Keep main content stable during swaps */
main.main {
    min-height: 40vh;
}


/* ===== Card layouts (admin-controlled via data-card-layout) ===== */

/* VERTICAL — portrait product tiles (default, closer to marketplace) */
html[data-card-layout="vertical"] .grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}
@media (min-width: 700px) {
    html[data-card-layout="vertical"] .grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 14px;
    }
}
@media (min-width: 1100px) {
    html[data-card-layout="vertical"] .grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 16px;
    }
}
html[data-card-layout="vertical"] .product-card {
    flex-direction: column;
}
html[data-card-layout="vertical"] .product-card .thumb {
    height: auto;
    aspect-ratio: 3 / 4;
    max-height: 280px;
}
html[data-card-layout="vertical"] .product-card .body {
    padding: 10px 11px 12px;
}
html[data-card-layout="vertical"] .product-card .title {
    font-size: 0.84rem;
    -webkit-line-clamp: 3;
    min-height: 3.2em;
}
html[data-card-layout="vertical"] .product-card .price {
    font-size: 1.05rem;
}
html[data-card-layout="vertical"] .product-card .btn-shop {
    font-size: 0.78rem;
    padding: 9px 10px;
}

/* HORIZONTAL — wide row cards (image left, content right) */
html[data-card-layout="horizontal"] .grid {
    grid-template-columns: 1fr;
    gap: 10px;
}
@media (min-width: 900px) {
    html[data-card-layout="horizontal"] .grid {
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
}
html[data-card-layout="horizontal"] .product-card {
    flex-direction: row;
    align-items: stretch;
    min-height: 120px;
}
html[data-card-layout="horizontal"] .product-card .thumb {
    width: 120px;
    min-width: 120px;
    height: auto;
    align-self: stretch;
    flex-shrink: 0;
}
@media (min-width: 600px) {
    html[data-card-layout="horizontal"] .product-card .thumb {
        width: 150px;
        min-width: 150px;
    }
}
html[data-card-layout="horizontal"] .product-card .body {
    padding: 10px 12px;
    justify-content: center;
}
html[data-card-layout="horizontal"] .product-card .title {
    -webkit-line-clamp: 2;
    min-height: 0;
    font-size: 0.9rem;
}
html[data-card-layout="horizontal"] .product-card .card-actions {
    padding-top: 6px;
}
html[data-card-layout="horizontal"] .product-card .btn-shop {
    max-width: 160px;
}
html[data-card-layout="horizontal"] .product-card .heart {
    top: 6px;
    right: 6px;
    width: 28px;
    height: 28px;
    font-size: 0.75rem;
}

/* Admin layout preview chips */
.layout-choice {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}
.layout-choice label {
    flex: 1;
    min-width: 140px;
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    background: var(--bg-card);
    transition: border-color .15s, box-shadow .15s;
}
.layout-choice label:has(input:checked) {
    border-color: #7b5cff;
    box-shadow: 0 0 0 3px rgba(123, 92, 255, 0.15);
}
.layout-choice input { margin-right: 8px; }
.layout-preview {
    height: 56px;
    border-radius: 8px;
    background: #f0f2f5;
    margin-bottom: 8px;
    display: flex;
    gap: 4px;
    padding: 6px;
}
[data-theme="dark"] .layout-preview { background: rgba(255,255,255,0.06); }
.layout-preview.v .lp-card {
    flex: 1;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
}
.layout-preview.h {
    flex-direction: column;
}
.layout-preview.h .lp-card {
    flex: 1;
    background: #fff;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    display: flex;
}
.layout-preview.h .lp-card::before {
    content: '';
    width: 28%;
    background: #dde3ea;
    border-radius: 4px 0 0 4px;
}
[data-theme="dark"] .layout-preview .lp-card {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.1);
}
[data-theme="dark"] .layout-preview.h .lp-card::before {
    background: rgba(255,255,255,0.12);
}


/* List cards follow global card layout */
html[data-card-layout="vertical"] .lists-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (min-width: 700px) {
    html[data-card-layout="vertical"] .lists-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 1100px) {
    html[data-card-layout="vertical"] .lists-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
html[data-card-layout="vertical"] .list-card {
    flex-direction: column;
}
html[data-card-layout="vertical"] .list-card-img {
    height: auto;
    aspect-ratio: 3 / 4;
    max-height: 240px;
}

html[data-card-layout="horizontal"] .lists-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
}
@media (min-width: 900px) {
    html[data-card-layout="horizontal"] .lists-grid {
        grid-template-columns: 1fr 1fr;
    }
}
html[data-card-layout="horizontal"] .list-card {
    flex-direction: row;
    align-items: stretch;
    min-height: 110px;
}
html[data-card-layout="horizontal"] .list-card-img {
    width: 120px;
    min-width: 120px;
    height: auto;
    align-self: stretch;
}
@media (min-width: 600px) {
    html[data-card-layout="horizontal"] .list-card-img {
        width: 150px;
        min-width: 150px;
    }
}
html[data-card-layout="horizontal"] .list-card-body {
    justify-content: center;
    padding: 10px 12px;
}
html[data-card-layout="horizontal"] .list-card-meta {
    margin-bottom: 8px;
}

/* List totals bar */
.list-totals {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 8px 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-soft);
    border-radius: 12px;
    padding: 10px 14px;
    margin-bottom: 14px;
}
.list-totals-label {
    font-weight: 600;
    font-size: 0.88rem;
    color: var(--text-muted);
}
.list-totals-values {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    font-size: 0.9rem;
}
.list-total-main {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}
.list-total-sep {
    color: var(--text-muted);
    opacity: 0.6;
}

/* Admin rates table */
.rates-table-wrap { overflow-x: auto; }
.rates-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
}
.rates-table th,
.rates-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border-soft);
}
.rates-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.8rem;
}

.rates-attempts { font-size: 0.85rem; color: var(--text-muted); }
.rates-attempts summary { cursor: pointer; user-select: none; }
.rates-attempts-list { margin: 8px 0 0; padding-left: 1.2em; }
.rates-attempts-list li { margin: 2px 0; }
.rates-attempts-list li.ok { color: var(--success, #2a9d6e); }
.rates-attempts-list li.fail { color: var(--text-muted); }
.rates-attempts-list .muted { opacity: 0.7; font-size: 0.8em; }
.manual-rates-form input[type="number"] {
    width: 140px;
    padding: 8px 10px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text);
}
