.attachment-preview-eye, .attachment-preview__action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: .45rem;
    flex: 0 0 auto;
    border: 1px solid var(--mud-palette-lines-default, #dce0e6);
    border-radius: 999px;
    background: var(--mud-palette-surface, #fff);
    color: var(--mud-palette-text-primary, #202631);
    box-shadow: 0 2px 8px rgb(0 0 0 / 8%);
    font: inherit;
    font-weight: 650;
    text-decoration: none;
    cursor: pointer;
    transition: background-color 150ms, box-shadow 150ms, transform 150ms;
}
.attachment-preview-eye, .attachment-preview__action--icon {
    width: 2.5rem;
    height: 2.5rem;
    padding: .5rem;
}
.attachment-preview-eye svg, .attachment-preview__action svg { width: 1.25rem; height: 1.25rem; }
.attachment-preview-eye:hover, .attachment-preview__action:hover {
    background: color-mix(in srgb, var(--mud-palette-surface, #fff) 88%, var(--mud-palette-info, #2463b4));
    box-shadow: 0 4px 12px rgb(0 0 0 / 14%);
    transform: translateY(-1px);
}
.attachment-preview-eye:focus-visible, .attachment-preview__action:focus-visible {
    outline: 2px solid var(--mud-palette-info, #2463b4);
    outline-offset: 3px;
}
.attachment-preview__row { display: flex; align-items: center; gap: .55rem; min-width: 0; }
.attachment-preview__row > a { min-width: 0; flex: 1 1 auto; }

.attachment-preview {
    --preview-border: var(--mud-palette-lines-default, #dce0e6);
    --preview-ink: var(--mud-palette-text-primary, #202631);
    --preview-muted: var(--mud-palette-text-secondary, #56606e);
    --preview-surface: var(--mud-palette-surface, #fff);
    --preview-accent: var(--mud-palette-info, #2463b4);
    --preview-card: color-mix(in srgb, var(--preview-surface) 96%, var(--preview-ink));
    width: min(900px, calc(100vw - 36px));
    max-width: none;
    max-height: calc(100dvh - 36px);
    margin: auto;
    padding: 0;
    border: 1px solid var(--preview-border);
    border-radius: 24px;
    background: var(--preview-surface);
    color: var(--preview-ink);
    box-shadow: 0 24px 70px rgb(0 0 0 / 38%);
    overflow: hidden;
}
.attachment-preview[open] { display: flex; flex-direction: column; animation: attachment-preview-enter 180ms ease-out; }
.attachment-preview::backdrop { background: rgb(8 10 18 / 52%); backdrop-filter: blur(8px); }
.attachment-preview__header, .attachment-preview__footer {
    display: flex;
    align-items: center;
    gap: .8rem;
    padding: 1rem 1.25rem;
    flex-shrink: 0;
}
.attachment-preview__header { border-bottom: 1px solid var(--preview-border); }
.attachment-preview__footer { border-top: 1px solid var(--preview-border); justify-content: flex-end; }
.attachment-preview__footer:empty { display: none; }
.attachment-preview__action--primary {
    padding: .65rem 1rem;
    border-color: transparent;
    color: var(--preview-ink);
    background: color-mix(in srgb, var(--preview-surface) 86%, var(--preview-accent));
}
.attachment-preview__icon {
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    border-radius: 50%;
    width: 2.9rem;
    height: 2.9rem;
    color: var(--preview-accent);
    background: color-mix(in srgb, var(--preview-surface) 88%, var(--preview-accent));
}
.attachment-preview__icon svg { width: 1.55rem; height: 1.55rem; }
.attachment-preview__heading { flex: 1; min-width: 0; }
.attachment-preview__heading h2 {
    margin: .15rem 0 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: clamp(1.05rem, 2vw, 1.35rem);
    font-weight: 750;
}
.attachment-preview__eyebrow { color: var(--preview-muted); font-size: .78rem; font-weight: 700; margin: 0; }
.attachment-preview__content { display: grid; gap: .8rem; padding: 1rem 1.25rem; min-height: 0; overflow: auto; overscroll-behavior: contain; }
.attachment-preview__status { display: flex; justify-content: center; align-items: center; gap: .6rem; margin: 1.25rem 0; color: var(--preview-muted); text-align: center; }
.attachment-preview__status.is-loading::before {
    content: "";
    width: 1.15rem;
    height: 1.15rem;
    border-radius: 50%;
    border: 2px solid var(--preview-border);
    border-top-color: var(--preview-accent);
    animation: attachment-preview-spin .65s linear infinite;
}
.attachment-preview__pdf, .attachment-preview__text, .attachment-preview__card {
    border: 1px solid var(--preview-border);
    border-radius: 16px;
    background: var(--preview-card);
    box-shadow: 0 3px 12px rgb(0 0 0 / 5%);
}
.attachment-preview__pdf { display: block; width: 100%; height: min(72dvh, 900px); }
.attachment-preview__text, .attachment-preview__mail-text { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.attachment-preview__text { padding: 1rem 1.15rem; font: .9rem/1.65 ui-monospace, Consolas, monospace; }
.attachment-preview__card { padding: 1rem 1.15rem; min-width: 0; }
.attachment-preview__envelope h3 { margin: 0; font-size: 1.2rem; overflow-wrap: anywhere; }
.attachment-preview__envelope dl { margin: .75rem 0 0; display: grid; grid-template-columns: auto minmax(0, 1fr); gap: .35rem 1rem; }
.attachment-preview__envelope dl:empty { display: none; }
.attachment-preview__envelope dt { color: var(--preview-muted); font-size: .85rem; font-weight: 650; }
.attachment-preview__envelope dd { margin: 0; overflow-wrap: anywhere; }
.attachment-preview__mail { display: grid; gap: .75rem; }
.attachment-preview__mail-text { line-height: 1.75; }
.attachment-preview__mail-frame { width: 100%; border: none; min-height: 200px; }
.attachment-preview__files { list-style: none; display: flex; flex-wrap: wrap; gap: .55rem; padding: 0; margin: .65rem 0 0; }
.attachment-preview__files li { display: flex; align-items: center; gap: .4rem; overflow-wrap: anywhere; padding: .35rem .65rem; border: 1px solid var(--preview-border); border-radius: 12px; }
.attachment-preview__files svg { width: 1rem; height: 1rem; flex-shrink: 0; }
.attachment-preview__notice { color: var(--preview-muted); margin: 0; padding: .35rem 1.25rem .75rem; font-size: .85rem; flex-shrink: 0; }
@keyframes attachment-preview-enter { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
@keyframes attachment-preview-spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) {
    .attachment-preview { width: 100%; height: 100dvh; max-height: none; border: 0; border-radius: 0; }
    .attachment-preview__header, .attachment-preview__footer, .attachment-preview__content { padding-inline: .85rem; }
    .attachment-preview__header { padding-top: max(1rem, env(safe-area-inset-top)); }
    .attachment-preview__footer { padding-bottom: max(1rem, env(safe-area-inset-bottom)); }
    .attachment-preview__content { flex: 1; align-content: start; }
    .attachment-preview__content:has(.attachment-preview__pdf) { align-content: stretch; }
    .attachment-preview__pdf { height: 100%; min-height: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .attachment-preview[open], .attachment-preview__status.is-loading::before { animation: none; }
    .attachment-preview-eye, .attachment-preview__action { transition: none; }
    .attachment-preview-eye:hover, .attachment-preview__action:hover { transform: none; }
}
