@font-face {
  font-family: "Manrope";
  src: url("/brand/fonts/manrope-regular.ttf") format("truetype");
  font-weight: 400 500;
  font-display: swap;
}
@font-face {
  font-family: "Manrope";
  src: url("/brand/fonts/manrope-bold.ttf") format("truetype");
  font-weight: 600 800;
  font-display: swap;
}
@font-face {
  font-family: "IBM Plex Mono";
  src: url("/brand/fonts/ibm-plex-mono.ttf") format("truetype");
  font-weight: 400 500;
  font-display: swap;
}

:root {
  color-scheme: light;
  --ink: #11141b;
  --muted: #6e7785;
  --paper: #f3f2ee;
  --panel: #ffffff;
  --chrome: #11141b;
  --line: rgba(17, 20, 27, 0.11);
  --line-strong: rgba(17, 20, 27, 0.24);
  --cobalt: #1742c6;
  --cobalt-bright: #3b82f6;
  --cobalt-soft: rgba(23, 66, 198, 0.08);
  --danger: #ad3c38;
  --font: "Manrope", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, SFMono-Regular, monospace;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 13.5px/1.5 var(--font);
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; text-decoration: none; }
h1 { margin: 0; font-weight: 600; }

.mono-dim { font: 11.5px/1.4 var(--mono); color: var(--muted); }
.error { color: var(--danger); font-size: 12.5px; margin-top: 10px; min-height: 18px; }

.primary, .secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px 15px;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.primary {
  background: var(--ink);
  border: 1px solid var(--ink);
  color: #fff;
}
.primary:hover { background: var(--cobalt); border-color: var(--cobalt); }
.primary:disabled { opacity: 0.5; cursor: default; }
.secondary {
  background: #fff;
  border: 1px solid var(--line-strong);
  color: var(--ink);
}
.secondary:hover { border-color: var(--ink); }
.secondary.danger { color: var(--danger); }
.secondary.danger:hover { border-color: var(--danger); }

/* Login Split */
.login-shell {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  min-height: 100dvh;
}
.login-art {
  position: relative;
  overflow: hidden;
  padding: 38px 48px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background:
    linear-gradient(to right, rgba(255, 255, 255, 0.032) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(to bottom, rgba(255, 255, 255, 0.032) 1px, transparent 1px) 0 0 / 48px 48px,
    radial-gradient(circle at 72% 38%, rgba(23, 66, 198, 0.16) 0%, transparent 52%),
    var(--chrome);
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}
.login-art::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cobalt) 0%, var(--cobalt-bright) 42%, transparent 100%);
}
.login-logo { width: 136px; height: auto; display: block; }
.fy-axis-stage {
  position: relative;
  width: min(360px, 78%);
  aspect-ratio: 1;
  margin: auto;
  display: grid;
  place-items: center;
}
.fy-axis-svg { width: 100%; height: 100%; overflow: visible; }
.login-brand-foot {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-top: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.login-brand-foot .fy-kicker {
  font: 500 11px/1 var(--mono);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cobalt-bright);
}
.login-brand-foot .fy-edge {
  font: 600 22px/1.1 var(--font);
  letter-spacing: -0.03em;
  color: #f5f4f0;
}

.login-side {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background:
    linear-gradient(to right, transparent calc(50% - 0.5px), rgba(17, 20, 27, 0.04) 50%, transparent calc(50% + 0.5px)),
    linear-gradient(to bottom, transparent calc(50% - 0.5px), rgba(17, 20, 27, 0.04) 50%, transparent calc(50% + 0.5px)),
    var(--paper);
}
.login-form { width: 340px; max-width: 100%; }
.login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  margin-top: 18px;
}
.login-form input {
  height: 44px;
  padding: 0 12px;
  background: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  outline: none;
}
.login-form input:focus {
  border-color: var(--cobalt);
  box-shadow: 0 0 0 2px var(--cobalt-soft);
}
.login-form .primary {
  width: 100%;
  justify-content: space-between;
  margin-top: 24px;
  padding: 13px 16px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  background: rgba(17, 20, 27, 0.06);
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-bottom: 12px;
}
.mode-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  border-radius: 2px;
  transition: background 0.15s, color 0.15s;
}
.mode-tab:hover { color: var(--ink); }
.mode-tab.active {
  background: var(--ink);
  color: #fff;
}

/* App Shell */
.mail-app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
.topbar {
  position: relative;
  height: 56px;
  flex-shrink: 0;
  background: var(--chrome);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.topbar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, var(--cobalt) 0%, var(--cobalt-bright) 42%, transparent 100%);
}
.brand-lockup { padding: 0 2px; display: inline-flex; align-items: center; height: 36px; }
.brand-lockup img { height: 26px; width: auto; display: block; }
.divider { width: 1px; height: 20px; background: rgba(255, 255, 255, 0.14); }
.top-switch {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.05);
  padding: 3px;
  border-radius: 3px;
  border: 1px solid rgba(255, 255, 255, 0.09);
}
.top-tab {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 500;
  color: #9ea6b2;
  border-radius: 2px;
  transition: color 0.15s, background 0.15s;
}
.top-tab:hover { color: #fff; }
.top-tab.active {
  color: #fff;
  background: rgba(59, 130, 246, 0.22);
  box-shadow: inset 0 -2px 0 var(--cobalt-bright);
}
.workspace-title { color: #d6dce5; }
.top-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 14px;
}
.top-actions .mono-dim { color: #9ea6b2; }
.top-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  border-radius: 3px;
  padding: 5px 11px;
  font-size: 12px;
}
.top-btn:hover { border-color: #fff; }

.mail-layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 210px 330px 1fr;
}

/* Left Rail */
.rail {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}
.compose-btn { width: 100%; }
.folder-list { display: flex; flex-direction: column; gap: 3px; }
.folder-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 9px 11px;
  background: transparent;
  border: 0;
  border-radius: 3px;
  text-align: left;
  font-size: 13px;
  color: var(--ink);
}
.folder-btn:hover { background: var(--paper); }
.folder-btn.active {
  background: var(--cobalt-soft);
  color: var(--cobalt);
  font-weight: 600;
}
.folder-count {
  font: 11px var(--mono);
  color: var(--muted);
}
.folder-btn.active .folder-count { color: var(--cobalt); }
.folder-sep { height: 1px; background: var(--line); margin: 8px 4px; }

/* Message List */
.list-pane {
  background: var(--paper);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.list-head {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
}
.list-head input {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 3px;
  font-size: 12.5px;
  outline: none;
}
.list-head input:focus { border-color: var(--cobalt); background: #fff; }
.icon-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 3px;
  font-size: 15px;
  display: grid;
  place-items: center;
}
.icon-btn:hover { border-color: var(--ink); }
.list-body { flex: 1; overflow-y: auto; }
.list-empty { padding: 32px 16px; text-align: center; color: var(--muted); font-size: 12.5px; }

.msg-row {
  display: block;
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.msg-row:hover { background: rgba(255, 255, 255, 0.7); }
.msg-row.active { background: #fff; box-shadow: inset 2px 0 0 var(--cobalt); }
.msg-row.unread .row-from,
.msg-row.unread .row-subj { font-weight: 600; color: var(--ink); }
.row-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}
.row-from {
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-date { font: 10.5px var(--mono); color: var(--muted); flex-shrink: 0; }
.row-subj {
  font-size: 12.5px;
  color: #363e4a;
  margin-top: 3px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 4px;
  font: 10.5px var(--mono);
  color: var(--muted);
}
.status-pill {
  padding: 1px 6px;
  border-radius: 2px;
  font: 10px var(--mono);
  text-transform: uppercase;
  background: rgba(17, 20, 27, 0.07);
  color: var(--ink);
}
.status-pill.pending { background: var(--cobalt-soft); color: var(--cobalt); }

/* Reader & Compose */
.read-pane {
  background: var(--panel);
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.empty-state {
  margin: auto;
  color: var(--muted);
  font-size: 13px;
}
.detail-view {
  padding: 26px 32px;
  max-width: 860px;
  width: 100%;
}
.detail-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.detail-head h1 { font-size: 20px; letter-spacing: -0.02em; }
.meta-line { display: flex; gap: 14px; align-items: baseline; margin-top: 8px; font-size: 13px; }
.meta-sub { margin-top: 4px; }
.detail-actions { display: flex; gap: 8px; flex-shrink: 0; align-items: center; }
.detail-actions select {
  height: 36px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: #fff;
  font-size: 12.5px;
}

.attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.att-chip {
  font: 11.5px var(--mono);
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--paper);
}

.msg-body {
  margin: 22px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: 14px/1.68 var(--font);
  color: var(--ink);
}

.enq-fields {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 16px;
  margin: 20px 0 0;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.enq-fields dt { font: 11.5px var(--mono); color: var(--muted); text-transform: uppercase; }
.enq-fields dd { margin: 0; font-size: 13.5px; }
.enq-fields a { color: var(--cobalt); }

.compose-form { display: flex; flex-direction: column; gap: 14px; }
.compose-form label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 600; }
.compose-form input,
.compose-form textarea {
  padding: 9px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: #fff;
  outline: none;
}
.compose-form textarea { resize: vertical; line-height: 1.6; }
.compose-form input:focus,
.compose-form textarea:focus { border-color: var(--cobalt); box-shadow: 0 0 0 2px var(--cobalt-soft); }

.toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 3px;
  font-size: 12.5px;
  z-index: 50;
}

@media (max-width: 960px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-art { display: none; }
  .mail-layout { grid-template-columns: 180px 1fr; }
  .read-pane { position: fixed; inset: 54px 0 0 180px; z-index: 10; }
  .read-pane.idle { display: none; }
}
@media (max-width: 640px) {
  .mail-layout { grid-template-columns: 1fr; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px; }
  .folder-list { flex-direction: row; overflow-x: auto; }
  .folder-btn { width: auto; white-space: nowrap; }
  .folder-sep { display: none; }
  .read-pane { inset: 54px 0 0 0; }
}
