:root {
    color-scheme: dark;
    --bg: #07111d;
    --panel: rgba(13, 27, 43, 0.82);
    --panel-strong: #102337;
    --line: rgba(147, 197, 253, 0.16);
    --text: #eef7ff;
    --muted: #91a8bc;
    --accent: #67e8f9;
    --accent-strong: #22d3ee;
    --shadow: 0 24px 80px rgba(0, 0, 0, 0.38);
}

* { box-sizing: border-box; }

body {
    min-height: 100vh;
    margin: 0;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 15% 10%, rgba(34, 211, 238, 0.08), transparent 28rem),
        radial-gradient(circle at 90% 75%, rgba(129, 140, 248, 0.1), transparent 30rem),
        var(--bg);
    color: var(--text);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input { font: inherit; }

button, .button-link {
    border: 0;
    border-radius: 0.8rem;
    background: linear-gradient(135deg, var(--accent), var(--accent-strong));
    color: #05202a;
    cursor: pointer;
    font-weight: 800;
    padding: 0.85rem 1.15rem;
    text-decoration: none;
    transition: transform 160ms ease, box-shadow 160ms ease;
}

button:hover, .button-link:hover { transform: translateY(-1px); box-shadow: 0 10px 30px rgba(34, 211, 238, 0.2); }

.button-secondary {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--line);
    color: var(--text);
}

.ambient {
    position: fixed;
    width: 24rem;
    height: 24rem;
    border-radius: 999px;
    filter: blur(100px);
    opacity: 0.16;
    pointer-events: none;
}

.ambient-one { background: #22d3ee; left: -8rem; top: 8rem; }
.ambient-two { background: #818cf8; bottom: -8rem; right: -8rem; }
.shell { width: min(1180px, calc(100% - 2rem)); margin: 0 auto; padding: 2rem 0 4rem; position: relative; }

.login-card, .search-card, .message-list, .reader {
    background: var(--panel);
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    backdrop-filter: blur(20px);
}

.login-card { width: min(460px, 100%); margin: 10vh auto 0; border-radius: 1.4rem; padding: 2rem; }
.brand-mark { display: grid; place-items: center; width: 3.2rem; height: 3.2rem; border-radius: 1rem; background: rgba(103, 232, 249, 0.12); color: var(--accent); font-size: 1.5rem; font-weight: 900; }
.eyebrow { margin: 1rem 0 0.35rem; color: var(--accent); font-size: 0.72rem; font-weight: 900; letter-spacing: 0.14em; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin-bottom: 0.55rem; font-size: clamp(1.8rem, 4vw, 2.6rem); }
h2 { margin-bottom: 0.4rem; }
.lede, .search-card p, .empty-state p { color: var(--muted); line-height: 1.6; }
.stack { display: grid; gap: 0.75rem; margin-top: 1.5rem; }
label { color: #c7d8e8; font-size: 0.9rem; font-weight: 700; }

input {
    width: 100%;
    min-width: 0;
    border: 1px solid var(--line);
    border-radius: 0.8rem;
    outline: none;
    background: rgba(3, 13, 24, 0.72);
    color: var(--text);
    padding: 0.9rem 1rem;
}

input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.12); }
.alert { margin: 1rem 0; border: 1px solid rgba(252, 165, 165, 0.35); border-radius: 0.8rem; background: rgba(127, 29, 29, 0.22); color: #fecaca; padding: 0.9rem 1rem; }
.topbar, .inbox-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.topbar { margin-bottom: 1.5rem; }
.topbar .eyebrow, .inbox-header .eyebrow { margin-top: 0; }
.search-card { display: grid; grid-template-columns: 0.9fr 1.3fr; align-items: end; gap: 2rem; border-radius: 1.3rem; padding: 1.5rem; }
.mailbox-form { display: flex; align-items: stretch; gap: 0.75rem; }
.address-input { display: flex; flex: 1; align-items: center; border: 1px solid var(--line); border-radius: 0.85rem; background: rgba(3, 13, 24, 0.72); overflow: hidden; }
.address-input:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(103, 232, 249, 0.12); }
.address-input input { border: 0; border-radius: 0; background: transparent; box-shadow: none; }
.address-input span { color: var(--muted); padding-right: 1rem; white-space: nowrap; }
.inbox-header { margin: 2rem 0 1rem; }
.actions { display: flex; gap: 0.7rem; }
.inbox-grid { display: grid; grid-template-columns: minmax(300px, 0.85fr) minmax(0, 1.35fr); gap: 1rem; align-items: start; }
.message-list, .reader { min-height: 430px; border-radius: 1.2rem; overflow: hidden; }
.message-row { display: grid; gap: 0.32rem; border-bottom: 1px solid var(--line); color: var(--text); padding: 1rem 1.1rem; text-decoration: none; transition: background 150ms ease; }
.message-row:hover, .message-row.is-active { background: rgba(103, 232, 249, 0.08); }
.message-row.is-unread strong::before { content: ''; display: inline-block; width: 0.45rem; height: 0.45rem; margin-right: 0.5rem; border-radius: 50%; background: var(--accent); vertical-align: 0.08rem; }
.sender { color: #bad0e3; font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snippet, time { color: var(--muted); font-size: 0.8rem; }
.snippet { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reader { padding: 1.4rem; }
.reader .eyebrow { margin-top: 0; }
.message-meta { display: grid; gap: 0.5rem; margin: 1.2rem 0; border-block: 1px solid var(--line); padding: 1rem 0; }
.message-meta div { display: grid; grid-template-columns: 5rem 1fr; gap: 0.7rem; }
.message-meta dt { color: var(--muted); }
.message-meta dd { margin: 0; overflow-wrap: anywhere; }
.message-body { margin: 0; min-height: 220px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; color: #dceaf5; font: 0.92rem/1.65 ui-monospace, SFMono-Regular, Consolas, monospace; }
.empty-state { min-height: 430px; display: grid; place-content: center; justify-items: center; padding: 2rem; text-align: center; }
.empty-state.compact { min-height: 360px; }
.empty-state span { color: var(--accent); font-size: 2rem; }
.toast { position: fixed; right: 1.2rem; bottom: 1.2rem; transform: translateY(2rem); opacity: 0; border: 1px solid var(--line); border-radius: 0.75rem; background: var(--panel-strong); padding: 0.8rem 1rem; transition: 180ms ease; }
.toast.show { transform: translateY(0); opacity: 1; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; }

@media (max-width: 800px) {
    .search-card, .inbox-grid { grid-template-columns: 1fr; }
    .mailbox-form { flex-direction: column; }
    .reader { min-height: 320px; }
}

@media (max-width: 560px) {
    .shell { width: min(100% - 1rem, 1180px); padding-top: 1rem; }
    .topbar, .inbox-header { align-items: flex-start; flex-direction: column; }
    .actions { width: 100%; }
    .actions > * { flex: 1; text-align: center; }
    .address-input span { font-size: 0.78rem; }
}
