:root {
    --blue: #3b82f6;
    --pink: #ec4899;
    --bg: #0a0a0a;
    --panel: #111111;
    --panel-alt: rgba(26, 26, 26, 0.8);
    --line: rgba(59, 130, 246, 0.2);
    --line-soft: rgba(59, 130, 246, 0.1);
    --text: #ffffff;
    --text-soft: #9a9a9a;
    --text-faint: #6b6b6b;
    --gradient: linear-gradient(135deg, var(--blue), var(--pink));
}

/* ---- App shell ---- */
.app {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: calc(100vh - 72px - 220px);
}

.sidebar {
    border-right: 1px solid var(--line);
    padding: 24px 16px;
}

.compose-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    margin-bottom: 20px;
    text-align: center;
    font-size: 14px;
}

.mailbox-list { list-style: none; margin: 0; padding: 0; }

.mailbox-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-soft);
    transition: all 0.2s;
}

.mailbox-list a:hover { background: var(--line-soft); color: var(--text); }
.mailbox-list a.active {
    background: var(--line-soft);
    color: var(--blue);
    font-weight: 600;
    border: 1px solid var(--line);
}

.mailbox-name { text-transform: capitalize; }

.main {
    padding: 0;
}

/* ---- Message list ---- */
.list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 28px;
    border-bottom: 1px solid var(--line);
}

.list-header h1 {
    font-size: 20px;
    font-weight: 700;
    margin: 0;
    text-transform: capitalize;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.list-meta {
    color: var(--text-soft);
    font-size: 12px;
}

.message-row {
    display: grid;
    grid-template-columns: 24px 220px 1fr auto;
    gap: 16px;
    align-items: center;
    padding: 14px 28px;
    border-bottom: 1px solid var(--line-soft);
    cursor: pointer;
    text-decoration: none;
    color: var(--text);
    transition: background 0.2s;
}

.message-row:hover { background: var(--line-soft); }

.message-row.unread { font-weight: 600; }

.unread-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--gradient);
    justify-self: center;
}

.message-row.read .unread-dot { background: transparent; }

.msg-from {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 13px;
    color: var(--text-soft);
}

.message-row.unread .msg-from { color: var(--text); }

.msg-subject {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.msg-date {
    font-size: 12px;
    color: var(--text-faint);
    white-space: nowrap;
}

.empty-state {
    padding: 80px 28px;
    text-align: center;
    color: var(--text-soft);
}

.empty-state h2 {
    color: var(--text);
    margin-bottom: 8px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 28px;
}

.pagination a, .pagination span {
    padding: 8px 16px;
    border: 1px solid var(--line);
    border-radius: 20px;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    transition: all 0.2s;
}

.pagination a:hover { background: var(--line-soft); border-color: var(--blue); }
.pagination .disabled { color: var(--text-faint); opacity: 0.5; pointer-events: none; }
.pagination span:not(.disabled) { border: none; color: var(--text-soft); }

/* ---- Message view ---- */
.message-view { padding: 32px; max-width: 760px; }

.message-view h1 {
    font-size: 26px;
    margin: 0 0 20px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.message-meta {
    border-bottom: 1px solid var(--line);
    padding-bottom: 20px;
    margin-bottom: 24px;
    font-size: 13px;
    color: var(--text-soft);
}

.message-meta .meta-row { margin-bottom: 6px; }
.message-meta .meta-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--text-faint);
    margin-right: 8px;
    display: inline-block;
    min-width: 50px;
}
.message-meta .meta-value { color: var(--text); }

.message-body {
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #e5e5e5;
}

.message-body iframe {
    width: 100%;
    border: none;
    min-height: 400px;
    background: #fff;
    border-radius: 8px;
}

.message-actions {
    display: flex;
    gap: 12px;
    margin-top: 28px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.attachments {
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.attachment-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    border: 1px solid var(--line);
    border-radius: 20px;
    font-size: 12px;
    margin-right: 8px;
    color: var(--text-soft);
}

/* ---- Buttons ---- */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border-radius: 25px;
    border: 1px solid var(--line);
    background: transparent;
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.btn:hover { background: var(--line-soft); border-color: var(--blue); }

.btn-primary {
    background: var(--gradient);
    color: #fff;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.3);
}

.btn-danger { border-color: rgba(236, 72, 153, 0.3); color: #f3a0c3; }
.btn-danger:hover { border-color: var(--pink); background: rgba(236, 72, 153, 0.1); color: var(--pink); }

/* ---- Forms ---- */
.form-page {
    max-width: 540px;
    margin: 60px auto;
    padding: 40px;
    background: var(--panel-alt);
    border: 1px solid var(--line);
    border-radius: 16px;
}

.form-page h1 {
    font-size: 24px;
    margin: 0 0 8px;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline-block;
}

.form-page .subtitle {
    color: var(--text-soft);
    font-size: 13px;
    margin: 0 0 28px;
    line-height: 1.6;
}

.field { margin-bottom: 18px; }

.field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-soft);
    margin-bottom: 8px;
}

.field input, .field textarea {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    font-family: inherit;
    font-size: 14px;
    background: #0a0a0a;
    color: var(--text);
}

.field textarea {
    min-height: 220px;
    resize: vertical;
    line-height: 1.6;
}

.field input:focus, .field textarea:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.field input::placeholder, .field textarea::placeholder {
    color: var(--text-faint);
}

.alert {
    padding: 14px 16px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 20px;
}

.alert-error { background: rgba(236, 72, 153, 0.1); color: #f3a0c3; border: 1px solid rgba(236, 72, 153, 0.3); }
.alert-success { background: rgba(59, 130, 246, 0.1); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.3); }
.alert-info { background: var(--line-soft); color: var(--blue); border: 1px solid var(--line); }

.helper-text {
    font-size: 12px;
    color: var(--text-faint);
    margin-top: 6px;
    line-height: 1.5;
}

/* ---- Login page ---- */
.login-page {
    min-height: calc(100vh - 72px - 220px);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 24px;
    text-align: center;
    padding: 60px 20px;
}

.login-page .login-mark {
    width: 64px;
    height: 64px;
    border-radius: 16px;
    background: var(--gradient);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: 700;
}

.login-page h1 {
    font-size: 28px;
    margin: 0;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-page p {
    color: var(--text-soft);
    font-size: 14px;
    max-width: 360px;
    line-height: 1.6;
}

@media (max-width: 720px) {
    .app { grid-template-columns: 1fr; }
    .sidebar { display: flex; overflow-x: auto; gap: 8px; padding: 16px; border-right: none; border-bottom: 1px solid var(--line); }
    .compose-btn { display: none; }
    .mailbox-list { display: flex; gap: 8px; }
    .message-row { grid-template-columns: 16px 1fr auto; }
    .msg-from { display: none; }
    .message-view { padding: 20px; }
}
