/* RFChat Developers. Self-contained: no external fonts or scripts. */
:root {
  color-scheme: light dark;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --panel-2: #f7f9fa;
  --line: #e3e8eb;
  --text: #111b21;
  --muted: #5f707a;
  --accent: #1daa61;
  --accent-strong: #128c4b;
  --accent-ink: #ffffff;
  --accent-soft: #e5f6ec;
  --danger: #d93a3a;
  --danger-soft: #fdecec;
  --warn: #b26f05;
  --warn-soft: #fdf3e1;
  --info: #2f80ed;
  --info-soft: #e8f1fd;
  --code-bg: #0f1a20;
  --code-text: #dfe7eb;
  --code-key: #7fd6a4;
  --code-str: #f2c879;
  --code-com: #7d8f99;
  --shadow: 0 1px 2px rgba(17, 27, 33, 0.05), 0 6px 24px rgba(17, 27, 33, 0.05);
  --radius: 16px;
  --top: 64px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0b141a;
    --panel: #111b21;
    --panel-2: #172229;
    --line: #24323b;
    --text: #e9edef;
    --muted: #8a9aa4;
    --accent: #21c063;
    --accent-strong: #3ad57a;
    --accent-ink: #062014;
    --accent-soft: #143426;
    --danger: #f15c6d;
    --danger-soft: #3b2228;
    --warn: #f0b04c;
    --warn-soft: #3a2f1b;
    --info: #5aa0ff;
    --info-soft: #1b2b40;
    --code-bg: #071015;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--top) + 16px); }
html, body { margin: 0; }
body {
  min-height: 100vh;
  font: 15px/1.55 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; letter-spacing: -0.015em; line-height: 1.25; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 20px; font-weight: 680; }
h3 { font-size: 16px; font-weight: 650; }
h4 { font-size: 14px; font-weight: 650; }
p { margin: 0; }
a { color: var(--info); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, Consolas, monospace; }
code { font-size: 0.88em; background: var(--panel-2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
[hidden] { display: none !important; }

/* ---- top bar ---- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  height: var(--top);
  display: flex; align-items: center; gap: 28px;
  padding: 0 24px;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 16px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.brand strong { font-weight: 720; }
.topnav { display: flex; gap: 4px; flex: 1; }
.topnav a {
  color: var(--muted); font-weight: 560; padding: 8px 12px; border-radius: 10px;
}
.topnav a:hover { color: var(--text); background: var(--panel-2); text-decoration: none; }
.topnav a.active { color: var(--text); background: var(--panel-2); }
.account { display: flex; align-items: center; gap: 10px; }
.avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft); color: var(--accent-strong);
  font-weight: 700; font-size: 13px;
}
.account .who { text-align: right; line-height: 1.2; }
.account .who small { display: block; color: var(--muted); font-size: 12px; }

.view { max-width: 1120px; margin: 0 auto; padding: 32px 24px 80px; outline: none; }
.view.wide { max-width: 1280px; }
.loading { display: grid; place-items: center; min-height: 50vh; }
.spinner {
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--accent);
  animation: spin 0.8s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- buttons and fields ---- */
button, .button {
  font: inherit; font-weight: 600; font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 38px; padding: 0 16px;
  border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
  cursor: pointer; white-space: nowrap;
  transition: background 0.15s, border-color 0.15s, transform 0.05s;
}
button:hover, .button:hover { background: var(--panel-2); text-decoration: none; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.55; cursor: default; transform: none; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.primary:hover, .button.primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); }
button.danger { color: var(--danger); }
button.danger:hover { background: var(--danger-soft); border-color: var(--danger-soft); }
button.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
button.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--panel-2); }
button.sm { min-height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
button.wide { width: 100%; }
button .spinner { width: 16px; height: 16px; border-width: 2px; }

.field { display: grid; gap: 6px; margin-bottom: 16px; }
.field > span { font-size: 13px; font-weight: 600; }
.field .hint { font-size: 12.5px; color: var(--muted); }
input, select, textarea {
  font: inherit; color: var(--text);
  width: 100%; min-height: 42px; padding: 9px 12px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}
input.code { font-size: 24px; letter-spacing: 0.4em; text-align: center; font-family: ui-monospace, Menlo, Consolas, monospace; }
.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.top { align-items: flex-start; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.mt { margin-top: 18px; }
.error { color: var(--danger); font-size: 13.5px; min-height: 1em; }

/* ---- surfaces ---- */
.card {
  background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 24px;
}
.card + .card, .grid + .card { margin-top: 16px; }
.grid > .card + .card { margin-top: 0; }
.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.card-head p { margin-top: 4px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.page-head p { margin-top: 6px; color: var(--muted); }
.crumbs { font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.crumbs a { color: var(--muted); }
.grid { display: grid; gap: 16px; }
.grid.apps { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
.grid.stats { grid-template-columns: repeat(3, 1fr); }
.empty { text-align: center; padding: 56px 24px; }
.empty .art {
  width: 64px; height: 64px; margin: 0 auto 16px; border-radius: 20px;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong);
}
.empty p { color: var(--muted); max-width: 440px; margin: 8px auto 20px; }

.app-card { display: block; color: var(--text); transition: border-color 0.15s, transform 0.15s; }
.app-card:hover { text-decoration: none; border-color: color-mix(in srgb, var(--accent) 50%, var(--line)); transform: translateY(-2px); }
.app-card .icon {
  width: 44px; height: 44px; border-radius: 12px; margin-bottom: 14px;
  display: grid; place-items: center; font-weight: 750; font-size: 18px;
  background: linear-gradient(135deg, var(--accent), #0f8a8a); color: #fff;
}
.app-card .meta { display: flex; gap: 14px; margin-top: 14px; font-size: 13px; color: var(--muted); }

.stat { padding: 20px; }
.stat .label { font-size: 13px; color: var(--muted); font-weight: 560; }
.stat .value { font-size: 30px; font-weight: 720; letter-spacing: -0.02em; margin-top: 4px; }

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 650; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.pill::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.pill.ok { background: var(--accent-soft); color: var(--accent-strong); border-color: transparent; }
.pill.bad { background: var(--danger-soft); color: var(--danger); border-color: transparent; }
.pill.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }
.pill.plain::before { display: none; }

/* ---- app page ---- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 24px; overflow-x: auto; }
.tabs a {
  padding: 10px 14px; color: var(--muted); font-weight: 600; white-space: nowrap;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs a:hover { color: var(--text); text-decoration: none; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); }

.steps { display: grid; gap: 10px; }
.step { display: flex; gap: 14px; align-items: center; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; }
.step .dot {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  display: grid; place-items: center; font-size: 13px; font-weight: 700;
  background: var(--panel-2); color: var(--muted); border: 1px solid var(--line);
}
.step.done .dot { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.step .grow h4 { margin-bottom: 2px; }

.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th {
  text-align: left; font-size: 12px; font-weight: 650; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); padding: 0 12px 10px; border-bottom: 1px solid var(--line);
}
.table td { padding: 14px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: none; }
.table tr.clickable { cursor: pointer; }
.table tr.clickable:hover td { background: var(--panel-2); }
.table .actions { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }

.secret {
  display: flex; align-items: center; gap: 8px;
  background: var(--panel-2); border: 1px dashed color-mix(in srgb, var(--accent) 55%, var(--line));
  border-radius: 12px; padding: 12px 12px 12px 16px;
}
.secret code { flex: 1; background: none; border: none; padding: 0; font-size: 14px; word-break: break-all; }
.notice {
  display: flex; gap: 12px; padding: 14px 16px; border-radius: 12px;
  background: var(--info-soft); font-size: 14px;
}
.notice.warn { background: var(--warn-soft); }
.notice.danger { background: var(--danger-soft); }
.notice svg { flex: none; margin-top: 2px; }
.notice + .notice, .notice + .field, .field + .notice { margin-top: 12px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 10px 16px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-all; }

/* ---- sign-in ---- */
.signin { display: grid; grid-template-columns: 1.1fr 1fr; gap: 48px; align-items: center; min-height: calc(100vh - var(--top) - 112px); }
.hero h1 { font-size: 44px; line-height: 1.08; letter-spacing: -0.03em; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero > p { font-size: 18px; color: var(--muted); margin-top: 18px; max-width: 520px; }
.features { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 32px; }
.feature { display: flex; gap: 12px; }
.feature .ic {
  width: 36px; height: 36px; border-radius: 10px; flex: none;
  display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-strong);
}
.feature h4 { margin-bottom: 2px; }
.feature p { font-size: 13.5px; color: var(--muted); }
.signin .card { padding: 32px; }
.signin .card h2 { margin-bottom: 6px; }
.signin .card > p { color: var(--muted); margin-bottom: 22px; }
.link { background: none; border: none; color: var(--info); padding: 0; min-height: 0; font-weight: 560; }
.link:hover { background: none; text-decoration: underline; }

/* ---- code ---- */
pre {
  position: relative; margin: 0;
  background: var(--code-bg); color: var(--code-text);
  border-radius: 12px; padding: 16px 18px; overflow-x: auto;
  font-size: 13px; line-height: 1.6;
}
pre code { background: none; border: none; border-radius: 0; padding: 0; font-size: inherit; color: inherit; }
pre .k { color: var(--code-key); }
pre .s { color: var(--code-str); }
pre .c { color: var(--code-com); }
.codeblock { position: relative; margin: 14px 0; }
.codeblock .lang {
  position: absolute; top: 8px; right: 56px; font-size: 11px; font-weight: 650;
  text-transform: uppercase; letter-spacing: 0.06em; color: var(--code-com);
}
.codeblock .copy {
  position: absolute; top: 6px; right: 6px; min-height: 26px; padding: 0 8px; font-size: 12px;
  background: rgba(255, 255, 255, 0.06); border-color: rgba(255, 255, 255, 0.1); color: var(--code-text);
}
.codeblock .copy, .codeblock .lang { z-index: 1; }
.codeblock .copy:hover { background: rgba(255, 255, 255, 0.14); }

/* ---- docs ---- */
.docs { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 48px; }
.docs-nav { position: sticky; top: calc(var(--top) + 24px); align-self: start; max-height: calc(100vh - var(--top) - 48px); overflow-y: auto; }
.docs-nav h4 { font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); margin: 20px 0 6px; }
.docs-nav h4:first-child { margin-top: 0; }
.docs-nav a { display: block; color: var(--text); padding: 5px 10px; border-radius: 8px; font-size: 14px; opacity: 0.8; }
.docs-nav a:hover { background: var(--panel-2); text-decoration: none; opacity: 1; }
.docs-nav a.active { background: var(--accent-soft); color: var(--accent-strong); opacity: 1; font-weight: 600; }
.doc { max-width: 780px; }
.doc section { padding-bottom: 40px; margin-bottom: 40px; border-bottom: 1px solid var(--line); }
.doc section:last-child { border-bottom: none; }
.doc h1 { margin-bottom: 12px; }
.doc h2 { margin-bottom: 12px; font-size: 24px; }
.doc h3 { margin: 26px 0 8px; }
.doc p, .doc li { color: color-mix(in srgb, var(--text) 86%, var(--muted)); }
.doc p + p { margin-top: 12px; }
.doc ul, .doc ol { padding-left: 22px; margin: 10px 0; }
.doc li + li { margin-top: 4px; }
.doc .lead { font-size: 18px; color: var(--muted); }
.endpoint {
  display: flex; align-items: center; gap: 10px; margin: 14px 0;
  font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 14px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 10px 14px;
}
.method { font-size: 11.5px; font-weight: 750; padding: 2px 8px; border-radius: 6px; letter-spacing: 0.04em; }
.method.get { background: var(--info-soft); color: var(--info); }
.method.post { background: var(--accent-soft); color: var(--accent-strong); }
.method.delete { background: var(--danger-soft); color: var(--danger); }
.params { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.params th { text-align: left; font-size: 12px; color: var(--muted); font-weight: 650; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.params td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
.params td:first-child { white-space: nowrap; }
.params td:first-child code { font-weight: 600; }
.params .type { color: var(--muted); font-size: 12.5px; display: block; margin-top: 2px; }
.badge-soon { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--warn-soft); color: var(--warn); vertical-align: middle; margin-left: 6px; }

/* ---- template preview, editor ---- */
.phone {
  background: #efeae2; border-radius: 16px; padding: 18px 14px; min-height: 160px;
  background-image: radial-gradient(rgba(0, 0, 0, 0.035) 1px, transparent 1px); background-size: 14px 14px;
}
@media (prefers-color-scheme: dark) { .phone { background-color: #0b141a; background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px); } }
.bubble-wrap { max-width: 300px; display: grid; gap: 3px; }
.bubble {
  background: #fff; color: #111b21; border-radius: 4px 14px 14px 14px; padding: 8px 10px 6px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08); font-size: 14.5px; line-height: 1.4; position: relative;
}
.b-header { font-weight: 700; margin-bottom: 3px; }
.b-media {
  height: 120px; border-radius: 8px; margin: -2px -4px 6px; display: grid; place-items: center;
  background: linear-gradient(135deg, #cfe9da, #b8d8f0); color: #3b5260; font-size: 13px; text-transform: capitalize;
}
.b-body { white-space: pre-wrap; word-break: break-word; }
.b-footer { color: #667781; font-size: 12.5px; margin-top: 3px; }
.b-time { text-align: right; color: #667781; font-size: 11px; margin-top: 2px; }
.b-button {
  background: #fff; border-radius: 10px; padding: 8px; text-align: center; color: #027eb5; font-weight: 600;
  font-size: 14px; box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}
@media (prefers-color-scheme: dark) {
  .bubble, .b-button { background: #202c33; color: #e9edef; }
  .b-button { color: #53bdeb; }
}
.tpl-editor { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; margin: 14px 0 20px; }
.tpl-side { display: grid; gap: 8px; align-content: start; position: sticky; top: 0; }
.tpl-btns { display: grid; gap: 8px; margin-bottom: 8px; }
.tpl-btn { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.tpl-btn input { min-width: 140px; }
@media (max-width: 760px) { .tpl-editor { grid-template-columns: 1fr; } .tpl-side { position: static; } }

/* ---- analytics, billing ---- */
.grid.stats6 { grid-template-columns: repeat(6, 1fr); }
@media (max-width: 1000px) { .grid.stats6 { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 560px) { .grid.stats6 { grid-template-columns: repeat(2, 1fr); } }
.grid.stats6 .stat .value { font-size: 24px; }
.chart { width: 100%; height: auto; margin-top: 10px; }
.chart .axis { font-size: 11px; fill: var(--muted); }
.chart .grid-line { stroke: var(--line); stroke-dasharray: 3 3; }
.legend-row { gap: 14px; margin-top: 6px; }
.legend { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.swatch { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.w-auto { width: auto; }
.grid.billing { grid-template-columns: 1fr 1.4fr; margin-bottom: 16px; }
@media (max-width: 900px) { .grid.billing { grid-template-columns: 1fr; } }
.balance-card .label { color: var(--muted); font-weight: 560; font-size: 13px; }
.balance { font-size: 40px; font-weight: 750; letter-spacing: -0.02em; margin: 4px 0 8px; }
.table .num, .table th.num { text-align: right; white-space: nowrap; }
.neg { color: var(--danger); }
.pos { color: var(--accent-strong); }

/* ---- modal and toasts ---- */
.scrim {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center; padding: 20px;
  background: rgba(8, 14, 18, 0.48); backdrop-filter: blur(2px);
  animation: fade 0.15s ease-out;
}
.modal {
  width: min(520px, 100%); max-height: calc(100vh - 40px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25); padding: 26px;
  animation: pop 0.18s ease-out;
}
.modal.large { width: min(940px, 100%); }
.modal h2 { margin-bottom: 8px; }
.modal .body { margin: 14px 0 22px; }
.modal .body > p { color: var(--muted); }
.modal .body > p + * { margin-top: 16px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
.toasts { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); z-index: 60; display: grid; gap: 8px; }
.toast {
  background: var(--text); color: var(--bg); padding: 10px 16px; border-radius: 12px;
  font-size: 14px; font-weight: 560; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  animation: pop 0.18s ease-out;
}
.toast.bad { background: var(--danger); color: #fff; }

@media (max-width: 900px) {
  .signin { grid-template-columns: 1fr; gap: 32px; }
  .hero h1 { font-size: 34px; }
  .docs { grid-template-columns: 1fr; gap: 24px; }
  .docs-nav { position: static; max-height: none; border-bottom: 1px solid var(--line); padding-bottom: 16px; }
  .grid.stats { grid-template-columns: 1fr; }
}
@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 0 16px; }
  .brand span { display: none; }
  .account .who { display: none; }
  .view { padding: 24px 16px 64px; }
  .features { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; align-items: stretch; }
  .kv { grid-template-columns: 1fr; gap: 2px; }
  .kv dd { margin-bottom: 10px; }
  .card { padding: 18px; }
}
