:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #66716b;
  --paper: #f4f2eb;
  --surface: #fffdf7;
  --line: #d8d8cd;
  --green: #1d5e46;
  --green-bright: #b5f536;
  --orange: #f26a3d;
  --shadow: 0 24px 70px rgba(31, 45, 38, 0.09);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 90% 2%, rgba(181, 245, 54, 0.15), transparent 24rem),
    var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .62; }

.shell { width: min(1180px, calc(100% - 40px)); margin: 0 auto; padding-bottom: 70px; }

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark {
  width: 38px; height: 38px; display: grid; place-items: center;
  background: var(--ink); color: var(--green-bright); border-radius: 11px;
  font-family: Georgia, serif; font-size: 21px; font-style: italic;
}
.brand strong, .brand small { display: block; }
.brand strong { letter-spacing: -0.02em; }
.brand small { color: var(--muted); font-size: 11px; margin-top: 2px; }

.backend-status { display: flex; align-items: center; gap: 9px; color: var(--muted); font-size: 13px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #a5aaa7; box-shadow: 0 0 0 4px rgba(165,170,167,.15); }
.backend-status.online .status-dot { background: #37a56c; box-shadow: 0 0 0 4px rgba(55,165,108,.15); }
.backend-status.offline .status-dot { background: #d45742; box-shadow: 0 0 0 4px rgba(212,87,66,.15); }

.hero { padding: 74px 0 54px; max-width: 800px; }
.eyebrow { margin: 0 0 17px; color: var(--green); font-size: 12px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; }
.hero h1 { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(52px, 7vw, 88px); font-weight: 400; line-height: .91; letter-spacing: -.055em; }
.hero h1 em { color: var(--green); font-weight: 400; }
.hero-copy { max-width: 640px; margin: 28px 0 0; color: var(--muted); font-size: 17px; line-height: 1.65; }

.workspace { display: grid; grid-template-columns: 360px minmax(0, 1fr); background: var(--surface); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow); overflow: hidden; }
.network-panel, .test-panel { padding: 32px; }
.network-panel { background: #edece4; border-right: 1px solid var(--line); }
.section-heading { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 28px; }
.section-heading > span { display: grid; place-items: center; width: 27px; height: 27px; border: 1px solid var(--ink); border-radius: 50%; font-size: 10px; font-weight: 800; }
.section-heading p { margin: 0 0 3px; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .11em; text-transform: uppercase; }
.section-heading h2 { margin: 0; font-family: Georgia, serif; font-size: 23px; font-weight: 400; }

.network-list { display: grid; gap: 9px; }
.network-card {
  width: 100%; display: grid; grid-template-columns: 42px 1fr auto; align-items: center; gap: 12px;
  padding: 13px; text-align: left; color: var(--ink); background: transparent; border: 1px solid transparent; border-radius: 14px;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.network-card:hover { transform: translateX(3px); background: rgba(255,255,255,.5); }
.network-card.active { background: var(--surface); border-color: #cfd1c7; box-shadow: 0 7px 20px rgba(31,45,38,.06); }
.network-card strong, .network-card small { display: block; }
.network-card strong { font-size: 14px; }
.network-card small { color: var(--muted); margin-top: 3px; font-size: 11px; }
.network-icon { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 12px; color: white; font-size: 11px; font-weight: 900; letter-spacing: .04em; }
.network-icon.whatsapp { background: #228c5a; }
.network-icon.messenger { background: #266bea; }
.network-icon.instagram { background: linear-gradient(135deg, #7b38ae, #e34f62 60%, #f2a642); }
.network-icon.tiktok { background: #171918; }
.availability { padding: 4px 7px; border-radius: 20px; font-size: 9px; font-weight: 900; text-transform: uppercase; }
.availability.live { color: #246a48; background: #dff3df; }
.availability.async { color: #855732; background: #f5e7d4; }
.privacy-note { display: flex; gap: 12px; margin-top: 26px; padding-top: 22px; border-top: 1px solid var(--line); color: var(--muted); }
.privacy-note > span { color: var(--green); font-size: 22px; }
.privacy-note p { margin: 0; font-size: 11px; line-height: 1.55; }
.privacy-note strong { display: block; color: var(--ink); font-size: 12px; }

.token-row { margin-bottom: 25px; }
label > span, .token-row > label { display: block; margin-bottom: 8px; color: var(--muted); font-size: 11px; font-weight: 800; letter-spacing: .05em; text-transform: uppercase; }
.token-control { display: flex; align-items: center; border: 1px solid var(--line); border-radius: 11px; background: white; overflow: hidden; }
.token-control input { flex: 1; border: 0; min-width: 0; }
input, textarea, select { width: 100%; color: var(--ink); background: white; border: 1px solid var(--line); border-radius: 11px; padding: 12px 13px; outline: 0; transition: border-color .18s, box-shadow .18s; }
input:focus, textarea:focus, select:focus { border-color: var(--green); box-shadow: 0 0 0 3px rgba(29,94,70,.1); }
textarea { resize: vertical; line-height: 1.5; }
.text-button { border: 0; background: transparent; color: var(--green); font-size: 12px; font-weight: 800; padding: 10px 13px; }

.endpoint-line { display: flex; justify-content: space-between; align-items: center; gap: 15px; padding: 12px 14px; margin-bottom: 24px; background: #f0efe9; border-radius: 11px; color: var(--muted); font-size: 11px; }
.endpoint-line > div { display: flex; align-items: center; gap: 9px; min-width: 0; }
.endpoint-line code { color: var(--ink); overflow: hidden; text-overflow: ellipsis; }
.method { color: var(--green); font-size: 9px; font-weight: 900; }
.mode-picker { display: inline-grid; grid-template-columns: 1fr 1fr; padding: 4px; margin: 0 0 24px; background: #ecece5; border-radius: 12px; }
.mode-button { min-width: 120px; padding: 9px 14px; border: 0; border-radius: 9px; color: var(--muted); background: transparent; font-size: 12px; font-weight: 800; }
.mode-button.active { color: var(--ink); background: white; box-shadow: 0 3px 10px rgba(31,45,38,.08); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.full-width { grid-column: 1 / -1; }
.actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 22px; }
.primary-button, .secondary-button { min-height: 45px; border-radius: 11px; padding: 0 17px; font-weight: 800; border: 1px solid var(--ink); }
.primary-button { color: white; background: var(--ink); }
.primary-button:hover { background: var(--green); border-color: var(--green); }
.primary-button span { margin-left: 12px; color: var(--green-bright); }
.secondary-button { color: var(--ink); background: transparent; }
.secondary-button:hover { background: #eeeee7; }
.button-indicator { display: inline-block; width: 7px; height: 7px; margin-right: 8px; border-radius: 50%; background: #a4aaa6; }
.secondary-button.connected .button-indicator { background: #31a067; box-shadow: 0 0 0 4px rgba(49,160,103,.13); }
.simulation-caption { margin: 10px 0 0; text-align: right; color: var(--muted); font-size: 10px; }
.real-caption code { color: var(--green); }
.real-account-note { display: flex; gap: 12px; margin: 0 0 22px; padding: 13px 15px; border: 1px solid #d2dfca; border-radius: 12px; background: #edf3e8; }
.real-account-note > span { flex: 0 0 auto; display: grid; place-items: center; width: 25px; height: 25px; border-radius: 50%; color: white; background: var(--green); font-weight: 900; }
.real-account-note p { margin: 0; color: #526056; font-size: 11px; line-height: 1.5; }
.real-account-note strong { display: block; color: var(--ink); font-size: 12px; }
.real-account-note code { color: var(--green); }
.messenger-note > span { background: #266bea; font-family: Georgia, serif; font-size: 18px; }
.messenger-top-actions { flex-wrap: wrap; }
.messenger-inbox { display: grid; grid-template-columns: minmax(190px, .8fr) minmax(280px, 1.2fr); min-height: 430px; margin-top: 24px; border: 1px solid var(--line); border-radius: 15px; overflow: hidden; background: white; }
.conversation-column { min-width: 0; border-right: 1px solid var(--line); background: #f3f3ed; }
.message-column { display: grid; grid-template-rows: auto minmax(150px, 1fr) auto; min-width: 0; }
.inbox-heading { min-height: 51px; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 15px; border-bottom: 1px solid var(--line); }
.inbox-heading strong { font-family: Georgia, serif; font-size: 15px; }
.inbox-heading span { color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .05em; }
.conversation-list, .message-list { overflow: auto; max-height: 390px; }
.conversation-button { width: 100%; padding: 13px 14px; text-align: left; color: var(--ink); border: 0; border-bottom: 1px solid #dedfd7; background: transparent; }
.conversation-button:hover, .conversation-button.active { background: white; }
.conversation-button strong, .conversation-button small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conversation-button strong { font-size: 12px; }
.conversation-button small { margin-top: 4px; color: var(--muted); font-size: 9px; }
.inbox-empty { margin: 0; padding: 28px 18px; color: var(--muted); font-size: 11px; line-height: 1.5; text-align: center; }
.message-list { padding: 15px; background: #fbfaf6; }
.message-bubble { width: fit-content; max-width: 86%; margin: 0 0 10px; padding: 9px 11px; border-radius: 12px 12px 12px 3px; background: #e7e8e1; font-size: 11px; line-height: 1.45; overflow-wrap: anywhere; }
.message-bubble.outgoing { margin-left: auto; border-radius: 12px 12px 3px 12px; color: white; background: #266bea; }
.message-bubble time { display: block; margin-top: 4px; color: inherit; opacity: .65; font-size: 8px; }
.messenger-compose { display: grid; gap: 10px; padding: 14px; border-top: 1px solid var(--line); }
.messenger-compose label > span { margin-bottom: 5px; font-size: 9px; }
.messenger-compose input, .messenger-compose textarea { padding: 9px 10px; font-size: 11px; }
.messenger-compose .primary-button { justify-self: end; min-height: 39px; font-size: 11px; }

.callout { display: flex; gap: 13px; padding: 16px; background: #edf3e8; border: 1px solid #d2dfca; border-radius: 13px; }
.callout > span { flex: 0 0 auto; width: 23px; height: 23px; display: grid; place-items: center; border-radius: 50%; background: var(--green); color: white; font-family: Georgia, serif; font-style: italic; }
.callout p { margin: 0; color: #526056; font-size: 13px; line-height: 1.55; }
.tiktok-actions { display: flex; align-items: center; gap: 18px; margin-top: 25px; }
.oauth-link { color: var(--green); font-size: 12px; font-weight: 800; }
.export-row { display: grid; grid-template-columns: auto 1fr auto; gap: 10px; margin-top: 18px; }

.event-console { margin-top: 20px; background: #18201c; border-radius: 20px; color: #eaf0eb; overflow: hidden; box-shadow: var(--shadow); }
.console-header { height: 58px; display: flex; align-items: center; justify-content: space-between; padding: 0 22px; border-bottom: 1px solid #303a35; }
.console-header > div { display: flex; align-items: center; gap: 10px; }
.console-header .text-button { color: #a9b5ae; }
.console-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--green-bright); box-shadow: 0 0 14px rgba(181,245,54,.6); }
.event-list { min-height: 190px; max-height: 390px; overflow: auto; padding: 15px; font-family: "Cascadia Code", Consolas, monospace; }
.empty-state { min-height: 160px; display: grid; place-content: center; justify-items: center; color: #77847d; text-align: center; }
.empty-state span { font-size: 30px; color: #536159; }
.empty-state p { font-family: Inter, sans-serif; font-size: 12px; }
.event-row { display: grid; grid-template-columns: 88px 108px 1fr; gap: 12px; padding: 11px 10px; border-bottom: 1px solid #29322e; font-size: 11px; line-height: 1.5; }
.event-time { color: #77847d; }
.event-network { color: var(--green-bright); text-transform: uppercase; }
.event-data { color: #cbd6cf; overflow-wrap: anywhere; white-space: pre-wrap; }
.event-row.error .event-network { color: #ff9978; }

.toast { position: fixed; right: 22px; bottom: 22px; max-width: min(420px, calc(100% - 44px)); padding: 14px 17px; border-radius: 12px; background: var(--ink); color: white; box-shadow: var(--shadow); font-size: 13px; z-index: 10; }
.toast.error { background: #8c3529; }

@media (max-width: 820px) {
  .shell { width: min(100% - 24px, 680px); }
  .hero { padding-top: 52px; }
  .workspace { grid-template-columns: 1fr; }
  .network-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .network-list { grid-template-columns: 1fr 1fr; }
  .event-row { grid-template-columns: 72px 88px 1fr; }
  .messenger-inbox { grid-template-columns: 1fr; }
  .conversation-column { border-right: 0; border-bottom: 1px solid var(--line); }
  .conversation-list { max-height: 220px; }
}

@media (max-width: 560px) {
  .shell { width: calc(100% - 18px); }
  .topbar { min-height: 70px; }
  .brand small { display: none; }
  .backend-status { font-size: 11px; }
  .hero { padding: 43px 8px 36px; }
  .hero h1 { font-size: 48px; }
  .hero-copy { font-size: 15px; }
  .network-panel, .test-panel { padding: 23px 18px; }
  .network-list { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .full-width { grid-column: auto; }
  .actions, .tiktok-actions { align-items: stretch; flex-direction: column; }
  .real-actions { align-items: stretch; }
  .mode-picker { display: grid; }
  .simulation-caption { text-align: left; }
  .export-row { grid-template-columns: 1fr; }
  .endpoint-line > span { display: none; }
  .event-row { grid-template-columns: 1fr; gap: 3px; }
}
