:root {
    --bg: #070708;
    --bg-elevated: #0d0d10;
    --surface: #121216;
    --surface-hover: #17171c;
    --border: #23232b;
    --border-soft: #1a1a21;
    --text: #ececef;
    --text-muted: #8b8b96;
    --text-dim: #5e5e68;
    --accent: #8fd4c4;
    --accent-dim: rgba(143, 212, 196, 0.12);
    --danger: #d98a8a;
    --danger-dim: rgba(217, 138, 138, 0.12);
    --ok: #8fd4c4;
    --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
    --radius: 16px;
    --tap: 44px;
    --font: "IBM Plex Sans", "Segoe UI", system-ui, sans-serif;
    --mono: "IBM Plex Mono", ui-monospace, monospace;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--accent);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

.page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--border-soft);
    background: #09090b;
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    color: var(--text);
    font-weight: 600;
    letter-spacing: 0.18em;
    font-size: 0.78rem;
    text-decoration: none;
}

.brand:hover {
    text-decoration: none;
    color: var(--text);
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 6px;
}

.nav-links a,
.nav-links button {
    appearance: none;
    border: 0;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 0.92rem;
    padding: 8px 12px;
    border-radius: 10px;
    cursor: pointer;
}

.nav-links a:hover,
.nav-links button:hover,
.nav-links a.active {
    color: var(--text);
    background: var(--surface);
    text-decoration: none;
}

.nav-toggle {
    display: none;
    width: var(--tap);
    height: var(--tap);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    border-radius: 12px;
    cursor: pointer;
}

.wrap {
    width: min(920px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 64px;
    flex: 1;
}

.hero {
    padding: 72px 0 40px;
}

.hero h1,
.auth-card h1,
.inbox-head h1,
.account-card h1 {
    font-size: clamp(1.8rem, 4vw, 2.6rem);
    font-weight: 600;
    letter-spacing: -0.03em;
    margin: 0 0 12px;
}

.lede {
    color: var(--text-muted);
    font-size: 1.05rem;
    max-width: 38rem;
    margin: 0 0 28px;
}

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

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--tap);
    padding: 0 18px;
    border-radius: 12px;
    border: 1px solid transparent;
    font: inherit;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
}

.btn:hover {
    text-decoration: none;
}

.btn-primary {
    background: var(--accent);
    color: #08110f;
}

.btn-primary:hover {
    filter: brightness(1.05);
}

.btn-ghost {
    background: transparent;
    color: var(--text);
    border-color: var(--border);
}

.btn-ghost:hover {
    background: var(--surface);
}

.btn-danger {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: transparent;
}

.btn-danger:hover {
    background: rgba(217, 138, 138, 0.2);
}

.btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
}

.auth-card,
.account-card,
.message-view,
.empty-state {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.auth-card {
    width: min(460px, 100%);
    margin: 48px auto;
    padding: 28px 24px 24px;
}

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 16px;
}

label {
    font-size: 0.82rem;
    color: var(--text-muted);
}

input {
    width: 100%;
    min-height: var(--tap);
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #0b0b0e;
    color: var(--text);
    font: inherit;
    padding: 0 14px;
    outline: none;
}

input:focus {
    border-color: #3d5e57;
    box-shadow: 0 0 0 3px var(--accent-dim);
}

.hint,
.preview,
.meta {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.preview strong {
    color: var(--text);
    font-family: var(--mono);
    font-weight: 500;
}

.error {
    color: var(--danger);
    background: var(--danger-dim);
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.92rem;
    margin: 0 0 14px;
    display: none;
}

.error.show {
    display: block;
}

.ok {
    color: var(--ok);
    font-size: 0.88rem;
}

.auth-foot {
    margin-top: 18px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.inbox-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 22px;
}

.inbox-head p {
    margin: 0;
    color: var(--text-muted);
    font-family: var(--mono);
    font-size: 0.92rem;
}

.message-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--bg-elevated);
}

.message-row {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 6px 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border-soft);
    color: inherit;
    text-decoration: none;
    background: transparent;
    cursor: pointer;
    text-align: left;
    font: inherit;
    width: 100%;
}

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

.message-row:hover {
    background: var(--surface-hover);
    text-decoration: none;
}

.message-row.unread .sender,
.message-row.unread .subject {
    color: var(--text);
    font-weight: 600;
}

.sender {
    color: var(--text);
}

.subject {
    grid-column: 1;
    color: var(--text-muted);
    font-size: 0.94rem;
}

.when {
    grid-column: 2;
    grid-row: 1 / span 2;
    align-self: center;
    color: var(--text-dim);
    font-size: 0.8rem;
    white-space: nowrap;
}

.unread-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent);
    display: inline-block;
    margin-right: 8px;
}

.empty-state {
    padding: 56px 24px;
    text-align: center;
}

.empty-state h2 {
    margin: 0 0 8px;
    font-size: 1.2rem;
}

.empty-state p {
    margin: 0;
    color: var(--text-muted);
}

.message-view {
    padding: 24px;
}

.message-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 20px;
}

.kv {
    display: grid;
    gap: 8px;
    margin-bottom: 22px;
    color: var(--text-muted);
    font-size: 0.92rem;
}

.kv span {
    color: var(--text);
}

.body-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    color: var(--text);
    font-size: 1rem;
}

.dev-banner {
    border: 1px solid #3d3420;
    background: #16130c;
    color: #d8c79a;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 0.88rem;
    margin-bottom: 16px;
}

.account-card {
    padding: 24px;
}

.account-row {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 0;
    border-bottom: 1px solid var(--border-soft);
    color: var(--text-muted);
}

.account-row:last-child {
    border-bottom: 0;
}

.account-row span {
    color: var(--text);
    text-align: right;
}

.loading {
    color: var(--text-muted);
    padding: 24px 0;
}

.hidden {
    display: none !important;
}

@media (max-width: 720px) {
    .nav-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nav-links {
        display: none;
        position: absolute;
        top: 73px;
        left: 0;
        right: 0;
        flex-direction: column;
        align-items: stretch;
        padding: 10px;
        background: #09090b;
        border-bottom: 1px solid var(--border);
    }

    .nav-links.open {
        display: flex;
    }

    .nav-links a,
    .nav-links button {
        min-height: var(--tap);
        justify-content: flex-start;
        display: flex;
        align-items: center;
    }

    .inbox-head,
    .message-toolbar,
    .account-row {
        flex-direction: column;
        align-items: flex-start;
    }

    .account-row span {
        text-align: left;
    }

    .hero {
        padding-top: 40px;
    }
}
