:root {
    --ink: #17212b;
    --muted: #73808d;
    --line: #e7ebee;
    --soft: #f6f8f9;
    --paper: #ffffff;
    --navy: #122532;
    --navy-soft: #1d3543;
    --accent: #ef6f3b;
    --accent-dark: #d85a2c;
    --accent-wash: #fff0e9;
    --danger: #c83d3d;
    --shadow: 0 24px 70px rgba(20, 35, 47, .14);
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html,
body {
    min-height: 100%;
    margin: 0;
}

body {
    color: var(--ink);
    background: var(--soft);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    -webkit-font-smoothing: antialiased;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
input:focus-visible {
    outline: 3px solid rgba(239, 111, 59, .25);
    outline-offset: 2px;
}

noscript {
    display: block;
    padding: 16px;
    color: #fff;
    background: var(--danger);
    text-align: center;
}

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

.brand-mark {
    display: grid;
    width: 39px;
    height: 39px;
    place-items: center;
    color: #fff;
    background: var(--accent);
    border-radius: 12px 4px 12px 4px;
    font-size: 21px;
    font-weight: 800;
    font-style: italic;
    box-shadow: 0 8px 18px rgba(239, 111, 59, .25);
}

.brand > span:last-child {
    display: flex;
    flex-direction: column;
    line-height: 1;
}

.brand strong {
    font-size: 20px;
    letter-spacing: -.5px;
}

.brand small {
    margin-top: 4px;
    color: var(--muted);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 3.2px;
}

.login-view {
    display: grid;
    min-height: 100vh;
    padding: 32px 18px;
    place-items: center;
    background:
        radial-gradient(circle at 10% 15%, rgba(239, 111, 59, .12), transparent 28%),
        radial-gradient(circle at 90% 80%, rgba(18, 37, 50, .09), transparent 28%),
        #f5f7f8;
}

.login-card {
    width: min(100%, 430px);
    padding: 42px;
    background: rgba(255, 255, 255, .97);
    border: 1px solid rgba(20, 35, 47, .07);
    border-radius: 22px;
    box-shadow: var(--shadow);
}

.brand-login {
    margin-bottom: 42px;
}

.login-copy h1 {
    margin: 0;
    font-size: clamp(27px, 5vw, 34px);
    line-height: 1.13;
    letter-spacing: -1.2px;
}

.login-copy p {
    margin: 11px 0 30px;
    color: var(--muted);
    font-size: 15px;
}

.login-card label {
    display: block;
    margin: 18px 0 8px;
    font-size: 13px;
    font-weight: 700;
}

.input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.input-wrap input {
    width: 100%;
    height: 51px;
    padding: 0 72px 0 43px;
    color: var(--ink);
    background: #fafbfb;
    border: 1px solid #dde3e6;
    border-radius: 11px;
    transition: border-color .18s, box-shadow .18s, background .18s;
}

.input-wrap input:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(239, 111, 59, .09);
    outline: none;
}

.input-icon {
    position: absolute;
    left: 15px;
    z-index: 1;
    color: #87939d;
    font-weight: 700;
}

.input-icon.lock {
    width: 13px;
    height: 11px;
    border: 2px solid #87939d;
    border-radius: 3px;
}

.input-icon.lock::before {
    position: absolute;
    top: -9px;
    left: 1px;
    width: 7px;
    height: 8px;
    border: 2px solid #87939d;
    border-bottom: 0;
    border-radius: 8px 8px 0 0;
    content: "";
}

.password-toggle {
    position: absolute;
    right: 11px;
    padding: 6px;
    color: var(--muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 12px;
    font-weight: 700;
}

.form-error {
    margin: 15px 0 0;
    padding: 11px 13px;
    color: #9f2f2f;
    background: #fff0f0;
    border: 1px solid #ffd5d5;
    border-radius: 9px;
    font-size: 13px;
    line-height: 1.45;
}

.primary-button {
    display: flex;
    width: 100%;
    height: 52px;
    margin-top: 25px;
    padding: 0 18px;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 11px;
    cursor: pointer;
    font-weight: 750;
    box-shadow: 0 10px 22px rgba(239, 111, 59, .24);
    transition: transform .15s, background .15s, box-shadow .15s;
}

.primary-button:hover {
    background: var(--accent-dark);
    box-shadow: 0 13px 25px rgba(239, 111, 59, .3);
    transform: translateY(-1px);
}

.primary-button:disabled {
    opacity: .62;
    cursor: wait;
    transform: none;
}

.privacy-note {
    margin: 23px 0 0;
    color: #9aa4ac;
    font-size: 11px;
    text-align: center;
}

.mail-view {
    display: grid;
    min-height: 100vh;
    grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
    position: sticky;
    top: 0;
    display: flex;
    height: 100vh;
    padding: 27px 18px 20px;
    flex-direction: column;
    color: #dce5e9;
    background: var(--navy);
    overflow-y: auto;
}

.sidebar-brand {
    padding: 0 10px 27px;
    color: #fff;
}

.sidebar-brand small {
    color: #7f96a3;
}

.account {
    display: flex;
    margin-bottom: 27px;
    padding: 14px 10px;
    align-items: center;
    gap: 11px;
    background: rgba(255, 255, 255, .045);
    border: 1px solid rgba(255, 255, 255, .055);
    border-radius: 12px;
}

.avatar {
    display: grid;
    width: 35px;
    height: 35px;
    flex: 0 0 auto;
    place-items: center;
    color: #fff;
    background: var(--navy-soft);
    border: 1px solid rgba(255, 255, 255, .11);
    border-radius: 50%;
    font-size: 13px;
    font-weight: 800;
}

.account-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.account-copy strong {
    overflow: hidden;
    color: #fff;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.account-copy small {
    margin-top: 4px;
    color: #8195a0;
    font-size: 10px;
}

.folder-nav {
    flex: 1;
}

.folder-branch {
    min-width: 0;
}

.folder-row {
    display: grid;
    grid-template-columns: 20px minmax(0, 1fr);
    padding-left: calc(var(--folder-depth, 0) * 14px);
    align-items: center;
}

.folder-children[hidden] {
    display: none;
}

.folder-expander {
    display: grid;
    width: 20px;
    height: 30px;
    padding: 0;
    place-items: center;
    color: #728996;
    background: transparent;
    border: 0;
    border-radius: 6px;
    cursor: pointer;
    font-size: 17px;
    line-height: 1;
    transition: color .15s, background .15s, transform .15s;
}

.folder-expander:hover {
    color: #fff;
    background: rgba(255, 255, 255, .055);
}

.folder-expander[aria-expanded="true"] {
    transform: rotate(90deg);
}

.folder-expander.placeholder {
    visibility: hidden;
    pointer-events: none;
}

.nav-label {
    margin: 0 10px 9px;
    color: #69818e;
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 1.8px;
    text-transform: uppercase;
}

.folder-button,
.settings-button,
.logout-button {
    display: flex;
    width: 100%;
    padding: 10px 12px;
    align-items: center;
    gap: 12px;
    color: #aebdc5;
    background: transparent;
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    font-size: 13px;
    text-align: left;
    transition: color .15s, background .15s;
}

.folder-branch + .folder-branch {
    margin-top: 2px;
}

.folder-button:hover,
.settings-button:hover,
.logout-button:hover {
    color: #fff;
    background: rgba(255, 255, 255, .055);
}

.folder-button.active {
    color: #fff;
    background: rgba(239, 111, 59, .15);
}

.folder-button.active .folder-icon {
    color: var(--accent);
}

.folder-icon {
    display: inline-grid;
    width: 17px;
    place-items: center;
    color: #728996;
    font-size: 17px;
}

.folder-name {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-button {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, .07);
    border-radius: 0;
}

.logout-button {
    margin-top: 2px;
    border-radius: 0 0 9px 9px;
}

.mail-main {
    min-width: 0;
    padding: 0 42px 50px;
    background: var(--paper);
}

.mail-header {
    position: sticky;
    z-index: 5;
    top: 0;
    display: flex;
    min-height: 118px;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
    background: rgba(255, 255, 255, .94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.heading-row {
    display: flex;
    align-items: center;
    gap: 13px;
}

.heading-copy {
    min-width: 0;
}

.header-actions {
    display: flex;
    margin-left: 4px;
    align-items: center;
    gap: 7px;
}

.eyebrow {
    margin: 0 0 4px;
    color: var(--accent);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: 1.5px;
    text-transform: uppercase;
}

.mail-header h1 {
    margin: 0;
    font-size: clamp(23px, 2.6vw, 31px);
    letter-spacing: -1px;
}

.menu-button,
.refresh-button {
    display: grid;
    width: 39px;
    height: 39px;
    padding: 0;
    place-items: center;
    color: var(--muted);
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
}

.menu-button {
    display: none;
}

.refresh-button {
    margin-left: 6px;
    font-size: 20px;
}

.refresh-button:hover {
    color: var(--accent);
}

.refresh-button.spinning {
    animation: spin .85s linear infinite;
}

.mailbox-cleanup-button,
.empty-trash-button {
    display: inline-flex;
    min-height: 39px;
    padding: 0 12px;
    align-items: center;
    gap: 7px;
    color: #53616c;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 10px;
    cursor: pointer;
    font-size: 10px;
    transition: color .15s, border-color .15s, background .15s;
}

.mailbox-cleanup-button b,
.empty-trash-button b {
    font-weight: 800;
    white-space: nowrap;
}

.mailbox-cleanup-button:hover {
    color: var(--accent-dark);
    background: var(--accent-wash);
    border-color: #f1c0aa;
}

.empty-trash-button {
    color: #a93434;
    background: #fff8f8;
    border-color: #efd3d3;
}

.empty-trash-button:hover {
    color: #fff;
    background: var(--danger);
    border-color: var(--danger);
}

.mailbox-cleanup-button:disabled,
.empty-trash-button:disabled {
    opacity: .5;
    cursor: wait;
}

.search-box {
    display: flex;
    width: min(37vw, 380px);
    height: 43px;
    padding: 0 10px 0 14px;
    align-items: center;
    gap: 10px;
    color: #8b969e;
    background: var(--soft);
    border: 1px solid transparent;
    border-radius: 11px;
}

.search-box:focus-within {
    background: #fff;
    border-color: #dfe5e8;
    box-shadow: 0 5px 18px rgba(20, 35, 47, .06);
}

.search-box input {
    min-width: 0;
    flex: 1;
    color: var(--ink);
    background: transparent;
    border: 0;
    outline: none;
    font-size: 13px;
}

.search-box kbd {
    padding: 3px 6px;
    color: #9ca6ad;
    background: #fff;
    border: 1px solid #e2e6e8;
    border-radius: 5px;
    font: 10px inherit;
    box-shadow: 0 1px 1px rgba(0, 0, 0, .03);
}

.list-toolbar {
    display: flex;
    min-height: 56px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
}

.list-summary {
    display: flex;
    align-items: center;
    gap: 12px;
}

.select-all {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    cursor: pointer;
}

.select-all input,
.message-checkbox {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--accent);
    cursor: pointer;
}

.select-all span {
    display: none;
}

.list-toolbar p,
.list-toolbar span {
    margin: 0;
    color: var(--muted);
    font-size: 11px;
    font-weight: 650;
}

.bulk-toolbar {
    display: flex;
    min-height: 57px;
    margin: 0 -10px;
    padding: 8px 10px;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: #fff8f4;
    border-bottom: 1px solid #f4d9cc;
    animation: toolbar-in .18s both;
}

.bulk-toolbar strong {
    flex: 0 0 auto;
    color: var(--accent-dark);
    font-size: 12px;
}

.bulk-actions,
.move-control,
.reader-actions,
.reader-nav {
    display: flex;
    align-items: center;
    gap: 7px;
}

.bulk-actions > button,
.move-control button,
.reader-toolbar button {
    min-height: 34px;
    padding: 0 11px;
    color: #53616c;
    background: #fff;
    border: 1px solid #dce3e6;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 750;
    white-space: nowrap;
    transition: color .15s, border-color .15s, background .15s;
}

.bulk-actions > button:hover,
.move-control button:hover,
.reader-toolbar button:hover {
    color: var(--accent-dark);
    border-color: #efb59c;
}

.bulk-actions button:disabled,
.move-control button:disabled,
.reader-toolbar button:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.move-control {
    padding-left: 7px;
    border-left: 1px solid #eadfd9;
}

.move-control select {
    width: 145px;
    height: 34px;
    padding: 0 25px 0 9px;
    color: #53616c;
    background: #fff;
    border: 1px solid #dce3e6;
    border-radius: 8px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 650;
}

.danger-action {
    color: #b53d3d !important;
}

.danger-action:hover {
    color: #fff !important;
    background: #c94444 !important;
    border-color: #c94444 !important;
}

.clear-selection {
    width: 34px;
    padding: 0 !important;
    font-size: 18px !important;
}

.bulk-toolbar.busy {
    opacity: .68;
}

.message-row {
    --delay: 0ms;
    display: grid;
    min-height: 88px;
    padding: 18px 6px;
    align-items: center;
    grid-template-columns: 18px 8px minmax(120px, 190px) minmax(200px, 1fr) auto;
    gap: 13px;
    border-bottom: 1px solid var(--line);
    animation: rise .35s both;
    animation-delay: var(--delay);
    transition: background .14s, padding .14s;
}

.message-row.selected {
    background: #fff7f2;
}

.message-row:focus-visible {
    position: relative;
    z-index: 1;
    outline: 3px solid rgba(239, 111, 59, .2);
    outline-offset: -3px;
}

.message-checkbox {
    opacity: .42;
    transition: opacity .15s;
}

.message-row:hover .message-checkbox,
.message-row.selected .message-checkbox,
.message-checkbox:focus {
    opacity: 1;
}

.message-row:hover {
    margin: 0 -12px;
    padding-right: 18px;
    padding-left: 18px;
    background: #fbfcfc;
}

.unread-dot {
    width: 6px;
    height: 6px;
    background: transparent;
    border-radius: 50%;
}

.message-row.unread .unread-dot {
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-wash);
}

.sender {
    min-width: 0;
    overflow: hidden;
    color: #47545f;
    font-size: 12px;
    font-weight: 650;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-row.unread .sender,
.message-row.unread h2 {
    color: var(--ink);
    font-weight: 800;
}

.message-content {
    min-width: 0;
}

.message-content h2 {
    margin: 0 0 7px;
    overflow: hidden;
    color: #35434e;
    font-size: 13px;
    font-weight: 680;
    line-height: 1.25;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-content p {
    margin: 0;
    overflow: hidden;
    color: #849099;
    font-size: 12px;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-meta {
    display: flex;
    align-self: start;
    align-items: center;
    gap: 7px;
    color: #7f8b94;
    font-size: 10px;
    font-weight: 650;
    white-space: nowrap;
}

.attachment {
    color: #9aa4ab;
    font-size: 18px;
    line-height: 1;
}

.loading-state,
.empty-state {
    display: grid;
    min-height: 420px;
    padding: 50px 20px;
    place-items: center;
    align-content: center;
    color: var(--muted);
    text-align: center;
}

.loading-state p {
    margin: 15px 0 0;
    font-size: 13px;
}

.spinner {
    width: 26px;
    height: 26px;
    border: 3px solid #e8ecee;
    border-top-color: var(--accent);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

.empty-icon {
    display: grid;
    width: 55px;
    height: 55px;
    margin-bottom: 17px;
    place-items: center;
    color: var(--accent);
    background: var(--accent-wash);
    border-radius: 16px;
    font-size: 23px;
}

.empty-state h2 {
    margin: 0 0 8px;
    color: var(--ink);
    font-size: 17px;
}

.empty-state p {
    max-width: 410px;
    margin: 0;
    font-size: 13px;
    line-height: 1.55;
}

.empty-state button {
    margin-top: 18px;
    padding: 9px 14px;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
}

.page-shade {
    display: none;
}

.toast {
    position: fixed;
    z-index: 30;
    right: 20px;
    bottom: 20px;
    padding: 12px 16px;
    color: #fff;
    background: var(--navy);
    border-radius: 9px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, .18);
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    transform: translateY(10px);
    transition: opacity .2s, transform .2s;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.reader-open {
    overflow: hidden;
}

.reader-overlay {
    position: fixed;
    z-index: 40;
    inset: 0;
    display: flex;
    justify-content: flex-end;
}

.reader-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(9, 23, 32, .42);
    backdrop-filter: blur(2px);
    animation: fade-in .2s both;
}

.reader-panel {
    position: relative;
    z-index: 1;
    width: min(760px, calc(100% - 80px));
    height: 100%;
    background: #fff;
    box-shadow: -24px 0 70px rgba(9, 23, 32, .2);
    overflow-y: auto;
    animation: reader-in .24s ease-out both;
}

.reader-toolbar {
    position: sticky;
    z-index: 2;
    top: 0;
    display: flex;
    min-height: 67px;
    padding: 12px 24px;
    align-items: center;
    gap: 14px;
    background: rgba(255, 255, 255, .96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}

.reader-toolbar .reader-close {
    width: 39px;
    padding: 0;
    color: var(--ink);
    font-size: 18px;
}

.reader-nav {
    padding-left: 6px;
    border-left: 1px solid var(--line);
}

.reader-nav button {
    width: 34px;
    padding: 0;
}

.reader-actions {
    margin-left: auto;
}

.reader-move {
    border-left-color: var(--line);
}

.reader-content {
    padding: 45px clamp(26px, 6vw, 68px) 80px;
}

.reader-folder {
    margin: 0 0 9px;
    color: var(--accent);
    font-size: 10px;
    font-weight: 850;
    letter-spacing: 1.4px;
    text-transform: uppercase;
}

.reader-content > h1 {
    margin: 0;
    color: var(--ink);
    font-size: clamp(25px, 4vw, 36px);
    line-height: 1.18;
    letter-spacing: -1.2px;
    overflow-wrap: anywhere;
}

.reader-sender-row {
    display: grid;
    margin: 30px 0 32px;
    padding-bottom: 25px;
    align-items: start;
    grid-template-columns: 42px minmax(0, 1fr) auto;
    gap: 13px;
    border-bottom: 1px solid var(--line);
}

.reader-avatar {
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    color: #fff;
    background: var(--navy-soft);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 800;
}

.reader-addresses {
    min-width: 0;
    display: flex;
    align-items: flex-start;
    flex-direction: column;
}

.reader-addresses > strong {
    max-width: 100%;
    overflow: hidden;
    color: #273640;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reader-addresses > button {
    margin: 4px 0 0;
    padding: 0;
    color: var(--muted);
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 10px;
}

.recipient-details {
    width: 100%;
    margin-top: 10px;
    padding: 10px 12px;
    background: var(--soft);
    border-radius: 8px;
}

.recipient-details p {
    display: grid;
    margin: 0;
    grid-template-columns: 42px minmax(0, 1fr);
    gap: 7px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
}

.recipient-details p + p {
    margin-top: 5px;
}

.recipient-details b {
    color: #53616c;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.reader-sender-row time {
    color: var(--muted);
    font-size: 10px;
    white-space: nowrap;
}

.reader-attachments {
    display: flex;
    margin: -8px 0 28px;
    flex-wrap: wrap;
    gap: 8px;
}

.attachment-chip {
    display: flex;
    min-height: 38px;
    padding: 8px 11px;
    align-items: center;
    gap: 8px;
    background: var(--soft);
    border: 1px solid var(--line);
    border-radius: 9px;
    text-decoration: none;
    transition: border-color .15s, background .15s;
}

.attachment-chip:hover {
    background: #fff8f4;
    border-color: #efb59c;
}

.attachment-chip strong {
    max-width: 220px;
    overflow: hidden;
    color: #45535e;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-chip small {
    color: var(--muted);
    font-size: 9px;
}

.reader-body {
    color: #34434e;
    font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
    font-size: 13px;
    line-height: 1.75;
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

.settings-open,
.cleanup-open {
    overflow: hidden;
}

.settings-overlay,
.rule-editor-overlay,
.cleanup-overlay {
    position: fixed;
    z-index: 50;
    inset: 0;
    display: grid;
    padding: 20px;
    place-items: center;
}

.settings-backdrop,
.rule-editor-backdrop,
.cleanup-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(8, 22, 31, .56);
    backdrop-filter: blur(4px);
    animation: fade-in .2s both;
}

.settings-panel {
    position: relative;
    z-index: 1;
    display: flex;
    width: min(100%, 980px);
    height: min(100%, 820px);
    flex-direction: column;
    background: #f7f9fa;
    border: 1px solid rgba(255, 255, 255, .4);
    border-radius: 20px;
    box-shadow: 0 30px 100px rgba(7, 20, 29, .3);
    overflow: hidden;
    animation: settings-in .22s ease-out both;
}

.settings-header {
    display: flex;
    min-height: 86px;
    padding: 20px 28px;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    background: var(--navy);
}

.settings-header p,
.rule-editor > header p {
    margin: 0 0 5px;
    color: #8299a5;
    font-size: 9px;
    font-weight: 850;
    letter-spacing: 2px;
}

.settings-header h1 {
    margin: 0;
    font-size: 23px;
    letter-spacing: -.6px;
}

.settings-header > button,
.rule-editor > header > button {
    display: grid;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    color: #b9c7ce;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 10px;
    cursor: pointer;
    font-size: 22px;
}

.settings-header > button:hover,
.rule-editor > header > button:hover {
    color: #fff;
    background: rgba(255, 255, 255, .12);
}

.settings-content {
    min-height: 0;
    padding: 26px 30px 38px;
    flex: 1;
    overflow-y: auto;
}

.settings-account-card {
    display: flex;
    padding: 18px 20px;
    align-items: center;
    gap: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 7px 22px rgba(20, 35, 47, .045);
}

.settings-account-avatar {
    display: grid;
    width: 43px;
    height: 43px;
    flex: 0 0 auto;
    place-items: center;
    color: #fff;
    background: var(--navy-soft);
    border-radius: 50%;
    font-size: 14px;
    font-weight: 850;
}

.settings-account-card > div {
    min-width: 0;
    flex: 1;
}

.settings-account-card strong {
    display: block;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.settings-account-card p {
    margin: 4px 0 0;
    color: var(--muted);
    font-size: 10px;
}

.connection-badge {
    padding: 5px 9px;
    color: #237a52;
    background: #eaf8f1;
    border-radius: 999px;
    font-size: 9px;
    font-weight: 850;
}

.rules-section {
    margin-top: 30px;
}

.rules-heading {
    display: flex;
    margin-bottom: 18px;
    align-items: flex-end;
    justify-content: space-between;
    gap: 20px;
}

.settings-kicker {
    margin: 0 0 5px;
    color: var(--accent);
    font-size: 9px;
    font-weight: 850;
    letter-spacing: 1.5px;
}

.rules-heading h2 {
    margin: 0 0 4px;
    font-size: 24px;
    letter-spacing: -.7px;
}

.rules-heading > div > span {
    color: var(--muted);
    font-size: 11px;
}

.add-rule-button {
    min-height: 39px;
    padding: 0 15px;
    color: #fff;
    background: var(--accent);
    border: 0;
    border-radius: 9px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
    box-shadow: 0 8px 18px rgba(239, 111, 59, .2);
}

.add-rule-button:hover {
    background: var(--accent-dark);
}

.add-rule-button:disabled {
    opacity: .5;
    cursor: wait;
}

.rules-warning {
    display: grid;
    margin-bottom: 14px;
    padding: 13px 15px;
    align-items: start;
    grid-template-columns: 25px minmax(0, 1fr);
    gap: 10px;
    color: #77511c;
    background: #fff8df;
    border: 1px solid #f2dfa0;
    border-radius: 11px;
}

.rules-warning > span {
    display: grid;
    width: 23px;
    height: 23px;
    place-items: center;
    color: #fff;
    background: #d99c2b;
    border-radius: 50%;
    font-size: 11px;
    font-weight: 900;
}

.rules-warning p {
    margin: 1px 0 0;
    font-size: 10px;
    line-height: 1.55;
}

.rules-status,
.rules-empty {
    display: grid;
    min-height: 210px;
    padding: 35px 20px;
    place-items: center;
    align-content: center;
    color: var(--muted);
    background: #fff;
    border: 1px dashed #dce3e6;
    border-radius: 13px;
    text-align: center;
}

.rules-status p,
.rules-empty p {
    max-width: 450px;
    margin: 13px 0 0;
    font-size: 11px;
    line-height: 1.55;
}

.rules-status.error {
    color: #a83c3c;
    background: #fff8f8;
    border-color: #efcaca;
}

.rules-empty > span {
    display: grid;
    width: 46px;
    height: 46px;
    margin-bottom: 12px;
    place-items: center;
    color: var(--accent);
    background: var(--accent-wash);
    border-radius: 13px;
    font-size: 22px;
}

.rules-empty strong {
    font-size: 13px;
}

.rules-list {
    display: grid;
    gap: 10px;
}

.rule-card {
    display: grid;
    min-height: 112px;
    padding: 17px 18px;
    align-items: start;
    grid-template-columns: 28px minmax(0, 1fr) auto;
    gap: 13px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 13px;
    box-shadow: 0 5px 16px rgba(20, 35, 47, .035);
}

.rule-card.disabled {
    opacity: .64;
}

.rule-card.rule-error {
    border-color: #efcaca;
}

.rule-priority {
    display: grid;
    width: 26px;
    height: 26px;
    place-items: center;
    color: #7d8a94;
    background: var(--soft);
    border-radius: 7px;
    font-size: 10px;
    font-weight: 800;
}

.rule-card-body {
    min-width: 0;
}

.rule-title-row {
    display: flex;
    min-width: 0;
    align-items: center;
    flex-wrap: wrap;
    gap: 7px;
}

.rule-title-row h3 {
    max-width: 100%;
    margin: 1px 0 8px;
    overflow: hidden;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rule-badge {
    margin: -6px 0 2px;
    padding: 4px 7px;
    color: #697781;
    background: #edf1f3;
    border-radius: 999px;
    font-size: 8px;
    font-weight: 800;
}

.rule-badge.error {
    color: #a83c3c;
    background: #fff0f0;
}

.rule-summary {
    display: grid;
    gap: 5px;
}

.rule-summary p {
    display: grid;
    margin: 0;
    grid-template-columns: 45px minmax(0, 1fr);
    gap: 8px;
    color: var(--muted);
    font-size: 10px;
    line-height: 1.4;
}

.rule-summary span {
    color: #9aa4ab;
    font-size: 8px;
    font-weight: 850;
    letter-spacing: .7px;
}

.rule-summary b {
    color: #53616c;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.rule-controls {
    display: flex;
    align-items: flex-end;
    flex-direction: column;
    gap: 16px;
}

.rule-switch {
    position: relative;
    width: 38px;
    height: 21px;
    padding: 0;
    background: #d7dee2;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    transition: background .16s;
}

.rule-switch span {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 15px;
    height: 15px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 5px rgba(0, 0, 0, .16);
    transition: transform .16s;
}

.rule-switch.on {
    background: var(--accent);
}

.rule-switch.on span {
    transform: translateX(17px);
}

.rule-switch:disabled {
    opacity: .45;
    cursor: not-allowed;
}

.rule-card-actions {
    display: flex;
    gap: 5px;
}

.rule-card-actions button {
    min-height: 28px;
    padding: 0 9px;
    color: #687680;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 7px;
    cursor: pointer;
    font-size: 9px;
    font-weight: 750;
}

.rule-card-actions button:hover {
    color: var(--accent-dark);
    border-color: #efb59c;
}

.rule-card-actions .remove-rule:hover {
    color: #fff;
    background: #c94444;
    border-color: #c94444;
}

.rule-editor-overlay {
    z-index: 60;
}

.rule-editor {
    position: relative;
    z-index: 1;
    width: min(100%, 560px);
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 30px 100px rgba(7, 20, 29, .34);
    overflow-y: auto;
    animation: settings-in .2s ease-out both;
}

.rule-editor > header {
    position: sticky;
    z-index: 2;
    top: 0;
    display: flex;
    min-height: 76px;
    padding: 17px 22px;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    background: var(--navy);
}

.rule-editor > header h2 {
    margin: 0;
    font-size: 19px;
}

.rule-editor form {
    padding: 23px 25px 26px;
}

.rule-editor form > label,
.rule-editor fieldset > label:not(.rule-check),
.rule-editor fieldset > div > label {
    display: block;
    margin: 13px 0 7px;
    color: #3d4b56;
    font-size: 11px;
    font-weight: 750;
}

.rule-editor input[type="text"],
.rule-editor select {
    width: 100%;
    height: 43px;
    padding: 0 12px;
    color: var(--ink);
    background: #fafbfb;
    border: 1px solid #dce3e6;
    border-radius: 9px;
}

.rule-editor input[type="text"]:focus,
.rule-editor select:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(239, 111, 59, .08);
    outline: 0;
}

.rule-editor fieldset {
    margin: 23px 0 0;
    padding: 14px 16px 17px;
    background: #fafbfb;
    border: 1px solid var(--line);
    border-radius: 11px;
}

.rule-editor legend {
    padding: 0 7px;
    color: var(--accent-dark);
    background: #fff;
    font-size: 9px;
    font-weight: 850;
    letter-spacing: .7px;
    text-transform: uppercase;
}

.rule-check {
    display: flex;
    margin-top: 14px;
    align-items: center;
    gap: 9px;
    color: #53616c;
    cursor: pointer;
    font-size: 10px;
    font-weight: 650;
}

.rule-check input {
    width: 15px;
    height: 15px;
    margin: 0;
    accent-color: var(--accent);
}

.rule-form-actions {
    display: flex;
    margin-top: 24px;
    justify-content: flex-end;
    gap: 8px;
}

.rule-form-actions button {
    min-height: 40px;
    padding: 0 15px;
    color: #62707b;
    background: #fff;
    border: 1px solid #dce3e6;
    border-radius: 9px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
}

.rule-form-actions .rule-save-button {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.rule-form-actions .rule-save-button:hover {
    background: var(--accent-dark);
}

.rule-form-actions button:disabled {
    opacity: .5;
    cursor: wait;
}

.cleanup-overlay {
    z-index: 65;
}

.cleanup-dialog {
    position: relative;
    z-index: 1;
    width: min(100%, 540px);
    max-height: calc(100vh - 40px);
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 30px 100px rgba(7, 20, 29, .34);
    overflow-y: auto;
    animation: settings-in .2s ease-out both;
}

.cleanup-dialog > header {
    display: flex;
    min-height: 78px;
    padding: 17px 22px;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    background: var(--navy);
}

.cleanup-dialog > header p {
    margin: 0 0 5px;
    color: #8299a5;
    font-size: 9px;
    font-weight: 850;
    letter-spacing: 2px;
}

.cleanup-dialog > header h2 {
    margin: 0;
    font-size: 19px;
}

.cleanup-dialog > header > button {
    display: grid;
    width: 38px;
    height: 38px;
    padding: 0;
    place-items: center;
    color: #b9c7ce;
    background: rgba(255, 255, 255, .07);
    border: 1px solid rgba(255, 255, 255, .1);
    border-radius: 10px;
    cursor: pointer;
    font-size: 22px;
}

.cleanup-dialog > header > button:hover {
    color: #fff;
    background: rgba(255, 255, 255, .12);
}

.cleanup-dialog form {
    padding: 25px 27px 27px;
}

.cleanup-icon {
    display: grid;
    width: 54px;
    height: 54px;
    margin-bottom: 16px;
    place-items: center;
    color: var(--accent);
    background: var(--accent-wash);
    border-radius: 15px;
    font-size: 25px;
}

.cleanup-intro {
    margin: 0 0 22px;
    color: #56646e;
    font-size: 12px;
    line-height: 1.65;
}

.cleanup-dialog form > label {
    display: block;
    margin-bottom: 8px;
    color: #3d4b56;
    font-size: 11px;
    font-weight: 800;
}

.cleanup-dialog select {
    width: 100%;
    height: 44px;
    padding: 0 12px;
    color: var(--ink);
    background: #fafbfb;
    border: 1px solid #dce3e6;
    border-radius: 9px;
}

.cleanup-dialog select:focus {
    background: #fff;
    border-color: var(--accent);
    box-shadow: 0 0 0 4px rgba(239, 111, 59, .08);
    outline: 0;
}

.cleanup-summary {
    display: grid;
    margin-top: 18px;
    padding: 13px 14px;
    align-items: start;
    grid-template-columns: 22px minmax(0, 1fr);
    gap: 9px;
    color: #66747e;
    background: #f6f8f9;
    border: 1px solid var(--line);
    border-radius: 10px;
}

.cleanup-summary > span {
    display: grid;
    width: 20px;
    height: 20px;
    place-items: center;
    color: #fff;
    background: #81939e;
    border-radius: 50%;
    font-size: 10px;
    font-weight: 850;
}

.cleanup-summary p,
.cleanup-progress {
    margin: 0;
    font-size: 10px;
    line-height: 1.55;
}

.cleanup-summary strong {
    color: #35444f;
}

.cleanup-progress {
    margin-top: 14px;
    padding: 11px 13px;
    color: var(--accent-dark);
    background: var(--accent-wash);
    border-radius: 9px;
    font-weight: 750;
}

.cleanup-actions {
    display: flex;
    margin-top: 22px;
    justify-content: flex-end;
    gap: 8px;
}

.cleanup-actions button {
    min-height: 41px;
    padding: 0 15px;
    color: #62707b;
    background: #fff;
    border: 1px solid #dce3e6;
    border-radius: 9px;
    cursor: pointer;
    font-size: 11px;
    font-weight: 800;
}

.cleanup-actions .cleanup-submit {
    color: #fff;
    background: var(--accent);
    border-color: var(--accent);
}

.cleanup-actions .cleanup-submit:hover {
    background: var(--accent-dark);
}

.cleanup-actions button:disabled,
.cleanup-dialog > header > button:disabled,
.cleanup-dialog select:disabled {
    opacity: .5;
    cursor: wait;
}

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

@keyframes rise {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toolbar-in {
    from { opacity: 0; transform: translateY(-3px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes reader-in {
    from { transform: translateX(25px); opacity: .6; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes settings-in {
    from { opacity: .65; transform: translateY(10px) scale(.985); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 850px) {
    .mail-view {
        display: block;
    }

    .sidebar {
        position: fixed;
        z-index: 20;
        left: 0;
        width: 265px;
        transform: translateX(-102%);
        transition: transform .22s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .page-shade {
        position: fixed;
        z-index: 15;
        inset: 0;
        display: block;
        background: rgba(9, 23, 32, .42);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s;
    }

    .page-shade.show {
        opacity: 1;
        pointer-events: auto;
    }

    .mail-main {
        padding: 0 24px 35px;
    }

    .menu-button {
        display: grid;
    }

    .message-row {
        grid-template-columns: 18px 8px minmax(95px, 145px) minmax(180px, 1fr) auto;
    }

    .bulk-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .bulk-actions {
        width: 100%;
        overflow-x: auto;
        padding-bottom: 2px;
    }
}

@media (max-width: 620px) {
    .login-card {
        padding: 30px 24px;
        border-radius: 17px;
    }

    .brand-login {
        margin-bottom: 34px;
    }

    .mail-main {
        padding: 0 16px 25px;
    }

    .mail-header {
        min-height: auto;
        padding: 18px 0 15px;
        align-items: stretch;
        flex-direction: column;
        gap: 15px;
    }

    .heading-row {
        width: 100%;
    }

    .heading-row > .heading-copy {
        min-width: 0;
        flex: 1;
    }

    .header-actions {
        margin-left: auto;
    }

    .mailbox-cleanup-button,
    .empty-trash-button {
        width: 39px;
        padding: 0;
        justify-content: center;
    }

    .mailbox-cleanup-button b,
    .empty-trash-button b {
        display: none;
    }

    .search-box {
        width: 100%;
    }

    .search-box kbd {
        display: none;
    }

    .message-row {
        min-height: 96px;
        padding: 15px 3px;
        align-items: start;
        grid-template-columns: 18px 7px minmax(0, 1fr) auto;
        gap: 9px;
    }

    .message-row:hover {
        margin: 0;
        padding-right: 3px;
        padding-left: 3px;
    }

    .sender {
        grid-column: 3;
        font-size: 12px;
    }

    .message-content {
        grid-column: 3 / 5;
    }

    .message-meta {
        grid-column: 4;
        grid-row: 1;
    }

    .message-content h2 {
        margin-bottom: 5px;
    }

    .unread-dot {
        margin-top: 5px;
    }

    .message-checkbox {
        margin-top: 1px;
        opacity: .7;
    }

    .list-toolbar {
        min-height: 47px;
    }

    .reader-panel {
        width: 100%;
    }

    .reader-toolbar {
        padding: 10px 14px;
        flex-wrap: wrap;
    }

    .reader-actions {
        width: 100%;
        margin: 0;
        overflow-x: auto;
    }

    .reader-actions > button:first-child {
        margin-left: auto;
    }

    .reader-content {
        padding: 30px 20px 60px;
    }

    .reader-sender-row {
        grid-template-columns: 38px minmax(0, 1fr);
    }

    .reader-avatar {
        width: 38px;
        height: 38px;
    }

    .reader-sender-row time {
        grid-column: 2;
    }

    .bulk-toolbar {
        margin: 0 -4px;
        padding-right: 4px;
        padding-left: 4px;
    }

    .bulk-actions > button,
    .move-control button {
        min-height: 36px;
    }

    .settings-overlay,
    .rule-editor-overlay,
    .cleanup-overlay {
        padding: 0;
    }

    .settings-panel,
    .rule-editor,
    .cleanup-dialog {
        width: 100%;
        height: 100%;
        max-height: none;
        border-radius: 0;
    }

    .settings-header {
        min-height: 72px;
        padding: 14px 17px;
    }

    .settings-content {
        padding: 18px 15px 30px;
    }

    .rules-heading {
        align-items: stretch;
        flex-direction: column;
        gap: 13px;
    }

    .add-rule-button {
        width: 100%;
    }

    .rule-card {
        padding: 14px 13px;
        grid-template-columns: 24px minmax(0, 1fr);
        gap: 10px;
    }

    .rule-controls {
        grid-column: 2;
        align-items: center;
        flex-direction: row;
        justify-content: space-between;
    }

    .rule-editor form {
        padding: 19px 17px 28px;
    }

    .cleanup-dialog form {
        padding: 22px 17px 28px;
    }

    .cleanup-actions {
        align-items: stretch;
        flex-direction: column-reverse;
    }

    .cleanup-actions button {
        width: 100%;
    }
}
