:root {
  --bg: #17131a; --card: rgba(34, 28, 38, .86); --ink: #f1eaf3; --muted: #a99db0; --line: #3f3445;
  --accent: #f08cb6; --accent-ink: #2a1320; --bad: #ef7d72;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 system-ui, "Segoe UI", Arial, sans-serif; }
h1 { margin: 0 0 12px; font-size: 24px; text-align: center; }
h2 { margin: 18px 0 6px; font-size: 15px; color: var(--accent); }
p { margin: 6px 0; }
.muted { color: var(--muted); font-size: 13px; }
.logo { display: block; width: 72px; height: 72px; margin: 0 auto 6px; }
.brand { margin-bottom: 0; font-size: 28px; letter-spacing: .02em; }
.brand-he { margin: 0 0 12px; text-align: center; }
.error { color: var(--bad); font-size: 14px; min-height: 1.4em; }
.grow { flex: 1; }
.row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }

label { display: block; margin: 8px 0; font-size: 14px; }
label.check { display: flex; gap: 8px; align-items: flex-start; }
input, select { font: inherit; color: var(--ink); background: #2a2230; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
label > input:not([type=checkbox]), label > select { display: block; width: 100%; margin-top: 4px; }
button { font: inherit; color: var(--ink); background: #2f2636; border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--bad); border-color: var(--bad); }

#auth { position: relative; z-index: 2; min-height: 100%; display: flex; align-items: center; justify-content: flex-start; padding: 16px clamp(16px, 8vw, 120px);
  background: linear-gradient(to left, rgba(23, 19, 26, .72), rgba(23, 19, 26, .12) 55%, transparent); }
.card { width: min(400px, 100%); background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 22px; backdrop-filter: blur(10px); }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tabs button { flex: 1; }
.tabs button.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
#auth-submit { width: 100%; margin-top: 6px; }

#stage { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
#top { position: fixed; top: 0; inset-inline: 0; z-index: 3; display: flex; align-items: center; gap: 10px; padding: 10px 16px; background: linear-gradient(rgba(23, 19, 26, .75), transparent); }
#chat { position: fixed; z-index: 2; inset-inline-end: 16px; top: 60px; bottom: 16px; width: min(380px, calc(100% - 32px)); display: flex; flex-direction: column;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); }
#messages { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 88%; padding: 8px 12px; border-radius: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg.user { align-self: flex-start; background: #4a2f49; }
.msg.assistant { align-self: flex-end; background: #2f2636; }
.msg.typing { align-self: flex-end; color: var(--muted); }
#composer { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--line); }
#composer input { flex: 1; min-width: 0; }

#settings { position: fixed; z-index: 4; inset-inline-start: 16px; top: 60px; bottom: 16px; width: min(340px, calc(100% - 32px)); overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 16px 16px; backdrop-filter: blur(8px); }
#build { position: fixed; z-index: 3; inset-inline-start: 16px; top: 60px; bottom: 16px; width: min(340px, calc(100% - 32px)); overflow-y: auto;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 6px 16px 16px; backdrop-filter: blur(8px); }
#catalog { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.thing { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px 4px; font-size: 13px; line-height: 1.25; }
.thing:hover { border-color: var(--accent); }
.thing img { width: 64px; height: 64px; }
body.building #chat { display: none; }
#toast { position: fixed; z-index: 5; bottom: 20px; inset-inline: 0; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
#toast div { max-width: min(520px, calc(100% - 32px)); background: #3a2130; border: 1px solid var(--bad); border-radius: 10px; padding: 8px 14px; }

#setup { position: fixed; inset: 0; z-index: 6; overflow-y: auto; display: flex; padding: 16px; background: rgba(23, 19, 26, .55); }
.setup-card { width: min(640px, 100%); margin: auto; }
.setup-card h1 { text-align: start; }
.setup-card ol { padding-inline-start: 22px; margin: 10px 0; }
.setup-card li { margin: 8px 0; }
.setup-card a, label.check a, #settings a, .doc a { color: var(--accent); }
.doc { width: min(720px, 100%); margin: 0 auto; padding: 32px 16px 48px; }
.doc h1 { text-align: start; }
.doc h2 { margin-top: 24px; }
.doc .logo { margin: 0 0 12px; }
.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.choice { display: flex; flex-direction: column; gap: 8px; padding: 16px; text-align: start; }
.choice:hover { border-color: var(--accent); }
.choice strong { font-size: 17px; color: var(--accent); }
.cmd { display: flex; gap: 8px; align-items: center; margin-top: 6px; }
.cmd code { flex: 1; min-width: 0; padding: 8px 10px; background: #15111a; border: 1px solid var(--line); border-radius: 8px; overflow-x: auto; white-space: nowrap; }

@media (max-width: 760px) {
  .choices { grid-template-columns: 1fr; }
  #auth { align-items: flex-end; justify-content: center; padding: 16px; background: linear-gradient(to top, rgba(23, 19, 26, .8), transparent 70%); }
  #chat { top: auto; height: 48%; bottom: 8px; inset-inline: 8px; width: auto; }
  #settings { inset-inline: 8px; width: auto; top: 54px; bottom: 8px; }
  #build { inset-inline: 8px; width: auto; top: auto; height: 46%; bottom: 8px; }
  #stage-hint { display: none; }
}
