/* Herald subscriber PWA — a mail client, so it should read like one.
   Quiet chrome, dense list, one loud exception: an unverified sender. */

:root {
  --bg: #f6f6f4;
  --surface: #ffffff;
  --surface-2: #eceeea;
  --surface-3: #e3e6e1;
  --text: #14171c;
  --text-dim: #5f6672;
  --text-faint: #8b93a1;
  --border: #e2e4e0;
  --accent: #1c5f4a;
  --accent-soft: #e6f2ea;
  --accent-text: #ffffff;
  --ok: #1c6b45;
  --ok-bg: #e6f2ea;
  --warn: #8a5a00;
  --warn-bg: #fdf3e0;
  --danger: #a32020;
  --danger-bg: #fbeaea;
  --star: #d99413;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 6px 20px rgba(0,0,0,.05);
  --tab-h: 58px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #101317;
    --surface: #181c21;
    --surface-2: #21262d;
    --surface-3: #2b3138;
    --text: #e9ebee;
    --text-dim: #99a1ad;
    --text-faint: #737c89;
    --border: #2a2f36;
    --accent: #4db392;
    --accent-soft: #142b23;
    --accent-text: #06120e;
    --ok: #6cd39f;
    --ok-bg: #13291f;
    --warn: #e0b062;
    --warn-bg: #2c2312;
    --danger: #f28c8c;
    --danger-bg: #2d1717;
    --star: #e9b949;
    --shadow: 0 1px 2px rgba(0,0,0,.5), 0 6px 20px rgba(0,0,0,.35);
  }
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { overscroll-behavior-y: none; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-font-smoothing: antialiased;
}
.app { max-width: 520px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; }

/* ---- top bar ---------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 20; background: var(--bg);
  padding: max(10px, env(safe-area-inset-top)) 12px 8px;
}
.topbar__row { display: flex; align-items: center; gap: 8px; min-height: 40px; }
.topbar__title { flex: 1; margin: 0; font-size: 18px; font-weight: 680; letter-spacing: -.02em; }
.iconbtn {
  border: 0; background: none; color: var(--text); cursor: pointer;
  /* 44px is the smallest reliable touch target on iOS; Android asks for 48dp.
     The visual circle stays smaller than the hit area via the background clip. */
  width: 44px; height: 44px; border-radius: 50%; display: grid; place-items: center;
  font-size: 19px; line-height: 1; flex: none; padding: 0;
}
.iconbtn:hover, .iconbtn:focus-visible { background: var(--surface-2); }
.iconbtn--star.is-on { color: var(--star); }

/* Gmail-style search pill */
.search {
  display: flex; align-items: center; gap: 6px; background: var(--surface-2);
  border-radius: 999px; padding: 0 4px 0 14px; height: 48px;
}
.search input {
  flex: 1; border: 0; background: none; font: inherit; color: var(--text);
  min-width: 0; padding: 0; height: 100%;
}
.search input:focus { outline: none; }
.search input::placeholder { color: var(--text-faint); }
.search__icon { color: var(--text-dim); font-size: 16px; }

.chips { display: flex; gap: 7px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  border: 1px solid var(--border); background: var(--surface); color: var(--text-dim);
  border-radius: 999px; padding: 9px 15px; font-size: 13px; font-weight: 600;
  cursor: pointer; white-space: nowrap; flex: none; min-height: 38px;
}
.chip[aria-pressed="true"] { background: var(--accent-soft); color: var(--ok); border-color: transparent; }

/* ---- screen ----------------------------------------------------------- */
.screen { flex: 1; padding: 4px 12px calc(var(--tab-h) + 28px); }
.screen--flush { padding-left: 0; padding-right: 0; }

/* ---- message list ----------------------------------------------------- */
.list { display: flex; flex-direction: column; }
.row {
  display: flex; gap: 12px; align-items: flex-start; width: 100%;
  padding: 12px; border: 0; background: none; color: inherit; font: inherit;
  text-align: left; cursor: pointer; border-radius: 12px;
}
.row:hover { background: var(--surface-2); }
.row + .row { box-shadow: inset 0 1px 0 var(--border); }
.row.is-unread { background: var(--surface); }
.row.is-unread:hover { background: var(--surface-2); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%; flex: none;
  display: grid; place-items: center; color: #fff;
  font-weight: 680; font-size: 16px; letter-spacing: -.01em;
}
.row__main { display: block; flex: 1; min-width: 0; overflow: hidden; }
.row__top { display: flex; align-items: baseline; gap: 8px; }
/* `text-overflow` and `overflow` have no effect on an inline box, and these are
   all spans. Without `display: block` the nowrap text simply grew the row, the
   layout viewport widened past the device width, and the browser scaled the
   whole page down -- an overflow that looks like a font-size bug. */
.row__sender { display: block; font-size: 14.5px; color: var(--text-dim); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__time { font-size: 12px; color: var(--text-faint); flex: none; }
.row__subject { display: block; font-size: 14.5px; margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row__snippet { display: block; font-size: 13.5px; color: var(--text-faint); margin-top: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.is-unread .row__sender, .is-unread .row__subject { font-weight: 700; color: var(--text); }
.row__tail { display: flex; flex-direction: column; align-items: center; gap: 6px; flex: none; }
.row__meta { display: flex; gap: 6px; align-items: center; margin-top: 4px; }

.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex: none; }
.clip { font-size: 12px; color: var(--text-faint); }

/* ---- badges & notes --------------------------------------------------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px;
  border-radius: 999px; font-size: 11.5px; font-weight: 650; white-space: nowrap;
}
.badge--ok { background: var(--ok-bg); color: var(--ok); }
.badge--warn { background: var(--warn-bg); color: var(--warn); }
.badge--danger { background: var(--danger-bg); color: var(--danger); }
.badge--mute { background: var(--surface-2); color: var(--text-dim); }

.note { border-radius: 11px; padding: 12px 14px; font-size: 13.5px; border: 1px solid transparent; margin-bottom: 12px; }
.note--ok { background: var(--ok-bg); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 28%, transparent); }
.note--warn { background: var(--warn-bg); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 28%, transparent); }
.note--danger { background: var(--danger-bg); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 28%, transparent); }
.note strong { display: block; margin-bottom: 3px; }

/* ---- cards ------------------------------------------------------------ */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); margin-bottom: 12px;
}
.card--tap { cursor: pointer; text-align: left; width: 100%; font: inherit; color: inherit; display: block; }
.card--tap:hover { border-color: var(--accent); }
h2 { margin: 0 0 3px; font-size: 16px; font-weight: 680; letter-spacing: -.01em; }
h3 { margin: 20px 0 8px; font-size: 11.5px; font-weight: 680; letter-spacing: .07em;
  text-transform: uppercase; color: var(--text-dim); }
p { margin: 0 0 9px; }
.dim { color: var(--text-dim); } .small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11.5px; word-break: break-all; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; width: 100%;
  padding: 13px 16px; border-radius: 11px; border: 1px solid transparent;
  background: var(--accent); color: var(--accent-text); font: inherit; font-weight: 650; cursor: pointer;
}
.btn:active { transform: scale(.99); }
.btn:disabled { opacity: .5; cursor: default; }
.btn--ghost { background: none; color: var(--text); border-color: var(--border); }
.btn--danger { background: none; color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.row2 { display: flex; gap: 10px; } .row2 > .btn { flex: 1; }

/* ---- message detail --------------------------------------------------- */
.detail__subject { font-size: 20px; font-weight: 700; letter-spacing: -.02em; margin: 6px 0 12px; line-height: 1.3; }
.detail__from { display: flex; gap: 11px; align-items: center; margin-bottom: 16px; }
.detail__from-main { min-width: 0; flex: 1; }
.detail__name { font-weight: 650; font-size: 14.5px; }
.body { font-size: 15.5px; line-height: 1.65; overflow-wrap: break-word; }
.body h2 { font-size: 19px; margin: 22px 0 8px; }
.body h3 { font-size: 16.5px; margin: 20px 0 6px; text-transform: none; letter-spacing: 0; color: var(--text); }
.body h4 { font-size: 15px; margin: 18px 0 6px; }
.body p { margin: 0 0 13px; }
.body ul, .body ol { margin: 0 0 13px; padding-left: 22px; }
.body li { margin-bottom: 5px; }
.body a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.body blockquote { margin: 0 0 13px; padding: 2px 0 2px 13px;
  border-left: 3px solid var(--surface-3); color: var(--text-dim); }
.body code { background: var(--surface-2); padding: 1px 5px; border-radius: 5px;
  font-family: ui-monospace, Menlo, monospace; font-size: .88em; }
.body pre { background: var(--surface-2); padding: 12px 14px; border-radius: 10px;
  overflow-x: auto; margin: 0 0 13px; }
.body pre code { background: none; padding: 0; }
.body img { max-width: 100%; height: auto; border-radius: 10px; display: block; margin: 0 0 13px; }
.body hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.md-blocked { display: inline-block; font-size: 12.5px; color: var(--warn);
  background: var(--warn-bg); border-radius: 6px; padding: 2px 7px; }

.attach {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 11px;
  padding: 11px 13px; margin-bottom: 8px; font: inherit; color: inherit; cursor: pointer;
}
.attach:hover { border-color: var(--accent); }
.attach__icon { font-size: 19px; flex: none; }
.attach__main { flex: 1; min-width: 0; }
.attach__name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach__meta { font-size: 12px; color: var(--text-faint); }

details.verify { border-top: 1px solid var(--border); margin-top: 22px; padding-top: 14px; }
details.verify summary { cursor: pointer; font-size: 13px; color: var(--text-dim); font-weight: 600; }
details.verify dl { display: grid; grid-template-columns: auto 1fr; gap: 5px 14px;
  font-size: 12.5px; margin: 12px 0 0; }
details.verify dt { color: var(--text-faint); } details.verify dd { margin: 0; }

/* ---- sender / consent ------------------------------------------------- */
.sender__name { font-size: 20px; font-weight: 700; letter-spacing: -.02em; }
.sender__domain { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 5px; }
.terms { display: grid; gap: 1px; background: var(--border); border-radius: 11px; overflow: hidden; margin-top: 14px; }
.terms__row { display: flex; justify-content: space-between; gap: 12px; background: var(--surface); padding: 11px 13px; font-size: 14px; }
.terms__row dt { color: var(--text-dim); margin: 0; }
.terms__row dd { margin: 0; font-weight: 620; text-align: right; }
.terms__cap { background: var(--accent-soft) !important; }
.terms__cap dd, .terms__cap dt { color: var(--ok); }

/* ---- tab bar ---------------------------------------------------------- */
/* A `display` rule beats the user-agent's `[hidden] { display: none }`, so the
   tab bar stayed visible on the screens that set `.hidden = true`. */
[hidden] { display: none !important; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  display: flex; background: var(--surface); border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  max-width: 520px; margin: 0 auto;
}
.tabbar button {
  flex: 1; border: 0; background: none; cursor: pointer; color: var(--text-faint);
  height: var(--tab-h); display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; font: inherit; font-size: 11px; font-weight: 600;
}
.tabbar button span.ico { font-size: 20px; line-height: 1; }
.tabbar button[aria-current="page"] { color: var(--accent); }
.tabbar .pill {
  position: absolute; transform: translate(14px, -12px);
  background: var(--accent); color: var(--accent-text); border-radius: 999px;
  font-size: 10px; font-weight: 700; padding: 1px 5px; min-width: 16px;
}

/* ---- misc ------------------------------------------------------------- */
.empty { text-align: center; color: var(--text-faint); padding: 56px 20px; }
.empty__icon { font-size: 40px; opacity: .45; display: block; margin-bottom: 10px; }
input[type=text], textarea {
  width: 100%; padding: 12px 13px; border-radius: 11px; font: inherit;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
}
label { display: block; font-size: 12.5px; color: var(--text-dim); margin-bottom: 6px; font-weight: 550; }
video { width: 100%; border-radius: var(--radius); background: #000; aspect-ratio: 1; object-fit: cover; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tab-h) + env(safe-area-inset-bottom) + 14px);
  transform: translateX(-50%) translateY(14px); z-index: 60;
  width: calc(100% - 28px); max-width: 460px;
  padding: 13px 15px; border-radius: 11px; font-size: 14px; font-weight: 560;
  background: var(--text); color: var(--bg); box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s;
}
.toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast--error { background: var(--danger); color: #fff; }
.toast--ok { background: var(--ok); color: #fff; }
.spinner { display: inline-block; width: 15px; height: 15px; border: 2px solid currentColor;
  border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.center { display: grid; place-items: center; min-height: 50dvh; text-align: center; }
