:root {
  --ink: #07080a;
  --ink-soft: #0b0e12;
  --panel: #0e1217;
  --panel-lift: #12171d;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.13);
  --paper: #e8eae6;
  --muted: #78828e;
  --faint: #4c555f;
  --postal: #5b9dff;
  --postal-soft: rgba(91, 157, 255, 0.14);
  --stamp: #eb5f43;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;
  --sans: 'IBM Plex Sans', system-ui, sans-serif;
  --rail-h: 4px;
}

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

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

body {
  margin: 0;
  background:
    radial-gradient(900px 380px at 50% -140px, rgba(91, 157, 255, 0.11), transparent 70%),
    var(--ink);
  color: var(--paper);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

.hidden { display: none !important; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* The airmail rail: the one loud element on the page. */
.rail {
  position: fixed; top: 0; left: 0; right: 0; height: var(--rail-h); z-index: 50;
  background-image:
    repeating-linear-gradient(135deg,
      var(--postal) 0 10px,
      var(--ink) 10px 16px,
      var(--stamp) 16px 26px,
      var(--ink) 26px 32px);
  background-size: 64px 100%;
  opacity: 0.85;
}

.page {
  max-width: 740px;
  margin: 0 auto;
  padding: calc(var(--rail-h) + 42px) 24px 64px;
}

/* --- masthead ------------------------------------------------------------ */

.masthead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 30px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--paper);
}

.wordmark-glyph {
  font-family: var(--mono);
  font-size: 14px;
  color: var(--ink);
  background: var(--paper);
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  line-height: 1;
  padding-top: 1px;
}

.wordmark-text {
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.015em;
}

.wordmark-text em {
  font-style: normal;
  color: var(--muted);
  margin-left: 5px;
  font-weight: 400;
}

.masthead-right {
  display: flex;
  align-items: center;
  gap: 18px;
}

.status {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.04em;
  color: var(--muted);
  text-transform: lowercase;
  white-space: nowrap;
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--muted);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.status.is-live .status-dot { background: var(--postal); box-shadow: 0 0 0 3px var(--postal-dim, rgba(91,157,255,0.16)); }
.status.is-live { color: #9aa4b0; }
.status.is-down .status-dot { background: var(--stamp); }
.status.is-down { color: var(--stamp); }

/* --- account ------------------------------------------------------------- */

.account { position: relative; }

.account-live { display: flex; align-items: center; gap: 12px; }

.account-name {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--paper);
}

.link-btn {
  font-family: var(--sans);
  font-size: 13px;
  background: none;
  border: 0;
  padding: 2px 0;
  color: var(--postal);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease, color 0.15s ease;
}

.link-btn:hover { border-bottom-color: currentColor; }
.link-btn-quiet { color: var(--muted); }
.link-btn-quiet:hover { color: var(--paper); }
.link-btn:focus-visible { outline: 2px solid var(--postal); outline-offset: 3px; border-radius: 2px; }

.auth-panel {
  position: absolute;
  right: 0;
  top: calc(100% + 14px);
  width: 296px;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  padding: 18px;
  z-index: 40;
  box-shadow: 0 30px 60px -18px rgba(0, 0, 0, 0.95);
}

.segmented {
  display: flex;
  gap: 2px;
  background: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 2px;
  margin-bottom: 16px;
}

.segment {
  flex: 1;
  font-family: var(--sans);
  font-size: 12px;
  padding: 7px 4px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.segment.active { background: var(--panel-lift); color: var(--paper); }
.segment:focus-visible { outline: 2px solid var(--postal); outline-offset: -2px; }

.field { display: block; margin-bottom: 14px; }

.field-label {
  display: block;
  font-size: 10.5px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 7px;
  font-weight: 500;
}

.input, .select {
  font-family: var(--sans);
  font-size: 14px;
  width: 100%;
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 11px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder { color: var(--faint); }

.input:focus, .select:focus {
  outline: none;
  border-color: var(--postal);
  box-shadow: 0 0 0 3px var(--postal-soft);
}

.select {
  font-family: var(--mono);
  font-size: 12.5px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2378828e' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.select option { background: var(--panel); color: var(--paper); }

/* --- buttons ------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--paper);
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover { border-color: var(--line-strong); background: var(--panel-lift); }
.btn:active { transform: translateY(0.5px); }
.btn:focus-visible { outline: 2px solid var(--postal); outline-offset: 2px; }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn svg { flex: 0 0 auto; color: var(--muted); }
.btn:hover svg { color: var(--paper); }

.btn-primary {
  background: var(--postal);
  border-color: var(--postal);
  color: #04121f;
  font-weight: 600;
}
.btn-primary:hover { background: #7ab0ff; border-color: #7ab0ff; color: #04121f; }

.btn-block { width: 100%; }
.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); }
.btn-quiet:hover { color: var(--paper); background: var(--panel-lift); border-color: transparent; }
.btn-quiet svg { color: inherit; }

.btn-tiny { padding: 5px 11px; font-size: 12px; border-radius: 7px; }

.btn.is-done { border-color: rgba(91, 157, 255, 0.5); color: var(--postal); }
.btn.is-done svg { color: var(--postal); }

.icon-btn {
  display: grid;
  place-items: center;
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.icon-btn:hover { background: var(--panel-lift); color: var(--paper); }
.icon-btn:focus-visible { outline: 2px solid var(--postal); outline-offset: 2px; }

/* --- hero ---------------------------------------------------------------- */

.hero {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(520px 200px at 12% -30%, rgba(91, 157, 255, 0.13), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008));
  padding: 20px 22px 16px;
  margin-bottom: 22px;
  overflow: hidden;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 6px;
}

.eyebrow {
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--sans);
  font-size: 12.5px;
  font-weight: 500;
  padding: 7px 13px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.035);
  color: var(--paper);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.chip-btn svg { color: var(--muted); transition: color 0.15s ease; }
.chip-btn:hover { border-color: rgba(91, 157, 255, 0.55); color: var(--postal); background: var(--postal-soft); }
.chip-btn:hover svg { color: var(--postal); }
.chip-btn:focus-visible { outline: 2px solid var(--postal); outline-offset: 3px; }

.address {
  display: block;
  width: 100%;
  min-width: 0;
  text-align: left;
  font-family: var(--mono);
  font-size: clamp(20px, 4.2vw, 29px);
  font-weight: 500;
  letter-spacing: -0.025em;
  line-height: 1.25;
  padding: 10px 0 14px;
  background: none;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: var(--paper);
  cursor: pointer;
  word-break: break-all;
  transition: border-color 0.15s ease;
}

.address:hover { border-bottom-color: rgba(91, 157, 255, 0.55); }
.address:focus-visible { outline: 2px solid var(--postal); outline-offset: 4px; border-radius: 4px; }

.address-at { color: var(--postal); }
.address.is-empty { color: var(--muted); font-size: clamp(16px, 3.4vw, 21px); }

.hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 14px 0;
}

.hero-hint {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--faint);
  font-family: var(--mono);
  white-space: nowrap;
}

.hero-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  border-top: 1px solid var(--line);
  padding-top: 12px;
}

.meta { margin: 0; font-size: 12.5px; color: var(--muted); }
.meta-strong { color: var(--paper); font-family: var(--mono); font-size: 11.5px; }

.meta-select { display: flex; align-items: center; gap: 8px; }
.meta-select .field-label { margin: 0; }
.meta-select .select { width: auto; min-width: 152px; }

/* --- panels -------------------------------------------------------------- */

.panel {
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  margin-bottom: 20px;
  overflow: hidden;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.012);
}

.panel-title {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.panel-tools { display: flex; align-items: center; gap: 14px; }

.panel-count {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

/* --- saved addresses ----------------------------------------------------- */

.address-rows { list-style: none; margin: 0; padding: 0; max-height: 232px; overflow-y: auto; }

.address-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 11px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  color: var(--paper);
  font-family: var(--mono);
  font-size: 13px;
  text-align: left;
  cursor: pointer;
  transition: background 0.12s ease;
}

.address-row:last-child { border-bottom: 0; }
.address-row:hover { background: rgba(255, 255, 255, 0.028); }
.address-row.active { color: var(--postal); background: var(--postal-soft); }
.address-row:focus-visible { outline: 2px solid var(--postal); outline-offset: -2px; }

.address-row-mark { font-size: 10.5px; color: var(--muted); font-family: var(--sans); text-transform: uppercase; letter-spacing: 0.08em; }
.address-row.active .address-row-mark { color: var(--postal); }

/* --- message list -------------------------------------------------------- */

.messages { list-style: none; margin: 0; padding: 0; max-height: 520px; overflow-y: auto; }

.message {
  display: grid;
  grid-template-columns: 54px 1fr auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 13px 16px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: none;
  text-align: left;
  color: var(--paper);
  cursor: pointer;
  transition: background 0.12s ease;
}

.message:last-child { border-bottom: 0; }
.message:hover { background: rgba(255, 255, 255, 0.028); }
.message:focus-visible { outline: 2px solid var(--postal); outline-offset: -2px; }

.message-time {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
}

.message-body { min-width: 0; }

.message-subject {
  display: block;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.message-from {
  display: block;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.message-flag {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--postal);
  opacity: 0;
  align-self: center;
}

.message.is-new .message-flag { opacity: 1; }
.message.is-new .message-subject { font-weight: 600; }
.message.is-new { animation: arrive 0.45s ease-out; }

@keyframes arrive {
  from { background: var(--postal-soft); }
  to { background: transparent; }
}

.empty { padding: 40px 24px 34px; text-align: center; }

.empty-emoji {
  display: block;
  font-size: 30px;
  line-height: 1;
  margin-bottom: 14px;
  filter: saturate(0.9);
}

.empty-title { margin: 0 0 6px; font-size: 14px; font-weight: 500; }
.empty-body { margin: 0; font-size: 12.5px; color: var(--muted); max-width: 38ch; margin-inline: auto; }

.empty-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 16px;
}

/* --- notes and footer ---------------------------------------------------- */

.note {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.55;
  color: var(--muted);
}

.note-error { color: var(--stamp); }
.note-inset { padding: 0 16px 12px; margin: 0; }

.footer {
  margin-top: 34px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.footer p { margin: 0; font-size: 12px; color: var(--muted); max-width: 60ch; }

/* --- composer dialog ----------------------------------------------------- */

.dialog {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(4, 6, 9, 0.72);
  animation: fade 0.16s ease-out;
}

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

.dialog-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 36px 90px -24px rgba(0, 0, 0, 0.95);
  animation: pop 0.18s ease-out;
}

@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.dialog-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 16px;
}

.dialog-title { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }

.dialog-note { margin: 4px 0 0; font-size: 12px; color: var(--muted); max-width: 40ch; }

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.compose-field {
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--ink);
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.compose-field:focus-within { border-color: var(--postal); box-shadow: 0 0 0 3px var(--postal-soft); }

.compose-field .input {
  border: 0;
  border-radius: 0;
  background: transparent;
  font-family: var(--mono);
  font-size: 13.5px;
}

.compose-field .input:focus { box-shadow: none; }

.compose-suffix {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--muted);
  padding-right: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 50%;
}

.domain-chips { display: flex; flex-wrap: wrap; gap: 8px; }

.domain-chip {
  font-family: var(--mono);
  font-size: 12.5px;
  padding: 8px 13px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.domain-chip:hover { color: var(--paper); border-color: var(--line-strong); }
.domain-chip.active { color: var(--postal); border-color: rgba(91, 157, 255, 0.5); background: var(--postal-soft); }
.domain-chip:focus-visible { outline: 2px solid var(--postal); outline-offset: 2px; }

/* --- message viewer ------------------------------------------------------ */

.viewer {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: var(--ink);
  display: flex;
  flex-direction: column;
  animation: rise 0.22s ease-out;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.viewer-bar {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}

.viewer-titles { flex: 1; min-width: 0; }

.viewer-tools {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
}

.viewer-subject {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.viewer-from {
  margin: 2px 0 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.viewer-date {
  margin: 0;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  padding-top: 4px;
}

.viewer-notice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
  font-size: 12px;
  color: var(--muted);
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.viewer-frame {
  flex: 1;
  width: 100%;
  border: 0;
  background: #fff;
}

.viewer-status {
  flex: 1;
  margin: 0;
  padding: 48px 28px;
  font-size: 13.5px;
  line-height: 1.65;
  color: var(--muted);
  text-align: center;
  max-width: 52ch;
  margin-inline: auto;
}

/* --- responsive ---------------------------------------------------------- */

@media (max-width: 640px) {
  .page { padding-left: 16px; padding-right: 16px; }
  .masthead { flex-wrap: wrap; gap: 14px; }
  .masthead-right { width: 100%; justify-content: space-between; }
  .auth-panel { right: auto; left: 0; width: min(296px, calc(100vw - 48px)); }
  .hero { padding: 18px 16px 14px; }
  .hero-hint { display: none; }
  .hero-actions .btn { flex: 1; }
  .message { grid-template-columns: 48px 1fr auto; gap: 10px; padding: 12px 14px; }
  .meta-select { width: 100%; }
  .meta-select .select { flex: 1; }
  .viewer-bar { flex-wrap: wrap; }
  .viewer-date { padding-top: 0; }
  .dialog-card { padding: 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}
