/* ---- Reset (replaces Pico CSS) ---- */
*,
*::before,
*::after {
    box-sizing: border-box;
}
* {
    margin: 0;
}
html {
    -webkit-text-size-adjust: 100%;
}
img,
picture,
video,
canvas,
svg {
    display: block;
    max-width: 100%;
}
input,
button,
textarea,
select {
    font: inherit;
}
p,
h1,
h2,
h3,
h4,
h5,
h6 {
    overflow-wrap: break-word;
}

/* ---- Base form styles ---- */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
input[type="tel"],
textarea,
select {
    display: block;
    width: 100%;
    padding: var(--space-xs) var(--space-sm);
    border: 2px solid var(--tiger-border);
    border-radius: var(--radius-md);
    font-size: var(--text-body);
    font-family: inherit;
    background: var(--tiger-surface);
    color: var(--tiger-text);
    margin-bottom: var(--space-xs);
    transition: border-color var(--duration-short);
}

textarea {
    overflow: hidden;
    resize: none;
}

input:focus,
textarea:focus,
select:focus {
    border-color: var(--tiger-accent);
    outline: none;
}

label {
    display: block;
    font-size: var(--text-small);
    font-weight: var(--weight-medium);
    margin-bottom: var(--space-2xs);
}

fieldset {
    border: none;
    padding: 0;
    margin: 0;
}

button {
    cursor: pointer;
    font: inherit;
    border: none;
    background: none;
    padding: 0;
}

/* ---- Tiger Design System ---- */
/* See DESIGN.md for full specification */

:root {
    /* Colors */
    --tiger-bg: #faf9f7;
    --tiger-surface: #ffffff;
    --tiger-text: #2c2c2c;
    --tiger-muted: #8a8a86;
    --tiger-accent: #5b9a6d;
    --tiger-accent-hover: #4e8760;
    --tiger-border: #e8e6e3;

    /* Severity scale */
    --severity-1: #a8e6a3;
    --severity-2: #d4e89c;
    --severity-3: #f0e68c;
    --severity-4: #f5c96c;
    --severity-5: #f0a050;

    /* Semantic */
    --tiger-success: #5b9a6d;
    --tiger-warning: #d4a030;
    --tiger-error: #c44040;
    --tiger-info: #5b7ea6;

    /* Spacing (8px base) */
    --space-2xs: 4px;
    --space-xs: 8px;
    --space-sm: 12px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    --space-3xl: 64px;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 9999px;

    /* Typography Scale */
    --text-hero: 48px;
    --text-title: 32px;
    --text-section: 24px;
    --text-sub: 18px;
    --text-body: 16px;
    --text-small: 14px;
    --text-caption: 13px;
    --text-micro: 12px;

    /* Font Weights */
    --weight-regular: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;

    /* Motion */
    --duration-micro: 100ms;
    --duration-short: 150ms;
    --duration-medium: 200ms;
}

[data-theme="dark"] {
    --tiger-bg: #1a1a18;
    --tiger-surface: #252523;
    --tiger-text: #e8e6e3;
    --tiger-muted: #8a8a86;
    --tiger-accent: #7dba8f;
    --tiger-accent-hover: #6aab7e;
    --tiger-border: #3a3a37;

    --severity-1: #3a6b38;
    --severity-2: #5a6b30;
    --severity-3: #7a6b20;
    --severity-4: #8a5a18;
    --severity-5: #8a4010;

    /* Dark mode for new components */
    .app-header-brand {
        color: var(--tiger-text);
    }
    .chip {
        color: var(--tiger-text);
        border-color: var(--tiger-border);
    }
    .btn-secondary {
        color: var(--tiger-text);
        border-color: var(--tiger-border);
    }
    .landing-subtitle {
        color: var(--tiger-muted);
    }
    .auth-card {
        background: var(--tiger-surface);
        border-color: var(--tiger-border);
    }
    input,
    textarea,
    select {
        background: var(--tiger-bg);
        border-color: var(--tiger-border);
        color: var(--tiger-text);
    }
    input.edit-name,
    input.edit-name:focus,
    input.edit-metric-name,
    input.edit-metric-name:focus,
    input.edit-option-label,
    input.edit-option-label:focus {
        background: none;
        border: none;
        border-bottom: 2px solid transparent;
    }
}

body {
    font-family:
        "Instrument Sans",
        -apple-system,
        sans-serif;
    font-size: 16px;
    line-height: 1.5;
    background: var(--tiger-bg);
    color: var(--tiger-text);
}

/* ---- Global overrides (DESIGN.md scale) ---- */
h1 {
    font-size: var(--text-title);
    font-weight: var(--weight-bold);
}
h2 {
    font-size: var(--text-section);
    font-weight: var(--weight-semibold);
}
h3 {
    font-size: var(--text-sub);
    font-weight: var(--weight-semibold);
}
h4 {
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
}

a {
    color: var(--tiger-accent);
}
a:hover {
    color: var(--tiger-accent-hover);
}

main {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 var(--space-md);
    overflow-x: hidden;
}

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

/* ---- App Header ---- */
.app-header {
    padding: var(--space-sm) var(--space-md);
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.app-header-brand {
    font-family: "Instrument Sans", sans-serif;
    font-weight: var(--weight-bold);
    font-size: var(--text-sub);
    text-decoration: none;
    color: var(--tiger-text);
}

.app-header-nav {
    display: flex;
    gap: var(--space-md);
    align-items: center;
}

.app-header-nav a {
    font-size: var(--text-small);
    font-weight: var(--weight-medium);
    color: var(--tiger-muted);
    text-decoration: none;
    transition: color var(--duration-short);
}

.app-header-nav a:hover,
.app-header-nav a.active {
    color: var(--tiger-accent);
}

.app-header-nav .btn-outline {
    padding: var(--space-xs) var(--space-md);
    border: 2px solid var(--tiger-border);
    border-radius: var(--radius-full);
    font-size: var(--text-small);
    font-weight: var(--weight-medium);
    color: var(--tiger-muted);
    background: none;
    cursor: pointer;
    transition: all var(--duration-short);
    text-decoration: none;
}

.app-header-nav .btn-outline:hover {
    border-color: var(--tiger-accent);
    color: var(--tiger-accent);
}

/* ---- Minimal Chrome Header ---- */
.app-header-minimal {
    padding: var(--space-sm) var(--space-md);
    max-width: 800px;
    margin: 0 auto;
}

.app-header-minimal a {
    color: var(--tiger-muted);
    text-decoration: none;
    font-size: var(--text-small);
}

.app-header-minimal a:hover {
    color: var(--tiger-accent);
}

/* ---- Desktop nav links (hidden on mobile) ---- */
.desktop-nav {
    display: none;
}

@media (min-width: 768px) {
    .desktop-nav {
        display: inline;
    }
}

/* ---- Bottom Navigation (mobile) ---- */
.bottom-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--tiger-surface);
    border-top: 1px solid var(--tiger-border);
    height: 56px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--tiger-muted);
    font-size: 11px;
    font-weight: 500;
    gap: 2px;
    transition: color var(--duration-short);
}

.bottom-nav-item.active {
    color: var(--tiger-accent);
}

.bottom-nav-icon {
    font-size: 20px;
    line-height: 1;
}

@media (min-width: 768px) {
    .bottom-nav {
        display: none;
    }
}

/* Add padding to body so content isn't hidden behind bottom nav on mobile */
@media (max-width: 767px) {
    body.has-bottom-nav {
        padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + 16px);
    }

    body.has-bottom-nav > header {
        display: none;
    }

    body.has-bottom-nav > main {
        padding-top: 0;
    }
}

/* ---- Chip (unified pill component) ---- */
.chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    padding: 0;
    border: none;
    margin-bottom: var(--space-md);
}

.chip {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-md);
    border: 2px solid var(--tiger-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: var(--text-small);
    font-weight: var(--weight-regular);
    transition: all var(--duration-short);
    margin: 0;
    background: none;
    user-select: none;
    color: var(--tiger-muted);
    font-family: inherit;
    min-height: 44px;
}

.chip:hover {
    border-color: var(--tiger-accent);
    color: var(--tiger-accent);
}

.chip:has(input:checked) {
    background: var(--tiger-accent);
    color: white;
    border-color: var(--tiger-accent);
}

.chip span {
    text-transform: capitalize;
}

/* ---- Button variants ---- */
a.btn-primary,
button.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs) var(--space-lg);
    background: var(--tiger-accent);
    color: var(--tiger-surface);
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    font-family: inherit;
    min-height: 44px;
    transition: background var(--duration-short);
    text-decoration: none;
}

a.btn-primary:hover,
button.btn-primary:hover {
    background: var(--tiger-accent-hover);
    color: var(--tiger-surface);
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs) var(--space-lg);
    background: none;
    color: var(--tiger-text);
    border: 2px solid var(--tiger-border);
    border-radius: var(--radius-full);
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    font-family: inherit;
    min-height: 44px;
    transition: all var(--duration-short);
    text-decoration: none;
}

.btn-secondary:hover {
    border-color: var(--tiger-accent);
    color: var(--tiger-accent);
}

.btn-ghost {
    display: inline-flex;
    align-items: center;
    padding: var(--space-xs) var(--space-lg);
    background: none;
    color: var(--tiger-accent);
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--text-body);
    font-weight: var(--weight-medium);
    cursor: pointer;
    font-family: inherit;
    transition: opacity var(--duration-short);
    text-decoration: none;
}

/* ---- Tracker sections ---- */
.tracker-section {
    margin-bottom: var(--space-lg);
    scroll-margin-top: 72px;
}

.tracker-heading {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: var(--text-sub);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 1px solid var(--tiger-border);
}

.tracker-metrics {
    margin-bottom: var(--space-lg);
}

.tracker-icon {
    margin-right: var(--space-xs);
}

/* Kebab / context menu */
.kebab-menu {
    position: relative;
}

.kebab-trigger {
    background: none;
    border: none;
    color: var(--tiger-muted);
    cursor: pointer;
    padding: var(--space-xs);
    font-size: var(--text-sub);
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color var(--duration-short);
    line-height: 1;
}

.kebab-trigger:hover,
.kebab-trigger:focus {
    color: var(--tiger-accent);
    outline: none;
}

.kebab-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--tiger-surface);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    z-index: 100;
    min-width: 150px;
    padding: var(--space-xs) 0;
}

.kebab-menu:focus-within .kebab-dropdown {
    display: block;
}

.kebab-item {
    width: 100%;
    padding: var(--space-xs) var(--space-md);
    background: none;
    border: none;
    color: var(--tiger-text);
    text-decoration: none;
    text-align: left;
    cursor: pointer;
    font-size: var(--text-small);
    font-family: inherit;
    min-height: 36px;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    transition: background var(--duration-short);
}

.kebab-item:hover {
    background: var(--tiger-bg);
}

.kebab-item-danger {
    color: var(--tiger-error);
}

.kebab-icon {
    width: 1em;
    text-align: center;
    flex-shrink: 0;
}

.kebab-dropdown .inline-form {
    margin: 0;
}

.metric-label {
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
    color: var(--tiger-muted);
    margin-bottom: var(--space-sm);
    text-decoration: none;
    display: block;
}

a.metric-label:hover {
    color: var(--tiger-accent);
}

.metric-group {
    margin-bottom: var(--space-xl);
}

/* ---- Landing page ---- */
.landing-hero {
    text-align: center;
    padding: var(--space-3xl) 0;
}

.landing-hero h1 {
    font-size: var(--text-hero);
    font-weight: var(--weight-bold);
}

.landing-subtitle {
    color: var(--tiger-muted);
    font-size: var(--text-sub);
    margin-bottom: var(--space-xl);
}

.landing-cta {
    display: flex;
    gap: var(--space-md);
    justify-content: center;
}

/* ---- Calendar nav ---- */
.calendar-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.calendar-nav h4 {
    flex: 1;
    text-align: center;
    line-height: 1.3;
}

.calendar-month,
.calendar-year {
    display: block;
}

.calendar-year {
    font-size: var(--text-micro);
    font-weight: var(--weight-regular);
    color: var(--tiger-muted);
}

/* ---- Inline form ---- */
.inline-form {
    display: inline;
}

/* ---- Auth card ---- */
.auth-card {
    max-width: 400px;
    margin: var(--space-2xl) auto;
    padding: var(--space-xl);
    background: var(--tiger-surface);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-md);
}

.auth-card h2 {
    margin-bottom: var(--space-lg);
}

.auth-card form {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
}

/* Auth form inputs use base form styles — no overrides needed */

.auth-card .auth-footer {
    text-align: center;
    margin-top: var(--space-md);
    font-size: var(--text-small);
    color: var(--tiger-muted);
}

/* ---- Empty stats state ---- */
.stats-empty {
    text-align: center;
    padding: var(--space-2xl) 0;
}

.stats-empty p {
    color: var(--tiger-muted);
}

.stats-empty .stats-empty-title {
    font-size: var(--text-sub);
}

.stats-empty .stats-empty-hint {
    font-size: var(--text-small);
    margin-top: var(--space-xs);
}

.stats-empty .btn-primary {
    margin-top: var(--space-lg);
}

/* ---- Save toast ---- */
#save-toast {
    position: fixed;
    bottom: calc(56px + 56px + env(safe-area-inset-bottom, 0px) + var(--space-md));
    left: 50%;
    transform: translateX(-50%);
    z-index: 50;
    pointer-events: none;
    text-align: center;
}

@keyframes toast-in {
    0%   { opacity: 0; transform: translateY(8px); }
    100% { opacity: 1; transform: translateY(0); }
}

@keyframes toast-fade-out {
    0%   { opacity: 1; transform: translateY(0); }
    70%  { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-4px); }
}

@keyframes toast-in-out {
    0%   { opacity: 0; transform: translateY(8px); }
    15%  { opacity: 1; transform: translateY(0); }
    75%  { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-4px); }
}

#save-toast .save-pending,
#save-toast .save-ok {
    display: inline-block;
    min-width: 7em;
    text-align: center;
    background: var(--tiger-surface);
    border: 1px solid var(--tiger-border);
    font-size: var(--text-caption);
    padding: var(--space-2xs) var(--space-sm);
    border-radius: var(--radius-full);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

#save-toast .save-pending {
    color: var(--tiger-text-muted);
    animation: toast-in 0.15s ease-out forwards;
}

#save-toast .save-ok {
    color: var(--tiger-accent);
    animation: toast-fade-out 1s ease-in-out forwards;
}

#save-toast .save-error {
    display: inline-block;
    background: var(--tiger-surface);
    border: 1px solid var(--tiger-error);
    color: var(--tiger-error);
    font-size: var(--text-caption);
    padding: var(--space-2xs) var(--space-sm);
    border-radius: var(--radius-full);
    animation: toast-in-out 2s ease-in-out forwards;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ---- Connection error overlay ---- */
#connection-error {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--tiger-bg);
    opacity: 0;
    animation: overlay-in var(--duration-medium) ease-out forwards;
}

#connection-error.dismissing {
    animation: overlay-out var(--duration-medium) ease-in forwards;
}

#connection-error .connection-error-card {
    text-align: center;
    background: var(--tiger-surface);
    border-radius: var(--radius-lg);
    padding: var(--space-xl) var(--space-2xl);
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
    max-width: 280px;
}

#connection-error .connection-error-heading {
    font-size: var(--text-sub);
    font-weight: var(--weight-semibold);
    color: var(--tiger-text);
    margin-bottom: var(--space-xs);
}

#connection-error .connection-error-sub {
    font-size: var(--text-small);
    color: var(--tiger-muted);
    margin-bottom: var(--space-lg);
}

.retry-dots {
    display: flex;
    gap: var(--space-xs);
    justify-content: center;
}

.retry-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--tiger-muted);
    animation: retry-pulse 1.5s ease-in-out infinite;
}

.retry-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.retry-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes retry-pulse {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

@keyframes overlay-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes overlay-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ---- Severity selector ---- */
.severity-selector {
    display: flex;
    gap: var(--space-xs);
    padding: 0;
    border: none;
    margin-bottom: var(--space-md);
}

.severity-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    border-radius: var(--radius-full);
    cursor: pointer;
    font-weight: var(--weight-bold);
    font-size: var(--text-sub);
    border: 2px solid transparent;
    transition: transform var(--duration-micro);
    padding: var(--space-xs) var(--space-sm);
    margin: 0;
    line-height: 1;
    text-transform: capitalize;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.severity-btn input {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.severity-btn.selected {
    transform: scale(1.1);
    border: 2px solid var(--tiger-text);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* ---- Calendar ---- */
.calendar-table {
    table-layout: fixed;
    width: 100%;
}

.calendar-table th {
    text-align: center;
    font-size: var(--text-micro);
    padding: var(--space-2xs);
}

.calendar-day {
    text-align: center;
    padding: var(--space-xs) var(--space-2xs);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition:
        background var(--duration-short),
        transform var(--duration-micro);
    font-size: var(--text-small);
}

.calendar-day:hover {
    transform: scale(1.08);
    outline: 2px solid var(--tiger-accent);
}

.calendar-day.future {
    cursor: default;
    opacity: 0.35;
}

.calendar-day.future:hover {
    transform: none;
    outline: none;
}

/* ---- Confirmation card ---- */
.confirmation {
    text-align: center;
    background: var(--severity-1);
    border: none;
}

/* ---- Error messages ---- */
.error {
    color: var(--severity-5);
    font-weight: bold;
}

/* ---- Date slide transitions ---- */
@keyframes slide-out-left {
    to { opacity: 0; transform: translateX(-80px); }
}
@keyframes slide-out-right {
    to { opacity: 0; transform: translateX(80px); }
}
@keyframes slide-in-left {
    from { opacity: 0; transform: translateX(60px); }
}
@keyframes slide-in-right {
    from { opacity: 0; transform: translateX(-60px); }
}

#page-content.slide-out-left {
    animation: slide-out-left var(--duration-short) ease-in forwards;
}
#page-content.slide-out-right {
    animation: slide-out-right var(--duration-short) ease-in forwards;
}
#page-content.slide-in-left {
    animation: slide-in-left var(--duration-short) ease-out forwards;
}
#page-content.slide-in-right {
    animation: slide-in-right var(--duration-short) ease-out forwards;
}

/* ---- Date navigation ---- */
.date-nav {
    position: sticky;
    top: 0;
    z-index: 99;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--tiger-surface);
    border-bottom: 1px solid var(--tiger-border);
    height: 56px;
    padding: 0;
    margin: 0 calc(-1 * var(--space-md));
    margin-bottom: var(--space-md);
}

.date-nav-arrow,
.date-nav-arrow-placeholder {
    flex: 0 0 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    background: none;
    border: none;
    color: var(--tiger-muted);
    font-size: var(--text-caption);
    cursor: pointer;
    transition: color var(--duration-short);
}

.date-nav-arrow:hover {
    color: var(--tiger-accent);
}

.date-nav-arrow-placeholder {
    cursor: default;
}

button.form-date {
    flex: 1;
    color: var(--tiger-muted);
    background: none;
    border: none;
    padding: 0;
    cursor: pointer;
    font-family: inherit;
    text-align: center;
    line-height: 1.3;
}

.form-date-weekday {
    display: block;
    font-size: 10px;
}

.form-date-day {
    display: block;
    font-size: var(--text-micro);
}

.form-date-relative {
    display: block;
    font-size: 10px;
}

@media (min-width: 768px) {
    .date-nav {
        top: 0;
    }
}

button.form-date:hover {
    color: var(--tiger-accent);
    border-bottom-color: var(--tiger-accent);
}

/* ---- Date picker modal ---- */
dialog.date-picker-modal {
    border: none;
    border-radius: var(--radius-md);
    max-width: 360px;
    width: calc(100% - var(--space-xl));
    padding: var(--space-lg);
    background: var(--tiger-surface);
    color: var(--tiger-text);
    font-family: inherit;
    margin: auto;
}

dialog.date-picker-modal::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.date-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.date-picker-header h3 {
    font-size: var(--text-sub);
    font-weight: var(--weight-semibold);
    margin: 0;
}

.date-picker-close {
    background: none;
    border: none;
    color: var(--tiger-muted);
    font-size: var(--text-body);
    cursor: pointer;
    padding: var(--space-2xs);
}

.date-picker-close:hover {
    color: var(--tiger-text);
}

.calendar-day.selected {
    outline: 2px solid var(--tiger-accent);
    outline-offset: -2px;
    font-weight: var(--weight-semibold);
}

.calendar-day.today {
    outline: 2px solid var(--tiger-muted);
    outline-offset: -2px;
}

.calendar-day.today.selected {
    outline: 2px solid var(--tiger-accent);
    outline-offset: -2px;
}

.calendar-day.has-data {
    background: var(--tiger-border);
}

/* ---- Add more link ---- */
.add-more {
    text-align: center;
    padding: var(--space-lg) 0;
    border-top: 1px solid var(--tiger-border);
    margin-top: var(--space-lg);
}

.add-more a {
    color: var(--tiger-accent);
    font-size: var(--text-body);
    font-weight: var(--weight-medium);
    text-decoration: none;
}

.add-more a:hover {
    text-decoration: underline;
}

/* ---- Stats Panel ---- */

.period-nav-label {
    flex: 1;
    text-align: center;
    font-size: var(--text-body);
    font-weight: 500;
    color: var(--tiger-muted);
}

.stat-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
}

.stat-card {
    text-align: center;
    padding: var(--space-sm) var(--space-xs);
    border-radius: var(--radius-md);
    background: var(--tiger-surface);
    border: 1px solid var(--tiger-border);
}

.stat-value {
    font-size: var(--text-section);
    font-weight: var(--weight-bold);
    color: var(--tiger-accent);
}

.stat-mono {
    font-family: "Geist Mono", monospace;
    font-variant-numeric: tabular-nums;
}

.stat-desc {
    font-size: var(--text-micro);
    color: var(--tiger-muted);
    margin-top: var(--space-2xs);
}

/* Comparison card */
.stat-comparison-row {
    display: flex;
    align-items: baseline;
    justify-content: center;
    gap: var(--space-xs);
}

.stat-comparison-arrow {
    font-size: var(--text-body);
    font-weight: var(--weight-bold);
}

.stat-value-prev {
    font-size: var(--text-small);
    color: var(--tiger-muted);
}

.stat-improved {
    color: var(--tiger-success, #5b9a6d);
}

.stat-regressed {
    color: var(--tiger-error, #c44040);
}

.stat-neutral {
    color: var(--tiger-muted);
}

.stat-delta {
    font-family: "Geist Mono", monospace;
    font-size: var(--text-micro);
    font-weight: var(--weight-semibold);
    margin-top: var(--space-2xs);
}

/* Sparkline */
.sparkline {
    display: flex;
    align-items: flex-end;
    height: 48px;
    gap: 1px;
    margin-bottom: var(--space-md);
    padding: var(--space-xs) 0;
}

.spark-bar {
    flex: 1;
    background: var(--tiger-accent);
    border-radius: 1px 1px 0 0;
    min-width: 2px;
    min-height: 2px;
    transition: height var(--duration-short) ease;
}

.spark-bar.spark-empty {
    background: var(--tiger-border);
    min-height: 1px;
    height: 1px;
    align-self: flex-end;
    opacity: 0.4;
}

/* Frequency bars section */
.stat-frequency {
    margin-bottom: var(--space-sm);
}

/* Metric stats section spacing */
.metric-stats-section {
    margin-bottom: var(--space-lg);
    scroll-margin-top: 72px;
}

.stat-bar-row {
    display: grid;
    grid-template-columns: 120px 1fr 40px;
    align-items: center;
    gap: var(--space-xs);
    margin-bottom: var(--space-2xs);
}

.stat-label {
    font-size: var(--text-caption);
    text-transform: capitalize;
    text-align: right;
}

.stat-bar-track {
    height: var(--space-md);
    background: var(--tiger-border);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

.stat-bar-fill {
    height: 100%;
    background: var(--tiger-accent);
    border-radius: var(--radius-sm);
    transition: width var(--duration-medium) ease;
    min-width: 2px;
}

.stat-count {
    font-family: "Geist Mono", monospace;
    font-size: var(--text-caption);
    font-weight: var(--weight-semibold);
    text-align: left;
}

.tracker-stats-section {
    margin-bottom: var(--space-xl);
}

.tracker-stats-title {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    font-size: var(--text-sub);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-xs);
    border-bottom: 2px solid var(--tiger-border);
}

.tracker-stats-icon {
    font-size: var(--text-section);
}

#stats section {
    margin-bottom: var(--space-lg);
}

#stats h4 {
    margin-bottom: var(--space-sm);
    border-bottom: 1px solid var(--tiger-border);
    padding-bottom: var(--space-2xs);
}

.stat-last-entry {
    font-style: italic;
}

.text-entries {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.text-entry {
    display: flex;
    gap: var(--space-sm);
    align-items: baseline;
    padding: var(--space-xs) var(--space-sm);
    background: var(--tiger-surface);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-md);
}

.text-entry-date {
    font-size: var(--text-micro);
    color: var(--tiger-muted);
    white-space: nowrap;
    min-width: 80px;
}

.text-entry-value {
    font-size: var(--text-small);
}

/* ---- Settings Panel ---- */
#settings h3 {
    margin-bottom: var(--space-2xs);
}

#settings > p {
    color: var(--tiger-muted);
    font-size: var(--text-small);
    margin-bottom: var(--space-lg);
}

.settings-section {
    margin-bottom: var(--space-xl);
}

.settings-section h4 {
    margin-bottom: var(--space-xs);
    border-bottom: 1px solid var(--tiger-border);
    padding-bottom: var(--space-2xs);
}

.theme-options {
    display: flex;
    gap: var(--space-xs);
}

.theme-option {
    flex: 1;
    padding: var(--space-xs) var(--space-md);
    background: var(--tiger-surface);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-full);
    color: var(--tiger-muted);
    font-size: var(--text-small);
    font-weight: var(--weight-medium);
    cursor: pointer;
    transition: background var(--duration-short), color var(--duration-short);
}

.theme-option:hover {
    background: var(--tiger-bg);
    color: var(--tiger-text);
}

.theme-option.active {
    background: var(--tiger-accent);
    border-color: var(--tiger-accent);
    color: #fff;
}

.settings-section.danger-zone {
    margin-top: var(--space-2xl);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--tiger-error);
}

.settings-section.danger-zone h4 {
    color: var(--tiger-error);
    border-bottom: none;
    padding-bottom: 0;
}

.settings-section.danger-zone p {
    color: var(--tiger-muted);
    font-size: var(--text-body);
    margin-bottom: var(--space-md);
}

dialog.confirm-modal .input {
    width: 100%;
    margin-bottom: var(--space-md);
}

.settings-section .chip-group {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
}

.toggle-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
}

.remove-btn {
    background: none;
    border: none;
    color: var(--tiger-muted);
    cursor: pointer;
    padding: var(--space-2xs);
    font-size: var(--text-small);
    line-height: 1;
    border-radius: var(--radius-full);
    margin: 0;
    transition: color var(--duration-short);
}

.remove-btn:hover {
    color: var(--tiger-error);
}

.add-custom-form {
    display: flex;
    gap: var(--space-xs);
    align-items: center;
    margin-top: var(--space-xs);
}

.add-custom-form input[type="text"] {
    max-width: 250px;
    margin-bottom: 0;
    padding: var(--space-2xs) var(--space-sm);
    font-size: var(--text-caption);
}

.add-custom-form button {
    flex: 1;
    padding: var(--space-2xs) var(--space-md);
    margin-bottom: 0;
    font-size: var(--text-caption);
    white-space: nowrap;
}

/* ---- Template Browser ---- */
.category-pills {
    display: flex;
    gap: var(--space-xs);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-2xs);
}

.template-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--tiger-border);
    text-decoration: none;
    color: inherit;
    cursor: pointer;
}

.template-icon {
    font-size: var(--text-section);
    width: 2.25rem; /* icon container, off-scale */
    text-align: center;
    flex-shrink: 0;
}

.template-info {
    flex: 1;
    min-width: 0;
}

.template-name {
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
}

.template-desc {
    font-size: var(--text-micro);
    color: var(--tiger-muted);
}

.template-metric-count {
    font-family: "Geist Mono", monospace;
    font-size: var(--text-micro);
}

.template-row:active {
    opacity: 0.7;
}

.template-custom {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    border-bottom: none;
    border: 2px dashed var(--tiger-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm);
    margin-top: var(--space-xs);
}

.template-empty {
    text-align: center;
    padding: var(--space-xl) 0;
    color: var(--tiger-muted);
}

.template-added {
    text-align: center;
    padding: var(--space-xl) 0;
}

.template-added a {
    color: var(--tiger-accent);
}

/* ---- Onboarding ---- */
.onboarding {
    max-width: 600px;
    margin: 0 auto;
}

.onboarding h1 {
    text-align: center;
    margin-bottom: var(--space-2xs);
}

.onboarding-subtitle {
    text-align: center;
    color: var(--tiger-muted);
    margin-bottom: var(--space-lg);
}

.onboarding-grid {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    margin-bottom: var(--space-lg);
}

.onboarding-card {
    display: flex;
    align-items: center;
    gap: var(--space-xs);
    padding: var(--space-xs) var(--space-md);
    border: 2px solid var(--tiger-border);
    border-radius: var(--radius-full);
    cursor: pointer;
    font-size: var(--text-small);
    transition: all var(--duration-short);
    user-select: none;
}

.onboarding-card:has(input:checked) {
    background: var(--tiger-accent);
    color: white;
    border-color: var(--tiger-accent);
}

.onboarding-card .template-icon {
    font-size: var(--text-sub);
    width: auto;
}

.onboarding-card .template-name {
    font-weight: var(--weight-semibold);
    font-size: var(--text-caption);
}

.onboarding-card .template-desc {
    display: none;
}

.onboarding-footer {
    position: sticky;
    bottom: 0;
    background: var(--tiger-bg);
    padding: var(--space-md) 0;
    border-top: 1px solid var(--tiger-border);
}

.btn-onboarding {
    width: 100%;
    padding: var(--space-sm);
    background: var(--tiger-accent);
    color: white;
    border: none;
    border-radius: var(--radius-full);
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    font-family: inherit;
    min-height: 44px;
    transition: background var(--duration-short);
}

.btn-onboarding:hover {
    background: var(--tiger-accent-hover);
}

/* ---- Confirmation modal ---- */
dialog.confirm-modal {
    border: none;
    border-radius: var(--radius-md);
    max-width: 400px;
    width: calc(100% - var(--space-xl));
    padding: var(--space-lg);
    background: var(--tiger-surface);
    color: var(--tiger-text);
    font-family: inherit;
    margin: auto;
}

dialog.confirm-modal::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

dialog.confirm-modal h3 {
    font-size: var(--text-section);
    font-weight: var(--weight-bold);
    margin-bottom: var(--space-sm);
}

dialog.confirm-modal p {
    font-size: var(--text-body);
    color: var(--tiger-muted);
    margin-bottom: var(--space-lg);
}

.modal-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xs) var(--space-lg);
    background: none;
    color: var(--tiger-error);
    border: 2px solid var(--tiger-error);
    border-radius: var(--radius-full);
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
    cursor: pointer;
    font-family: inherit;
    min-height: 44px;
    transition: all var(--duration-short);
}

.btn-danger:hover {
    background: var(--tiger-error);
    color: white;
}

/* ---- Tracker edit page ---- */
#tracker-edit,
#create-tracker {
    max-width: 100%;
    overflow-x: hidden;
    padding-bottom: calc(56px + env(safe-area-inset-bottom, 0) + var(--space-md));
}

.edit-header {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    margin-bottom: var(--space-sm);
    flex-wrap: wrap;
}

input.edit-name,
input.edit-name:focus {
    font-size: var(--text-section);
    font-weight: var(--weight-bold);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--tiger-text);
    font-family: inherit;
    flex: 1;
    min-width: 0;
    padding: var(--space-2xs) 0;
    transition: border-color var(--duration-short);
}

input.edit-name:hover {
    border-bottom-color: var(--tiger-border);
}

input.edit-name:focus {
    border-bottom-color: var(--tiger-accent);
}

.entry-count {
    font-family: var(--font-mono);
    font-size: var(--text-small);
    color: var(--tiger-muted);
    margin-bottom: var(--space-lg);
}

.sticky-save-bar {
    display: flex;
    justify-content: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--tiger-surface);
    border-top: 1px solid var(--tiger-border);
    height: 56px;
    padding: 0 var(--space-md);
    padding-bottom: env(safe-area-inset-bottom, 0);
    z-index: 100;
    align-items: center;
}

.sticky-save-bar .inline-form {
    flex: 1;
    display: flex;
}

.action-bar-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--tiger-muted);
    font-size: 11px;
    font-weight: 500;
    gap: 2px;
    cursor: pointer;
    transition: color var(--duration-short);
    font-family: inherit;
    padding: 0;
}

.action-bar-item:hover {
    color: var(--tiger-text);
}

.action-bar-icon {
    font-size: 20px;
    line-height: 1;
}

.action-bar-label {
    line-height: 1;
}

.action-save {
    color: var(--tiger-accent);
}

.action-save:hover {
    color: var(--tiger-accent-hover);
}

.action-delete:hover {
    color: var(--tiger-error);
}


.metric-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-sm);
}

input.edit-metric-name,
input.edit-metric-name:focus {
    font-size: var(--text-body);
    font-weight: var(--weight-semibold);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--tiger-text);
    font-family: inherit;
    padding: var(--space-2xs) 0;
    transition: border-color var(--duration-short);
    width: 100%;
    margin-bottom: 0;
}
input.edit-metric-name:hover {
    border-bottom-color: var(--tiger-border);
}
input.edit-metric-name:focus {
    border-bottom-color: var(--tiger-accent);
}

input.edit-option-label,
input.edit-option-label:focus {
    font-size: var(--text-small);
    font-weight: var(--weight-medium);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: none;
    color: var(--tiger-text);
    font-family: inherit;
    padding: var(--space-2xs) 0;
    transition: border-color var(--duration-short);
    width: auto;
    min-width: 60px;
    margin-bottom: 0;
    display: inline;
}
input.edit-option-label:hover {
    border-bottom-color: var(--tiger-border);
}
input.edit-option-label:focus {
    border-bottom-color: var(--tiger-accent);
}

input.edit-option-value {
    font-family: "Geist Mono", monospace;
    font-size: var(--text-micro);
    width: 48px;
    padding: var(--space-2xs) var(--space-2xs);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-sm);
    background: var(--tiger-surface);
    color: var(--tiger-muted);
    text-align: center;
    margin: 0 var(--space-2xs);
    flex-shrink: 0;
}
input.edit-option-value:focus {
    border-color: var(--tiger-accent);
    color: var(--tiger-text);
    outline: none;
}
input.edit-option-value::placeholder {
    color: var(--tiger-border);
}

/* ---- Counter display ---- */
.counter-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: var(--space-md) var(--space-sm);
    background: var(--tiger-surface);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.counter-value-row {
    display: flex;
    align-items: baseline;
    gap: var(--space-xs);
}

.counter-number {
    font-family: "Geist Mono", monospace;
    font-variant-numeric: tabular-nums;
    font-size: var(--text-title);
    font-weight: var(--weight-bold);
    color: var(--tiger-accent);
}

.counter-label {
    font-size: var(--text-body);
    font-weight: var(--weight-medium);
    color: var(--tiger-text);
    text-transform: capitalize;
}

.counter-unit {
    font-size: var(--text-small);
    color: var(--tiger-muted);
}

/* Accumulator chips — same shape as regular chips */
.accumulator-chip {
    position: relative;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.accumulator-chip.active {
    background: var(--tiger-accent);
    color: white;
    border-color: var(--tiger-accent);
}

.chip-badge {
    position: absolute;
    top: -6px;
    right: -6px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: var(--tiger-error);
    color: white;
    font-family: "Geist Mono", monospace;
    font-size: 11px;
    font-weight: var(--weight-bold);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    box-sizing: border-box;
}

.timeline-chip .chip-badge {
    top: -5px;
    right: -5px;
    min-width: 14px;
    height: 14px;
    padding: 0 3px;
    border-radius: 7px;
    font-size: 9px;
}

/* ---- Photo metric ---- */

/* Multi-photo: thumbnail strip */
.photo-strip {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.photo-thumb {
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    flex-shrink: 0;
}

.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-add {
    width: 80px;
    height: 80px;
    border: 2px dashed var(--tiger-border);
    border-radius: 8px;
    background: transparent;
    color: var(--tiger-muted);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: border-color 150ms ease;
}

.photo-add:hover {
    border-color: var(--tiger-accent);
    color: var(--tiger-accent);
}

.photo-add:disabled,
.photo-hero-add:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Single-photo: full-width hero */
.photo-hero {
    width: 100%;
}

.photo-hero-img {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
}

.photo-hero-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.photo-hero-add {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px dashed var(--tiger-border);
    border-radius: 8px;
    background: transparent;
    color: var(--tiger-muted);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 150ms ease;
}

.photo-hero-add:hover {
    border-color: var(--tiger-accent);
    color: var(--tiger-accent);
}

/* Compact add button — shown when hero has no photo yet */
.photo-compact-add {
    width: 80px;
    height: 80px;
    border: 2px dashed var(--tiger-border);
    border-radius: 8px;
    background: transparent;
    color: var(--tiger-muted);
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 150ms ease;
}

.photo-compact-add:hover {
    border-color: var(--tiger-accent);
    color: var(--tiger-accent);
}

/* Shared: skeleton loader */
.photo-skeleton {
    background: var(--tiger-border);
    animation: photo-pulse 1.2s ease-in-out infinite;
}

.photo-hero .photo-skeleton {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
}

.photo-strip .photo-skeleton {
    width: 80px;
    height: 80px;
}

@keyframes photo-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Photo config in tracker edit */
.photo-config {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
}

.photo-config-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--tiger-muted);
}

.photo-config select {
    padding: 4px 8px;
    border: 1px solid var(--tiger-border);
    border-radius: 4px;
    background: var(--tiger-surface);
    color: var(--tiger-text);
    font-size: 14px;
}

/* Photo lightbox */
.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 200ms ease;
}

.photo-lightbox.open {
    opacity: 1;
}

.photo-lightbox-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--tiger-surface);
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    z-index: 1;
}

.photo-lightbox-img {
    max-width: 90vw;
    max-height: 80vh;
    object-fit: contain;
    border-radius: 4px;
}

.photo-lightbox-delete {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--tiger-error);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: var(--weight-medium);
    cursor: pointer;
    opacity: 0.9;
    transition: opacity 150ms ease;
}

.photo-lightbox-delete:hover {
    opacity: 1;
}

/* Timeline photo block (label above, photos below) */
.timeline-photo-block {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 4px 0 12px;
}

/* Timeline photo hero (single-photo metrics) */
.timeline-photo-hero {
    width: 100%;
    aspect-ratio: 1 / 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
}

.timeline-photo-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Timeline photo thumbs (multi-photo metrics) */
.timeline-photo-strip {
    display: flex;
    gap: 4px;
    align-items: center;
}

.timeline-photo-thumb {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    flex-shrink: 0;
}

.timeline-photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.timeline-photo-more {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background: var(--tiger-border);
    color: var(--tiger-muted);
    font-size: 12px;
    font-weight: var(--weight-semibold);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ---- Display mode controls ---- */
.display-mode-controls {
    margin-bottom: var(--space-sm);
    padding: var(--space-sm);
    background: var(--tiger-bg);
    border-radius: var(--radius-md);
}

.mode-row {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-xs);
}

.mode-row:last-child {
    margin-bottom: 0;
}

.mode-row-label {
    font-size: var(--text-micro);
    color: var(--tiger-muted);
    min-width: 50px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: var(--weight-semibold);
}

.mode-pills {
    display: flex;
    gap: var(--space-2xs);
}

.mode-pill {
    font-size: var(--text-micro);
    font-weight: var(--weight-medium);
    padding: var(--space-2xs) var(--space-sm);
    border: 1px solid var(--tiger-border);
    border-radius: 9999px;
    background: transparent;
    color: var(--tiger-muted);
    cursor: pointer;
    transition: all var(--duration-short) ease;
}

.mode-pill.active {
    background: var(--tiger-accent);
    border-color: var(--tiger-accent);
    color: white;
}

.mode-unit-input {
    font-size: var(--text-small);
    padding: var(--space-2xs) var(--space-xs);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-sm);
    background: var(--tiger-surface);
    width: 80px;
}

.mode-unit-input:focus {
    border-color: var(--tiger-accent);
    outline: none;
}

/* ---- Slide toggle ---- */
.slide-toggle {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    margin-bottom: var(--space-sm);
    cursor: pointer;
    user-select: none;
}
.slide-toggle-label {
    font-size: var(--text-small);
    color: var(--tiger-muted);
}
.slide-toggle-track {
    position: relative;
    width: 44px;
    height: 24px;
    background: var(--tiger-border);
    border-radius: var(--radius-full);
    transition: background var(--duration-short) ease;
    flex-shrink: 0;
}
.slide-toggle-track.on {
    background: var(--tiger-accent);
}
.slide-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: var(--tiger-surface);
    border-radius: 50%;
    transition: transform var(--duration-micro) ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}
.slide-toggle-track.on .slide-toggle-thumb {
    transform: translateX(20px);
}

.sortable-ghost {
    opacity: 0.4;
}
.drag-handle {
    cursor: grab;
    color: var(--tiger-muted);
    padding: var(--space-2xs);
    user-select: none;
    font-size: var(--text-body);
    line-height: 1;
    flex-shrink: 0;
}
.drag-handle:active {
    cursor: grabbing;
}

.collapse-btn {
    color: var(--tiger-muted);
    padding: var(--space-2xs);
    font-size: var(--text-small);
    transition: transform var(--duration-short), color var(--duration-short);
    flex-shrink: 0;
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.collapse-btn:hover {
    color: var(--tiger-text);
}
.metric-section.collapsed .collapse-btn {
    transform: rotate(180deg);
}
.metric-section.collapsed .metric-body {
    display: none;
}

.metric-header .remove-btn {
    min-width: 44px;
    min-height: 44px;
}

.metric-type-badge {
    display: inline-block;
    font-size: var(--text-small);
    color: var(--tiger-muted);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-full);
    padding: var(--space-2xs) var(--space-sm);
}

.empty-state {
    color: var(--tiger-muted);
    font-size: var(--text-small);
    font-style: italic;
    margin-bottom: var(--space-sm);
}

/* ---- Emoji picker ---- */
.emoji-picker {
    position: relative;
}

.emoji-trigger {
    font-size: var(--text-section);
    background: none;
    border: 2px solid var(--tiger-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    padding: var(--space-xs);
    line-height: 1;
    min-width: 48px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color var(--duration-short);
    flex-shrink: 0;
}

.emoji-trigger:hover {
    border-color: var(--tiger-accent);
}

.emoji-modal {
    border: none;
    border-radius: var(--radius-md);
    max-width: 360px;
    width: calc(100% - var(--space-xl));
    padding: var(--space-lg);
    background: var(--tiger-surface);
    color: var(--tiger-text);
    font-family: inherit;
    margin: auto;
    max-height: 80vh;
    overflow-y: auto;
}

.emoji-modal::backdrop {
    background: rgba(0, 0, 0, 0.4);
}

.emoji-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-md);
}

.emoji-modal-header h3 {
    font-size: var(--text-sub);
    font-weight: var(--weight-semibold);
    margin: 0;
}

.emoji-quick-picks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: var(--space-2xs);
}

.emoji-search-wrap {
    margin-bottom: var(--space-sm);
}

.emoji-search-input {
    width: 100%;
    padding: var(--space-xs) var(--space-sm);
    border: 2px solid var(--tiger-border);
    border-radius: var(--radius-md);
    font-size: var(--text-body);
    font-family: inherit;
    background: var(--tiger-bg);
    color: var(--tiger-text);
    transition: border-color var(--duration-short);
}

.emoji-search-input:focus {
    outline: none;
    border-color: var(--tiger-accent);
}

.emoji-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
    gap: var(--space-2xs);
    margin-bottom: var(--space-sm);
}

.emoji-results:empty {
    display: none;
}

.emoji-no-results {
    font-size: var(--text-small);
    color: var(--tiger-muted);
    text-align: center;
    padding: var(--space-sm);
    grid-column: 1 / -1;
}

.emoji-option {
    font-size: var(--text-section);
    background: none;
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    cursor: pointer;
    padding: var(--space-2xs);
    transition: all var(--duration-short);
    line-height: 1;
    min-width: 44px;
    min-height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-option:hover {
    background: var(--tiger-bg);
}

.emoji-option.selected {
    border-color: var(--tiger-accent);
    background: var(--tiger-bg);
}

/* ---- Custom tracker creation ---- */
#create-tracker h2 {
    font-size: var(--text-section);
    font-weight: var(--weight-bold);
    margin-bottom: var(--space-lg);
}

#create-tracker h3 {
    font-size: var(--text-sub);
    font-weight: var(--weight-semibold);
    margin-bottom: var(--space-md);
}

.metric-row {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    padding: var(--space-sm);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
    align-items: center;
}

.metric-row input[type="text"] {
    flex: 1;
    min-width: 150px;
}

.metric-row select {
    max-width: 180px;
}

.remove-metric {
    color: var(--tiger-muted);
    font-size: var(--text-sub);
}

.form-actions {
    margin-top: var(--space-lg);
}

/* ---- Activity / Change Log ---- */
#activity {
    display: flex;
    flex-direction: column;
    gap: var(--space-lg);
}

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-xs);
    align-items: center;
}

.filter-bar select,
.filter-bar input[type="date"] {
    width: auto;
    flex: 1;
    min-width: 120px;
    margin-bottom: 0;
    font-size: var(--text-small);
}

.change-date-heading {
    font-size: var(--text-small);
    font-weight: var(--weight-semibold);
    color: var(--tiger-muted);
    padding: var(--space-sm) 0 var(--space-2xs);
    border-bottom: 1px solid var(--tiger-border);
    margin-top: var(--space-sm);
}

.change-date-heading:first-child {
    margin-top: 0;
}

.change-row {
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--tiger-border);
}

.change-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-xs);
}

.change-meta {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    font-size: var(--text-small);
    color: var(--tiger-muted);
}

.change-separator {
    color: var(--tiger-border);
}

.change-date {
    font-size: var(--text-small);
    color: var(--tiger-muted);
    margin-right: var(--space-xs);
}

.change-time {
    font-family: 'Geist Mono', monospace;
    font-size: var(--text-micro);
    color: var(--tiger-muted);
    white-space: nowrap;
}

.change-desc {
    margin-top: var(--space-2xs);
    font-size: var(--text-body);
}

.pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md) 0;
}

.page-info {
    font-family: 'Geist Mono', monospace;
    font-size: var(--text-small);
    color: var(--tiger-muted);
}

.activity-empty {
    text-align: center;
    padding: var(--space-2xl) 0;
}

.activity-empty p {
    color: var(--tiger-muted);
}

.activity-empty .activity-empty-title {
    font-size: var(--text-sub);
}

.activity-empty .activity-empty-hint {
    font-size: var(--text-small);
    margin-top: var(--space-xs);
}

.activity-empty .btn-primary {
    margin-top: var(--space-lg);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .severity-btn {
        font-size: var(--text-body);
    }

    .stat-bar-row {
        grid-template-columns: 90px 1fr 35px;
    }
}

@media (min-width: 768px) {
    #save-toast {
        bottom: var(--space-lg);
    }
}

/* ---- Timeline ---- */

.timeline-container {
    position: relative;
    padding: var(--space-md) 0 var(--space-2xl);
}

/* Connector: centered dot */
.timeline-connector {
    display: flex;
    justify-content: center;
    padding: var(--space-xs) 0;
}

.timeline-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--tiger-accent);
    flex-shrink: 0;
}

/* Vertical line segment (used in cards, gaps) */
.timeline-line {
    width: 1px;
    height: var(--space-md);
    background: var(--tiger-muted);
    margin: 0 auto;
}

/* Card */
.timeline-card {
    margin-bottom: 0;
}

.timeline-card-date {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    padding: var(--space-2xs) 0;
    min-height: 44px;
    justify-content: center;
}

.timeline-age {
    font-size: 11px;
    font-weight: 400;
    color: var(--tiger-muted);
    line-height: 1.2;
}

.timeline-card-date:hover .timeline-date {
    color: var(--tiger-accent);
}

.timeline-weekday {
    font-size: 12px;
    font-weight: 400;
    color: var(--tiger-muted);
    line-height: 1.2;
}

.timeline-date {
    font-size: 16px;
    font-weight: 600;
    color: var(--tiger-text);
    line-height: 1.3;
    padding: var(--space-2xs) 0;
    transition: color var(--duration-short);
}

.timeline-card-body {
    background: var(--tiger-surface);
    border: 1px solid var(--tiger-border);
    border-radius: var(--radius-md);
    padding: var(--space-sm) var(--space-md);
}

.timeline-tracker {
    display: block;
    text-decoration: none;
    color: inherit;
}

.timeline-tracker:hover {
    opacity: 0.7;
}

.timeline-tracker + .timeline-tracker {
    border-top: 1px solid var(--tiger-border);
    padding-top: var(--space-sm);
    margin-top: var(--space-sm);
}

.timeline-tracker-header {
    display: flex;
    align-items: center;
    gap: var(--space-2xs);
    font-size: 14px;
    font-weight: 500;
    color: var(--tiger-text);
    margin-bottom: var(--space-xs);
}

.timeline-metrics {
    display: grid;
    grid-template-columns: 5rem 1fr;
    gap: var(--space-xs) var(--space-3xl);
    font-size: 14px;
}

.timeline-metric {
    display: contents;
}

.timeline-metric-label {
    color: var(--tiger-muted);
    font-size: 13px;
    font-weight: 400;
    white-space: nowrap;
}

.timeline-metric-value {
    color: var(--tiger-text);
    font-size: 13px;
    text-align: left;
}

.timeline-text-value {
    white-space: pre-line;
    word-break: break-word;
    text-align: left;
}

.timeline-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2xs);
    justify-content: flex-start;
}

.timeline-chip {
    position: relative;
    display: inline-block;
    padding: 2px var(--space-xs);
    border-radius: var(--radius-full);
    font-size: 12px;
    white-space: nowrap;
    background: var(--tiger-accent);
    color: white;
}

/* Gap indicator: line, text, line (all centered) */
.timeline-gap {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.timeline-gap-text {
    font-size: 13px;
    color: var(--tiger-muted);
    padding: var(--space-2xs) 0;
}

.timeline-loading {
    text-align: center;
    padding: var(--space-lg) 0;
    color: var(--tiger-muted);
    font-size: 14px;
}

.timeline-empty {
    text-align: center;
    padding: var(--space-3xl) var(--space-md);
}

.timeline-empty-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--tiger-text);
    margin: 0 0 var(--space-xs);
}

.timeline-empty-hint {
    font-size: 16px;
    color: var(--tiger-muted);
    margin: 0 0 var(--space-lg);
}

@media (prefers-reduced-motion: reduce) {
    #page-content.slide-out-left,
    #page-content.slide-out-right,
    #page-content.slide-in-left,
    #page-content.slide-in-right {
        animation: none;
    }

    #save-toast .save-pending,
    #save-toast .save-ok,
    #save-toast .save-error {
        animation: none;
    }
}
