:root {
    --bg: #000000;
    --bg-elevated: #17171a;
    --card: #1c1c1e;
    --card-border: rgba(255, 255, 255, 0.08);
    --text: #ffffff;
    --text-muted: #98989f;
    --text-faint: #636366;
    --accent: #0a84ff;
    --accent-soft: rgba(10, 132, 255, 0.16);
    --c-heart: #ff375f;
    --c-sleep: #7c6cff;
    --c-activity: #30d158;
    --c-food: #ffd60a;
    --c-workout: #ff9f0a;
    --c-drop: #64d2ff;
    --c-temp: #bf5af2;
    --c-body: #5e5ce6;
    --track: rgba(255, 255, 255, 0.12);
    --shadow: 0 1px 0 rgba(0, 0, 0, 0.3), 0 8px 20px rgba(0, 0, 0, 0.35);
    --radius-lg: 24px;
    --radius-md: 18px;
    --safe-top: min(env(safe-area-inset-top, 0px), 60px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --tabbar-height: 58px;
}

* {
    box-sizing: border-box;
    min-width: 0;
}

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

body {
    margin: 0;
    min-height: 100dvh;
    overflow-x: hidden;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Inter, system-ui, sans-serif;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

.screen {
    max-width: 560px;
    margin-inline: auto;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: calc(var(--safe-top) + 16px) 16px 12px;
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    backdrop-filter: blur(16px) saturate(1.4);
    -webkit-backdrop-filter: blur(16px) saturate(1.4);
}

.topbar-title {
    display: flex;
    flex-direction: column;
    align-items: center;
    line-height: 1.2;
}

.eyebrow {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--text-faint);
}

.day {
    font-size: 16px;
    font-weight: 700;
}

.nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--card-border);
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.nav-btn:active {
    transform: scale(0.92);
}

.nav-btn.is-disabled {
    opacity: 0.3;
    pointer-events: none;
}

.nav-btn svg {
    width: 18px;
    height: 18px;
}

.content {
    flex: 1;
    padding: 8px 16px calc(var(--safe-bottom) + var(--tabbar-height) + 24px);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.tab-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    max-width: 560px;
    margin-inline: auto;
    display: flex;
    align-items: stretch;
    height: calc(var(--tabbar-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--bg-elevated);
    border-top: 1px solid var(--card-border);
    overflow-x: auto;
    overflow-y: hidden;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
}

.tab-bar::-webkit-scrollbar {
    display: none;
}

.tab-item {
    flex: 0 0 auto;
    width: 72px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    text-decoration: none;
    color: var(--text-faint);
    transition: color 0.15s ease, transform 0.15s ease;
    scroll-snap-align: start;
}

.tab-item:active {
    transform: scale(0.94);
}

.tab-item svg {
    width: 23px;
    height: 23px;
}

.tab-label {
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.tab-item.is-active {
    color: var(--text);
}

.hero-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 28px 20px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.ring-wrap {
    position: relative;
    width: 176px;
    height: 176px;
}

.ring {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-track {
    fill: none;
    stroke: var(--track);
    stroke-width: 10;
}

.ring-progress {
    fill: none;
    stroke: var(--accent);
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.ring-center {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
}

.ring-value {
    font-size: 44px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.ring-unit {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.hero-caption {
    margin: 0;
    text-align: center;
    font-size: 14px;
    color: var(--text-muted);
    max-width: 34ch;
}

a.hero-card {
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease;
}

a.hero-card:active {
    transform: scale(0.98);
}

.section-title {
    margin: 4px 2px -2px;
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-faint);
}

/* Withings-style stacked measurement cards */
.measure-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.measure-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease;
}

.measure-card:active {
    transform: scale(0.98);
}

.measure-head {
    display: flex;
    align-items: center;
    gap: 8px;
}

.measure-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    display: inline-flex;
}

.measure-icon svg {
    width: 100%;
    height: 100%;
}

.measure-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.measure-chevron {
    margin-left: auto;
    width: 16px;
    height: 16px;
    color: var(--text-faint);
    flex-shrink: 0;
}

.measure-body {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 12px;
}

.measure-main {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.measure-value {
    font-size: 28px;
    font-weight: 800;
    letter-spacing: -0.01em;
    color: var(--text);
}

.measure-value small {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-faint);
    margin-left: 3px;
}

.measure-sub {
    font-size: 12.5px;
    color: var(--text-muted);
}

.measure-spark {
    width: 96px;
    height: 34px;
    flex-shrink: 0;
}

.measure-spark polyline {
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-heart { color: var(--c-heart); }
.icon-pulse { color: var(--c-heart); }
.icon-moon { color: var(--c-sleep); }
.icon-steps { color: var(--c-activity); }
.icon-drop { color: var(--c-drop); }
.icon-temp { color: var(--c-temp); }
.icon-food { color: var(--c-food); }
.icon-workout { color: var(--c-workout); }
.icon-scale { color: var(--c-body); }

.spark-heart { stroke: var(--c-heart); }
.spark-pulse { stroke: var(--c-heart); }
.spark-moon { stroke: var(--c-sleep); }
.spark-steps { stroke: var(--c-activity); }

.stat-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    text-decoration: none;
    color: inherit;
    transition: transform 0.15s ease;
}

.stat-card:active {
    transform: scale(0.97);
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
}

.stat-icon svg {
    width: 17px;
    height: 17px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.stat-value small {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-faint);
    margin-left: 2px;
}

.empty-state {
    margin-top: 12vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 12px;
    padding: 0 12px;
}

.empty-icon {
    width: 60px;
    height: 60px;
    border-radius: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border: 1px solid var(--card-border);
    color: var(--accent);
    margin-bottom: 4px;
}

.empty-icon svg {
    width: 28px;
    height: 28px;
}

.empty-title {
    font-size: 19px;
    font-weight: 700;
    margin: 0;
}

.empty-text {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
    max-width: 40ch;
}

.empty-code {
    margin-top: 8px;
    max-width: 100%;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12.5px;
    background: var(--card);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    padding: 10px 14px;
    border-radius: 12px;
    white-space: pre;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.flash-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: calc(var(--safe-top) + 4px) 16px 0;
}

.flash {
    font-size: 13.5px;
    font-weight: 600;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid var(--card-border);
}

.flash-success {
    color: var(--c-activity);
    background: color-mix(in srgb, var(--c-activity) 14%, var(--card));
}

.flash-error {
    color: var(--c-heart);
    background: color-mix(in srgb, var(--c-heart) 14%, var(--card));
}

.withings-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 16px 4px;
    font-size: 12.5px;
    color: var(--text-faint);
}

.withings-status a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.metric-hero-value {
    font-size: 40px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text);
}

.metric-hero-value small {
    font-size: 16px;
    font-weight: 700;
    margin-left: 2px;
    color: var(--text-faint);
}

.period-tabs {
    display: flex;
    gap: 4px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    padding: 4px;
}

.period-tab {
    flex: 1;
    text-align: center;
    padding: 8px 0;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-decoration: none;
    transition: background 0.15s ease, color 0.15s ease;
}

.period-tab.is-active {
    background: var(--accent);
    color: #fff;
}

.chart-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 20px 16px 12px;
}

.chart {
    display: flex;
    align-items: stretch;
    gap: 6px;
    height: 160px;
}

.chart-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.bar-col {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.chart-scroll .bar-col {
    flex: 0 0 16px;
}

.bar-track {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.bar {
    width: 100%;
    max-width: 22px;
    border-radius: 6px 6px 3px 3px;
    background: var(--accent);
    min-height: 4px;
    transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.bar.is-empty {
    background: var(--track);
}

.bar-label {
    font-size: 10px;
    color: var(--text-faint);
    font-weight: 600;
    text-transform: uppercase;
    white-space: nowrap;
    height: 12px;
}

.bar-value {
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 700;
    white-space: nowrap;
    height: 12px;
}

.chart-scroll .bar-value {
    font-size: 9px;
}

.period-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 14px;
}

.period-nav-label {
    min-width: 15ch;
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.period-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--card);
    border: 1px solid var(--card-border);
    color: var(--text);
    text-decoration: none;
    flex-shrink: 0;
    transition: transform 0.15s ease, opacity 0.15s ease;
}

.period-nav-btn:active {
    transform: scale(0.92);
}

.period-nav-btn.is-disabled {
    opacity: 0.3;
    pointer-events: none;
}

.period-nav-btn svg {
    width: 16px;
    height: 16px;
}

.metric-stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.metric-stat {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    text-align: center;
}

.sync-all-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font: inherit;
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    background: var(--accent);
    border: none;
    padding: 16px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    cursor: pointer;
}

.sync-all-btn svg {
    width: 20px;
    height: 20px;
}

.sync-all-btn:active {
    opacity: 0.9;
}

.sync-all-btn:disabled {
    opacity: 0.6;
    cursor: default;
}

.sync-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sync-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 14px 14px 14px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sync-card-main {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sync-card-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.sync-card-name {
    font-size: 15px;
    font-weight: 700;
}

.sync-card-meta {
    font-size: 12.5px;
    color: var(--text-muted);
}

.sync-btn {
    flex-shrink: 0;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    padding: 9px 16px;
    border-radius: 12px;
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.15s ease;
}

.sync-btn:active {
    opacity: 0.75;
}

.sync-btn.is-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.sync-btn-connect {
    color: #fff;
    background: var(--accent);
    border: none;
    display: inline-flex;
    align-items: center;
}

.auth-content {
    flex: 1;
    justify-content: center;
    padding-bottom: calc(var(--safe-bottom) + 24px);
}

.auth-brand {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    margin-bottom: 8px;
}

.auth-brand .empty-icon {
    margin-bottom: 8px;
}

.auth-title {
    margin: 0;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

.auth-subtitle {
    margin: 0;
    color: var(--text-muted);
    font-size: 14px;
}

.auth-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.auth-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.auth-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted);
}

.auth-input {
    font: inherit;
    font-size: 16px;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 14px;
}

.auth-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.auth-submit {
    margin-top: 4px;
}

/* Goals / habits */
.goal-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.goal-card {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.goal-card-main {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.goal-icon {
    width: 34px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
}

.goal-icon svg {
    width: 18px;
    height: 18px;
}

.icon-check, .icon-target, .icon-flame, .icon-book { color: var(--accent); }

.goal-card-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.goal-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.goal-sub {
    font-size: 12.5px;
    color: var(--text-muted);
}

.goal-progress-track {
    height: 5px;
    border-radius: 3px;
    background: var(--track);
    overflow: hidden;
}

.goal-progress-fill {
    height: 100%;
    border-radius: 3px;
    background: var(--accent);
    transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.goal-progress-track-lg {
    width: 100%;
    height: 8px;
    margin-top: 4px;
}

.goal-toggle {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    color: transparent;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.goal-toggle svg {
    width: 20px;
    height: 20px;
}

.goal-toggle:active {
    transform: scale(0.92);
}

.goal-toggle.is-complete {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.goal-number-form {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.goal-number-form input {
    width: 64px;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 8px;
    text-align: center;
}

.goal-number-form input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.goal-number-form select {
    flex: 1;
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 8px;
}

.goal-number-form select:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.goal-number-form button {
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--accent);
    border: none;
    color: #fff;
    cursor: pointer;
}

.goal-number-form button svg {
    width: 18px;
    height: 18px;
}

.goal-number-form button:active {
    opacity: 0.85;
}

.goal-manage-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.goal-delete-btn {
    color: var(--c-heart);
}

.bar.is-complete {
    background: var(--c-activity);
}

.bar.is-exceeded,
.goal-progress-fill.is-exceeded {
    background: var(--c-heart);
}

.goal-progress-fill.is-complete {
    background: var(--c-activity);
}

.goal-auto-badge {
    flex-shrink: 0;
    font-size: 10.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-faint);
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 3px 8px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.period-tab:has(input:checked) {
    background: var(--accent);
    color: #fff;
}

.icon-picker {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

.icon-swatch {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.icon-swatch svg {
    width: 20px;
    height: 20px;
}

.icon-swatch:has(input:checked) {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
}

.plan-metric-picker {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.plan-metric-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 10px 12px;
    border-radius: 12px;
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
}

.plan-metric-row.is-checked {
    border-color: var(--accent);
}

.plan-metric-row.has-error {
    border-color: var(--c-heart);
}

.plan-metric-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.plan-metric-values {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.plan-metric-values .auth-input {
    padding: 8px 10px;
}

.plan-table {
    width: 100%;
    table-layout: fixed;
    border-collapse: collapse;
    font-size: 13px;
}

.plan-table th,
.plan-table td {
    padding: 8px 4px;
    text-align: right;
    border-bottom: 1px solid var(--card-border);
}

.plan-table th:first-child,
.plan-table td:first-child {
    text-align: left;
}

.plan-table td {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.plan-table th {
    color: var(--text-muted);
    font-weight: 600;
    font-size: 10.5px;
    line-height: 1.25;
    white-space: normal;
    word-break: break-word;
    hyphens: auto;
}

.plan-table-toggle-row td {
    padding: 4px;
    border-bottom: none;
}

.plan-table-toggle-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 6px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
}

.plan-table-toggle-btn svg {
    width: 14px;
    height: 14px;
    transition: transform 0.15s ease;
}

.plan-table-toggle-btn.is-expanded svg {
    transform: rotate(180deg);
}

.plan-gap-positive {
    color: var(--c-activity);
}

.plan-gap-negative {
    color: var(--c-heart);
}

.plan-note-form {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    border-radius: 12px;
    background: var(--bg-elevated);
    border: 1px dashed var(--card-border);
}

.icon-journal { color: var(--accent); }

.journal-content {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 40px;
}

.journal-title-input {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text);
    font: inherit;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.01em;
    padding: 8px 4px;
}

.journal-title-input:focus {
    outline: none;
}

.journal-title-input::placeholder {
    color: var(--text-faint);
}

.journal-blocks {
    display: flex;
    flex-direction: column;
}

.journal-block-row {
    display: flex;
    align-items: flex-start;
    gap: 4px;
    padding: 1px 0;
}

.journal-block-body {
    flex: 1;
    min-width: 0;
}

.journal-input {
    display: block;
    width: 100%;
    resize: none;
    overflow: hidden;
    background: transparent;
    border: none;
    color: var(--text);
    font: inherit;
    font-size: 15px;
    line-height: 1.5;
    padding: 6px 4px;
    border-radius: 8px;
}

.journal-input:focus {
    outline: none;
    background: var(--bg-elevated);
}

.journal-input::placeholder {
    color: var(--text-faint);
}

.journal-heading_1 { font-size: 22px; font-weight: 800; }
.journal-heading_2 { font-size: 19px; font-weight: 700; }
.journal-heading_3 { font-size: 16px; font-weight: 700; }

.journal-list-row {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.journal-bullet,
.journal-number {
    flex-shrink: 0;
    color: var(--text-muted);
    padding-top: 6px;
    font-size: 15px;
    line-height: 1.5;
}

.journal-quote {
    margin: 0;
    padding-left: 10px;
    border-left: 3px solid var(--accent);
}

.journal-quote .journal-input {
    font-style: italic;
    color: var(--text-muted);
}

.journal-divider {
    border: none;
    border-top: 1px solid var(--card-border);
    margin: 14px 4px;
}

.journal-toggle-head {
    display: flex;
    align-items: flex-start;
    gap: 2px;
}

.journal-toggle-caret {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px 2px;
}

.journal-toggle-caret svg {
    width: 16px;
    height: 16px;
    transition: transform 0.15s ease;
}

.journal-toggle-caret.is-open svg {
    transform: rotate(90deg);
}

.journal-toggle-children {
    padding-left: 20px;
    margin-left: 9px;
    border-left: 1px solid var(--card-border);
}

.journal-callout {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    background: var(--bg-elevated);
    border-radius: 12px;
    padding: 8px 10px;
}

.journal-color-default { background: var(--bg-elevated); }
.journal-color-blue { background: rgba(10, 132, 255, 0.14); }
.journal-color-green { background: rgba(48, 209, 88, 0.14); }
.journal-color-yellow { background: rgba(255, 214, 10, 0.14); }
.journal-color-red { background: rgba(255, 55, 95, 0.14); }
.journal-color-purple { background: rgba(191, 90, 242, 0.14); }

.journal-callout-style-form {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    padding-top: 4px;
}

.journal-callout-icon {
    width: 34px;
    text-align: center;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text);
    font-size: 15px;
    padding: 3px 0;
}

.journal-callout-color-select {
    width: 78px;
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 10.5px;
    padding: 3px 2px;
}

.journal-block-actions {
    display: flex;
    align-items: center;
    gap: 0;
    flex-shrink: 0;
    opacity: 0.55;
}

.journal-block-actions:focus-within {
    opacity: 1;
}

.journal-type-select {
    background: transparent;
    border: 1px solid var(--card-border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 10.5px;
    padding: 4px 2px;
    max-width: 92px;
}

.journal-icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    padding: 6px;
    cursor: pointer;
    border-radius: 6px;
}

.journal-icon-btn:active {
    background: var(--card);
}

.journal-icon-btn-danger:active {
    color: var(--c-heart);
}

.journal-inline-form {
    margin: 0;
}

.journal-add-after-form {
    margin: 0;
}

.journal-add-after-btn {
    background: none;
    border: none;
    color: var(--text-faint);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px 10px 8px;
    opacity: 0.6;
}

.journal-add-after-btn:active {
    opacity: 1;
    color: var(--accent);
}

.journal-add-child-form {
    margin-top: 4px;
}

.journal-add-child-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    padding: 6px 4px;
}

.journal-add-end-form {
    margin-top: 12px;
}

.food-search {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

.food-search-input {
    font: inherit;
    font-size: 15px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 12px 14px;
}

.food-search-input:focus {
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.food-search-results {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.food-result {
    text-align: left;
    font: inherit;
    font-size: 14px;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 10px;
    padding: 10px 12px;
    cursor: pointer;
}

.food-result:active {
    background: var(--bg-elevated);
}

.food-add-form {
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    flex-wrap: wrap;
}

.exercise-gif {
    display: block;
    width: 100%;
    border-radius: var(--radius-md);
    background: var(--card);
    border: 1px solid var(--card-border);
    margin-bottom: 4px;
}

.exercise-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.exercise-tag {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 4px 10px;
    text-transform: capitalize;
}

.exercise-instructions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0 0 16px;
    padding-left: 20px;
    color: var(--text);
    font-size: 14.5px;
    line-height: 1.4;
}

.food-add-form[hidden] {
    display: none;
}

.food-delete-btn {
    color: var(--text-faint);
}

.food-delete-btn:active {
    color: var(--accent);
}

.food-add-name {
    flex-basis: 100%;
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    margin: 0 0 2px;
}

.food-preview {
    flex-basis: 100%;
    font-size: 12.5px;
    color: var(--text-muted);
    margin: 0 0 6px;
}

.food-meal-empty {
    font-size: 13.5px;
    color: var(--text-muted);
    margin: 0 0 10px;
}

.food-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
}

.food-suggestion-chip {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 7px 12px;
    cursor: pointer;
}

.food-suggestion-chip small {
    font-weight: 500;
    color: var(--text-faint);
}

.food-suggestion-chip:active {
    background: var(--bg-elevated);
}

.food-search-row {
    display: flex;
    gap: 8px;
}

.food-search-row .food-search-input {
    flex: 1;
    margin-bottom: 0;
}

.food-scan-btn {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    color: var(--text);
    cursor: pointer;
}

.food-scan-btn svg {
    width: 20px;
    height: 20px;
}

.food-scan-btn:active {
    background: var(--bg-elevated);
}

.food-scanner {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--card);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 10px;
}

.food-scanner[hidden] {
    display: none;
}

.food-scanner-video {
    width: 100%;
    aspect-ratio: 4 / 3;
    border-radius: 12px;
    background: #000;
    object-fit: cover;
}

.food-scanner-close {
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 6px 14px;
    cursor: pointer;
}

.food-scan-error {
    font-size: 13px;
    color: var(--c-heart);
    margin: 0;
}

.food-scan-error:empty {
    display: none;
}

.food-serving-chips {
    flex-basis: 100%;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 2px;
}

.food-serving-chips:empty {
    display: none;
}

.food-serving-chip {
    font: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--card-border);
    border-radius: 999px;
    padding: 5px 10px;
    cursor: pointer;
}

.food-serving-chip:active {
    background: var(--card);
}

.food-entry-card {
    gap: 8px;
}

.food-entry-qty-form {
    gap: 4px;
}
