/* ==========================================================================
   Mini Webmail — tampilan modern
   Tema dipilih user (cookie mw_theme) lewat atribut body[data-theme].
   ========================================================================== */

:root,
body[data-theme="default"] {
    --accent: #f4511e;
    --accent-2: #ff9f43;
    --accent-ink: #c2410c;
    --hero-1: #2a1208;
    --hero-2: #5a1f0b;
}

body[data-theme="blue"] {
    --accent: #2563eb;
    --accent-2: #06b6d4;
    --accent-ink: #1d4ed8;
    --hero-1: #06142e;
    --hero-2: #0c2d5e;
}

body[data-theme="green"] {
    --accent: #059669;
    --accent-2: #a3e635;
    --accent-ink: #047857;
    --hero-1: #03190f;
    --hero-2: #0b3d26;
}

body[data-theme="purple"] {
    --accent: #7c3aed;
    --accent-2: #ec4899;
    --accent-ink: #6d28d9;
    --hero-1: #16072b;
    --hero-2: #3b0f5c;
}

body {
    --bg: color-mix(in srgb, var(--accent) 5%, #f5f6f8);
    --panel: #ffffff;
    --panel-2: #f8f9fb;
    --text: #0f172a;
    --muted: #64748b;
    --border: #e6e8ee;
    --soft: color-mix(in srgb, var(--accent) 11%, transparent);
    --softer: color-mix(in srgb, var(--accent) 6%, transparent);
    --ring: color-mix(in srgb, var(--accent) 28%, transparent);
    --danger: #dc2626;
    --success: #059669;
    --grad: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
    --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 8px 24px -8px rgba(15, 23, 42, .10);
    --shadow-lg: 0 24px 60px -18px rgba(15, 23, 42, .28);
    --radius: 18px;
    --av-bg-l: 92%;
    --av-fg-l: 32%;
    --av-sat: 72%;
}

body[data-theme="dark"] {
    --accent: #818cf8;
    --accent-2: #c084fc;
    --accent-ink: #a5b4fc;
    --hero-1: #05060a;
    --hero-2: #1b1640;
    --bg: #0b0d12;
    --panel: #12151c;
    --panel-2: #171b23;
    --text: #e6e8ef;
    --muted: #8b93a7;
    --border: #232835;
    --danger: #f87171;
    --success: #34d399;
    --shadow: 0 0 0 1px rgba(255, 255, 255, .03), 0 12px 32px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 24px 60px -18px rgba(0, 0, 0, .8);
    --av-bg-l: 22%;
    --av-fg-l: 80%;
    --av-sat: 40%;
    color-scheme: dark;
}

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

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    font-family: 'Plus Jakarta Sans', 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}

a {
    color: inherit;
}

[hidden] {
    display: none !important;
}

.i {
    flex-shrink: 0;
    display: block;
}

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

.accent-text {
    color: var(--accent-ink);
    font-weight: 700;
}

::selection {
    background: var(--ring);
}

:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

/* ---------- Tombol ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 42px;
    padding: 0 18px;
    border-radius: 12px;
    border: 0;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .2s ease, background .2s ease, filter .2s ease;
}

.btn:active {
    transform: translateY(1px) scale(.99);
}

.btn-primary {
    color: #fff;
    background: var(--grad);
    box-shadow: 0 8px 20px -8px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .25);
}

.btn-primary:hover {
    filter: brightness(1.06) saturate(1.05);
    box-shadow: 0 12px 26px -8px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .25);
}

.btn-ghost {
    color: var(--text);
    background: var(--panel);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--softer);
    border-color: var(--ring);
}

.btn-block {
    width: 100%;
    height: 48px;
    font-size: 15px;
}

.btn.is-loading {
    pointer-events: none;
    opacity: .85;
}

.btn.is-loading .i {
    animation: nudge .8s ease-in-out infinite alternate;
}

.icon-btn {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    border: 0;
    background: transparent;
    color: var(--muted);
    cursor: pointer;
    text-decoration: none;
    font-size: 20px;
    transition: background .15s, color .15s;
}

.icon-btn:hover {
    background: var(--softer);
    color: var(--text);
}

.icon-btn-danger:hover {
    background: color-mix(in srgb, var(--danger) 12%, transparent);
    color: var(--danger);
}

.pill {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 36px;
    padding: 0 14px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: background .15s, border-color .15s, color .15s;
}

.pill:hover {
    background: var(--soft);
    border-color: transparent;
    color: var(--accent-ink);
}

.link-btn {
    border: 0;
    background: none;
    font: inherit;
    font-weight: 600;
    font-size: 13px;
    color: var(--accent-ink);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    white-space: nowrap;
}

.link-btn:hover {
    background: var(--softer);
}

/* ---------- Alert & toast ---------- */
.alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 12px 14px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 18px;
}

.alert-error {
    color: var(--danger);
    background: color-mix(in srgb, var(--danger) 9%, var(--panel));
    border: 1px solid color-mix(in srgb, var(--danger) 25%, transparent);
}

.alert .i {
    margin-top: 1px;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    z-index: 60;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 18px 12px 14px;
    border-radius: 14px;
    background: #0f172a;
    color: #fff;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    transform: translateX(-50%);
    animation: toast-in .45s cubic-bezier(.2, .9, .3, 1.3);
    transition: opacity .35s, transform .35s;
}

.toast .i {
    color: #fff;
    background: var(--success);
    border-radius: 50%;
    padding: 3px;
    width: 24px;
    height: 24px;
}

.toast-warn .i {
    background: #d97706;
}

.toast.is-hidden {
    opacity: 0;
    transform: translate(-50%, 12px);
    pointer-events: none;
}

body[data-theme="dark"] .toast {
    background: #e6e8ef;
    color: #0b0d12;
}

/* ---------- Avatar (warna dari --h, di-set per alamat email) ---------- */
.avatar {
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: .02em;
    color: hsl(var(--h) var(--av-sat) var(--av-fg-l));
    background: hsl(var(--h) var(--av-sat) var(--av-bg-l));
}

.avatar-sm {
    width: 34px;
    height: 34px;
    font-size: 12px;
}

.avatar-lg {
    width: 48px;
    height: 48px;
    font-size: 16px;
}

/* ---------- Brand ---------- */
.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    color: #fff;
    background: var(--grad);
    box-shadow: 0 8px 18px -6px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .3);
}

.brand-mark-lg {
    width: 56px;
    height: 56px;
    border-radius: 18px;
}

.brand-text {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    min-width: 0;
}

.brand-text strong {
    font-size: 15px;
    font-weight: 800;
    letter-spacing: .06em;
}

.brand-text small {
    font-size: 12px;
    color: var(--muted);
    font-weight: 500;
}

/* ---------- Pemilih tema ---------- */
.theme-picker {
    display: flex;
    gap: 8px;
}

.swatch {
    width: 22px;
    height: 22px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid var(--panel);
    cursor: pointer;
    box-shadow: 0 0 0 1px var(--border);
    transition: transform .15s, box-shadow .15s;
}

.swatch:hover {
    transform: scale(1.15);
}

.swatch.is-active {
    box-shadow: 0 0 0 2px var(--text);
}

.swatch-default { background: linear-gradient(135deg, #f4511e, #ff9f43); }
.swatch-blue { background: linear-gradient(135deg, #2563eb, #06b6d4); }
.swatch-green { background: linear-gradient(135deg, #059669, #a3e635); }
.swatch-purple { background: linear-gradient(135deg, #7c3aed, #ec4899); }
.swatch-dark { background: linear-gradient(135deg, #0b0d12, #4f46e5); }

/* ==========================================================================
   Halaman login
   ========================================================================== */
.auth {
    min-height: 100vh;
    min-height: 100dvh;
    background: var(--hero-1);
    overflow-x: hidden;
}

.auth-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    background: radial-gradient(1200px 700px at 10% 10%, var(--hero-2), transparent 60%), var(--hero-1);
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(70px);
    opacity: .55;
    animation: float 18s ease-in-out infinite alternate;
}

.blob-1 { width: 520px; height: 520px; left: -120px; top: -140px; background: var(--accent); }
.blob-2 { width: 420px; height: 420px; left: 32%; bottom: -180px; background: var(--accent-2); animation-duration: 22s; animation-delay: -6s; }
.blob-3 { width: 300px; height: 300px; right: 8%; top: 12%; background: color-mix(in srgb, var(--accent) 50%, #fff); opacity: .25; animation-duration: 26s; }

.grid-overlay {
    position: absolute;
    inset: 0;
    background-image:
        linear-gradient(rgba(255, 255, 255, .045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, .045) 1px, transparent 1px);
    background-size: 44px 44px;
    mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
    -webkit-mask-image: radial-gradient(ellipse at 30% 40%, #000 20%, transparent 75%);
}

.auth-shell {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    min-height: 100dvh;
    display: grid;
    grid-template-columns: minmax(0, 1.1fr) minmax(360px, 440px);
    align-items: center;
    gap: clamp(32px, 6vw, 96px);
    max-width: 1180px;
    margin: 0 auto;
    padding: 40px clamp(20px, 5vw, 56px);
}

.auth-hero {
    color: #fff;
    animation: rise .7s cubic-bezier(.2, .8, .2, 1) both;
}

.brand-light .brand-text small {
    color: rgba(255, 255, 255, .65);
}

.auth-hero h1 {
    margin: 44px 0 16px;
    font-size: clamp(34px, 4.4vw, 54px);
    line-height: 1.08;
    font-weight: 800;
    letter-spacing: -.03em;
}

.hero-accent {
    background: linear-gradient(90deg, var(--accent-2), color-mix(in srgb, var(--accent-2) 40%, #fff));
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.hero-lead {
    max-width: 460px;
    margin: 0 0 28px;
    font-size: 16px;
    color: rgba(255, 255, 255, .72);
}

.hero-lead b {
    color: #fff;
}

.hero-points {
    list-style: none;
    margin: 0 0 36px;
    padding: 0;
    display: grid;
    gap: 12px;
}

.hero-points li {
    display: flex;
    align-items: center;
    gap: 12px;
    color: rgba(255, 255, 255, .85);
    font-weight: 500;
}

.hero-points li span {
    display: grid;
    place-items: center;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255, 255, 255, .08);
    border: 1px solid rgba(255, 255, 255, .12);
    color: var(--accent-2);
}

.hero-preview {
    max-width: 440px;
    padding: 10px;
    border-radius: 20px;
    background: rgba(255, 255, 255, .06);
    border: 1px solid rgba(255, 255, 255, .1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .6);
    transform: perspective(900px) rotateX(8deg) rotateY(-6deg);
}

.preview-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 12px;
    --av-bg-l: 90%;
    --av-fg-l: 30%;
    --av-sat: 72%;
}

.preview-row.is-unread {
    background: rgba(255, 255, 255, .08);
}

.preview-row .avatar {
    width: 34px;
    height: 34px;
    font-size: 11px;
}

.preview-lines {
    flex: 1;
    display: grid;
    gap: 7px;
}

.preview-lines i {
    display: block;
    height: 8px;
    border-radius: 99px;
    background: rgba(255, 255, 255, .22);
}

.preview-lines i + i {
    height: 7px;
    background: rgba(255, 255, 255, .1);
}

.preview-row.is-unread .preview-lines i:first-child {
    background: rgba(255, 255, 255, .5);
}

.preview-row em {
    font-style: normal;
    font-size: 11px;
    color: rgba(255, 255, 255, .5);
}

.auth-card {
    padding: 36px 32px 26px;
    border-radius: 28px;
    background: var(--panel);
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .06);
    animation: rise .7s .08s cubic-bezier(.2, .8, .2, 1) both;
}

body[data-theme="dark"] .auth-card {
    background: rgba(18, 21, 28, .88);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    box-shadow: 0 40px 80px -30px rgba(0, 0, 0, .8), 0 0 0 1px rgba(255, 255, 255, .08);
}

.auth-card-head {
    text-align: center;
    margin-bottom: 26px;
}

.auth-card-head .brand-mark {
    margin: 0 auto 18px;
}

.auth-card-head h2 {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -.02em;
}

.auth-card-head p {
    margin: 0;
}

.input-group {
    display: block;
    margin-bottom: 16px;
}

.input-label {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
    font-size: 13px;
}

.input-wrap {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 50px;
    padding: 0 6px 0 14px;
    border-radius: 14px;
    border: 1.5px solid var(--border);
    background: var(--panel-2);
    color: var(--muted);
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.input-wrap:focus-within {
    border-color: var(--accent);
    background: var(--panel);
    box-shadow: 0 0 0 4px var(--ring);
    color: var(--accent-ink);
}

.input-wrap input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 15px;
    color: var(--text);
}

.input-wrap input::placeholder {
    color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.pw-toggle.is-on {
    color: var(--accent-ink);
    background: var(--soft);
}

.auth-form .btn-block {
    margin-top: 8px;
}

.auth-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 24px;
    padding-top: 18px;
    border-top: 1px solid var(--border);
    font-size: 12px;
}

.auth-foot .muted {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Halaman "IMAP belum aktif" (imap_required.php) */
.login-page {
    min-height: 100vh;
    padding: 20px;
    background: var(--bg);
}

/* ==========================================================================
   Aplikasi: sidebar + panel utama
   ========================================================================== */
.app {
    display: grid;
    grid-template-columns: 272px minmax(0, 1fr);
    min-height: 100vh;
    min-height: 100dvh;
    background:
        radial-gradient(900px 500px at 0% 0%, var(--softer), transparent 70%),
        var(--bg);
}

.sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    gap: 18px;
    padding: 22px 16px 16px;
}

.sidebar .brand {
    padding: 0 6px;
}

.drawer-close {
    display: none;
    margin-left: auto;
}

.btn-compose {
    display: flex;
    align-items: center;
    gap: 10px;
    height: 50px;
    padding: 0 20px;
    border-radius: 16px;
    color: #fff;
    background: var(--grad);
    font-weight: 700;
    font-size: 15px;
    text-decoration: none;
    box-shadow: 0 12px 24px -10px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .25);
    transition: transform .15s, box-shadow .2s, filter .2s;
}

.btn-compose:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
    box-shadow: 0 16px 30px -10px var(--accent), inset 0 1px 0 rgba(255, 255, 255, .25);
}

.nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
    overflow-y: auto;
}

.nav-label {
    padding: 4px 12px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
}

.nav-item {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 44px;
    padding: 0 12px;
    border-radius: 12px;
    color: var(--muted);
    font-weight: 600;
    text-decoration: none;
    transition: background .15s, color .15s;
}

.nav-item:hover {
    background: var(--softer);
    color: var(--text);
}

.nav-item.is-active {
    background: var(--panel);
    color: var(--accent-ink);
    box-shadow: var(--shadow);
}

.nav-item.is-active::before {
    content: "";
    position: absolute;
    left: -16px;
    top: 10px;
    bottom: 10px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--grad);
}

.nav-text {
    flex: 1;
}

.badge {
    min-width: 24px;
    height: 22px;
    padding: 0 7px;
    border-radius: 99px;
    display: inline-grid;
    place-items: center;
    font-size: 11px;
    font-weight: 800;
    color: #fff;
    background: var(--grad);
}

.sidebar-foot {
    display: grid;
    gap: 10px;
}

.theme-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
}

.theme-row-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 600;
    color: var(--muted);
}

.theme-row .theme-picker {
    gap: 6px;
}

.theme-row .swatch {
    width: 18px;
    height: 18px;
}

.me {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 8px 10px 10px;
    border-radius: 14px;
    background: var(--panel);
    border: 1px solid var(--border);
}

.me-text {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.me-text strong {
    font-size: 13px;
    text-transform: capitalize;
}

.me-text small {
    font-size: 11px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.scrim {
    display: none;
}

/* ---------- Panel utama ---------- */
.main {
    display: flex;
    flex-direction: column;
    min-width: 0;
    height: calc(100vh - 28px);
    height: calc(100dvh - 28px);
    margin: 14px 14px 14px 0;
    border-radius: 24px;
    background: var(--panel);
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    overflow: hidden;
    animation: fade .35s ease both;
}

.topbar {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 72px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--panel);
}

.menu-btn {
    display: none;
}

.topbar-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-right: auto;
}

.topbar-title h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -.02em;
    line-height: 1.2;
}

.topbar-title .muted {
    font-size: 12px;
}

.topbar-crumb {
    font-weight: 600;
    color: var(--muted);
    margin-right: auto;
}

.topbar-actions {
    display: flex;
    gap: 8px;
}

.search {
    display: flex;
    align-items: center;
    gap: 8px;
    width: min(340px, 40%);
    height: 42px;
    padding: 0 14px;
    border-radius: 12px;
    background: var(--panel-2);
    border: 1.5px solid var(--border);
    color: var(--muted);
    transition: border-color .15s, box-shadow .15s, background .15s;
}

.search:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--ring);
    background: var(--panel);
}

.search input {
    flex: 1;
    min-width: 0;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    color: var(--text);
}

#refreshBtn.is-spinning .i {
    animation: spin .8s linear infinite;
}

/* ---------- Daftar email ---------- */
.list {
    flex: 1;
    overflow-y: auto;
    padding: 0 10px 16px;
}

.list-group {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 16px 12px 8px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--muted);
    background: var(--panel);
}

.row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 14px;
    border-radius: 14px;
    text-decoration: none;
    color: var(--text);
    transition: background .15s;
    animation: rise .4s cubic-bezier(.2, .8, .2, 1) both;
}

.row:nth-of-type(2) { animation-delay: .03s; }
.row:nth-of-type(3) { animation-delay: .06s; }
.row:nth-of-type(4) { animation-delay: .09s; }
.row:nth-of-type(n+5) { animation-delay: .12s; }

.row:hover {
    background: var(--softer);
}

.row + .row::before {
    content: "";
    position: absolute;
    top: 0;
    left: 68px;
    right: 14px;
    border-top: 1px solid var(--border);
}

.row:hover::before,
.row:hover + .row::before,
.row.is-unread + .row::before,
.row.is-unread::before {
    opacity: 0;
}

.row-body {
    flex: 1;
    min-width: 0;
    display: grid;
    gap: 2px;
}

.row-top {
    display: flex;
    align-items: baseline;
    gap: 12px;
}

.row-from {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    font-size: 14px;
}

.row-time {
    flex-shrink: 0;
    font-size: 12px;
    color: var(--muted);
    font-variant-numeric: tabular-nums;
}

.row-subject {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--muted);
    font-size: 13.5px;
}

.row.is-unread {
    background: var(--softer);
    margin-bottom: 2px;
}

.row.is-unread:hover {
    background: var(--soft);
}

.row.is-unread .row-from,
.row.is-unread .row-subject {
    color: var(--text);
    font-weight: 700;
}

.row.is-unread .row-time {
    color: var(--accent-ink);
    font-weight: 700;
}

.row.is-unread::after {
    content: "";
    position: absolute;
    left: 4px;
    top: 50%;
    width: 6px;
    height: 6px;
    margin-top: -3px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 3px var(--ring);
}

/* ---------- Keadaan kosong ---------- */
.empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 72px 24px;
    color: var(--muted);
}

.empty-art {
    display: grid;
    place-items: center;
    width: 96px;
    height: 96px;
    margin-bottom: 22px;
    border-radius: 30px;
    color: var(--accent-ink);
    background: var(--soft);
    box-shadow: 0 0 0 10px var(--softer);
    animation: bob 3.5s ease-in-out infinite;
}

.empty h2 {
    margin: 0 0 6px;
    color: var(--text);
    font-size: 18px;
    font-weight: 800;
}

.empty p {
    margin: 0 0 22px;
    max-width: 320px;
}

/* ---------- Baca email ---------- */
.reader {
    flex: 1;
    overflow-y: auto;
    width: 100%;
    padding: 30px clamp(18px, 4vw, 44px) 40px;
    animation: rise .4s cubic-bezier(.2, .8, .2, 1) both;
}

.reader > * {
    max-width: 860px;
    margin-left: auto;
    margin-right: auto;
}

.reader-subject {
    margin-top: 0;
    margin-bottom: 22px;
    font-size: clamp(21px, 2.4vw, 28px);
    line-height: 1.25;
    font-weight: 800;
    letter-spacing: -.02em;
    word-break: break-word;
}

.sender-card {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    margin-bottom: 24px;
}

.sender-info {
    flex: 1;
    min-width: 0;
}

.sender-line {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
}

.sender-line strong {
    font-size: 15px;
}

.sender-line .muted {
    font-size: 13px;
    word-break: break-all;
}

.recipients summary {
    display: inline-block;
    margin-top: 2px;
    font-size: 13px;
    color: var(--muted);
    cursor: pointer;
    list-style: none;
    border-radius: 6px;
}

.recipients summary::-webkit-details-marker {
    display: none;
}

.recipients summary::after {
    content: " ▾";
    font-size: 11px;
}

.recipients[open] summary::after {
    content: " ▴";
}

.recipients dl {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 6px 14px;
    margin: 10px 0 0;
    padding: 14px 16px;
    border-radius: 14px;
    background: var(--panel-2);
    border: 1px solid var(--border);
    font-size: 13px;
}

.recipients dt {
    color: var(--muted);
    font-weight: 600;
}

.recipients dd {
    margin: 0;
    word-break: break-word;
}

.sender-date {
    flex-shrink: 0;
    font-size: 12.5px;
    color: var(--muted);
    white-space: nowrap;
    padding-top: 3px;
}

.message {
    padding: 26px 28px;
    border-radius: var(--radius);
    background: var(--panel-2);
    border: 1px solid var(--border);
    font-size: 15px;
    line-height: 1.7;
    overflow-x: auto;
    word-break: break-word;
}

.message-text {
    white-space: pre-wrap;
}

/* Email HTML dirancang untuk latar putih, jadi tetap putih meski tema gelap. */
.message-html {
    background: #fff;
    color: #1f2937;
}

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

.message-html table {
    max-width: 100%;
    border-collapse: collapse;
}

.message-html td,
.message-html th {
    padding: 6px 10px;
}

.message-html a {
    color: #2563eb;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 28px;
    margin-bottom: 12px;
    font-size: 12px;
    font-weight: 800;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: .08em;
}

.attachment-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 10px;
}

.file-chip {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
    padding: 10px;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--panel);
    color: var(--text);
    text-decoration: none;
    transition: border-color .15s, box-shadow .15s, transform .15s;
}

a.file-chip:hover {
    border-color: var(--ring);
    box-shadow: var(--shadow);
    transform: translateY(-1px);
}

.file-badge {
    display: grid;
    place-items: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
    border-radius: 11px;
    font-size: 10.5px;
    font-weight: 800;
    letter-spacing: .03em;
    color: #fff;
    background: var(--grad);
}

.file-meta {
    flex: 1;
    min-width: 0;
    display: grid;
}

.file-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
    font-size: 13px;
}

.file-size {
    font-size: 12px;
    color: var(--muted);
}

.file-dl {
    color: var(--muted);
    padding: 0 6px;
}

a.file-chip:hover .file-dl {
    color: var(--accent-ink);
}

.reader-footer {
    display: flex;
    gap: 10px;
    margin-top: 30px;
}

/* ---------- Tulis email ---------- */
.composer {
    flex: 1;
    overflow-y: auto;
    width: 100%;
    padding: 24px clamp(14px, 3vw, 36px) 40px;
    animation: rise .4s cubic-bezier(.2, .8, .2, 1) both;
}

.composer > * {
    max-width: 880px;
    margin-left: auto;
    margin-right: auto;
}

.composer-card {
    border-radius: 22px;
    border: 1px solid var(--border);
    background: var(--panel);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.field {
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 54px;
    padding: 0 20px;
    border-bottom: 1px solid var(--border);
    transition: background .15s;
}

.field:focus-within {
    background: var(--softer);
}

.field-label {
    flex-shrink: 0;
    width: 64px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
}

.field input {
    flex: 1;
    min-width: 0;
    height: 52px;
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 14.5px;
    color: var(--text);
}

.field input::placeholder,
.composer-body::placeholder {
    color: color-mix(in srgb, var(--muted) 65%, transparent);
}

.field-static {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 600;
}

#subject {
    font-weight: 700;
    font-size: 15.5px;
}

.composer-body {
    display: block;
    width: 100%;
    min-height: 260px;
    padding: 20px;
    border: 0;
    outline: 0;
    resize: none;
    background: transparent;
    font: inherit;
    font-size: 15px;
    line-height: 1.7;
    color: var(--text);
}

.check {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin: 0 20px 14px;
    padding: 12px 14px;
    border-radius: 12px;
    background: var(--softer);
    font-size: 13px;
    cursor: pointer;
}

.check input {
    margin-top: 3px;
    accent-color: var(--accent);
}

.dropzone {
    position: relative;
    margin: 0 20px;
    border-radius: 16px;
    border: 2px dashed var(--border);
    background: var(--panel-2);
    transition: border-color .15s, background .15s, transform .15s;
}

.dropzone:hover,
.dropzone.is-over {
    border-color: var(--accent);
    background: var(--softer);
}

.dropzone.is-over {
    transform: scale(1.01);
}

.dropzone input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.dropzone-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px 12px;
    padding: 18px;
    color: var(--muted);
    font-size: 13.5px;
    pointer-events: none;
    text-align: center;
}

.dropzone-inner b {
    color: var(--text);
}

.dropzone-inner u {
    color: var(--accent-ink);
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.dropzone-icon {
    display: grid;
    place-items: center;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    color: var(--accent-ink);
    background: var(--soft);
}

.dropzone-inner small {
    flex-basis: 100%;
    font-size: 12px;
}

.chips {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 8px;
    padding: 12px 20px 0;
}

.chips:empty {
    display: none;
}

.file-chip-sm {
    padding: 8px;
    animation: rise .25s ease both;
}

.file-chip-sm .file-badge {
    width: 36px;
    height: 36px;
    font-size: 10px;
}

.composer-foot {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 20px;
}

.composer-foot .muted {
    flex: 1;
    font-size: 12.5px;
}

.composer-foot .is-danger {
    color: var(--danger);
    font-weight: 700;
}

.btn-send {
    height: 46px;
    padding: 0 26px;
    font-size: 15px;
}

/* ---------- Tombol tulis melayang (ponsel) ---------- */
.fab {
    display: none;
}

/* ==========================================================================
   Responsif
   ========================================================================== */
@media (max-width: 980px) {
    .auth-shell {
        grid-template-columns: minmax(0, 1fr);
        max-width: 480px;
        gap: 28px;
        padding-top: 28px;
    }
    .auth-hero h1 {
        margin: 28px 0 10px;
        font-size: 32px;
    }
    .hero-lead {
        margin-bottom: 0;
        font-size: 15px;
    }
    .hero-points,
    .hero-preview {
        display: none;
    }
}

@media (max-width: 860px) {
    .app {
        grid-template-columns: minmax(0, 1fr);
    }
    .sidebar {
        position: fixed;
        z-index: 50;
        left: 0;
        top: 0;
        width: min(300px, 86vw);
        background: var(--bg);
        box-shadow: var(--shadow-lg);
        transform: translateX(-105%);
        transition: transform .3s cubic-bezier(.2, .8, .2, 1);
    }
    .drawer-open .sidebar {
        transform: none;
    }
    .scrim {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 40;
        background: rgba(2, 6, 23, .45);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity .3s;
    }
    .drawer-open .scrim {
        opacity: 1;
        pointer-events: auto;
    }
    .drawer-close,
    .menu-btn {
        display: inline-grid;
    }
    .nav-item.is-active::before {
        display: none;
    }
    .main {
        height: auto;
        min-height: 100vh;
        min-height: 100dvh;
        margin: 0;
        border-radius: 0;
        border: 0;
        overflow: visible;
    }
    .topbar {
        position: sticky;
        top: 0;
        z-index: 5;
        flex-wrap: wrap;
        min-height: 60px;
        padding: 10px 12px;
        gap: 6px;
    }
    .topbar-title h1 {
        font-size: 19px;
    }
    .search {
        order: 5;
        width: 100%;
    }
    .topbar-actions .pill span {
        display: none;
    }
    .topbar-actions .pill {
        width: 38px;
        padding: 0;
        justify-content: center;
        border-color: transparent;
        background: transparent;
    }
    .list {
        padding: 0 4px 90px;
        overflow: visible;
    }
    .list-group {
        position: static;
    }
    .reader,
    .composer {
        overflow: visible;
    }
    .reader {
        padding: 20px 16px 90px;
    }
    .sender-card {
        flex-wrap: wrap;
    }
    .sender-date {
        order: 3;
        flex-basis: 100%;
        padding-left: 62px;
        margin-top: -6px;
    }
    .message {
        padding: 18px;
        font-size: 14.5px;
    }
    .composer {
        padding: 12px 10px 40px;
    }
    .field {
        padding: 0 14px;
    }
    .field-label {
        width: 54px;
    }
    .dropzone,
    .check {
        margin-left: 14px;
        margin-right: 14px;
    }
    .composer-body {
        padding: 16px 14px;
    }
    .fab {
        position: fixed;
        right: 18px;
        bottom: 20px;
        z-index: 30;
        display: grid;
        place-items: center;
        width: 58px;
        height: 58px;
        border-radius: 20px;
        color: #fff;
        background: var(--grad);
        box-shadow: 0 16px 30px -10px var(--accent);
        animation: pop .4s .2s cubic-bezier(.2, .9, .3, 1.4) both;
    }
    .toast {
        bottom: 92px;
        max-width: calc(100vw - 32px);
    }
}

@media (max-width: 420px) {
    .auth-card {
        padding: 28px 20px 20px;
        border-radius: 24px;
    }
    .auth-foot {
        flex-direction: column;
    }
}

/* ---------- Animasi ---------- */
@keyframes rise {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

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

@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(60px, 40px) scale(1.1); }
    100% { transform: translate(-30px, 70px) scale(.95); }
}

@keyframes bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-6px); }
}

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

@keyframes nudge {
    from { transform: translateX(0); }
    to { transform: translateX(4px); }
}

@keyframes pop {
    from { opacity: 0; transform: scale(.6); }
    to { opacity: 1; transform: none; }
}

@keyframes toast-in {
    from { opacity: 0; transform: translate(-50%, 20px) scale(.96); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}
