:root {
  color-scheme: dark;
  --bg: #0b0d10;
  --panel: #11151a;
  --panel2: #171b21;
  --panel3: #20252c;
  --line: #2b3139;
  --text: #e8eaed;
  --muted: #9aa0a6;
  --blue: #8ab4f8;
  --blue2: #a8c7fa;
  --shadow: 0 18px 60px rgba(0,0,0,.45);
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.45 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; overflow: hidden; }
button, input, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }
.boot { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 1000; }
.spinner { width: 34px; height: 34px; border: 3px solid #252a31; border-top-color: var(--blue); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.auth-view { position: fixed; inset: 0; display: grid; place-items: center; padding: 24px; background: radial-gradient(circle at 50% 15%, #151c27 0, var(--bg) 48%); }
.auth-card { width: min(420px, 100%); padding: 34px; background: rgba(17,21,26,.94); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); text-align: center; }
.auth-card h1 { margin: 16px 0 4px; font-size: 28px; }
.auth-card p { color: var(--muted); }
.auth-card form { text-align: left; margin-top: 26px; }
.auth-card label { display: block; margin: 0 0 8px; color: #c5c9cf; }
.auth-card input { width: 100%; height: 48px; border-radius: 12px; border: 1px solid #353b44; background: #0d1014; color: var(--text); padding: 0 14px; outline: none; }
.auth-card input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(138,180,248,.12); }
.error { min-height: 20px; color: #ff9b9b !important; text-align: center; }
.brand-mark { width: 58px; height: 58px; display: grid; place-items: center; margin: auto; border-radius: 16px; background: linear-gradient(145deg, #dbe9ff, #7daff7); color: #07111f; font-weight: 800; font-size: 28px; box-shadow: inset 0 0 0 1px rgba(255,255,255,.45); }
.brand-mark.small { width: 34px; height: 34px; border-radius: 10px; margin: 0; font-size: 17px; }
.primary, .secondary, .send-btn { border: 0; cursor: pointer; border-radius: 999px; padding: 10px 18px; font-weight: 600; }
.primary, .send-btn { background: var(--blue2); color: #07111f; }
.secondary { background: transparent; border: 1px solid #444b55; }
.wide { width: 100%; }
.text-btn { background: none; border: 0; color: var(--blue); cursor: pointer; }

.app { height: 100%; display: grid; grid-template-columns: 256px 1fr; grid-template-rows: 64px 1fr; }
.topbar { grid-column: 1 / -1; display: grid; grid-template-columns: 238px minmax(220px, 720px) 1fr; gap: 18px; align-items: center; padding: 8px 18px; background: var(--bg); }
.brand { display: flex; gap: 12px; align-items: center; font-size: 20px; font-weight: 600; letter-spacing: -.3px; }
.search-wrap { height: 48px; position: relative; }
.search-wrap input { width: 100%; height: 100%; border: 1px solid transparent; border-radius: 14px; background: #1a2027; color: var(--text); padding: 0 48px; outline: none; font-size: 15px; }
.search-wrap input:focus { background: #20262e; border-color: #343b45; }
.search-icon { position: absolute; left: 17px; top: 11px; font-size: 24px; color: var(--muted); pointer-events: none; }
.top-actions { justify-self: end; display: flex; align-items: center; gap: 5px; }
.icon-btn, .toolbar-btn, .compose-icon, .inline-btn, .trash-btn { border: 0; background: transparent; color: #bdc1c6; cursor: pointer; }
.icon-btn { width: 40px; height: 40px; border-radius: 50%; font-size: 20px; }
.icon-btn:hover, .toolbar-btn:hover, .compose-icon:hover { background: rgba(255,255,255,.08); }
.avatar { width: 34px; height: 34px; border-radius: 50%; border: 0; background: #7e57c2; color: white; font-weight: 700; cursor: pointer; }
.avatar.big { width: 58px; height: 58px; display: grid; place-items: center; font-size: 22px; cursor: default; }

.sidebar { grid-column: 1; grid-row: 2; display: flex; flex-direction: column; padding: 10px 12px 14px; overflow: auto; }
.compose-btn { width: 150px; min-height: 54px; border: 0; border-radius: 16px; background: #c2e7ff; color: #07131c; cursor: pointer; font-weight: 650; font-size: 15px; box-shadow: 0 3px 10px rgba(0,0,0,.15); margin: 4px 0 16px 2px; }
.compose-btn span { margin-right: 7px; font-size: 22px; }
.nav-item { width: 100%; height: 36px; border: 0; border-radius: 0 18px 18px 0; background: transparent; display: grid; grid-template-columns: 32px 1fr auto; align-items: center; gap: 6px; padding: 0 14px; color: #c7cbd0; cursor: pointer; text-align: left; }
.nav-item:hover { background: rgba(255,255,255,.055); }
.nav-item.active { background: #2a3647; color: #d8e8ff; font-weight: 700; }
.nav-item b { font-size: 12px; font-weight: 700; }
.sidebar-foot { margin-top: auto; padding: 18px 12px 4px; color: var(--muted); }
.mail-address { color: #d7dadd; font-size: 12px; overflow-wrap: anywhere; }
.quota { margin-top: 4px; font-size: 10px; }

.main { grid-column: 2; grid-row: 2; min-width: 0; min-height: 0; margin: 0 12px 12px 0; background: var(--panel); border-radius: 16px; overflow: hidden; border: 1px solid #151a20; }
.list-view, .message-view { height: 100%; overflow: auto; }
.list-toolbar, .message-toolbar { position: sticky; top: 0; z-index: 10; height: 50px; display: flex; align-items: center; gap: 8px; padding: 0 14px; background: rgba(17,21,26,.95); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(255,255,255,.03); }
.toolbar-btn { min-width: 36px; height: 36px; border-radius: 50%; font-size: 18px; }
.spacer { flex: 1; }
.range-label { color: var(--muted); font-size: 12px; }
.check-wrap { width: 34px; height: 34px; display: grid; place-items: center; cursor: pointer; }
.check-wrap input { accent-color: var(--blue); }
.mail-list { min-height: 100px; }
.mail-row { display: grid; grid-template-columns: 38px 38px minmax(160px, .8fr) minmax(260px, 2fr) 90px; align-items: center; min-height: 46px; border-bottom: 1px solid #252a31; padding: 0 12px 0 8px; background: #161a20; cursor: pointer; transition: background .12s ease; }
.mail-row:hover { background: #20252c; box-shadow: inset 3px 0 0 #3b82c4; }
.mail-row.unread { background: #20252c; font-weight: 650; }
.mail-row .cell-check { display: grid; place-items: center; }
.star { font-size: 19px; color: #9aa0a6; background: none; border: 0; cursor: pointer; }
.star.active { color: #f7cb4d; }
.from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding-right: 10px; }
.subject-line { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.subject-line .preview { color: var(--muted); font-weight: 400; }
.date { text-align: right; color: #aeb3b9; font-size: 12px; white-space: nowrap; }
.empty { height: calc(100% - 50px); display: grid; place-content: center; text-align: center; color: var(--muted); }
.empty-icon { font-size: 50px; opacity: .5; }
.empty h2 { color: var(--text); margin-bottom: 0; }

.message-content { max-width: 1100px; margin: auto; padding: 18px 34px 50px; }
.message-content h1 { margin: 8px 0 28px; font-weight: 500; font-size: 26px; word-break: break-word; }
.sender-row { display: grid; grid-template-columns: 42px 1fr auto; gap: 12px; align-items: center; }
.sender-avatar { width: 42px; height: 42px; border-radius: 50%; background: #415a77; display: grid; place-items: center; font-weight: 700; text-transform: uppercase; }
.sender-meta { min-width: 0; }
.sender-meta > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.muted { color: var(--muted); font-size: 12px; }
.sender-row time { color: var(--muted); font-size: 12px; }
.message-body { margin: 28px 0 24px; min-height: 120px; color: #e3e5e8; overflow-wrap: anywhere; }
.message-body iframe { width: 100%; min-height: 420px; border: 0; background: white; border-radius: 8px; }
.message-body pre { white-space: pre-wrap; font: inherit; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; }
.attachment { padding: 9px 12px; border: 1px solid #363d46; border-radius: 8px; color: #cdd1d5; text-decoration: none; }
.attachment:hover { background: #20262d; }
.reply-strip { display: flex; gap: 10px; margin-top: 26px; }

.compose-window { position: fixed; z-index: 50; right: 22px; bottom: 0; width: min(580px, calc(100vw - 28px)); height: min(650px, calc(100vh - 90px)); display: flex; flex-direction: column; background: #14181d; border-radius: 10px 10px 0 0; box-shadow: var(--shadow); border: 1px solid #333941; overflow: hidden; }
.compose-window.minimized { height: 42px; }
.compose-head { height: 42px; flex: none; display: flex; align-items: center; padding: 0 10px 0 14px; background: #242a31; font-weight: 650; }
.compose-head > span { flex: 1; }
.compose-icon { width: 32px; height: 32px; font-size: 18px; border-radius: 5px; }
.compose-window form { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.compose-field { display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 0 14px; border-bottom: 1px solid #333941; color: var(--muted); }
.compose-field input { flex: 1; height: 40px; border: 0; outline: none; background: transparent; color: var(--text); min-width: 0; }
.subject-field input { margin-left: -4px; }
.inline-btn { font-size: 12px; color: var(--muted); }
#bodyInput { flex: 1; min-height: 120px; border: 0; resize: none; outline: none; background: transparent; color: var(--text); padding: 14px; line-height: 1.5; }
.compose-foot { min-height: 54px; display: flex; align-items: center; gap: 8px; padding: 8px 12px; }
.send-btn { min-width: 80px; }
.attach-btn { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; cursor: pointer; color: #c2c6cb; }
.attach-btn:hover { background: rgba(255,255,255,.07); }
.send-status { color: var(--muted); font-size: 12px; }
.trash-btn { width: 36px; height: 36px; border-radius: 50%; }
.compose-attachments { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 12px; }
.compose-attachment { padding: 6px 9px; border-radius: 8px; background: #252b32; font-size: 12px; }

.modal { position: fixed; z-index: 100; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(0,0,0,.65); backdrop-filter: blur(7px); }
.modal-card { width: min(760px, 100%); max-height: min(820px, calc(100vh - 40px)); overflow: auto; background: #11151a; border: 1px solid #353b44; border-radius: 18px; box-shadow: var(--shadow); }
.modal-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; padding: 20px 22px 14px; background: rgba(17,21,26,.97); border-bottom: 1px solid #252b31; }
.modal-head > div { flex: 1; }
.modal-head h2 { margin: 0; }
.modal-head p { margin: 3px 0 0; color: var(--muted); }
.setup-content { padding: 20px 22px 28px; }
.setup-step { padding: 18px; background: #171c22; border: 1px solid #2d343d; border-radius: 14px; margin-bottom: 14px; }
.setup-step h3 { margin: 0 0 8px; }
.setup-step p { color: #b7bcc2; margin: 5px 0 12px; }
.setup-step code { background: #0a0d10; border: 1px solid #2d333a; border-radius: 7px; padding: 2px 6px; color: #d6e6ff; }
.status-pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 4px 9px; font-size: 11px; font-weight: 700; text-transform: uppercase; }
.status-good { background: #153c2b; color: #9be8c3; }
.status-warn { background: #493b16; color: #f7d879; }
.status-bad { background: #4a2020; color: #ffb0b0; }
.dns-table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 12px; }
.dns-table th, .dns-table td { text-align: left; padding: 9px 7px; border-bottom: 1px solid #2a3038; vertical-align: top; }
.dns-table th { color: var(--muted); font-weight: 500; }
.dns-table td:nth-child(3) { word-break: break-all; max-width: 360px; }
.copy-btn { padding: 4px 7px; border: 1px solid #3b424c; background: transparent; border-radius: 6px; color: #cdd1d6; cursor: pointer; }
.codeblock { white-space: pre-wrap; background: #090c0f; border: 1px solid #2e343c; border-radius: 10px; padding: 12px; color: #d2d8df; overflow-wrap: anywhere; }

.account-menu { position: fixed; z-index: 60; right: 18px; top: 58px; width: 260px; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 22px; background: #1b2026; border: 1px solid #353b44; border-radius: 18px; box-shadow: var(--shadow); }
.account-menu span { color: var(--muted); margin-bottom: 10px; }
.toast { position: fixed; z-index: 200; left: 50%; bottom: 26px; transform: translateX(-50%); min-width: 220px; max-width: min(520px, calc(100vw - 32px)); padding: 11px 16px; background: #e8eaed; color: #111; border-radius: 8px; box-shadow: var(--shadow); text-align: center; }
.mobile-only { display: none; }

@media (max-width: 820px) {
  .mobile-only { display: inline-grid; place-items: center; }
  .app { grid-template-columns: 1fr; grid-template-rows: 62px 1fr; }
  .topbar { grid-template-columns: 40px 1fr auto; gap: 8px; padding: 7px 10px; }
  .brand { display: none; }
  .search-wrap { grid-column: 2; }
  .top-actions #refreshBtn { display: none; }
  .sidebar { position: fixed; z-index: 70; top: 62px; bottom: 0; left: 0; width: 275px; transform: translateX(-110%); background: #11151a; box-shadow: var(--shadow); transition: transform .2s ease; }
  .sidebar.open { transform: translateX(0); }
  .main { grid-column: 1; grid-row: 2; margin: 0; border-radius: 0; border: 0; }
  .mail-row { grid-template-columns: 30px 30px minmax(95px,.8fr) minmax(160px,2fr) 65px; padding-right: 6px; }
  .message-content { padding: 16px 16px 40px; }
  .sender-row { grid-template-columns: 38px 1fr; }
  .sender-row time { grid-column: 2; }
  .message-content h1 { font-size: 22px; }
}
@media (max-width: 560px) {
  .mail-row { grid-template-columns: 28px 30px 100px 1fr; min-height: 58px; }
  .mail-row .date { display: none; }
  .subject-line { white-space: normal; max-height: 40px; line-height: 20px; }
  .subject-line .preview { display: none; }
  .compose-window { right: 0; width: 100vw; height: calc(100vh - 62px); border-radius: 0; }
  .auth-card { padding: 28px 20px; }
  .dns-table { display: block; overflow-x: auto; }
}
