:root {
    color-scheme: light dark;
    --color-bg: #f4f5f7;
    --color-surface: #ffffff;
    --color-text: #1c1e21;
    --color-muted: #6b7280;
    --color-border: #d7dade;
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-error: #dc2626;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-bg);
    color: var(--color-text);
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app-shell {
    width: 100%;
    display: flex;
    justify-content: center;
    padding: 1rem;
}

.app-loading {
    color: var(--color-muted);
}

.card {
    width: 100%;
    max-width: 24rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 2rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.card h1 {
    margin-top: 0;
    font-size: 1.5rem;
}

form label {
    display: block;
    margin-top: 1rem;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    font-weight: 600;
}

form input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    font-size: 1rem;
}

form input:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

form select {
    width: 100%;
    padding: 0.5rem 2.25rem 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    background-color: var(--color-surface);
    color: var(--color-text);
    font-size: 1rem;
    font-family: inherit;
    appearance: none;
    background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%236b7280'><path d='M5.5 7.5l4.5 4.5 4.5-4.5z'/></svg>");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

form select:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

button {
    margin-top: 1.5rem;
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: none;
    border-radius: 0.5rem;
    background: var(--color-primary);
    color: #fff;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

button:hover {
    background: var(--color-primary-hover);
}

button:disabled {
    opacity: 0.6;
    cursor: progress;
}

.form-error {
    background: #fee2e2;
    color: var(--color-error);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.field-error {
    margin: 0.25rem 0 0;
    color: var(--color-error);
    font-size: 0.8rem;
    min-height: 1em;
}

.app-layout {
    width: 100%;
    max-width: 72rem;
    min-height: calc(100vh - 2rem);
    display: flex;
    align-items: stretch;
    gap: 1.5rem;
}

.sidebar {
    width: 15rem;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    padding: 1.5rem 1rem;
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.1rem;
    padding: 0 0.5rem 1.5rem;
}

.sidebar-nav {
    list-style: none;
    margin: 0;
    padding: 0;
    flex: 1;
}

.sidebar-nav-item + .sidebar-nav-item {
    margin-top: 0.25rem;
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0.75rem;
    border-radius: 0.5rem;
    color: var(--color-text);
    text-decoration: none;
    font-size: 0.95rem;
}

.sidebar-nav-link i {
    width: 1.25rem;
    text-align: center;
    color: var(--color-muted);
}

.sidebar-nav-link:hover {
    background: var(--color-bg);
}

.sidebar-nav-link.is-active {
    background: var(--color-primary);
    color: #fff;
}

.sidebar-nav-link.is-active i {
    color: #fff;
}

.sidebar-start-training {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    padding: 0.8rem 1rem;
    border: none;
    border-radius: 0.6rem;
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    font-weight: 700;
    font-size: 1rem;
    box-shadow: 0 4px 14px rgba(234, 88, 12, 0.4);
}

.sidebar-start-training i {
    font-size: 1.1rem;
}

.sidebar-start-training:hover {
    background: linear-gradient(135deg, #fb923c, #ea580c);
    box-shadow: 0 6px 18px rgba(234, 88, 12, 0.5);
}

.sidebar-logout {
    margin-top: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.sidebar-logout:hover {
    background: var(--color-bg);
}

.app-content {
    flex: 1;
    min-width: 0;
}

.app-content .card {
    max-width: none;
}

form .field-row {
    display: flex;
    gap: 1rem;
}

form .field-row[hidden] {
    display: none;
}

form .field-row > div {
    flex: 1;
}

form select[multiple] {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    font-size: 1rem;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    margin-top: 0.5rem;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    margin: 0;
    font-weight: 400;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

.exercise-equipment-row {
    align-items: center;
}

.exercise-equipment-quantity {
    width: 4rem;
    padding: 0.25rem 0.4rem;
}

.exercise-equipment-quantity:disabled {
    opacity: 0.5;
}

.form-hint {
    margin: 0.25rem 0 0;
    color: var(--color-muted);
    font-size: 0.8rem;
}

.form-success {
    background: #dcfce7;
    color: #15803d;
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.food-item-list-card,
.equipment-list-card,
.exercise-list-card,
.exercise-plan-active-card,
.exercise-plan-list-card {
    margin-top: 1.5rem;
}

.food-item-list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
}

.food-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.75rem 0;
    border-top: 1px solid var(--color-border);
}

.food-item-row:first-child {
    border-top: none;
}

.food-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.food-item-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.food-item-actions button {
    margin-top: 0;
    width: auto;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

.food-item-edit,
.meal-edit,
.equipment-edit {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.food-item-edit:hover,
.meal-edit:hover,
.equipment-edit:hover {
    background: var(--color-bg);
}

.food-item-photo-section {
    margin-top: 1rem;
}

.form-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.form-actions button {
    flex: 1;
}

.food-item-photos {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.6rem;
}

.food-item-photo {
    position: relative;
    flex-shrink: 0;
}

.food-item-thumb {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 0.5rem;
    object-fit: cover;
    display: block;
    border: 1px solid var(--color-border);
    cursor: zoom-in;
}

.food-item-photo-delete {
    position: absolute;
    top: -0.4rem;
    right: -0.4rem;
    width: 1.5rem;
    height: 1.5rem;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: var(--color-error);
    color: #fff;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.food-item-photo-delete:hover {
    background: #b91c1c;
}

.food-item-photo-add,
.button-like {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    font-size: 0.85rem;
    cursor: pointer;
    background: var(--color-bg);
    color: var(--color-text);
    white-space: nowrap;
}

.food-item-photo-add {
    width: 4.5rem;
    height: 4.5rem;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0;
    text-align: center;
    border-style: dashed;
    font-size: 0.7rem;
    white-space: normal;
}

.food-item-photo-add i {
    font-size: 1rem;
}

.button-like:hover,
.food-item-photo-add:hover {
    background: var(--color-border);
}

.food-item-photo-add.is-disabled {
    pointer-events: none;
    opacity: 0.6;
}

.food-item-photo--uploading {
    width: 4.5rem;
    height: 4.5rem;
    border-radius: 0.5rem;
    border: 1px dashed var(--color-border);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--color-primary);
    font-size: 1.25rem;
    background: var(--color-bg);
}

.food-item-photo-error {
    margin: 0;
    text-align: left;
}

.exercise-type-switch {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.exercise-type-label {
    font-weight: 600;
    color: var(--color-muted);
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.exercise-type-label.is-active {
    color: var(--color-text);
}

.switch {
    position: relative;
    display: inline-block;
    width: 3rem;
    height: 1.65rem;
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch .slider {
    position: absolute;
    inset: 0;
    background: var(--color-border);
    border-radius: 999px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.switch .slider::before {
    content: "";
    position: absolute;
    height: 1.25rem;
    width: 1.25rem;
    left: 0.2rem;
    bottom: 0.2rem;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s ease;
}

.switch input:checked + .slider {
    background: var(--color-primary);
}

.switch input:checked + .slider::before {
    transform: translateX(1.35rem);
}

.exercise-type-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-left: 0.5rem;
    padding: 0.1rem 0.5rem;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 600;
    vertical-align: middle;
}

.exercise-type-badge--strength {
    background: #ede9fe;
    color: #6d28d9;
}

.exercise-type-badge--cardio {
    background: #fee2e2;
    color: #b91c1c;
}

.modal-overlay[hidden] {
    display: none;
}

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    z-index: 1000;
}

.modal-content {
    position: relative;
    background: var(--color-surface);
    border-radius: 0.75rem;
    max-width: min(90vw, 40rem);
    max-height: 85vh;
    overflow: auto;
}

.modal-content--image {
    padding: 0;
    line-height: 0;
}

.modal-content--image img {
    display: block;
    max-width: 100%;
    max-height: 85vh;
    border-radius: 0.75rem;
}

.modal-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 2rem;
    height: 2rem;
    margin: 0;
    padding: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 1.25rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.modal-content--confirm {
    padding: 1.5rem;
    width: 100%;
    max-width: 24rem;
}

.modal-content--confirm p {
    margin: 0 0 1.5rem;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

.modal-actions button {
    margin-top: 0;
    width: auto;
    padding: 0.5rem 1rem;
}

.modal-content--training-plans {
    padding: 1.5rem;
    width: 100%;
    max-width: 28rem;
}

.modal-content--training-plans h2 {
    margin: 0;
}

.training-plan-select-list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
    max-height: 60vh;
    overflow-y: auto;
}

.training-plan-select-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    font-size: 0.95rem;
    font-weight: 600;
}

.training-plan-select-item + .training-plan-select-item {
    margin-top: 0.5rem;
}

.training-plan-select-item:hover {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

.training-session-exercise {
    padding: 1rem 0;
    border-top: 1px solid var(--color-border);
}

.training-session-exercise:first-child {
    padding-top: 0;
    border-top: none;
}

.training-session-exercise h3 {
    margin: 0 0 0.25rem;
    font-size: 1.05rem;
}

.training-session-equipment {
    margin: 0 0 0.5rem;
}

.button-secondary {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.button-secondary:hover {
    background: var(--color-bg);
}

.button-danger {
    background: var(--color-error);
}

.button-danger:hover {
    background: #b91c1c;
}

.meal-list-card,
.meal-active-card {
    margin-top: 1.5rem;
}

.meal-item-list {
    list-style: none;
    margin: 1rem 0 0;
    padding: 0;
}

.meal-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    border-top: 1px solid var(--color-border);
}

.meal-item-row:first-child {
    border-top: none;
}

.meal-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.1rem;
}

.meal-item-name {
    font-weight: 600;
}

.meal-item-delete {
    margin-top: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-error);
    display: flex;
    align-items: center;
    justify-content: center;
}

.meal-item-delete:hover {
    background: #fee2e2;
}

.exercise-plan-item-delete {
    margin-top: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--color-error);
    display: flex;
    align-items: center;
    justify-content: center;
}

.exercise-plan-item-delete:hover {
    background: #fee2e2;
}

.meal-totals {
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--color-bg);
    border-radius: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.meal-photo-section {
    margin-top: 1rem;
}

.meal-add-item-chooser {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.meal-add-item-chooser button {
    margin-top: 0;
    flex: 1;
}

.meal-item-form {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--color-border);
}

@media (max-width: 40rem) {
    .app-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
    }

    .sidebar-brand {
        padding: 0 1rem 0 0;
    }

    .sidebar-nav {
        display: flex;
        flex: none;
    }

    .sidebar-logout {
        margin-top: 0;
        margin-left: auto;
    }
}

@media (prefers-color-scheme: dark) {
    :root {
        --color-bg: #16181c;
        --color-surface: #1f2226;
        --color-text: #f2f3f5;
        --color-muted: #9aa0a6;
        --color-border: #33373d;
    }

    .form-success {
        background: #14532d;
        color: #bbf7d0;
    }
}

.calendar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.calendar-title {
    text-align: center;
}

.calendar-title h1 {
    margin: 0;
    font-size: 2rem;
}

.calendar-title p {
    margin: 0.25rem 0 0;
    font-size: 1.25rem;
    color: var(--color-muted);
}

.calendar-nav {
    width: 3.5rem;
    height: 3.5rem;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.calendar-week {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 0.75rem;
}

.calendar-day {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    min-height: 16rem;
    padding: 1rem 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
}

.calendar-day.is-today {
    border-color: var(--color-text);
    box-shadow: 0 0 0 1px var(--color-text);
}

.calendar-day-name {
    font-size: 1rem;
    font-weight: 600;
}

.calendar-day-number {
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1.1;
}

.calendar-day-month {
    font-size: 0.875rem;
    color: var(--color-muted);
}

@media (max-width: 900px) {
    .calendar-week {
        grid-template-columns: 1fr;
    }

    .calendar-day {
        min-height: 0;
        flex-direction: row;
        justify-content: space-between;
    }
}

.sidebar-footer {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.sidebar-footer .sidebar-logout {
    flex: 1;
    margin-top: 0;
}

.sidebar-profile {
    flex-shrink: 0;
    width: auto;
    margin: 0;
    padding: 0;
    background: transparent;
    border-radius: 50%;
    line-height: 0;
}

.sidebar-profile:hover {
    background: transparent;
}

.sidebar-profile.is-active .sidebar-profile-avatar {
    box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 4px var(--color-primary);
}

.sidebar-profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    object-fit: cover;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
}

.profile-header {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    margin-bottom: 1rem;
}

.profile-header h1 {
    margin: 0;
}

.profile-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 5rem;
    height: 5rem;
    border-radius: 50%;
    object-fit: cover;
    color: #fff;
    font-size: 1.75rem;
    font-weight: 700;
    flex-shrink: 0;
}

.profile-email {
    margin: 0.25rem 0 0;
    color: var(--color-muted);
}

.profile-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 2rem 0 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--color-border);
    font-size: 1.1rem;
}

.profile-section-title i {
    color: var(--color-primary);
}

.profile form .field-row > * {
    flex: 1;
    min-width: 0;
}

.calorie-summary {
    display: flex;
    align-items: stretch;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.calorie-operator {
    align-self: center;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-muted);
}

.calorie-tile {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    padding: 1.25rem 0.75rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    text-align: center;
}

.calorie-tile-label {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-muted);
}

.calorie-tile-value {
    font-size: 2.25rem;
    font-weight: 700;
    line-height: 1.1;
}

.calorie-tile-unit {
    font-size: 0.85rem;
    color: var(--color-muted);
}

.calorie-tile input {
    width: 100%;
    max-width: 9rem;
    text-align: center;
    font-size: 1.75rem;
    font-weight: 700;
}

.calorie-tile--result {
    background: linear-gradient(135deg, #f97316, #ea580c);
    border-color: transparent;
    color: #fff;
    box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35);
}

.calorie-tile--result .calorie-tile-label,
.calorie-tile--result .calorie-tile-unit {
    color: rgba(255, 255, 255, 0.85);
}

@media (max-width: 40rem) {
    .sidebar-footer {
        margin-top: 0;
        margin-left: auto;
    }

    .calorie-summary {
        flex-direction: column;
    }

    .profile form .field-row {
        flex-direction: column;
        gap: 0;
    }
}

button.calendar-day {
    margin: 0;
    width: auto;
    color: var(--color-text);
    font: inherit;
    cursor: pointer;
}

button.calendar-day:hover {
    background: var(--color-surface);
    border-color: var(--color-primary);
}

.calendar-day-balance {
    margin-top: auto;
    padding: 0.25rem 0.6rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
    background: var(--color-muted);
}

.calendar-day-balance--deficit,
.day-balance[data-level="deficit"] .day-balance-item--result { background: #16a34a; }
.calendar-day-balance--neutral,
.day-balance[data-level="neutral"] .day-balance-item--result { background: #f59e0b; }
.calendar-day-balance--surplus,
.day-balance[data-level="surplus"] .day-balance-item--result { background: #dc2626; }

.day-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.day-header h1 {
    margin: 0;
    font-size: 1.75rem;
}

.day-back {
    width: auto;
    margin: 0;
    flex-shrink: 0;
}

.day-columns {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
}

.day-panel {
    padding: 1.25rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
}

.day-panel-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.5rem;
    font-size: 1.15rem;
}

.day-panel-title i {
    color: var(--color-primary);
}

.day-panel .field-row > * {
    flex: 1;
    min-width: 0;
}

.day-exercise {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.6rem;
}

.day-exercise h3 {
    margin: 0 0 0.25rem;
    font-size: 1rem;
}

.day-balance {
    margin-top: 1.5rem;
}

.day-balance-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.75rem;
}

.day-balance-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.2rem;
    padding: 1.25rem 0.5rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    text-align: center;
}

.day-balance-item--result {
    background: var(--color-muted);
    border-color: transparent;
    color: #fff;
}

.day-balance-label {
    font-size: 0.85rem;
    font-weight: 600;
    opacity: 0.8;
}

.day-balance-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1.1;
}

.day-balance-sub {
    font-size: 0.85rem;
    opacity: 0.8;
}

@media (max-width: 900px) {
    .day-columns {
        grid-template-columns: 1fr;
    }

    .day-balance-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.day-plan {
    margin-top: 1rem;
    padding: 0.75rem 1rem 1rem;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
}

.day-plan-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

.day-plan-header h3 {
    margin: 0;
    font-size: 1.05rem;
}

button.day-plan-remove {
    width: auto;
    margin: 0;
    padding: 0.3rem 0.6rem;
}

.day-plan .day-exercise {
    background: var(--color-bg);
}

.body-today {
    margin-top: 0;
}

.body-today h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

.food-log {
    margin-top: 1.5rem;
}

.food-log h2 {
    margin-top: 0;
    font-size: 1.15rem;
}

.food-log-totals {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.food-log-total {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.6rem 0.25rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    text-align: center;
}

.food-log-total-value {
    font-size: 1.1rem;
    font-weight: 700;
}

.food-log-total--kcal .food-log-total-value {
    font-size: 1.4rem;
}

.food-log-total-label {
    color: var(--color-muted);
    font-size: 0.75rem;
}

.food-log-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
}

.food-log-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.food-log-info {
    display: flex;
    flex-direction: column;
}

button.calendar-day.is-future,
button.calendar-day.is-future:hover {
    opacity: 0.4;
    cursor: not-allowed;
    background: var(--color-bg);
}

.food-log-total[data-level] {
    color: #fff;
    border-color: transparent;
}

.food-log-total[data-level] .food-log-total-label {
    color: inherit;
}

.food-log-total[data-level="good"] { background: #16a34a; }

.food-log-total[data-level="warn"] { background: #f59e0b; }

.food-log-total[data-level="bad"] { background: #dc2626; }

form textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    background-color: var(--color-surface);
    color: var(--color-text);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
}

form textarea:focus {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

form .field-row > div {
    min-width: 0;
}

.food-log-row button.food-log-delete {
    flex-shrink: 0;
    width: 2.75rem;
    min-height: 2.75rem;
    margin: 0;
    padding: 0;
}

.food-log-info {
    min-width: 0;
}

.sidebar-menu-toggle {
    display: none;
}

/* Smartphone: nichts darf seitlich überlaufen, alles muss gut antippbar sein. */
@media (max-width: 40rem) {
    .app-shell {
        padding: 0.75rem;
    }

    .app-layout {
        gap: 0.75rem;
    }

    .sidebar {
        padding: 0.75rem;
        gap: 0.5rem;
    }

    /* Kopfzeile: Name | Profil | Menü-Knopf. Der Rest klappt auf. */
    .sidebar-footer {
        display: contents;
    }

    .sidebar-brand {
        order: 1;
        flex: 1;
        min-width: 0;
        padding: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .sidebar-profile {
        order: 2;
    }

    .sidebar-menu-toggle {
        order: 3;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 0.5rem;
        width: auto;
        margin: 0;
        padding: 0 1rem;
        min-height: 2.75rem;
        background: transparent;
        color: var(--color-text);
        border: 1px solid var(--color-border);
    }

    .sidebar-menu-toggle:hover,
    .sidebar.is-menu-open .sidebar-menu-toggle {
        background: var(--color-bg);
    }

    .sidebar-start-training {
        order: 4;
        width: 100%;
        margin-top: 0.25rem;
    }

    .sidebar-nav,
    .sidebar-footer .sidebar-logout {
        display: none;
    }

    .sidebar.is-menu-open .sidebar-nav {
        order: 5;
        display: flex;
        flex: 1 1 100%;
        flex-wrap: wrap;
        gap: 0.35rem;
        min-width: 0;
    }

    .sidebar.is-menu-open .sidebar-footer .sidebar-logout {
        order: 6;
        display: flex;
        flex: 1 1 100%;
        width: 100%;
        min-height: 2.75rem;
        margin: 0.25rem 0 0;
    }

    .sidebar-nav-item + .sidebar-nav-item {
        margin-top: 0;
    }

    .sidebar-nav-link {
        min-height: 2.75rem;
        padding: 0.5rem 0.75rem;
        gap: 0.5rem;
        border: 1px solid var(--color-border);
    }

    .sidebar-nav-link.is-active {
        border-color: var(--color-primary);
    }

    form .field-row {
        align-items: flex-end;
    }

    .profile form .field-row {
        align-items: stretch;
    }

    .sidebar-profile-avatar {
        width: 2.75rem;
        height: 2.75rem;
    }

    .app-content .card {
        padding: 1.25rem 1rem;
    }

    button:not(.sidebar-profile),
    form input,
    form select {
        min-height: 2.75rem;
    }

    .modal-overlay {
        padding: 0.75rem;
    }

    .modal-content {
        max-height: calc(100dvh - 1.5rem);
    }

    .modal-close {
        width: 2.75rem;
        height: 2.75rem;
    }

    .modal-content--training-plans,
    .modal-content--confirm {
        padding: 1.25rem 1rem;
    }

    .modal-content--training-plans h2,
    .modal-content--confirm p {
        padding-right: 2.5rem;
    }

    .calendar-header {
        gap: 0.5rem;
    }

    .calendar-title {
        flex: 1;
        min-width: 0;
    }

    .calendar-title h1 {
        font-size: 1.4rem;
    }

    .calendar-title p {
        font-size: 1rem;
    }

    .calendar-nav {
        width: 2.75rem;
        height: 2.75rem;
        padding: 0;
        margin: 0;
    }

    button.calendar-day {
        min-height: 3.5rem;
        flex-wrap: wrap;
    }

    .day-header {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    .day-header h1 {
        flex: 1 1 100%;
        font-size: 1.35rem;
    }

    .day-panel {
        padding: 1rem;
    }

    .training-session-exercise .field-row,
    .day-panel .field-row {
        flex-wrap: wrap;
        align-items: flex-end;
    }

    .training-session-exercise .field-row > div,
    .day-panel .field-row > * {
        flex: 1 1 8rem;
        min-width: 0;
    }

    .form-actions {
        flex-direction: column;
        align-items: stretch;
        margin-top: 1.5rem;
    }

    .form-actions button {
        flex: none;
        margin-top: 0;
    }

    .food-item-row {
        flex-wrap: wrap;
    }

    .food-item-info {
        flex: 1 1 100%;
    }

    .food-item-actions {
        flex-wrap: wrap;
        width: 100%;
    }

    .food-item-actions .meal-preparation-open {
        flex: 1 1 100%;
    }

    .food-item-actions button {
        flex: 1;
        justify-content: center;
        min-height: 2.75rem;
    }
}

@media (max-width: 23rem) {
    .sidebar-menu-toggle {
        width: 2.75rem;
        padding: 0;
    }

    .sidebar-menu-toggle span {
        display: none;
    }
}

/* Zubereitung einer Mahlzeit */
.meal-preparation-open {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.meal-preparation-open:hover {
    background: var(--color-bg);
}

button.meal-prep-back {
    width: auto;
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
}

.meal-prep-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.75rem 0 0;
    font-size: 1.5rem;
}

.meal-prep-title i {
    color: var(--color-primary);
}

.meal-prep-meal {
    margin: 0.25rem 0 1rem;
    color: var(--color-muted);
    font-size: 1.1rem;
}

.meal-prep-subtitle {
    margin: 1.5rem 0 0.5rem;
    font-size: 1.1rem;
}

.meal-prep-steps {
    list-style: none;
    counter-reset: prep-step;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.meal-prep-step-read,
.meal-prep-step {
    counter-increment: prep-step;
    position: relative;
    padding: 0.85rem 1rem 0.85rem 3.25rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
}

.meal-prep-step-read::before,
.meal-prep-step::before {
    content: counter(prep-step);
    position: absolute;
    top: 0.85rem;
    left: 0.85rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    font-size: 0.9rem;
    font-weight: 700;
}

.meal-prep-step-ingredient {
    display: inline-block;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: rgba(37, 99, 235, 0.14);
    color: var(--color-primary);
    font-size: 0.8rem;
    font-weight: 700;
}

.meal-prep-step-ingredient.is-missing {
    background: transparent;
    border: 1px dashed var(--color-muted);
    color: var(--color-muted);
}

.meal-prep-step-text {
    margin: 0.4rem 0 0;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.meal-prep-step-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.meal-prep-step-actions button {
    width: auto;
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.meal-prep-step .meal-prep-step-edit,
.meal-prep-step .meal-prep-step-cancel {
    background: transparent;
    color: var(--color-text);
    border: 1px solid var(--color-border);
}

.meal-prep-ingredients {
    list-style: none;
    margin: 0;
    padding: 0;
}

.meal-prep-ingredients li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.5rem 0;
    border-bottom: 1px solid var(--color-border);
}

.meal-prep-add-form {
    margin-top: 1.5rem;
    padding: 1rem;
    border: 1px dashed var(--color-border);
    border-radius: 0.75rem;
}

.meal-prep-add-title {
    margin: 0;
    font-size: 1.05rem;
}

.meal-prep-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.meal-prep-actions button,
.meal-prep-cook {
    width: auto;
    min-height: 2.75rem;
    margin: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 1rem;
    border-radius: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
}

.meal-prep-cook {
    background: linear-gradient(135deg, #f97316, #ea580c);
    color: #fff;
    text-decoration: none;
    box-shadow: 0 4px 14px rgba(234, 88, 12, 0.35);
}

.meal-prep-cook:hover {
    background: linear-gradient(135deg, #fb923c, #ea580c);
}

/* Eigenständige Koch-Ansicht (neuer Tab) */
.cook-page {
    width: 100%;
    max-width: 42rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.cook-page .card {
    max-width: none;
}

.cook-header h1 {
    margin: 0;
    font-size: 1.75rem;
}

.cook-progress {
    margin: 0.5rem 0 0;
    color: var(--color-muted);
    font-weight: 600;
}

.cook-progress.is-complete {
    color: #16a34a;
}

.cook-page h2 {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0 0 0.75rem;
    font-size: 1.2rem;
}

.cook-ingredients {
    list-style: none;
    margin: 0;
    padding: 0;
}

.cook-ingredients li {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    padding: 0.6rem 0;
    border-bottom: 1px solid var(--color-border);
}

.cook-ingredients li:last-child {
    border-bottom: none;
}

.cook-steps {
    list-style: none;
    counter-reset: cook-step;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.cook-step {
    counter-increment: cook-step;
}

.cook-step-label {
    display: flex;
    align-items: flex-start;
    gap: 0.9rem;
    padding: 1rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    font-size: 1.05rem;
    cursor: pointer;
}

.cook-step-check {
    flex: none;
    width: 1.75rem;
    height: 1.75rem;
    margin: 0.1rem 0 0;
    accent-color: #16a34a;
    cursor: pointer;
}

.cook-step-body {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    min-width: 0;
}

.cook-step-ingredient {
    color: var(--color-primary);
    font-size: 0.85rem;
    font-weight: 700;
}

.cook-step-ingredient::before {
    content: counter(cook-step) ". ";
}

.cook-step-ingredient.is-missing {
    color: var(--color-muted);
}

.cook-step-text {
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.cook-step.is-done .cook-step-label {
    border-color: #16a34a;
    opacity: 0.6;
}

.cook-step.is-done .cook-step-text {
    text-decoration: line-through;
}

.cook-reset {
    margin-top: 1.25rem;
}

@media (max-width: 40rem) {
    .meal-prep-actions > * {
        flex: 1 1 100%;
    }

    .meal-prep-step-actions button {
        flex: 1;
        justify-content: center;
        min-height: 2.75rem;
    }

    .meal-prep-add-form {
        padding: 0.75rem;
    }

    .cook-header h1 {
        font-size: 1.5rem;
    }

    .cook-page .card {
        padding: 1.25rem 1rem;
    }

    .cook-step-label {
        padding: 0.85rem;
        gap: 0.75rem;
    }
}

/* History: Statistiken und Diagramme */
.history {
    --viz-1: #2a78d6;
    --viz-2: #eb6834;
    --viz-3: #1baf7a;
    --viz-good: #0ca30c;
    --viz-warning: #fab219;
    --viz-critical: #d03b3b;
    --viz-on: #0b0b0b;
    --viz-on-critical: #ffffff;
    --viz-surface: var(--color-surface);
    --viz-ink: var(--color-text);
    --viz-ink-2: #52514e;
    --viz-axis-text: #6b6a66;
    --viz-grid: #e1e0d9;
    --viz-baseline: #b3b2a8;
    --viz-good-text: #006300;
    --viz-bad-text: #b91c1c;
    --viz-vacation: var(--vacation);
}

@media (prefers-color-scheme: dark) {
    .history {
        --viz-1: #3987e5;
        --viz-2: #d95926;
        --viz-3: #199e70;
        --viz-ink-2: #c3c2b7;
        --viz-axis-text: #a6a59c;
        --viz-grid: #2c2c2a;
        --viz-baseline: #4a4a46;
        --viz-good-text: #34c734;
        --viz-bad-text: #ef6b6b;
    }
}

.history-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1rem;
}

.history-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    font-size: 1.5rem;
}

.history-title i {
    color: var(--color-primary);
}

.history-ranges,
.history-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.history-chips {
    margin: 0.75rem 0;
}

button.history-chip {
    width: auto;
    margin: 0;
    padding: 0.4rem 0.9rem;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: transparent;
    color: var(--color-text);
    font-size: 0.9rem;
    font-weight: 600;
}

button.history-chip:hover {
    background: var(--color-bg);
}

button.history-chip[aria-pressed="true"] {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: #fff;
}

.history-period {
    margin: 0.5rem 0 0;
    color: var(--color-muted);
    font-size: 0.85rem;
}

.history-tabs {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 0.25rem;
    margin: 1.25rem 0 0;
    padding: 0.25rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
}

button.history-tab {
    width: auto;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.55rem 0.5rem;
    border-radius: 0.55rem;
    background: transparent;
    color: var(--viz-ink-2);
    font-size: 0.95rem;
    font-weight: 600;
}

button.history-tab:hover {
    background: var(--color-surface);
}

button.history-tab[aria-selected="true"] {
    background: var(--color-surface);
    color: var(--color-text);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18), 0 0 0 1px var(--color-primary);
}

.history-body {
    margin-top: 1rem;
    transition: opacity 0.15s;
}

.history-body.is-loading {
    opacity: 0.55;
}

.history-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 2rem 1rem;
    color: var(--color-muted);
    text-align: center;
}

.history-empty i {
    font-size: 2rem;
}

.history-empty p,
.history-note {
    margin: 0;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(10.5rem, 1fr));
    gap: 0.75rem;
}

@media (min-width: 40.01rem) {
    .stat-grid[data-count="6"] {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.stat-tile {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    padding: 0.85rem;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
}

.stat-tile-label {
    color: var(--viz-ink-2);
    font-size: 0.8rem;
    font-weight: 600;
}

.stat-tile-value {
    font-size: 1.4rem;
    font-weight: 700;
    line-height: 1.15;
    overflow-wrap: anywhere;
}

.stat-tile-unit {
    color: var(--viz-ink-2);
    font-size: 0.65em;
    font-weight: 600;
}

.stat-tile-sub {
    color: var(--color-muted);
    font-size: 0.8rem;
}

.stat-tile.is-good .stat-tile-value {
    color: var(--viz-good-text);
}

.stat-tile.is-bad .stat-tile-value {
    color: var(--viz-bad-text);
}

.stat-tile .fa-solid {
    font-size: 0.9em;
}

.chart-card {
    margin-top: 1.25rem;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
}

.chart-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.chart-card-title {
    margin: 0;
    font-size: 1.1rem;
}

.chart-card-sub {
    margin: 0.35rem 0 0;
    color: var(--color-muted);
    font-size: 0.85rem;
}

button.chart-table-toggle {
    width: auto;
    margin: 0;
    flex-shrink: 0;
    padding: 0.35rem 0.75rem;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    background: transparent;
    color: var(--color-text);
    font-size: 0.85rem;
}

button.chart-table-toggle:hover {
    background: var(--color-bg);
}

button.chart-table-toggle[aria-pressed="true"] {
    background: var(--color-bg);
    border-color: var(--color-primary);
}

.chart-view[hidden],
.chart-table-view[hidden] {
    display: none;
}

.chart-host {
    position: relative;
}

.chart-svg {
    display: block;
    width: 100%;
    max-width: 100%;
    touch-action: pan-y;
    user-select: none;
    -webkit-user-select: none;
}

.chart-host:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    border-radius: 0.25rem;
}

.viz-grid {
    stroke: var(--viz-grid);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.viz-baseline {
    stroke: var(--viz-baseline);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.viz-axis-text {
    fill: var(--viz-axis-text);
    font-size: 11px;
    font-variant-numeric: tabular-nums;
}

.viz-line {
    stroke-width: 2;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.viz-area {
    opacity: 0.1;
}

.viz-dot {
    stroke: var(--viz-surface);
    stroke-width: 2;
}

.viz-bar.is-hover {
    stroke: var(--viz-ink);
    stroke-width: 1;
}

.viz-ref {
    stroke: var(--viz-axis-text);
    stroke-width: 1;
    shape-rendering: crispEdges;
}

.viz-ref-text {
    fill: var(--viz-ink-2);
    font-size: 11px;
    font-weight: 600;
    paint-order: stroke;
    stroke: var(--viz-surface);
    stroke-width: 4px;
    stroke-linejoin: round;
}

.viz-end-label {
    fill: var(--viz-ink);
    font-size: 12px;
    font-weight: 700;
    paint-order: stroke;
    stroke: var(--viz-surface);
    stroke-width: 4px;
    stroke-linejoin: round;
}

.viz-crosshair {
    stroke: var(--viz-axis-text);
    stroke-width: 1;
}

.chart-tooltip {
    position: absolute;
    z-index: 5;
    padding: 0.5rem 0.65rem;
    background: var(--viz-surface);
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    font-size: 0.8rem;
    white-space: nowrap;
    pointer-events: none;
}

.chart-tooltip[hidden] {
    display: none;
}

.chart-tooltip-title {
    margin-bottom: 0.3rem;
    color: var(--viz-ink-2);
    font-weight: 600;
}

.chart-tooltip-row {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    line-height: 1.5;
}

.chart-tooltip-key {
    display: inline-block;
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.chart-tooltip-key.is-line {
    width: 14px;
    height: 3px;
}

.chart-tooltip-key:not([style]) {
    visibility: hidden;
}

.chart-tooltip-value {
    color: var(--viz-ink);
}

.chart-tooltip-label {
    color: var(--viz-ink-2);
}

.chart-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem 1rem;
    margin: 0.5rem 0;
    padding: 0;
    list-style: none;
}

.chart-legend-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
}

.chart-legend-key {
    display: inline-block;
    flex: none;
    width: 10px;
    height: 10px;
    border-radius: 2px;
}

.chart-legend-key.is-line {
    width: 14px;
    height: 3px;
}

.chart-legend-value {
    margin-left: 0.25rem;
}

.hbars {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 0.75rem;
}

.hbar-row {
    display: grid;
    grid-template-columns: minmax(5rem, 30%) minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.25rem 0.75rem;
}

.hbar-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.9rem;
}

.hbar-track {
    display: block;
    height: 14px;
}

.hbar-bar {
    display: block;
    height: 100%;
    border-radius: 0 4px 4px 0;
}

.hbar-value {
    font-size: 0.85rem;
    white-space: nowrap;
}

.stack {
    margin-top: 0.75rem;
}

.stack-bar {
    display: flex;
    gap: 2px;
    height: 32px;
}

.stack-segment {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 700;
}

.chart-table-wrap {
    max-height: 22rem;
    margin-top: 0.75rem;
    overflow: auto;
    border: 1px solid var(--color-border);
    border-radius: 0.5rem;
}

.chart-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    font-variant-numeric: tabular-nums;
}

.chart-table th,
.chart-table td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--color-border);
    text-align: right;
    white-space: nowrap;
}

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

.chart-table thead th {
    position: sticky;
    top: 0;
    background: var(--color-bg);
    font-weight: 700;
}

.chart-table tbody th {
    font-weight: 400;
}

@media (max-width: 40rem) {
    button.history-chip,
    button.chart-table-toggle {
        min-height: 2.75rem;
    }

    .history-tabs {
        gap: 0.15rem;
    }

    button.history-tab {
        flex-direction: column;
        gap: 0.2rem;
        padding: 0.45rem 0.15rem;
        font-size: 0.75rem;
    }

    button.history-tab i {
        font-size: 1rem;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .stat-tile-value {
        font-size: 1.1rem;
        white-space: nowrap;
    }

    .stat-tile .fa-solid {
        font-size: 0.8em;
    }

    .stat-tile {
        padding: 0.75rem;
    }

    .chart-card {
        padding: 0.75rem;
    }

    .hbar-row {
        grid-template-columns: minmax(0, 1fr) auto;
    }

    .hbar-track {
        grid-column: 1 / -1;
    }

    .hbar-value {
        grid-column: 2;
        grid-row: 1;
    }
}

/* Urlaub: Kalender-Markierung und Hinterlegung in der History */
:root {
    --vacation: #4a3aa7;
    --vacation-wash: rgba(74, 58, 167, 0.12);
}

@media (prefers-color-scheme: dark) {
    :root {
        --vacation: #9085e9;
        --vacation-wash: rgba(144, 133, 233, 0.2);
    }
}

.calendar-cell {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    min-width: 0;
}

.calendar-cell .calendar-day {
    flex: 1;
    width: 100%;
}

.calendar-cell.is-vacation .calendar-day {
    background: var(--vacation-wash);
    border-color: var(--vacation);
}

.calendar-day-vacation {
    margin-top: 0.25rem;
    padding: 0.2rem 0.6rem;
    border: 1px solid var(--vacation);
    border-radius: 999px;
    background: var(--color-surface);
    color: var(--vacation);
    font-size: 0.85rem;
    font-weight: 700;
    white-space: nowrap;
}

button.calendar-vacation-toggle {
    width: 100%;
    margin: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    border: 1px solid var(--color-border);
    border-radius: 0.6rem;
    background: transparent;
    color: var(--color-text);
    font-size: 0.8rem;
    font-weight: 600;
}

button.calendar-vacation-toggle:hover {
    background: var(--color-bg);
}

button.calendar-vacation-toggle[aria-pressed="true"] {
    background: var(--vacation-wash);
    border-color: var(--vacation);
    color: var(--vacation);
}

@media (max-width: 900px) {
    .calendar-cell {
        flex-direction: row;
        align-items: stretch;
    }

    button.calendar-vacation-toggle {
        flex: 0 0 3.5rem;
        width: 3.5rem;
        padding: 0;
    }

    button.calendar-vacation-toggle span {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip: rect(0 0 0 0);
        white-space: nowrap;
    }

    button.calendar-vacation-toggle i {
        font-size: 1.15rem;
    }
}

.viz-vacation-band {
    fill: var(--vacation-wash);
    pointer-events: none;
}

.chart-legend-key.is-band {
    border: 1px solid var(--vacation);
}

.chart-vacation-note i {
    color: var(--vacation);
}

/* Einstellungen: Passkeys und Passwort */
.settings {
    max-width: 46rem;
    margin-inline: auto;
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding-bottom: 1.25rem;
    border-bottom: 1px solid var(--color-border);
}

.settings-header h1 {
    margin: 0;
}

.settings-header button {
    width: auto;
    margin-top: 0;
    padding: 0.45rem 0.9rem;
    font-size: 0.9rem;
}

.settings .profile-section-title {
    margin: 1.75rem 0 0;
    padding: 0 0 0.75rem;
    border-bottom: none;
    font-size: 1.15rem;
}

.settings .profile-section-title i {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    background: color-mix(in srgb, var(--color-primary) 12%, transparent);
    font-size: 0.95rem;
}

.settings > .form-hint {
    margin: 0 0 0.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
}

.settings form {
    padding: 1rem 1.25rem 1.25rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-bg);
}

.settings form label:first-of-type {
    margin-top: 0;
}

.settings form input {
    background: var(--color-surface);
    color: var(--color-text);
}

.settings form button[type="submit"] {
    margin-top: 1.25rem;
}

.settings .field-error {
    margin: 0.25rem 0 0;
    min-height: 0;
    font-size: 0.8rem;
    color: var(--color-error);
}

.settings .field-error:empty {
    display: none;
}

.profile-settings-button {
    width: auto;
    margin-top: 0;
}

.passkey-list {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.passkey-item,
.passkey-empty {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: 0.75rem;
    background: var(--color-surface);
}

.passkey-empty {
    justify-content: center;
    border-style: dashed;
    color: var(--color-muted);
    font-size: 0.9rem;
}

.passkey-info {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.passkey-name {
    font-weight: 600;
    overflow-wrap: anywhere;
}

.passkey-name i {
    color: var(--color-primary);
}

.passkey-meta {
    color: var(--color-muted);
    font-size: 0.8rem;
}

.passkey-delete-button {
    width: auto;
    margin-top: 0;
    flex-shrink: 0;
    padding: 0.45rem 0.7rem;
}

.password-input-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.password-input-row input {
    flex: 1;
    min-width: 0;
}

.password-input-row button {
    flex-shrink: 0;
    width: auto;
    margin-top: 0;
    padding: 0.5rem 0.85rem;
    white-space: nowrap;
}

.password-strength {
    --strength-color: var(--color-border);
    margin: 0.5rem 0 0.25rem;
}

.password-strength-bar {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.25rem;
}

.password-strength-bar span {
    height: 0.4rem;
    border-radius: 0.2rem;
    background: var(--color-border);
    transition: background 0.2s;
}

.password-strength-label {
    margin: 0.25rem 0 0;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--color-muted);
}

.password-strength[data-level="0"] { --strength-color: #dc2626; }
.password-strength[data-level="1"] { --strength-color: #ea580c; }
.password-strength[data-level="2"] { --strength-color: #ca8a04; }
.password-strength[data-level="3"] { --strength-color: #16a34a; }
.password-strength[data-level="4"] { --strength-color: #15803d; }

.password-strength[data-level="0"] .password-strength-bar span:nth-child(-n+1),
.password-strength[data-level="1"] .password-strength-bar span:nth-child(-n+2),
.password-strength[data-level="2"] .password-strength-bar span:nth-child(-n+3),
.password-strength[data-level="3"] .password-strength-bar span:nth-child(-n+4),
.password-strength[data-level="4"] .password-strength-bar span:nth-child(-n+5) {
    background: var(--strength-color);
}

.password-strength[data-level="0"] .password-strength-label,
.password-strength[data-level="1"] .password-strength-label,
.password-strength[data-level="2"] .password-strength-label,
.password-strength[data-level="3"] .password-strength-label,
.password-strength[data-level="4"] .password-strength-label {
    color: var(--strength-color);
}

.login-passkey {
    margin-top: 1rem;
}

.login-passkey-divider {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin: 0 0 0.75rem;
    color: var(--color-muted);
    font-size: 0.85rem;
}

.login-passkey-divider::before,
.login-passkey-divider::after {
    content: "";
    flex: 1;
    height: 1px;
    background: var(--color-border);
}

.login-passkey-button {
    width: 100%;
}

@media (max-width: 600px) {
    .password-input-row {
        flex-wrap: wrap;
    }

    .password-input-row input {
        flex-basis: 100%;
    }

    .password-input-row #password-generate-button {
        flex: 1;
    }

    .settings form {
        padding: 0.75rem 1rem 1rem;
    }
}
