:root {
  --bg: #f5f6f8;
  --card: #ffffff;
  --text: #16181d;
  --muted: #6b7280;
  --border: #e5e7eb;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --danger: #dc2626;
  --code-bg: #eef2ff;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --card: #181b21;
    --text: #e8eaed;
    --muted: #9aa0a6;
    --border: #2a2e36;
    --accent: #818cf8;
    --accent-text: #0f1115;
    --danger: #f87171;
    --code-bg: #262a40;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
}
main, .topbar { max-width: 960px; margin: 0 auto; padding: 0 16px; }
main { padding-bottom: 40px; }
.hidden { display: none !important; }

/* Topbar */
.topbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding-top: 24px; padding-bottom: 20px; flex-wrap: wrap; }
.brand { font-size: 26px; font-weight: 800; letter-spacing: -0.5px; }
.brand span { color: var(--accent); }
.who { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.who-email { word-break: break-all; }

/* Card */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 16px;
}
.card.narrow { max-width: 420px; margin: 40px auto; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 8px; }
.card-head h2 { margin: 0; }
h2 { margin: 0 0 12px; font-size: 18px; }
.count { color: var(--muted); font-weight: 400; font-size: 14px; }
.meta { color: var(--muted); font-size: 13px; }
.error { color: var(--danger); font-size: 13px; margin-top: 8px; min-height: 1em; }
.empty { color: var(--muted); padding: 24px 0 8px; text-align: center; }
.spaced { margin-top: 8px; }
.spaced-bottom { margin-bottom: 10px; }

/* Form */
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack.wide { max-width: none; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row input { flex: 1; min-width: 160px; }
.at { color: var(--muted); }
label.check { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
input, select {
  font: inherit; color: inherit; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px; padding: 9px 11px;
}
input:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button {
  font: inherit; font-weight: 600; cursor: pointer;
  border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
  border-radius: 8px; padding: 8px 14px;
}
button:disabled { opacity: .6; cursor: default; }
button.small { padding: 4px 10px; font-size: 13px; }
button.ghost { background: transparent; color: var(--text); border-color: var(--border); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); font-weight: 600; }
a.btn {
  display: inline-block; font-weight: 600; text-decoration: none; border-radius: 8px; padding: 8px 14px;
  border: 1px solid var(--border); color: var(--text);
}
.link-pill { font-size: 12px; }

.badge { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--code-bg); color: var(--accent); font-weight: 600; }
.creds { margin-top: 12px; padding: 12px; border-radius: 8px; background: var(--code-bg); font-family: ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; word-break: break-all; }

/* API key */
.key-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 6px; }
.key-box {
  flex: 1; min-width: 220px; padding: 9px 11px; border-radius: 8px;
  background: var(--bg); border: 1px solid var(--border);
  font: 13px ui-monospace, Menlo, Consolas, monospace; word-break: break-all;
}
.key-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.api-docs { margin-top: 12px; }
.api-docs summary { cursor: pointer; font-weight: 600; color: var(--accent); }
.api-docs h3 { font-size: 14px; margin: 16px 0 4px; }
.api-docs p { margin: 4px 0; }
.api-docs code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.api-example { position: relative; }
.api-example pre {
  margin: 4px 0 0; padding: 10px 12px; padding-right: 70px; border-radius: 8px; overflow-x: auto;
  background: var(--bg); border: 1px solid var(--border); font: 12.5px/1.5 ui-monospace, Menlo, Consolas, monospace;
}
.api-example button { position: absolute; top: 6px; right: 6px; padding: 2px 8px; font-size: 12px; }

.search { width: 100%; margin: 4px 0 8px; }
.more { text-align: center; margin-top: 8px; }
mark { background: var(--code-bg); color: var(--accent); border-radius: 3px; padding: 0 1px; }

/* Table */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 8px 6px; border-top: 1px solid var(--border); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; border-top: 0; }
td.mono { font-family: ui-monospace, Menlo, Consolas, monospace; word-break: break-all; }
td.actions { white-space: nowrap; text-align: right; }
td.actions button { padding: 4px 10px; font-size: 13px; margin-left: 4px; }
.unseen-dot { color: var(--accent); font-weight: 700; }

/* Inbox */
.addr-row { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.addr { font: 600 22px/1.3 ui-monospace, Menlo, Consolas, monospace; word-break: break-all; flex: 1; }
.live { color: #16a34a; font-size: 12px; }
.list { list-style: none; margin: 4px 0 0; padding: 0; }
.list li {
  display: grid; grid-template-columns: 1fr auto; gap: 4px 12px;
  padding: 12px; border-radius: 8px; cursor: pointer; border-top: 1px solid var(--border);
}
.list li:first-child { border-top: 0; }
.list li:hover { background: var(--bg); }
.list li.unseen .subj { font-weight: 700; }
.list .from { color: var(--muted); font-size: 13px; }
.list .time { color: var(--muted); font-size: 12px; text-align: right; }
.list .preview { color: var(--muted); font-size: 13px; grid-column: 1 / -1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.code-pill {
  font: 700 14px ui-monospace, Menlo, Consolas, monospace;
  background: var(--code-bg); color: var(--accent);
  padding: 2px 8px; border-radius: 6px; justify-self: end; text-align: center;
}

.viewer-head { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.viewer-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.subject { font-weight: 700; font-size: 17px; word-break: break-word; }
iframe { width: 100%; height: 60vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
