:root {
  --bg: #0b0d0f;
  --panel: #111417;
  --panel-2: #161a1e;
  --panel-3: #1b2025;
  --line: rgba(255,255,255,.08);
  --muted: #8f979f;
  --text: #f2f3f2;
  --soft: #c7ccd0;
  --gold: #c7a462;
  --gold-2: #e4ca93;
  --green: #6bbfa8;
  --danger: #e27777;
  --shadow: 0 24px 70px rgba(0,0,0,.45);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Inter", sans-serif;
  color: var(--text);
  background: var(--bg);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; width: 100%; height: 100%; overflow: hidden; background: var(--bg); }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

.login-screen {
  position: fixed; z-index: 120; inset: 0; display: grid; place-items: center; padding: 28px;
  background: radial-gradient(circle at 75% 10%, rgba(199,164,98,.14), transparent 38%), #090b0d;
}
.login-card { width: min(470px, 100%); padding: 42px; border: 1px solid rgba(255,255,255,.1); border-radius: 22px; background: rgba(17,20,23,.96); box-shadow: var(--shadow); }
.login-card > img { display: block; width: min(300px, 100%); margin: 0 auto 30px; padding: 9px; border-radius: 13px; background: #f7f5ef; }
.login-card h1 { margin: 0; font-size: clamp(34px, 8vw, 52px); line-height: 1.02; }
.login-copy { margin: 18px 0 28px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.login-card form { display: grid; gap: 14px; }
.login-card label { display: grid; gap: 7px; }
.login-card label span { color: #7b8388; font-size: 9px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; }
.login-card input { width: 100%; padding: 13px 14px; border: 1px solid var(--line); border-radius: 11px; outline: 0; background: #0d1012; color: var(--text); }
.login-card input:focus { border-color: rgba(199,164,98,.45); box-shadow: 0 0 0 3px rgba(199,164,98,.08); }
.login-card .send-button { min-height: 44px; margin-top: 4px; }
.login-error { margin: 0; padding: 10px 12px; border-radius: 9px; background: rgba(226,119,119,.1); color: #f0a0a0; font-size: 11px; }

.app-shell {
  display: grid;
  grid-template-columns: 260px minmax(360px, 430px) minmax(460px, 1fr);
  width: 100vw;
  height: 100vh;
  background:
    radial-gradient(circle at 80% -20%, rgba(199,164,98,.07), transparent 40%),
    var(--bg);
}

.sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px 18px 18px;
  border-right: 1px solid var(--line);
  background: rgba(14,17,19,.92);
}

.brand { display: grid; gap: 8px; padding: 0 8px 18px; }
.brand-logo-panel {
  display: flex; align-items: center; justify-content: center; width: 100%; height: auto; aspect-ratio: 1.78; padding: 6px;
  min-height: 0; overflow: hidden; border-radius: 12px; background: #f7f5ef; border: 1px solid rgba(228,202,147,.3);
}
.brand-logo-panel img { display: block; width: 100%; height: auto; min-width: 0; object-fit: contain; }
.product-name { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.product-name strong { display: block; font-size: 16px; letter-spacing: -.02em; }
.product-name small { display: block; color: var(--muted); font-size: 9px; }

.compose-primary {
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  margin: 2px 2px 22px;
  display: flex;
  align-items: center;
  gap: 9px;
  background: linear-gradient(135deg, var(--gold-2), var(--gold));
  color: #101112;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 10px 30px rgba(199,164,98,.16);
}
.compose-primary:hover { filter: brightness(1.06); transform: translateY(-1px); }
.plus { font-size: 20px; line-height: 1; font-weight: 400; }

.primary-nav, .account-list { display: grid; gap: 4px; }
.nav-item, .account-item, .footer-action {
  width: 100%; border: 0; background: transparent; cursor: pointer;
  display: grid; grid-template-columns: 24px 1fr auto; align-items: center;
  gap: 8px; min-height: 38px; padding: 8px 10px; border-radius: 10px;
  color: var(--soft); text-align: left; font-size: 13px;
}
.nav-item:hover, .account-item:hover, .footer-action:hover { background: rgba(255,255,255,.045); color: var(--text); }
.nav-item.active, .account-item.active {
  background: linear-gradient(90deg, rgba(199,164,98,.16), rgba(199,164,98,.04));
  color: var(--gold-2);
  box-shadow: inset 2px 0 var(--gold);
}
.nav-item b { min-width: 22px; padding: 2px 6px; border-radius: 10px; text-align: center; background: rgba(255,255,255,.06); font-size: 10px; }
.nav-icon { color: var(--muted); font-size: 15px; text-align: center; }

.section-label {
  display: flex; justify-content: space-between; align-items: center;
  margin: 24px 9px 9px; color: #666f76; text-transform: uppercase;
  letter-spacing: .11em; font-size: 9px; font-weight: 800;
}
.section-label button { background: none; border: 0; color: #70777d; cursor: pointer; letter-spacing: 1px; }
.account-list { overflow: auto; padding-right: 2px; }
.account-item { grid-template-columns: 10px 1fr auto; }
.account-dot { width: 7px; height: 7px; border-radius: 50%; box-shadow: 0 0 0 3px rgba(255,255,255,.03); }
.account-copy { min-width: 0; }
.account-copy strong { display: block; overflow: hidden; text-overflow: ellipsis; font-size: 12px; font-weight: 640; color: inherit; }
.account-copy small { display: block; margin-top: 2px; color: #656d74; overflow: hidden; text-overflow: ellipsis; }
.account-state { width: 7px; height: 7px; border: 1px solid #5d656b; border-radius: 50%; }
.account-state.connected { background: var(--green); border-color: var(--green); }
.account-state.error { background: var(--danger); border-color: var(--danger); }

.sidebar-footer { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.footer-action { grid-template-columns: 22px 1fr; }
.privacy-state { display: flex; align-items: center; gap: 7px; color: #666e74; font-size: 10px; padding: 10px; }
.privacy-state > span { width: 6px; height: 6px; background: var(--green); border-radius: 50%; box-shadow: 0 0 10px rgba(107,191,168,.5); }

.mail-column { min-width: 0; display: flex; flex-direction: column; border-right: 1px solid var(--line); background: rgba(17,20,23,.82); }
.mail-header { display: flex; align-items: end; justify-content: space-between; gap: 18px; padding: 27px 22px 18px; }
.eyebrow { margin: 0 0 6px; color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .14em; }
h1 { margin: 0; font-size: 25px; letter-spacing: -.035em; }
.header-actions { display: flex; gap: 8px; align-items: center; }
.search-box {
  min-width: 185px; display: flex; align-items: center; gap: 8px; padding: 8px 9px;
  border: 1px solid var(--line); border-radius: 10px; background: rgba(0,0,0,.16); color: #687078;
}
.search-box:focus-within { border-color: rgba(199,164,98,.38); box-shadow: 0 0 0 3px rgba(199,164,98,.07); }
.search-box input { width: 100%; border: 0; outline: 0; color: var(--text); background: transparent; font-size: 11px; }
.search-box kbd { padding: 2px 5px; border: 1px solid var(--line); border-radius: 5px; color: #666e74; font-size: 8px; white-space: nowrap; }
.icon-button {
  width: 34px; height: 34px; display: grid; place-items: center; border: 1px solid var(--line);
  border-radius: 10px; background: rgba(255,255,255,.03); cursor: pointer; font-size: 16px;
}
.icon-button:hover { border-color: rgba(199,164,98,.35); background: rgba(199,164,98,.08); }
.sync-button.syncing { animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 22px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  color: #767e85; font-size: 10px;
}
.sync-status { display: flex; align-items: center; gap: 7px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.message-list { overflow: auto; flex: 1; padding: 7px 8px 18px; }
.message-row {
  display: grid; grid-template-columns: 42px 1fr auto; gap: 10px; padding: 14px 12px;
  border-bottom: 1px solid rgba(255,255,255,.045); border-radius: 10px; cursor: pointer;
  transition: background .15s ease, transform .15s ease;
}
.message-row:hover { background: rgba(255,255,255,.038); }
.message-row.active { background: linear-gradient(100deg, rgba(199,164,98,.13), rgba(199,164,98,.035)); box-shadow: inset 2px 0 var(--gold); }
.message-row.unread .message-sender, .message-row.unread .message-subject { color: var(--text); font-weight: 720; }
.avatar { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 11px; color: #101214; font-size: 11px; font-weight: 800; }
.message-main { min-width: 0; }
.message-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.message-sender { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: #d3d7da; }
.message-time { flex: none; color: #626a70; font-size: 9px; }
.message-subject { margin-top: 5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #bcc1c5; font-size: 11px; }
.message-snippet { margin-top: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #6c747a; font-size: 10px; }
.message-badges { display: flex; align-items: center; gap: 4px; margin-top: 7px; }
.mini-pill { padding: 2px 6px; border: 1px solid var(--line); border-radius: 8px; color: #747c82; font-size: 8px; }
.unread-dot { width: 6px; height: 6px; margin-top: 4px; border-radius: 50%; background: var(--gold); }
.list-empty { height: 100%; display: grid; place-items: center; text-align: center; color: #687078; padding: 40px; }
.list-empty strong { display: block; color: #bdc2c6; margin-bottom: 7px; }

.reader { min-width: 0; position: relative; background: rgba(11,13,15,.7); overflow: hidden; }
.mobile-reader-close { display: none; }
.reader-empty { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; padding: 40px; }
.empty-orbit {
  width: 90px; height: 90px; display: grid; place-items: center; position: relative;
  border: 1px solid rgba(199,164,98,.28); border-radius: 50%; color: var(--gold-2); font-weight: 760;
  box-shadow: 0 0 80px rgba(199,164,98,.08), inset 0 0 30px rgba(199,164,98,.04);
}
.empty-orbit:after { content: ""; position: absolute; width: 7px; height: 7px; top: 5px; right: 15px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 12px var(--gold); }
.reader-empty h2 { margin: 22px 0 7px; font-size: 20px; }
.reader-empty p { max-width: 330px; margin: 0 0 20px; color: #737b81; font-size: 12px; line-height: 1.6; }
.secondary-button { border: 1px solid var(--line); border-radius: 10px; background: rgba(255,255,255,.04); padding: 9px 13px; color: #d4d8da; cursor: pointer; }
.secondary-button:hover { border-color: rgba(199,164,98,.35); }
.reader-content { height: 100%; overflow: auto; }
.reader-header { padding: 34px 38px 22px; border-bottom: 1px solid var(--line); }
.reader-actions { float: right; display: flex; gap: 7px; }
.action-button { border: 1px solid rgba(199,164,98,.25); border-radius: 10px; background: rgba(199,164,98,.08); color: var(--gold-2); padding: 8px 12px; cursor: pointer; }
.reader-header h2 { max-width: 680px; margin: 0 100px 27px 0; font-size: 24px; line-height: 1.25; letter-spacing: -.025em; }
.sender-card { display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px; }
.sender-avatar { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 12px; background: var(--gold); color: #111; font-size: 12px; font-weight: 800; }
.sender-meta strong { display: block; font-size: 12px; }
.sender-meta span, .sender-card time { display: block; color: #70787e; font-size: 10px; margin-top: 4px; }
.delivery-row { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin: 15px 0 0 54px; color: #717980; font-size: 10px; }
.account-pill { border: 1px solid var(--line); border-radius: 9px; padding: 4px 7px; color: #969da2; }
.message-frame { display: block; width: calc(100% - 48px); min-height: 650px; margin: 24px; border: 0; border-radius: 12px; background: #fff; }

.modal-backdrop { position: fixed; z-index: 40; inset: 0; display: grid; place-items: center; padding: 28px; background: rgba(2,3,4,.74); backdrop-filter: blur(18px); }
.compose-card, .settings-card { width: min(960px, 94vw); max-height: 95vh; overflow: auto; border: 1px solid rgba(255,255,255,.1); border-radius: 18px; background: #121619; box-shadow: var(--shadow); }
.compose-card > header, .settings-card > header { display: flex; justify-content: space-between; align-items: center; padding: 20px 22px; border-bottom: 1px solid var(--line); }
.compose-card h2, .settings-card h2 { margin: 0; font-size: 20px; }
.compose-card form { padding: 4px 22px 20px; }
.form-row { display: grid; grid-template-columns: 70px 1fr; align-items: center; border-bottom: 1px solid var(--line); }
.form-row label { color: #737b81; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; }
.form-row input, .form-row select { width: 100%; border: 0; outline: 0; background: transparent; color: var(--text); padding: 14px 0; font-size: 12px; }
.form-row select, .signature-control select { appearance: none; }
.identity-row { grid-template-columns: 70px 1fr 28px; }
.from-badge { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; color: #111; background: var(--gold); font-size: 9px; font-weight: 800; }
.address-details { border-bottom: 1px solid var(--line); }
.address-details summary { padding: 10px 0 10px 70px; color: #777f85; font-size: 10px; cursor: pointer; }
.address-details .form-row:last-child { border-bottom: 0; }
.compose-body { width: 100%; min-height: 170px; resize: vertical; margin-top: 12px; border: 0; outline: 0; background: transparent; color: var(--text); line-height: 1.7; font-size: 13px; }
.signature-preview-wrap { display: grid; grid-template-columns: 190px minmax(0, 1fr); gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px; background: rgba(0,0,0,.14); }
.signature-control { padding: 9px; }
.signature-control label { display: block; margin-bottom: 8px; color: #747c82; font-size: 9px; text-transform: uppercase; letter-spacing: .08em; }
.signature-control select { width: 100%; border: 1px solid var(--line); border-radius: 9px; background: #1b2024; color: var(--text); padding: 9px; font-size: 10px; }
.signature-preview-wrap iframe { width: 100%; height: 280px; border: 0; border-radius: 8px; background: white; }
.compose-card footer { display: flex; justify-content: space-between; align-items: center; gap: 14px; margin-top: 18px; }
.send-area { display: flex; align-items: center; gap: 12px; }
#sendStatus { color: #7b8388; font-size: 10px; }
.send-button { border: 0; border-radius: 10px; padding: 10px 16px; background: linear-gradient(135deg, var(--gold-2), var(--gold)); color: #101112; font-weight: 750; cursor: pointer; }

.settings-card { width: min(760px, 94vw); padding-bottom: 18px; }
.signature-list, .account-status-list { display: grid; gap: 10px; padding: 18px 22px; }
.signature-item, .account-status-item { display: grid; grid-template-columns: 1fr auto; gap: 14px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); }
.signature-item h3, .account-status-item h3 { margin: 0; font-size: 12px; }
.signature-item p, .account-status-item p { margin: 5px 0 0; color: #747c82; font-size: 10px; }
.signature-item button { align-self: center; }
.status-label { align-self: center; padding: 4px 8px; border-radius: 9px; background: rgba(107,191,168,.1); color: var(--green); font-size: 9px; }
.status-label.error { color: var(--danger); background: rgba(226,119,119,.1); }
.settings-note { margin: 0 22px; padding: 13px; border-radius: 10px; background: rgba(199,164,98,.06); color: #8c9297; font-size: 10px; line-height: 1.55; }
.settings-content { display: grid; gap: 10px; padding: 18px 22px 4px; }
.settings-group, .setting-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.025); }
.settings-group h3, .pin-form h3 { margin: 0; font-size: 13px; }
.settings-group p, .pin-form p { margin: 5px 0 0; color: var(--muted); font-size: 10px; line-height: 1.5; }
.setting-row > span { display: grid; gap: 4px; }
.setting-row b { font-size: 12px; }
.setting-row small { color: var(--muted); font-size: 10px; }
.setting-row select { min-width: 145px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel-3); color: var(--text); }
.setting-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--gold); }
.settings-save { justify-self: end; }
.pin-form { display: grid; grid-template-columns: 1.3fr 1fr 1fr 1fr auto; gap: 9px; align-items: center; margin-top: 8px; padding: 15px; border-top: 1px solid var(--line); }
.pin-form input { min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: 9px; outline: none; background: #0d1012; color: var(--text); font-size: 10px; }
.settings-inline-status { grid-column: 2 / -1; min-height: 14px; margin: 0; color: var(--muted); font-size: 10px; }
body.compact .message-row { padding-top: 8px; padding-bottom: 8px; }

:root[data-theme="light"] {
  --bg: #e9ecef; --panel: #ffffff; --panel-2: #f6f7f8; --panel-3: #e8ebee;
  --line: rgba(20,28,35,.12); --muted: #687078; --text: #171a1d; --soft: #353b40;
  color-scheme: light;
}
:root[data-theme="light"] .app-shell { background: #eef0f2; }
:root[data-theme="light"] .sidebar, :root[data-theme="light"] .mail-column { background: rgba(255,255,255,.94); }
:root[data-theme="light"] .reader { background: #f4f5f6; }
:root[data-theme="light"] .compose-card, :root[data-theme="light"] .settings-card { background: #fff; }
:root[data-theme="light"] .form-row input, :root[data-theme="light"] .form-row select, :root[data-theme="light"] .compose-body { color: #171a1d; }
:root[data-theme="light"] .pin-form input, :root[data-theme="light"] .login-card input { background: #f3f5f6; color: #171a1d; }
.toast { position: fixed; z-index: 80; right: 24px; bottom: 24px; max-width: 360px; padding: 12px 15px; border: 1px solid rgba(107,191,168,.3); border-radius: 11px; background: #17201e; box-shadow: var(--shadow); color: #c9e7df; font-size: 11px; }

@media (max-width: 900px) {
  .pin-form { grid-template-columns: 1fr; }
  .settings-inline-status { grid-column: 1; }
  .settings-group, .setting-row { align-items: flex-start; }
}

@media (max-width: 1080px) {
  .app-shell { grid-template-columns: 220px 360px 1fr; }
  .sidebar { padding-left: 12px; padding-right: 12px; }
  .search-box { min-width: 150px; }
}

@media (max-width: 820px) {
  .app-shell { grid-template-columns: 68px minmax(0, 1fr); }
  .sidebar { padding: 14px 8px; }
  .brand { padding: 0 0 12px; }
  .brand-logo-panel { width: 50px; height: 40px; aspect-ratio: auto; padding: 3px; margin: auto; overflow: hidden; }
  .brand-logo-panel img { width: 100%; height: auto; object-position: center; }
  .product-name, .compose-primary span:not(.plus), .nav-item span:nth-child(2), .nav-item b,
  .account-copy, .section-label span, .section-label button, .footer-action:not(:focus) { font-size: 0; }
  .compose-primary { justify-content: center; margin: 0 1px 14px; padding: 10px; }
  .primary-nav { justify-items: center; }
  .nav-item, .account-item, .footer-action { display: grid; grid-template-columns: 1fr; justify-items: center; padding: 8px 4px; }
  .section-label { margin: 12px 0 5px; min-height: 1px; }
  .account-item { min-height: 28px; }
  .account-dot { width: 9px; height: 9px; }
  .footer-action span { font-size: 14px; }
  .account-state, .privacy-state { display: none; }
  .mail-column { border-right: 0; }
  .mail-header { display: grid; align-items: start; padding: 20px 14px 12px; }
  .header-actions { width: 100%; }
  .search-box { flex: 1; min-width: 0; }
  .reader { display: none; }
  .reader.mobile-open { display: block; position: fixed; inset: 0; z-index: 30; background: var(--bg); }
  .reader-header { padding: 18px 16px; }
  .mobile-reader-close { display: inline-block; margin: 0 0 20px; border: 0; background: none; color: var(--gold-2); font-size: 13px; cursor: pointer; }
  .reader-header h2 { margin-right: 0; font-size: 20px; }
  .reader-actions { margin-top: 0; }
  .message-frame { width: calc(100% - 24px); margin: 12px; }
  .modal-backdrop { padding: 0; align-items: end; }
  .compose-card, .settings-card { width: 100vw; max-height: 96vh; border-radius: 18px 18px 0 0; }
  .signature-preview-wrap { grid-template-columns: 1fr; }
  .signature-preview-wrap iframe { height: 260px; }
}
