:root {
  color-scheme: dark;
  --bg: #080909;
  --panel: #0d0f0f;
  --panel-2: #131616;
  --line: #252a29;
  --line-soft: #1b1f1e;
  --text: #f1f4f1;
  --muted: #8d9692;
  --soft: #c9d0cc;
  --accent: #d8ff7a;
  --accent-ink: #11150b;
  --danger: #ff7d86;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: -0.01em;
}

button, input { font: inherit; }

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  min-height: 44px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  cursor: pointer;
  font-weight: 720;
  padding: 0.72rem 0.95rem;
  transition: transform 140ms ease, background 140ms ease, border-color 140ms ease;
}

button:hover { background: #e8ffae; border-color: #e8ffae; transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: 0.62; transform: none; }

input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  background: #080a0a;
  color: var(--text);
  padding: 0.78rem 0.85rem;
}

input::placeholder { color: #5f6964; }
input:focus { border-color: #6b7a62; box-shadow: 0 0 0 3px rgba(216, 255, 122, 0.08); }
label { color: var(--soft); font-size: 0.9rem; font-weight: 650; }
h1, h2, h3, p { margin-top: 0; }
.hidden { display: none !important; }

.login-view {
  display: grid;
  min-height: 100vh;
  place-items: center;
  padding: 1.25rem;
  background: var(--bg);
}

.login-wrap { width: min(100%, 390px); }
.login-brand { display: flex; align-items: center; gap: 0.75rem; margin: 0 0 1.3rem 0.15rem; }
.login-brand strong { display: block; font-size: 0.84rem; letter-spacing: 0.13em; }
.login-brand span { display: block; color: var(--muted); font-size: 0.66rem; letter-spacing: 0.11em; margin-top: 0.18rem; }

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid #3f4b3b;
  border-radius: 9px;
  background: #161d14;
  color: var(--accent);
  font-size: 1rem;
  font-weight: 850;
  letter-spacing: -0.05em;
}
.brand-mark.small { width: 38px; height: 38px; margin: 0; }

.login-panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.24);
  padding: 1.5rem;
}
.login-kicker { color: var(--accent); font-size: 0.75rem; font-weight: 800; letter-spacing: 0.11em; text-transform: uppercase; }
h1 { margin: 0.55rem 0 0.5rem; font-size: 2rem; font-weight: 780; line-height: 1.08; }
.muted { color: var(--muted); line-height: 1.55; margin-bottom: 1.55rem; }
.stack { display: grid; gap: 0.65rem; margin-top: 1.15rem; }
.button-arrow { font-size: 1.1rem; line-height: 0; }
.notice { min-height: 1.4rem; margin-top: 1rem; color: var(--muted); font-size: 0.94rem; line-height: 1.45; }
.notice.error { color: var(--danger); }
.link-button { min-height: 30px; border: 0; background: transparent; color: var(--muted); font-size: 0.86rem; padding: 0.2rem; text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 0.2em; }
.link-button:hover { border: 0; background: transparent; color: var(--text); text-decoration-color: currentColor; transform: none; }

.portal-view { display: grid; min-height: 100vh; grid-template-columns: 232px 1fr; }
.rail { display: flex; flex-direction: column; justify-content: space-between; border-right: 1px solid var(--line-soft); background: #060707; padding: 1.15rem; }
.brand-row { display: flex; align-items: center; gap: 0.72rem; padding: 0.35rem 0.3rem; }
.brand-row strong { letter-spacing: 0.04em; }
.brand-row span { display: block; color: var(--muted); font-size: 0.82rem; margin-top: 0.15rem; }
.nav { display: grid; gap: 0.35rem; margin-top: 2rem; }
.nav-item, .ghost { border: 1px solid transparent; background: transparent; color: var(--muted); text-align: left; }
.nav-item { justify-content: flex-start; font-weight: 650; }
.nav-item.active, .nav-item:hover, .ghost:hover { border-color: var(--line); background: var(--panel); color: var(--text); }
.nav-icon { display: grid; width: 22px; height: 22px; place-items: center; border: 1px solid var(--line); border-radius: 5px; color: var(--soft); font-size: 0.76rem; }
.nav-item.active .nav-icon { border-color: #53633f; color: var(--accent); }
.rail-footer { display: grid; gap: 0.7rem; }
.connection { color: var(--muted); font-size: 0.78rem; padding: 0.35rem; }
.connection i { display: inline-block; width: 6px; height: 6px; margin-right: 0.35rem; border-radius: 50%; background: var(--accent); vertical-align: 0.08em; }

.workspace { display: grid; min-width: 0; max-width: 1420px; grid-template-rows: auto auto auto 1fr; padding: 1.35rem 1.7rem; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; border-bottom: 1px solid var(--line-soft); padding: 0.4rem 0 1rem; }
.actions { display: flex; align-items: center; gap: 0.55rem; }
.eyebrow { color: var(--muted); font-size: 0.76rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.eyebrow span { color: var(--soft); letter-spacing: 0; text-transform: none; }
h2 { margin: 0.4rem 0 0; font-size: 1.7rem; font-weight: 730; }
.status-bar { min-height: 1.7rem; color: var(--muted); padding: 0.65rem 0; }
.status-bar.error { color: var(--danger); }
.refresh-symbol { font-size: 1.1rem; line-height: 0; }

.stats-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0.75rem; margin: 0.1rem 0 1rem; }
.stat-card { display: grid; gap: 0.3rem; border: 1px solid var(--line-soft); border-radius: 9px; background: #0b0d0d; padding: 0.8rem 0.95rem; }
.stat-card span { color: var(--muted); font-size: 0.78rem; }
.stat-card strong { font-size: 1.18rem; font-weight: 740; }
.stat-card.quiet strong { color: var(--accent); font-size: 0.98rem; }

.content-grid { display: grid; min-height: 0; grid-template-columns: minmax(320px, 420px) minmax(0, 1fr); gap: 1rem; }
.list-pane, .detail-pane, .aliases-pane { min-height: 0; border: 1px solid var(--line-soft); border-radius: 10px; background: var(--panel); overflow: hidden; }
.list-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line-soft); color: var(--soft); font-weight: 700; padding: 0.85rem 1rem; }
.count-pill { display: inline-grid; min-width: 1.6rem; min-height: 1.6rem; place-items: center; border-radius: 999px; background: var(--panel-2); color: var(--soft); font-size: 0.78rem; }
.message-list, .alias-list { max-height: calc(100vh - 300px); overflow: auto; }
.message-item, .alias-item { width: 100%; min-height: auto; border: 0; border-bottom: 1px solid var(--line-soft); border-radius: 0; background: transparent; color: var(--text); display: grid; gap: 0.38rem; padding: 0.95rem 1rem; text-align: left; }
.message-item:hover, .message-item.active { background: var(--panel-2); transform: none; }
.message-item.unread { box-shadow: inset 2px 0 0 var(--accent); }
.message-meta, .alias-meta { color: var(--muted); font-size: 0.82rem; }
.message-subject { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.detail-pane { display: flex; flex-direction: column; }
.message-full { display: grid; gap: 0.9rem; padding: 1.1rem; }
.message-body { border-top: 1px solid var(--line-soft); color: var(--soft); line-height: 1.65; margin-top: 0.3rem; padding-top: 1rem; white-space: pre-wrap; word-break: break-word; }
.empty-state { display: grid; min-height: 100%; place-content: center; padding: 2rem; text-align: center; }
.empty-state p { color: var(--muted); line-height: 1.55; }
.empty-icon { display: grid; width: 44px; height: 44px; margin: 0 auto 1rem; place-items: center; border: 1px solid #53633f; border-radius: 9px; color: var(--accent); font-weight: 800; }

.alias-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 0.8rem; border-bottom: 1px solid var(--line-soft); padding: 1rem; }
.alias-input { display: grid; grid-template-columns: 1fr auto; align-items: center; margin-top: 0.45rem; border: 1px solid var(--line); border-radius: 7px; background: #080a0a; }
.alias-input input { border: 0; box-shadow: none; }
.alias-input span { color: var(--muted); padding-right: 0.85rem; }
.alias-item { grid-template-columns: 1fr auto; align-items: center; }
.alias-item button { border-color: #3a2024; background: #16090b; color: #ff9ba5; }

@media (max-width: 900px) {
  .portal-view { grid-template-columns: 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line-soft); flex-direction: row; gap: 1rem; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 1rem; }
  .rail-footer { align-content: space-between; }
  .content-grid { grid-template-columns: 1fr; }
  .detail-pane { min-height: 340px; }
  .message-list, .alias-list { max-height: 420px; }
}

@media (max-width: 620px) {
  .login-panel { padding: 1.1rem; }
  h1 { font-size: 1.7rem; }
  h2 { font-size: 1.4rem; }
  .workspace { padding: 1rem; }
  .topbar, .rail, .actions, .alias-form { align-items: stretch; flex-direction: column; grid-template-columns: 1fr; }
  .actions { width: 100%; }
  .stats-row { grid-template-columns: 1fr 1fr; }
  .stat-card.quiet { display: none; }
}
