.history {
    display: flex;
    flex-direction: column;
    gap: var(--space-row);
}

.card.history-card {
    padding: 0;
    overflow: hidden;
}

.history-table {
    width: 100%;
    border-collapse: collapse;
}

.history-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
}

.history-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
        "date menu"
        "what menu"
        "who menu";
    column-gap: var(--space-3);
    row-gap: var(--space-1);
    padding: var(--space-4);
    overflow-wrap: anywhere;
}

.history-line + .history-line {
    border-top: 1px solid var(--divider);
}

.history-line > td {
    padding: 0;
    text-align: left;
}

.history-date {
    grid-area: date;
    font-size: var(--font-size-meta);
    font-weight: var(--font-weight-medium);
    color: var(--text-muted);
}

.history-what {
    grid-area: what;
}

.history-what > * {
    display: block;
    margin-top: 2px;
}

.history-what > .history-title-row {
    display: flex;
}

.history-what > .history-trace {
    display: flex;
    margin-top: var(--space-2);
}

.history-who {
    grid-area: who;
    margin-top: var(--space-2);
    font-size: var(--font-size-meta);
    color: var(--text-muted);
}

.history-who > span {
    display: block;
}

.history-performer {
    font-weight: var(--font-weight-medium);
    color: var(--text-soft);
}

.history-menu {
    grid-area: menu;
    align-self: start;
}

.history-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: var(--space-1) var(--space-2);
}

.history-title-row .option-title {
    font-size: var(--font-size-control);
}

.history-note {
    font-size: var(--font-size-meta);
    font-style: italic;
    color: var(--text-muted);
}

.history-prescription {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-pill);
    color: var(--link);
}

.history-prescription:hover,
.history-prescription:focus-visible {
    background: var(--surface-selected);
}

.history-line.cancelled {
    background: var(--surface-soft);
}

.history-line.cancelled .history-title-row .option-title,
.history-line.cancelled .history-what > .option-subtitle {
    color: var(--text-soft);
    text-decoration: line-through;
}

.history-more {
    align-self: center;
    text-align: center;
    min-height: var(--target-size);
    padding: 0 var(--space-5);
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: var(--font-weight-bold);
    cursor: pointer;
}

.history-more:hover {
    border-color: var(--border-hover);
}

@container content (min-width: 640px) {
    .history-table thead {
        position: static;
        width: auto;
        height: auto;
        overflow: visible;
        clip-path: none;
    }

    .history-table th {
        padding: var(--space-3) 0;
        border-bottom: 1px solid var(--divider);
        text-align: left;
    }

    .history-table th:first-child {
        padding-left: 22px;
    }

    .history-line {
        display: table-row;
        padding: 0;
    }

    .history-line > td {
        display: table-cell;
        padding: var(--space-row) var(--space-4) var(--space-row) 0;
        vertical-align: top;
    }

    .history-line > td:first-child {
        padding-left: 22px;
    }

    .history-line + .history-line > td {
        border-top: 1px solid var(--divider);
    }

    .history-line + .history-line {
        border-top: 0;
    }

    .history-table th:first-child,
    .history-date {
        width: 90px;
    }

    .history-table th:nth-child(3),
    .history-who {
        width: 240px;
    }

    .history-line > td.history-who {
        margin-top: 0;
    }

    .history-line > td.history-menu {
        width: 44px;
        padding-right: 22px;
    }

    .history-line > td.history-date {
        font-size: var(--font-size-meta);
        color: var(--text-soft);
        white-space: nowrap;
    }
}

.history-trace {
    display: flex;
    flex-direction: column;
    gap: var(--space-1);
    padding-top: var(--space-3);
    border-top: 1px solid var(--divider);
}

.history-mention {
    font-size: var(--font-size-meta);
    font-weight: var(--font-weight-bold);
    color: var(--tone-mint-text);
}

.entry-option.destructive .option-title {
    color: var(--danger);
}

.entry-option.destructive .entry-icon {
    background: var(--danger-surface);
    color: var(--danger);
}

.entry-form {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
    width: 100%;
    max-width: 640px;
}

.correction-group,
.treatment-details,
.treatment-prescription,
.other-performer {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

.reveal-choices {
    align-items: center;
}

.entry-form:has(input[name="treatment_mode"][value="prescription"]:checked) .treatment-details,
.entry-form:has(input[name="treatment_mode"][value="details"]:checked) .treatment-prescription,
.entry-form:not(:has(input[name="performer"][value="other"]:checked)) .other-performer {
    display: none;
}

.card.cancelled-summary {
    gap: var(--space-1);
    background: var(--surface-soft);
    color: var(--text-soft);
}

.confirm .badge.butter {
    width: 46px;
    height: 46px;
    border-radius: var(--radius-small);
}

.confirm-actions form {
    display: flex;
    flex-direction: column;
}

h1.sheet-title {
    overflow-wrap: anywhere;
}
