:root {
  color-scheme: light;
  --ink: #172238;
  --muted: #778199;
  --line: #e7eaf0;
  --panel: rgba(255, 255, 255, 0.9);
  --blue: #4c6fff;
  --blue-dark: #3453dd;
  --violet: #7d5cff;
  --green: #24c486;
  --red: #ef5a67;
  font-family: "DM Sans", sans-serif;
  background: #f4f6fa;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 15% 20%, rgba(122, 92, 255, .08), transparent 27%),
    radial-gradient(circle at 90% 85%, rgba(76, 111, 255, .08), transparent 30%),
    #f5f7fb;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.app-shell { min-height: 100vh; padding: 26px; }
.workspace {
  max-width: 1480px;
  min-height: calc(100vh - 52px);
  margin: 0 auto;
  overflow: hidden;
  border: 1px solid rgba(225, 229, 238, .9);
  border-radius: 28px;
  background: rgba(255,255,255,.72);
  box-shadow: 0 24px 80px rgba(49, 60, 92, .11);
  backdrop-filter: blur(18px);
}

.topbar {
  height: 92px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 34px;
  border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,.75);
}

.brand { display: flex; align-items: center; gap: 13px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 14px; display: flex; gap: 4px;
  align-items: center; justify-content: center;
  color: white; background: linear-gradient(145deg, var(--blue), var(--violet));
  box-shadow: 0 8px 22px rgba(76,111,255,.28);
}
.brand-mark span { display:block; width: 4px; border-radius: 5px; background: white; }
.brand-mark span:nth-child(1) { height: 10px; opacity:.75; }
.brand-mark span:nth-child(2) { height: 20px; }
.brand-mark span:nth-child(3) { height: 14px; opacity:.85; }
.brand h1, .panel-heading h2 { font: 800 22px/1 "Manrope"; margin: 3px 0 0; letter-spacing: -.5px; }
.eyebrow { margin: 0; text-transform: uppercase; letter-spacing: 1.6px; font-size: 9px; font-weight: 700; color: #9ca5b7; }

.connection-pill {
  display:flex; align-items:center; gap:8px; padding: 9px 13px; border-radius: 30px;
  color: #3c8069; background: #eefaf5; font-size: 12px; font-weight: 700;
}
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px rgba(36,196,134,.12); }
.connection-pill.offline { color: #a14a52; background: #fff0f1; }
.connection-pill.offline .status-dot { background: var(--red); box-shadow: 0 0 0 4px rgba(239,90,103,.12); }

.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  min-height: calc(100vh - 145px);
}
.panel-heading { display:flex; justify-content:space-between; align-items:center; margin-bottom: 30px; }
.panel-heading h2 { font-size: 18px; }
.icon-button, .phone-icon-button {
  border:0; background:transparent; color:#8992a7; display:grid; place-items:center; padding:8px; border-radius:10px;
}
.icon-button:hover, .phone-icon-button:hover { background:#f0f2f7; color:var(--ink); }
.icon-button svg, .phone-icon-button svg, .inspect-icon svg { width:20px; height:20px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }

.field { display:block; margin-bottom: 20px; }
.field > span { display:block; margin-bottom:8px; color:#737d91; font-size:11px; font-weight:700; }
.field input, .field select {
  width:100%; border:1px solid #e1e5ec; border-radius:12px; padding:12px 13px; outline:none;
  color:var(--ink); background:#fbfcfe; font-size:13px; transition:.2s ease;
}
.field input:focus, .field select:focus { border-color:#9daeff; box-shadow: 0 0 0 3px rgba(76,111,255,.09); background:white; }
.input-wrap { position:relative; }
.input-wrap .prefix { position:absolute; z-index:1; left:13px; top:11px; font-size:13px; color:#99a1b3; }
.input-wrap input { padding-left:25px; }
.divider { height:1px; background:var(--line); margin: 27px 0; }
.metric-row { display:grid; grid-template-columns:repeat(3,1fr); gap:7px; margin-bottom:28px; }
.metric { text-align:center; padding:12px 3px; border-radius:12px; background:#f7f8fb; }
.metric span { display:block; font:700 18px/1 "Manrope"; }
.metric small { display:block; margin-top:6px; color:#9aa2b3; font-size:9px; }
.endpoint-card { padding:15px; border:1px solid #e5e8f0; border-radius:14px; background:linear-gradient(145deg,#fafbff,#f7f5ff); }
.endpoint-title { display:flex; justify-content:space-between; align-items:center; margin-bottom:10px; font-size:10px; font-weight:700; color:#818a9e; }
.mode-badge { padding:3px 6px; border-radius:5px; color:#5a42c8; background:#ece8ff; font-size:8px; letter-spacing:.7px; }
.endpoint-card code { display:block; overflow:hidden; text-overflow:ellipsis; color:#4e5e7a; font-size:10px; white-space:nowrap; }
.endpoint-card p { margin:10px 0 0; color:#929aad; font-size:10px; line-height:1.45; }

.phone-stage {
  position:relative; display:grid; place-items:center; min-height:720px; overflow:hidden;
  background:
    linear-gradient(rgba(255,255,255,.6),rgba(255,255,255,.6)),
    radial-gradient(circle at center, #eef1ff 0, #f6f7fb 56%, #f4f5f8 100%);
}
.phone-stage::before {
  content:""; position:absolute; width:460px; height:460px; border:1px solid rgba(76,111,255,.08);
  border-radius:50%; box-shadow: 0 0 0 75px rgba(76,111,255,.025), 0 0 0 150px rgba(76,111,255,.018);
}
.ambient { position:absolute; border-radius:50%; filter:blur(3px); }
.ambient-one { width:110px; height:110px; top:12%; left:12%; background:rgba(125,92,255,.09); }
.ambient-two { width:80px; height:80px; right:13%; bottom:15%; background:rgba(76,111,255,.1); }

.phone { position:relative; z-index:2; padding:20px 0; }
.phone-frame {
  width: 344px; height: 700px; padding: 9px; border-radius: 48px;
  background: linear-gradient(145deg,#252a35,#080a0e 65%);
  box-shadow: 0 34px 70px rgba(25,33,55,.25), inset 0 0 0 1px #4b515e;
}
.phone-screen { position:relative; height:100%; overflow:hidden; border-radius:40px; background:#fff; display:flex; flex-direction:column; }
.dynamic-island { position:absolute; z-index:6; top:18px; left:50%; transform:translateX(-50%); width:94px; height:27px; border-radius:20px; background:#08090b; }
.status-bar { height:48px; padding:13px 24px 0; display:flex; align-items:center; justify-content:space-between; font-size:10px; font-weight:700; }
.status-icons { display:flex; align-items:center; gap:4px; }
.status-icons svg { width:13px; height:13px; fill:none; stroke:#151821; stroke-width:2.2; }
.battery { width:17px; height:8px; padding:1px; border:1px solid #151821; border-radius:2px; position:relative; }
.battery::after { content:""; position:absolute; right:-3px; top:2px; width:2px; height:4px; border-radius:0 2px 2px 0; background:#151821; }
.battery i { display:block; width:80%; height:100%; background:#151821; border-radius:1px; }

.conversation-header { min-height:64px; padding:6px 12px 11px; display:flex; align-items:center; border-bottom:1px solid #edf0f4; background:rgba(255,255,255,.96); }
.phone-icon-button { padding:7px; }
.phone-icon-button svg { width:18px; height:18px; }
.avatar {
  position:relative; width:37px; height:37px; flex:0 0 auto; display:grid; place-items:center; border-radius:50%;
  color:white; background:linear-gradient(145deg,#735cff,#496eff); font:700 11px "Manrope";
  box-shadow:0 5px 14px rgba(76,111,255,.22);
}
.online-dot { position:absolute; right:0; bottom:1px; width:9px; height:9px; border:2px solid white; border-radius:50%; background:var(--green); }
.contact { flex:1; padding-left:10px; }
.contact strong { display:block; font:700 12px "Manrope"; }
.contact span { display:block; margin-top:2px; color:#9ca5b4; font-size:8px; }

.messages {
  flex:1; min-height:0; overflow-y:auto; padding:18px 14px 10px;
  scrollbar-width:none; background:linear-gradient(180deg,#fff 0%,#fdfdff 100%);
  overflow-anchor: none;
  scroll-behavior: auto;
}
.messages::-webkit-scrollbar { display:none; }
.day-separator { text-align:center; margin:2px 0 16px; color:#a8afbd; font-size:8px; font-weight:600; }
.message-row {
  display:flex;
  margin:0 0 11px;
  animation:none !important;
  transition:none !important;
  transform:none !important;
}
.message-row.outbound { justify-content:flex-end; }
.bubble-wrap { max-width:78%; contain:layout style; }
.bubble {
  border:0; padding:9px 11px; text-align:left; line-height:1.35; font-size:11px; word-break:break-word;
  color:#3a4355; background:#f0f2f6; border-radius:5px 15px 15px 15px;
  box-shadow:0 2px 5px rgba(44,52,75,.04);
  animation:none !important; transition:none !important; transform:none !important;
}
.outbound .bubble { color:white; background:linear-gradient(145deg,#5878ff,#4864eb); border-radius:15px 5px 15px 15px; box-shadow:0 5px 12px rgba(76,111,255,.18); }
.bubble.selected { outline:2px solid rgba(125,92,255,.35); outline-offset:2px; }
.message-meta { display:flex; min-height:10px; align-items:center; gap:4px; margin-top:4px; padding:0 3px; color:#a2a9b8; font-size:7px; }
.outbound .message-meta { justify-content:flex-end; }
.delivery-check { color:#5372f4; font-size:9px; letter-spacing:-3px; margin-right:3px; }
.failed-mark { color:var(--red); font-weight:700; }
.typing { width:44px; margin:0 0 6px 15px; padding:9px 10px; display:flex; gap:3px; border-radius:5px 14px 14px; background:#f0f2f6; }
.typing span { width:5px; height:5px; border-radius:50%; background:#a4acba; animation:bounce 1.2s infinite; }
.typing span:nth-child(2){ animation-delay:.15s; }.typing span:nth-child(3){ animation-delay:.3s; }
@keyframes bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-4px)} }
.hidden { display:none !important; }

.composer { position:relative; display:flex; align-items:flex-end; gap:7px; padding:8px 12px 19px; border-top:1px solid #edf0f4; background:white; }
.composer-action { width:29px; height:29px; margin-bottom:2px; border:0; border-radius:50%; color:#828ca0; background:#f0f2f6; font-size:17px; }
.message-input-wrap { position:relative; flex:1; }
.message-input-wrap textarea {
  display:block; width:100%; max-height:82px; resize:none; border:1px solid #e5e8ef; border-radius:16px;
  padding:8px 40px 8px 11px; outline:none; color:#343e52; background:#f8f9fb; font-size:10px; line-height:1.4;
}
.message-input-wrap textarea:focus { border-color:#bcc7fc; background:white; }
.char-count { position:absolute; right:9px; bottom:8px; color:#aeb5c1; font-size:7px; }
.char-count.over { color:var(--red); }
.send-button { width:31px; height:31px; display:grid; place-items:center; border:0; border-radius:50%; color:white; background:linear-gradient(145deg,#5978ff,#405de0); box-shadow:0 4px 10px rgba(76,111,255,.25); }
.send-button:disabled { opacity:.5; cursor:not-allowed; }
.send-button svg { width:14px; height:14px; fill:none; stroke:currentColor; stroke-width:1.8; stroke-linecap:round; stroke-linejoin:round; }
.emoji-picker { position:absolute; left:9px; bottom:67px; z-index:5; width:178px; padding:8px; display:grid; grid-template-columns:repeat(6,1fr); gap:3px; border:1px solid #e4e7ed; border-radius:13px; background:white; box-shadow:0 12px 30px rgba(37,46,73,.17); }
.emoji-picker button { border:0; padding:4px 1px; border-radius:5px; background:transparent; font-size:15px; }
.emoji-picker button:hover { background:#f0f2f7; }
.home-indicator { position:absolute; bottom:6px; left:50%; transform:translateX(-50%); width:105px; height:4px; border-radius:4px; background:#12151c; }

.live-label { display:flex; align-items:center; gap:5px; color:#26a978; font-size:8px; font-weight:700; letter-spacing:1px; }
.live-label i { width:6px; height:6px; border-radius:50%; background:var(--green); box-shadow:0 0 0 3px rgba(36,196,134,.12); }
.metadata-empty { min-height:480px; display:flex; flex-direction:column; align-items:center; justify-content:center; padding:30px; text-align:center; }
.inspect-icon { width:48px; height:48px; display:grid; place-items:center; margin-bottom:14px; border-radius:15px; color:#6e79a0; background:#f2f4f8; }
.metadata-empty strong { color:#5d677b; font-size:12px; }
.metadata-empty p { margin:7px 0; color:#9ba3b3; font-size:10px; line-height:1.5; }
.metadata-content { overflow:auto; max-height:calc(100vh - 230px); padding-right:3px; scrollbar-width:thin; }
.meta-summary { padding:14px; margin-bottom:17px; border-radius:14px; color:white; background:linear-gradient(145deg,#536ffd,#7058e9); box-shadow:0 10px 22px rgba(76,111,255,.18); }
.meta-summary small { display:block; opacity:.72; font-size:8px; text-transform:uppercase; letter-spacing:1px; }
.meta-summary strong { display:block; margin-top:7px; font:700 13px "Manrope"; word-break:break-all; }
.meta-summary span { display:inline-block; margin-top:9px; padding:4px 7px; border-radius:6px; background:rgba(255,255,255,.16); font-size:8px; font-weight:700; text-transform:uppercase; }
.meta-group { margin-bottom:18px; }
.meta-group-title { margin-bottom:8px; color:#9ba3b4; font-size:8px; font-weight:700; text-transform:uppercase; letter-spacing:1px; }
.meta-item { display:flex; justify-content:space-between; gap:14px; padding:9px 0; border-bottom:1px solid #edf0f4; font-size:10px; }
.meta-item span { color:#9099ab; }
.meta-item strong { text-align:right; color:#4d586e; font-weight:600; word-break:break-all; }
.json-block { margin:0; padding:12px; overflow:auto; border-radius:10px; color:#59657d; background:#f4f6f9; font:9px/1.55 monospace; white-space:pre-wrap; word-break:break-word; }

.metadata-modal {
  position: fixed;
  z-index: 30;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.metadata-modal.hidden {
  display: none !important;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(6px);
}
.modal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 92vw);
  max-height: 85vh;
  overflow: auto;
  padding: 30px 26px;
  background: var(--panel);
  border-radius: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.25);
}
.modal-panel .panel-heading {
  margin-bottom: 22px;
}
.modal-panel .metadata-content {
  max-height: calc(85vh - 100px);
}

.toast-container { position:fixed; z-index:20; right:25px; bottom:25px; display:flex; flex-direction:column; gap:8px; }
.toast { padding:11px 15px; border:1px solid #e2e6ee; border-radius:11px; color:#536078; background:white; box-shadow:0 10px 28px rgba(35,43,67,.15); font-size:11px; animation:toast-in .25s ease; }
.toast.error { color:#a7434d; border-color:#ffd4d8; background:#fff7f8; }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } }

@media (max-width:1100px) {
  .content-grid { grid-template-columns: 1fr; }
}
@media (max-width:760px) {
  .app-shell { padding:0; }
  .workspace { min-height:100vh; border:0; border-radius:0; }
  .topbar { height:70px; padding:0 17px; }
  .content-grid { display:block; }
  .phone-stage { min-height:calc(100vh - 70px); }
  .phone-frame { width:min(344px,92vw); height:min(700px,calc(100vh - 90px)); }
}
