/* Mobile-first styles; light and dark via CSS variables */

:root {
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f9fafb;
    --text: #111827;
    --muted: #6b7280;
    --border: #e5e7eb;
    --border-strong: #d1d5db;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-text: #ffffff;
    --ring: rgba(37, 99, 235, 0.25);
    --danger: #dc2626;
    --danger-bg: rgba(220, 38, 38, 0.08);
    --shadow: 0 1px 2px rgba(17, 24, 39, 0.06), 0 1px 3px rgba(17, 24, 39, 0.08);
    --shadow-lg: 0 4px 12px rgba(17, 24, 39, 0.1);
    --success-bg: #ecfdf5;
    --success-text: #065f46;
    --success-border: #34d399;
    --error-bg: #fef2f2;
    --error-text: #991b1b;
    --error-border: #f87171;
    --danger-solid: #dc2626;
    --danger-solid-hover: #b91c1c;
    --neutral-solid: #475569;
    --neutral-solid-hover: #334155;
    --success-solid: #16a34a;
    --success-solid-hover: #15803d;
    --attention-bg: #fffcf4;
    --state-new: #94a3b8;
    --state-wip: #f59e0b;
    --state-done: #22c55e;
    --badge-new-bg: #eef2f6;
    --badge-new-text: #475569;
    --badge-wip-bg: #fef3c7;
    --badge-wip-text: #92400e;
    --badge-done-bg: #dcfce7;
    --badge-done-text: #166534;
    --badge-reply-bg: #dbeafe;
    --badge-reply-text: #1e40af;
    --page-max: 1200px;
}

/* Theme mapping for the mzf filter component (works in light and dark) */
:root {
    --mzf-bg: var(--surface-2);
    --mzf-bg-hover: var(--border);
    --mzf-surface: var(--surface);
    --mzf-border: var(--border);
    --mzf-border-hover: var(--border-strong);
    --mzf-border-strong: var(--border-strong);
    --mzf-text: var(--text);
    --mzf-text-soft: var(--text);
    --mzf-muted: var(--muted);
    --mzf-muted-strong: var(--text);
    --mzf-active-bg: var(--ring);
    --mzf-accent: var(--accent);
    --mzf-focus: var(--accent);
    --mzf-focus-ring: var(--ring);
    --mzf-danger: var(--danger);
    --mzf-shadow: var(--shadow-lg);
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f1115;
        --surface: #191c22;
        --surface-2: #1f232b;
        --text: #e5e7eb;
        --muted: #9ca3af;
        --border: #2a2f3a;
        --border-strong: #3b4250;
        --accent: #3b82f6;
        --accent-hover: #60a5fa;
        --accent-text: #ffffff;
        --ring: rgba(96, 165, 250, 0.3);
        --danger: #f87171;
        --danger-bg: rgba(248, 113, 113, 0.12);
        --shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-lg: 0 4px 16px rgba(0, 0, 0, 0.5);
        --success-bg: rgba(52, 211, 153, 0.12);
        --success-text: #6ee7b7;
        --success-border: #059669;
        --error-bg: rgba(248, 113, 113, 0.12);
        --error-text: #fca5a5;
        --error-border: #b91c1c;
        --danger-solid: #dc2626;
        --danger-solid-hover: #ef4444;
        --neutral-solid: #475569;
        --neutral-solid-hover: #64748b;
        --success-solid: #16a34a;
        --success-solid-hover: #22c55e;
        --attention-bg: #26200f;
        --state-new: #64748b;
        --state-wip: #f59e0b;
        --state-done: #4ade80;
        --badge-new-bg: #2b3442;
        --badge-new-text: #cbd5e1;
        --badge-wip-bg: #47320c;
        --badge-wip-text: #fcd34d;
        --badge-done-bg: #113a25;
        --badge-done-text: #86efac;
        --badge-reply-bg: #1e3a8a;
        --badge-reply-text: #bfdbfe;
    }
}

@media (prefers-reduced-motion: reduce) {
    * {
        transition: none !important;
        animation: none !important;
    }
}

* {
    box-sizing: border-box;
}

html {
    font-size: 100%;
}

body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
        "Helvetica Neue", Arial, sans-serif;
    line-height: 1.55;
    overflow-wrap: anywhere;
    -webkit-font-smoothing: antialiased;
}

main {
    padding: 0.5rem 1rem 3rem;
}

h1 {
    font-size: 1.45rem;
    font-weight: 700;
    letter-spacing: -0.015em;
    margin: 1.25rem 0 1rem;
}

h2 {
    font-size: 1.05rem;
    font-weight: 650;
    letter-spacing: -0.01em;
    margin: 0 0 0.75rem;
}

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

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

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* Footer */

.site-footer {
    text-align: center;
    padding: 1.25rem 1rem 1.75rem;
    color: var(--muted);
    font-size: 0.75rem;
}

/* Header */

.site-header {
    position: sticky;
    top: 0;
    z-index: 10;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.header-inner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem 1rem;
    max-width: var(--page-max);
    margin: 0 auto;
    padding: 0.65rem 1rem;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
    color: var(--text);
    margin-right: auto;
}

.brand-icon {
    font-size: 2.4rem;
    line-height: 1;
    color: var(--accent);
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.brand-name {
    font-weight: 800;
    font-size: 1.2rem;
    letter-spacing: -0.02em;
}

.brand-sub {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--muted);
}

.brand:hover .brand-name {
    color: var(--accent);
}

.site-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem;
}

/* User menu (click the name -> dropdown with logout) */

.user-menu {
    position: relative;
}

.user-menu > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    min-height: 2.1rem;
    padding: 0 0.6rem;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    background: var(--surface);
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: border-color 0.15s, background 0.15s;
}

.user-menu > summary::-webkit-details-marker {
    display: none;
}

.user-menu > summary:hover {
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.user-menu > summary .bi-person-circle {
    font-size: 0.95rem;
    color: var(--accent);
}

.user-caret {
    font-size: 0.6rem;
    color: var(--muted);
    transition: transform 0.15s;
}

.user-menu[open] .user-caret {
    transform: rotate(180deg);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    z-index: 50;
    min-width: 8.5rem;
    padding: 0.25rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.45rem;
    box-shadow: var(--shadow-lg);
}

.user-dropdown a,
.user-dropdown button.push-item {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.4rem 0.6rem;
    border-radius: 0.35rem;
    font-size: 0.82rem;
    font-weight: 550;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}

.user-dropdown button.push-item {
    min-height: 0;
    background: none;
    border: none;
    box-shadow: none;
    justify-content: flex-start;
    text-align: left;
    cursor: pointer;
}

.user-dropdown a .bi,
.user-dropdown button.push-item .bi {
    font-size: 0.85rem;
}

.user-dropdown a:hover {
    background: var(--surface-2);
    color: var(--danger);
}

.user-dropdown button.push-item:hover:not(:disabled) {
    background: var(--surface-2);
    color: var(--accent);
}

.user-dropdown button.push-item:disabled {
    opacity: 0.6;
    cursor: default;
    white-space: normal;
}

.user-dropdown button.push-item[data-state="on"] .bi {
    color: var(--accent);
}

/* Language switch: joined segmented control */

.lang-switch {
    display: inline-flex;
    align-items: stretch;
}

.lang-form {
    display: inline-flex;
}

.lang-switch .lang-form:first-child button {
    border-radius: 0.5rem 0 0 0.5rem;
}

.lang-switch .lang-form:last-child button {
    border-radius: 0 0.5rem 0.5rem 0;
    margin-left: -1px;
}

.lang-form button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: auto;
    min-height: 2rem;
    min-width: 2.3rem;
    margin: 0;
    padding: 0 0.45rem;
    font-size: 0.75rem;
    font-weight: 600;
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--border);
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
    transition: color 0.15s, background 0.15s;
}

.lang-form button:hover {
    color: var(--text);
    background: var(--surface-2);
}

.lang-form button.lang-active {
    background: var(--accent);
    color: var(--accent-text);
    border-color: var(--accent);
}

/* Forms */

label,
.form-label {
    display: block;
    margin: 0.9rem 0 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    min-height: 2.75rem;
    font-size: 1rem;
    font-family: inherit;
    padding: 0.6rem 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--text);
    transition: border-color 0.15s, box-shadow 0.15s;
}

textarea {
    min-height: auto;
}

textarea {
    resize: vertical;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}

/* Buttons */

button {
    display: block;
    width: 100%;
    min-height: 2.75rem;
    margin-top: 0.9rem;
    font-size: 0.95rem;
    font-weight: 600;
    font-family: inherit;
    padding: 0.6rem 1.1rem;
    border: 1px solid transparent;
    border-radius: 0.5rem;
    background: var(--accent);
    color: var(--accent-text);
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s, transform 0.05s;
}

button:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-lg);
}

button:active {
    transform: translateY(1px);
    box-shadow: none;
}

button:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

/* Solid variants: every action button gets a full color fill */

button.danger {
    background: var(--danger-solid);
    color: #ffffff;
    border-color: transparent;
    box-shadow: var(--shadow);
}

button.danger:hover {
    background: var(--danger-solid-hover);
    box-shadow: var(--shadow-lg);
}

button.success {
    background: var(--success-solid);
    color: #ffffff;
    border-color: transparent;
    box-shadow: var(--shadow);
}

button.success:hover {
    background: var(--success-solid-hover);
    box-shadow: var(--shadow-lg);
}

a.btn-neutral,
button.neutral {
    background: var(--neutral-solid);
    color: #ffffff;
    border: none;
    box-shadow: var(--shadow);
}

a.btn-neutral:hover,
button.neutral:hover {
    background: var(--neutral-solid-hover);
    color: #ffffff;
    box-shadow: var(--shadow-lg);
}

button.small,
a.btn.small {
    min-height: 1.70rem;
    font-size: 0.75rem;
    padding: 0rem 1rem;
}

/* Panels, flash */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.1rem 1.25rem 1.25rem;
    margin-bottom: 1.75rem;
    box-shadow: var(--shadow);
}

.flash {
    padding: 0.7rem 1rem;
    border-radius: 0.5rem;
    border: 1px solid;
    font-weight: 500;
}

.flash-success {
    background: var(--success-bg);
    color: var(--success-text);
    border-color: var(--success-border);
}

.flash-error {
    background: var(--error-bg);
    color: var(--error-text);
    border-color: var(--error-border);
}

/* Filters: pill segments */

.filters {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1rem;
    color: var(--muted);
    font-size: 0.9rem;
}

.filters a {
    display: inline-flex;
    align-items: center;
    min-height: 2.25rem;
    padding: 0 0.85rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    color: var(--muted);
    font-weight: 550;
    text-decoration: none;
    transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.filters a:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.filters a.filter-active {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

/* Task list (cards) */

.task-list,
.update-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.task-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.9rem 1.1rem;
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.15s, border-color 0.15s;
}

.task-card:hover {
    box-shadow: var(--shadow-lg);
    border-color: var(--border-strong);
}

.task-title {
    font-weight: 650;
    font-size: 1.05rem;
    letter-spacing: -0.01em;
    text-decoration: none;
    color: var(--text);
}

.task-title:hover {
    color: var(--accent);
}

.task-meta,
.update-meta {
    color: var(--muted);
    font-size: 0.85rem;
    margin: 0.35rem 0 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    vertical-align: middle;
}

.badge::before {
    content: "";
    width: 0.45rem;
    height: 0.45rem;
    border-radius: 50%;
    background: currentColor;
}

.badge-new {
    background: var(--badge-new-bg);
    color: var(--badge-new-text);
}

.badge-wip {
    background: var(--badge-wip-bg);
    color: var(--badge-wip-text);
}

.badge-done {
    background: var(--badge-done-bg);
    color: var(--badge-done-text);
}

/* Task state accent (left border) */

.state-new {
    border-left: 4px solid var(--state-new);
}

.state-wip {
    border-left: 4px solid var(--state-wip);
}

.state-done {
    border-left: 4px solid var(--state-done);
}

/* Update kind selector (segmented radio pills) */

.kind-options {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.kind-option {
    margin: 0;
    position: relative;
}

.kind-option input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    min-height: 0;
}

.kind-option-body {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    min-height: 2.5rem;
    padding: 0.4rem 0.95rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.kind-option-body:hover {
    color: var(--text);
    background: var(--surface-2);
}

.kind-option input:checked + .kind-option-body {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.kind-option input:checked + .kind-option-body.kind-done {
    background: var(--state-done);
    border-color: var(--state-done);
    color: #ffffff;
}

.kind-option input:checked + .kind-option-body.kind-info {
    background: var(--state-wip);
    border-color: var(--state-wip);
    color: #ffffff;
}

.kind-option input:focus-visible + .kind-option-body {
    box-shadow: 0 0 0 3px var(--ring);
}

/* Flag banner on a single update */

.update-flag {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    margin: 0.4rem 0;
    padding: 0.3rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    font-weight: 700;
}

.update-flag.flag-done {
    background: var(--badge-done-bg);
    color: var(--badge-done-text);
}

.update-flag.flag-info {
    background: var(--badge-wip-bg);
    color: var(--badge-wip-text);
}

/* Author attention banner in the task view */

.attention-banner {
    display: flex;
    align-items: flex-start;
    gap: 0.8rem;
    margin-bottom: 1rem;
    padding: 0.85rem 1.1rem;
    background: var(--badge-wip-bg);
    color: var(--badge-wip-text);
    border: 1px solid var(--state-wip);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
}

.attention-banner .bi {
    font-size: 1.25rem;
    margin-top: 0.1rem;
}

/* Attention markers in the task table */

.attention-bell {
    display: inline-block;
    color: var(--state-wip);
    margin-right: 0.3rem;
    transform-origin: top center;
    animation: bellRing 2.2s ease-in-out infinite;
}

.attention-banner .bi-bell-fill {
    display: inline-block;
    transform-origin: top center;
    animation: bellRing 2.2s ease-in-out infinite;
}

@keyframes bellRing {
    0%, 24%, 100% { transform: rotate(0); }
    4%  { transform: rotate(18deg); }
    9%  { transform: rotate(-14deg); }
    14% { transform: rotate(9deg); }
    19% { transform: rotate(-5deg); }
}

.task-table tbody tr.row-attention {
    background: var(--attention-bg);
}

.task-table tbody tr.row-attention:hover {
    background: var(--attention-bg);
}

/* Read-receipt strip (discreet, bottom of the task view) */

.viewers-strip {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.45rem;
    margin: 1rem 0;
    color: var(--muted);
    font-size: 0.82rem;
}

.viewers-strip .bi-eye {
    font-size: 0.95rem;
}

.viewers-strip .viewer .avatar {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.72rem;
    box-shadow: none;
    cursor: default;
}

/* Collapsible "add update" form (collapsed when replies already exist) */

details.add-update > summary {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    background: var(--accent);
    color: var(--accent-text);
    border-radius: 0.5rem;
    box-shadow: var(--shadow);
    cursor: pointer;
    list-style: none;
    user-select: none;
    transition: background 0.15s, box-shadow 0.15s;
}

details.add-update > summary::-webkit-details-marker {
    display: none;
}

details.add-update > summary:hover {
    background: var(--accent-hover);
    box-shadow: var(--shadow-lg);
}

details.add-update[open] > summary {
    margin-bottom: 0.9rem;
}

/* Bottom panel (author only): toggle on the left, delete on the right */

/* One footer row: "add update" on the left, close/delete (author) on the right */
.task-footer {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.75rem;
    margin-top: 1.5rem;
}

.task-footer details.add-update {
    flex: 1 1 auto;
    min-width: 0;
}

.close-panel {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    margin-left: auto;
}

.close-panel form {
    display: inline-flex;
    margin: 0;
}

.close-panel button {
    margin-top: 0;
    justify-content: center;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Task view header */

.task-head {
    position: relative;
    padding-bottom: 2.6rem;
}

/* Status badge pinned to the bottom-right edge of the header panel */
.task-head-badge {
    position: absolute;
    right: 1.25rem;
    bottom: 0;
    border-radius: 10px 10px 0 0;
    padding: 0.3rem 0.95rem;
    font-size: 0.82rem;
}

.task-meta-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1.2rem;
    margin-bottom: 0.5rem;
}

.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    height: 1.9rem;
    padding: 0.2rem;
    border-radius: 26%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

.avatar svg {
    display: block;
    width: 100%;
    height: 100%;
}

.meta-author {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text);
}

.meta-item {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.meta-dates {
    display: inline-flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.6rem 1.2rem;
}

@media (min-width: 640px) {
    .meta-dates {
        margin-left: auto;
    }
}

.meta-item .bi {
    color: var(--accent);
    font-size: 0.95rem;
}

.meta-label {
    font-weight: 600;
}

/* Clear separation between the header blocks: tags / description / files */
.task-head .tag-list {
    margin: 0.6rem 0 0;
}

.task-head .md-content {
    margin-top: 1.75rem;
}

.task-head .attachment-wrap {
    margin-top: 1.75rem;
}

.task-head .actions {
    margin-top: 1.75rem;
}

.update-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 1rem;
}

.update-meta .avatar {
    width: 1.5rem;
    height: 1.5rem;
    font-size: 0.75rem;
}

.update-meta .meta-author {
    font-size: 0.88rem;
}

/* Task view */

.actions {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    margin-top: 1rem;
}

.actions button,
.actions a.btn {
    margin-top: 0;
    min-height: 2.75rem;
    width: 100%;
    justify-content: center;
}

.user-text {
    white-space: pre-line;
}

.update {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 0.9rem 1.1rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
}

/* Clear rhythm inside an update: header / flag / body / attachments / actions */
.update .update-meta {
    margin: 0 0 0.9rem;
    padding-bottom: 0.6rem;
    border-bottom: 1px solid var(--border);
    font-weight: 550;
}

.update .update-flag {
    margin: 0 0 0.75rem;
}

.update .md-content {
    margin-top: 0.9rem;
}

.update .attachment-wrap {
    margin-top: 1.25rem;
}

/* Edit/Delete live in the header line, pushed to the right */
.update .update-meta .update-actions {
    margin: 0 0 0 auto;
}

/* Dropzone */

.dropzone {
    display: block;
    margin: 0;
    padding: 1.1rem 1rem;
    border: 2px dashed var(--border-strong);
    border-radius: 0.75rem;
    background: var(--surface-2);
    text-align: center;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.dropzone:hover,
.dropzone:focus-within {
    border-color: var(--accent);
}

.dropzone.dragover {
    border-color: var(--accent);
    background: var(--ring);
}

/* Without JS: show the plain input, hide the decorative zone content */
.dropzone-ui {
    display: none;
}

.js .dropzone-ui {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    pointer-events: none;
}

/* With JS: keep the input focusable but visually hidden */
.js .dropzone input[type="file"] {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.dropzone input[type="file"] {
    width: 100%;
    font-size: 1rem;
    font-family: inherit;
    color: var(--text);
}

.dropzone-icon {
    color: var(--accent);
    margin-bottom: 0.25rem;
}

.dropzone-text {
    font-weight: 600;
    font-size: 0.95rem;
}

.dropzone-browse {
    color: var(--muted);
    font-size: 0.85rem;
}

.dropzone-files {
    list-style: none;
    margin: 0.5rem 0 0;
    padding: 0;
}

.dropzone-file {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.75rem;
    margin-bottom: 0.35rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    font-size: 0.88rem;
}

.dropzone-file-name {
    font-weight: 550;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dropzone-file-size {
    color: var(--muted);
    font-size: 0.8rem;
    margin-left: auto;
    flex-shrink: 0;
}

.dropzone-file-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    min-height: 1.75rem;
    margin: 0;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
    background: transparent;
    color: var(--muted);
    border: none;
    border-radius: 0.375rem;
    box-shadow: none;
    flex-shrink: 0;
}

.dropzone-file-remove:hover {
    background: var(--danger-bg);
    color: var(--danger);
    box-shadow: none;
}

.hint {
    color: var(--muted);
    font-size: 0.82rem;
    margin: 0.4rem 0 0;
}

/* Button-styled links */

a.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 2.75rem;
    padding: 0.6rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: 0.5rem;
    text-decoration: none;
    transition: background 0.15s, box-shadow 0.15s, color 0.15s;
}

a.btn-primary {
    background: var(--accent);
    color: var(--accent-text);
    box-shadow: var(--shadow);
}

a.btn-primary:hover {
    background: var(--accent-hover);
    color: var(--accent-text);
    box-shadow: var(--shadow-lg);
}

a.btn-ghost {
    color: var(--muted);
    border: 1px solid var(--border);
    background: var(--surface);
}

a.btn-ghost:hover {
    color: var(--text);
    border-color: var(--border-strong);
    background: var(--surface-2);
}

.page-actions {
    margin: 0 0 1.25rem;
}

.update-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.update-actions button.small {
    margin-top: 0;
}

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

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

/* Filter bar — compact controls, one shared 2.25rem height.
   One row: "new task" button on the left, filters pushed to the right. */

.filter-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.filter-group {
    display: flex;
    flex-wrap: wrap;
    align-items: stretch;
    gap: 0.4rem;
    margin-left: auto;
}

.filter-bar .mzf-filter-toggle {
    min-height: 2.25rem;
    width: auto;
    margin: 0;
    padding: 0 0.7rem;
    font-size: 0.85rem;
    border-radius: 0.5rem;
    box-shadow: none;
}

/* Search inputs live inside styled wrappers — strip the global input chrome */

#mzf-search-wrap {
    min-height: 2.25rem;
    padding: 0 0.35rem 0 0.65rem;
    border-radius: 0.5rem;
    gap: 0.4rem;
}

/* Higher specificity than the global input[type="text"] rule, which would
   otherwise force its 2.75rem height and border onto these bare inputs */
#mzf-search,
input[type="text"].mzf-filter-search {
    min-height: 0;
    width: 100%;
    padding: 0;
    border: none;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    font-size: 1rem;
}

#mzf-search {
    width: 11rem;
}

#mzf-search:focus,
input[type="text"].mzf-filter-search:focus {
    border: none;
    box-shadow: none;
    outline: none;
}

#mzf-search-clear {
    display: none;
    align-items: center;
    justify-content: center;
    width: 1.9rem;
    min-height: 1.9rem;
    margin: 0;
    padding: 0;
    background: none;
    border: none;
    border-radius: 0.375rem;
    box-shadow: none;
    color: var(--muted);
    font-size: 0.85rem;
}

#mzf-search-clear:hover {
    background: var(--surface-2);
    color: var(--text);
    box-shadow: none;
}

/* In-dropdown search: a regular compact text input, not a bare oversized field */
.mzf-filter-search-wrap {
    align-items: center;
    margin: 0.25rem 0.25rem 0.45rem;
    padding: 0.3rem 0.6rem;
    min-height: 2.1rem;
    gap: 0.4rem;
    border: 1px solid var(--border-strong);
    border-radius: 0.375rem;
    background: var(--surface);
    font-size: 0.9rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.mzf-filter-search-wrap:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px var(--ring);
}

input[type="text"].mzf-filter-search {
    font-size: 0.9rem;
    line-height: 1.3;
}

.mzf-filter-item {
    min-height: 2.1rem;
    padding: 0.35rem 0.7rem;
    font-size: 0.87rem;
}

.mzf-filter-item input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    min-height: 0;
}

/* Task table */

.table-wrap {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.task-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.92rem;
    /* Fixed layout: set columns keep their width, the title column flexes */
    table-layout: fixed;
}

.task-table th,
.task-table td {
    padding: 0.65rem 0.85rem;
    text-align: left;
    vertical-align: middle;
}

.task-table thead th {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.task-table tbody tr {
    border-bottom: 1px solid var(--border);
    border-left: 4px solid transparent;
    transition: background 0.12s;
}

.task-table tbody tr:last-child {
    border-bottom: none;
}

.task-table tbody tr:hover {
    background: var(--surface-2);
}

.task-table tbody tr.state-new { border-left-color: var(--state-new); }
.task-table tbody tr.state-wip { border-left-color: var(--state-wip); }
.task-table tbody tr.state-done { border-left-color: var(--state-done); }

.task-table tr[hidden] {
    display: none;
}

.task-table .col-id {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    width: 3.5rem;
}

.task-table .col-title {
    width: auto;
}

.task-table .col-flag {
    width: 9rem;
}

.task-table .col-status {
    width: 8rem;
}

.task-table .col-author {
    width: 9.5rem;
}

.task-table .col-author .table-author {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.task-table .col-dates {
    width: 10.5rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.date-line {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--muted);
}

.date-line .bi {
    color: var(--accent);
    font-size: 0.85rem;
}

.flag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.2rem 0.6rem;
    border-radius: 0.5rem;
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
}

.flag-chip.flag-reply {
    background: var(--badge-reply-bg);
    color: var(--badge-reply-text);
}

/* Bell color follows the chip: dark green / amber / blue */
.flag-chip.flag-done .attention-bell {
    color: var(--badge-done-text);
}

.flag-chip.flag-info .attention-bell {
    color: var(--badge-wip-text);
}

.flag-chip.flag-reply .attention-bell {
    color: var(--badge-reply-text);
}

.flag-chip.flag-done {
    background: var(--badge-done-bg);
    color: var(--badge-done-text);
}

.flag-chip.flag-info {
    background: var(--badge-wip-bg);
    color: var(--badge-wip-text);
}

.task-table .col-num {
    width: 3.25rem;
}

/* Scoped to .task-link so tag chips inside the same cell stay untouched */
.task-table .col-title a.task-link {
    font-weight: 600;
    text-decoration: none;
    color: var(--text);
    overflow-wrap: anywhere;
    /* Long titles clamp to two lines; the full text lives in the title tooltip */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.task-table .col-title a.task-link:hover {
    color: var(--accent);
}

.task-table .col-num {
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.table-author {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
}

.table-author .avatar {
    width: 1.6rem;
    height: 1.6rem;
    font-size: 0.78rem;
}

/* Tags in the list need breathing room */

.task-table .col-title {
    line-height: 1.35;
}

.task-table .col-title .tag-list {
    margin: 0.8rem 0 0;
    gap: 0.45rem;
}

.task-table .tag-chip {
    font-size: 0.72rem;
    padding: 0.20rem 0.55rem;
}

/* Uniform rows: 100px min height, with vertical padding tight enough that
   a two-line title or a tag row still fits within those 100px */
.task-table tbody td {
    height: 100px;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}

/* Pagination */

.pagination {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    margin-top: 1.25rem;
}

.page-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 2.25rem;
    min-height: 2.25rem;
    padding: 0 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 600;
    text-decoration: none;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

.page-link:hover {
    color: var(--text);
    border-color: var(--border-strong);
}

.page-link.page-current {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
}

.page-gap {
    color: var(--muted);
    padding: 0 0.2rem;
}

/* Instant tooltip box */

.app-tipbox {
    position: fixed;
    z-index: 4000;
    max-width: 24rem;
    padding: 0.45rem 0.75rem;
    background: var(--neutral-solid);
    color: #ffffff;
    border-radius: 0.45rem;
    font-size: 0.82rem;
    line-height: 1.4;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s;
    overflow-wrap: anywhere;
}

.app-tipbox.is-on {
    opacity: 1;
}

.app-tipbox::after {
    content: "";
    position: absolute;
    bottom: -5px;
    left: var(--tip-arrow, 50%);
    margin-left: -5px;
    border: 5px solid transparent;
    border-top-color: var(--neutral-solid);
    border-bottom: none;
}

.app-tipbox.is-below::after {
    bottom: auto;
    top: -5px;
    border-top: none;
    border-bottom: 5px solid var(--neutral-solid);
}

/* Narrow screens: table becomes stacked cards, no horizontal scroll */

@media (max-width: 767px) {
    .table-wrap {
        background: transparent;
        border: none;
        box-shadow: none;
        overflow: visible;
    }

    .task-table thead {
        display: none;
    }

    .task-table,
    .task-table tbody,
    .task-table tr,
    .task-table td {
        display: block;
        width: 100%;
    }

    .task-table tbody tr {
        background: var(--surface);
        border: 1px solid var(--border);
        border-left: 4px solid var(--border);
        border-radius: 0.75rem;
        box-shadow: var(--shadow);
        padding: 0.5rem 0;
        margin-bottom: 0.75rem;
    }

    .task-table td {
        display: flex;
        gap: 0.75rem;
        padding: 0.25rem 1rem;
        text-align: left;
    }

    .task-table td::before {
        content: attr(data-label);
        flex: 0 0 7rem;
        font-size: 0.78rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--muted);
        padding-top: 0.1rem;
    }

    .task-table .col-num {
        text-align: left;
    }

    .task-table tbody td {
        height: auto;
    }

    .task-table td:empty {
        display: none;
    }
}

/* Tag chips */

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.1rem 0.6rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    background: var(--badge-new-bg);
    color: var(--badge-new-text);
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

a.tag-chip:hover {
    background: var(--accent);
    color: var(--accent-text);
}

.tag-chip .bi {
    font-size: 0.7rem;
}

/* Tagify theming — matches the app inputs (size, border, focus ring) */

.tagify {
    --tags-border-color: var(--border-strong);
    --tags-hover-border-color: var(--border-strong);
    --tags-focus-border-color: var(--accent);
    --tag-bg: var(--badge-new-bg);
    --tag-text-color: var(--badge-new-text);
    --tag-hover: var(--ring);
    --tag-remove-btn-color: var(--muted);
    --tag-remove-bg: var(--danger-bg);
    --input-color: var(--text);
    --placeholder-color: var(--muted);
    --placeholder-color-focus: var(--muted);
    width: 100%;
    min-height: 2.75rem;
    align-items: center;
    background: var(--surface);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.tagify--focus {
    box-shadow: 0 0 0 3px var(--ring);
}

.tagify__input {
    min-height: 0;
}

.tagify__tag {
    font-weight: 600;
}

/* Busy overlay (submit with uploads) */

.busy-overlay {
    position: fixed;
    inset: 0;
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
}

.busy-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.9rem;
    padding: 1.5rem 2.25rem;
    background: var(--surface);
    color: var(--text);
    font-weight: 600;
    border-radius: 0.75rem;
    box-shadow: var(--shadow-lg);
}

.busy-spinner {
    width: 2.5rem;
    height: 2.5rem;
    border: 4px solid var(--border);
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: busySpin 0.8s linear infinite;
}

@keyframes busySpin {
    to { transform: rotate(360deg); }
}

/* Markdown editor */

.md-editor {
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    overflow: hidden;
}

.md-tabs-nav {
    display: flex;
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
}

.md-tab {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    width: auto;
    min-height: 2.5rem;
    margin: 0;
    padding: 0.5rem 1rem;
    font-size: 0.88rem;
    font-weight: 600;
    background: transparent;
    color: var(--muted);
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    box-shadow: none;
    cursor: pointer;
}

.md-tab:hover {
    background: var(--surface);
    color: var(--text);
    box-shadow: none;
}

.md-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
    background: var(--surface);
}

.md-tab-body {
    display: none;
    padding: 0.75rem;
}

.md-tab-active {
    display: block;
}

.md-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px;
    padding: 0.375rem 0.5rem;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 0.375rem 0.375rem 0 0;
    margin-bottom: -1px;
}

.md-btn {
    display: inline-flex;
    width: 2rem;
    min-height: 2rem;
    margin: 0;
    padding: 0;
    align-items: center;
    justify-content: center;
    border: 1px solid transparent;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    border-radius: 0.375rem;
    font-size: 1rem;
    line-height: 1;
    box-shadow: none;
    transition: background-color 0.1s, color 0.1s;
}

.md-btn:hover {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
    box-shadow: none;
}

.md-btn:active {
    background: var(--ring);
    color: var(--accent);
    transform: none;
}

.md-sep {
    width: 1px;
    height: 1.25rem;
    background: var(--border);
    margin: 0 4px;
}

.md-btn-fs {
    margin-left: auto;
}

.md-input {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 1rem;
    line-height: 1.5;
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-strong);
    border-radius: 0 0 0.375rem 0.375rem;
    background: var(--surface);
    color: var(--text);
    resize: vertical;
    tab-size: 4;
}

.md-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}

.md-preview {
    min-height: 8rem;
    padding: 0.5rem 0.25rem;
}

/* Fullscreen mode */

.md-editor.md-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    margin: 0;
    border-radius: 0;
    display: flex;
    flex-direction: column;
}

.md-editor.md-fullscreen > .md-tabs-nav {
    flex: 0 0 auto;
}

.md-editor.md-fullscreen > .md-tab-body {
    flex: 1 1 auto;
    min-height: 0;
}

.md-editor.md-fullscreen > .md-tab-body.md-tab-active {
    display: flex;
    flex-direction: column;
}

.md-editor.md-fullscreen .md-toolbar {
    flex: 0 0 auto;
}

.md-editor.md-fullscreen .md-input {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    resize: none;
}

.md-editor.md-fullscreen .md-preview {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
}

.md-editor.md-fullscreen > .md-tab-body > small {
    flex: 0 0 auto;
}

html.md-fullscreen-lock {
    overflow: hidden;
}

/* Rendered markdown content (task view + editor preview) */

.md-content {
    line-height: 1.65;
}

.md-content > :first-child {
    margin-top: 0;
}

.md-content > :last-child {
    margin-bottom: 0;
}

.md-content h1,
.md-content h2,
.md-content h3,
.md-content h4 {
    margin: 1.5em 0 0.5em;
    letter-spacing: -0.01em;
}

.md-content h1 { font-size: 1.35rem; }
.md-content h2 { font-size: 1.2rem; }
.md-content h3 { font-size: 1.05rem; }

.md-content img {
    display: block;
    max-width: 100%;
    border-radius: 0.375rem;
}

.md-content pre,
.md-content code {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 0.88em;
    background: var(--surface-2);
    border-radius: 0.3rem;
}

.md-content code {
    padding: 0.1em 0.35em;
}

.md-content pre {
    padding: 0.75rem 1rem;
    overflow-x: auto;
    border: 1px solid var(--border);
}

.md-content pre code {
    padding: 0;
    background: transparent;
}

.md-content blockquote {
    margin: 0.75em 0;
    padding: 0.25em 0 0.25em 1em;
    border-left: 4px solid var(--accent);
    color: var(--muted);
}

.md-content table {
    border-collapse: collapse;
    max-width: 100%;
    display: block;
    width: fit-content;
    overflow-x: auto;
}

.md-content th,
.md-content td {
    border: 1px solid var(--border-strong);
    padding: 0.35rem 0.7rem;
    text-align: left;
}

.md-content th {
    background: var(--surface-2);
}

.md-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 1.25rem 0;
}

.md-content a {
    overflow-wrap: anywhere;
}

/* Attachments table */

.attachment-wrap {
    margin-top: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow: hidden;
}

.attachment-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
    /* Fixed layout: every column keeps its set width, the name column flexes */
    table-layout: fixed;
}

.attachment-table th,
.attachment-table td {
    padding: 0.45rem 0.75rem;
    text-align: left;
    vertical-align: middle;
}

.attachment-table thead th {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--muted);
    background: var(--surface-2);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.attachment-table tbody tr {
    border-bottom: 1px solid var(--border);
}

.attachment-table tbody tr:last-child {
    border-bottom: none;
}

.attachment-table tbody tr:hover {
    background: var(--surface-2);
}

.attachment-table .col-id {
    color: var(--muted);
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    width: 3.5rem;
}

.attachment-table .col-preview {
    width: 4.5rem;
}

.attachment-table .col-name {
    width: auto;
}

.attachment-table .col-name a {
    overflow-wrap: anywhere;
}

.attachment-table .col-size {
    width: 5.75rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.attachment-table .col-date {
    width: 9.75rem;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.attachment-thumb {
    display: block;
    width: 3.5rem;
    height: 2.5rem;
    object-fit: cover;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
}

.attachment-icon {
    font-size: 1.6rem;
    color: var(--muted);
    line-height: 1;
}

.attachment-name {
    font-weight: 550;
}

.attachment-table .col-actions {
    width: 9.5rem;
    text-align: right;
}

.attachment-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.3rem;
}

button.attachment-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    min-height: 2.25rem;
    margin: 0;
    padding: 0;
    font-size: 0.95rem;
}

a.attachment-download {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0 0.7rem;
    min-height: 2.25rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}

a.attachment-download .bi {
    font-size: 0.95rem;
}

a.attachment-download:hover {
    color: var(--accent);
    border-color: var(--accent);
    background: var(--surface-2);
}

@media (max-width: 639px) {
    .attachment-table thead {
        display: none;
    }

    .attachment-table,
    .attachment-table tbody,
    .attachment-table tr,
    .attachment-table td {
        display: block;
        width: 100%;
    }

    .attachment-table tbody tr {
        padding: 0.4rem 0;
        border-bottom: 1px solid var(--border);
    }

    .attachment-table td {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.2rem 0.75rem;
    }

    .attachment-table td[data-label]::before {
        content: attr(data-label);
        flex: 0 0 5rem;
        font-size: 0.72rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--muted);
    }
}

/* Wider screens */

@media (min-width: 640px) {
    main {
        max-width: var(--page-max);
        margin: 0 auto;
    }

    h1 {
        font-size: 1.65rem;
    }

    button {
        display: inline-block;
        width: auto;
    }

    .actions {
        flex-direction: row;
        align-items: center;
    }

    .actions form {
        display: inline;
    }

    .actions button,
    .actions a.btn {
        width: auto;
    }

    /* Destructive action pushed away from the constructive ones */
    .actions .action-delete {
        margin-left: auto;
    }
}

@media (min-width: 1024px) {
    main {
        padding-top: 1rem;
    }

    h1 {
        font-size: 1.8rem;
    }
}
