:root {
  color-scheme: dark;
  --bg: #090b0e;
  --panel: #11151a;
  --panel-2: #171c22;
  --line: #282f38;
  --text: #f4f6f8;
  --muted: #919ba8;
  --accent: #ff5a1f;
  --accent-soft: rgba(255,90,31,.13);
  --green: #45d483;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at 25% -10%, #202731 0, var(--bg) 38%); color: var(--text); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.muted, .helper { color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--accent); font-size: 11px; font-weight: 800; letter-spacing: .14em; }
.error { color: #ff8870; font-size: 13px; }

.login-body { display: grid; place-items: center; padding: 24px; }
.login-card { width: min(440px, 100%); padding: 42px; border: 1px solid var(--line); border-radius: 22px; background: rgba(17,21,26,.92); box-shadow: 0 32px 90px rgba(0,0,0,.45); }
.login-card h1 { margin: 12px 0 6px; font-size: 32px; }
.login-logo { display: block; width: 130px; height: 104px; margin: -16px 0 2px -16px; object-fit: contain; filter: drop-shadow(0 12px 25px rgba(255,185,31,.16)); }
.header-logo { display: block; width: 51px; height: 48px; margin: -7px -3px -7px -8px; object-fit: contain; }
.login-form { display: grid; gap: 10px; margin-top: 32px; }
.login-form label { color: var(--muted); font-size: 13px; }
.login-form input, .address-field input { min-width: 0; border: 1px solid var(--line); outline: none; background: #0b0e12; color: var(--text); }
.login-form input { padding: 14px; border-radius: 10px; }
.login-form input:focus, .address-field:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-form button, .address-field button { border: 0; border-radius: 10px; padding: 14px 18px; color: #fff; background: var(--accent); font-weight: 750; cursor: pointer; }

.topbar { height: 66px; display: flex; align-items: center; gap: 24px; padding: 0 28px; border-bottom: 1px solid var(--line); background: rgba(9,11,14,.88); backdrop-filter: blur(16px); position: sticky; top: 0; z-index: 5; }
.brand { display: flex; align-items: center; gap: 11px; font-weight: 800; }
.status { margin-left: auto; color: var(--muted); font-size: 13px; }
.status-dot { display: inline-block; width: 8px; height: 8px; margin-right: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.ghost, .icon-button { border: 1px solid var(--line); color: var(--text); background: transparent; cursor: pointer; }
.ghost { padding: 8px 13px; border-radius: 8px; }
.ghost:hover, .icon-button:hover { background: var(--panel-2); }

.app-shell { width: min(1500px, 100%); margin: 0 auto; padding: 34px 28px; }
.mailbox-launcher { max-width: 780px; }
.address-field { display: grid; grid-template-columns: minmax(100px,1fr) auto auto; align-items: center; border: 1px solid var(--line); border-radius: 13px; background: #0b0e12; overflow: hidden; }
.address-field input { padding: 15px 4px 15px 16px; border: 0; font-size: 17px; }
.address-field span { color: var(--muted); padding: 0 12px 0 2px; }
.address-field button { margin: 5px; padding: 11px 17px; }
.helper { margin: 10px 0; font-size: 12px; }

.tabs { display: flex; gap: 8px; overflow-x: auto; margin: 28px 0 12px; padding-bottom: 4px; }
.tab { display: flex; align-items: center; gap: 8px; flex: none; padding: 9px 10px 9px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--panel); color: var(--muted); cursor: pointer; }
.tab.active { border-color: rgba(255,90,31,.55); color: var(--text); background: var(--accent-soft); }
.tab-at { color: var(--accent); font-weight: 900; }
.tab-close { display: grid; place-items: center; width: 20px; height: 20px; border-radius: 5px; color: var(--muted); font-size: 17px; }
.tab-close:hover { color: white; background: rgba(255,255,255,.1); }

.empty-state { display: grid; place-items: center; text-align: center; min-height: 400px; border: 1px dashed var(--line); border-radius: 16px; color: var(--muted); }
.empty-state h2 { color: var(--text); margin: 16px 0 0; }
.empty-state p { max-width: 480px; margin: 7px auto; }
.empty-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; color: var(--accent); background: var(--accent-soft); font-size: 26px; font-weight: 800; }
.empty-icon.small { width: 42px; height: 42px; margin: auto; font-size: 15px; }

.mail-panel { display: grid; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); height: calc(100vh - 250px); min-height: 520px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); }
.message-list-pane { min-width: 0; border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.pane-heading { display: flex; align-items: center; justify-content: space-between; padding: 20px; border-bottom: 1px solid var(--line); }
.pane-heading h2 { margin: 0; overflow: hidden; font-size: 16px; text-overflow: ellipsis; }
.icon-button { width: 36px; height: 36px; border-radius: 8px; font-size: 20px; }
.message-list { overflow-y: auto; }
.message-row { display: block; width: 100%; padding: 16px 18px; text-align: left; border: 0; border-bottom: 1px solid var(--line); color: var(--text); background: transparent; cursor: pointer; }
.message-row:hover, .message-row.selected { background: var(--panel-2); }
.message-row.selected { box-shadow: inset 3px 0 var(--accent); }
.row-top { display: flex; gap: 12px; align-items: baseline; }
.row-top strong { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 13px; }
.row-top time { margin-left: auto; flex: none; color: var(--muted); font-size: 10px; }
.row-subject { margin-top: 6px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 14px; font-weight: 650; }
.message-row p { margin: 5px 0 0; overflow: hidden; color: var(--muted); font-size: 12px; white-space: nowrap; text-overflow: ellipsis; }
.loading, .empty-list { padding: 40px 22px; text-align: center; color: var(--muted); }
.empty-list h3 { color: var(--text); margin-bottom: 4px; }
.empty-list p { line-height: 1.5; }

.message-view { min-width: 0; overflow-y: auto; background: #0d1014; }
.message-placeholder { display: grid; place-items: center; align-content: center; gap: 10px; height: 100%; color: var(--muted); }
.message-placeholder span { font-size: 32px; opacity: .5; }
.message-header { position: relative; padding: 34px 38px 26px; border-bottom: 1px solid var(--line); }
.message-header h1 { max-width: 780px; margin: 0 0 20px; font-size: 25px; line-height: 1.25; }
.message-header dl { display: grid; gap: 7px; margin: 0; color: var(--muted); font-size: 12px; }
.message-header dl div { display: grid; grid-template-columns: 65px 1fr; }
.message-header dt { color: #66717e; }
.message-header dd { margin: 0; overflow-wrap: anywhere; }
.message-actions { float: right; margin-left: 18px; }
.message-actions a { color: var(--accent); font-size: 12px; text-decoration: none; }
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 20px; }
.attachment { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border: 1px solid var(--line); border-radius: 9px; color: var(--text); text-decoration: none; background: var(--panel); }
.attachment > span { color: var(--accent); font-size: 19px; }
.attachment strong, .attachment small { display: block; max-width: 180px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.attachment strong { font-size: 11px; }
.attachment small { color: var(--muted); font-size: 9px; }
.message-body { padding: 38px; color: #1e242b; background: #fff; min-height: calc(100% - 180px); }
.html-email { overflow-wrap: anywhere; }
.html-email img { max-width: 100%; height: auto; }
.html-email a { color: #d94713; }
.plain-email { margin: 0; white-space: pre-wrap; word-break: break-word; color: #1e242b; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 13px; line-height: 1.6; }

@media (max-width: 800px) {
  .topbar { padding: 0 16px; }
  .status { display: none; }
  .app-shell { padding: 24px 14px; }
  .address-field { grid-template-columns: minmax(80px,1fr) auto; }
  .address-field button { grid-column: 1 / -1; margin-top: 0; }
  .mail-panel { display: block; height: auto; min-height: 520px; }
  .message-list-pane { border-right: 0; max-height: 420px; }
  .message-view { min-height: 500px; border-top: 1px solid var(--line); }
  .message-header, .message-body { padding: 24px 20px; }
  .login-card { padding: 30px 24px; }
}
