:root {
  --ink: #15243d;
  --ink-soft: #31425d;
  --muted: #667085;
  --paper: #f3f0e9;
  --paper-deep: #ebe6dc;
  --panel: #ffffff;
  --panel-tint: #fbfcff;
  --navy: #142744;
  --navy-soft: #203958;
  --blue: #315cc8;
  --blue-deep: #244ba9;
  --blue-pale: #eaf0ff;
  --line: #dfe5ed;
  --line-strong: #c8d2df;
  --green: #14735a;
  --green-pale: #e8f5f0;
  --amber: #9f5c12;
  --amber-pale: #fff7ea;
  --danger: #b42318;
  --shadow: 0 18px 42px rgba(21, 36, 61, 0.09);
}

* { box-sizing: border-box; }
.login-shell {max-width:480px;margin:10vh auto;padding:24px;}
.platform-form {display:grid;gap:16px;margin:20px 0;}
.platform-form label {display:grid;gap:6px;}
.platform-form input,.platform-form textarea,.platform-form select {width:100%;min-width:0;font:inherit;padding:10px;border:1px solid var(--line);border-radius:8px;}
.platform-form input[type=checkbox] {width:auto;justify-self:start;}
.platform-form button {justify-self:start;}
.platform-body {overflow-wrap:anywhere;}
.platform-body pre {white-space:pre-wrap;max-height:240px;overflow:auto;font-size:13px;}
.platform-body details {padding:12px 0;border-bottom:1px solid var(--line);}
.platform-body summary {cursor:pointer;}
.platform-result {color:var(--danger);}
.proposal {padding:16px 0;border-bottom:1px solid var(--line);}
.chat-filters {display:flex;gap:8px;flex-wrap:wrap;margin:16px 0;}
.chat-filters input,.chat-filters select {min-width:0;max-width:100%;padding:8px;font:inherit;border:1px solid var(--line);border-radius:8px;}
.topbar-actions select {max-width:220px;padding:8px;border-radius:8px;font:inherit;}
@media(max-width:650px){.topbar-inner,.topbar-actions{flex-wrap:wrap;gap:12px;}.topbar-actions select{max-width:180px;}}
.brand-form {display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px;margin-top:20px;}
.brand-form label {display:grid;gap:6px;}
.brand-form input[type=checkbox] {justify-self:start;}
.live-actions {display:flex;gap:8px;flex-wrap:wrap;padding:12px;}
.live-actions button {font-size:12px;padding:8px;}
#live-error {padding:0 12px;color:var(--danger);}
#live-messages {height:400px;overflow:auto;}
@media(max-width:650px){.brand-form{grid-template-columns:1fr;}}
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 15px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
  text-rendering: optimizeLegibility;
}
::selection { background: #cad7fb; color: var(--ink); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { border: 3px solid var(--paper); border-radius: 99px; background: #9da8b9; }
::-webkit-scrollbar-track { background: var(--paper); }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, input:focus-visible, a:focus-visible { outline: 3px solid rgba(49, 92, 200, .42); outline-offset: 3px; }

.topbar { min-height: 68px; background: var(--navy); color: #fff; }
.topbar-inner { width: min(1180px, calc(100% - 56px)); min-height: 68px; margin: auto; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: flex; align-items: baseline; gap: 12px; min-width: 0; }
.brand span { color: #b7cafc; font-size: 11px; letter-spacing: .18em; font-weight: 800; }
.brand b { font-size: 17px; letter-spacing: -.025em; white-space: nowrap; }
.topbar-actions { display: flex; align-items: center; gap: 20px; }
.preview-link { color: #fff; font-size: 13px; font-weight: 700; text-decoration: none; text-underline-offset: 4px; }
.preview-link:hover { text-decoration: underline; }
.pill { display: inline-flex; align-items: center; gap: 7px; color: #c5d1e5; font-size: 12px; }
.pill i, .answerability > span { width: 8px; height: 8px; flex: 0 0 auto; border-radius: 50%; background: #51c89c; box-shadow: 0 0 0 3px rgba(81, 200, 156, .17); }

main { width: min(1180px, calc(100% - 56px)); margin: auto; padding: 46px 0 88px; }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 42px; margin-bottom: 30px; }
.intro-copy { max-width: 675px; }
h1 { margin: 0; font-size: clamp(34px, 4.1vw, 52px); line-height: 1.04; letter-spacing: -.04em; }
.intro-copy > p { max-width: 570px; margin: 16px 0 0; color: var(--ink-soft); font-size: 16px; }
.answerability { display: flex; align-items: flex-start; gap: 12px; width: 300px; padding: 0 0 2px 18px; border-left: 1px solid #bac3d0; }
.answerability > span { margin-top: 7px; }
.answerability b { display: block; color: var(--ink); font-size: 13px; }
.answerability p { margin: 3px 0 0; color: var(--muted); font-size: 12px; line-height: 1.5; }

.workbench { display: grid; grid-template-columns: 226px minmax(0, 1fr); align-items: start; gap: 26px; }
.workflow-nav { position: sticky; top: 24px; padding: 25px 22px; border-radius: 16px; background: var(--navy); color: #fff; box-shadow: 0 18px 34px rgba(20, 39, 68, .18); }
.workflow-nav h2 { margin: 0; font-size: 13px; letter-spacing: -.01em; }
.workflow-nav nav { display: grid; gap: 6px; margin-top: 18px; }
.workflow-nav nav a { display: flex; align-items: center; gap: 11px; padding: 10px 0; color: #d7e0ef; font-size: 13px; font-weight: 700; text-decoration: none; transition: color .16s ease, transform .16s ease; }
.workflow-nav nav a:hover { color: #fff; transform: translateX(3px); }
.workflow-nav nav span { color: #8cacef; font-size: 11px; font-variant-numeric: tabular-nums; letter-spacing: .06em; }

.workflow { overflow: hidden; background: var(--panel); border-radius: 16px; box-shadow: var(--shadow); }
.step { scroll-margin-top: 24px; padding: 30px 34px 32px; border-bottom: 1px solid var(--line); }
.step:last-child { border-bottom: 0; }
.source-step { background: var(--panel-tint); }
.stephead { display: flex; align-items: flex-start; gap: 16px; }
.stephead > :first-child { min-width: 0; }
.step-actions { display: flex; flex: 0 0 auto; align-items: center; justify-content: flex-end; gap: 8px; margin-left: auto; }
.step h2 { margin: 0; color: var(--ink); font-size: 20px; line-height: 1.35; letter-spacing: -.03em; }
.step p { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

form { display: flex; gap: 10px; }
#crawl-form { margin-top: 20px; }
input { min-width: 0; flex: 1; border: 1px solid var(--line-strong); border-radius: 9px; padding: 12px 13px; background: #fff; color: var(--ink); transition: border-color .16s ease, box-shadow .16s ease; }
input:hover { border-color: #aab7c8; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(49, 92, 200, .14); outline: 0; }
button { border: 1px solid transparent; border-radius: 9px; padding: 12px 16px; background: var(--blue); color: #fff; font-weight: 750; cursor: pointer; white-space: nowrap; transition: background .16s ease, transform .16s ease, box-shadow .16s ease; }
button:hover:not(:disabled) { background: var(--blue-deep); box-shadow: 0 6px 15px rgba(49, 92, 200, .22); }
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: .65; }
button.quiet { flex: 0 0 auto; padding: 8px 11px; background: var(--blue-pale); color: var(--blue-deep); font-size: 13px; }
button.quiet:hover:not(:disabled) { background: #dce6ff; box-shadow: none; }
.result { margin-top: 12px; padding: 10px 12px; border-radius: 9px; background: #f0f4fc; color: var(--muted); font-size: 13px; }
.save-result { min-height: 0; margin-top: 10px; color: var(--green); font-size: 13px; }
.save-result:empty { display: none; }
.save-result.is-error { color: var(--danger); }

.knowledge { display: grid; gap: 10px; margin-top: 20px; }
.knowledge-node { display: grid; gap: 8px; }
.knowledge-node.is-child { position: relative; margin-left: 26px; }
.knowledge-node.is-child::before { position: absolute; top: -12px; bottom: 50%; left: -15px; width: 10px; border-bottom: 1px solid #cbd5e4; border-left: 1px solid #cbd5e4; border-radius: 0 0 0 6px; content: ""; }
.knowledge-row { display: grid; grid-template-columns: minmax(162px, .56fr) minmax(0, 1.5fr) auto auto; align-items: center; gap: 12px; min-height: 74px; padding: 11px 13px; border: 1px solid var(--line); border-radius: 11px; background: #fff; transition: border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.knowledge-row.is-group { border-color: #c7d5f0; background: #fbfcff; }
.knowledge-row:hover { border-color: #b8c6d8; box-shadow: 0 7px 18px rgba(21, 36, 61, .055); }
.knowledge-row label { min-width: 0; overflow-wrap: anywhere; font-size: 13px; font-weight: 780; }
.knowledge-row label small { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; font-weight: 500; line-height: 1.35; }
.knowledge-row input { padding: 9px 10px; font-size: 13px; }
.knowledge-row .topic-input { width: 100%; padding: 4px 0; border: 0; border-radius: 0; background: transparent; font-weight: 750; }
.knowledge-row .topic-input:focus { box-shadow: 0 2px 0 var(--blue); }
.answer-input { position: relative; display: flex; align-self: stretch; align-items: center; min-width: 0; padding-bottom: 15px; }
.answer-input input { width: 100%; }
.answer-input small { position: absolute; bottom: -7px; left: 0; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }
.row-actions { align-self: center; display: flex; align-items: center; justify-content: flex-end; gap: 8px; transform: translateY(-12px); }
.child-toggle, .add-child { padding: 6px 8px; border-color: #cbd6ec; background: #f3f6ff; color: var(--blue-deep); font-size: 12px; box-shadow: none; }
.child-toggle:hover:not(:disabled), .add-child:hover:not(:disabled) { background: #e5edff; box-shadow: none; }
.knowledge-children { display: grid; gap: 8px; padding: 2px 0 2px 15px; }
.child-empty { margin: 0 0 2px 12px; color: var(--muted); font-size: 12px; }
.status-dot { width: 11px; height: 11px; min-width: 11px; padding: 0; border: 0; border-radius: 50%; background: #d59a3f; box-shadow: 0 0 0 4px var(--amber-pale); }
.status-dot:hover:not(:disabled) { background: #b8781d; box-shadow: 0 0 0 4px #fff0d7; }
.status-dot.confirmed { background: #249472; box-shadow: 0 0 0 4px var(--green-pale); }
.status-dot.confirmed:hover:not(:disabled) { background: #14735a; box-shadow: 0 0 0 4px #d9f0e7; }
.edit-trigger { padding: 6px 9px; border-color: #d6dde7; background: #fff; color: var(--ink-soft); font-size: 12px; box-shadow: none; }
.edit-trigger:hover:not(:disabled) { background: #f3f6fa; box-shadow: none; }
.edit-trigger.is-editing { border-color: #c8d7f7; background: var(--blue-pale); color: var(--blue-deep); }
.inline-delete { padding: 6px 3px; border: 0; background: transparent; color: var(--danger); font-size: 12px; font-weight: 700; box-shadow: none; }
.inline-delete:hover:not(:disabled) { background: #fff0ef; box-shadow: none; }
.add-child-card { display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 58px; margin-left: 26px; border: 1px dashed #aebfdc; border-radius: 9px; background: #fbfcff; color: var(--blue-deep); font-size: 13px; font-weight: 700; box-shadow: none; }
.add-child-card span { display: grid; width: 21px; height: 21px; place-items: center; border-radius: 50%; background: var(--blue-pale); font-size: 18px; font-weight: 500; line-height: 1; }
.add-child-card:hover:not(:disabled) { border-color: var(--blue); background: #f1f5ff; box-shadow: none; }

.logs { margin-top: 20px; font-size: 13px; }
.logs.empty { padding: 18px 0 2px; color: var(--muted); }
.log-browser { display: grid; grid-template-columns: minmax(230px, .78fr) minmax(0, 1.45fr); min-height: 320px; border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #fff; }
.session-list { min-height: 0; height: 100%; overflow: auto; padding: 8px; background: #f7f8fa; border-right: 1px solid var(--line); }
.session-title {display:flex;align-items:center;gap:8px;}
.visitor-ip {display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-top:8px;overflow-wrap:anywhere;font-size:13px;}
.visitor-ip button {padding:6px 10px;min-height:32px;}
#live-head {display:block;}
#live-head .visitor-ip {display:flex;gap:8px;}
#live-head .visitor-ip span {font-size:13px;}
.presence-dot {display:inline-block;width:8px;height:8px;flex:0 0 8px;border-radius:50%;background:var(--green);}
.console-switch {color:#d7e0ef;font-size:13px;text-decoration:none;}
#logs .log-browser {height:660px;min-height:0;}
#logs .conversation {min-height:0;height:100%;overflow:hidden;}
#live-messages {flex:1;min-height:0;height:auto;max-height:none;align-content:start;}
#logs .conversation-head, #logs .live-actions, #live-error {flex-shrink:0;}
#live-error:empty {display:none;}
.session-item { display: grid; width: 100%; gap: 2px; padding: 11px 10px; border: 0; border-radius: 7px; background: transparent; color: var(--ink); text-align: left; box-shadow: none; }
.session-item:hover:not(:disabled) { background: #e9eef9; box-shadow: none; }
.session-item.selected { background: var(--blue-pale); color: var(--ink); }
.session-time, .session-item small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.session-item b { overflow: hidden; font-size: 13px; font-weight: 720; line-height: 1.45; text-overflow: ellipsis; white-space: nowrap; }
.conversation { display: flex; min-width: 0; flex-direction: column; }
.conversation-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 57px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.conversation-head div { display: grid; gap: 1px; }
.conversation-head b { font-size: 14px; }
.conversation-head span, .conversation-head small { color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.conversation-messages { display: grid; gap: 16px; max-height: 430px; overflow: auto; padding: 17px; background: #fcfdff; }
.transcript-turn { display: grid; gap: 8px; }
.transcript { max-width: 88%; padding: 10px 12px; border-radius: 8px; }
.transcript span { display: block; margin-bottom: 3px; font-size: 11px; font-weight: 750; }
.transcript p { margin: 0; white-space: pre-wrap; }
.transcript.guest { justify-self: end; background: var(--blue); color: #fff; }
.transcript.guest span,
.transcript.guest p { color: #fff; }
.transcript.assistant { background: #eef2f8; color: var(--ink); }
.transcript.assistant span { color: var(--blue-deep); }
.transcript.assistant small { display: block; margin-top: 6px; color: var(--muted); font-size: 10px; font-variant-numeric: tabular-nums; }

@media (max-width: 880px) {
  .topbar-inner, main { width: min(100% - 40px, 1180px); }
  .intro { align-items: start; flex-direction: column; gap: 22px; }
  .answerability { width: auto; max-width: 500px; }
  .workbench { grid-template-columns: 1fr; }
  .workflow-nav { position: static; }
  .workflow-nav nav { grid-template-columns: repeat(3, 1fr); gap: 14px; }
}

@media (max-width: 600px) {
  .topbar, .topbar-inner { min-height: 62px; }
  .topbar-inner, main { width: min(100% - 32px, 1180px); }
  .brand { gap: 8px; }
  .brand span { font-size: 10px; }
  .brand b { font-size: 14px; }
  .topbar-actions { gap: 0; }
  .pill { display: none; }
  .preview-link { font-size: 12px; }
  main { padding: 35px 0 62px; }
  h1 { font-size: 36px; }
  .intro-copy > p { margin-top: 12px; font-size: 15px; }
  .answerability { padding-left: 14px; }
  .workflow-nav { padding: 22px 20px; }
  .workflow-nav nav { grid-template-columns: 1fr; gap: 0; margin-top: 14px; }
  .workflow-nav nav a { padding: 7px 0; }
  .step { padding: 26px 20px 28px; }
  #crawl-form { flex-direction: column; }
  #crawl-form button { width: 100%; }
  .knowledge-row { grid-template-columns: 1fr; gap: 8px; padding: 12px; }
  .knowledge-row .status-dot { justify-self: start; }
  .row-actions { justify-content: flex-start; flex-wrap: wrap; }
  .row-actions { transform: none; }
  .add-child-card { margin-left: 0; }
  .step-actions { gap: 6px; }
  .step-actions .quiet { padding: 7px 9px; }
  .log-browser { grid-template-columns: 1fr; }
  .session-list { max-height: 190px; border-right: 0; border-bottom: 1px solid var(--line); }
  #logs .log-browser {height:auto;grid-template-rows:190px 600px;}
  .conversation-messages { max-height: 390px; }
}

@media (prefers-reduced-motion: no-preference) {
  .workflow { animation: workspace-enter .45s cubic-bezier(.2,.8,.2,1) both; }
  @keyframes workspace-enter { from { opacity: .01; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
}
