/* ACK web app. One stylesheet, no build step. Served from /assets/app.css
   so the CSP can forbid inline styles. */
:root {
  --ink: #121212;
  --ink-2: #4a4a4a;
  --muted: #6b6b6b;
  --line: #e4e2dd;
  --bg: #fbfaf7;
  --panel: #ffffff;
  --accent: #16a34a;
  --accent-ink: #ffffff;
  --warn-bg: #fff7e6;
  --warn-line: #f2c46d;
  --ok-bg: #effaf2;
  --ok-line: #9ad7ab;
  --err: #b42318;
  --err-bg: #fef1f0;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ink: #f2f1ee;
    --ink-2: #cfcdc8;
    --muted: #9b9994;
    --line: #2c2b29;
    --bg: #121211;
    --panel: #1a1a19;
    --accent: #22c55e;
    --accent-ink: #0b1a10;
    --warn-bg: #2a2212;
    --warn-line: #7a5a17;
    --ok-bg: #11241a;
    --ok-line: #2f6b44;
    --err: #ff8a80;
    --err-bg: #2b1513;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.5 var(--sans);
}
a { color: inherit; text-underline-offset: 3px; }
a:hover { color: var(--accent); }
h1 { font-size: 1.75rem; line-height: 1.2; letter-spacing: -0.02em; margin: 0 0 0.5rem; }
h2 { font-size: 1.15rem; margin: 2.25rem 0 0.75rem; letter-spacing: -0.01em; }
h3 { font-size: 1rem; margin: 1.5rem 0 0.5rem; }
p { margin: 0 0 0.75rem; }
small { display: block; color: var(--muted); font-size: 0.85rem; margin-top: 0.25rem; }

.top { border-bottom: 1px solid var(--line); background: var(--panel); }
.bar {
  max-width: 960px; margin: 0 auto; padding: 0.75rem 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand {
  font: 800 1.25rem/1 var(--mono); letter-spacing: 0.04em; text-decoration: none;
  display: inline-flex; align-items: flex-start; gap: 3px;
}
.brand .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-top: 1px; }
.who { display: flex; align-items: center; gap: 0.75rem; min-width: 0; }
.who .org {
  font-weight: 600; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 40vw; padding: 0.25rem 0.6rem; border: 1px solid var(--line); border-radius: 999px; font-size: 0.9rem;
}
nav {
  max-width: 960px; margin: 0 auto; padding: 0 16px;
  display: flex; gap: 1.25rem; overflow-x: auto; scrollbar-width: none;
}
nav::-webkit-scrollbar { display: none; }
nav a {
  padding: 0.6rem 0 0.7rem; text-decoration: none; color: var(--muted); white-space: nowrap;
  border-bottom: 2px solid transparent; font-size: 0.95rem;
}
nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--ink); }

main { max-width: 960px; margin: 0 auto; padding: 2rem 16px 4rem; }
.auth { max-width: 400px; margin: 1rem auto; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.9em; word-break: break-all; }
.eyebrow { text-transform: uppercase; letter-spacing: 0.08em; font-size: 0.75rem; color: var(--muted); margin: 0 0 0.25rem; }
.big { font-size: 1.4rem; font-weight: 700; margin: 0 0 0.25rem; text-transform: capitalize; }
.price { margin: 1.5rem 0; color: var(--ink-2); }

.notice, .error, .callout {
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.75rem 1rem; margin: 0 0 1.25rem; background: var(--panel);
}
.notice { border-color: var(--ok-line); background: var(--ok-bg); }
.error { border-color: var(--err); background: var(--err-bg); color: var(--err); }
.callout.warn { border-color: var(--warn-line); background: var(--warn-bg); }
.callout.ok { border-color: var(--ok-line); background: var(--ok-bg); }
.callout p:last-child, .callout form:last-child { margin-bottom: 0; }

.stack { display: grid; gap: 0.9rem; margin: 0 0 1rem; }
.narrow { max-width: 440px; }
label { display: grid; gap: 0.3rem; font-weight: 600; font-size: 0.92rem; }
label.check { display: flex; align-items: center; gap: 0.5rem; font-weight: 500; }
input[type=text], input[type=email], input[type=password], input[type=url], select {
  width: 100%; font: 400 1rem var(--sans); color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.65rem 0.75rem; min-height: 44px;
}
input:focus-visible, select:focus-visible, button:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  font: 600 0.95rem var(--sans); color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.6rem 1rem; min-height: 44px;
  cursor: pointer; text-decoration: none; transition: border-color .15s, background-color .15s;
}
button:hover, .button:hover { border-color: var(--ink-2); color: var(--ink); }
button.primary, .button.primary { background: var(--ink); color: var(--bg); border-color: var(--ink); }
button.primary:hover, .button.primary:hover { background: var(--ink-2); }
button.danger { color: var(--err); }
button.danger:hover { border-color: var(--err); }
button.link {
  background: none; border: 0; padding: 0; min-height: 0; color: var(--muted); font-weight: 500; text-decoration: underline;
  text-underline-offset: 3px;
}
form.inline { display: inline; margin: 0; }
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; align-items: center; }

.or { display: flex; align-items: center; gap: 0.75rem; color: var(--muted); margin: 1.25rem 0; font-size: 0.85rem; }
.or::before, .or::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.alt { display: grid; gap: 0.6rem; margin: 1.25rem 0; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 0.75rem; margin: 1.5rem 0; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.card a { font-size: 0.9rem; color: var(--muted); }

.rows { list-style: none; padding: 0; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem; border-top: 1px solid var(--line);
}
.row:first-child { border-top: 0; }
.row > div { display: grid; gap: 0.1rem; min-width: 0; }
.row .muted { font-size: 0.88rem; }
.badge {
  font-size: 0.75rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px;
  border: 1px solid var(--line); color: var(--muted); white-space: nowrap;
}
.badge.ok { border-color: var(--ok-line); color: var(--accent); }

pre.code {
  font: 0.88rem/1.5 var(--mono); background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 0.75rem 1rem; overflow-x: auto; white-space: pre;
}
pre.code.key { white-space: pre-wrap; word-break: break-all; user-select: all; }

@media (max-width: 560px) {
  h1 { font-size: 1.45rem; }
  main { padding-top: 1.25rem; }
  .row { flex-direction: column; align-items: stretch; }
  .row form.inline button { width: 100%; }
  .actions { flex-direction: column; align-items: stretch; }
  .actions form.inline button { width: 100%; }
}

/* ---- Inbox browser, domains, webhooks, staff ---- */
.strong { font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.crumbs { font-size: 0.9rem; color: var(--muted); margin-bottom: 0.5rem; }
.crumbs a { color: var(--muted); }
.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.head h1 { margin-bottom: 0.25rem; }
h1.addr, h1.subject { overflow-wrap: anywhere; }
.badge.warn { border-color: var(--warn-line); color: var(--ink-2); background: var(--warn-bg); }
.chip {
  display: inline-flex; align-items: center; gap: 0.25rem; font-size: 0.75rem; font-weight: 600;
  padding: 0.1rem 0.5rem; border-radius: 999px; background: var(--ok-bg); border: 1px solid var(--ok-line); color: var(--ink-2);
}
.chip .x { min-height: 0; padding: 0 0.15rem; border: 0; background: none; font-size: 1rem; line-height: 1; color: var(--muted); }
.empty { padding: 1.5rem 0; }
textarea {
  width: 100%; font: 400 1rem/1.5 var(--sans); color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.65rem 0.75rem; resize: vertical;
}
textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input[type=search] {
  flex: 1; min-width: 0; font: 400 1rem var(--sans); color: var(--ink); background: var(--panel);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 0.65rem 0.75rem; min-height: 44px;
}
.search { display: flex; gap: 0.5rem; margin: 0 0 1rem; align-items: flex-end; flex-wrap: wrap; }
.search.filters label { flex: 1; min-width: 160px; }
.tabs {
  max-width: none; padding: 0; margin: 0 0 1rem; border-bottom: 1px solid var(--line);
  display: flex; gap: 1.1rem; overflow-x: auto; scrollbar-width: none;
}
.tabs a { padding: 0.4rem 0 0.55rem; font-size: 0.9rem; }

.threads .row { padding: 0; }
.thread { display: grid; gap: 0.1rem; padding: 0.7rem 1rem; text-decoration: none; width: 100%; min-width: 0; }
.thread:hover { color: inherit; background: var(--bg); }
.t-top { display: flex; justify-content: space-between; gap: 1rem; min-width: 0; }
.t-from { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.t-when { font-size: 0.82rem; white-space: nowrap; }
.t-subject { overflow-wrap: anywhere; }
.t-preview { font-size: 0.88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unread .t-from, .unread .t-subject { font-weight: 700; }
.unread-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); margin-right: 0.4rem; vertical-align: middle; }

.labels { display: flex; flex-wrap: wrap; gap: 0.4rem; align-items: center; margin: 0.25rem 0 0.75rem; }
.labelbar { margin-bottom: 1.5rem; }
.addlabel { display: inline-flex; gap: 0.4rem; }
.addlabel input { width: 12rem; }

.msg { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); margin: 0 0 1rem; overflow: hidden; }
.msg-head { display: flex; justify-content: space-between; gap: 1rem; padding: 0.75rem 1rem; border-bottom: 1px solid var(--line); }
.msg-head p { margin: 0; overflow-wrap: anywhere; }
.mailframe { display: block; width: 100%; height: 60vh; min-height: 240px; border: 0; background: #fff; resize: vertical; }
.mailtext {
  margin: 0; padding: 1rem; white-space: pre-wrap; overflow-wrap: anywhere;
  font: 0.95rem/1.55 var(--sans);
}
.imgbar { margin: 0; padding: 0.5rem 1rem; background: var(--warn-bg); border-bottom: 1px solid var(--warn-line); }
.atts { list-style: none; margin: 0; padding: 0.5rem 1rem; border-top: 1px solid var(--line); display: grid; gap: 0.25rem; }
.atts a { overflow-wrap: anywhere; }
.msg-actions { padding: 0.75rem 1rem; border-top: 1px solid var(--line); }
.compose textarea { min-height: 14rem; }

.tablewrap { overflow-x: auto; margin: 0 0 1rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.records { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
.records th, .records td { text-align: left; padding: 0.55rem 0.75rem; border-top: 1px solid var(--line); vertical-align: top; }
.records thead th { border-top: 0; color: var(--muted); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.05em; }
.records td.mono { word-break: break-all; min-width: 10rem; }
.records td.over { color: var(--err); font-weight: 700; }
fieldset.events { border: 1px solid var(--line); border-radius: var(--radius); padding: 0.5rem 0.9rem 0.75rem; display: grid; gap: 0.35rem; }
fieldset.events legend { font-weight: 600; font-size: 0.92rem; padding: 0 0.25rem; }
details.manage { margin-top: 2rem; }
details.manage summary { cursor: pointer; color: var(--muted); margin-bottom: 0.75rem; }
.review { margin: 0 0 1rem; }
.review .head { margin-bottom: 0.5rem; }
.audit code.data { font: 0.8rem/1.4 var(--mono); color: var(--ink-2); overflow-wrap: anywhere; }

@media (max-width: 560px) {
  .msg-head { flex-direction: column; gap: 0.25rem; }
  .mailframe { height: 70vh; }
  .addlabel { display: flex; width: 100%; }
  .addlabel input { width: auto; flex: 1; }
  .threads .row { flex-direction: row; }
  .search button { width: 100%; }
}
