:root {
    --bg: #f7faff;
    --surface: #ffffff;
    --surface-soft: #f8fbff;
    --surface-blue: #eff6ff;
    --ink: #0f172a;
    --muted: #64748b;
    --muted-strong: #475569;
    --line: #dbe5f2;
    --line-strong: #bfdbfe;
    --accent: #2563eb;
    --accent-dark: #1d4ed8;
    --accent-soft: #dbeafe;
    --accent-ink: #1e3a8a;
    --success: #22c55e;
    --amber: #b45309;
    --amber-bg: #fffbeb;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --danger-line: #fecaca;
    --shadow-sm: 0 8px 24px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 22px 70px rgba(37, 99, 235, 0.10);
    --radius-lg: 18px;
    --radius-xl: 26px;
    --radius-pill: 999px;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    color-scheme: light;
    scroll-behavior: smooth;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at top left, rgba(37, 99, 235, 0.16), transparent 34rem),
        radial-gradient(circle at top right, rgba(14, 165, 233, 0.10), transparent 30rem),
        linear-gradient(180deg, var(--bg) 0%, #ffffff 54rem);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.5;
    text-rendering: optimizeLegibility;
}

button,
input,
select,
textarea {
    font: inherit;
}

button,
.button-link {
    min-height: 44px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--accent), #3b82f6);
    color: #fff;
    cursor: pointer;
    font-weight: 750;
    letter-spacing: -0.01em;
    padding: 0 16px;
    text-decoration: none;
    transition:
        transform 160ms ease,
        box-shadow 160ms ease,
        background 160ms ease,
        border-color 160ms ease,
        color 160ms ease;
}

button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.button-link {
    display: flex;
    align-items: center;
    justify-content: center;
}

button:hover,
.button-link:hover {
    background: linear-gradient(135deg, var(--accent-dark), var(--accent));
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.18);
    color: #fff;
    transform: translateY(-1px);
}

button:active,
.button-link:active {
    transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
a:focus-visible {
    outline: 3px solid rgba(37, 99, 235, 0.22);
    outline-offset: 2px;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.58;
    box-shadow: none;
    transform: none;
}

button.danger {
    background: var(--danger-bg);
    border-color: var(--danger-line);
    color: var(--danger);
}

button.danger:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    box-shadow: 0 12px 24px rgba(220, 38, 38, 0.10);
    color: var(--danger);
}

input,
select,
textarea {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.88);
    color: var(--ink);
    outline: none;
    padding: 11px 13px;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input::placeholder,
textarea::placeholder {
    color: #94a3b8;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(37, 99, 235, 0.55);
    background: #fff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

select {
    appearance: none;
    background:
        linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 50% / 6px 6px no-repeat,
        linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 13px) 50% / 6px 6px no-repeat,
        rgba(255, 255, 255, 0.88);
    padding-right: 38px;
}

a {
    color: var(--accent);
    font-weight: 760;
    text-decoration-color: rgba(37, 99, 235, 0.28);
    text-underline-offset: 3px;
}

a:hover {
    color: var(--accent-dark);
    text-decoration-color: rgba(29, 78, 216, 0.62);
}

.app-shell {
    width: min(1320px, calc(100% - 36px));
    margin: 0 auto;
    padding: 28px 0 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    margin-bottom: 20px;
}

.app-header {
    position: sticky;
    top: 10px;
    z-index: 40;
    display: grid;
    gap: 12px;
    border: 1px solid rgba(191, 219, 254, 0.78);
    border-radius: 24px;
    background:
        radial-gradient(circle at 0% 0%, rgba(37, 99, 235, 0.10), transparent 18rem),
        rgba(247, 250, 255, 0.88);
    box-shadow: 0 22px 62px rgba(37, 99, 235, 0.12);
    margin-bottom: 16px;
    padding: 12px;
    backdrop-filter: blur(18px);
}

.app-header-main {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
}

.app-header h1 {
    font-size: clamp(1.35rem, 2.6vw, 2rem);
    line-height: 1;
}

.header-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.header-link {
    min-height: 38px;
    border-radius: 12px;
    padding: 0 12px;
}

.app-header .brand-mark {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    padding: 6px;
}

.app-header .mode-switch {
    width: 100%;
    margin: 0;
    overflow-x: auto;
    justify-content: center;
}

.app-header .mode-tab {
    flex: 1 1 0;
    min-width: 110px;
    padding-inline: 16px;
}

.brand-group {
    max-width: 760px;
}

.brand-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    flex: 0 0 auto;
    border-radius: 16px;
    background: #fff;
    box-shadow: 0 18px 36px rgba(12, 74, 110, 0.16);
    object-fit: contain;
    padding: 7px;
}

.eyebrow,
.section-label {
    margin: 0;
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 850;
    letter-spacing: 0.10em;
    text-transform: uppercase;
}

h1,
h2 {
    margin: 0;
    color: var(--ink);
    letter-spacing: -0.045em;
}

h1 {
    font-size: clamp(2rem, 4.5vw, 3.45rem);
    line-height: 0.98;
}

h2 {
    font-size: 1.18rem;
    line-height: 1.25;
}

.hero-copy {
    max-width: 620px;
    margin: 12px 0 0;
    color: var(--muted);
    font-size: clamp(0.98rem, 2vw, 1.1rem);
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line);
    border-radius: var(--radius-pill);
    background: rgba(255, 255, 255, 0.84);
    color: var(--muted-strong);
    font-size: 0.92rem;
    font-weight: 760;
    padding: 9px 13px;
    white-space: nowrap;
    box-shadow: var(--shadow-sm);
}

.status-pill::before {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #94a3b8;
    content: "";
}

.status-pill.is-active {
    border-color: rgba(37, 99, 235, 0.28);
    background: #fff;
    color: var(--accent-ink);
}

.status-pill.is-active::before {
    background: var(--success);
    box-shadow: 0 0 0 5px rgba(34, 197, 94, 0.12);
}

.status-pill.is-expired {
    border-color: #fde68a;
    background: var(--amber-bg);
    color: var(--amber);
}

.status-pill.is-expired::before {
    background: #f59e0b;
}

.mode-switch {
    display: flex;
    width: fit-content;
    max-width: 100%;
    gap: 6px;
    margin: 0 auto 18px;
    border: 1px solid var(--line);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.76);
    box-shadow: var(--shadow-sm);
    padding: 6px;
    backdrop-filter: blur(16px);
}

.mode-tab {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border-radius: 13px;
    color: var(--muted-strong);
    font-weight: 800;
    padding: 0 28px;
    text-decoration: none;
}

.mode-tab:hover,
.mode-tab.is-active {
    background: var(--surface-blue);
    color: var(--accent);
    text-decoration: none;
}

.mode-tab.is-active {
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.36);
}

.hero-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    align-items: stretch;
}

body.is-temp-tab .hero-grid {
    grid-template-columns: 1fr;
}

.mailbox-band,
.permanent-card,
.bulk-panel,
.bulk-results,
.bulk-detail,
.pane,
.challenge-panel,
.test-panel,
.history-panel,
.mail-sidebar {
    border: 1px solid rgba(191, 219, 254, 0.72);
    border-radius: var(--radius-xl);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(16px);
}

.mailbox-band {
    position: relative;
    display: grid;
    grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.45fr);
    gap: 18px;
    overflow: hidden;
    padding: 26px;
}

.mailbox-band::before,
.permanent-card::before {
    position: absolute;
    inset: 0;
    background:
        radial-gradient(circle at 12% 0%, rgba(37, 99, 235, 0.13), transparent 20rem),
        linear-gradient(135deg, rgba(239, 246, 255, 0.62), rgba(255, 255, 255, 0));
    content: "";
    pointer-events: none;
}

.mailbox-band > *,
.permanent-card > * {
    position: relative;
    z-index: 1;
}

.mailbox-main {
    min-width: 0;
}

.address-row,
.access-row,
.custom-row {
    display: grid;
    gap: 10px;
}

.address-row {
    grid-template-columns: minmax(0, 1fr) auto auto;
    margin-top: 14px;
}

.access-row {
    grid-template-columns: minmax(0, 1fr) auto;
    margin-top: 10px;
}

.custom-row {
    grid-template-columns: minmax(0, 1fr);
    margin-top: 10px;
}

.address-input,
.access-input {
    overflow: hidden;
    text-overflow: ellipsis;
}

.address-input {
    min-height: 58px;
    border-color: rgba(37, 99, 235, 0.20);
    background: #fff;
    color: var(--accent);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: clamp(1.05rem, 3vw, 1.62rem);
    font-weight: 850;
    letter-spacing: -0.055em;
}

.access-input {
    color: var(--muted);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.86rem;
}

.helper-text {
    color: var(--muted);
    font-size: 0.9rem;
    margin: 9px 0 0;
}

.security-note,
.delivery-note {
    border: 1px solid rgba(37, 99, 235, 0.14);
    border-radius: 14px;
    background: rgba(239, 246, 255, 0.68);
    color: var(--accent-ink);
    font-size: 0.86rem;
    margin: 10px 0 0;
    padding: 10px 12px;
}

.delivery-note {
    margin: 0;
    border-width: 0 0 1px;
    border-radius: 0;
    background: rgba(248, 251, 255, 0.86);
    color: var(--muted-strong);
    padding: 12px 18px;
}

.meta-row {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    margin-top: 16px;
    color: var(--muted-strong);
    font-size: 0.88rem;
}

.meta-row span {
    display: inline-flex;
    align-items: center;
    min-height: 32px;
    border: 1px solid rgba(37, 99, 235, 0.14);
    border-radius: var(--radius-pill);
    background: rgba(239, 246, 255, 0.76);
    padding: 5px 10px;
}

.custom-form {
    align-self: stretch;
    border: 1px solid rgba(37, 99, 235, 0.12);
    border-radius: 22px;
    background:
        linear-gradient(180deg, rgba(239, 246, 255, 0.88), rgba(255, 255, 255, 0.78));
    padding: 16px;
}

.custom-form label {
    color: var(--muted-strong);
    font-size: 0.9rem;
    font-weight: 780;
}

.custom-form button {
    width: 100%;
}

.trap-field {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.permanent-card {
    position: relative;
    overflow: hidden;
    padding: 26px;
}

body.is-permanent-tab .permanent-card {
    max-width: 780px;
    margin: 0 auto;
    padding: 30px;
}

.permanent-card h2 {
    margin-top: 2px;
}

.webmail-fields {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.webmail-fields span {
    display: flex;
    align-items: center;
    min-height: 44px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.84);
    color: #94a3b8;
    padding: 0 13px;
}

.permanent-actions {
    display: grid;
    gap: 10px;
    margin-top: 14px;
}

body.is-permanent-tab .permanent-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.is-permanent-tab .webmail-fields {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.is-permanent-tab .permanent-create {
    margin-top: 18px;
}

body.is-permanent-tab .permanent-form {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

body.is-permanent-tab .permanent-form > label,
body.is-permanent-tab .permanent-form > input,
body.is-permanent-tab .permanent-address-row,
body.is-permanent-tab .permanent-split,
body.is-permanent-tab .permanent-form > button {
    grid-column: 1 / -1;
}

.permanent-create {
    margin-top: 16px;
    border: 1px solid rgba(37, 99, 235, 0.14);
    border-radius: 18px;
    background: rgba(255, 255, 255, 0.72);
    padding: 5px;
}

.permanent-create summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    min-height: 46px;
    cursor: pointer;
    border-radius: 14px;
    color: var(--accent-ink);
    font-weight: 820;
    list-style: none;
    padding: 0 12px;
}

.permanent-create summary::-webkit-details-marker {
    display: none;
}

.permanent-create summary::after {
    width: 24px;
    height: 24px;
    display: grid;
    flex: 0 0 auto;
    place-items: center;
    border-radius: 50%;
    background: var(--surface-blue);
    color: var(--accent);
    content: "+";
    font-weight: 900;
}

.permanent-create[open] summary::after {
    content: "–";
}

.permanent-create small {
    display: inline-flex;
    align-items: center;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: var(--radius-pill);
    background: var(--surface-blue);
    color: var(--accent);
    font-size: 0.74rem;
    font-weight: 800;
    margin-left: auto;
    padding: 4px 9px;
}

.permanent-form {
    display: grid;
    gap: 10px;
    border-top: 1px solid rgba(37, 99, 235, 0.10);
    margin-top: 5px;
    padding: 14px 8px 8px;
}

.permanent-form label {
    color: var(--muted-strong);
    font-size: 0.86rem;
    font-weight: 780;
}

.permanent-address-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
}

.permanent-address-row span {
    display: inline-flex;
    align-items: center;
    min-height: 44px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 14px;
    background: var(--surface-blue);
    color: var(--accent-ink);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.84rem;
    font-weight: 800;
    padding: 0 12px;
}

.permanent-split {
    display: grid;
    grid-template-columns: 0.7fr 1.3fr;
    gap: 10px;
}

.permanent-split label {
    display: grid;
    gap: 6px;
}

.permanent-result {
    border: 1px dashed rgba(37, 99, 235, 0.20);
    border-radius: 14px;
    background: rgba(239, 246, 255, 0.58);
    color: var(--muted);
    font-size: 0.86rem;
    margin: 0 8px 8px;
    padding: 11px 12px;
}

.permanent-result.is-success {
    border-color: rgba(34, 197, 94, 0.25);
    background: rgba(240, 253, 244, 0.86);
    color: #166534;
}

.permanent-result.is-error {
    border-color: var(--danger-line);
    background: var(--danger-bg);
    color: var(--danger);
}

.result-card {
    display: grid;
    gap: 4px;
}

.result-card strong,
.result-card code {
    overflow-wrap: anywhere;
}

.result-card code {
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.84);
    color: var(--accent-ink);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    padding: 2px 5px;
}

.bulk-panel {
    display: grid;
    gap: 16px;
    padding: 22px;
}

.bulk-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.bulk-limit-pill,
.status-mini,
.type-pill {
    display: inline-flex;
    align-items: center;
    width: fit-content;
    min-height: 30px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: var(--radius-pill);
    background: var(--surface-blue);
    color: var(--accent-ink);
    font-size: 0.82rem;
    font-weight: 820;
    padding: 4px 10px;
    white-space: nowrap;
}

.bulk-create-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
}

.bulk-card {
    display: grid;
    gap: 13px;
    border: 1px solid rgba(37, 99, 235, 0.14);
    border-radius: 22px;
    background:
        radial-gradient(circle at 10% 0%, rgba(37, 99, 235, 0.08), transparent 16rem),
        rgba(255, 255, 255, 0.78);
    padding: 18px;
}

.admin-shortcut {
    align-content: start;
}

.bulk-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.bulk-card h3 {
    margin: 0;
    color: var(--ink);
    font-size: 1.04rem;
    letter-spacing: -0.025em;
}

.bulk-card p {
    margin: 3px 0 0;
    color: var(--muted);
    font-size: 0.9rem;
}

.bulk-icon {
    display: grid;
    flex: 0 0 44px;
    width: 44px;
    height: 44px;
    place-items: center;
    border-radius: 16px;
    background: var(--surface-blue);
    color: var(--accent);
    font-size: 1.16rem;
}

.bulk-icon.teal {
    background: rgba(20, 184, 166, 0.12);
    color: #0f766e;
}

.bulk-field-label,
.bulk-form-split label {
    color: var(--muted-strong);
    font-size: 0.88rem;
    font-weight: 780;
}

.bulk-counts {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.bulk-counts label {
    min-width: 0;
}

.bulk-counts input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.bulk-counts span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 13px;
    background: rgba(255, 255, 255, 0.84);
    color: var(--ink);
    cursor: pointer;
    font-weight: 820;
    transition: border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.bulk-counts input:checked + span {
    border-color: rgba(37, 99, 235, 0.62);
    background: var(--surface-blue);
    color: var(--accent);
    box-shadow: inset 0 0 0 1px rgba(37, 99, 235, 0.18);
}

.bulk-form-split {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.bulk-form-split label {
    display: grid;
    gap: 6px;
}

.helper-text.warning {
    border: 1px solid #fde68a;
    border-radius: 13px;
    background: var(--amber-bg);
    color: var(--amber);
    padding: 9px 10px;
}

.bulk-dashboard {
    display: grid;
    grid-template-columns: minmax(0, 1.55fr) minmax(300px, 0.62fr);
    gap: 14px;
}

.bulk-results,
.bulk-detail {
    overflow: hidden;
}

.bulk-results-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    border-bottom: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(248, 251, 255, 0.96), rgba(255, 255, 255, 0.82));
    padding: 17px 18px;
}

.bulk-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.bulk-select-all {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 14px;
    background: #fff;
    color: var(--accent-ink);
    font-weight: 800;
    padding: 0 12px;
}

.bulk-select-all input {
    width: 16px;
    min-height: 16px;
}

.bulk-table-wrap {
    overflow-x: auto;
}

.bulk-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 820px;
}

.bulk-table th,
.bulk-table td {
    border-bottom: 1px solid var(--line);
    padding: 12px 13px;
    text-align: left;
    vertical-align: middle;
}

.bulk-table th {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
    text-transform: uppercase;
    letter-spacing: 0.055em;
}

.bulk-row {
    transition: background 160ms ease;
}

.bulk-row:hover,
.bulk-row.is-active {
    background: rgba(239, 246, 255, 0.68);
}

.bulk-table input[type="checkbox"] {
    width: 16px;
    min-height: 16px;
}

.bulk-email,
.bulk-row-note {
    display: block;
    overflow-wrap: anywhere;
}

.bulk-email {
    color: var(--accent-ink);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.9rem;
    letter-spacing: -0.035em;
}

.bulk-row-note {
    color: var(--muted);
    font-size: 0.78rem;
    margin-top: 3px;
}

.bulk-row-note code,
.bulk-detail-list code {
    border-radius: 8px;
    background: rgba(239, 246, 255, 0.9);
    color: var(--accent-ink);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    padding: 2px 5px;
}

.status-mini.is-ready {
    border-color: rgba(34, 197, 94, 0.24);
    background: rgba(240, 253, 244, 0.86);
    color: #166534;
}

.type-pill {
    min-height: 28px;
    font-size: 0.78rem;
}

.bulk-link-pill {
    max-width: 230px;
    min-height: 34px;
    overflow: hidden;
    border-color: rgba(37, 99, 235, 0.14);
    background: var(--surface-blue);
    color: var(--accent);
    box-shadow: none;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.78rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bulk-link-pill:hover {
    color: var(--accent-dark);
}

.bulk-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.bulk-actions .icon-button,
.bulk-detail-actions .icon-button {
    min-height: 36px;
    padding-inline: 10px;
}

.bulk-empty {
    color: var(--muted);
    padding: 24px !important;
    text-align: center !important;
}

.bulk-card-list {
    display: none;
}

.bulk-empty-card,
.bulk-result-card {
    border: 1px solid var(--line);
    border-radius: 18px;
    background: #fff;
}

.bulk-empty-card {
    color: var(--muted);
    padding: 18px;
    text-align: center;
}

.bulk-result-card {
    display: grid;
    gap: 11px;
    padding: 13px;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.bulk-result-card:hover,
.bulk-result-card.is-active {
    border-color: rgba(37, 99, 235, 0.30);
    background: var(--surface-soft);
    transform: translateY(-1px);
}

.bulk-result-card.is-active {
    background: var(--surface-blue);
}

.bulk-result-top,
.bulk-result-bottom {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.bulk-result-check {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--accent-ink);
    font-size: 0.86rem;
    font-weight: 820;
}

.bulk-result-check input {
    width: 16px;
    min-height: 16px;
}

.bulk-result-card .bulk-link-pill {
    justify-content: flex-start;
    width: 100%;
    max-width: 100%;
}

.bulk-detail {
    padding: 18px;
}

.bulk-detail h2 {
    margin-top: 3px;
    overflow-wrap: anywhere;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 1rem;
    letter-spacing: -0.035em;
}

.bulk-detail-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.bulk-detail-list {
    display: grid;
    gap: 12px;
    margin: 16px 0;
}

.bulk-detail-list div {
    display: grid;
    gap: 5px;
}

.bulk-detail-list dt {
    color: var(--muted);
    font-size: 0.78rem;
    font-weight: 850;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.bulk-detail-list dd {
    margin: 0;
    overflow-wrap: anywhere;
}

.bulk-detail-actions {
    display: grid;
    gap: 8px;
}

.button-link.ghost {
    background: #fff;
    border-color: rgba(37, 99, 235, 0.16);
    color: var(--accent);
}

.button-link.ghost:hover {
    background: var(--surface-blue);
    border-color: rgba(37, 99, 235, 0.34);
    color: var(--accent-dark);
}

.challenge-panel {
    display: grid;
    grid-template-columns: minmax(220px, 0.7fr) minmax(0, 1fr);
    gap: 16px;
    margin-top: 16px;
    padding: 18px;
}

.challenge-form {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
}

.mail-workspace {
    display: grid;
    grid-template-columns: 1fr;
    gap: 14px;
    margin-top: 14px;
    align-items: stretch;
}

.mail-sidebar {
    display: none;
    min-height: 510px;
    overflow: hidden;
    padding: 14px;
}

.sidebar-menu {
    display: grid;
    gap: 8px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 48px;
    border: 1px solid transparent;
    border-radius: 14px;
    color: var(--ink);
    font-weight: 760;
    padding: 0 13px;
    text-decoration: none;
}

.sidebar-link:hover,
.sidebar-link.is-active {
    border-color: rgba(37, 99, 235, 0.18);
    background: var(--surface-blue);
    color: var(--accent);
    text-decoration: none;
}

.sidebar-link strong {
    color: var(--accent);
    font-size: 0.95rem;
}

.history-panel {
    padding: 18px;
}

.history-tab-panel {
    margin-top: 14px;
}

.history-tab-panel .history-list {
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    max-height: none;
    padding-right: 0;
}

.history-tab-panel .history-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.sidebar-history {
    margin-top: 18px;
    border-radius: 20px;
    box-shadow: none;
    padding: 14px;
}

.history-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.history-head .helper-text {
    margin-top: 4px;
}

.history-list {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    max-height: 420px;
    overflow-y: auto;
    padding-right: 4px;
    scrollbar-gutter: stable;
}

.history-item {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
    padding: 12px;
    transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.history-item:hover {
    border-color: rgba(37, 99, 235, 0.26);
    background: var(--surface-soft);
    transform: translateY(-1px);
}

.history-item.is-current {
    border-color: rgba(37, 99, 235, 0.45);
    background: var(--surface-blue);
}

.history-copy strong,
.history-copy span {
    display: block;
    overflow-wrap: anywhere;
}

.history-copy strong {
    color: var(--accent-ink);
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 0.88rem;
    letter-spacing: -0.035em;
}

.history-copy span {
    color: var(--muted);
    font-size: 0.82rem;
    margin-top: 3px;
}

.history-buttons {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
}

.icon-button,
.toolbar button {
    background: #fff;
    border-color: rgba(37, 99, 235, 0.16);
    color: var(--accent-ink);
    box-shadow: none;
}

.icon-button:hover,
.toolbar button:hover {
    background: var(--surface-blue);
    border-color: rgba(37, 99, 235, 0.34);
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.10);
    color: var(--accent-ink);
}

.rotate-button {
    width: 50px;
    padding: 0;
    font-size: 1.28rem;
}

.rotate-button span {
    display: inline-block;
    line-height: 1;
    transition: transform 180ms ease;
}

.rotate-button:hover span {
    transform: rotate(90deg);
}

.icon-button.subtle {
    border-color: transparent;
    background: transparent;
    color: var(--muted);
}

.icon-button.subtle:hover {
    border-color: var(--line);
    background: #fff;
    color: var(--ink);
}

.empty-state.compact {
    min-height: auto;
    padding: 13px 0 0;
}

.pane {
    min-height: 510px;
    overflow: hidden;
}

.inbox-pane {
    min-height: 560px;
}

.detail-pane {
    min-height: auto;
}

.detail-pane.is-open {
    display: block;
}

.pane-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    background:
        linear-gradient(180deg, rgba(248, 251, 255, 0.96), rgba(255, 255, 255, 0.82));
    padding: 17px 18px;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
}

.message-tools {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(170px, 0.7fr) auto;
    gap: 10px;
    border-bottom: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.76);
    padding: 12px 18px;
}

.message-tools button.is-active {
    border-color: rgba(37, 99, 235, 0.42);
    background: var(--surface-blue);
    color: var(--accent);
}

.empty-state,
.message-detail {
    color: var(--muted);
    padding: 20px;
}

.empty-state {
    min-height: 140px;
}

.message-list {
    display: grid;
    gap: 8px;
    padding: 10px;
}

.message-item {
    width: 100%;
    min-height: auto;
    border: 1px solid transparent;
    border-radius: 17px;
    background: transparent;
    color: var(--ink);
    box-shadow: none;
    padding: 14px;
    text-align: left;
    transform: none;
}

.message-item.is-unread {
    border-color: rgba(37, 99, 235, 0.18);
    background: rgba(239, 246, 255, 0.42);
}

.message-item:hover,
.message-item.is-selected {
    border-color: rgba(37, 99, 235, 0.20);
    background: var(--surface-blue);
    box-shadow: none;
    transform: none;
}

.message-item.is-selected {
    border-color: rgba(37, 99, 235, 0.42);
}

.message-item strong,
.message-item span {
    display: block;
    overflow-wrap: anywhere;
}

.message-title-row {
    display: flex !important;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.message-item strong {
    color: var(--ink);
    font-size: 0.98rem;
    letter-spacing: -0.015em;
}

.message-item span {
    color: var(--muted);
    font-size: 0.9rem;
    margin-top: 2px;
}

.message-badges {
    display: flex !important;
    flex: 0 0 auto;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: flex-end;
    margin-top: 0 !important;
}

.message-badge {
    display: inline-flex !important;
    align-items: center;
    width: fit-content;
    min-height: 24px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: var(--radius-pill);
    background: var(--surface-blue);
    color: var(--accent);
    font-size: 0.72rem !important;
    font-weight: 850;
    padding: 2px 8px;
    white-space: nowrap;
}

.message-badge.spam {
    border-color: var(--danger-line);
    background: var(--danger-bg);
    color: var(--danger);
}

.message-badge.warning,
.message-badge.attachment {
    border-color: #fde68a;
    background: var(--amber-bg);
    color: var(--amber);
}

.message-badge.unread {
    border-color: rgba(37, 99, 235, 0.32);
    background: #fff;
    color: var(--accent-ink);
}

.detail-meta {
    display: grid;
    gap: 5px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: var(--surface-soft);
    color: var(--muted);
    padding: 12px;
}

.detail-body {
    color: var(--ink);
    margin-top: 14px;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.detail-frame {
    width: 100%;
    min-height: 280px;
    margin-top: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    background: #fff;
}

.test-panel {
    display: grid;
    grid-template-columns: 220px minmax(0, 1fr);
    gap: 18px;
    margin-top: 14px;
    padding: 18px;
}

.test-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr)) auto;
    gap: 10px;
}

.test-form textarea {
    grid-column: 1 / 3;
    resize: vertical;
}

.test-form button {
    grid-row: 1 / 3;
    grid-column: 3;
    align-self: stretch;
}

.footer-links {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
    margin-top: 18px;
    color: var(--muted);
}

.toast {
    position: fixed;
    right: 18px;
    bottom: 18px;
    max-width: min(360px, calc(100% - 36px));
    border: 1px solid rgba(147, 197, 253, 0.24);
    border-radius: 18px;
    background: #0f172a;
    color: #fff;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.24);
    opacity: 0;
    padding: 13px 15px;
    transform: translateY(10px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.legal-page {
    width: min(760px, calc(100% - 32px));
    margin: 0 auto;
    padding: 54px 0;
}

.legal-page h1 {
    margin: 20px 0 14px;
}

.legal-page p {
    color: var(--muted);
}

.abuse-page {
    width: min(820px, calc(100% - 32px));
}

.abuse-form {
    display: grid;
    gap: 11px;
    border: 1px solid var(--line);
    border-radius: 24px;
    background:
        radial-gradient(circle at 10% 0%, rgba(37, 99, 235, 0.08), transparent 18rem),
        rgba(255, 255, 255, 0.86);
    box-shadow: var(--shadow-sm);
    margin-top: 22px;
    padding: 20px;
}

.abuse-form label {
    color: var(--muted-strong);
    font-weight: 800;
}

.abuse-form label span {
    color: var(--muted);
    font-size: 0.86rem;
    font-weight: 650;
}

.abuse-form textarea {
    resize: vertical;
}

.abuse-form button {
    width: fit-content;
    min-width: 170px;
}

.abuse-result {
    border: 1px dashed rgba(37, 99, 235, 0.20);
    border-radius: 16px;
    background: rgba(239, 246, 255, 0.58);
    color: var(--muted);
    margin-top: 14px;
    padding: 12px 14px;
}

.abuse-result.is-success {
    border-color: rgba(34, 197, 94, 0.25);
    background: rgba(240, 253, 244, 0.86);
    color: #166534;
}

.abuse-result.is-error {
    border-color: var(--danger-line);
    background: var(--danger-bg);
    color: var(--danger);
}

.back-link {
    display: inline-flex;
    margin-bottom: 16px;
}

.admin-shell {
    padding-bottom: 46px;
}

.admin-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 4px 0 16px;
}

.admin-nav .button-link {
    min-width: 170px;
}

.admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px;
    align-items: stretch;
}

.admin-card {
    min-width: 0;
}

.admin-card.permanent-card {
    display: grid;
    gap: 13px;
}

.admin-card .permanent-form,
.admin-card .permanent-result {
    margin-left: 0;
    margin-right: 0;
}

.admin-results {
    margin-top: 14px;
}

.admin-results > .bulk-results-head {
    border: 1px solid var(--line);
    border-radius: 22px;
}

.admin-results .bulk-dashboard {
    align-items: start;
}

.history-toggle {
    width: 100%;
    min-height: 40px;
    margin-top: 10px;
    border-color: rgba(37, 99, 235, 0.16);
    background: #fff;
    color: var(--accent);
    box-shadow: none;
}

.history-toggle:hover {
    background: var(--surface-blue);
    border-color: rgba(37, 99, 235, 0.34);
    color: var(--accent-dark);
}

@media (max-width: 1060px) {
    .hero-grid,
    .mail-workspace,
    .bulk-create-grid,
    .bulk-dashboard,
    .admin-grid {
        grid-template-columns: 1fr;
    }

    .mail-sidebar,
    .pane {
        min-height: auto;
    }

    .sidebar-menu {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }

    .sidebar-link {
        justify-content: center;
        text-align: center;
    }

    .sidebar-link strong {
        display: none;
    }

    .history-buttons {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 760px) {
    .topbar,
    .mailbox-band,
    .bulk-header,
    .bulk-results-head,
    .challenge-panel,
    .test-panel,
    .test-form {
        grid-template-columns: 1fr;
    }

    .topbar {
        align-items: flex-start;
    }

    .app-header {
        top: 6px;
        border-radius: 20px;
        padding: 10px;
    }

    .app-header-main {
        align-items: flex-start;
        flex-direction: column;
    }

    .header-actions {
        width: 100%;
        justify-content: stretch;
    }

    .header-actions > * {
        flex: 1 1 120px;
    }

    .app-header .mode-switch {
        justify-content: flex-start;
    }

    .status-pill {
        align-self: flex-start;
    }

    .bulk-header,
    .bulk-results-head {
        display: grid;
    }

    .message-tools {
        grid-template-columns: 1fr;
    }

    .bulk-toolbar {
        justify-content: stretch;
    }

    .bulk-toolbar > * {
        flex: 1 1 160px;
    }

    .bulk-table-wrap {
        display: none;
    }

    .bulk-card-list {
        display: grid;
        gap: 10px;
        padding: 12px;
    }

    .brand-row {
        align-items: flex-start;
    }

    .address-row,
    .access-row,
    .bulk-form-split,
    body.is-permanent-tab .permanent-actions,
    body.is-permanent-tab .webmail-fields,
    body.is-permanent-tab .permanent-form,
    .challenge-form {
        grid-template-columns: 1fr;
    }

    .mode-switch {
        width: 100%;
    }

    .mode-tab {
        flex: 1;
        padding-inline: 12px;
    }

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

    .history-head {
        display: grid;
    }

    .history-buttons {
        grid-template-columns: 1fr;
    }

    .history-tab-panel .history-list {
        grid-template-columns: 1fr;
    }

    .history-list {
        max-height: 320px;
    }

    .bulk-result-bottom {
        align-items: stretch;
        flex-direction: column;
    }

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

    .permanent-split,
    .test-form textarea,
    .test-form button {
        grid-column: auto;
        grid-row: auto;
    }

    .permanent-address-row {
        grid-template-columns: 1fr;
    }

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

    .address-row .address-input {
        grid-column: 1 / -1;
    }
}

@media (max-width: 560px) {
    .app-shell {
        width: min(100% - 22px, 1240px);
        padding-top: 12px;
    }

    .app-header .brand-mark {
        width: 42px;
        height: 42px;
    }

    .app-header .mode-tab {
        min-width: 96px;
        padding-inline: 10px;
    }

    .brand-mark {
        width: 46px;
        height: 46px;
        border-radius: 14px;
        font-size: 1.25rem;
    }

    .mailbox-band,
    .permanent-card,
    .bulk-panel,
    .bulk-card,
    .bulk-results,
    .bulk-detail,
    .mail-sidebar,
    .history-panel,
    .challenge-panel,
    .test-panel {
        border-radius: 22px;
        padding: 14px;
    }

    .pane {
        border-radius: 22px;
    }

    .pane-head {
        flex-direction: column;
        padding: 15px;
    }

    .toolbar {
        width: 100%;
        justify-content: stretch;
    }

    .toolbar button,
    .address-row button,
    .access-row button,
    .bulk-toolbar button,
    .bulk-detail-actions button,
    .bulk-actions button,
    .message-tools button,
    .abuse-form button {
        width: 100%;
    }

    .sidebar-menu {
        grid-template-columns: 1fr;
    }
}

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    clip-path: inset(50%) !important;
}

.lucide {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    stroke-width: 2;
}

.button-with-icon,
.section-label-with-icon {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}

.section-label-with-icon .lucide {
    width: 15px;
    height: 15px;
}

.app-header {
    grid-template-columns: minmax(230px, 1fr) auto minmax(230px, 1fr);
    align-items: center;
    gap: 16px;
    padding: 11px 13px;
}

.app-header .brand-row {
    min-width: 0;
    gap: 11px;
}

.app-header .brand-mark {
    width: 44px;
    height: 44px;
    border-radius: 13px;
}

.app-header h1 {
    font-size: clamp(1.2rem, 2vw, 1.7rem);
}

.app-header .mode-switch {
    width: auto;
    justify-self: center;
    overflow: visible;
    padding: 4px;
}

.app-header .mode-tab {
    width: 44px;
    min-width: 44px;
    min-height: 40px;
    flex: 0 0 44px;
    padding: 0;
}

.app-header .mode-tab .lucide {
    width: 19px;
    height: 19px;
}

.header-actions {
    justify-self: end;
    flex-wrap: nowrap;
}

.header-link.icon-only,
.square-icon-button {
    width: 44px;
    min-width: 44px;
    min-height: 44px;
    padding: 0;
}

.mailbox-band {
    grid-template-columns: minmax(0, 1fr);
    padding: 24px;
    text-align: center;
}

.mailbox-band .section-label {
    display: block;
    text-align: center;
}

.address-form {
    width: min(100%, 920px);
    margin: 0 auto;
}

.address-row {
    grid-template-columns: minmax(0, 1fr) 50px 50px;
    width: 100%;
    max-width: 920px;
    align-items: center;
    margin: 14px auto 0;
}

.address-editor {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    min-width: 0;
    min-height: 58px;
    overflow: hidden;
    border: 1px solid rgba(37, 99, 235, 0.20);
    border-radius: 14px;
    background: #fff;
    transition: border-color 160ms ease, box-shadow 160ms ease;
}

.address-editor:focus-within {
    border-color: rgba(37, 99, 235, 0.55);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.address-editor .address-input,
.address-domain {
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    font-weight: 850;
    letter-spacing: -0.045em;
}

.address-editor .address-input {
    min-width: 0;
    min-height: 56px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--accent);
    padding: 8px 0 8px 14px;
    text-align: right;
}

.address-editor .address-input:focus {
    border: 0;
    background: transparent;
    box-shadow: none;
}

.address-domain {
    overflow: hidden;
    color: var(--accent);
    padding-right: 14px;
    text-align: left;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.square-icon-button .lucide {
    width: 19px;
    height: 19px;
}

.rotate-button .lucide {
    transition: transform 180ms ease;
}

.rotate-button:hover .lucide {
    transform: rotate(90deg);
}

.pane-head {
    align-items: center;
}

.pane-title {
    flex: 0 0 auto;
}

.inbox-head-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.inbox-meta {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    color: var(--muted-strong);
    font-size: 0.78rem;
    font-weight: 720;
}

.inbox-meta span {
    display: inline-flex;
    align-items: center;
    min-height: 30px;
    border: 1px solid rgba(37, 99, 235, 0.12);
    border-radius: var(--radius-pill);
    background: rgba(239, 246, 255, 0.68);
    padding: 4px 9px;
    white-space: nowrap;
}

.unread-tools {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 7px;
}

.info-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex: 0 0 36px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 50%;
    background: #fff;
    color: var(--muted-strong);
    cursor: help;
    outline: none;
}

.info-tooltip:hover,
.info-tooltip:focus-visible {
    border-color: rgba(37, 99, 235, 0.38);
    color: var(--accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.tooltip-content {
    position: absolute;
    right: 0;
    top: calc(100% + 9px);
    z-index: 60;
    width: min(320px, calc(100vw - 42px));
    border: 1px solid rgba(191, 219, 254, 0.92);
    border-radius: 13px;
    background: #0f172a;
    color: #fff;
    box-shadow: 0 18px 44px rgba(15, 23, 42, 0.22);
    font-size: 0.8rem;
    font-weight: 560;
    line-height: 1.5;
    opacity: 0;
    padding: 10px 12px;
    pointer-events: none;
    text-align: left;
    transform: translateY(-4px);
    transition: opacity 150ms ease, transform 150ms ease;
}

.info-tooltip:hover .tooltip-content,
.info-tooltip:focus-visible .tooltip-content {
    opacity: 1;
    transform: translateY(0);
}

.bulk-icon .lucide {
    width: 20px;
    height: 20px;
}

.footer-links {
    align-items: center;
    justify-content: space-between;
}

.footer-links nav {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.footer-links p {
    margin: 0 0 0 auto;
    color: var(--muted);
    font-size: 0.86rem;
}

@media (max-width: 900px) {
    .app-header {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 9px 12px;
    }

    .app-header .mode-switch {
        grid-column: 1 / -1;
        grid-row: 2;
    }

    .header-actions {
        grid-column: 2;
        grid-row: 1;
    }
}

@media (max-width: 760px) {
    .app-header {
        align-items: center;
    }

    .app-header .brand-row {
        align-items: center;
    }

    .app-header .eyebrow {
        display: none;
    }

    .app-header h1 {
        font-size: 1.16rem;
    }

    .app-header .mode-switch {
        width: fit-content;
        justify-self: center;
    }

    .header-actions {
        width: auto;
        justify-content: flex-end;
    }

    .header-actions > * {
        flex: 0 0 auto;
    }

    .status-pill {
        align-self: center;
        min-height: 38px;
        font-size: 0.78rem;
        padding: 7px 10px;
    }

    .mailbox-band {
        padding: 18px;
    }

    .address-row {
        grid-template-columns: repeat(2, 50px);
        justify-content: center;
    }

    .address-editor {
        grid-column: 1 / -1;
        width: min(100%, 680px);
    }

    .address-row .address-input {
        grid-column: auto;
    }

    .address-row .square-icon-button {
        width: 50px;
    }

    .inbox-head-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .inbox-meta {
        width: 100%;
        justify-content: flex-start;
    }

    .unread-tools {
        justify-content: flex-start;
    }
}

@media (max-width: 560px) {
    .app-header .brand-mark {
        width: 40px;
        height: 40px;
    }

    .app-header .mode-tab {
        width: 42px;
        min-width: 42px;
        flex-basis: 42px;
        padding: 0;
    }

    .header-link.icon-only {
        width: 38px;
        min-width: 38px;
        min-height: 38px;
    }

    .inbox-head-actions .square-icon-button {
        width: 44px;
    }

    .footer-links {
        align-items: flex-start;
        flex-direction: column;
    }

    .footer-links p {
        margin-left: 0;
    }
}

.inbox-pane,
.detail-pane.is-open {
    display: flex;
    min-width: 0;
    flex-direction: column;
}

.message-list {
    display: grid;
    flex: 1 1 auto;
    align-content: start;
    gap: 0;
    grid-auto-rows: min-content;
    min-height: 0;
    overflow-y: auto;
    padding: 0;
    scrollbar-gutter: stable;
}

.message-item {
    display: grid;
    grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) minmax(96px, auto);
    align-items: center;
    gap: 14px;
    width: 100%;
    min-height: 58px;
    border: 0;
    border-bottom: 1px solid #e6ebf2;
    border-radius: 0;
    background: #f5f7fa;
    color: var(--muted-strong);
    box-shadow: none;
    padding: 10px 16px;
    text-align: left;
    transform: none;
}

.message-item:last-child {
    border-bottom: 0;
}

.message-item:hover {
    border-color: #dbe4f0;
    background: #eef4ff;
    box-shadow: inset 3px 0 0 rgba(37, 99, 235, 0.32);
    color: var(--ink);
    transform: none;
}

.message-item.is-unread {
    border-color: #e6ebf2;
    background: #fff;
    color: var(--ink);
    box-shadow: inset 3px 0 0 var(--accent);
}

.message-item.is-selected {
    border-color: #bfdbfe;
    background: #e8f1ff;
    box-shadow: inset 3px 0 0 var(--accent);
}

.message-item > span,
.message-item > time {
    min-width: 0;
    margin: 0;
}

.message-sender-cell {
    display: flex !important;
    align-items: center;
    gap: 9px;
    overflow: hidden;
}

.message-unread-dot {
    display: block !important;
    width: 7px;
    height: 7px;
    flex: 0 0 7px;
    border-radius: 50%;
    background: transparent;
    margin: 0 !important;
}

.message-item.is-unread .message-unread-dot {
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.10);
}

.message-item .message-sender {
    display: block;
    min-width: 0;
    overflow: hidden;
    color: inherit;
    font-size: 0.9rem;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-item.is-unread .message-sender,
.message-item.is-unread .message-subject {
    color: var(--ink);
    font-weight: 850;
}

.message-summary-cell {
    display: flex !important;
    align-items: center;
    min-width: 0;
    gap: 8px;
    overflow: hidden;
}

.message-summary-line {
    display: flex !important;
    align-items: baseline;
    min-width: 0;
    flex: 1 1 auto;
    gap: 6px;
    overflow: hidden;
    white-space: nowrap;
}

.message-item .message-subject {
    display: block;
    max-width: 52%;
    flex: 0 1 auto;
    overflow: hidden;
    color: var(--ink);
    font-size: 0.91rem;
    font-weight: 680;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-separator {
    display: block !important;
    flex: 0 0 auto;
    color: #94a3b8 !important;
    font-size: 0.85rem !important;
    margin: 0 !important;
}

.message-preview {
    display: block !important;
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    color: #64748b !important;
    font-size: 0.88rem !important;
    font-weight: 520;
    margin: 0 !important;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-time {
    display: block;
    color: #64748b;
    font-size: 0.76rem;
    font-weight: 650;
    text-align: right;
    white-space: nowrap;
}

.message-item.is-unread .message-time {
    color: var(--accent-ink);
    font-weight: 800;
}

.message-summary-cell .message-badges {
    flex-wrap: nowrap;
    margin: 0 !important;
}

.message-summary-cell .message-badge {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-pane {
    min-width: 0;
}

.detail-pane .pane-head {
    flex: 0 0 auto;
}

.detail-pane .pane-head > div:first-child {
    min-width: 0;
}

.detail-pane .pane-head h2 {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-actions {
    flex: 0 0 auto;
    flex-wrap: nowrap;
    margin-left: auto;
}

.detail-actions .detail-delete-button,
.detail-actions .detail-close-button {
    width: 42px;
    min-width: 42px;
    min-height: 42px;
    border-radius: 12px;
    padding: 0;
}

.detail-actions .detail-delete-button {
    border-color: #fecaca;
    background: #fff1f2;
    color: #dc2626;
}

.detail-actions .detail-delete-button:hover {
    border-color: #fca5a5;
    background: #ffe4e6;
    color: #b91c1c;
}

.detail-actions .detail-close-button {
    border-color: #dc2626;
    background: #dc2626;
    color: #fff;
    box-shadow: 0 8px 18px rgba(220, 38, 38, 0.18);
}

.detail-actions .detail-close-button:hover {
    border-color: #b91c1c;
    background: #b91c1c;
    color: #fff;
    box-shadow: 0 10px 22px rgba(185, 28, 28, 0.24);
}

.message-detail {
    min-height: 0;
    flex: 1 1 auto;
    overflow-y: auto;
    color: var(--muted);
    padding: 0;
    scrollbar-gutter: stable;
}

.detail-message-header {
    display: grid;
    grid-template-columns: 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--line);
    background: #fff;
    padding: 16px 18px;
}

.detail-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), #60a5fa);
    color: #fff;
    font-size: 1rem;
    font-weight: 850;
    box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
}

.detail-sender-copy {
    display: grid;
    min-width: 0;
    gap: 1px;
}

.detail-sender-copy strong,
.detail-sender-copy span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.detail-sender-copy strong {
    color: var(--ink);
    font-size: 0.94rem;
}

.detail-sender-copy span {
    color: var(--muted);
    font-size: 0.78rem;
}

.detail-recipient {
    margin-top: 2px;
}

.detail-time {
    display: grid;
    gap: 2px;
    text-align: right;
    white-space: nowrap;
}

.detail-time strong {
    color: var(--ink);
    font-size: 0.78rem;
}

.detail-time span {
    color: var(--muted);
    font-size: 0.72rem;
}

.detail-flags {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
    border-bottom: 1px solid var(--line);
    background: #f8fafc;
    padding: 9px 18px;
}

.detail-flag {
    display: inline-flex;
    align-items: center;
    min-height: 26px;
    border: 1px solid #dbe4f0;
    border-radius: var(--radius-pill);
    background: #fff;
    color: var(--muted-strong);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 9px;
}

.detail-flags .message-badges {
    margin: 0 !important;
}

.email-content {
    min-height: 260px;
    margin: 0;
    background: #fff;
    color: #1e293b;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    font-size: 0.94rem;
    line-height: 1.72;
    overflow-wrap: anywhere;
    padding: 24px;
}

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

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

.email-content p,
.email-content div {
    margin-block: 0 0.9em;
}

.email-content strong,
.email-content b {
    color: #0f172a;
    font-weight: 800;
}

.email-content a {
    color: var(--accent);
    font-weight: 650;
    text-decoration: underline;
    text-decoration-color: rgba(37, 99, 235, 0.36);
    text-underline-offset: 3px;
}

.email-content a:hover {
    color: var(--accent-dark);
    text-decoration-color: currentColor;
}

.email-content blockquote {
    margin: 1em 0;
    border-left: 3px solid #93c5fd;
    border-radius: 0 10px 10px 0;
    background: #eff6ff;
    color: #334155;
    padding: 10px 14px;
}

.email-content pre,
.email-content code {
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

.email-content pre {
    overflow-x: auto;
    border: 1px solid #dbe4f0;
    border-radius: 12px;
    background: #f8fafc;
    padding: 12px;
    white-space: pre-wrap;
}

.email-content code {
    border-radius: 5px;
    background: #f1f5f9;
    color: #0f172a;
    padding: 2px 5px;
}

.email-content ul,
.email-content ol {
    margin: 0.8em 0;
    padding-left: 1.4em;
}

.email-content li + li {
    margin-top: 0.35em;
}

.email-content table {
    width: 100%;
    max-width: 100%;
    margin: 1em 0;
    border-collapse: collapse;
    border-spacing: 0;
}

.email-content th,
.email-content td {
    border: 1px solid #e2e8f0;
    padding: 8px 10px;
    text-align: left;
    vertical-align: top;
}

.email-content th {
    background: #f8fafc;
    color: #0f172a;
    font-weight: 800;
}

.email-content hr {
    height: 1px;
    margin: 1.25em 0;
    border: 0;
    background: #e2e8f0;
}

.email-content-plain {
    white-space: pre-wrap;
}

@media (min-width: 901px) {
    .mail-workspace.is-detail-open {
        grid-template-columns: minmax(380px, 0.9fr) minmax(0, 1.35fr);
        align-items: stretch;
    }

    .mail-workspace.is-detail-open .inbox-pane,
    .mail-workspace.is-detail-open .detail-pane {
        height: clamp(560px, 68vh, 760px);
        min-height: 560px;
    }

    .mail-workspace.is-detail-open .message-item {
        grid-template-columns: minmax(112px, 0.72fr) minmax(0, 1.5fr) auto;
        gap: 10px;
        padding-inline: 12px;
    }

    .mail-workspace.is-detail-open .message-subject {
        max-width: 48%;
    }

    .mail-workspace.is-detail-open .message-time {
        max-width: 82px;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

@media (max-width: 900px) {
    .mail-workspace.is-detail-open {
        grid-template-columns: 1fr;
    }

    .detail-pane.is-open {
        min-height: 520px;
    }
}

@media (max-width: 680px) {
    .message-item {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 5px 10px;
        padding: 11px 13px;
    }

    .message-sender-cell {
        grid-column: 1;
        grid-row: 1;
    }

    .message-time {
        grid-column: 2;
        grid-row: 1;
    }

    .message-summary-cell {
        grid-column: 1 / -1;
        grid-row: 2;
        padding-left: 16px;
    }

    .message-item .message-subject {
        max-width: 46%;
    }

    .detail-message-header {
        grid-template-columns: 40px minmax(0, 1fr);
        padding: 14px;
    }

    .detail-avatar {
        width: 40px;
        height: 40px;
    }

    .detail-time {
        grid-column: 2;
        text-align: left;
    }

    .detail-time span {
        display: none;
    }

    .email-content {
        padding: 18px;
    }
}

@media (max-width: 560px) {
    .detail-pane .pane-head {
        flex-direction: row;
        align-items: center;
    }

    .detail-actions {
        width: auto;
        justify-content: flex-end;
    }

    .detail-actions .detail-delete-button,
    .detail-actions .detail-close-button {
        width: 40px;
        min-width: 40px;
        min-height: 40px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        transition-delay: 0ms !important;
    }
}

/* Compact address editor and full-width inbox */
.address-section {
    display: flex;
    justify-content: center;
    margin-top: 14px;
}

.address-section .address-form {
    width: min(100%, 760px);
    margin: 0 auto;
}

.address-section .address-row {
    grid-template-columns: minmax(0, 1fr) 50px 50px;
    max-width: none;
    margin: 0;
    gap: 8px;
}

.address-section .address-editor {
    grid-template-columns: minmax(150px, 1fr) 1px minmax(180px, 0.7fr);
    min-height: 50px;
    border-color: #dce3ee;
    border-radius: 15px;
    background: #f8fafc;
    box-shadow: 0 8px 22px rgba(15, 23, 42, 0.05);
}

.address-section .address-divider {
    width: 1px;
    height: 100%;
    background: #e2e8f0;
}

.address-section .address-input,
.address-section .address-domain {
    min-height: 48px;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 1rem;
    font-weight: 720;
    letter-spacing: -0.015em;
    text-align: left;
}

.address-section .address-input {
    padding: 8px 18px;
}

.address-section .address-domain {
    width: 100%;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: #64748b;
    padding: 8px 38px 8px 16px;
}

.address-section .address-domain:focus {
    box-shadow: none;
}

.address-section .square-icon-button {
    width: 50px;
    min-width: 50px;
    min-height: 50px;
    height: 50px;
    border-radius: 14px;
}

.mail-workspace,
.mail-workspace.is-detail-open {
    grid-template-columns: minmax(0, 1fr);
}

.mail-workspace .inbox-pane,
.mail-workspace.is-detail-open .inbox-pane {
    width: 100%;
    height: clamp(560px, 68vh, 760px);
    min-height: 560px;
}

.inbox-head-actions {
    flex: 1 1 auto;
}

.inbox-head-actions .top-warning {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    min-width: 42px;
    height: 42px;
    border: 1px solid rgba(37, 99, 235, 0.16);
    border-radius: 12px;
    background: #fff;
    color: var(--muted-strong);
}

.inbox-head-actions .top-warning .lucide {
    width: 18px;
    height: 18px;
}

.danger-soft {
    border-color: #fecaca;
    background: #fff1f2;
    color: #dc2626;
}

.danger-soft:hover {
    border-color: #fca5a5;
    background: #ffe4e6;
    color: #b91c1c;
}

.refresh-compact {
    min-height: 42px;
    padding-inline: 14px;
}

.compact-message-tools {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 0.42fr);
    padding-block: 10px;
}

.message-search-control,
.message-filter-control {
    display: flex;
    align-items: center;
    gap: 9px;
    min-width: 0;
    min-height: 42px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #fff;
    color: var(--muted);
    padding: 0 12px;
}

.message-filter-control select {
    flex: 1 1 0;
}

.message-filter-control select + select {
    flex: 0 0 92px;
    border-left: 1px solid var(--line);
    padding-left: 10px;
}

.message-search-control .lucide,
.message-filter-control .lucide {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
}

.message-search-control input,
.message-filter-control select {
    min-width: 0;
    min-height: 40px;
    border: 0;
    border-radius: 0;
    background: transparent;
    box-shadow: none;
    padding: 0;
}

.selection-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    border-bottom: 1px solid #bfdbfe;
    background: #eff6ff;
    color: var(--accent-ink);
    padding: 9px 18px;
}

.selection-toolbar > span {
    margin-right: auto;
    font-size: 0.82rem;
    font-weight: 800;
}

.selection-toolbar .square-icon-button {
    width: 38px;
    min-width: 38px;
    min-height: 38px;
}

/* Checkbox + message row */
.message-item,
.mail-workspace.is-detail-open .message-item {
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 0;
    min-height: 58px;
    padding: 0;
}

.message-item.is-checked {
    background: #eff6ff;
    box-shadow: inset 3px 0 0 var(--accent);
}

.message-check {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.message-check input {
    width: 17px;
    height: 17px;
    min-height: 17px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.message-open {
    display: grid;
    grid-template-columns: minmax(150px, 210px) minmax(0, 1fr) minmax(96px, auto);
    align-items: center;
    gap: 14px;
    min-width: 0;
    min-height: 58px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: inherit;
    box-shadow: none;
    padding: 10px 16px 10px 0;
    text-align: left;
    transform: none;
}

.message-open:hover {
    background: transparent;
    color: inherit;
    box-shadow: none;
    transform: none;
}

/* Floating message detail keeps the inbox at full width */
.has-detail-modal {
    overflow: hidden;
}

.detail-modal {
    position: fixed;
    z-index: 100;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 24px;
}

.detail-backdrop {
    position: absolute;
    z-index: 0;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    border-radius: 0;
    background: rgba(15, 23, 42, 0.52);
    box-shadow: none;
    padding: 0;
    backdrop-filter: blur(5px);
}

.detail-backdrop:hover {
    background: rgba(15, 23, 42, 0.58);
    box-shadow: none;
    transform: none;
}

.detail-modal .detail-pane {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(980px, calc(100vw - 48px));
    height: min(82vh, 780px);
    min-height: 480px;
    flex-direction: column;
    border-color: rgba(148, 163, 184, 0.3);
    background: #fff;
    box-shadow: 0 32px 90px rgba(15, 23, 42, 0.28);
}

.detail-modal .message-detail {
    flex: 1 1 auto;
}

@media (max-width: 900px) {
    .inbox-pane .pane-head {
        align-items: flex-start;
        flex-direction: column;
    }

    .inbox-head-actions {
        width: 100%;
        justify-content: flex-start;
    }

    .inbox-meta {
        width: 100%;
        justify-content: flex-start;
    }
}

@media (max-width: 680px) {
    .address-section .address-form {
        width: 100%;
    }

    .address-section .address-row {
        grid-template-columns: minmax(0, 1fr) 46px 46px;
    }

    .address-section .address-editor {
        grid-column: auto;
        grid-template-columns: minmax(112px, 1fr) 1px minmax(132px, 0.82fr);
    }

    .address-section .address-input,
    .address-section .address-domain {
        min-height: 46px;
        font-size: 0.9rem;
    }

    .address-section .address-input {
        padding-inline: 12px;
    }

    .address-section .address-domain {
        padding-left: 10px;
        padding-right: 28px;
    }

    .address-section .square-icon-button {
        width: 46px;
        min-width: 46px;
        min-height: 46px;
        height: 46px;
    }

    .compact-message-tools {
        grid-template-columns: 1fr;
    }

    .message-item,
    .mail-workspace.is-detail-open .message-item {
        grid-template-columns: 36px minmax(0, 1fr);
    }

    .message-open {
        grid-template-columns: minmax(0, 1fr) auto;
        gap: 5px 10px;
        padding: 11px 12px 11px 0;
    }

    .message-open .message-sender-cell {
        grid-column: 1;
        grid-row: 1;
    }

    .message-open .message-time {
        grid-column: 2;
        grid-row: 1;
    }

    .message-open .message-summary-cell {
        grid-column: 1 / -1;
        grid-row: 2;
        padding-left: 16px;
    }

    .detail-modal {
        align-items: end;
        padding: 0;
    }

    .detail-modal .detail-pane {
        width: 100%;
        height: min(92vh, 820px);
        min-height: 0;
        border-radius: 22px 22px 0 0;
    }
}

@media (max-width: 520px) {
    .inbox-head-actions {
        gap: 6px;
    }

    .inbox-head-actions .inbox-meta {
        order: -2;
    }

    .inbox-head-actions .top-warning,
    .inbox-head-actions .square-icon-button {
        width: 40px;
        min-width: 40px;
        height: 40px;
        min-height: 40px;
    }

    .refresh-compact {
        min-height: 40px;
        padding-inline: 11px;
    }

    .inbox-meta span:nth-child(2) {
        display: none;
    }
}
