:root {
  --ink: #16181f;
  --muted: #5e6578;
  --bg: #f3f5fa;
  --surface: #ffffff;
  --line: #e3e6ef;
  --teal: #0c9aa6;
  --teal-deep: #087f89;
  --violet: #6b35d4;
  --violet-deep: #5424b0;
  --nav: #101218;
  --nav-ink: #f4f6fb;
  --nav-muted: #a7adbd;
  --nav-hover: rgba(255, 255, 255, 0.06);
  --nav-active: rgba(124, 77, 224, 0.28);
  --danger: #9f2d3a;
  --ok: #0d7a55;
  --warn: #8a5a00;
  --shadow: 0 18px 50px rgba(16, 18, 24, 0.12);
  --radius: 14px;
  --nav-width: 280px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
}

html[data-theme="dark"] {
  --ink: #f2f4f8;
  --muted: #aeb4c4;
  --bg: #0c0e14;
  --surface: #171a22;
  --line: #2a2f3c;
  --nav: #07080c;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

html { font-size: 14px; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--bg);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.5;
}

button, input, select, textarea { font: inherit; color: inherit; }

a { color: var(--violet); }

.nav {
  position: sticky;
  top: 0;
  height: 100vh;
  width: var(--nav-width);
  flex: none;
  display: flex;
  flex-direction: column;
  background: var(--nav);
  color: var(--nav-ink);
}

.nav.is-collapsed { width: 76px; }
.nav.is-collapsed .nav-label { display: none; }

.nav-top, .nav-bottom { padding: 16px 12px; }
.nav-top { display: flex; align-items: center; gap: 8px; }
.nav-menu { display: flex; flex-direction: column; gap: 4px; padding: 8px 12px; flex: 1; overflow: auto; }
.nav-tree { display: none; padding: 0 4px 8px 34px; }
.nav-branch.is-open .nav-tree { display: block; }
.nav.is-collapsed .nav-tree { display: none; }
.nav .tree a, .nav .tree summary { color: var(--nav-ink); }
.nav .tree a { display: block; padding: 4px 8px; border-radius: 8px; font-size: 0.92rem; text-decoration: none; }
.nav .tree a:hover, .nav .tree summary:hover { background: var(--nav-hover); }
.nav .tree summary { padding: 4px 8px; border-radius: 8px; cursor: pointer; }
.nav .tree a:hover, .nav .tree a.is-current { color: #d7c6ff; }
.nav .threads a { font-size: 0.82rem; line-height: 1.35; white-space: normal; }
.nav-tree form { margin: 0 0 6px; }
.nav .threads { margin-left: -10px; }
.nav .threads li { position: relative; display: flex; align-items: flex-start; border-radius: 8px; }
.nav .threads li:hover, .nav .threads li:focus-within { background: var(--nav-hover); }
.nav .threads li a { flex: 1; min-width: 0; padding-left: 20px; }
.nav .threads li a:hover { background: transparent; }
.nav .threads .thread-delete-form { position: absolute; left: 4px; top: 5px; margin: 0; }
.nav .threads .thread-delete {
  display: none;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  min-height: 0;
  padding: 0;
  box-shadow: none;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--nav-muted);
  cursor: pointer;
}
.nav .threads li:hover .thread-delete, .nav .threads li:focus-within .thread-delete { display: flex; }
.nav .threads .thread-delete:hover { background: rgba(255, 255, 255, 0.18); color: var(--nav-ink); }
.nav-tree button.nav-sub {
  display: block;
  width: 100%;
  padding: 4px 8px;
  background: transparent;
  font: inherit;
  font-size: 0.92rem;
  color: var(--nav-ink);
  border: 0;
  border-radius: 8px;
  text-decoration: none;
  text-align: left;
  cursor: pointer;
}
.nav-tree button.nav-sub:hover { background: var(--nav-hover); }
.nav .tree summary { font-weight: 600; color: var(--nav-muted); }
.nav-note { margin: 4px 8px 8px 44px; color: var(--nav-muted); font-size: 0.82rem; }
.nav-user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 0;
  padding: 8px 10px;
  color: var(--nav-ink);
  min-width: 0;
}
.nav-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--violet);
  display: grid;
  place-items: center;
  font-size: 13px;
  font-weight: 600;
  flex: none;
}
.nav-user .nav-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-bottom { margin-top: auto; display: flex; flex-direction: column; gap: 4px; border-top: 1px solid rgba(255, 255, 255, 0.08); }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.04em;
}

.brand img { width: 36px; height: 36px; object-fit: cover; border-radius: 8px; background: #000; }

.icon-button, .nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--nav-ink);
  text-decoration: none;
  text-align: left;
  padding: 10px;
  cursor: pointer;
}

.nav-item:hover, .icon-button:hover { background: var(--nav-hover); }
.nav-item.is-active { background: var(--nav-active); }
.nav-item svg, .icon-button svg { flex: none; }
.nav-item { font-size: 0.95rem; }
.nav-item svg { width: 15px; height: 15px; }

.icon-button { width: auto; color: var(--nav-muted); padding: 8px; }
.icon-button img { width: 22px; height: 22px; display: block; object-fit: cover; border-radius: 5px; background: #000; }

.app { display: flex; min-height: 100vh; }

.project, .chat, .editor, .system {
  min-width: 0;
}

.project {
  width: 300px;
  flex: none;
  background: var(--surface);
  border-right: 1px solid var(--line);
  overflow: auto;
  padding: 20px 16px 32px;
}

.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
}

.editor {
  width: min(42vw, 560px);
  flex: none;
  height: 100vh;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--line);
  padding: 20px;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

.editor { position: relative; }
.editor[hidden] { display: none; }
.resize-handle {
  position: absolute;
  top: 0;
  left: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 20;
  background: transparent;
  transition: background 0.15s;
}
.resize-handle:hover, .resize-handle.is-dragging {
  background: var(--accent, #6366f1);
}
.graph-panel { width: min(55vw, 720px); max-width: 75vw; }
.wiki-panel { width: min(55vw, 720px); max-width: 75vw; padding: 0; display: flex; flex-direction: column; }
.wiki-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.wiki-toolbar-title { font-weight: 600; font-size: 0.95rem; margin-left: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.wiki-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  flex-shrink: 0;
}
.wiki-nav-btn:hover { background: var(--bg); }
.wiki-nav-btn:disabled { opacity: .35; cursor: default; }
#wiki-sidebar {
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  max-height: 180px;
  overflow-y: auto;
}
.wiki-sidebar-label { margin: 0 0 4px; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); font-weight: 600; }
#wiki-sidebar ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 10px; }
#wiki-sidebar a { font-size: 0.85rem; color: var(--ink); text-decoration: none; padding: 2px 6px; border-radius: 4px; }
#wiki-sidebar a:hover { background: var(--bg); }
#wiki-sidebar a.is-current { background: var(--accent, #6366f1); color: #fff; }
.wiki-body {
  flex: 1;
  overflow: auto;
  padding: 20px 24px 40px;
  scroll-behavior: smooth;
}
.wiki-body h1 { font-size: 1.5rem; margin: 0 0 12px; }
.wiki-body h2 { font-size: 1.2rem; margin: 24px 0 8px; border-bottom: 1px solid var(--line); padding-bottom: 4px; }
.wiki-body h3 { font-size: 1.05rem; margin: 18px 0 6px; }
.wiki-body p { margin: 8px 0; line-height: 1.6; }
.wiki-body ul, .wiki-body ol { margin: 8px 0; padding-left: 24px; }
.wiki-body li { margin: 4px 0; line-height: 1.5; }
.wiki-body pre { background: var(--bg); padding: 12px; border-radius: 6px; overflow-x: auto; font-size: 0.85rem; }
.wiki-body code { font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 0.88em; background: var(--bg); padding: 1px 4px; border-radius: 3px; }
.wiki-body pre code { background: none; padding: 0; }
.wiki-table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 0.9rem; }
.wiki-table th, .wiki-table td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.wiki-table th { background: var(--bg); font-weight: 600; }
a.wiki-link { color: var(--accent, #6366f1); text-decoration: none; font-weight: 500; cursor: pointer; }
a.wiki-link:hover { text-decoration: underline; }
.wiki-concept { color: var(--muted); font-style: italic; }
.graph-panel svg text { fill: var(--ink); }
.nav-graph-form { margin: 0; padding: 0; }
.nav-graph-form .nav-sub { width: 100%; text-align: left; }

.nav button.nav-item { background: transparent; color: var(--nav-ink); }
.nav button.nav-item:hover { background: var(--nav-hover); }
.nav button.nav-item.is-active { background: var(--nav-active); }

.who { margin: 0; font-size: 1.35rem; }
.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.step-form, .stack-form { display: flex; flex-direction: column; gap: 8px; margin: 12px 0 20px; }

select, input, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 10px 12px;
}

textarea { resize: vertical; }

.btn, button[type="submit"] {
  border: 0;
  border-radius: 10px;
  background: var(--violet);
  color: white;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
}

.btn.secondary, .step-form button, .project button[type="submit"] {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

.tree, .conversations { list-style: none; margin: 0; padding-left: 0; }
.tree ul { list-style: none; padding-left: 14px; margin: 4px 0; }
.tree a, .conversations a { color: var(--ink); text-decoration: none; }
.tree a:hover, .conversations a:hover { color: var(--violet); }
.tree summary { cursor: pointer; font-weight: 600; padding: 4px 0; }

.chat-head, .composer, .notice {
  padding: 16px 24px;
}

.chat-head, .composer, .chat > .notice, .chat > .studio-note { flex-shrink: 0; }
.chat-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}
.chat-tools { display: flex; align-items: flex-end; gap: 12px; }
.chat-tools .step-form { flex-direction: row; align-items: flex-end; margin: 0; }
.chat-tools .step-form select { width: 240px; }
.chat-tools .step-form button, .chat-tools .btn.secondary { width: auto; white-space: nowrap; }
.thread-bar {
  display: flex;
  gap: 8px;
  overflow: auto;
  padding: 12px 24px;
  border-bottom: 1px solid var(--line);
}
.thread-bar a {
  color: var(--ink);
  text-decoration: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  white-space: nowrap;
  font-size: 0.85rem;
  background: var(--surface);
}
.thread-bar a.is-current { border-color: var(--violet); color: var(--violet); }
.thread-bar .empty { padding: 0; }
.studio-note { padding: 8px 24px 0; }

.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: min(52vh, 420px);
  padding: 28px 20px 36px;
  text-align: center;
}
.chat-empty img {
  width: auto;
  height: auto;
  max-width: 16.67vw;
  max-height: 16.67vh;
  object-fit: contain;
}
.chat-empty-tagline {
  max-width: 36ch;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.5;
}
.chat-empty-ask {
  margin: 28px 0 14px;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.chat-empty-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}
.chat-empty-prompt {
  margin: 0;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
}
.chat-empty-prompt:hover {
  border-color: color-mix(in srgb, #6b3fa0 45%, var(--line));
  background: color-mix(in srgb, var(--surface) 80%, transparent);
}

.transcript {
  flex: 1;
  min-height: 0;
  margin: 0;
  padding: 24px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bubble { max-width: 72ch; padding: 12px 14px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.bubble.mine { align-self: flex-end; background: #efe9fb; }
html[data-theme="dark"] .bubble.mine { background: #2a2140; }
.bubble .meta { margin: 0 0 6px; color: var(--muted); font-size: 0.78rem; font-weight: 600; }
.bubble .bubble-body { margin: 0; white-space: pre-wrap; }
.bubble .coach-md { white-space: normal; line-height: 1.45; }
.bubble .coach-md > *:first-child { margin-top: 0; }
.bubble .coach-md > *:last-child { margin-bottom: 0; }
.bubble .coach-md p { margin: 0 0 0.65em; white-space: pre-wrap; }
.bubble .coach-md ul,
.bubble .coach-md ol { margin: 0 0 0.65em; padding-left: 1.25em; }
.bubble .coach-md li { margin: 0.15em 0; }
.bubble .coach-md code {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 0.9em;
  padding: 0.1em 0.35em;
  border-radius: 4px;
  background: color-mix(in srgb, var(--line) 65%, transparent);
}
.bubble .coach-md pre {
  margin: 0 0 0.65em;
  padding: 10px 12px;
  overflow-x: auto;
  border-radius: 8px;
  background: color-mix(in srgb, var(--line) 65%, transparent);
}
.bubble .coach-md pre code { padding: 0; background: none; }
.bubble .coach-md a { color: inherit; text-decoration: underline; }
.bubble .coach-md a[href*="graph=1"] {
  display: inline-block;
  margin-top: 4px;
  padding: 6px 16px;
  background: var(--accent, #6366f1);
  color: #fff !important;
  border-radius: 8px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}
.bubble .coach-md a[href*="graph=1"]:hover { opacity: .85; }
.bubble .waiting .thought { margin: 0; white-space: pre-wrap; }

.composer { position: relative; padding: 8px 20px 18px; background: transparent; }
.waiting[hidden] { display: none; }
.waiting .meta { display: flex; align-items: center; gap: 8px; color: var(--ink); }
.waiting .meta img {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
  background: #07080d;
}
.waiting .thought { margin: 0; color: var(--teal); min-height: 1.4em; }
.waiting.is-blink .thought { animation: lift-blink 0.9s ease-in-out infinite; }
@keyframes lift-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.15; }
}
.composer-box {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "note note"
    "message message"
    "tools send";
  align-items: end;
  column-gap: 8px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  padding: 8px 10px 8px;
}
.composer .note { grid-area: note; }
.composer-box > textarea { grid-area: message; }
.composer-bar { grid-area: tools; min-width: 0; }
.composer button.send { grid-area: send; }
.composer-box > textarea,
.composer .note textarea {
  border: 0;
  padding: 6px 6px 4px;
  background: transparent;
  min-height: 64px;
  resize: vertical;
}
.composer .note { margin: 0 0 4px; font-size: 0.85rem; }
.composer .note textarea { min-height: 48px; }
.composer-bar { display: flex; align-items: flex-end; gap: 8px; }
.composer-tools { position: relative; display: flex; align-items: center; gap: 6px; }
.composer .tool, .composer .pop button {
  width: auto;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  padding: 4px 8px;
  font-weight: 600;
}
.composer .tool {
  display: inline-flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: auto;
  height: 30px;
  white-space: nowrap;
  color: var(--ink);
  background: color-mix(in srgb, var(--violet) 14%, var(--bg));
  border-color: color-mix(in srgb, var(--violet) 32%, var(--line));
  cursor: pointer;
}
.composer .tool:hover, .composer .pop button:hover { background: color-mix(in srgb, var(--violet) 24%, var(--bg)); color: var(--ink); }
.composer .tool-icon,
.composer button.mark img {
  width: 14px;
  height: 14px;
  min-width: 14px;
  max-width: 14px;
  max-height: 14px;
  flex: 0 0 14px;
  display: block;
  object-fit: contain;
}
.composer button.mark {
  width: auto;
  height: 30px;
  padding: 0 10px;
  background: color-mix(in srgb, var(--violet) 14%, var(--bg));
  color: var(--ink);
}
.composer button.mark img { border-radius: 3px; }
.composer button.send { width: auto; align-self: center; padding: 6px 14px; }
.composer .note[hidden],
.composer .pop[hidden] { display: none; }
.composer .pop {
  position: absolute;
  left: 0;
  bottom: 38px;
  z-index: 2;
  min-width: 148px;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
}
.composer .pop button { text-align: left; }
.composer .pop.skill-menu {
  left: 20px;
  right: auto;
  top: auto;
  bottom: calc(100% + 8px);
  width: min(440px, calc(100% - 40px));
  min-width: 0;
  max-height: min(280px, 42vh);
  align-items: stretch;
  text-align: left;
  z-index: 4;
}
.composer .pop.skill-menu button {
  display: block;
  width: 100%;
  text-align: left;
  font-weight: 400;
}
.composer .pop .menu-hint { padding: 6px 12px; font-size: 0.74rem; color: var(--muted); border-top: 1px solid var(--line); }
.composer .pop button.is-active { background: var(--bg); color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0; padding: 0; list-style: none; flex: 1; }
.chips li { font-size: 0.78rem; color: var(--muted); background: var(--bg); border-radius: 999px; padding: 2px 8px; }
.bubble .confirm { margin-top: 10px; }
.bubble .confirm .choice { font-weight: 400; }
.notice { margin: 16px 24px 0; background: #f4efe2; color: var(--warn); border-radius: 10px; }
.notice.is-error { background: #d93025; color: #fff; }
html[data-theme="dark"] .notice { background: #2a2418; }
html[data-theme="dark"] .notice.is-error { background: #c5221f; color: #fff; }

.editor-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.icon-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: var(--muted);
  text-decoration: none;
}
.icon-close:hover { background: var(--bg); color: var(--ink); }
.editor textarea { min-height: 62vh; font-family: "IBM Plex Mono", ui-monospace, monospace; font-size: 12px; }
.editor-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.editor-actions button { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.editor-actions button[value="validated"], .editor h2 { color: var(--ink); }
.path { margin-top: 0; font-size: 0.95rem; word-break: break-all; }

.system { flex: 1; padding: 32px 40px 48px; }
.settings-form { display: flex; flex-direction: column; gap: 16px; max-width: 680px; }
.settings .notice { margin: 0 0 16px; background: #e7f6ef; color: var(--ok); }
html[data-theme="dark"] .settings .notice { background: #163028; }
.settings-form .card h2 { margin: 0 0 8px; }
.work-management { max-width: 680px; margin-top: 24px; }
.work-management .notice,
.work-management .alert { margin: 12px 0; padding: 10px 14px; border-radius: var(--radius); }
.work-management .notice { background: #e7f6ef; color: var(--ok); }
.work-management .alert { background: #fdecea; color: var(--danger); }
html[data-theme="dark"] .work-management .notice { background: #163028; }
html[data-theme="dark"] .work-management .alert { background: #3a1818; }
.work-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }
.work-section:first-of-type { border-top: 0; padding-top: 0; }
.work-section h3 { margin: 0 0 6px; font-size: 1rem; }
.work-section form { display: flex; flex-wrap: wrap; align-items: end; gap: 12px; margin-top: 8px; }
.work-section select { min-width: 220px; }
.work-section label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.hint { margin: 0 0 12px; color: var(--muted); }
label.choice { display: flex; align-items: center; gap: 8px; font-weight: 500; }
label.choice input { width: auto; margin: 0; }
.system h1 { margin: 8px 0 20px; font-size: 1.8rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; }
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 8px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.card p { margin: 0; font-size: 1.15rem; }
.health-green { color: var(--ok); }
.health-error { color: var(--danger); }
.system .actions { display: flex; gap: 8px; margin-top: 16px; }
.system ul { padding-left: 18px; }

.sign-in {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
  color: #eceef4;
  background: #0b0c10;
  overflow: hidden;
}

.auth-atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(280px 180px at 14% 16%, rgba(214, 196, 255, 0.18), transparent 70%),
    radial-gradient(220px 160px at 88% 84%, rgba(196, 168, 255, 0.14), transparent 72%),
    #0b0c10;
}

.auth-top,
.auth-hero,
.auth-sheet {
  position: relative;
  z-index: 1;
}

.auth-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 22px 28px;
  z-index: 4;
  transition: padding-right 0.32s ease;
}

.auth-wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #f4f6fb;
  text-decoration: none;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.auth-wordmark img { width: 28px; height: 28px; object-fit: contain; }

.auth-actions { display: flex; gap: 10px; }

.auth-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 96px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.04);
  color: #eef1f8;
  text-decoration: none;
  font-weight: 500;
}
.auth-toggle:hover,
.auth-toggle[aria-expanded="true"] {
  border-color: rgba(176, 140, 255, 0.55);
  background: rgba(107, 53, 212, 0.28);
}
.auth-toggle-primary {
  background: #6b35d4;
  border-color: #6b35d4;
}
.auth-toggle-primary:hover,
.auth-toggle-primary[aria-expanded="true"] {
  background: #5424b0;
  border-color: #5424b0;
}

.auth-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
.auth-hero img {
  width: auto;
  height: auto;
  max-width: 16.67vw;
  max-height: 16.67vh;
  object-fit: contain;
}
.auth-hero p {
  max-width: 36ch;
  margin: 16px 0 0;
  color: #9aa1b2;
  font-size: 0.95rem;
  line-height: 1.5;
}

.auth-sheet {
  position: fixed;
  top: 50%;
  right: 28px;
  z-index: 3;
  width: min(380px, calc(100% - 48px));
  max-height: calc(100vh - 48px);
  padding: 28px 28px 24px;
  overflow: auto;
  color: #eceef4;
  background: #14161c;
  border: 1px solid rgba(214, 196, 255, 0.18);
  border-radius: 16px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  transform: translate(120%, -50%);
  transition: transform 0.28s ease;
}
.auth-sheet.is-open,
.auth-sheet:has(#register:target),
.auth-sheet:has(#login:target) {
  transform: translate(0, -50%);
}
.auth-sheet form { display: none; }
.auth-sheet[data-current="register"] #register,
.auth-sheet[data-current="login"] #login,
#register:target,
#login:target {
  display: block;
}
.sign-in:has(.auth-sheet.is-open) .auth-top,
.sign-in:has(#register:target) .auth-top,
.sign-in:has(#login:target) .auth-top {
  padding-right: calc(min(380px, 100%) + 40px);
}

.auth-close {
  position: absolute;
  top: 24px;
  right: 24px;
  color: #aeb4c4;
  text-decoration: none;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}
.auth-close:hover { color: #fff; }

.auth-sheet h1 {
  margin: 0 0 8px;
  font-size: 1.7rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.auth-lead {
  margin: 0 0 24px;
  color: #aeb4c4;
  font-size: 0.95rem;
}
.auth-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.auth-sheet label {
  display: block;
  margin: 0 0 14px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #c5cad6;
}
.auth-sheet input {
  display: block;
  width: 100%;
  margin-top: 6px;
  padding: 11px 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: #f4f6fb;
  font-weight: 400;
}
.auth-sheet input:focus {
  outline: 2px solid rgba(124, 77, 224, 0.55);
  outline-offset: 1px;
}
.auth-sheet button[type="submit"] {
  width: 100%;
  margin-top: 8px;
  padding: 12px 18px;
  border: 0;
  border-radius: 10px;
  background: #6b35d4;
  color: #fff;
  font-weight: 600;
  cursor: pointer;
}
.auth-sheet button[type="submit"]:hover { background: #5424b0; }
.auth-switch {
  margin: 18px 0 0;
  color: #aeb4c4;
  font-size: 0.92rem;
}
.auth-switch a { color: #c4a8ff; }

.auth-sheet .alert {
  margin: 0 0 16px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(159, 45, 58, 0.2);
  color: #ffc7cd;
}

label { display: block; margin: 0 0 14px; font-size: 0.92rem; font-weight: 600; }
label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  font-weight: 400;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

.alert {
  margin: 0 0 14px;
  padding: 10px 12px;
  border-radius: 10px;
  background: #fdecef;
  color: var(--danger);
}

.empty { color: var(--muted); padding: 12px 0 24px; }

@media (max-width: 960px) {
  .auth-sheet {
    right: 16px;
    width: calc(100% - 32px);
  }
  .sign-in:has(.auth-sheet.is-open) .auth-top,
  .sign-in:has(#register:target) .auth-top,
  .sign-in:has(#login:target) .auth-top {
    padding-right: 28px;
  }
  .auth-hero img {
    max-width: 16.67vw;
    max-height: 12vh;
  }
  .auth-row { grid-template-columns: 1fr; }
  .project { display: none; }
  .editor { width: 100%; }
}

/* Tech Lessons */
.editor.lesson { width: min(48vw, 720px); overflow: hidden; }

/* Materials panel — collapsible top section */
.lesson-materials {
  flex: none;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 40vh;
  transition: max-height 0.25s ease;
  border-bottom: 1px solid var(--line);
}
.lesson-materials.is-collapsed { max-height: 36px; }
.lesson-materials.is-collapsed .lesson-materials-text { display: none; }
.lesson-materials-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--ink);
  width: 100%;
  text-align: left;
}
.lesson-materials-toggle:hover { background: var(--bg); }
.lesson-materials-chevron {
  flex: none;
  transition: transform 0.2s ease;
}
.lesson-materials.is-collapsed .lesson-materials-chevron { transform: rotate(-90deg); }
.lesson-materials-label {
  margin: 0;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}
.lesson-materials-text {
  margin: 0 20px 16px;
  padding: 16px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 0.78rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/* Chat area — bottom section */
.lesson-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.lesson-transcript {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.lesson-transcript .bubble { max-width: 100%; font-size: 0.88rem; }
.lesson-transcript .bubble.mine { align-self: flex-end; }
.lesson-transcript .bubble .meta { font-size: 0.72rem; }

/* Lesson waiting indicator */
.lesson-transcript .lesson-waiting { display: none; }
.lesson-transcript .lesson-waiting.is-visible { display: block; }
.lesson-transcript .lesson-waiting .thought { margin: 0; white-space: pre-wrap; }
.lesson-transcript .lesson-waiting.is-blink .thought::after {
  content: " ●";
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

/* Lesson composer */
.lesson-composer {
  flex: none;
  display: flex;
  gap: 8px;
  padding: 8px 16px 12px;
  border-top: 1px solid var(--line);
  background: var(--surface);
  align-items: flex-end;
}
.lesson-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  font: inherit;
  font-size: 0.88rem;
  line-height: 1.4;
  background: var(--bg);
  color: var(--ink);
  min-height: 0;
}
.lesson-composer textarea:focus { outline: 2px solid var(--violet); outline-offset: -1px; border-color: transparent; }
.lesson-composer .lesson-send {
  flex: none;
  padding: 8px 16px;
  border: none;
  border-radius: 10px;
  background: var(--violet);
  color: #fff;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  line-height: 1.4;
}
.lesson-composer .lesson-send:hover { opacity: 0.9; }
.lesson-composer .lesson-send:disabled { opacity: 0.5; cursor: default; }

/* Quiz/exercise elements inside lesson chat */
.quiz-body p { margin: 0 0 0.6em; white-space: pre-wrap; }
.quiz-body h3 { margin: 0 0 0.4em; font-size: 1rem; }
.quiz-again {
  display: block;
  width: auto;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  margin-top: 8px;
}
.quiz-again:hover:not(:disabled) { background: var(--bg); }
@media (max-width: 960px) { .editor.lesson { width: 100%; } }

/* ── Confirmation dialog ── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.15s ease;
  pointer-events: none;
}
.confirm-overlay.is-visible {
  opacity: 1;
  pointer-events: auto;
}
.confirm-dialog {
  width: 400px;
  max-width: calc(100vw - 32px);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  transform: scale(0.96) translateY(8px);
  transition: transform 0.15s ease;
}
.confirm-overlay.is-visible .confirm-dialog {
  transform: scale(1) translateY(0);
}
.confirm-dialog h3 {
  margin: 0 0 8px;
  font-size: 1rem;
  font-weight: 600;
  color: var(--ink);
}
.confirm-dialog p {
  margin: 0 0 20px;
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--muted);
}
.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
.confirm-actions button {
  padding: 8px 18px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  border: 1px solid var(--line);
  transition: background 0.1s ease, border-color 0.1s ease;
}
.confirm-cancel {
  background: transparent;
  color: var(--ink);
}
.confirm-cancel:hover { background: var(--bg); }
.confirm-proceed {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}
.confirm-proceed:hover { opacity: 0.88; }
