:root {
  --bg: #0f1318;
  --panel: rgba(23, 29, 36, 0.96);
  --panel-line: rgba(255, 255, 255, 0.08);
  --text: #e8edf2;
  --text-dim: #93a1ad;
  --accent: #ffb703;
  --accent-soft: rgba(255, 183, 3, 0.14);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: "Noto Sans", "Noto Sans Devanagari", Arial, sans-serif; }

#app { display: grid; grid-template-columns: 1fr 400px; height: 100%; }
#canvas-side { position: relative; }
#canvas { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #0f1318; }
#canvas-note { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); background: var(--panel); border: 1px solid var(--panel-line); border-radius: 10px; padding: 8px 14px; font-size: 12.5px; color: var(--text-dim); }

#chat-side { display: flex; flex-direction: column; border-left: 1px solid var(--panel-line); background: #12171d; min-height: 0; }
#chat-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--panel-line); }
#brand { display: flex; align-items: center; gap: 8px; font-size: 15px; }
#live-dot { margin-left: 6px; font: 600 10px ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); background: var(--accent-soft); border: 1px solid rgba(255,183,3,.35); padding: 3px 8px; border-radius: 999px; }
#chat-sub { margin-left: auto; font-size: 11.5px; color: var(--text-dim); }

#artifact { position: relative; margin: 10px 12px 0; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 12px; overflow: hidden; max-height: 52%; display: flex; flex-direction: column; }
#artifact-close { position: absolute; top: 6px; right: 8px; z-index: 2; width: 26px; height: 26px; border-radius: 8px; border: none; background: rgba(255,255,255,.06); color: var(--text-dim); font-size: 15px; cursor: pointer; }
#artifact-close:hover { color: var(--text); }
#artifact-body { overflow-y: auto; padding: 16px 14px 12px; }

#log { flex: 1; overflow-y: auto; padding: 12px 12px 8px; display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.msg { max-width: 92%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; line-height: 1.5; }
.msg.user { align-self: flex-end; background: #2b3a46; color: #eaf2f7; border-bottom-right-radius: 4px; }
.msg.bot { align-self: flex-start; background: var(--panel); border: 1px solid var(--panel-line); border-bottom-left-radius: 4px; }
.msg.err { align-self: flex-start; background: rgba(209,73,91,.14); border: 1px solid rgba(209,73,91,.4); color: #f2b8c0; font-size: 12.5px; }
.msg.think { align-self: flex-start; color: var(--text-dim); font-size: 12.5px; padding: 4px 8px; }

.variants { display: flex; flex-direction: column; gap: 6px; align-self: flex-start; width: 94%; }
.vcard { display: flex; align-items: center; gap: 10px; text-align: left; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 10px; padding: 9px 12px; color: var(--text); font: 600 13px inherit; cursor: pointer; }
.vcard:hover { border-color: rgba(255,183,3,.45); background: var(--accent-soft); }
.vcard.applied { opacity: .55; border-color: rgba(255,183,3,.5); pointer-events: none; }
.vcard .num { flex: none; width: 20px; height: 20px; border-radius: 50%; background: rgba(255,255,255,.07); color: var(--text-dim); font: 600 10.5px ui-monospace, monospace; display: flex; align-items: center; justify-content: center; }
.vcard.applied .num { background: var(--accent); color: #191104; }
.vcard .acts { margin-left: auto; font: 500 10.5px ui-monospace, monospace; color: var(--text-dim); }

#suggest { display: flex; gap: 6px; flex-wrap: wrap; padding: 6px 12px; }
.chip { background: transparent; border: 1px solid var(--panel-line); border-radius: 999px; padding: 6px 11px; color: var(--text-dim); font: 600 12px inherit; cursor: pointer; }
.chip:hover { color: var(--text); border-color: rgba(255,255,255,.25); }

#composer { display: flex; gap: 8px; padding: 10px 12px 12px; border-top: 1px solid var(--panel-line); }
#chat-input { flex: 1; background: var(--panel); border: 1px solid var(--panel-line); border-radius: 10px; color: var(--text); font: 500 14px inherit; padding: 11px 13px; outline: none; }
#chat-input:focus { border-color: rgba(255,183,3,.5); }
#send { flex: none; width: 42px; border-radius: 10px; border: 1px solid rgba(255,183,3,.45); background: var(--accent); color: #191104; cursor: pointer; display: flex; align-items: center; justify-content: center; }
#send:disabled { opacity: .45; cursor: default; }

.flowstep { display: flex; gap: 10px; padding: 9px 10px; border-radius: 10px; margin: 0 0 6px; background: rgba(255,255,255,.03); border-left: 3px solid var(--accent); opacity: .45; transition: opacity .5s; }
.flowstep.on { opacity: 1; background: var(--accent-soft); }
.flowstep .n { flex: none; width: 20px; height: 20px; border-radius: 50%; background: var(--accent); color: #191104; font: 700 11px/20px inherit; text-align: center; }
.flowstep small { display: block; color: var(--text-dim); font-size: 12.5px; }
.flowstep b { font-size: 13.5px; }
#flow-title { font: 700 15px inherit; margin: 0 0 10px; }

.qcard { background: rgba(255,255,255,.03); border: 1px solid var(--panel-line); border-radius: 12px; padding: 12px; margin: 0 0 10px; }
.qcard .q { font: 600 13.5px inherit; margin: 0 0 9px; }
.qopt { display: block; width: 100%; text-align: left; background: transparent; border: 1px solid var(--panel-line); border-radius: 9px; padding: 8px 11px; margin: 0 0 6px; color: var(--text); font: 500 13px inherit; cursor: pointer; }
.qopt:hover { border-color: rgba(255,255,255,.25); }
.qopt.right { border-color: #7fb56a; background: rgba(127,181,106,.16); }
.qopt.wrong { border-color: #d1495b; background: rgba(209,73,91,.14); }
.qopt:disabled { cursor: default; opacity: .8; }
#quiz-score { font: 600 13px inherit; color: var(--accent); padding: 4px 2px 0; }

@media (max-width: 900px) {
  #app { grid-template-columns: 1fr; grid-template-rows: 1fr 46%; }
  #chat-side { border-left: none; border-top: 1px solid var(--panel-line); }
  #artifact { max-height: 44%; }
}
