@import url('https://fonts.googleapis.com/css2?family=Fraunces:opsz,wght@9..144,400;9..144,500;9..144,600;9..144,700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    --bg: #faf6ef;
    --paper: #fffdf8;
    --ink: #1d2621;
    --ink-soft: #5b6a60;
    --ink-faint: #8a988e;
    --line: #e3dccb;
    --line-soft: #eee7d6;
    --primary: #2b4a3a;
    --primary-soft: #e5ede6;
    --accent: #c45a32;
    --accent-soft: #f7e5dc;
    --warning: #b77a1a;
    --focus: #86a28d;
    --shadow-sm: 0 1px 2px rgba(29, 38, 33, 0.04), 0 1px 3px rgba(29, 38, 33, 0.06);
    --shadow-md: 0 2px 4px rgba(29, 38, 33, 0.04), 0 8px 16px rgba(29, 38, 33, 0.06);
    --radius: 10px;
    --radius-lg: 16px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--ink);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
    font-family: 'Fraunces', 'Georgia', serif;
    font-weight: 500;
    color: var(--ink);
    letter-spacing: -0.01em;
    margin: 0;
}

h1 { font-size: 2.1rem; line-height: 1.15; font-weight: 600; letter-spacing: -0.025em; }
h2 { font-size: 1.4rem; }
h3 { font-size: 1.1rem; }

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

h1:focus { outline: none; }

/* ===== Layout ===== */
.app-shell {
    display: grid;
    grid-template-columns: 240px 1fr;
    min-height: 100vh;
}

.topbar { display: none; }
.drawer-backdrop { display: none; }

.sidebar {
    background: var(--paper);
    border-right: 1px solid var(--line);
    padding: 28px 20px;
    position: sticky;
    top: 0;
    height: 100vh;
    display: flex;
    flex-direction: column;
    z-index: 50;
}

.brand {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
    color: var(--ink);
    padding: 0 8px 22px;
    border-bottom: 1px solid var(--line-soft);
    margin-bottom: 18px;
}
.brand em {
    font-style: italic;
    color: var(--accent);
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--ink-soft);
    font-weight: 500;
    font-size: 0.93rem;
    transition: background 0.15s, color 0.15s;
}
.nav a:hover {
    background: var(--line-soft);
    color: var(--ink);
    text-decoration: none;
}
.nav a.active {
    background: var(--primary-soft);
    color: var(--primary);
}
.nav a .dot {
    width: 5px; height: 5px; border-radius: 50%;
    background: currentColor;
    opacity: 0.5;
}
.nav .nav-divider {
    margin-top: 14px;
    padding: 6px 12px 2px;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-soft);
    opacity: 0.7;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
    font-size: 0.78rem;
    color: var(--ink-faint);
    line-height: 1.4;
}

.content {
    padding: 40px 48px 80px;
    max-width: 1100px;
    width: 100%;
}

/* ===== Mobile adaptation (< 768px) ===== */
@media (max-width: 767px) {
    .app-shell {
        grid-template-columns: 1fr;
    }
    .topbar {
        display: flex;
        align-items: center;
        gap: 14px;
        position: sticky;
        top: 0;
        z-index: 30;
        height: 56px;
        padding: 0 14px;
        background: var(--paper);
        border-bottom: 1px solid var(--line);
        box-shadow: 0 1px 3px rgba(29, 38, 33, 0.04);
    }
    .topbar-brand {
        font-family: 'Fraunces', serif;
        font-weight: 600;
        font-size: 1.2rem;
        color: var(--ink);
    }
    .topbar-brand em { font-style: italic; color: var(--accent); }
    .hamburger {
        display: flex;
        flex-direction: column;
        justify-content: center;
        gap: 4px;
        width: 40px;
        height: 40px;
        border: 0;
        background: transparent;
        cursor: pointer;
        padding: 0;
        border-radius: 8px;
    }
    .hamburger:hover { background: var(--line-soft); }
    .hamburger span {
        display: block;
        width: 22px;
        height: 2px;
        background: var(--ink);
        border-radius: 2px;
        margin: 0 auto;
    }
    .topbar-scan {
        margin-left: auto;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
        border-radius: 10px;
        background: var(--primary);
        color: #fff !important;
        font-size: 1.3rem;
        text-decoration: none;
    }
    .topbar-scan:hover { text-decoration: none; }
    .scan-icon { transform: rotate(45deg); font-weight: bold; }

    .sidebar {
        position: fixed;
        top: 0; left: 0;
        width: 260px;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform 0.22s ease-out;
        box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    }
    .app-shell.drawer-open .sidebar { transform: translateX(0); }
    .app-shell.drawer-open .drawer-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(29, 38, 33, 0.35);
        z-index: 40;
        backdrop-filter: blur(2px);
    }
    .content {
        padding: 20px 16px 80px;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .page-header .actions {
        width: 100%;
        flex-wrap: wrap;
    }
    .page-header .actions .btn { flex: 1; min-width: 0; }

    /* Roomier tap targets */
    .btn-sm { padding: 8px 12px; font-size: 0.88rem; }
    select, input[type="text"], input[type="number"], input[type="date"], input[type="search"], input[type="url"], input[type="password"] {
        font-size: 16px; /* prevents iOS zoom-on-focus */
        padding: 10px 12px;
    }
    .chip { padding: 3px 10px; font-size: 0.82rem; }

    /* Planner: horizontal scroll on small screens */
    .planner {
        grid-template-columns: 80px repeat(7, minmax(120px, 1fr));
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Stack the two-column grids everywhere */
    .grid[style*="1fr 1fr"], .grid[style*="2fr 1fr"] {
        grid-template-columns: 1fr !important;
    }
    .recipe-detail { grid-template-columns: 1fr; gap: 24px; }
    .grid-recipes { grid-template-columns: 1fr; }
}

@media (min-width: 768px) {
    .topbar { display: none; }
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 28px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--line);
}
.page-header .lede {
    color: var(--ink-soft);
    font-size: 0.95rem;
    margin-top: 6px;
    max-width: 60ch;
}
.page-header .actions { display: flex; gap: 8px; }

/* ===== Buttons & controls ===== */
.btn {
    font: inherit;
    font-weight: 500;
    padding: 8px 14px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:hover { border-color: var(--ink-faint); }
.btn:active { transform: translateY(1px); }
.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}
.btn-primary:hover { background: #1f3a2c; border-color: #1f3a2c; }
.btn-ghost {
    border-color: transparent;
    background: transparent;
    color: var(--ink-soft);
}
.btn-ghost:hover { background: var(--line-soft); color: var(--ink); }
.btn-sm { padding: 4px 9px; font-size: 0.82rem; border-radius: 6px; }
.btn-danger { color: var(--accent); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--accent-soft); }

select, input[type="text"], input[type="number"], input[type="date"], input[type="search"] {
    font: inherit;
    padding: 7px 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    color: var(--ink);
    transition: border-color 0.15s, box-shadow 0.15s;
}
select:focus, input:focus {
    outline: none;
    border-color: var(--focus);
    box-shadow: 0 0 0 3px rgba(134, 162, 141, 0.2);
}

/* ===== Cards ===== */
.card {
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.card-hover {
    transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
    cursor: pointer;
}
.card-hover:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: var(--ink-faint);
}

/* ===== Tags / chips ===== */
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--line-soft);
    color: var(--ink-soft);
    font-weight: 500;
    white-space: nowrap;
}
.chip-primary { background: var(--primary-soft); color: var(--primary); }
.chip-accent { background: var(--accent-soft); color: var(--accent); }
.chip-warn { background: #fdf0d9; color: var(--warning); }

/* ===== Recipes grid ===== */
.grid { display: grid; gap: 16px; }
.grid-recipes { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.recipe-card h3 { margin-bottom: 6px; }
.recipe-card .desc {
    color: var(--ink-soft);
    font-size: 0.9rem;
    min-height: 2.8em;
    margin-bottom: 14px;
}
.recipe-card .meta {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.recipe-card .times {
    display: flex;
    gap: 16px;
    font-size: 0.8rem;
    color: var(--ink-soft);
    padding-top: 12px;
    border-top: 1px solid var(--line-soft);
}
.recipe-card .times span strong { color: var(--ink); font-weight: 600; }

/* ===== Weekly planner grid ===== */
.planner {
    display: grid;
    grid-template-columns: 120px repeat(7, 1fr);
    gap: 1px;
    background: var(--line);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    overflow: hidden;
}
.planner-head, .planner-cell {
    background: var(--paper);
    padding: 10px 12px;
    min-height: 84px;
}
.planner-head {
    font-size: 0.78rem;
    color: var(--ink-faint);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    text-align: center;
    min-height: 0;
    padding: 10px 6px;
}
.planner-head .day { color: var(--ink); text-transform: none; font-size: 1rem; font-weight: 500; letter-spacing: 0; }
.planner-rowhead {
    background: var(--bg);
    font-size: 0.8rem;
    color: var(--ink-soft);
    font-weight: 600;
    display: flex;
    align-items: center;
}
.planner-cell {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;
}
.planner-cell .recipe-name {
    font-weight: 500;
    color: var(--ink);
    line-height: 1.3;
}
.planner-cell .leftover {
    font-size: 0.72rem;
    color: var(--accent);
    font-weight: 500;
}
.planner-cell .empty-slot {
    color: var(--ink-faint);
    font-size: 0.82rem;
    font-style: italic;
}
.planner-cell select {
    font-size: 0.78rem;
    padding: 3px 6px;
    width: 100%;
    max-width: 100%;
}

/* ===== Recipe detail ===== */
.recipe-detail { display: grid; grid-template-columns: 2fr 1fr; gap: 32px; }
.recipe-detail h2 { margin-bottom: 8px; }
.recipe-detail .meta-row { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }

.steps { counter-reset: step; list-style: none; padding: 0; margin: 0; }
.steps li {
    counter-increment: step;
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 14px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line-soft);
}
.steps li:last-child { border-bottom: none; }
.steps li::before {
    content: counter(step);
    font-family: 'Fraunces', serif;
    font-size: 1.3rem;
    color: var(--accent);
    font-weight: 500;
    line-height: 1.2;
}

.ingredients {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.ingredients h3 {
    font-family: 'Fraunces', serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-faint);
    font-weight: 600;
    margin-bottom: 12px;
}
.ingredients ul { list-style: none; padding: 0; margin: 0; }
.ingredients li {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    padding: 6px 0;
    font-size: 0.9rem;
    border-bottom: 1px dotted var(--line);
}
.ingredients li:last-child { border: none; }
.ingredients .amount { color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.ingredients .optional { font-size: 0.72rem; color: var(--ink-faint); margin-left: 6px; font-style: italic; }

/* ===== Shopping list ===== */
.shop-section { margin-bottom: 28px; }
.shop-section h3 {
    font-family: 'Fraunces', serif;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.12em;
    color: var(--ink-faint);
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--line);
}
.shop-list { list-style: none; padding: 0; margin: 0; }
.shop-list li {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    gap: 12px;
    padding: 8px 0;
    font-size: 0.93rem;
    align-items: center;
}
.shop-list .qty { color: var(--ink-soft); font-variant-numeric: tabular-nums; font-size: 0.85rem; }
.shop-list input[type="checkbox"] { accent-color: var(--primary); }

/* ===== Prep schedule ===== */
.prep-day { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.prep-day:last-child { border-bottom: none; }
.prep-day-head {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
}
.prep-day-head .day {
    font-family: 'Fraunces', serif;
    font-size: 1.05rem;
    font-weight: 500;
}
.prep-day-head .date { color: var(--ink-faint); font-size: 0.82rem; }
.prep-task {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.9rem;
}
.prep-task .minutes { color: var(--ink-faint); font-size: 0.8rem; }

/* ===== Exclusion chips ===== */
.exclusion-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    padding: 14px 18px;
    background: var(--accent-soft);
    border-radius: var(--radius);
    margin-bottom: 24px;
    border: 1px solid #f0d1bf;
}
.exclusion-bar .label {
    font-size: 0.82rem;
    color: var(--accent);
    font-weight: 600;
    letter-spacing: 0.02em;
}
.exclusion-bar .chip {
    background: var(--paper);
    border: 1px solid #e9c4b1;
    color: var(--accent);
    font-weight: 600;
    cursor: default;
}
.exclusion-bar .chip button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    margin-left: 2px;
    opacity: 0.6;
}
.exclusion-bar .chip button:hover { opacity: 1; }

/* ===== Misc ===== */
.empty-state {
    padding: 48px 24px;
    text-align: center;
    color: var(--ink-faint);
    background: var(--paper);
    border: 1px dashed var(--line);
    border-radius: var(--radius-lg);
}
.empty-state h3 { margin-bottom: 6px; color: var(--ink-soft); }

.pill-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pill-row .btn { border-radius: 999px; font-size: 0.85rem; padding: 5px 12px; }
.pill-row .btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.muted { color: var(--ink-soft); }
.tiny { font-size: 0.8rem; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.spacer { flex: 1; }
.divider { height: 1px; background: var(--line); margin: 20px 0; }

/* ===== Modals ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(29, 38, 33, 0.45);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    backdrop-filter: blur(4px);
}
.modal {
    background: var(--paper);
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 560px;
    padding: 28px 30px;
    animation: modal-in 0.15s ease-out;
}
@keyframes modal-in {
    from { opacity: 0; transform: translateY(6px) scale(0.98); }
    to { opacity: 1; transform: none; }
}
.modal h2 { margin-bottom: 4px; }
.modal .lede { color: var(--ink-soft); font-size: 0.92rem; margin-bottom: 20px; }
.modal textarea {
    font: inherit;
    width: 100%;
    min-height: 100px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--paper);
    resize: vertical;
}
.modal textarea:focus { outline: none; border-color: var(--focus); box-shadow: 0 0 0 3px rgba(134, 162, 141, 0.2); }
.modal input[type="text"], .modal input[type="url"] { width: 100%; }
.modal-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

.spinner {
    width: 14px; height: 14px;
    border: 2px solid var(--line);
    border-top-color: var(--primary);
    border-radius: 50%;
    display: inline-block;
    animation: spin 0.8s linear infinite;
    vertical-align: middle;
    margin-right: 6px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.ai-chip {
    background: linear-gradient(90deg, #e5ede6, #f7e5dc);
    color: var(--primary);
    font-weight: 600;
    font-size: 0.7rem;
    padding: 2px 8px;
    border-radius: 999px;
    letter-spacing: 0.04em;
}

.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--ink);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 0.88rem;
    z-index: 200;
    box-shadow: var(--shadow-md);
    animation: toast-in 0.2s ease-out;
}
.toast.error { background: var(--accent); }
@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 8px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* ===== Cook-with-me mode ===== */
.cook-topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0 20px;
    border-bottom: 1px solid var(--line);
    margin-bottom: 28px;
}
.cook-recipe-title {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 1.1rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cook-step {
    display: grid;
    grid-template-columns: 80px 1fr;
    gap: 18px;
    align-items: start;
    padding: 36px 36px 40px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    margin-bottom: 20px;
    min-height: 200px;
}
.cook-step-num {
    font-family: 'Fraunces', serif;
    font-size: 4rem;
    font-weight: 500;
    color: var(--accent);
    line-height: 0.9;
}
.cook-step-text {
    font-size: 1.25rem;
    line-height: 1.55;
    color: var(--ink);
}
.cook-nav {
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: space-between;
    margin-bottom: 28px;
}
.cook-progress {
    display: inline-flex;
    gap: 6px;
    align-items: center;
    flex: 1;
    justify-content: center;
}
.cook-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--line);
    display: inline-block;
    transition: background 0.15s, transform 0.15s;
}
.cook-dot.done { background: var(--primary); opacity: 0.6; }
.cook-dot.current {
    background: var(--accent);
    transform: scale(1.4);
}

.cook-chat h3 { font-size: 1rem; }
.cook-transcript {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 10px;
    max-height: 460px;
    overflow-y: auto;
}
.cook-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    max-width: 85%;
    font-size: 0.95rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.cook-bubble.user {
    background: var(--primary-soft);
    color: var(--primary);
    align-self: flex-end;
}
.cook-bubble.assistant {
    background: var(--bg);
    border: 1px solid var(--line-soft);
    align-self: flex-start;
}
.cook-bubble-who {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.6;
    margin-bottom: 4px;
}
.cook-caret {
    display: inline-block;
    margin-left: 2px;
    color: var(--accent);
    animation: caret-blink 1s steps(1, end) infinite;
}
@keyframes caret-blink {
    50% { opacity: 0; }
}

/* ===== Shelf photo preview ===== */
.shelf-preview {
    max-width: 100%;
    max-height: 360px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--line);
    display: block;
    object-fit: contain;
    background: var(--bg);
}

/* ===== Rating thumbs ===== */
.rating-row {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-left: 6px;
}
.rating-row .thumb {
    background: transparent;
    border: 0;
    padding: 2px 5px;
    font-size: 0.92rem;
    line-height: 1;
    cursor: pointer;
    border-radius: 5px;
    opacity: 0.4;
    transition: background 0.12s, opacity 0.12s, transform 0.05s;
}
.rating-row .thumb:hover { opacity: 0.85; background: var(--line-soft); }
.rating-row .thumb:active { transform: translateY(1px); }
.rating-row .thumb.active { opacity: 1; background: var(--primary-soft); }
.rating-row .thumb.active.down { background: var(--accent-soft); }
.rating-row .thumb.active.mid { background: #fdf0d9; }

/* ===== Cooked toggle ===== */
.cooked-toggle {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    color: var(--ink-faint);
    cursor: pointer;
    user-select: none;
    padding: 2px 6px;
    border-radius: 6px;
    transition: background 0.12s;
}
.cooked-toggle:hover { background: var(--line-soft); color: var(--ink-soft); }
.cooked-toggle input { accent-color: var(--primary); cursor: pointer; margin: 0; }
.cooked-toggle.on { color: var(--primary); font-weight: 600; }
.cooked-toggle.skipped { color: var(--accent); font-style: italic; }

/* ===== Location chip variants (reuses base .chip) ===== */
.chip.chip-warn { background: #fdf0d9; color: var(--warning); }

/* ===== Scan page ===== */
.scan-stage {
    position: relative;
    width: 100%;
    max-width: 560px;
    aspect-ratio: 4 / 3;
    margin: 0 auto 8px;
    border-radius: var(--radius-lg);
    overflow: hidden;
    background: #000;
    box-shadow: var(--shadow-md);
}
.scan-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.scan-reticle {
    position: absolute;
    left: 10%;
    right: 10%;
    top: 38%;
    height: 24%;
    border: 2px solid rgba(255, 255, 255, 0.75);
    border-radius: 10px;
    box-shadow: 0 0 0 100vmax rgba(0, 0, 0, 0.35);
    pointer-events: none;
}
.scan-chrome {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    padding: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to top, rgba(0,0,0,0.55), transparent);
    color: #fff;
}
.scan-chrome .btn {
    background: rgba(255, 255, 255, 0.92);
    color: var(--ink);
    border-color: transparent;
}
.scan-status {
    font-size: 0.82rem;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}
.scan-thumb {
    width: 72px;
    height: 72px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--bg);
    flex-shrink: 0;
}
.confirm-card { border: 2px solid var(--primary-soft); }

/* ===== Match cards (semantic search results) ===== */
.match-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--line-soft);
    align-items: start;
}
.match-row:last-child { border: none; }
.match-row .why { color: var(--ink-soft); font-size: 0.88rem; margin-top: 3px; }

/* Errors */
.valid.modified:not([type=checkbox]) { outline: 1px solid #26b050; }
.invalid { outline: 1px solid #e50000; }
.validation-message { color: #e50000; }

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}
#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: 8px;
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* ───────────────────────────────────────────────────────────────
   Auth pages — standalone, center-card layout, no sidebar.
   ─────────────────────────────────────────────────────────────── */

.auth-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}
.auth-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
}
.auth-header .brand {
    font-family: 'Fraunces', serif;
    font-weight: 600;
    font-size: 1.4rem;
    color: var(--ink);
    padding: 0;
    border: none;
    margin: 0;
}
.auth-header .brand em { font-style: italic; color: var(--accent); }

.auth-main {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
}
.auth-footer {
    padding: 20px 32px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--ink-faint);
    border-top: 1px solid var(--line-soft);
}

.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-sm);
}
.auth-card h1 {
    font-size: 1.9rem;
    margin-bottom: 6px;
}
.auth-card .muted { color: var(--ink-soft); font-size: 0.95rem; }

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 24px;
}

/* Labelled form-field wrapper. Stacks label on top of input with sensible
   spacing; used on auth pages and anywhere else that wants the same shape. */
.pos-field label {
    display: block;
    font-weight: 600;
    color: var(--ink);
    margin-bottom: 6px;
    font-size: 0.95rem;
}
.pos-field input,
.pos-field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-family: inherit;
    font-size: 1rem;
    background: var(--bg);
    color: var(--ink);
}
.pos-field input:focus,
.pos-field textarea:focus {
    outline: 2px solid var(--focus);
    border-color: var(--focus);
}
.pos-field input:disabled {
    background: var(--line-soft);
    color: var(--ink-faint);
}
.pos-field .hint {
    font-size: 0.82rem;
    color: var(--ink-faint);
    margin-top: 4px;
}

.auth-btn {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: var(--paper);
    color: var(--ink);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}
.auth-btn.primary {
    background: var(--primary);
    color: #fffdf8;
    border-color: var(--primary);
}
.auth-btn.primary:hover { background: #22382c; }

.auth-error {
    background: var(--accent-soft);
    color: var(--accent);
    padding: 10px 14px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 0.9rem;
}
.auth-notice {
    background: var(--primary-soft);
    color: var(--primary);
    padding: 10px 14px;
    border-radius: 8px;
    margin-top: 20px;
    font-size: 0.9rem;
}

.auth-footer-links {
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid var(--line-soft);
    font-size: 0.9rem;
    color: var(--ink-soft);
    text-align: center;
}
.auth-footer-links a { color: var(--primary); }

/* Sidebar footer "signed in as" block. */
.sidebar-user {
    padding: 14px 12px;
    margin-top: auto;
    border-top: 1px solid var(--line-soft);
    font-size: 0.82rem;
}
.sidebar-user .who {
    color: var(--ink);
    font-weight: 600;
    margin-bottom: 2px;
}
.sidebar-user .email {
    color: var(--ink-faint);
    font-size: 0.78rem;
    margin-bottom: 10px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.sidebar-user form {
    margin: 0;
}
.sidebar-user button {
    background: transparent;
    border: none;
    color: var(--ink-soft);
    font-size: 0.82rem;
    padding: 4px 0;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.sidebar-user button:hover { color: var(--accent); }
