/* =====================================================
   TruDinery -- App CSS
   Warm, editorial feel -- like a personal food journal.
   Dark mode default. Shares portal CSS variables.
   ===================================================== */

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

:root {
    /* Portal brand (inherited) */
    --sidebar:      #0A1F38;
    --accent:       #0D7377;
    --accent-hover: #14919B;

    /* TruDinery accent -- matches portal palette */
    --warm:         #0D7377;   /* teal -- same as portal accent */
    --warm-light:   #14919B;
    --star:         #F5C842;   /* star rating gold -- kept */
    --outstanding:  #14919B;   /* outstanding -- teal light */

    /* Dark mode */
    --bg:           #0d1829;
    --bg-card:      #0F2D52;
    --bg-card-2:    #163D6E;
    --bg-input:     rgba(255,255,255,0.07);
    --border:       rgba(255,255,255,0.09);
    --border-input: rgba(255,255,255,0.14);
    --text:         #ffffff;
    --text-2:       rgba(255,255,255,0.72);
    --text-3:       rgba(255,255,255,0.45);
    --topbar-bg:    #0A1F38;
    --topbar-border:rgba(255,255,255,0.07);
    --pill-bg:      rgba(255,255,255,0.08);
    --pill-border:  rgba(255,255,255,0.12);
    --pill-text:    rgba(255,255,255,0.65);
    --shadow:       rgba(0,0,0,0.3);
    --bottomnav-h:  58px;

    /* Typography */
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;

    /* Layout */
    --sidebar-w:    200px;
    --topbar-h:     56px;
    --radius:       12px;
    --radius-sm:    8px;
    --radius-pill:  20px;
    --transition:   0.18s ease;
}

/* ── Light mode ─────────────────────────────────────── */
[data-theme="light"] {
    --bg:           #f4f7fb;
    --bg-card:      #ffffff;
    --bg-card-2:    #eef3fb;
    --bg-input:     #ffffff;
    --border:       rgba(0,0,0,0.10);
    --border-input: rgba(0,0,0,0.18);
    --text:         #0A1F38;
    --text-2:       #3a5272;
    --text-3:       #7a9ab8;
    --topbar-bg:    #0A1F38;
    --topbar-border:rgba(255,255,255,0.07);
    --shadow:       rgba(0,0,0,0.10);
}

/* ── Base ───────────────────────────────────────────── */
html, body {
    height: 100%;
    font-family: var(--font);
    font-size: 14px;
    background: var(--bg);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: var(--font); }

/* ── App shell ──────────────────────────────────────── */
.app-shell { display: flex; height: 100dvh; overflow: hidden; }

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}
.sb-header { padding: 18px 14px 0; }
.sb-logo-row { display: flex; align-items: center; gap: 9px; margin-bottom: 18px; }
.sb-logo {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 16px; flex-shrink: 0;
}
.sb-appname { font-size: 15px; font-weight: 600; color: #fff; letter-spacing: -0.01em; }
.sb-accent-bar { height: 2px; background: var(--accent); margin: 0 14px 18px; opacity: 0.5; border-radius: 1px; }
.sb-nav { flex: 1; padding: 0 8px; }
.sb-section { font-size: 10px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); padding: 0 6px; margin-bottom: 6px; }
.sb-item {
    display: flex; align-items: center; gap: 9px;
    font-size: 13px; color: var(--text-2);
    padding: 8px 8px; border-radius: 7px; margin-bottom: 2px;
    transition: background var(--transition), color var(--transition);
    text-decoration: none; border-left: 2px solid transparent;
    cursor: pointer; background: none; border-top: none; border-right: none; border-bottom: none;
    width: 100%; text-align: left;
}
.sb-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.sb-item.active { color: #fff; background: rgba(255,255,255,0.08); border-left-color: var(--accent); padding-left: 6px; }
.sb-icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sb-bottom {
    padding: 14px 14px;
    border-top: 0.5px solid rgba(255,255,255,0.08);
    display: flex; align-items: center; justify-content: space-between;
}
.sb-user { display: flex; align-items: center; gap: 8px; }
.sb-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent); display: flex; align-items: center;
    justify-content: center; font-size: 11px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.sb-username { font-size: 12px; color: var(--text-2); }

/* ── Main area ──────────────────────────────────────── */
.main-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }

/* ── Topbar ─────────────────────────────────────────── */
.topbar {
    height: var(--topbar-h);
    background: var(--topbar-bg);
    border-bottom: 0.5px solid var(--topbar-border);
    display: flex; align-items: center;
    padding: 0 20px; gap: 12px; flex-shrink: 0;
}
.topbar-title { font-size: 15px; font-weight: 600; color: #fff; flex: 1; letter-spacing: -0.01em; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-theme-btn {
    background: rgba(255,255,255,0.08);
    border: 1.5px solid rgba(255,255,255,0.18);
    font-size: 16px; color: #f5c842;
    width: 32px; height: 32px; border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0; transition: background var(--transition);
}
.topbar-theme-btn:hover { background: rgba(255,255,255,0.14); }
.user-pill {
    display: flex; align-items: center; gap: 6px;
    background: var(--pill-bg); border: 0.5px solid var(--pill-border);
    border-radius: var(--radius-pill); padding: 4px 10px 4px 6px;
}
.user-pill-avatar {
    width: 22px; height: 22px; border-radius: 50%;
    background: var(--accent); display: flex; align-items: center;
    justify-content: center; font-size: 10px; font-weight: 600; color: #fff; flex-shrink: 0;
}
.user-pill-name { font-size: 12px; color: var(--pill-text); }

/* ── Page content ───────────────────────────────────── */
.page-content {
    flex: 1; overflow-y: auto;
    padding: 24px;
    padding-bottom: calc(24px + var(--bottomnav-h));
}

/* ── Tabs ───────────────────────────────────────────── */
.tab-bar {
    display: flex; gap: 8px;
    margin-bottom: 20px;
    width: fit-content;
}

.tab-btn {
    font-size: 12px; font-weight: 600;
    padding: 6px 13px; border-radius: var(--radius-pill);
    border: 1px solid transparent; cursor: pointer; transition: background var(--transition), color var(--transition);
}
.tab-btn[data-tab="visited"] { background: rgba(13,115,119,0.15); color: var(--accent); border-color: rgba(13,115,119,0.4); }
.tab-btn[data-tab="visited"].active { background: var(--accent); color: #fff; border-color: var(--accent); }
.tab-btn[data-tab="visited"]:not(.active):hover { background: rgba(13,115,119,0.25); }
.tab-btn[data-tab="want_to_visit"] { background: rgba(245,200,66,0.15); color: #B8860B; border-color: rgba(184,134,11,0.45); }
.tab-btn[data-tab="want_to_visit"].active { background: var(--star); color: #0A1F38; border-color: var(--star); }
.tab-btn[data-tab="want_to_visit"]:not(.active):hover { background: rgba(245,200,66,0.25); }

/* ── Restaurant cards grid ──────────────────────────── */
.restaurant-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
}

.restaurant-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 0.5px solid var(--border);
    overflow: hidden;
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition);
    text-decoration: none;
    display: flex; flex-direction: column;
}
.restaurant-card:hover { transform: translateY(-2px); box-shadow: 0 6px 20px var(--shadow); }
[data-theme="light"] .restaurant-card { box-shadow: 0 1px 4px rgba(0,0,0,0.07); }

.rc-photo {
    width: 100%; height: 95px; object-fit: cover;
    background: var(--bg-card-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 36px; color: var(--text-3); flex-shrink: 0;
}
.rc-photo img { width: 100%; height: 100%; object-fit: cover; }

.rc-body { padding: 8px; flex: 1; display: flex; flex-direction: column; }
.rc-name { font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: 2px; }
.rc-meta { font-size: 11px; color: var(--text-2); margin-bottom: 4px; }
.rc-footer { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }

/* ── Star rating display ────────────────────────────── */
.stars {
    display: inline-flex; align-items: center; gap: 1px;
    font-size: 13px; color: var(--text-3);
}
.star-filled     { color: var(--star); }
.star-outstanding { color: var(--outstanding); }
.stars-label { font-size: 11px; color: var(--text-2); margin-left: 4px; }

/* ── Interactive star rater ─────────────────────────── */
.star-rater { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.star-rater-stars { display: flex; gap: 3px; }
.star-rater-star {
    font-size: 22px; cursor: pointer; color: var(--text-3);
    transition: color var(--transition), transform 0.1s;
    line-height: 1;
}
.star-rater-star:hover, .star-rater-star.active { color: var(--star); }
.star-rater-star:hover { transform: scale(1.15); }
.star-rater-plus {
    font-size: 12px; font-weight: 700;
    padding: 4px 9px; border-radius: var(--radius-pill);
    border: 1.5px solid var(--outstanding); color: var(--outstanding);
    background: none; cursor: pointer; white-space: nowrap;
    transition: background var(--transition);
}
.star-rater-plus.active { background: var(--outstanding); color: #fff; }
.star-rater-plus:hover  { background: rgba(255,107,53,0.15); }

/* ── Badge / pill ───────────────────────────────────── */
.badge {
    font-size: 10px; font-weight: 500;
    padding: 2px 8px; border-radius: var(--radius-pill); white-space: nowrap;
}
.badge-visited  { background: rgba(13,115,119,0.18); color: #45C4B0; }
.badge-wishlist { background: rgba(13,115,119,0.18); color: var(--accent-hover); }
.badge-price    { background: rgba(255,255,255,0.08); color: var(--text-2); font-size: 11px; }
[data-theme="light"] .badge-visited  { background: #ddf2f0; color: #085c60; }
[data-theme="light"] .badge-wishlist { background: #ddf2f0; color: #085c60; }
[data-theme="light"] .badge-price    { background: rgba(0,0,0,0.06); color: var(--text-2); }

/* ── Category chips ─────────────────────────────────── */
.cat-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.cat-chip {
    font-size: 10px; padding: 2px 8px;
    border-radius: var(--radius-pill);
    background: rgba(255,255,255,0.07); color: var(--text-2);
    border: 0.5px solid rgba(255,255,255,0.1);
}
[data-theme="light"] .cat-chip { background: rgba(0,0,0,0.05); border-color: rgba(0,0,0,0.1); }

/* ── Slide panel ────────────────────────────────────── */
.panel-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.55);
    z-index: 100; opacity: 0; pointer-events: none;
    transition: opacity 0.25s ease;
}
.panel-overlay.open { opacity: 1; pointer-events: all; }

.slide-panel {
    position: fixed; top: 0; right: 0; bottom: 0;
    width: 100%; max-width: 460px;
    background: var(--sidebar);
    z-index: 101; display: flex; flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.25s ease;
    overflow: hidden;
}
.slide-panel.open { transform: translateX(0); }

.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 0.5px solid rgba(255,255,255,0.1);
    flex-shrink: 0;
}
.panel-title { font-size: 15px; font-weight: 600; color: #fff; }
.panel-close {
    background: none; border: none; color: #fff;
    font-size: 22px; cursor: pointer; line-height: 1; padding: 2px;
    transition: color var(--transition);
}
.panel-close:hover { color: #fff; }
.panel-body { flex: 1; overflow-y: auto; padding: 20px; }
.panel-footer {
    padding: 16px 20px;
    border-top: 0.5px solid rgba(255,255,255,0.1);
    display: flex; gap: 10px; flex-shrink: 0;
}

/* Panel fields */
.panel-field { margin-bottom: 16px; }
.panel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel-label {
    display: block; font-size: 11px; color: var(--text-2);
    margin-bottom: 6px; text-transform: uppercase; letter-spacing: 0.05em;
}
.panel-input {
    width: 100%; background: rgba(255,255,255,0.07);
    border: 0.5px solid rgba(255,255,255,0.14);
    border-radius: var(--radius-sm); color: #fff;
    font-size: 16px; font-family: var(--font);
    padding: 10px 13px; outline: none;
    transition: border-color var(--transition);
}
.panel-input:focus { border-color: var(--accent); }
.panel-input::placeholder { color: var(--text-3); }

.panel-select {
    width: 100%; background: rgba(255,255,255,0.07);
    border: 0.5px solid rgba(255,255,255,0.14);
    border-radius: var(--radius-sm); color: #fff;
    font-size: 16px; font-family: var(--font);
    padding: 10px 13px; outline: none; cursor: pointer;
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='white'%3E%3Cpath d='M5.5 7.5l4.5 4.5 4.5-4.5' stroke='white' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 32px;
}
.panel-textarea {
    width: 100%; background: rgba(255,255,255,0.07);
    border: 0.5px solid rgba(255,255,255,0.14);
    border-radius: var(--radius-sm); color: #fff;
    font-size: 16px; font-family: var(--font);
    padding: 10px 13px; outline: none; resize: vertical; min-height: 80px;
    transition: border-color var(--transition);
}
.panel-textarea:focus { border-color: var(--accent); }
.panel-textarea::placeholder { color: var(--text-3); }

.panel-section-title {
    font-size: 10px; text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--text-3); margin: 20px 0 10px;
    padding-bottom: 6px; border-bottom: 0.5px solid rgba(255,255,255,0.08);
}

/* Category checkboxes in panel */
.panel-cat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.panel-cat-item {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 10px; border-radius: var(--radius-sm);
    border: 0.5px solid rgba(255,255,255,0.1);
    cursor: pointer; transition: background var(--transition);
}
.panel-cat-item:hover { background: rgba(255,255,255,0.06); }
.panel-cat-item.selected { background: rgba(13,115,119,0.2); border-color: var(--accent); }
.panel-cat-item input { accent-color: var(--warm); cursor: pointer; }
.panel-cat-label { font-size: 12px; color: rgba(255,255,255,0.8); cursor: pointer; }

/* Photo upload in panel */
.photo-upload-area {
    border: 1.5px dashed rgba(255,255,255,0.2);
    border-radius: var(--radius-sm); padding: 20px;
    text-align: center; cursor: pointer;
    transition: border-color var(--transition), background var(--transition);
}
.photo-upload-area:hover { border-color: var(--accent); background: rgba(13,115,119,0.06); }
.photo-upload-icon { font-size: 24px; margin-bottom: 6px; opacity: 0.5; }
.photo-upload-label { font-size: 12px; color: var(--text-2); }
.photo-preview { width: 100%; max-height: 160px; object-fit: cover; border-radius: var(--radius-sm); }

/* Status pills in panel -- informational only, not clickable */
.status-toggle { display: flex; gap: 8px; }
.status-opt {
    flex: 1; padding: 9px; border-radius: var(--radius-sm);
    border: 1px solid rgba(255,255,255,0.15); background: none;
    color: var(--text-2); font-size: 12px; font-weight: 600; font-family: var(--font);
    text-align: center;
}
.status-opt[data-status="visited"] { border-color: rgba(13,115,119,0.4); background: rgba(13,115,119,0.15); color: var(--accent); }
.status-opt[data-status="want_to_visit"] { border-color: rgba(245,200,66,0.45); background: rgba(245,200,66,0.15); color: var(--star); }
.status-opt.active-visited  { border-color: var(--accent); color: #fff; background: var(--accent); }
.status-opt.active-wishlist { border-color: var(--star); color: #0A1F38; background: var(--star); }

/* Panel buttons */
.panel-btn-save {
    flex: 2; background: var(--accent-hover); border: none;
    border-radius: var(--radius-sm); color: #fff;
    font-size: 13px; font-weight: 600; font-family: var(--font);
    padding: 11px; cursor: pointer;
    transition: background var(--transition);
}
.panel-btn-save:hover { background: var(--accent-hover); }
.panel-btn-save:disabled { opacity: 0.5; cursor: default; }
.panel-btn-cancel {
    flex: 1; background: rgba(255,255,255,0.08); border: 0.5px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm); color: #fff;
    font-size: 13px; font-family: var(--font); padding: 11px 18px; cursor: pointer;
}
.panel-btn-delete {
    background: rgba(192,57,43,0.15); border: 0.5px solid rgba(192,57,43,0.3);
    border-radius: var(--radius-sm); color: #e74c3c;
    font-size: 13px; font-family: var(--font); padding: 11px 14px; cursor: pointer;
}

/* ── Lookup bar ─────────────────────────────────────── */
.lookup-bar {
    display: flex; gap: 8px; margin-bottom: 16px;
    background: rgba(255,255,255,0.04);
    border: 0.5px solid rgba(255,255,255,0.1);
    border-radius: var(--radius-sm); padding: 6px 10px;
    align-items: center;
}
.lookup-input {
    flex: 1; background: none; border: none; outline: none;
    font-size: 13px; color: #fff; font-family: var(--font);
}
.lookup-input::placeholder { color: var(--text-3); }
.lookup-btn {
    background: var(--accent); border: none; border-radius: 6px;
    color: #fff; font-size: 12px; padding: 5px 12px; cursor: pointer;
    font-family: var(--font);
}
.lookup-note { font-size: 11px; color: var(--text-3); text-align: center; margin-bottom: 10px; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: none; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 500; font-family: var(--font);
    padding: 9px 18px; cursor: pointer;
    transition: opacity var(--transition), transform var(--transition);
    white-space: nowrap;
}
.btn:hover { opacity: 0.88; }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-accent  { background: var(--accent); color: #fff; }
.btn-ghost   { background: transparent; border: 0.5px solid var(--border-input); color: var(--text); }
.btn-danger  { background: #c0392b; color: #fff; }
.btn-sm      { padding: 6px 13px; font-size: 12px; }
.btn-full    { width: 100%; }

/* ── Toast ──────────────────────────────────────────── */
.toast-container {
    position: fixed; bottom: calc(var(--bottomnav-h) + 12px);
    left: 50%; transform: translateX(-50%);
    z-index: 999; display: flex; flex-direction: column; align-items: center; gap: 8px;
    pointer-events: none;
}
.toast {
    background: #1e2d3d; border: 0.5px solid rgba(255,255,255,0.12);
    color: #fff; font-size: 13px; padding: 10px 18px;
    border-radius: var(--radius-pill);
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    opacity: 1; transition: opacity 0.4s ease; white-space: nowrap;
}
.toast.success { border-color: rgba(13,115,119,0.6); }
.toast.error   { border-color: rgba(192,57,43,0.6); color: #ff8a7a; }
.toast.fade-out { opacity: 0; }

/* ── Spinner ────────────────────────────────────────── */
.spinner {
    width: 22px; height: 22px;
    border: 2px solid rgba(255,255,255,0.15);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Empty state ────────────────────────────────────── */
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-2); }
.empty-state-icon { font-size: 40px; margin-bottom: 12px; opacity: 0.4; }
.empty-state-title { font-size: 16px; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.empty-state-sub   { font-size: 13px; margin-bottom: 20px; }

/* ── Bottom nav (mobile) ────────────────────────────── */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0;
    height: var(--bottomnav-h);
    background: var(--sidebar);
    border-top: 0.5px solid rgba(255,255,255,0.1);
    display: flex; align-items: center; justify-content: space-around;
    z-index: 20; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bn-item {
    display: flex; flex-direction: column; align-items: center; gap: 3px;
    flex: 1; padding: 8px 0 4px; opacity: 1;
    transition: opacity var(--transition);
    cursor: pointer; background: none; border: none; font-family: var(--font);
    text-decoration: none;
}
.bn-item:hover, .bn-item.active { opacity: 1; }
.bn-icon { font-size: 22px; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; line-height: 1; transition: transform 0.15s ease; }
.bn-label { font-size: 9px; color: #fff; letter-spacing: 0.02em; transition: transform 0.15s ease; display: inline-block; }
.bn-item.active .bn-icon { transform: scale(1.2); }
.bn-item.active .bn-label { transform: scale(1.2); }
.bn-dot { width: 4px; height: 4px; border-radius: 50%; background: var(--accent); margin-top: 1px; }

/* ── Page fade in ───────────────────────────────────── */
.page-fade-in { animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ── Responsive: desktop ────────────────────────────── */
@media (min-width: 768px) {
    .sidebar { display: flex; }
    .bottom-nav { display: none; }
    .page-content { padding-bottom: 24px; }
    .restaurant-grid { grid-template-columns: repeat(3, 1fr); }
    .topbar-title { display: none; }
    .topbar { justify-content: flex-end; }
}
@media (min-width: 1100px) {
    .restaurant-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ── Responsive: mobile ─────────────────────────────── */
@media (max-width: 767px) {
    .sidebar { display: none; }
    .page-content { padding: 16px; padding-bottom: calc(16px + var(--bottomnav-h)); }
    .restaurant-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .rc-photo { height: 80px; }
    #add-rest-btn { display: none; }
}

/* ── PWA safe areas ─────────────────────────────────── */
@supports (padding-bottom: env(safe-area-inset-bottom)) {
    .bottom-nav { padding-bottom: env(safe-area-inset-bottom); height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom)); }
    .page-content { padding-bottom: calc(24px + var(--bottomnav-h) + env(safe-area-inset-bottom)); }
}
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { transition: none !important; animation: none !important; }
}

/* =====================================================
   SESSION 2 -- Restaurant detail, visits, dishes
   ===================================================== */

/* Detail hero */
.tb-detail-hero {
    background: var(--bg-card);
    border-radius: var(--radius);
    border: 0.5px solid var(--border);
    overflow: hidden;
    margin-bottom: 20px;
}

.tb-detail-photo {
    width: 100%;
    height: 180px;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
}

.tb-detail-photo-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    background: var(--bg-card-2);
    color: var(--text-3);
}

.tb-detail-header {
    padding: 16px;
}

.tb-detail-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
    margin-bottom: 0px;
}

.tb-detail-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--text-2);
}

/* Action buttons */
.tb-action-btns {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 12px 16px 16px;
    border-top: 0.5px solid var(--border);
}

.tb-action-btn {
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font);
    padding: 7px 14px;
    border-radius: var(--radius-pill);
    border: 0.5px solid var(--border-input);
    background: transparent;
    color: var(--text);
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    transition: background var(--transition);
}
.tb-action-btn:hover { background: rgba(255,255,255,0.07); }
[data-theme="light"] .tb-action-btn:hover { background: rgba(0,0,0,0.04); }

.tb-action-btn-primary {
    background: var(--accent);
    color: #fff;
    border-color: transparent;
}
.tb-action-btn-primary:hover { background: var(--accent-hover); }

/* Sections */
.tb-section { margin-bottom: 24px; }

.tb-section-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 0.5px solid var(--border);
}

/* Visit rows */
.tb-visit-row {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 0.5px solid var(--border);
    margin-bottom: 8px;
    overflow: hidden;
}
[data-theme="light"] .tb-visit-row { box-shadow: 0 1px 3px rgba(0,0,0,0.06); }

.tb-visit-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    transition: background var(--transition);
}
.tb-visit-header:hover { background: rgba(255,255,255,0.04); }
[data-theme="light"] .tb-visit-header:hover { background: rgba(0,0,0,0.02); }

.tb-visit-detail {
    padding: 12px 14px;
    border-top: 0.5px solid var(--border);
    background: rgba(0,0,0,0.1);
}
[data-theme="light"] .tb-visit-detail { background: rgba(0,0,0,0.025); }

.tb-visit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    border-bottom: 0.5px solid var(--border);
}
.tb-visit-item:last-child { border-bottom: none; }

/* Dish summary grid */
.tb-dish-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.tb-dish-card {
    background: var(--bg-card);
    border-radius: var(--radius-sm);
    border: 0.5px solid var(--border);
    padding: 12px;
}
[data-theme="light"] .tb-dish-card { box-shadow: 0 1px 3px rgba(0,0,0,0.05); }

.tb-dish-name {
    font-size: 13px;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 3px;
}

.tb-dish-meta {
    font-size: 11px;
    color: var(--text-2);
}

/* Visit form dish rows */
.vf-dish-row {
    padding: 10px 0;
    border-bottom: 0.5px solid var(--border);
}
.vf-dish-row:last-child { border-bottom: none; }

.vf-dish-check-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* New inline dish row layout */
.vf-dish-full-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 0.5px solid var(--border);
}
.vf-dish-full-row:last-child { border-bottom: none; }

.vf-dish-name {
    font-size: 13px;
    color: #fff;
    flex: 1;
    min-width: 0;
}
[data-theme="light"] .vf-dish-name { color: var(--text); }

.vf-dish-inline-stars {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
    transition: opacity 0.2s;
}
.vf-dish-inline-stars .star-rater-star { font-size: 18px; }
.vf-dish-inline-stars .star-rater-plus { font-size: 10px; padding: 2px 6px; }

.vf-new-dish-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.vf-new-dish-input {
    flex: 1;
    min-width: 0;
}

/* Star rater */
.star-rater { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }

.star-rater-star {
    font-size: 22px;
    cursor: pointer;
    color: var(--text-3);
    transition: color var(--transition), transform 0.1s;
    line-height: 1;
    user-select: none;
}
.star-rater-star:hover  { transform: scale(1.15); color: var(--star); }
.star-rater-star.star-filled { color: var(--star); }

.star-rater-plus {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: var(--radius-pill);
    border: 1.5px solid var(--accent);
    color: var(--accent);
    background: none;
    cursor: pointer;
    transition: background var(--transition);
    font-family: var(--font);
    user-select: none;
}
.star-rater-plus.active { background: var(--accent); color: #fff; }
.star-rater-plus:hover  { background: rgba(13,115,119,0.15); }

@media (min-width: 768px) {
    .tb-dish-grid { grid-template-columns: repeat(3, 1fr); }
    .tb-detail-photo { height: 240px; }
}

/* =====================================================
   VISIT FORM -- compact item rows
   ===================================================== */
/* duplicate removed */

/* =====================================================
   DISH CAROUSEL / GRID
   ===================================================== */

/* Mobile: horizontal scroll carousel */
.tb-dish-carousel {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 8px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tb-dish-carousel::-webkit-scrollbar { display: none; }

.tb-dish-card {
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    width: 130px;
    height: 130px;
    position: relative;
    transition: transform 0.15s;
}
.tb-dish-card:hover { transform: scale(1.03); }

.tb-dish-card-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 8px;
    background: linear-gradient(to top, rgba(0,0,0,0.75) 0%, transparent 100%);
}

.tb-dish-name {
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Desktop: grid instead of carousel */
@media (min-width: 768px) {
    .tb-dish-carousel {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        overflow-x: visible;
        padding-bottom: 0;
    }
    .tb-dish-card {
        width: auto;
        height: 140px;
    }
}

/* =====================================================
   VISIT FORM -- compact item rows
   ===================================================== */
.vf-item-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 0;
    border-bottom: 0.5px solid rgba(255,255,255,0.06);
}
.vf-item-row:last-child { border-bottom: none; }

.vf-item-name {
    font-size: 13px;
    color: #ffffff !important;
    flex: 1 1 0%;
    min-width: 0;
    max-width: 40%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}
[data-theme="light"] .vf-item-name { color: #0A1F38 !important; }

.vf-item-stars {
    display: flex;
    align-items: center;
    gap: 1px;
    flex: 0 0 auto;
    flex-shrink: 0;
    transition: opacity 0.2s;
}
.vf-item-stars .star-rater-star { font-size: 15px; }
.vf-item-stars .star-rater-plus { font-size: 9px; padding: 1px 5px; }

.vf-new-dish-input {
    background: none;
    border: none;
    border-bottom: 0.5px solid rgba(255,255,255,0.15);
    outline: none;
    color: #fff;
    font-size: 13px;
    flex: 1;
    min-width: 0;
    font-family: var(--font);
    padding: 2px 4px;
}
.vf-new-dish-input::placeholder { color: var(--text-3); font-style: italic; }
[data-theme="light"] .vf-new-dish-input { color: #0A1F38; border-bottom-color: rgba(0,0,0,0.15); }

/* Dish card squares */
.tb-dish-card {
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
    width: 130px;
    height: 130px;
    position: relative;
    transition: transform 0.15s;
}

/* =====================================================
   CONTEXTUAL BOTTOM NAV
   ===================================================== */
.bn-item-primary { opacity: 1 !important; }

/* Action buttons -- horizontal scroll on mobile */
.tb-action-btns {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 12px 16px 16px;
    border-top: 0.5px solid var(--border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}
.tb-action-btns::-webkit-scrollbar { display: none; }
.tb-action-btn { white-space: nowrap; flex-shrink: 0; }

/* Desktop: wrap action buttons */
@media (min-width: 768px) {
    .tb-action-btns { flex-wrap: wrap; overflow-x: visible; }
}

/* =====================================================
   USER PILL DROPDOWN
   ===================================================== */
.user-pill-wrap { position: relative; }

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #0A1F38;
    border: 0.5px solid rgba(255,255,255,0.15);
    border-radius: 10px;
    min-width: 160px;
    z-index: 200;
    box-shadow: 0 8px 24px rgba(0,0,0,0.4);
    overflow: hidden;
    animation: fadeIn 0.15s ease;
}

.user-dropdown-item {
    display: block;
    padding: 11px 16px;
    font-size: 13px;
    color: rgba(255,255,255,0.85);
    cursor: pointer;
    text-decoration: none;
    transition: background 0.15s;
    font-family: var(--font);
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}
.user-dropdown-item:hover { background: rgba(255,255,255,0.08); }
.user-dropdown-danger { color: #e74c3c; }
.user-dropdown-divider {
    height: 0.5px;
    background: rgba(255,255,255,0.1);
    margin: 2px 0;
}


/* Desktop action buttons -- hidden on mobile (bottom nav handles it) */
.tb-action-btns-desktop { display: none; }
@media (min-width: 768px) {
    .tb-action-btns-desktop { display: flex; }
}

/* =====================================================
   SESSION 3 -- Search, sort, stats
   ===================================================== */

/* Search + sort controls */
.tb-list-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    align-items: center;
}

.tb-search-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-input);
    border: 0.5px solid var(--border-input);
    border-radius: var(--radius-sm);
    padding: 0 10px;
}

.tb-search-icon { font-size: 14px; color: var(--text-3); flex-shrink: 0; }

.tb-search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 16px;
    color: var(--text);
    font-family: var(--font);
    padding: 9px 0;
}
.tb-search-input::placeholder { color: var(--text-3); }

.tb-search-clear {
    background: none;
    border: none;
    color: var(--text-3);
    font-size: 18px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}

.tb-sort-select {
    background: var(--bg-input);
    border: 0.5px solid var(--border-input);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 12px;
    font-family: var(--font);
    padding: 9px 10px;
    outline: none;
    cursor: pointer;
    flex-shrink: 0;
}

/* Stats grid */
.tb-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.tb-stat-card {
    background: var(--bg-card);
    border: 0.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}

.tb-stat-value {
    font-size: 22px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.tb-stat-label {
    font-size: 11px;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Info pills (Hours, Dishes) on detail page */
.tb-info-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 2px 8px;
    border-radius: 20px;
    border: 0.5px solid var(--accent);
    background: rgba(13,115,119,0.1);
    color: var(--accent);
    font-size: 12px;
    font-weight: 500;
    font-family: var(--font);
    cursor: pointer;
    transition: background 0.15s;
}
.tb-info-pill:hover { background: rgba(13,115,119,0.2); }
.tb-info-pill-sm {
    padding: 5px 12px;
    font-size: 11px;
}
