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

:root {
    --bg: #1e1e1e;
    --surface: #2a2a2a;
    --surface2: #333;
    --border: #3d3d3d;
    --orange: #38bdf8;
    --orange-dim: #0ea5e9;
    --orange-light: rgba(56,189,248,0.1);
    --orange-glow: rgba(56,189,248,0.2);
    --green: #22c55e;
    --green-light: rgba(34,197,94,0.1);
    --red: #ef4444;
    --text: #e8e8e8;
    --text2: #999;
    --text3: #666;
    --white: #2a2a2a;
    --sidebar-w: 280px;
}

html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh; height: 100dvh;
    display: flex; flex-direction: column;
    overflow: hidden;
}

/* ====== AD ====== */
.ad-banner {
    width: 100%; background: #171717;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0; padding: 4px 8px; text-align: center;
}
.ad-placeholder {
    display: inline-block; max-width: 728px; width: 100%;
    height: 40px; line-height: 40px;
    color: var(--text3); font-size: 9px; letter-spacing: 1px;
    border: 1px dashed var(--border); border-radius: 3px;
}

/* ====== SIDEBAR ====== */
.sidebar {
    position: fixed; left: 0; top: 0;
    width: var(--sidebar-w); height: 100dvh;
    background: var(--surface); border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    z-index: 100; overflow-y: auto;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}
.sidebar.open { transform: translateX(0); }
.sidebar-header {
    padding: 14px 16px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.sidebar-close {
    background: none; border: none; color: var(--text2);
    font-size: 24px; cursor: pointer; transition: color 0.15s;
}
.sidebar-close:hover { color: var(--text); }
.sidebar-title { font-size: 14px; font-weight: 700; color: var(--text); }

.sidebar-body { padding: 16px; display: flex; flex-direction: column; gap: 16px; }
.sb-section { display: flex; flex-direction: column; gap: 8px; }
.sb-label { font-size: 10px; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: 0.5px; }
.sidebar-body label {
    display: flex; flex-direction: column; font-size: 11px; color: var(--text2); font-weight: 500; gap: 3px;
}
.sidebar-body input, .sidebar-body select {
    width: 100%; background: var(--surface); border: 2px solid var(--border);
    border-radius: 10px; padding: 10px 12px; color: var(--text);
    font-size: 16px; outline: none; font-family: inherit; -webkit-appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.sidebar-body input:focus, .sidebar-body select:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-glow);
}

.sb-action-btn {
    width: 100%; padding: 10px; background: var(--orange); border: none;
    border-radius: 8px; color: #fff; font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.sb-action-btn:hover { background: var(--orange-dim); }
.sb-rec { font-size: 11px; color: var(--text2); line-height: 1.6; }
.sb-rec strong { color: var(--orange); }

.clear-btn {
    width: 100%; padding: 9px; background: var(--red);
    border: none; border-radius: 8px;
    color: #fff; font-size: 12px; font-weight: 500;
    cursor: pointer; font-family: inherit; transition: all 0.2s;
}
.clear-btn:hover { background: #dc2626; }
.sb-date { font-size: 11px; color: var(--text3); padding-top: 8px; border-top: 1px solid var(--border); }

/* ====== OVERLAY ====== */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.3); z-index: 90;
}
.sidebar-overlay.open { display: block; }

/* ====== TOPBAR ====== */
.topbar {
    display: flex; align-items: center; flex-wrap: wrap;
    padding: 0 12px; border-bottom: 1px solid var(--border);
    flex-shrink: 0; background: var(--surface);
    min-height: 44px;
}
.menu-btn {
    background: none; border: none; color: var(--text);
    cursor: pointer; margin-right: 8px; padding: 4px;
    display: flex; align-items: center;
    -webkit-tap-highlight-color: transparent;
}
.page-title {
    font-size: 15px; font-weight: 700; color: var(--text);
    flex: 1;
}
.tab-bar { display: flex; gap: 2px; margin-left: auto; }
.tab {
    padding: 6px 12px; font-size: 11px; font-weight: 600;
    color: var(--text2); background: none; border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer; font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--orange); border-bottom-color: var(--orange); }

/* ====== CONTENT ====== */
.main { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.content {
    flex: 1; padding: 10px; display: flex; flex-direction: column;
    min-height: 0; overflow: hidden;
}

/* ====== TAB PANELS ====== */
.tab-panel { display: none; flex-direction: column; flex: 1; min-height: 0; gap: 8px; }
.tab-panel.active { display: flex; }

/* ====== VIEW TOGGLE ====== */
.view-toggle {
    display: flex; gap: 4px; flex-shrink: 0;
    background: var(--bg); border-radius: 10px; padding: 3px;
}
.view-btn {
    flex: 1; padding: 7px; text-align: center;
    font-size: 12px; font-weight: 600;
    color: var(--text2); background: none;
    border: none; border-radius: 8px;
    cursor: pointer; font-family: inherit;
    transition: all 0.15s;
}
.view-btn.active { color: #fff; background: var(--orange); }

/* ====== WEEKLY SUMMARY ====== */
.weekly-summary {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 10px; padding: 10px; flex-shrink: 0;
}
.week-stat-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 5px 0; font-size: 12px; color: var(--text);
    border-bottom: 1px solid var(--border);
}
.week-stat-row:last-child { border-bottom: none; }
.week-stat-val { font-weight: 700; }
.week-stat-val.over { color: var(--red); }
.week-stat-val.under { color: var(--green); }

/* ====== RINGS ====== */
.rings-row {
    display: flex; align-items: center; justify-content: center;
    gap: 6px; flex-shrink: 0; padding: 10px 4px;
    flex: 1 1 auto; min-height: 0;
}
.ring-wrap { flex: 1; max-width: 45vw; }
.ring-wrap svg { width: 100%; height: auto; }
.ring-bg { fill: none; stroke: var(--surface2); stroke-width: 5; }
.ring-fg {
    fill: none; stroke-width: 6;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s cubic-bezier(0.4,0,0.2,1), stroke 0.4s;
    transform: rotate(-90deg); transform-origin: 60px 60px;
    filter: drop-shadow(0 0 3px currentColor);
}
.ring-small { max-width: 30vw; }
.ring-val { font-size: 20px; font-weight: 800; fill: var(--text); text-anchor: middle; }
.ring-of { font-size: 10px; fill: var(--text3); text-anchor: middle; }
.ring-lbl { font-size: 8px; fill: var(--text3); text-anchor: middle; letter-spacing: 0.8px; }

/* ====== REMAINING ROW ====== */
.remaining-row {
    display: flex; gap: 4px; flex-shrink: 0; padding: 0 4px;
}
.remain-item {
    flex: 1; text-align: center;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 8px; padding: 5px 2px;
}
.remain-val {
    display: block; font-size: 14px; font-weight: 800; color: var(--text);
}
.remain-val.over { color: var(--red); }
.remain-val.done { color: var(--green); }
.remain-lbl {
    display: block; font-size: 7px; color: var(--text3);
    text-transform: uppercase; letter-spacing: 0.5px; margin-top: 1px;
}

/* ====== FAVORITES ROW ====== */
.fav-row {
    display: flex; gap: 6px; flex-shrink: 0;
    overflow-x: auto; padding: 2px 0;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}
.fav-row::-webkit-scrollbar { display: none; }
.fav-row:empty { display: none; }
.fav-chip {
    flex-shrink: 0; padding: 4px 10px;
    background: var(--orange-light); border: 1px solid rgba(249,115,22,0.2);
    border-radius: 16px; font-size: 10px; font-weight: 500;
    color: var(--orange); cursor: pointer; font-family: inherit;
    -webkit-tap-highlight-color: transparent; transition: all 0.15s;
    white-space: nowrap;
}
.fav-chip:hover { background: var(--orange); color: #fff; }
.fav-chip:active { transform: scale(0.93); }

/* ====== ADD BUTTON ====== */
.add-food-btn {
    width: 100%; padding: 10px; background: var(--orange);
    border: none; border-radius: 10px; color: #fff;
    font-size: 14px; font-weight: 700; cursor: pointer;
    font-family: inherit; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; gap: 6px;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s;
}
.add-food-btn:hover { background: var(--orange-dim); }
.add-food-btn:active { transform: scale(0.97); }
.add-food-btn svg { flex-shrink: 0; width: 14px; height: 14px; }
.supp-btn { background: #8b5cf6; }
.supp-btn:hover { background: #7c3aed; }
.meal-create-btn { background: #0891b2; }
.meal-create-btn:hover { background: #0e7490; }

/* ====== LOG CARD ====== */
.log-card {
    flex: 1; min-height: 0; background: var(--surface);
    border: 1px solid var(--border); border-radius: 10px;
    overflow: hidden; display: flex; flex-direction: column;
}
.log-list { flex: 1; overflow-y: auto; }
.log-empty {
    padding: 16px 12px; font-size: 11px; color: var(--text3); text-align: center;
    display: flex; flex-direction: column; align-items: center; gap: 6px;
}
.log-empty svg { color: var(--text3); width: 32px; height: 32px; }
.log-item {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 10px; border-bottom: 1px solid var(--border);
    cursor: pointer; transition: background 0.1s;
}
.log-item:last-child { border-bottom: none; }
.log-item:hover { background: rgba(0,0,0,0.02); }
.log-item:active { background: rgba(56,189,248,0.05); }
.log-name { flex: 1; font-size: 12px; font-weight: 500; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log-detail { font-size: 10px; color: var(--text2); white-space: nowrap; }
.log-detail b { color: var(--orange); font-weight: 600; }
.log-time { font-size: 8px; color: var(--text3); white-space: nowrap; }

/* Supplement log extras */
.supp-dose { font-size: 11px; color: var(--orange); font-weight: 600; }
.supp-timing { font-size: 10px; color: var(--text3); }

/* Saved meal items */
.meal-item {
    display: flex; align-items: center; gap: 8px;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    transition: background 0.1s;
}
.meal-item:last-child { border-bottom: none; }
.meal-info { flex: 1; }
.meal-name { font-size: 13px; font-weight: 600; color: var(--text); }
.meal-macros { font-size: 11px; color: var(--text2); }
.meal-macros b { color: var(--orange); }
.meal-use {
    padding: 6px 14px; background: var(--orange-light);
    border: 1px solid rgba(249,115,22,0.2); border-radius: 6px;
    color: var(--orange); font-size: 11px; font-weight: 600;
    cursor: pointer; font-family: inherit; white-space: nowrap;
    -webkit-tap-highlight-color: transparent; transition: all 0.15s;
}
.meal-use:hover { background: var(--orange); color: #fff; }
.meal-del {
    background: none; border: none; color: var(--text3);
    font-size: 16px; cursor: pointer; padding: 2px 4px;
    transition: color 0.15s;
}
.meal-del:hover { color: var(--red); }

.supps-header, .meals-header {
    font-size: 12px; font-weight: 700; color: var(--text);
    flex-shrink: 0;
}

/* ====== MODALS ====== */
.modal-bg {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.35); z-index: 200;
    align-items: flex-end; justify-content: center;
}
.modal-bg.open { display: flex; }
.modal {
    background: var(--bg); border-radius: 16px 16px 0 0;
    width: 100%; max-width: 420px; padding: 20px;
    display: flex; flex-direction: column; gap: 12px;
    animation: slideUp 0.25s ease;
    max-height: 80vh; overflow-y: auto;
}
/* Onboarding is full-screen */
#onboardModal {
    align-items: stretch; justify-content: stretch;
    background: var(--bg);
}
#onboardModal .modal {
    max-width: 100%; max-height: 100%; border-radius: 0;
    flex: 1; justify-content: center;
    padding: 24px 20px;
    gap: 14px;
}
#onboardModal .modal-head {
    font-size: 22px; text-align: center; justify-content: center;
}
#onboardModal .onboard-text { text-align: center; font-size: 14px; }
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    font-size: 16px; font-weight: 700; color: var(--text);
}
.modal-x {
    background: none; border: none; color: var(--text3);
    font-size: 22px; cursor: pointer; padding: 0 4px;
}
.modal label {
    display: flex; flex-direction: column; font-size: 11px;
    color: var(--text2); font-weight: 500; gap: 4px;
}
.modal input, .modal select {
    width: 100%; background: var(--surface); border: 2px solid var(--border);
    border-radius: 10px; padding: 12px 14px; color: var(--text);
    font-size: 16px; outline: none; font-family: inherit; -webkit-appearance: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.modal input:focus, .modal select:focus {
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-glow);
}
.modal-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.modal-submit {
    width: 100%; padding: 12px; background: var(--orange);
    border: none; border-radius: 10px; color: #fff;
    font-size: 14px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: background 0.15s;
}
.modal-submit:hover { background: var(--orange-dim); }
.modal-submit:active { transform: scale(0.98); }
.modal-actions { display: flex; gap: 8px; }
.modal-actions .modal-submit { flex: 1; }
.modal-delete {
    padding: 12px 20px; background: none; border: 1px solid rgba(239,68,68,0.3);
    border-radius: 10px; color: var(--red); font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.modal-delete:hover { background: rgba(239,68,68,0.05); border-color: var(--red); }
.check-label {
    display: flex !important; flex-direction: row !important; align-items: center;
    gap: 8px; font-size: 12px !important; color: var(--text2) !important;
}
.check-label input { width: 16px !important; height: 16px; accent-color: var(--orange); flex-shrink: 0; padding: 0 !important; }

/* ====== CALENDAR ====== */
.cal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 4px 0; flex-shrink: 0;
}
.cal-month { font-size: 14px; font-weight: 700; color: var(--text); }
.cal-arrow {
    background: none; border: 1px solid var(--border); border-radius: 6px;
    padding: 4px 10px; font-size: 14px; color: var(--text2);
    cursor: pointer; font-family: inherit; transition: all 0.15s;
}
.cal-arrow:hover { border-color: var(--orange); color: var(--orange); }
.cal-grid {
    display: grid; grid-template-columns: repeat(7, 1fr);
    gap: 2px; flex: 1; min-height: 0;
}
.cal-day-hdr {
    text-align: center; font-size: 9px; font-weight: 600;
    color: var(--text3); padding: 4px 0; text-transform: uppercase;
}
.cal-day {
    text-align: center; font-size: 11px; padding: 6px 2px;
    border-radius: 6px; cursor: pointer; position: relative;
    transition: background 0.15s; color: var(--text2);
}
.cal-day:hover { background: var(--surface); }
.cal-day.today { font-weight: 700; color: var(--orange); }
.cal-day.has-data::after {
    content: ''; position: absolute;
    bottom: 2px; left: 50%; transform: translateX(-50%);
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--orange);
}
.cal-day.selected { background: var(--orange); color: #fff; }
.cal-day.selected::after { background: #fff; }
.cal-day.other-month { opacity: 0.3; }
.cal-summary {
    flex-shrink: 0; font-size: 12px; color: var(--text2);
    padding: 8px; background: var(--surface); border-radius: 8px;
    border: 1px solid var(--border); margin-top: 4px;
    line-height: 1.6;
}
.cal-summary b { color: var(--orange); }

/* ====== ONBOARDING ====== */
.onboard-text { font-size: 13px; color: var(--text2); line-height: 1.5; }
.ob-preview { font-size: 12px; color: var(--text2); line-height: 1.7; padding: 8px; background: var(--surface); border-radius: 8px; }
.ob-preview strong { color: var(--orange); }
.input-unit { display: flex; align-items: center; margin-top: 4px; }
.input-unit input { border-radius: 8px 0 0 8px !important; }
.input-unit span {
    background: var(--surface); border: 1px solid var(--border); border-left: none;
    border-radius: 0 8px 8px 0; padding: 10px 10px; font-size: 12px;
    color: var(--text2); font-weight: 500;
}
.ob-choice {
    width: 100%; padding: 14px; background: var(--surface);
    border: 2px solid var(--border); border-radius: 10px;
    cursor: pointer; text-align: left; font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: all 0.15s; margin-bottom: 8px;
    display: flex; flex-direction: column; gap: 2px;
}
.ob-choice:hover { border-color: var(--orange); background: var(--orange-light); }
.ob-choice:active { transform: scale(0.98); }
.ob-choice-title { font-size: 14px; font-weight: 600; color: var(--text); }
.ob-choice-sub { font-size: 11px; color: var(--text2); }
.ob-skip {
    width: 100%; padding: 10px; background: none; border: none;
    color: var(--text3); font-size: 12px; cursor: pointer;
    font-family: inherit; margin-top: 4px;
    transition: color 0.15s;
}
.ob-skip:hover { color: var(--text2); }
.ob-supp-section { margin-top: 4px; }
.ob-optional { font-weight: 400; color: var(--text3); font-size: 9px; }
.ob-supp-row {
    display: flex; gap: 6px; align-items: flex-end; margin-bottom: 6px;
}
.ob-supp-row input { flex: 1; }
.ob-supp-row .ob-supp-del {
    background: none; border: none; color: var(--text3); font-size: 18px;
    cursor: pointer; padding: 8px 4px; transition: color 0.15s;
}
.ob-supp-row .ob-supp-del:hover { color: var(--red); }
.ob-add-supp, .sb-add-supp {
    width: 100%; padding: 8px; background: none;
    border: 1px dashed var(--border); border-radius: 8px;
    color: var(--orange); font-size: 11px; font-weight: 500;
    cursor: pointer; font-family: inherit; transition: all 0.15s;
    margin-top: 4px;
}
.ob-add-supp:hover, .sb-add-supp:hover { border-color: var(--orange); background: var(--orange-light); }

/* Sidebar supplement targets */
.supp-target-row {
    display: flex; gap: 6px; align-items: center; margin-bottom: 6px;
}
.supp-target-row input { flex: 1; font-size: 13px; padding: 7px 8px; }
.supp-target-row .supp-target-dose { width: 60px; flex: none; }
.supp-target-row .supp-target-del {
    background: none; border: none; color: var(--text3); font-size: 16px;
    cursor: pointer; padding: 2px 4px; transition: color 0.15s;
}
.supp-target-row .supp-target-del:hover { color: var(--red); }

/* Top tab bar removed — using bottom nav */
.tab-bar { display: none; }
.page-title { font-size: 15px; font-weight: 700; color: var(--text); }

/* ====== GOAL EDIT BUTTON ====== */
.goal-edit-btn {
    align-self: center; background: none; border: none;
    color: var(--orange); font-size: 11px; font-weight: 600;
    cursor: pointer; font-family: inherit; padding: 2px 8px;
    flex-shrink: 0; letter-spacing: 0.3px;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
}
.goal-edit-btn:hover { color: var(--orange-dim); }

/* ====== FULLSCREEN MODAL ====== */
.fullscreen-modal {
    align-items: stretch !important; justify-content: stretch !important;
    background: var(--bg) !important;
}
.fullscreen-modal .modal {
    max-width: 100% !important; max-height: 100% !important;
    border-radius: 0 !important; flex: 1;
    padding: 20px; overflow-y: auto;
}
.goal-section { display: flex; flex-direction: column; gap: 10px; }
.goal-divider {
    text-align: center; font-size: 9px; font-weight: 600;
    color: var(--text3); letter-spacing: 1px;
    padding: 8px 0; position: relative;
}
.goal-divider::before, .goal-divider::after {
    content: ''; position: absolute; top: 50%;
    width: 25%; height: 1px; background: var(--border);
}
.goal-divider::before { left: 0; }
.goal-divider::after { right: 0; }
.modal-submit.secondary {
    background: var(--surface2); color: var(--orange);
    border: 1px solid var(--orange);
}
.modal-submit.secondary:hover { background: var(--orange-light); }

/* ====== BOTTOM NAV ====== */
.bottom-nav {
    display: flex; flex-shrink: 0;
    background: #1a1a1a; border-top: none;
    padding: 6px 0;
    padding-bottom: max(6px, env(safe-area-inset-bottom, 6px));
}
.bnav {
    flex: 1; display: flex; flex-direction: column;
    align-items: center; gap: 2px;
    padding: 6px 0; background: none; border: none;
    color: #888; font-size: 9px; font-weight: 500;
    cursor: pointer; font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
}
.bnav svg { transition: transform 0.15s; }
.bnav:hover { color: #bbb; }
.bnav.active { color: var(--orange); }
.bnav.active svg { transform: scale(1.1); }
/* Goals button in center — bigger */
.bnav.bnav-goals {
    position: relative; margin-top: -14px;
}
.bnav.bnav-goals .bnav-circle {
    width: 44px; height: 44px; border-radius: 50%;
    background: var(--orange); display: flex;
    align-items: center; justify-content: center;
    transition: transform 0.15s;
}
.bnav.bnav-goals:hover .bnav-circle { transform: scale(1.08); }
.bnav.bnav-goals:active .bnav-circle { transform: scale(0.95); }
.bnav.bnav-goals .bnav-circle svg { color: #fff; }
.bnav.bnav-goals span { color: #888; margin-top: 4px; }

/* ══════════ DESKTOP ══════════ */
@media (min-width: 769px) {
    .sidebar { transform: translateX(0); box-shadow: none; }
    .sidebar-close { display: none; }
    .menu-btn { display: none; }
    .main { margin-left: var(--sidebar-w); }
    .topbar { padding: 0 20px; min-height: 50px; }
    .page-title { font-size: 17px; }
    .content { padding: 20px; max-width: 800px; margin: 0 auto; width: 100%; }
    .ad-placeholder { height: 90px; line-height: 90px; }
    .ring-wrap { max-width: 200px; }
    .ring-val { font-size: 22px; }
    .log-card { border-radius: 12px; }
    .log-list { padding: 4px 0; }
    .log-item { padding: 12px 16px; gap: 12px; }
    .meal-item { padding: 12px 16px; gap: 12px; }
    .modal-bg {
        align-items: center !important;
        justify-content: center !important;
    }
    .modal {
        border-radius: 16px !important;
        margin-bottom: 0;
        max-width: 480px !important;
    }
    .fullscreen-modal .modal {
        max-width: 520px !important;
        max-height: 85vh !important;
        border-radius: 16px !important;
        flex: none;
    }
    .bottom-nav { display: none; }
}

@media (max-width: 380px) {
    .ad-placeholder { height: 30px; line-height: 30px; font-size: 8px; }
    .ad-banner { padding: 2px 6px; }
    .ring-val { font-size: 14px; }
    .tab { font-size: 10px; padding: 5px 8px; }
}

/* ====== LIGHT MODE ====== */
body.light {
    --bg: #fff;
    --surface: #f5f5f0;
    --surface2: #eae8e0;
    --border: #e0ddd5;
    --text: #1a1a1a;
    --text2: #777;
    --text3: #aaa;
    --white: #fff;
}
body.light .ad-banner { background: #fafaf7; }
body.light .sidebar { background: #fff; box-shadow: 4px 0 20px rgba(0,0,0,0.08); }
body.light .topbar { background: #fff; }
body.light .bottom-nav { background: #fff; border-top: 1px solid #e0ddd5; }
body.light .bnav { color: #aaa; }
body.light .bnav.active { color: var(--orange); }
body.light .modal { background: #fff; }
body.light input, body.light select { background: #f5f5f0; color: #1a1a1a; }
body.light .bnav.bnav-goals .bnav-circle { box-shadow: 0 2px 8px rgba(0,0,0,0.1); }

/* Theme toggle */
.theme-toggle {
    background: none; border: none; color: var(--text2);
    cursor: pointer; padding: 4px; margin-left: auto;
    display: flex; align-items: center;
    -webkit-tap-highlight-color: transparent;
    transition: color 0.15s;
}
.theme-toggle:hover { color: var(--text); }

/* ====== TOUR OVERLAY ====== */
.tour-overlay {
    position: fixed; inset: 0; z-index: 300;
    pointer-events: all;
}
.tour-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.8);
    z-index: 300;
    transition: opacity 0.3s;
}
.tour-highlight {
    position: fixed; z-index: 301;
    border-radius: 10px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.85);
    border: 2px solid #38bdf8;
    background: rgba(255,255,255,0.08);
    pointer-events: none;
    transition: all 0.3s ease;
}
.tour-tooltip {
    position: fixed; z-index: 302;
    background: #fff; color: #1a1a1a;
    border: none;
    border-radius: 12px; padding: 16px 18px;
    max-width: 300px; width: 90vw;
    box-shadow: 0 12px 40px rgba(0,0,0,0.5);
    animation: tourFadeIn 0.25s ease;
}
@keyframes tourFadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.tour-text { font-size: 14px; color: #1a1a1a !important; line-height: 1.5; margin-bottom: 12px; }
.tour-footer { display: flex; align-items: center; justify-content: space-between; }
.tour-step { font-size: 11px; color: #999 !important; }
.tour-next {
    padding: 8px 18px; background: var(--orange); border: none;
    border-radius: 8px; color: #fff; font-size: 13px; font-weight: 600;
    cursor: pointer; font-family: inherit; transition: background 0.15s;
}
.tour-next:hover { background: var(--orange-dim); }
.tour-skip {
    background: none; border: none; color: #999 !important;
    font-size: 11px; cursor: pointer; font-family: inherit;
    padding: 4px 0; transition: color 0.15s;
}
.tour-skip:hover { color: #555 !important; }

.tour-replay-btn {
    width: 100%; padding: 8px; margin-top: 8px;
    background: none; border: 1px solid var(--border);
    border-radius: 8px; color: var(--text2);
    font-size: 11px; font-weight: 500;
    cursor: pointer; font-family: inherit;
    transition: all 0.15s;
}
.tour-replay-btn:hover { border-color: var(--accent); color: var(--accent); }

.guide-btn {
    margin-left: auto; padding: 4px 10px;
    background: var(--orange); color: #fff; border: none;
    border-radius: 6px; font-size: 10px; font-weight: 600;
    cursor: pointer; font-family: inherit;
    -webkit-tap-highlight-color: transparent;
    transition: opacity 0.15s;
    white-space: nowrap;
}
.guide-btn:hover { opacity: 0.85; }

::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
@supports (padding-bottom: env(safe-area-inset-bottom)) { body { padding-bottom: env(safe-area-inset-bottom); } }
