:root {
    color-scheme: light;
    --obsidian: #041f1b;
    --emerald-950: #062f29;
    --emerald-900: #083d35;
    --emerald-800: #0c5248;
    --gold-700: #9e7a25;
    --gold-600: #b98f32;
    --gold-400: #d8bd72;
    --gold-200: #efe2b7;
    --ivory: #fbfaf6;
    --porcelain: #f5f3ec;
    --panel: rgba(255, 255, 255, 0.92);
    --line: rgba(10, 49, 43, 0.14);
    --line-strong: rgba(184, 143, 50, 0.38);
    --ink: #10221f;
    --muted: #68736e;
    --danger: #a13b32;
    --success: #137a55;
    --shadow: 0 24px 70px rgba(4, 31, 27, 0.18);
    --gold-sheen: linear-gradient(135deg, #8f6c1f 0%, #d3b866 50%, #f5e9bd 100%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        radial-gradient(circle at 88% 8%, rgba(216, 189, 114, 0.2), transparent 32%),
        linear-gradient(135deg, #fbfaf6 0%, #f2efe6 48%, #ece5d4 100%);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

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

button,
.compose-button,
.pager a {
    min-height: 42px;
    border: 1px solid var(--line-strong);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.82);
    color: var(--emerald-950);
    cursor: pointer;
    padding: 0 15px;
    transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease, background 160ms ease;
}

button[type="submit"],
.compose-button {
    border-color: transparent;
    background: var(--gold-sheen);
    color: #10221f;
    font-weight: 850;
    box-shadow: 0 12px 24px rgba(158, 122, 37, 0.24);
}

button:hover,
.pager a:hover {
    border-color: var(--gold-600);
    box-shadow: 0 10px 26px rgba(4, 31, 27, 0.1);
    transform: translateY(-1px);
}

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

input:focus,
select:focus,
textarea:focus {
    border-color: var(--gold-600);
    box-shadow: 0 0 0 4px rgba(216, 189, 114, 0.22);
    background: white;
}

textarea {
    resize: vertical;
}

h1,
h2,
p {
    margin-top: 0;
}

h1,
h2,
.brand strong {
    letter-spacing: 0;
}

.muted,
small {
    color: var(--muted);
}

label {
    display: grid;
    gap: 7px;
    color: #52635d;
    font-size: 0.9rem;
    font-weight: 750;
}

.login-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    position: relative;
    overflow: hidden;
    background:
        linear-gradient(122deg, rgba(4, 31, 27, 0.96) 0%, rgba(6, 47, 41, 0.94) 38%, rgba(148, 119, 42, 0.86) 100%),
        var(--obsidian);
}

.login-shell::before {
    content: "";
    position: absolute;
    inset: -10% -8%;
    background-image: url("assets/zora-mail-logo.png");
    background-repeat: no-repeat;
    background-position: center;
    background-size: min(1080px, 115vw) auto;
    opacity: 0.11;
    filter: saturate(0.8);
}

.login-panel {
    width: min(480px, 100%);
    position: relative;
    z-index: 1;
    border: 1px solid rgba(239, 226, 183, 0.42);
    border-radius: 8px;
    background: rgba(251, 250, 246, 0.94);
    box-shadow: var(--shadow);
    padding: 34px;
    backdrop-filter: blur(18px);
}

.login-brand {
    display: grid;
    justify-items: start;
    gap: 8px;
    margin-bottom: 18px;
}

.login-brand img {
    width: 112px;
    height: 56px;
    object-fit: cover;
    object-position: left center;
    border-radius: 8px;
    box-shadow: 0 12px 28px rgba(4, 31, 27, 0.18);
}

.eyebrow {
    margin: 0;
    color: var(--gold-700);
    font-size: 0.76rem;
    font-weight: 900;
    text-transform: uppercase;
}

.login-panel h1 {
    margin-bottom: 4px;
    color: var(--emerald-950);
    font-size: clamp(2rem, 7vw, 3rem);
    line-height: 0.96;
}

.login-form,
.compose {
    display: grid;
    gap: 14px;
}

.create-mailbox {
    border-top: 1px solid var(--line);
    margin-top: 22px;
    padding-top: 18px;
}

.create-mailbox summary {
    cursor: pointer;
    color: var(--emerald-950);
    font-weight: 850;
}

.create-mailbox form {
    margin-top: 14px;
}

.domain-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: white;
    overflow: hidden;
}

.domain-input:focus-within {
    border-color: var(--gold-600);
    box-shadow: 0 0 0 4px rgba(216, 189, 114, 0.22);
}

.domain-input input {
    border: 0;
    border-radius: 0;
    box-shadow: none;
}

.domain-input span {
    color: var(--gold-700);
    font-weight: 800;
    padding: 0 12px;
    white-space: nowrap;
}

.tiny {
    margin-bottom: 0;
    font-size: 0.82rem;
}

.app-shell {
    min-height: 100vh;
    display: grid;
    grid-template-columns: 286px minmax(0, 1fr);
    background:
        linear-gradient(90deg, var(--emerald-950) 0, var(--emerald-950) 286px, transparent 286px),
        var(--porcelain);
}

.sidebar {
    display: flex;
    flex-direction: column;
    gap: 18px;
    border-right: 1px solid rgba(239, 226, 183, 0.2);
    background:
        linear-gradient(180deg, rgba(4, 31, 27, 0.98), rgba(8, 61, 53, 0.98) 58%, rgba(82, 76, 42, 0.98));
    color: white;
    padding: 22px;
}

.brand {
    display: flex;
    gap: 13px;
    align-items: center;
    padding-bottom: 6px;
}

.brand-mark {
    width: 54px;
    height: 54px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(239, 226, 183, 0.46);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 14px 34px rgba(0, 0, 0, 0.18);
    overflow: hidden;
}

.brand-mark img {
    width: 82px;
    height: 54px;
    object-fit: cover;
    object-position: left center;
}

.brand small,
.brand strong {
    display: block;
    overflow-wrap: anywhere;
}

.brand strong {
    color: #fffaf0;
    font-size: 1.12rem;
}

.brand small {
    color: rgba(239, 226, 183, 0.76);
}

.compose-button {
    width: 100%;
}

.folders {
    display: grid;
    gap: 5px;
    overflow: auto;
    padding-top: 6px;
}

.folders a,
.logout {
    color: rgba(255, 250, 240, 0.86);
    text-decoration: none;
    border: 1px solid transparent;
    border-radius: 8px;
    padding: 11px 12px;
    overflow-wrap: anywhere;
}

.folders a.active,
.folders a:hover {
    border-color: rgba(239, 226, 183, 0.26);
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.logout {
    margin-top: auto;
    color: #f1c2bc;
}

.mail {
    min-width: 0;
    display: grid;
    grid-template-rows: auto auto 1fr;
}

.toolbar {
    min-height: 76px;
    display: flex;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--line);
    background: rgba(251, 250, 246, 0.86);
    padding: 16px 20px;
    backdrop-filter: blur(14px);
}

.search {
    display: flex;
    gap: 9px;
    width: min(640px, 100%);
}

.pager {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.pager a {
    display: inline-grid;
    place-items: center;
    text-decoration: none;
}

.pager a.disabled {
    opacity: 0.42;
    pointer-events: none;
}

.pager span {
    color: var(--muted);
    font-weight: 750;
}

.alert {
    margin: 14px 20px 0;
    border-radius: 8px;
    padding: 12px 14px;
    font-weight: 750;
}

.alert.error {
    border: 1px solid rgba(161, 59, 50, 0.2);
    background: #fff0ed;
    color: var(--danger);
}

.alert.success {
    border: 1px solid rgba(19, 122, 85, 0.2);
    background: #e5f8ef;
    color: var(--success);
}

.mail-grid {
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(320px, 38%) minmax(0, 1fr);
}

.message-list {
    min-width: 0;
    overflow: auto;
    border-right: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.45);
}

.message-row {
    min-height: 88px;
    display: grid;
    gap: 5px;
    border-bottom: 1px solid rgba(10, 49, 43, 0.1);
    color: var(--ink);
    text-decoration: none;
    padding: 14px 18px;
    position: relative;
    transition: background 160ms ease, box-shadow 160ms ease;
}

.message-row::before {
    content: "";
    position: absolute;
    inset: 12px auto 12px 0;
    width: 3px;
    border-radius: 0 8px 8px 0;
    background: transparent;
}

.message-row:hover,
.message-row.selected {
    background: rgba(255, 255, 255, 0.88);
    box-shadow: inset 0 0 0 1px rgba(216, 189, 114, 0.16);
}

.message-row.selected::before,
.message-row.unread::before {
    background: var(--gold-sheen);
}

.message-row.unread .from,
.message-row.unread .subject {
    color: var(--emerald-950);
    font-weight: 850;
}

.from,
.subject,
.date {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.date {
    color: var(--muted);
    font-size: 0.83rem;
}

.paperclip {
    display: inline-block;
    width: 0.72rem;
    height: 0.72rem;
    border: 2px solid var(--gold-600);
    border-left-color: transparent;
    border-radius: 8px;
    text-indent: -999px;
    vertical-align: -1px;
}

.reader {
    min-width: 0;
    overflow: auto;
    background:
        linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(251, 250, 246, 0.98)),
        var(--panel);
}

.reader-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid var(--line);
    padding: 24px;
}

.reader-head h2 {
    margin-bottom: 12px;
    color: var(--emerald-950);
    font-size: clamp(1.22rem, 1.8vw, 1.72rem);
    overflow-wrap: anywhere;
}

.reader-head p {
    margin-bottom: 5px;
    overflow-wrap: anywhere;
}

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

.danger {
    color: var(--danger);
}

.attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    border-bottom: 1px solid var(--line);
    padding: 13px 24px;
    background: rgba(239, 226, 183, 0.16);
}

.attachments a {
    border: 1px solid rgba(184, 143, 50, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.72);
    color: var(--emerald-950);
    text-decoration: none;
    padding: 8px 10px;
}

.message-body {
    line-height: 1.58;
    max-width: 900px;
    padding: 28px;
    overflow-wrap: anywhere;
}

.message-body img {
    max-width: 100%;
    height: auto;
}

.empty {
    color: var(--muted);
    padding: 24px;
}

.reader-empty {
    min-height: 60vh;
    display: grid;
    place-items: center;
}

.compose-modal {
    position: fixed;
    inset: 0;
    display: none;
    align-items: flex-end;
    justify-content: flex-end;
    background: rgba(4, 31, 27, 0.52);
    padding: 24px;
    backdrop-filter: blur(8px);
}

.show-compose .compose-modal {
    display: flex;
}

.compose {
    width: min(700px, 100%);
    border: 1px solid rgba(239, 226, 183, 0.46);
    border-radius: 8px;
    background: rgba(251, 250, 246, 0.96);
    box-shadow: var(--shadow);
    padding: 20px;
}

.compose header,
.compose footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.compose h2 {
    margin-bottom: 0;
    color: var(--emerald-950);
    font-size: 1.16rem;
}

.file-input {
    border: 1px dashed rgba(184, 143, 50, 0.42);
    border-radius: 8px;
    background: rgba(239, 226, 183, 0.16);
    padding: 12px;
}

@media (max-width: 900px) {
    .app-shell {
        grid-template-columns: 1fr;
        background: var(--porcelain);
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(239, 226, 183, 0.22);
    }

    .folders {
        grid-auto-flow: column;
        grid-auto-columns: max-content;
    }

    .mail-grid {
        grid-template-columns: 1fr;
    }

    .reader {
        min-height: 60vh;
    }
}

@media (max-width: 640px) {
    .login-panel {
        padding: 24px;
    }

    .toolbar,
    .reader-head,
    .search {
        align-items: stretch;
        flex-direction: column;
    }

    .pager {
        flex-wrap: wrap;
    }

    .compose-modal {
        padding: 10px;
    }
}
