:root {
  --ink: #18130d;
  --muted: #6f6253;
  --paper: #f7f1e8;
  --panel: #fffaf2;
  --line: #e6dbc9;
  --teal: #0f766e;
  --teal-dark: #0d5f59;
  --gold: #d89a2b;
  --shadow: 0 24px 90px rgba(24, 19, 13, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(216, 154, 43, 0.18), transparent 28rem),
    radial-gradient(circle at top right, rgba(15, 118, 110, 0.16), transparent 32rem),
    var(--paper);
  color: var(--ink);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

.topbar {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.brand, .top-link {
  color: var(--ink);
  text-decoration: none;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--ink);
  box-shadow: 0 10px 30px rgba(24, 19, 13, 0.18);
}

.top-link {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 56px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(360px, 0.7fr);
  gap: 28px;
  align-items: end;
  padding: 38px 0 28px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1, h2 { letter-spacing: -0.05em; }

h1 {
  max-width: 760px;
  margin: 0;
  font-size: clamp(42px, 7vw, 86px);
  line-height: 0.92;
}

.lead {
  max-width: 720px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 21px);
  line-height: 1.45;
}

.url-card, .operator-panel {
  border: 1px solid rgba(230, 219, 201, 0.9);
  background: rgba(255, 250, 242, 0.86);
  backdrop-filter: blur(16px);
  border-radius: 28px;
  padding: 22px;
  box-shadow: var(--shadow);
}

label {
  display: block;
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 800;
}

.url-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: white;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 52px;
  padding: 0 16px;
}

textarea {
  min-height: 180px;
  padding: 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  resize: vertical;
}

input:focus, textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.14);
}

button {
  border: 0;
  border-radius: 16px;
  background: var(--teal);
  color: white;
  font-weight: 800;
  padding: 0 18px;
  min-height: 46px;
}

button:hover { background: var(--teal-dark); }

.hint {
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.preview-shell {
  overflow: hidden;
  min-height: 720px;
  border: 1px solid var(--line);
  border-radius: 32px;
  background: #1f1b17;
  box-shadow: var(--shadow);
}

.browser-bar {
  min-height: 58px;
  padding: 12px 14px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  color: #efe6d8;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.dots {
  display: flex;
  gap: 7px;
}

.dots span {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  display: block;
  background: #ff5f57;
}
.dots span:nth-child(2) { background: #febc2e; }
.dots span:nth-child(3) { background: #28c840; }

.address {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.82);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 13px;
}

.actions {
  display: flex;
  gap: 8px;
}

.ghost, .secondary {
  min-height: 38px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.08);
  color: #f8f2e8;
  font-size: 13px;
  padding: 0 13px;
}
.ghost:hover { background: rgba(255,255,255,0.16); }
.secondary { color: var(--ink); border-color: var(--line); background: #fff; }
.secondary:hover { background: #f3eadc; }

.preview-stage {
  position: relative;
  height: min(74vh, 860px);
  min-height: 620px;
  background: #f7f1e8;
}

#site-frame {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  padding: 32px;
  text-align: center;
}

.empty-state .spark {
  width: 68px;
  height: 68px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--ink);
  color: var(--gold);
  font-size: 32px;
}

.empty-state h2 {
  margin: 0;
  font-size: 36px;
}

.empty-state p {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.bot-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 3;
}

.demo-bot {
  pointer-events: auto;
  position: absolute;
  right: 24px;
  bottom: 24px;
}

.custom-bot-host {
  position: fixed;
  inset: auto 0 0 auto;
  z-index: 2147483000;
}

#chat_app {
  z-index: 2147483000 !important;
}

.demo-bot-bubble {
  width: 68px;
  height: 68px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: var(--teal);
  color: white;
  box-shadow: 0 18px 40px rgba(15, 118, 110, 0.36);
  font-size: 18px;
}

.demo-bot-window {
  display: none;
  width: min(380px, calc(100vw - 72px));
  overflow: hidden;
  border-radius: 26px;
  background: #fffaf2;
  border: 1px solid var(--line);
  box-shadow: 0 24px 80px rgba(24, 19, 13, 0.28);
}

.demo-bot[data-open="true"] .demo-bot-bubble { display: none; }
.demo-bot[data-open="true"] .demo-bot-window { display: block; }

.demo-bot-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 16px;
  background: var(--ink);
  color: white;
}

.demo-bot-head small {
  display: block;
  margin-top: 4px;
  color: rgba(255,255,255,0.72);
  font-size: 12px;
  line-height: 1.35;
}

.demo-bot-close {
  min-height: 0;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  padding: 0;
  background: rgba(255,255,255,0.12);
  font-size: 24px;
}

.demo-bot-body {
  padding: 16px;
  display: grid;
  gap: 10px;
}

.bot-msg {
  margin: 0 0 4px;
  padding: 12px 14px;
  border-radius: 16px 16px 16px 4px;
  background: #efe6d8;
  color: var(--ink);
  line-height: 1.45;
}

.quick {
  min-height: 42px;
  border-radius: 14px;
  background: white;
  border: 1px solid var(--line);
  color: var(--ink);
  text-align: left;
  font-weight: 700;
}
.quick:hover { background: #f3eadc; }

.operator-panel {
  margin: 28px 0 0;
  display: grid;
  gap: 14px;
}

.operator-panel[hidden] { display: none; }

.operator-panel h2 {
  margin: 0;
  font-size: 30px;
}
.operator-panel p { margin: 0; color: var(--muted); line-height: 1.5; }
.admin-form { display: grid; gap: 14px; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.admin-form label { margin: 0; }
.admin-form input { margin-top: 8px; }
.panel-actions { display: flex; gap: 10px; flex-wrap: wrap; }
.admin-status { min-height: 20px; font-weight: 800; }
.admin-status[data-type="success"] { color: var(--teal); }
.admin-status[data-type="error"] { color: #b42318; }
.page-list {
  border-top: 1px solid var(--line);
  padding-top: 14px;
}
.page-list h3 { margin: 0 0 10px; }
.page-list ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.page-list li {
  display: grid;
  grid-template-columns: minmax(120px, 0.35fr) minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid rgba(230, 219, 201, 0.7);
  color: var(--muted);
  font-size: 14px;
}
.page-list a { color: var(--teal); font-weight: 800; text-decoration: none; }
code { background: #f0e5d4; border-radius: 6px; padding: 2px 5px; }

body.customer-page .hero { display: none; }
body.customer-page main { margin-bottom: 18px; }
body.customer-page .preview-shell { min-height: calc(100vh - 102px); }
body.customer-page .preview-stage {
  height: calc(100vh - 162px);
  min-height: 620px;
}
body.customer-page .top-link { display: none; }

@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 22px; }
  .url-card { padding: 18px; }
  .url-row { grid-template-columns: 1fr; }
  .browser-bar { grid-template-columns: auto minmax(0, 1fr); }
  .actions { grid-column: 1 / -1; }
  .preview-stage { height: 70vh; min-height: 560px; }
  .top-link { display: none; }
}

@media (max-width: 540px) {
  main, .topbar { width: min(100% - 20px, 1180px); }
  h1 { font-size: 42px; }
  .preview-shell { border-radius: 22px; }
  .demo-bot { right: 12px; bottom: 12px; }
  .form-grid { grid-template-columns: 1fr; }
  .page-list li { grid-template-columns: 1fr; }
  body.customer-page .preview-stage { min-height: 560px; }
}
