:root {
    --ink: #2B2620;
    --ink-soft: #6B6255;
    --paper: #FBF8F3;
    --card: #FFFFFF;
    --line: #E8E1D5;
    --accent: #A94F23;
    --accent-ink: #FFFFFF;
    --accent-soft: #FBEAE0;
    --good: #387049;
    --good-soft: #E7F3E9;
    --warn: #A84E27;
    --warn-soft: #FCEEE5;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(43, 38, 32, 0.06), 0 8px 24px rgba(43, 38, 32, 0.05);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 20px 64px;
}

/* ── Top nav ─────────────────────────────────────────── */

.topbar {
    background: var(--card);
    border-bottom: 1px solid var(--line);
    margin-bottom: 28px;
}

.topbar-inner {
    max-width: 880px;
    margin: 0 auto;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.app-switcher { display: flex; gap: 6px; }

.app-switch-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 15px;
    color: var(--ink-soft);
    padding: 9px 16px;
    border-radius: 12px;
    white-space: nowrap;
}
.app-switch-item:hover { background: var(--paper); color: var(--ink); text-decoration: none; }
.app-switch-item.active { background: var(--accent); color: var(--accent-ink); }

.subnav-inner {
    max-width: 880px;
    margin: 0 auto;
    padding: 0 20px 12px;
}

nav.tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

nav.tabs a {
    color: var(--ink-soft);
    font-weight: 600;
    font-size: 14px;
    padding: 8px 14px;
    border-radius: 999px;
    white-space: nowrap;
}
nav.tabs a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }
nav.tabs a.active { background: var(--accent); color: var(--accent-ink); }

.settings-tabs {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 5px;
    margin-bottom: 20px;
}
.settings-tab {
    font-family: inherit;
    font-weight: 600;
    font-size: 14px;
    color: var(--ink-soft);
    background: none;
    border: none;
    padding: 9px 15px;
    border-radius: 8px;
    cursor: pointer;
}
.settings-tab:hover { background: var(--paper); color: var(--ink); }
.settings-tab.active { background: var(--accent); color: var(--accent-ink); }

.account {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 14px;
    color: var(--ink-soft);
}

.profile-menu-wrap { position: relative; }
.profile-trigger {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
    cursor: pointer;
}
.profile-trigger:hover { background: var(--accent-soft); }
.profile-menu {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 180px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 6px;
    z-index: 20;
}
.profile-menu.open { display: block; }
.profile-menu a {
    display: block;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--ink);
}
.profile-menu a:hover { background: var(--accent-soft); color: var(--accent); text-decoration: none; }

/* ── Themes: swap the accent hue plus a matching tint on the page background/borders so the
   whole app reads as themed, not just buttons. Cards stay white for text contrast either way.
   Scoped to body[data-theme] since that's where the attribute is actually set. ── */
body[data-theme="ocean"] {
    --accent: #1D6FA5;
    --accent-soft: #E1EEF6;
    --paper: #F1F6FA;
    --line: #DCE7EE;
}
body[data-theme="forest"] {
    --accent: #2E7D4F;
    --accent-soft: #E3F0E8;
    --paper: #F1F7F2;
    --line: #DCEBE1;
}
body[data-theme="berry"] {
    --accent: #8B3A7A;
    --accent-soft: #F3E5F0;
    --paper: #F8F1F6;
    --line: #EEDCE8;
}

/* ── Headings / layout ───────────────────────────────── */

h1 { font-size: 26px; margin: 0 0 4px; }
h2 { font-size: 19px; margin: 0 0 12px; }
h3 { font-size: 16px; margin: 0 0 8px; }

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 22px;
    flex-wrap: wrap;
}

.subtitle { color: var(--ink-soft); font-size: 14px; margin: 0; max-width: 58ch; }

/* ── Cards ────────────────────────────────────────────── */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
    margin-bottom: 18px;
}

.card + .card { margin-top: 18px; }

/* Collapsible cards (progressive disclosure for optional sections) */
details.card { padding: 16px 20px; }
details.card[open] { padding: 20px; }
details.card summary {
    cursor: pointer;
    list-style: none;
    font-size: 19px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
details.card summary::-webkit-details-marker { display: none; }
details.card summary::before {
    content: '›';
    display: inline-block;
    font-size: 20px;
    font-weight: 700;
    color: var(--ink-soft);
    transform: rotate(0deg);
    transition: transform 0.15s ease;
    width: 14px;
}
details.card[open] summary::before { transform: rotate(90deg); }
details.card summary:hover { color: var(--accent); }
.track-mode-toggle {
    display: flex;
    gap: 8px;
    margin: 4px 0 12px;
    flex-wrap: wrap;
}
.track-mode-option {
    flex: 1;
    min-width: 200px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--ink-soft);
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 9px;
    padding: 9px 12px;
    cursor: pointer;
}
.track-mode-option:has(input:checked) {
    background: var(--accent-soft);
    border-color: var(--accent);
    color: var(--accent);
}
.track-mode-option input { width: auto; margin: 0; }

.optional-tag {
    font-size: 11.5px;
    font-weight: 700;
    color: var(--ink-soft);
    background: var(--paper);
    border: 1px solid var(--line);
    padding: 2px 8px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ── Buttons ──────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--accent);
    color: var(--accent-ink);
    border: none;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}
.btn:hover { background: #8A431D; text-decoration: none; }

.btn.secondary {
    background: transparent;
    color: var(--ink);
    border: 1px solid var(--line);
}
.btn.secondary:hover { background: var(--paper); }

.btn.danger { background: var(--warn); }
.btn.danger:hover { background: #8F4120; }

.btn.small { padding: 6px 12px; font-size: 13px; }

.btn-link {
    background: none;
    border: none;
    color: var(--accent);
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
    font-family: inherit;
}
.btn-link:hover { text-decoration: underline; }

/* ── Forms ────────────────────────────────────────────── */

label {
    display: block;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink-soft);
    margin-bottom: 6px;
}

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    font-family: inherit;
    font-size: 14px;
    background: var(--paper);
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--accent);
    background: var(--card);
}

/* Every button and link relied on the browser's own default outline, which is inconsistent
   across browsers and sometimes barely visible — this gives keyboard navigation one clear,
   consistent focus indicator app-wide, without changing anything for mouse/touch use. */
a:focus-visible,
button:focus-visible,
input[type=checkbox]:focus-visible,
input[type=radio]:focus-visible,
.habit-check:focus-within .habit-check-box {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 4px;
}

.field { margin-bottom: 16px; }
.field-row { display: flex; gap: 12px; flex-wrap: wrap; }
.field-row > .field { flex: 1; min-width: 120px; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }

.hint { font-size: 12.5px; color: var(--ink-soft); margin-top: 4px; max-width: 58ch; }

/* ── Theme picker (account.php) ──────────────────────────── */

.theme-picker { display: flex; gap: 12px; flex-wrap: wrap; }
.theme-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
    margin: 0;
}
.theme-option input[type=radio] { width: auto; margin: 0; }
.theme-option.selected { border-color: var(--accent); background: var(--accent-soft); font-weight: 700; }
.theme-swatch {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.1);
    flex-shrink: 0;
}

/* ── Auth pages ───────────────────────────────────────── */

.auth-wrap {
    max-width: 380px;
    margin: 64px auto;
    padding: 0 20px;
}
.auth-wrap h1 { text-align: center; }
.auth-wrap .subtitle { text-align: center; margin-bottom: 24px; }
.auth-switch { text-align: center; font-size: 14px; margin-top: 16px; color: var(--ink-soft); }

/* ── Flash / alerts ───────────────────────────────────── */

.alert {
    padding: 12px 16px;
    border-radius: 10px;
    font-size: 14px;
    margin-bottom: 18px;
}
.alert.success { background: var(--good-soft); color: var(--good); }
.alert.error { background: var(--warn-soft); color: var(--warn); }

.undo-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--ink);
    color: var(--paper);
    padding: 12px 14px 12px 18px;
    border-radius: 999px;
    box-shadow: var(--shadow);
    font-size: 14px;
    font-weight: 600;
    z-index: 30;
    animation: toast-in 0.2s ease-out;
}
.undo-toast button {
    background: none;
    border: none;
    color: var(--accent-soft);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 10px;
    border-radius: 999px;
}
.undo-toast button:hover { background: rgba(255,255,255,0.12); }
@keyframes toast-in {
    from { opacity: 0; transform: translateX(-50%) translateY(8px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ── Lists / rows ─────────────────────────────────────── */

.row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }

.row-main { flex: 1; min-width: 0; }
.row-title { font-weight: 700; font-size: 15px; }
.row-meta { font-size: 13px; color: var(--ink-soft); margin-top: 2px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }

.expense-item-list {
    list-style: none;
    margin: 6px 0 0;
    padding: 8px 10px;
    background: var(--paper);
    border-radius: 8px;
    font-size: 13px;
    color: var(--ink-soft);
}
.expense-item-list li { display: flex; justify-content: space-between; gap: 10px; padding: 2px 0; }
.expense-item-list li span { color: var(--ink); font-weight: 600; }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--ink-soft);
}

/* ── Badges ───────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12.5px;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 999px;
}
.badge.have { background: var(--good-soft); color: var(--good); }
.badge.need { background: var(--warn-soft); color: var(--warn); }
.badge.soon { background: #FDF3D9; color: #8A620B; }
.badge.neutral { background: var(--line); color: var(--ink-soft); }

/* ── Recipe grid ──────────────────────────────────────── */

.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    align-items: start;
}
.dashboard-grid > .card { min-width: 0; }

.recipe-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    display: block;
    color: var(--ink);
}
.recipe-card:hover { border-color: var(--accent); text-decoration: none; }
.recipe-card h2 { font-size: 17px; font-weight: 800; margin: 0 0 6px; }
.recipe-card-photo {
    display: block;
    width: calc(100% + 32px);
    height: 140px;
    object-fit: cover;
    margin: -16px -16px 12px;
    border-radius: var(--radius) var(--radius) 0 0;
}
.recipe-card .row-meta { margin-top: 0; }

/* ── Date nav ─────────────────────────────────────────── */

.date-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}
.date-nav .btn.secondary { padding: 6px 12px; }
.date-nav strong { font-size: 15px; }

/* ── Dynamic form rows (recipe editor) ───────────────────*/

.dyn-row {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
    align-items: flex-start;
}
.dyn-row input, .dyn-row textarea { flex: 1; min-width: 0; }
.dyn-row .ing-qty { flex: 0 1 90px; max-width: 90px; }
.dyn-row .ing-unit { flex: 0 1 110px; max-width: 110px; }
.dyn-row .step-num {
    flex: 0 0 28px;
    padding-top: 10px;
    font-weight: 700;
    color: var(--ink-soft);
    text-align: center;
}
.dyn-remove {
    flex: 0 0 auto;
    background: none;
    border: 1px solid var(--line);
    border-radius: 8px;
    width: 38px;
    height: 38px;
    cursor: pointer;
    color: var(--warn);
    font-size: 16px;
    line-height: 1;
}
.dyn-remove:hover { background: var(--warn-soft); }

/* ── Misc ─────────────────────────────────────────────── */

.meal-type-pill {
    text-transform: capitalize;
    font-size: 12.5px;
    font-weight: 700;
    color: var(--accent);
    background: var(--accent-soft);
    padding: 3px 10px;
    border-radius: 999px;
}
/* Same meal-type colors as the calendar chips (style.css ~line 423), so the color code learned
   there carries over to the page you actually plan meals on. */
.meal-type-pill.meal-breakfast { background: #FDF3D9; color: #8A620B; }
.meal-type-pill.meal-lunch     { background: #E1F3EE; color: #1F7A63; }
.meal-type-pill.meal-dinner    { background: var(--accent-soft); color: #A94F23; }
.meal-type-pill.meal-snack     { background: #F1E9F9; color: #7A4FA0; }

ol.steps { padding-left: 22px; margin: 0; }
ol.steps li { margin-bottom: 12px; line-height: 1.5; max-width: 58ch; }

ul.ingredients { list-style: none; margin: 0; padding: 0; }
ul.ingredients li {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid var(--line);
    font-size: 14.5px;
}
ul.ingredients li:last-child { border-bottom: none; }
ul.ingredients li .qty { color: var(--ink-soft); flex-shrink: 1; min-width: 0; max-width: 36ch; text-align: right; }
ul.ingredients li { flex-wrap: wrap; }

/* ── Calendar ─────────────────────────────────────────── */

.cal-view-toggle { display: flex; gap: 8px; }

.cal-card { padding: 0; overflow: hidden; }

.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
}

.cal-weekdays {
    border-bottom: 1px solid var(--line);
    background: var(--paper);
}

.cal-weekday {
    padding: 10px 6px;
    font-size: 12px;
    font-weight: 700;
    color: var(--ink-soft);
    text-align: center;
}

.cal-cell {
    min-width: 0;
    min-height: 92px;
    padding: 6px;
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--ink);
}
a.cal-cell { cursor: pointer; }
a.cal-cell:hover { background: var(--accent-soft); text-decoration: none; }
.cal-cell-today.cal-cell-today:hover { background: #F5D9C4; }
.cal-grid > .cal-cell:nth-child(7n) { border-right: none; }

.cal-grid-week .cal-cell { min-height: 160px; }

.cal-cell-empty { background: var(--paper); }

.cal-cell-today { background: var(--accent-soft); }

.cal-date {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    flex-shrink: 0;
}
.cal-cell-today .cal-date { background: var(--accent); color: var(--accent-ink); }

.cal-dishes { display: flex; flex-direction: column; gap: 3px; min-width: 0; }

.cal-dish {
    display: block;
    font-size: 11.5px;
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 2px 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
.cal-dish.meal-breakfast { background: #FDF3D9; border-color: #F0DFA8; color: #8A620B; }
.cal-dish.meal-lunch     { background: #E1F3EE; border-color: #B9E1D5; color: #1F7A63; }
.cal-dish.meal-dinner    { background: var(--accent-soft); border-color: #F0CBB2; color: #A94F23; }
.cal-dish.meal-snack     { background: #F1E9F9; border-color: #DCC5EE; color: #7A4FA0; }
.cal-dish.cal-eating-out { background: var(--line); border-color: var(--line); color: var(--ink-soft); font-weight: 700; }

.cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--line);
    background: var(--paper);
}
.cal-legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--ink-soft);
    font-weight: 600;
}
.cal-legend-swatch {
    width: 12px;
    height: 12px;
    border-radius: 4px;
    border: 1px solid var(--line);
    flex-shrink: 0;
}
.cal-legend-item.meal-breakfast .cal-legend-swatch { background: #FDF3D9; border-color: #F0DFA8; }
.cal-legend-item.meal-lunch .cal-legend-swatch     { background: #E1F3EE; border-color: #B9E1D5; }
.cal-legend-item.meal-dinner .cal-legend-swatch    { background: var(--accent-soft); border-color: #F0CBB2; }
.cal-legend-item.meal-snack .cal-legend-swatch     { background: #F1E9F9; border-color: #DCC5EE; }

.cal-more {
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    padding: 0 5px;
}

@media (max-width: 700px) {
    .cal-dish { font-size: 10.5px; padding: 1px 4px; }
    .cal-cell { min-height: 74px; padding: 4px; }
    .cal-weekday { padding: 8px 2px; font-size: 10.5px; }
}

@media (max-width: 560px) {
    .topbar-inner { flex-direction: column; align-items: stretch; gap: 10px; padding-left: 14px; padding-right: 14px; }
    .app-switcher { justify-content: center; flex-wrap: wrap; gap: 4px; }
    .app-switch-item { padding: 8px 10px; font-size: 13.5px; gap: 5px; }
    nav.tabs { justify-content: center; }
    /* Keep the profile control pinned to the top-right corner, same as desktop, rather than
       stretching full-width and defaulting to the left edge like the row above it. */
    .profile-menu-wrap { align-self: flex-end; }
    .row { flex-direction: column; align-items: flex-start; }
    .row-actions { width: 100%; justify-content: flex-start; }

    /* Ingredient rows: name gets its own full-width line, qty/unit/remove share the next. */
    #ingredient-rows .dyn-row { flex-wrap: wrap; }
    #ingredient-rows .ing-name { flex-basis: 100%; }
    #ingredient-rows .ing-qty,
    #ingredient-rows .ing-unit { flex: 1 1 0; max-width: none; }

    /* Row-action buttons stay comfortably tappable at phone width. */
    .btn.small { min-height: 40px; padding: 8px 14px; }
}

/* ── Planner: daily habits / tasks checklist ─────────────*/

.habit-time-heading {
    font-size: 12.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--ink-soft);
    margin: 18px 0 4px;
}
.habit-time-heading:first-of-type { margin-top: 4px; }

ul.habit-list { list-style: none; margin: 0; padding: 0; }
ul.habit-list li.habit-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--line);
    max-height: 60px;
    overflow: hidden;
    transition: max-height 0.22s ease, opacity 0.22s ease, padding 0.22s ease, border-color 0.22s ease;
}
ul.habit-list li.habit-item:last-child { border-bottom: none; }

/* Checking an item off collapses it here, then it re-expands in the Completed list (see .entering). */
ul.habit-list li.habit-item.leaving {
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    border-color: transparent;
}
ul.habit-list li.habit-item.entering { animation: habit-pop-in 0.32s ease; }
@keyframes habit-pop-in {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}

.completed-section { margin-top: 4px; }
.completed-heading { color: var(--ink-soft); opacity: 0.8; }
ul.habit-list-completed .habit-label { color: var(--ink-soft); }
ul.habit-list-completed .habit-item { opacity: 0.85; }

/* ── Expense summary bars ─────────────────────────────── */

.expense-bar-row {
    display: grid;
    grid-template-columns: 100px 1fr 90px;
    align-items: center;
    gap: 12px;
    padding: 7px 0;
}
.expense-bar-label { font-size: 13.5px; font-weight: 600; color: var(--ink); }
.expense-bar-track {
    height: 10px;
    background: var(--paper);
    border-radius: 999px;
    overflow: hidden;
}
.expense-bar-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 999px;
    transition: width 0.3s ease;
}
.expense-bar-value { font-size: 13.5px; font-weight: 700; color: var(--ink); text-align: right; }

@media (max-width: 560px) {
    .expense-bar-row { grid-template-columns: 72px 1fr 70px; gap: 8px; }
    .expense-bar-label, .expense-bar-value { font-size: 12px; }
}

.habit-check {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}
.habit-check input[type=checkbox] {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
}
.habit-check-box {
    width: 24px;
    height: 24px;
    border-radius: 7px;
    border: 2px solid var(--line);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    transition: background 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}
.habit-check-box::after {
    content: '';
    width: 11px;
    height: 6px;
    margin-top: -2px;
    border-left: 2.5px solid white;
    border-bottom: 2.5px solid white;
    transform: rotate(-45deg) scale(0);
    transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.habit-item.done .habit-check-box {
    background: var(--good);
    border-color: var(--good);
}
.habit-item.done .habit-check-box::after { transform: rotate(-45deg) scale(1); }
.habit-check:active .habit-check-box { transform: scale(0.88); }

.habit-label {
    position: relative;
    font-size: 15px;
    font-weight: 600;
    transition: color 0.3s ease 0.1s;
}
.habit-label::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 0%;
    height: 2px;
    background: var(--ink-soft);
    transition: width 0.35s ease-out;
}
.habit-item.done .habit-label { color: var(--ink-soft); }
.habit-item.done .habit-label::after { width: 100%; }

.habit-numeric-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex: 1;
    min-width: 0;
}
.habit-numeric-control { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.habit-numeric-input {
    width: 64px;
    padding: 6px 8px;
    border: 1px solid var(--line);
    border-radius: 7px;
    font-family: inherit;
    font-size: 13.5px;
    background: var(--card);
    color: var(--ink);
    text-align: right;
}
.habit-numeric-input:focus { outline: none; border-color: var(--accent); }
.habit-unit { font-size: 12.5px; color: var(--ink-soft); white-space: nowrap; }

.habit-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    width: 100%;
    max-width: 280px;
}
.habit-grid-cell {
    width: 100%;
    aspect-ratio: 1;
    border-radius: 4px;
    background: var(--paper);
    border: 1px solid var(--line);
}
.habit-grid-cell.hit { background: var(--good); border-color: var(--good); }
.habit-grid-cell.miss { background: var(--warn-soft); border-color: var(--line); }
.habit-grid-cell.na { background: transparent; border-color: transparent; }

.cal-dish.cal-task { background: var(--card); border-color: var(--line); color: var(--ink); }
.cal-dish.cal-task-done { background: var(--good-soft); border-color: transparent; color: var(--good); text-decoration: line-through; }
