/* Today Daily Dashboard — spec palette + mobile-first layout */

:root {
    --today-green: #006F5C;
    --today-teal: #00C4B4;
    --today-bg: #FAF9F6;
    --today-charcoal: #121212;
    --today-flame: #FF6B00;
    --today-overdue: #D32F2F;
}

body.today-page {
    background: var(--today-bg);
    color: #1a1a1a;
    font-family: var(--font-family-sans, Inter, system-ui, sans-serif);
    font-size: 16px;
    line-height: 1.45;
    padding-bottom: calc(var(--ln-tab-bar-height, 56px) + env(safe-area-inset-bottom, 0px) + 16px);
}

[data-theme="dark"] body.today-page {
    background: var(--today-charcoal);
    color: #f0f0f0;
}

.td-shell {
    max-width: 640px;
    margin: 0 auto;
    padding: 16px 16px 32px;
}

.td-header {
    margin-bottom: 20px;
}

.td-date {
    font-size: 24px;
    font-weight: 700;
    color: var(--today-green);
    margin: 0 0 8px;
}

.td-streaks {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.td-streak-chip {
    font-size: 13px;
    font-weight: 600;
    color: var(--today-flame);
    background: rgba(255, 107, 0, 0.1);
    padding: 4px 10px;
    border-radius: 999px;
}

.td-score-block {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 8px;
}

.td-score-main {
    font-size: 18px;
    font-weight: 700;
}

.td-score-pct {
    font-size: 28px;
    font-weight: 700;
    color: var(--today-teal);
    transition: color 0.3s;
}
.td-score-pct--done  { color: var(--today-green); }
.td-score-pct--mid   { color: var(--today-teal); }
.td-score-pct--low   { color: var(--today-flame); }
.td-score-pct--empty { color: #aaa; }

.td-insight {
    font-size: 16px;
    color: #555;
    font-style: italic;
    margin: 0;
}

[data-theme="dark"] .td-insight { color: #aaa; }

.td-section {
    margin-bottom: 24px;
}

.td-section-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--today-green);
    margin: 0 0 12px;
}

.td-section-title--today {
    font-size: 20px;
    text-transform: none;
    letter-spacing: 0;
}

.td-today-count {
    font-size: 14px;
    font-weight: 500;
    color: #666;
    margin-left: 8px;
}

.td-momentum-scroll {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
}

.td-momentum-card {
    flex: 0 0 200px;
    scroll-snap-align: start;
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 111, 92, 0.12);
}

[data-theme="dark"] .td-momentum-card {
    background: #1e1e1e;
    border-color: rgba(0, 196, 180, 0.2);
}

.td-momentum-name {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
}

.td-momentum-pct {
    font-size: 22px;
    font-weight: 700;
    color: var(--today-teal);
}

.td-momentum-bar {
    height: 6px;
    background: rgba(0, 0, 0, 0.08);
    border-radius: 3px;
    margin: 8px 0;
    overflow: hidden;
}

.td-momentum-bar span {
    display: block;
    height: 100%;
    background: var(--today-green);
    border-radius: 3px;
}

.td-momentum-metric {
    font-size: 13px;
    color: #666;
}

.td-today-group {
    margin-bottom: 16px;
}

.td-today-group-title {
    font-size: 15px;
    font-weight: 700;
    margin: 0 0 8px;
    color: #333;
}

[data-theme="dark"] .td-today-group-title { color: #ddd; }

.td-today-row-wrap {
    margin-bottom: 8px;
    overflow: hidden;
    max-height: 120px;
    transition: opacity 0.28s ease, max-height 0.28s ease, margin 0.28s ease;
}

.td-today-row-wrap--removing {
    opacity: 0;
    max-height: 0;
    margin-bottom: 0;
    pointer-events: none;
}

.td-today-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fff;
    border-radius: 10px;
    padding: 12px 14px;
    border: 1px solid rgba(0, 0, 0, 0.06);
    min-height: 48px;
    transition: opacity 0.2s ease, background 0.2s ease;
}

[data-theme="dark"] .td-today-row {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.08);
}

.td-today-row--overdue {
    border-left: 3px solid var(--today-overdue);
}

.td-today-row--done {
    opacity: 0.6;
    background: rgba(0, 111, 92, 0.04);
    border-color: rgba(0, 111, 92, 0.15);
}

.td-today-row--transient {
    opacity: 0.55;
}

.td-today-row--dismissed {
    background: rgba(100, 116, 139, 0.06);
}

.td-today-row--snoozed {
    background: rgba(0, 196, 180, 0.06);
}

.td-today-row-main {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.td-today-row-text {
    flex: 1;
    min-width: 0;
}

.td-today-row-title--completed {
    text-decoration: line-through;
    text-decoration-color: rgba(0, 111, 92, 0.35);
}

.td-today-row-status {
    font-size: 13px;
    font-weight: 500;
    color: #64748b;
    margin-top: 2px;
}

.td-today-row-status--completed {
    color: var(--today-green);
}

.td-today-row--dismissed .td-today-row-status {
    color: #64748b;
}

.td-today-row--snoozed .td-today-row-status {
    color: var(--today-teal);
}

.td-transient-mark {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    flex-shrink: 0;
    color: #64748b;
}

.td-today-row--snoozed .td-transient-mark {
    color: var(--today-teal);
}

[data-theme="dark"] .td-today-row--done {
    background: rgba(0, 196, 180, 0.08);
}

[data-theme="dark"] .td-today-row-status {
    color: #94a3b8;
}

[data-theme="dark"] .td-today-row-status--completed {
    color: #6ee7b7;
}

.td-today-row-title {
    flex: 1;
    font-weight: 600;
    font-size: 16px;
}

.td-today-row-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
}

.td-today-row-hide {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #94a3b8;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: -4px -6px -4px 0;
    transition: color 0.15s ease, background 0.15s ease;
}

.td-today-row-hide:hover,
.td-today-row-hide:focus-visible {
    color: #64748b;
    background: rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] .td-today-row-hide {
    color: #64748b;
}

[data-theme="dark"] .td-today-row-hide:hover,
[data-theme="dark"] .td-today-row-hide:focus-visible {
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.08);
}

.td-done-mark {
    color: var(--today-green);
    font-size: 18px;
    font-weight: 700;
}

.td-btn {
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    min-height: 44px;
    padding: 0 14px;
    font-family: inherit;
}

.td-btn--primary {
    background: var(--today-green);
    color: #fff;
}

.td-btn--ghost {
    background: transparent;
    color: var(--today-green);
    border: 1px solid rgba(0, 111, 92, 0.35);
}

.td-btn--sm {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
}

.td-btn--icon {
    min-width: 44px;
    min-height: 44px;
    padding: 0;
    background: rgba(0, 111, 92, 0.08);
    color: var(--today-green);
    font-size: 16px;
}

.td-quick-log {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.td-quick-log-btn {
    flex: 1 1 calc(33% - 10px);
    min-width: 90px;
    min-height: 52px;
    border: none;
    border-radius: 12px;
    background: var(--today-green);
    color: #fff;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
}

.td-quick-log-btn--plus {
    background: var(--today-teal);
    flex: 0 0 52px;
    min-width: 52px;
    font-size: 22px;
}

.td-ai-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    border: 1px solid rgba(0, 111, 92, 0.15);
}

[data-theme="dark"] .td-ai-card {
    background: #1a1a1a;
    border-color: rgba(255, 255, 255, 0.08);
}

.td-ai-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.td-ai-select {
    flex: 0 0 120px;
    min-height: 44px;
    border-radius: 8px;
    border: 1px solid rgba(0, 111, 92, 0.3);
    padding: 0 8px;
    font-family: inherit;
    background: #fff;
}

.td-ai-input {
    flex: 1;
    min-height: 44px;
    border-radius: 8px;
    border: 1px solid rgba(0, 111, 92, 0.3);
    padding: 0 12px;
    font-family: inherit;
    font-size: 15px;
}

.td-ai-quick-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.td-ai-subheading {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
}

[data-theme="dark"] .td-ai-subheading {
    color: #94a3b8;
}

.td-ai-chip {
    border: 1px solid rgba(0, 111, 92, 0.25);
    background: rgba(0, 196, 180, 0.12);
    color: var(--today-green);
    border-radius: 999px;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    min-height: 36px;
    font-family: inherit;
}

.td-ai-messages {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: min(320px, 40vh);
    overflow-y: auto;
    font-size: 14px;
    scroll-behavior: smooth;
}

.td-ai-empty-hint {
    margin: 0;
    padding: 12px 10px;
    color: #64748b;
    font-size: 14px;
    line-height: 1.45;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 8px;
}

[data-theme="dark"] .td-ai-empty-hint {
    color: #94a3b8;
    background: rgba(255, 255, 255, 0.04);
}

.td-ai-turn {
    padding: 10px 12px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.03);
}

.td-ai-turn-user {
    background: rgba(0, 111, 92, 0.08);
}

.td-ai-turn-assistant {
    background: rgba(0, 0, 0, 0.04);
}

.td-ai-turn--error .td-ai-turn-body {
    color: var(--today-overdue);
}

.td-ai-turn--thinking .td-ai-turn-body {
    color: #64748b;
    font-style: italic;
}

.td-ai-turn-label {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #64748b;
    margin-bottom: 4px;
}

.td-ai-turn-user .td-ai-turn-label {
    color: var(--today-green);
}

.td-ai-turn-body {
    font-size: 15px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

[data-theme="dark"] .td-ai-turn {
    background: rgba(255, 255, 255, 0.04);
}

[data-theme="dark"] .td-ai-turn-user {
    background: rgba(0, 196, 180, 0.1);
}

.td-win-row {
    padding: 10px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.06);
    font-size: 15px;
}

.td-empty-hint {
    color: #888;
    font-size: 14px;
    margin: 0;
}

.td-loading,
.td-error {
    text-align: center;
    padding: 12px;
    font-size: 14px;
}

.td-error {
    color: var(--today-overdue);
}

/* Goal log bottom sheet — today page (explicit colors; avoids inherit + theme conflicts) */
body.today-page .ln-goal-record-backdrop.td-log-backdrop {
    align-items: flex-end;
    justify-content: center;
    z-index: 2000;
}

body.today-page .ln-goal-record-panel.td-log-panel {
    width: 100%;
    max-width: 640px;
    max-height: 85vh;
    margin: 0;
    overflow-y: auto;
    border-radius: 16px 16px 0 0;
    background: #fff;
    color: #0f172a;
    box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.15);
}

body.today-page .ln-goal-record-label {
    color: #475569;
}

body.today-page .ln-goal-record-input,
body.today-page .ln-goal-record-panel textarea.ln-goal-record-input {
    color: #0f172a;
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    -webkit-text-fill-color: #0f172a;
}

body.today-page .ln-goal-record-input::placeholder,
body.today-page .ln-goal-record-panel textarea.ln-goal-record-input::placeholder {
    color: #94a3b8;
    opacity: 1;
}

body.today-page .ln-goal-record-status {
    color: #64748b;
}

body.today-page .ln-goal-record-status.ok { color: #047857; }
body.today-page .ln-goal-record-status.error { color: #b91c1c; }
body.today-page .ln-goal-record-status.info { color: #64748b; }

body.today-page .ln-goal-record-header {
    border-bottom-color: #e2e8f0;
}

body.today-page .ln-goal-record-footer {
    border-top-color: #e2e8f0;
}

[data-theme="dark"] body.today-page .ln-goal-record-panel.td-log-panel {
    background: #1e2837;
    color: #f1f5f9;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.45);
}

[data-theme="dark"] body.today-page .ln-goal-record-label {
    color: rgba(241, 245, 249, 0.65);
}

[data-theme="dark"] body.today-page .ln-goal-record-input,
[data-theme="dark"] body.today-page .ln-goal-record-panel textarea.ln-goal-record-input {
    color: #f1f5f9;
    background: #0f172a;
    border-color: #475569;
    -webkit-text-fill-color: #f1f5f9;
}

[data-theme="dark"] body.today-page .ln-goal-record-input::placeholder,
[data-theme="dark"] body.today-page .ln-goal-record-panel textarea.ln-goal-record-input::placeholder {
    color: #94a3b8;
}

[data-theme="dark"] body.today-page .ln-goal-record-header {
    border-bottom-color: rgba(148, 163, 184, 0.2);
}

[data-theme="dark"] body.today-page .ln-goal-record-footer {
    border-top-color: rgba(148, 163, 184, 0.2);
}

[data-theme="dark"] body.today-page .ln-goal-record-status.ok { color: #6ee7b7; }
[data-theme="dark"] body.today-page .ln-goal-record-status.error { color: #fca5a5; }

@media (prefers-color-scheme: dark) {
    body.today-page:not([data-theme="light"]) .ln-goal-record-panel.td-log-panel {
        background: #1e2837;
        color: #f1f5f9;
    }

    body.today-page:not([data-theme="light"]) .ln-goal-record-input,
    body.today-page:not([data-theme="light"]) .ln-goal-record-panel textarea.ln-goal-record-input {
        color: #f1f5f9;
        background: #0f172a;
        border-color: #475569;
        -webkit-text-fill-color: #f1f5f9;
    }

    body.today-page:not([data-theme="light"]) .ln-goal-record-label {
        color: rgba(241, 245, 249, 0.65);
    }
}

@media (min-width: 769px) {
    body.today-page {
        padding-bottom: 24px;
    }
}
