/* s7ortlynk mail — all styles.
   Colours are CSS custom properties only: light values on bare :root,
   dark values repeated for the system preference and for the explicit
   [data-theme="dark"] override set by the theme toggle. */

:root {
  --bg:#f6f7f9; --surface:#fff; --surface-2:#edf0f4; --surface-3:#e3e8ef;
  --border:#dde2e9; --fg:#171a1f; --muted:#5a6472;
  --accent:#1d58d8; --accent-sf:#e7eefc; --unread:#1d58d8;
  --ok:#136f3b; --warn:#92610a; --del:#b4282a;
  --ok-sf:#e6f4ec; --on-del:#fff;
  --on-accent:#fff; --scrim:rgba(0,0,0,.45);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:#0d1016; --surface:#151a22; --surface-2:#1b212b; --surface-3:#222a36;
    --border:#28303c; --fg:#e3e8ef; --muted:#949fb0;
    --accent:#6f9dff; --accent-sf:#182439; --unread:#6f9dff;
    --ok:#4cc26a; --warn:#d9a441; --del:#f0665f;
    --ok-sf:#13281b; --on-del:#0d1016;
    --on-accent:#0d1016; --scrim:rgba(0,0,0,.6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg:#0d1016; --surface:#151a22; --surface-2:#1b212b; --surface-3:#222a36;
  --border:#28303c; --fg:#e3e8ef; --muted:#949fb0;
  --accent:#6f9dff; --accent-sf:#182439; --unread:#6f9dff;
  --ok:#4cc26a; --warn:#d9a441; --del:#f0665f;
  --ok-sf:#13281b; --on-del:#0d1016;
  --on-accent:#0d1016; --scrim:rgba(0,0,0,.6);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: "IBM Plex Sans", ui-sans-serif, system-ui, -apple-system, sans-serif;
  font-size: 14px; line-height: 1.55; -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.mono { font-family: "IBM Plex Mono", ui-monospace, Menlo, monospace; }
button { font: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

/* Shown only on the narrow layouts that hide the corresponding column. */
.only-narrow, .only-compact { display: none; }

/* ---------- top bar ---------- */
header {
  flex: none; display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.logo { font-weight: 600; letter-spacing: -.01em; white-space: nowrap; }
.logo span { color: var(--accent); }
.spacer { flex: 1; }
.btn {
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  border-radius: 7px; padding: 6px 12px; font-size: 13px;
}
a.btn { display: inline-block; text-decoration: none; }
.btn:hover { border-color: var(--accent); color: var(--accent); }
.btn.pri { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.pri:hover { filter: brightness(1.08); color: var(--on-accent); }
.btn.danger:hover { border-color: var(--del); color: var(--del); }
.btn:disabled { opacity: .5; cursor: default; }
.btn.sm { padding: 3px 9px; font-size: 12px; }
.btn.block { width: 100%; }

/* ---------- login ---------- */
#login { flex: 1; display: grid; place-items: center; padding: 24px 16px; }
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 12px; padding: 28px; width: 100%; max-width: 420px;
}
.card h1 { margin: 0 0 6px; font-size: 20px; letter-spacing: -.01em; }
.card p { margin: 0 0 18px; color: var(--muted); font-size: 13.5px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 6px; font-weight: 500; }
input[type=text], input[type=password], input[type=email], textarea, select {
  width: 100%; padding: 9px 11px; border-radius: 7px;
  border: 1px solid var(--border); background: var(--bg); color: var(--fg);
  font: inherit; font-size: 13.5px;
}
input.mono, textarea { font-family: "IBM Plex Mono", ui-monospace, monospace; }
textarea { resize: vertical; min-height: 120px; line-height: 1.55; }
.err { color: var(--del); font-size: 13px; margin-top: 10px; }

/* ---------- app shell ---------- */
#app { flex: 1; display: grid; grid-template-columns: 210px 330px minmax(0,1fr); min-height: 0; }

aside {
  border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
}
.side-head {
  padding: 12px 14px 8px; font-size: 10.5px; letter-spacing: .12em;
  text-transform: uppercase; color: var(--muted); font-weight: 600;
  display: flex; align-items: center; gap: 8px;
}
.boxes { overflow-y: auto; flex: 1; padding-bottom: 10px; }

/* A mailbox row: the select button plus its mute / delete controls. */
.box-row { display: flex; align-items: center; min-width: 0; }
.box-row:hover { background: var(--surface-2); }
.box-row.on { background: var(--accent-sf); }
.box {
  display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0;
  padding: 7px 4px 7px 14px; border: none; background: none; color: var(--fg);
  text-align: left; font-size: 13.5px;
}
.box-row.on .box { color: var(--accent); font-weight: 500; }
.box .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct {
  font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums;
  background: var(--surface-2); border-radius: 999px; padding: 1px 7px;
}
.box-row.on .ct { background: var(--surface); }
.box-acts { display: flex; gap: 1px; padding-right: 8px; opacity: 0; flex: none; }
.box-row:hover .box-acts, .box-row:focus-within .box-acts { opacity: 1; }
@media (hover: none) { .box-acts { opacity: 1; } }
.ibtn {
  border: none; background: none; color: var(--muted);
  padding: 3px 5px; border-radius: 5px; font-size: 12px; line-height: 1;
}
.ibtn:hover { color: var(--accent); background: var(--surface-3); }
.ibtn.danger:hover { color: var(--del); }
.box-confirm {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 7px 10px 9px 14px; width: 100%; font-size: 12px; color: var(--muted);
}
/* postmaster@ / abuse@ cannot be deleted; they carry this tag instead of the control. */
.tag {
  flex: none; font-size: 9.5px; letter-spacing: .08em; text-transform: uppercase;
  color: var(--muted); border: 1px solid var(--border); border-radius: 4px;
  padding: 0 5px; font-weight: 500; line-height: 1.6;
}
.box-confirm .q { width: 100%; color: var(--fg); overflow-wrap: anywhere; }

/* ---------- list ---------- */
.list-col {
  border-right: 1px solid var(--border); background: var(--surface);
  display: flex; flex-direction: column; min-height: 0; min-width: 0;
}
.list-head {
  flex: none; padding: 9px 12px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px; background: var(--surface-2);
}
.list-head .ttl { font-weight: 600; font-size: 13px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msgs { overflow-y: auto; flex: 1; }
.msg {
  display: block; width: 100%; text-align: left; border: none; background: none;
  color: var(--fg); padding: 10px 13px; border-bottom: 1px solid var(--border);
  border-left: 3px solid transparent;
}
.msg:hover { background: var(--surface-2); }
.msg.on { background: var(--accent-sf); border-left-color: var(--accent); }
.msg .r1 { display: flex; align-items: baseline; gap: 8px; }
.msg .frm { font-size: 13px; min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.unread .frm, .msg.unread .sub { font-weight: 600; }
.msg .tm { font-size: 11px; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.msg .sub { font-size: 13px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .pre { font-size: 12px; color: var(--muted); margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg .dotu { width: 6px; height: 6px; border-radius: 50%; background: var(--unread); display: inline-block; flex: none; }
.msg .clip { font-size: 11px; color: var(--muted); }
.msg .warnu { color: var(--del); font-size: 12px; line-height: 1; flex: none; }

/* ---------- reader ---------- */
.read-col { display: flex; flex-direction: column; min-height: 0; min-width: 0; background: var(--bg); }
.read-pane { display: flex; flex-direction: column; min-height: 0; flex: 1; }
.read-head { flex: none; padding: 14px 18px; border-bottom: 1px solid var(--border); background: var(--surface); }
.read-head .back { margin-bottom: 10px; }
.read-head h2 { margin: 0 0 8px; font-size: 17px; line-height: 1.3; letter-spacing: -.01em; text-wrap: balance; overflow-wrap: anywhere; }
.meta { font-size: 12.5px; color: var(--muted); display: grid; gap: 1px; }
.meta b { color: var(--fg); font-weight: 500; }
.meta span { overflow-wrap: anywhere; }
/* Sender verification: failure bar, "verified" chip and the details disclosure */
.auth-fail {
  flex: none; display: flex; align-items: flex-start; gap: 9px;
  padding: 10px 18px; background: var(--del); color: var(--on-del);
  font-size: 13.5px; font-weight: 600; line-height: 1.4; overflow-wrap: anywhere;
}
.auth-fail-ico { flex: none; }
.chip {
  display: inline-block; vertical-align: baseline; white-space: nowrap;
  font-size: 11px; font-weight: 500; line-height: 1.5;
  border-radius: 999px; padding: 0 8px; margin-left: 4px; cursor: default;
}
.chip.ok { color: var(--ok); background: var(--ok-sf); }
/* "Verified · <domain>": a long domain wraps instead of overflowing on a phone */
#authChip { white-space: normal; overflow-wrap: anywhere; max-width: 100%; }
.sec { margin-top: 8px; font-size: 12.5px; color: var(--muted); }
.sec summary { cursor: pointer; width: fit-content; max-width: 100%; border-radius: 4px; }
.sec summary:hover { color: var(--accent); }
.sec-rows { display: flex; flex-wrap: wrap; gap: 2px 18px; margin-top: 5px; }
.sec-row { overflow-wrap: anywhere; min-width: 0; }
.sec-row b { color: var(--fg); font-weight: 500; }
.sec-row .good { color: var(--ok); }
.sec-row .bad { color: var(--del); }
.read-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 11px; }

/* HTML / Text / Source view switch */
.seg {
  display: inline-flex; border: 1px solid var(--border); border-radius: 7px;
  overflow: hidden; background: var(--bg); flex: none;
}
.seg-btn {
  border: none; background: none; color: var(--muted);
  padding: 3px 10px; font-size: 12px; line-height: inherit;
}
.seg-btn + .seg-btn { border-left: 1px solid var(--border); }
.seg-btn:hover:not(:disabled) { color: var(--accent); background: var(--surface-2); }
.seg-btn[aria-pressed="true"] { background: var(--accent-sf); color: var(--accent); font-weight: 500; }
.seg-btn:disabled { opacity: .45; cursor: default; }
.seg-btn:focus-visible { outline-offset: -2px; }

/* Verification code callout */
.codes {
  flex: none; margin: 12px 18px 0; padding: 11px 14px 13px;
  border: 1px solid var(--accent); border-radius: 9px; background: var(--accent-sf);
}
.code-lbl {
  font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--accent); font-weight: 600; margin-bottom: 4px;
}
.code-main { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.code-val {
  font-size: 26px; font-weight: 500; letter-spacing: .1em; line-height: 1.2;
  color: var(--fg); user-select: all; overflow-wrap: anywhere;
}
.code-more { margin-top: 7px; font-size: 12px; color: var(--muted); overflow-wrap: anywhere; }
.code-more code { font-family: "IBM Plex Mono", ui-monospace, monospace; }

/* Links found in the message */
.links { flex: none; margin: 12px 18px 0; }
.links .btn { display: block; }
.lbl {
  font-size: 10.5px; letter-spacing: .11em; text-transform: uppercase;
  color: var(--muted); font-weight: 600; margin-bottom: 7px;
}
.link-list {
  max-height: 104px; overflow-y: auto;
  border: 1px solid var(--border); border-radius: 7px; background: var(--surface);
}
.link-item {
  display: block; padding: 6px 11px; font-size: 12.5px; color: var(--accent);
  text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.link-item:last-child { border-bottom: none; }
.link-item:hover { background: var(--surface-2); text-decoration: underline; }

.banner {
  flex: none; margin: 12px 18px 0; padding: 9px 12px; border-radius: 7px; font-size: 12.5px;
  background: var(--surface-2); border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.frame-wrap { flex: 1; min-height: 0; padding: 0 18px 18px; display: flex; }
iframe#body {
  flex: 1; width: 100%; border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface); margin-top: 12px; min-height: 240px;
}
/* Raw RFC 822 source, shown in place of the iframe */
.src-pane {
  flex: 1; min-width: 0; min-height: 240px; margin-top: 12px;
  display: flex; flex-direction: column;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface);
  overflow: hidden;
}
.src-bar {
  flex: none; display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 7px 10px 7px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2);
}
.src-bar .lbl { margin: 0; }
pre.src {
  flex: 1; min-height: 0; margin: 0; padding: 12px 14px; overflow: auto;
  font-size: 12px; line-height: 1.55; color: var(--fg);
  white-space: pre-wrap; overflow-wrap: anywhere; tab-size: 4;
}
.src-head { color: var(--muted); }
.atts { flex: none; padding: 0 18px 14px; }
.att {
  display: inline-flex; align-items: center; gap: 8px; margin: 0 7px 7px 0;
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 11px;
  background: var(--surface); font-size: 12.5px; max-width: 100%;
}
.att .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.att .sz { color: var(--muted); font-size: 11.5px; white-space: nowrap; }
.att button { border: none; background: none; color: var(--accent); padding: 0; font-size: 12.5px; min-width: 0; }

.empty { flex: 1; display: grid; place-items: center; color: var(--muted); padding: 30px; text-align: center; }
.empty div { max-width: 34ch; }
.empty.pad { padding: 36px 20px; }

/* ---------- modals ---------- */
.modal {
  position: fixed; inset: 0; background: var(--scrim);
  display: grid; place-items: center; padding: 20px; z-index: 50;
}
.modal .card { max-width: 560px; max-height: 90vh; overflow-y: auto; }
.fld { margin-bottom: 13px; }
.fld-row { display: flex; align-items: center; gap: 6px; }
.fld-row input { flex: 1; min-width: 0; }
.suffix { color: var(--muted); font-size: 13px; white-space: nowrap; }
.row-btns { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; flex-wrap: wrap; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--fg); color: var(--bg); padding: 9px 16px; border-radius: 8px;
  font-size: 13px; z-index: 60; max-width: 90vw;
}

/* ---------- responsive ---------- */
@media (max-width: 1000px) {
  #app { grid-template-columns: 180px minmax(0,1fr); }
  .read-col { display: none; }
  #app.reading { grid-template-columns: minmax(0,1fr); }
  #app.reading aside, #app.reading .list-col { display: none; }
  #app.reading .read-col { display: flex; }
  .only-compact { display: inline-block; }
}
@media (max-width: 640px) {
  #app { grid-template-columns: minmax(0,1fr); }
  #app aside { display: none; }
  #app.show-boxes aside { display: flex; }
  #app.show-boxes .list-col { display: none; }
  .only-narrow { display: inline-block; }
}
@media (max-width: 480px) {
  header { gap: 7px; padding: 9px 12px; }
  .card { padding: 20px; }
  .read-head { padding: 12px 14px; }
  .auth-fail { padding: 9px 14px; font-size: 13px; }
  .codes, .links, .banner { margin-left: 14px; margin-right: 14px; }
  .frame-wrap { padding: 0 14px 14px; }
  .atts { padding: 0 14px 12px; }
  .code-val { font-size: 22px; }
}

/* copyright line under the sign-in card */
.copy { margin: 18px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.copy a { color: inherit; }
