:root {
    color-scheme: dark;
    --bg: #101113;
    --surface: #1a1c20;
    --surface-2: #24262c;
    --line: #30333a;
    --text: #f5f6f7;
    --muted: #9a9da5;
    --accent: #d9ff63;
    --danger: #ff766b;
    --due: #ffd166;
}

:root[data-profile-theme="rose"] {
    --bg: #1b1419;
    --surface: #2a1e26;
    --surface-2: #382832;
    --line: #513a48;
    --text: #f7edf2;
    --muted: #bea6b3;
    --accent: #c487a2;
    --due: #dbc091;
}
[data-profile-theme="rose"] nav { background: rgba(27, 20, 25, .96); }
[data-profile-theme="rose"] .streak { background: linear-gradient(110deg, #382532, #2a1e26); }
[data-profile-theme="rose"] input, [data-profile-theme="rose"] select,
[data-profile-theme="rose"] .calendar-day, [data-profile-theme="rose"] .user-choice { background: #21171e; }
[data-profile-theme="rose"] .modal { background: var(--surface); }
[data-profile-theme="rose"] .completed, [data-profile-theme="rose"] .calendar-day.food-goal { border-color: #99647c; }
[data-profile-theme="rose"] .toggle-row input:checked + i { background: #98617b; }
[data-profile-theme="rose"] .primary-button, [data-profile-theme="rose"] .network-state,
[data-profile-theme="rose"] .completed .status { color: #21131b; }
.halfway { color: var(--accent); }

* { box-sizing: border-box; }

body {
    margin: 0;
    min-width: 320px;
    color: var(--text);
    background: var(--bg);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.auth-root:empty { display: none; }

.app {
    max-width: 680px;
    min-height: 100vh;
    margin: 0 auto;
    padding: max(20px, env(safe-area-inset-top)) 20px calc(94px + env(safe-area-inset-bottom));
}

.app-header, .modal-header, .card-title, .section-title, .food-entry, .toggle-row, .input-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.app-header { margin-bottom: 24px; }

.brand-button, .user-button, .icon-button {
    border: 0;
    color: var(--text);
    background: transparent;
    padding: 0;
    text-align: left;
}

.brand-button { display: grid; gap: 5px; }
.logo { display: block; font-size: 23px; font-weight: 900; letter-spacing: .12em; }
.date, .app-header small, small, .page-heading p, .settings-card p { color: var(--muted); font-size: 13px; }

.user-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 9px 11px;
    background: var(--surface-2);
    border-radius: 12px;
    font-weight: 750;
}

.network-state {
    margin: -9px 0 16px;
    padding: 10px 12px;
    color: #16180d;
    background: var(--accent);
    border-radius: 11px;
    font-size: 13px;
    font-weight: 650;
}

.page-heading { margin-bottom: 18px; }
.page-heading h1 { margin: 0 0 5px; font-size: 27px; letter-spacing: -.035em; }
.page-heading p { margin: 0; }

section { margin: 0 0 26px; }
.section-title { margin-bottom: 10px; }
h2 { margin: 0; color: var(--muted); font-size: 12px; letter-spacing: .12em; }
.section-title span { color: var(--muted); font-size: 12px; }

.tracker {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
    margin-bottom: 9px;
    padding: 15px;
    border: 1px solid transparent;
    border-radius: 17px;
    color: var(--text);
    background: var(--surface);
    text-align: left;
    transition: transform .14s ease, border-color .14s ease;
}

.tracker:active { transform: scale(.985); }
.tracker:hover { border-color: var(--line); }
.tracker-left { display: flex; align-items: center; gap: 13px; min-width: 0; }
.tracker-left span:last-child { display: grid; gap: 3px; min-width: 0; }
.tracker strong { font-size: 16px; }
.icon { flex: 0 0 auto; font-size: 24px; line-height: 1; }
.status { display: grid; place-items: center; width: 29px; height: 29px; flex: 0 0 auto; border: 2px solid #686c74; border-radius: 50%; font-weight: 900; }
.completed { border-color: rgba(217, 255, 99, .45); }
.completed .status { color: #13150a; background: var(--accent); border-color: var(--accent); }
.due { color: var(--due); font-weight: 700; }
.overdue { color: var(--danger); font-weight: 750; }

.streak {
    display: flex;
    align-items: center;
    gap: 13px;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: linear-gradient(110deg, #242028, #1a1c20);
}
.streak > span { font-size: 28px; }
.streak div { display: grid; gap: 3px; }
.streak small { font-size: 12px; }

nav {
    position: fixed;
    z-index: 10;
    bottom: 0;
    left: 50%;
    display: flex;
    justify-content: space-around;
    width: min(680px, 100%);
    padding: 9px 6px calc(10px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    border-top: 1px solid var(--line);
    background: rgba(16, 17, 19, .95);
    backdrop-filter: blur(14px);
}
nav button { display: grid; gap: 3px; min-width: 58px; border: 0; color: #777b84; background: transparent; font-size: 19px; }
nav button span { font-size: 11px; }
nav button.active { color: var(--accent); }

.goal-card, .progress-card, .settings-card {
    margin-bottom: 12px;
    padding: 17px;
    border: 1px solid var(--line);
    border-radius: 17px;
    background: var(--surface);
}
.goal-card .card-title, .settings-card .card-title { margin-bottom: 15px; }
.card-title > div { display: grid; gap: 4px; }
.goal-due { display: block; margin-top: 3px; }

label { display: grid; gap: 7px; color: var(--muted); font-size: 13px; }
.input-row { align-items: stretch; }
.input-row > * { min-width: 0; }
input, select {
    width: 100%;
    min-height: 45px;
    border: 1px solid var(--line);
    border-radius: 11px;
    outline: none;
    color: var(--text);
    background: #121316;
    padding: 10px 12px;
}
input:focus, select:focus { border-color: var(--accent); }
.input-row input { flex: 1; }
.input-row select, .input-row span { flex: 1; }
.input-row span { display: grid; place-items: center start; color: var(--muted); font-size: 13px; }

.primary-button, .secondary-button, .danger-button {
    width: 100%;
    min-height: 45px;
    margin-top: 13px;
    border-radius: 11px;
    padding: 10px 14px;
    font-size: 13px;
    font-weight: 850;
    letter-spacing: .055em;
}
.primary-button { border: 0; color: #191b0b; background: var(--accent); }
.secondary-button { border: 1px solid var(--line); color: var(--text); background: var(--surface-2); }
.danger-button { border: 1px solid rgba(255, 118, 107, .55); color: var(--danger); background: transparent; }
.save-status { display: block; min-height: 15px; margin-top: 7px; }

.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 12px; }
.stat-grid article { display: grid; gap: 6px; min-height: 91px; padding: 15px; border-radius: 16px; background: var(--surface); }
.stat-grid small { color: var(--muted); }
.stat-grid strong { font-size: 22px; letter-spacing: -.04em; }
.stat-grid em { margin-left: 2px; color: var(--muted); font-size: 13px; font-style: normal; font-weight: 600; }
.weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.weekdays { margin: 15px 0 7px; color: var(--muted); text-align: center; font-size: 11px; }
.calendar-day { display: grid; place-items: center; align-content: center; min-height: 42px; border: 1px solid transparent; border-radius: 10px; color: #787c84; background: #15171a; font-size: 12px; }
.calendar-day.active { color: var(--text); border-color: #4a4e57; background: var(--surface-2); }
.calendar-day.food-goal { border-color: rgba(217, 255, 99, .8); }
.calendar-day small { color: var(--accent); font-size: 9px; }
.two-column { display: grid; gap: 12px; }
.plain-list { margin: 12px 0 0; padding: 0; list-style: none; }
.plain-list li { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); color: var(--muted); font-size: 13px; }
.plain-list li:last-child { border: 0; padding-bottom: 0; }
.plain-list strong { color: var(--text); }
.month-input { max-width: 150px; margin-top: 15px; }

.setting-label { margin-top: 14px; }
.settings-card p { line-height: 1.45; }
.toggle-row { color: var(--text); }
.toggle-row > span { display: flex; align-items: center; gap: 10px; }
.toggle-row input { position: absolute; opacity: 0; width: 1px; min-height: 1px; }
.toggle-row i { position: relative; display: block; width: 44px; height: 25px; border-radius: 20px; background: #4a4e57; }
.toggle-row i::after { position: absolute; top: 3px; left: 3px; width: 19px; height: 19px; border-radius: 50%; background: white; content: ""; transition: transform .15s ease; }
.toggle-row input:checked + i { background: #91b728; }
.toggle-row input:checked + i::after { transform: translateX(19px); }

.empty-state { padding: 20px; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); text-align: center; font-size: 13px; }

.modal-overlay { position: fixed; z-index: 30; inset: 0; display: flex; align-items: end; justify-content: center; padding: 12px 0 0; background: rgba(0, 0, 0, .7); }
.modal { width: min(680px, 100%); max-height: 88vh; overflow-y: auto; padding: 22px 20px calc(24px + env(safe-area-inset-bottom)); border: 1px solid var(--line); border-bottom: 0; border-radius: 24px 24px 0 0; background: #191b1f; }
.modal h2 { color: var(--text); font-size: 21px; letter-spacing: -.03em; }
.modal p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.icon-button { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 10px; background: var(--surface-2); font-size: 24px; }
.food-entry { padding: 13px 0; border-bottom: 1px solid var(--line); }
.food-entry span { display: grid; gap: 3px; }
.danger-icon { display: grid; place-items: center; width: 31px; height: 31px; border: 0; border-radius: 9px; color: var(--danger); background: rgba(255, 118, 107, .12); font-size: 20px; }
.stack-form { display: grid; gap: 13px; }

.auth-root { display: grid; min-height: 100vh; place-items: center; padding: 20px; }
.auth-card { width: min(430px, 100%); padding: 28px; border: 1px solid var(--line); border-radius: 24px; background: var(--surface); }
.auth-card > p { margin: 7px 0 22px; color: var(--muted); }
.user-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.user-choice { display: grid; gap: 5px; min-height: 132px; place-content: center; border: 1px solid var(--line); border-radius: 17px; color: var(--text); background: #141519; }
.user-choice:hover { border-color: var(--accent); }
.user-choice span { font-size: 28px; }
.user-choice small { color: var(--muted); }
.auth-card #authForm { margin-top: 20px; }
.success-text { color: var(--accent) !important; }

@media (min-width: 580px) {
    .two-column { grid-template-columns: 1fr 1fr; }
    .page-heading { display: flex; justify-content: space-between; align-items: end; gap: 15px; }
    .month-input { margin: 0; }
}

.expense-filters { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
.expense-filters > label { min-width: 0; }
.expense-filters input, .expense-filters select { display: block; width: 100%; min-width: 0; max-width: 100%; height: 48px; }
.expense-filters input[type="month"] { appearance: none; -webkit-appearance: none; padding-inline: 10px; }
.expense-filters input[type="month"]::-webkit-date-and-time-value { min-width: 0; text-align: left; }
#expensesContent .expense-filters { grid-template-columns: 1.25fr 1fr 1fr; gap: 8px; }
#expensesContent .expense-filters input, #expensesContent .expense-filters select { padding-inline: 6px; font-size: 12px; height: 44px; }
#expensesContent .expense-filters label { font-size: 12px; }
@media (max-width: 350px) {
    #expensesContent .expense-filters { grid-template-columns: repeat(2,minmax(0,1fr)); }
    #expensesContent .expense-filters label:first-child { grid-column: 1 / -1; }
}
.expense-categories { padding: 12px 14px; }
#progressPage .page-heading { display: block; }
#progressMonth { display: block; width: 210px; max-width: 100%; margin: 18px auto 0; text-align: center; }
#progressMonth::-webkit-date-and-time-value { text-align: center; }
.togi-icon { display: inline-block; filter: grayscale(1); }
.food-open { color: var(--accent); font-size: 32px; line-height: 1; padding: 0 6px; }
.expense-actions { display: flex; gap: 10px; margin-bottom: 16px; }
.expense-actions button { flex: 1; min-width: 0; margin-top: 0; }
.expense-item { display: flex; align-items: start; justify-content: space-between; gap: 12px; padding: 15px; margin-bottom: 8px; border: 1px solid var(--line); border-radius: 15px; background: var(--surface); }
.expense-item > div { display: grid; gap: 5px; min-width: 0; overflow-wrap: anywhere; }
.expense-item > div:last-child { text-align: right; flex-shrink: 0; max-width: 48%; }
.expense-edit { background: transparent; border: 0; color: var(--accent); padding: 6px 0; font-size: 12px; }
.expense-review { padding: 12px 0; border-bottom: 1px solid var(--line); }
.expense-review pre, .expense-raw { white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; font-size: 13px; padding: 12px; border-radius: 10px; background: var(--surface-2); }
.expense-help { color: var(--muted); font-size: 12px; line-height: 1.5; }
button:disabled { opacity: .5; cursor: default; }
summary { cursor: pointer; }
.todo-item { display:flex; gap:12px; align-items:center; padding:14px; margin-bottom:10px; background:var(--surface); border:1px solid var(--line); border-radius:15px; }
.todo-item > div { flex:1; min-width:0; overflow-wrap:anywhere; }
.todo-item > button { width:auto; flex:0 0 auto; }
.todo-item > button:first-child { width:40px; min-width:40px; padding:8px; }
#todosContent .expense-actions { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); align-items:stretch; }
#todosContent .expense-actions > * { height:48px; min-height:48px; margin:0; }
#todoFilter { min-width:0; width:100%; margin:0; }
.todo-item small { display:block; margin-top:5px; color:var(--muted); }
.todo-done strong { text-decoration:line-through; opacity:.6; }
.push-actions { display:grid; gap:10px; margin-top:15px; }
nav button { min-width:0; flex:1; padding-inline:2px; }
@media (max-width: 380px) { nav button { min-width: 0; } nav button span { font-size: 10px; } }
