/* WAPI — shared styles (dark theme). No external fonts, no CDN. */

:root {
  --bg: #0b0f14;
  --surface: #111820;
  --surface-2: #0d1117;
  --surface-3: #161d26;
  --border: #1f2937;
  --border-strong: #2c3846;
  --text: #e6edf3;
  --muted: #9fb0bf;
  --green: #238636;
  --green-hover: #2ea043;
  --green-bright: #7ee787;
  --error: #f85149;
  --error-bg: #2a1414;
  --warn: #d29922;
  --warn-bg: #241c08;
  --info: #58a6ff;
  --radius: 12px;
  --radius-sm: 10px;
  --radius-lg: 16px;
  --max: 1120px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--green-bright);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

h1, h2, h3, h4 {
  line-height: 1.2;
  margin: 0 0 .5em;
  font-weight: 700;
  letter-spacing: -.01em;
}

h1 { font-size: 40px; }
h2 { font-size: 28px; }
h3 { font-size: 20px; }
h4 { font-size: 16px; }

p {
  margin: 0 0 1em;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

:focus-visible {
  outline: 2px solid var(--green-bright);
  outline-offset: 2px;
  border-radius: 4px;
}

::selection {
  background: rgba(35, 134, 54, .45);
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

[hidden] {
  display: none !important;
}

/* ---------- layout ---------- */

.container {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding: 0 20px;
}

.container-narrow {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 0 20px;
}

.page {
  padding: 32px 0 64px;
}

.stack > * + * {
  margin-top: 16px;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.row-between {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.mono {
  font-family: var(--mono);
  font-size: 13px;
}

.lead {
  color: var(--muted);
  font-size: 18px;
  max-width: 680px;
}

.section {
  margin-top: 56px;
}

.section-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--green-bright);
  font-weight: 700;
  margin-bottom: 8px;
}

/* ---------- banner / header / nav ---------- */

.banner {
  background: var(--warn-bg);
  border-bottom: 1px solid #4a3a12;
  color: #f2d493;
  font-size: 13.5px;
  padding: 9px 20px;
  text-align: center;
}

.banner strong {
  color: var(--warn);
  letter-spacing: .06em;
  text-transform: uppercase;
  font-size: 12.5px;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(11, 15, 20, .92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

.nav {
  display: flex;
  align-items: center;
  gap: 20px;
  min-height: 62px;
  flex-wrap: wrap;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  font-weight: 800;
  font-size: 19px;
  letter-spacing: .04em;
  color: var(--text);
}

.brand:hover {
  text-decoration: none;
  color: var(--green-bright);
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: linear-gradient(145deg, #2ea043, #17663a);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-wrap: wrap;
}

.nav-links a {
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14.5px;
  font-weight: 500;
}

.nav-links a:hover {
  color: var(--text);
  background: var(--surface-3);
  text-decoration: none;
}

.nav-links a.is-active {
  color: var(--text);
  background: var(--surface-3);
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: 64px;
  padding: 28px 0 44px;
  color: var(--muted);
  font-size: 13.5px;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 20px;
  margin-bottom: 12px;
}

.footer-links a {
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--green-bright);
}

/* ---------- buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  line-height: 1;
  padding: 12px 20px;
  min-height: 42px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--surface-3);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}

.btn:hover {
  text-decoration: none;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: .55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--green);
  border-color: #2ea043;
  color: #fff;
}

.btn-primary:hover {
  background: var(--green-hover);
}

.btn-secondary {
  background: var(--surface-3);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: #1b2530;
}

.btn-danger {
  background: transparent;
  border-color: #6e2b28;
  color: var(--error);
}

.btn-danger:hover {
  background: var(--error-bg);
  border-color: var(--error);
}

.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface-3);
  color: var(--text);
}

.btn-sm {
  min-height: 34px;
  padding: 7px 13px;
  font-size: 13px;
}

.btn-block {
  width: 100%;
}

/* ---------- cards / panels ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px;
}

.card-tight {
  padding: 16px;
}

.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.card-title h2,
.card-title h3 {
  margin: 0;
}

.grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
}

.grid-2 {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

.panel {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}

/* ---------- badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-3);
  color: var(--muted);
  white-space: nowrap;
}

.badge-ok {
  background: #0e2a17;
  border-color: #1f5f2f;
  color: var(--green-bright);
}

.badge-warn {
  background: var(--warn-bg);
  border-color: #4a3a12;
  color: var(--warn);
}

.badge-error {
  background: var(--error-bg);
  border-color: #6e2b28;
  color: var(--error);
}

.badge-demo {
  background: #10233a;
  border-color: #1f4a7a;
  color: var(--info);
}

.badge-info {
  background: #10233a;
  border-color: #1f4a7a;
  color: var(--info);
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

/* ---------- forms ---------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.form-row {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

label {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--muted);
}

input,
select,
textarea {
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  width: 100%;
  transition: border-color .15s ease, box-shadow .15s ease;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

input::placeholder,
textarea::placeholder {
  color: #6d7f8f;
}

input:hover,
select:hover,
textarea:hover {
  border-color: #3a4756;
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(35, 134, 54, .3);
}

select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 34px;
}

.hint {
  font-size: 12.5px;
  color: var(--muted);
}

.form-error {
  margin: 0;
  color: var(--error);
  font-size: 14px;
  background: var(--error-bg);
  border: 1px solid #6e2b28;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.form-error:empty {
  display: none;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

/* ---------- tabs ---------- */

.tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
}

.tab {
  flex: 1;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 9px;
  padding: 10px 14px;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
}

.tab[aria-selected="true"] {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* ---------- tables ---------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  min-width: 460px;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

th {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  background: var(--surface-2);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: #131b24;
}

td.actions {
  text-align: right;
  white-space: nowrap;
}

/* ---------- code ---------- */

code {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 6px;
}

pre {
  margin: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  overflow-x: auto;
  font-size: 13px;
  line-height: 1.6;
}

pre code {
  background: none;
  border: 0;
  padding: 0;
  color: #c9d7e3;
  white-space: pre;
}

/* ---------- empty states & spinner ---------- */

.empty {
  text-align: center;
  padding: 40px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--muted);
}

.empty h3 {
  color: var(--text);
  margin-bottom: 6px;
}

.empty p {
  margin-bottom: 16px;
}

.spinner {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  border-top-color: var(--green-bright);
  animation: spin .8s linear infinite;
  display: inline-block;
}

.spinner-lg {
  width: 34px;
  height: 34px;
  border-width: 3px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 60px 20px;
  color: var(--muted);
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* ---------- toasts ---------- */

.toast-wrap {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
}

.toast {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-left: 3px solid var(--green-bright);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 14px;
  box-shadow: var(--shadow);
  animation: toast-in .18s ease;
}

.toast-error {
  border-left-color: var(--error);
}

.toast-warn {
  border-left-color: var(--warn);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

/* ---------- modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 10, .78);
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow);
}

.modal h3 {
  margin-top: 0;
}

.key-reveal {
  font-family: var(--mono);
  font-size: 13px;
  word-break: break-all;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px;
  color: var(--green-bright);
}

.warn-box {
  background: var(--warn-bg);
  border: 1px solid #4a3a12;
  color: #f2d493;
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13.5px;
}

/* ---------- app shell ---------- */

.app-shell {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-main {
  flex: 1;
  padding: 26px 0 56px;
}

.account-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- steps ---------- */

.steps {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

.step {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.step-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.step-num {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--green);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  flex: none;
}

.step-head h2 {
  font-size: 17px;
  margin: 0;
}

.qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  background: #fff;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 14px;
  min-height: 220px;
  justify-content: center;
}

.qr-box img {
  width: 200px;
  height: 200px;
  image-rendering: pixelated;
}

.qr-placeholder {
  color: #55606b;
  font-size: 14px;
  text-align: center;
  padding: 30px 16px;
}

/* ---------- chat ---------- */

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  height: 320px;
  overflow-y: auto;
}

.msg {
  max-width: 78%;
  border-radius: 12px;
  padding: 8px 11px;
  font-size: 14.5px;
  background: var(--surface-3);
  border: 1px solid var(--border);
  align-self: flex-start;
  word-break: break-word;
}

.msg.out {
  align-self: flex-end;
  background: #0e2a17;
  border-color: #1f5f2f;
}

.msg-meta {
  display: block;
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
}

.chat-form {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.chat-form input {
  flex: 1;
}

/* ---------- inbox layout ---------- */

.inbox {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 280px;
  gap: 16px;
  align-items: start;
}

.inbox-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.inbox-panel h2,
.inbox-panel h3 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--muted);
  margin: 0;
}

.thread-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 420px;
  overflow-y: auto;
}

.thread-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  cursor: pointer;
  color: var(--text);
}

.thread-item:hover {
  border-color: var(--border-strong);
  background: var(--surface-3);
}

.thread-item.is-active {
  border-color: var(--green);
  background: #0e2a17;
}

.thread-peer {
  font-weight: 600;
  font-size: 14.5px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.thread-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.thread-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-top: 3px;
}

.thread-item .unread {
  background: var(--green);
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  flex: none;
}

.thread-preview {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.thread-time {
  color: var(--muted);
  font-size: 11.5px;
  flex: none;
}

.inbox-thread {
  min-height: 480px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.thread-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
}

.thread-head h2 {
  font-size: 17px;
  margin: 0;
}

.inbox-thread .chat-log {
  height: 380px;
  flex: 1;
}

.contact-kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 14px;
  font-size: 14px;
  margin: 0;
}

.contact-kv dt {
  color: var(--muted);
}

.contact-kv dd {
  margin: 0;
  word-break: break-word;
}

.tip-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 13.5px;
}

.tip-list li + li {
  margin-top: 6px;
}

@media (max-width: 900px) {
  .inbox {
    grid-template-columns: minmax(0, 1fr);
  }

  .thread-list {
    max-height: 260px;
  }
}

/* ---------- misc ---------- */

.endpoint {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 13.5px;
  flex-wrap: wrap;
}

.verb {
  font-weight: 700;
  font-size: 11.5px;
  letter-spacing: .06em;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  flex: none;
}

.verb-get {
  color: var(--info);
  background: #10233a;
  border-color: #1f4a7a;
}

.verb-post {
  color: var(--green-bright);
  background: #0e2a17;
  border-color: #1f5f2f;
}

.kv-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px 16px;
  font-size: 14.5px;
  margin: 0;
}

.kv-list dt {
  color: var(--muted);
}

.kv-list dd {
  margin: 0;
}

.status-live {
  min-height: 24px;
  font-size: 14.5px;
}

.status-live.is-error {
  color: var(--error);
}

.status-live.is-ok {
  color: var(--green-bright);
}

.auth-col {
  max-width: 560px;
  margin: 0 auto;
}

.auth-head {
  text-align: center;
  margin-bottom: 20px;
}

.auth-head .lead {
  margin-left: auto;
  margin-right: auto;
}

.auth-panels {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 16px;
}

.panel-note {
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
  margin: 4px 0 0;
}

.panel-note a {
  color: var(--green-bright);
}

/* small screens: no horizontal overflow at 360-375px (QA 2026-09-28) */
@media (max-width: 520px) {
  .container,
  .container-narrow {
    padding: 0 14px;
  }

  .nav {
    gap: 10px;
    row-gap: 6px;
  }

  .nav-links {
    gap: 2px;
    margin-left: 0;
  }

  .nav-links a {
    padding: 6px 9px;
    font-size: 13.5px;
  }

  .account-chip {
    max-width: 100%;
    font-size: 12.5px;
  }

  .pricing-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}
