:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #0f172a;
  background: #f8fafc;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #3b82f6;
  --accent: #059669;
  --accent-hover: #047857;
  --background: #f8fafc;
  --surface: #fff;
  --foreground: #0f172a;
  --muted: #f1f5fd;
  --muted-foreground: #475569;
  --border: #d9e3f4;
  --danger: #dc2626;
  --success: #047857;
  --focus: #2563eb;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 84px; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--background); }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .48; }
a { color: var(--primary); text-underline-offset: 3px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.shell { min-height: 100vh; }
.topbar {
  min-height: 68px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 0 max(24px, calc((100vw - 1240px) / 2));
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 5;
}
.brand { display: flex; gap: 12px; align-items: center; flex: none; font-weight: 700; letter-spacing: -.04em; font-size: 18px; }
.brand-mark { width: 32px; height: 32px; background: var(--primary); display: grid; place-items: center; color: #fff; font-size: 15px; font-weight: 700; }
.brand small { font-size: 12px; display: block; color: var(--muted-foreground); letter-spacing: 0; font-weight: 400; margin-top: 1px; }
.nav { display: flex; align-items: center; gap: 4px; }
.nav button, .quiet { min-height: 44px; background: transparent; border: 0; padding: 10px 14px; color: var(--muted-foreground); border-radius: 4px; white-space: nowrap; }
.nav button.active { background: #eff6ff; color: var(--primary); font-weight: 650; }
.nav button:hover, .quiet:hover { background: var(--muted); color: var(--foreground); }
.badge { font-size: 11px; padding: 4px 7px; border: 1px solid var(--border); color: var(--muted-foreground); vertical-align: middle; margin-left: 7px; }

.container { max-width: 1240px; margin: 0 auto; padding: 36px 24px 60px; }
.heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.eyebrow { text-transform: uppercase; font-size: 11px; letter-spacing: .1em; color: var(--muted-foreground); margin-bottom: 10px; }
.heading h1 { font-size: clamp(28px, 3vw, 34px); line-height: 1.12; letter-spacing: -.045em; margin: 0; font-weight: 700; color: var(--foreground); }
.heading p { color: var(--muted-foreground); font-size: 14px; line-height: 1.55; margin: 9px 0 0; max-width: 68ch; }
.btn { min-height: 44px; border: 1px solid var(--primary); background: var(--primary); color: #fff; padding: 10px 16px; border-radius: 4px; font-size: 14px; font-weight: 650; transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
.btn:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.cta { background: var(--accent); border-color: var(--accent); color: #04130e; }
.btn.cta:hover { background: #34d399; border-color: #34d399; }
.btn.outline { background: var(--surface); color: var(--foreground); border-color: var(--border); }
.btn.outline:hover { background: var(--muted); border-color: #b7c7df; }
.btn.small { min-height: 44px; padding: 8px 12px; font-size: 13px; }

.grid { display: grid; grid-template-columns: 1.2fr .8fr; gap: 20px; }
.card, .side-card, .editor-card, .preview-card { background: var(--surface); border: 1px solid var(--border); }
.card { padding: 24px; }
.card h2 { font-size: 17px; letter-spacing: -.02em; margin: 0 0 18px; }
.card h3 { font-size: 15px; margin: 0 0 8px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); border: 1px solid var(--border); background: var(--surface); margin-bottom: 20px; }
.stat { padding: 20px 22px; border-right: 1px solid var(--border); }
.stat:last-child { border: 0; }
.stat b { font-size: 28px; letter-spacing: -.04em; display: block; color: var(--foreground); font-variant-numeric: tabular-nums; }
.stat span { color: var(--muted-foreground); font-size: 13px; line-height: 1.45; display: block; margin-top: 3px; }
.project-row { border-top: 1px solid var(--border); padding: 18px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.project-row:first-of-type { border: 0; }
.project-title { font-size: 15px; font-weight: 650; }
.project-meta { color: var(--muted-foreground); font-size: 13px; margin-top: 4px; }
.status { display: inline-flex; align-items: center; min-height: 28px; font-size: 12px; font-weight: 600; color: var(--success); background: #ecfdf5; padding: 4px 9px; }
.status.off { color: #475569; background: var(--muted); }
.notice { font-size: 13px; line-height: 1.6; color: var(--muted-foreground); background: #eff6ff; border-left: 3px solid var(--primary); padding: 14px 16px; margin-top: 18px; }

.table-wrap { overflow: auto; }
table { border-collapse: collapse; width: 100%; font-size: 13px; white-space: nowrap; }
th { text-align: left; text-transform: uppercase; letter-spacing: .06em; font-size: 11px; color: var(--muted-foreground); font-weight: 650; padding: 13px 12px; border-bottom: 1px solid var(--border); }
td { padding: 14px 12px; border-bottom: 1px solid #edf1f7; color: var(--foreground); }
tr:last-child td { border-bottom: 0; }
.filters { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
select, input, textarea { min-height: 44px; border: 1px solid #cbd5e1; border-radius: 4px; padding: 10px 12px; background: var(--surface); color: var(--foreground); font-size: 14px; }
select:focus, input:focus, textarea:focus { border-color: var(--primary); }
.filters select { min-width: 190px; }
.layout { display: grid; grid-template-columns: 248px minmax(330px, 1fr) minmax(300px, .85fr); gap: 16px; align-items: start; }
.side-card { padding: 16px; }
.editor-card, .preview-card { padding: 20px; }
.side-title { font-size: 13px; font-weight: 650; display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 2px 0 14px; }
.side-title .quiet { min-height: 44px; padding: 6px 9px; font-size: 12px; }
.step-list { position: relative; }
.step-list:before { content: ""; position: absolute; left: 10px; top: 12px; bottom: 16px; width: 1px; background: #cbd5e1; }
.step-item { position: relative; width: 100%; min-height: 48px; display: flex; gap: 10px; align-items: flex-start; border: 0; text-align: left; background: transparent; padding: 9px 4px; color: var(--foreground); }
.step-item:hover, .step-item.selected { color: var(--primary); }
.step-dot { height: 18px; width: 18px; flex: none; border: 1px solid #94a3b8; border-radius: 50%; background: var(--surface); z-index: 1; margin-top: 2px; }
.step-item.selected .step-dot { background: var(--primary); border-color: var(--primary); box-shadow: inset 0 0 0 4px white; }
.step-copy { font-size: 13px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.step-copy small { display: block; color: var(--muted-foreground); font-size: 11px; font-weight: 400; margin-top: 3px; }
.field { display: grid; gap: 7px; margin-bottom: 16px; }
.field label, .field > span { font-size: 13px; font-weight: 650; color: var(--foreground); }
.field input, .field select, .field textarea { width: 100%; }
.field textarea { min-height: 100px; resize: vertical; line-height: 1.55; }
.field small { font-size: 12px; line-height: 1.5; color: var(--muted-foreground); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.answer-editor { border-top: 1px solid var(--border); padding: 16px 0 4px; }
.answer-line { display: grid; grid-template-columns: 1fr 1fr 44px; gap: 8px; margin: 8px 0; }
.answer-line input, .answer-line select { width: 100%; min-width: 0; }
.remove { min-width: 44px; min-height: 44px; border: 1px solid transparent; background: transparent; color: var(--danger); font-size: 20px; }
.remove:hover { background: #fef2f2; border-color: #fecaca; }
.editor-actions { border-top: 1px solid var(--border); padding-top: 16px; display: flex; justify-content: space-between; align-items: center; gap: 8px; }
#deleteNode:not(:disabled) { color: var(--danger); border-color: #fecaca; }

.phone { background: #f1f5fd; border: 1px solid var(--border); height: 560px; display: flex; flex-direction: column; overflow: hidden; }
.phone-head { min-height: 60px; padding: 12px 14px; background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.avatar { height: 36px; width: 36px; flex: none; overflow: hidden; border-radius: 50%; background: var(--primary); color: #fff; display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.avatar img { display: block; width: 100%; height: 100%; object-fit: contain; }
.logo-upload-row { display: flex; align-items: center; gap: 14px; }
.logo-preview { width: 56px; height: 56px; font-size: 14px; }
.logo-upload-controls { display: flex; flex: 1; min-width: 0; flex-direction: column; align-items: flex-start; gap: 8px; }
.logo-upload-controls input[type="file"] { width: 100%; min-height: auto; padding: 8px; font-size: 12px; }
.logo-upload-controls small { color: var(--muted-foreground); font-size: 12px; line-height: 1.45; }
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; }
.backup-hint { display: block; margin-top: 8px; color: var(--muted-foreground); font-size: 12px; line-height: 1.5; }
.phone-head b { font-size: 13px; display: block; }
.phone-head small { font-size: 12px; color: var(--success); }
.messages { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; scroll-behavior: smooth; }
.bubble { max-width: 88%; padding: 11px 13px; background: var(--surface); border: 1px solid var(--border); font-size: 14px; line-height: 1.55; align-self: flex-start; white-space: pre-wrap; overflow-wrap: anywhere; animation: appear .18s ease-out; }
.bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-color: var(--primary); }
.bubble time { display: block; font-size: 11px; text-align: right; color: #64748b; margin-top: 5px; }
.bubble.user time { color: #dbeafe; }
.typing-dots { color: var(--muted-foreground); letter-spacing: 3px; animation: pulse .8s ease-in-out infinite alternate; }
.reply-area { padding: 12px; background: var(--surface); border-top: 1px solid var(--border); display: flex; gap: 8px; flex-wrap: wrap; }
.reply { min-height: 44px; max-width: 100%; background: var(--surface); border: 1px solid #94a3b8; color: var(--foreground); padding: 9px 12px; border-radius: 4px; font-size: 13px; line-height: 1.4; text-align: left; overflow-wrap: anywhere; transition: background-color .16s ease, border-color .16s ease, color .16s ease; }
.reply:hover { border-color: var(--primary); color: var(--primary); background: #eff6ff; }
.chat-input { display: flex; gap: 8px; width: 100%; }
.chat-input input { flex: 1; min-width: 0; }
.chat-disclaimer { padding: 10px 12px; text-align: center; font-size: 11px; color: var(--muted-foreground); background: var(--surface); }
.empty { color: var(--muted-foreground); font-size: 14px; padding: 30px; text-align: center; }
.modal-backdrop { position: fixed; inset: 0; background: rgb(15 23 42 / 55%); z-index: 10; display: grid; place-items: center; padding: 18px; overflow-y: auto; }
.modal { background: var(--surface); border: 1px solid var(--border); width: min(480px, 100%); max-height: min(90dvh, 760px); overflow-y: auto; padding: 24px; }
.modal h2 { font-size: 21px; letter-spacing: -.025em; margin: 0 0 18px; }
.toast { position: fixed; bottom: 20px; right: 20px; max-width: min(420px, calc(100vw - 32px)); background: var(--foreground); color: #fff; padding: 13px 16px; font-size: 13px; z-index: 20; animation: appear .18s ease-out; }
.public-wrap { min-height: 100vh; min-height: 100dvh; background: #ece7df; display: grid; place-items: center; padding: 24px; }
.public-frame { width: min(460px, 100%); height: min(850px, calc(100dvh - 48px)); min-height: 550px; background: #fffdf9; display: flex; flex-direction: column; border: 1px solid #d9d1c6; }
.public-head { min-height: 68px; padding: 12px 16px; border-bottom: 1px solid #e5ddd3; background: #fffdf9; display: flex; align-items: center; gap: 12px; }
.public-head .avatar { background: var(--primary); }
.public-head b { font-size: 14px; }
.public-head small { display: block; color: var(--success); font-size: 12px; margin-top: 3px; }
.public-tools { margin-left: auto; }
.public-frame .messages {
  padding: 18px 14px;
  gap: 8px;
  background-color: #efe9df;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='176' height='176' viewBox='0 0 176 176' fill='none'%3E%3Cg stroke='%23c8bdad' stroke-width='1.25' stroke-linecap='round' stroke-linejoin='round' opacity='.44'%3E%3Cpath d='M20 25c-7-8-17 2-7 11l7 6 7-6c10-9 0-19-7-11Z'/%3E%3Ccircle cx='93' cy='26' r='8'/%3E%3Cpath d='M93 11v5m0 20v5M78 26h5m20 0h5m-21-10 3 4m10 12 3 4m0-20-3 4m-10 12-3 4'/%3E%3Cpath d='M127 61h24a7 7 0 0 1 7 7v11a7 7 0 0 1-7 7h-10l-8 6v-6h-6a7 7 0 0 1-7-7V68a7 7 0 0 1 7-7Z'/%3E%3Cpath d='m33 87 3 7 7 3-7 3-3 7-3-7-7-3 7-3 3-7Z'/%3E%3Cpath d='M94 104c-9-8-19 3-8 12l8 7 8-7c11-9 1-20-8-12Z'/%3E%3Cpath d='M28 139c4-10 14-13 21-9-2 9-9 14-21 9Zm0 0c4 4 7 9 8 16m0-9 9-8'/%3E%3Crect x='119' y='126' width='28' height='24' rx='4'/%3E%3Cpath d='M125 126v-5a8 8 0 0 1 16 0v5m-10 10h4m-2-2v7'/%3E%3C/g%3E%3C/svg%3E");
  background-size: 176px 176px;
}
.public-frame .bubble {
  position: relative;
  max-width: 86%;
  padding: 9px 11px 6px;
  border-radius: 13px 13px 13px 4px;
  border-color: #e2ddd5;
  background: #fff;
  color: #20231f;
  font-size: 14px;
  line-height: 1.42;
}
.public-frame .bubble::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: -5px;
  width: 8px;
  height: 10px;
  background: #fff;
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
}
.public-frame .bubble.user {
  border-radius: 13px 13px 4px 13px;
  border-color: #c5e7bc;
  background: #d9fdd3;
  color: #1d2b18;
}
.public-frame .bubble.user::before {
  left: auto;
  right: -5px;
  background: #d9fdd3;
  clip-path: polygon(0 0, 0 100%, 100% 100%);
}
.public-frame .bubble time { margin-top: 3px; color: #5f6f59; font-size: 10px; }
.public-frame .bubble.user time { color: #526c4d; }
.public-frame .reply-area { padding: 10px 14px; gap: 8px; background: #fffdf9; border-top-color: #e5ddd3; }
.public-frame .reply { border-radius: 12px; border-color: #b9d7b1; background: #f7fff4; color: #294522; }
.public-frame .reply:hover { border-color: #66a55c; background: #edfae9; color: #183a13; }
.legal { font-size: 12px; color: var(--muted-foreground); line-height: 1.5; padding: 10px 14px; background: #fffdf9; border-top: 1px solid #e5ddd3; }
.legal a { color: var(--primary); }
.consent { font-size: 12px; line-height: 1.5; display: flex; gap: 9px; align-items: flex-start; margin: 8px 0 14px; color: var(--muted-foreground); }
.consent input { min-height: 20px; width: 20px; flex: none; margin: 1px 0 0; accent-color: var(--primary); }
.preview-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.preview-top h3 { font-size: 15px; margin: 0; }
.muted { color: var(--muted-foreground); }
.hidden { display: none !important; }
@keyframes appear { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }
@keyframes pulse { from { opacity: .4; } to { opacity: 1; } }

@media (max-width: 1024px) {
  .layout { grid-template-columns: 220px minmax(0, 1fr); }
  .preview-card { grid-column: 2; }
  .grid { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .container { padding: 28px 20px 48px; }
  .layout { grid-template-columns: 1fr; }
  .preview-card { grid-column: auto; }
  .side-card { max-height: 260px; overflow: auto; }
  .stats { grid-template-columns: 1fr; }
  .stat { border-right: 0; border-bottom: 1px solid var(--border); padding: 15px 18px; }
  .stat:last-child { border-bottom: 0; }
}
@media (max-width: 600px) {
  .topbar { min-height: 0; align-items: stretch; flex-direction: column; gap: 8px; padding: 10px 14px 8px; }
  .brand { font-size: 16px; }
  .brand-mark { width: 30px; height: 30px; }
  .nav { width: 100%; overflow-x: auto; scrollbar-width: thin; gap: 2px; }
  .nav button { flex: 0 0 auto; min-height: 44px; padding: 8px 11px; font-size: 13px; }
  .container { padding: 24px 14px 40px; }
  .heading { align-items: stretch; gap: 14px; flex-direction: column; margin-bottom: 22px; }
  .heading h1 { font-size: 28px; }
  .heading p { font-size: 14px; }
  .heading > div:last-child { display: flex; flex-wrap: wrap; gap: 8px; }
  .card { padding: 18px; }
  .project-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .project-row > div:last-child { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
  .filters, .filters select { width: 100%; }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .answer-line { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 44px; gap: 6px; }
  .editor-card, .preview-card { padding: 16px; }
  .phone { height: min(620px, 72dvh); min-height: 480px; }
  .public-wrap { padding: 0; }
  .public-frame { width: 100%; height: 100dvh; min-height: 0; border: 0; }
  .public-frame .messages { padding: 14px; }
  .reply-area { gap: 8px; }
  .reply { width: 100%; }
  .editor-actions { align-items: stretch; flex-direction: column-reverse; }
  .editor-actions .btn { width: 100%; }
  .modal { padding: 20px; }
}
@media (max-width: 380px) {
  .answer-line { grid-template-columns: 1fr 44px; }
  .answer-line select { grid-column: 1; }
  .answer-line .remove { grid-column: 2; grid-row: 1 / span 2; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}




.project-actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px}.project-row>div:first-child{min-width:0}.bubble a{color:var(--primary);font-weight:600;text-decoration:underline;text-underline-offset:2px;overflow-wrap:anywhere}.bubble.user a{color:#fff}
.bubble a{color:#1d4ed8}.bubble.user a{color:#fff}
.answer-head{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr) 44px;gap:8px;padding:4px 0;color:var(--muted-foreground);font-size:11px;font-weight:650}.answer-actions{display:flex;flex-wrap:wrap;gap:8px;margin-top:12px}.registered-answer{display:flex;align-items:center;justify-content:space-between;gap:12px;padding:12px 0;border-top:1px solid var(--border)}.registered-answer>span{min-width:0}.registered-answer b{display:block;font-size:14px;overflow-wrap:anywhere}.registered-answer small{display:block;margin-top:4px;color:var(--muted-foreground);font-size:12px;line-height:1.4}.registered-answer .btn{flex:none}.registered-answer{cursor:pointer}.registered-answer input[type=checkbox]{min-height:20px;width:20px;flex:none;margin:0;padding:0;accent-color:var(--primary)}.registered-answer input[type=checkbox]:checked+span b{color:var(--primary)}
@media(max-width:380px){.answer-head{grid-template-columns:1fr 44px}.answer-head span:nth-child(2){grid-column:1}.answer-head span:first-child{grid-column:1}.answer-head span:last-child{grid-column:2;grid-row:1 / span 2}}
.auth-wrap{min-height:100vh;display:grid;place-items:center;padding:24px;background:radial-gradient(ellipse at 20% 15%,#eaf1ff 0,transparent 42%),var(--background)}.auth-card{width:min(100%,440px);padding:34px;background:var(--surface);border:1px solid var(--border);border-radius:12px;box-shadow:0 18px 50px #162b4512}.auth-brand{display:flex;align-items:center;gap:12px;font-size:18px;font-weight:700;letter-spacing:-.04em}.auth-brand small{display:block;margin-top:2px;color:var(--muted-foreground);font-size:12px;font-weight:400;letter-spacing:0}.auth-copy{margin:32px 0 24px}.auth-copy h1{margin:8px 0;font-size:28px;letter-spacing:-.04em}.auth-copy p,.auth-foot{color:var(--muted-foreground);font-size:14px;line-height:1.6}.auth-card .field{display:grid;gap:7px;margin:16px 0}.auth-card .field span{font-size:13px;font-weight:650}.auth-card input{width:100%;min-height:46px;padding:10px 12px;border:1px solid var(--border);border-radius:6px;background:var(--surface);color:var(--foreground);font:inherit}.auth-card input:focus{outline:3px solid #2563eb33;border-color:var(--primary)}.auth-submit{width:100%;margin:8px 0 16px}.auth-error{min-height:20px;margin:8px 0;color:#b42318;font-size:13px}.auth-foot{display:block;text-align:center;font-size:12px}.auth-logout{margin-left:auto}@media(max-width:600px){.auth-card{padding:25px 20px}.auth-logout{position:absolute;right:14px;top:10px}.topbar{position:relative;padding-right:62px}}

