@import './tokens.css';

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  font-size: var(--text-sm);
  color: var(--color-ink);
  background: var(--color-soft);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
.hidden { display: none !important; }

/* —— Topbar (Linarys nav chrome) —— */
.topbar {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4, 1rem);
  padding: 0 1.25rem;
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-line);
  box-shadow: var(--shadow-nav);
  position: relative;
  z-index: 30;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--color-navy);
  flex-shrink: 0;
}
.brand-logo {
  height: 36px;
  width: auto;
  display: block;
}
.brand-suffix {
  font-weight: 500;
  color: var(--color-muted-2);
  white-space: nowrap;
}
.brand-suffix .sep { opacity: 0.45; margin: 0 0.1rem; }
.brand-suffix b { color: var(--color-navy); font-weight: 600; }
.topbar-mid { flex: 1; text-align: center; min-width: 0; }
.north-star {
  font-family: var(--font-display);
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--color-purple);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.topbar-actions { display: flex; align-items: center; gap: 0.45rem; flex-shrink: 0; }

.btn {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.8125rem;
  border-radius: var(--radius-pill);
  padding: 0.5rem 1.1rem;
  border: 1.5px solid transparent;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: transform 0.14s, box-shadow 0.2s, background 0.15s;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary {
  background: var(--color-navy);
  color: #fff;
  box-shadow: 0 10px 24px -12px rgba(0, 26, 93, 0.7);
}
.btn-primary:hover:not(:disabled) { transform: translateY(-1px); }
.btn-ghost {
  background: var(--color-bg);
  color: var(--color-navy);
  border-color: var(--color-line);
}
.btn-ghost:hover:not(:disabled) { border-color: var(--color-purple); color: var(--color-purple); }
.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.75rem; }
.btn-icon {
  background: var(--color-soft);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 1.25rem;
  cursor: pointer;
  color: var(--color-muted);
  display: flex;
  align-items: center;
  justify-content: center;
}
.btn-icon:hover { color: var(--color-purple); background: var(--color-line-2); }

/* —— Layout —— */
.shell {
  --sidebar-w: 300px;
  --ai-w: 380px;
  display: grid;
  grid-template-columns: var(--sidebar-w) 5px minmax(240px, 1fr) 5px var(--ai-w);
  grid-template-rows: 1fr;
  grid-template-areas: "sidebar rsb main rai ai";
  height: calc(100vh - var(--nav-height) - var(--mob-nav-height));
  min-height: 0;
}
.shell:not(.ai-open) {
  grid-template-columns: var(--sidebar-w) 5px minmax(240px, 1fr);
  grid-template-areas: "sidebar rsb main";
}
.shell:not(.ai-open) .panel-resize[data-resize="ai"],
.shell:not(.ai-open) .ai-panel {
  display: none;
}

.sidebar {
  grid-area: sidebar;
  background: var(--color-bg);
  border-right: 1px solid var(--color-line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.main-col {
  grid-area: main;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
  background: var(--color-bg);
}
.panel-resize {
  z-index: 5;
  background: transparent;
  transition: background 0.15s;
}
.panel-resize[data-resize="sidebar"] { grid-area: rsb; cursor: col-resize; }
.panel-resize[data-resize="ai"] { grid-area: rai; cursor: col-resize; }
.panel-resize:hover,
.panel-resize.dragging {
  background: var(--color-purple);
  opacity: 0.35;
}
.shell.term-open .terminal-panel { display: flex; }
.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-line);
  background: var(--color-softer);
}
.sidebar-tabs button {
  flex: 1;
  border: none;
  background: none;
  padding: 0.65rem 0.5rem;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted);
  cursor: pointer;
  position: relative;
}
.sidebar-tabs button.active { color: var(--color-navy); background: var(--color-bg); }
.sidebar-tabs button.active::after {
  content: '';
  position: absolute;
  bottom: 0; left: 20%; right: 20%;
  height: 2px;
  background: var(--gradient-brand);
  border-radius: 2px;
}
.tab-badge {
  display: inline-block;
  margin-left: 4px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--color-navy);
  color: #fff;
  font-size: 0.6rem;
  line-height: 16px;
}
.tab-badge.hot { background: var(--gradient-brand); }

.sidebar-head { padding: 0.65rem; border-bottom: 1px solid var(--color-line); }
.sidebar-head input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-family: var(--font-body);
}
.sidebar-head input:focus { outline: none; border-color: var(--color-purple); }

.panel-files, .panel-queue, .panel-registry, .panel-projects { flex: 1; overflow-y: auto; min-height: 0; }
.panel-queue, .panel-registry, .panel-projects { padding: 0.5rem; display: none; flex-direction: column; gap: 0.35rem; }
.panel-queue.active, .panel-registry.active, .panel-projects.active { display: flex; }
.sidebar-head.hidden { display: none; }
.projects-hint { padding: 0 0.25rem; margin: 0; }
.projects-picker {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.project-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  cursor: pointer;
  font-family: var(--font-body);
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}
.project-chip:hover { border-color: var(--color-purple); background: var(--color-soft); }
.project-chip.active {
  border-color: var(--color-purple);
  background: var(--color-soft);
  box-shadow: inset 3px 0 0 var(--color-purple);
}
.project-chip-title { font-weight: 500; font-size: 0.8125rem; color: var(--color-navy); }
.project-chip-main { display: flex; flex-direction: column; gap: 0.15rem; min-width: 0; }
.project-chip-lens {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
}
.project-chip.lens-internal .project-chip-lens { color: var(--color-purple); }
.project-chip.lens-delivery .project-chip-lens { color: #0d6b4f; }
.project-chip.lens-content .project-chip-lens { color: #6b5a0d; }
.project-chip.lens-portfolio .project-chip-lens { color: #1a5f8b; }
.project-chip-status {
  font-size: 0.65rem;
  text-transform: uppercase;
  color: var(--color-muted);
  letter-spacing: 0.03em;
}
.project-artifacts { flex: 1; overflow-y: auto; min-height: 0; }
.project-hub-meta {
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-soft);
  margin-bottom: 0.5rem;
}
.project-hub-meta.hidden,
.project-queue-wrap.hidden,
.project-artifacts-label.hidden { display: none; }
.project-hub-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.35rem; }
.project-phase-chip {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 0.2rem 0.45rem;
  border-radius: 999px;
  background: var(--color-bg);
  border: 1px solid var(--color-line);
  color: var(--color-navy);
}
.project-phase-chip.sdlc { color: var(--color-purple); border-color: rgba(88, 50, 140, 0.25); }
.project-hub-next { font-size: 0.75rem; color: var(--color-muted); line-height: 1.35; margin: 0; }
.project-section-label {
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-muted);
  margin: 0.35rem 0 0.25rem;
  padding: 0 0.15rem;
}
.project-queue { display: flex; flex-direction: column; gap: 0.35rem; margin-bottom: 0.5rem; max-height: 9rem; overflow-y: auto; }
.project-queue-item {
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  cursor: pointer;
  font-size: 0.75rem;
}
.project-queue-item:hover { border-color: var(--color-purple); background: var(--color-soft); }
.project-queue-item.stale { border-color: #c9a227; }
.project-queue-path { font-family: ui-monospace, monospace; font-size: 0.65rem; color: var(--color-muted); word-break: break-all; }
.registry-search {
  width: 100%;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.55rem;
  font-size: 0.8125rem;
  margin-bottom: 0.25rem;
}
.registry-item {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  margin-bottom: 0.35rem;
  cursor: pointer;
  background: var(--color-bg);
}
.registry-item:hover { border-color: var(--color-purple); background: var(--color-soft); }
.registry-item-head { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.25rem; }
.registry-type { font-size: 0.65rem; text-transform: uppercase; }
.registry-title { font-weight: 500; font-size: 0.8rem; color: var(--color-navy); line-height: 1.3; }
.registry-path { font-family: ui-monospace, monospace; font-size: 0.68rem; color: var(--color-muted); word-break: break-all; margin-top: 0.2rem; }
#registry-list { flex: 1; overflow-y: auto; min-height: 0; }
.panel-files.active { display: block; }
.panel-files { display: none; }

/* —— File tree —— */
.tree-dir, .tree-file {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.5rem 0.35rem calc(0.5rem + var(--depth, 0) * 14px);
  cursor: pointer;
  font-size: 0.8125rem;
  border-left: 3px solid transparent;
  user-select: none;
}
.tree-dir:hover, .tree-file:hover { background: var(--color-soft); }
.tree-file.active { background: var(--color-soft); border-left-color: var(--color-purple); }
.tree-file.dirty .tree-name { color: var(--color-magenta); font-weight: 500; }
.tree-file.dirty::after {
  content: '●';
  color: var(--color-magenta);
  font-size: 0.5rem;
  margin-left: 2px;
}
.tree-file.git-modified .tree-name { color: #b45309; }
.tree-file.git-untracked .tree-name { color: #047857; }
.tree-file.git-staged .tree-name,
.tree-file.git-added .tree-name { color: #7d2cce; }
.tree-file.dirty.git-modified .tree-name { color: var(--color-magenta); }
.tree-git-dot {
  font-family: var(--font-display);
  font-size: 0.58rem;
  font-weight: 700;
  margin-left: auto;
  flex-shrink: 0;
  opacity: 0.85;
}
.tree-git-dot.git-modified { color: #b45309; }
.tree-git-dot.git-untracked { color: #047857; }
.tree-git-dot.git-staged,
.tree-git-dot.git-added { color: var(--color-purple); }
.tree-git-dot.git-deleted { color: #dc2626; }
.tree-chevron { width: 14px; flex-shrink: 0; color: var(--color-muted-2); font-size: 0.65rem; }
.tree-icon { width: 16px; text-align: center; flex-shrink: 0; opacity: 0.7; }
.tree-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-children { display: none; }
.tree-children.open { display: block; }

.badge {
  font-family: var(--font-display);
  font-size: 0.58rem;
  padding: 0.12rem 0.4rem;
  border-radius: var(--radius-pill);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.badge-draft { background: var(--color-soft); color: var(--color-muted); }
.badge-proposed, .badge-proposed-reference { background: #fef3c7; color: #92400e; }
.badge-approved, .badge-approved-reference { background: #d1fae5; color: #065f46; }
.badge-muted { background: var(--color-soft); color: var(--color-muted); }

.queue-item {
  padding: 0.65rem 0.75rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  background: var(--color-bg);
  cursor: pointer;
}
.queue-item:hover { border-color: var(--color-purple); }
.queue-item.stale { border-left: 3px solid var(--color-magenta); }
.queue-path { font-family: ui-monospace, monospace; font-size: 0.7rem; color: var(--color-muted); word-break: break-all; }
.queue-action { font-size: 0.75rem; color: var(--color-muted); margin-top: 0.35rem; line-height: 1.4; }
.queue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.45rem;
}
.queue-btn {
  font-size: 0.68rem;
  padding: 0.2rem 0.45rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  background: var(--color-bg);
  color: var(--color-navy);
  cursor: pointer;
}
.queue-btn:hover { border-color: var(--color-purple); background: var(--color-soft); }
.queue-btn.gate { border-color: var(--color-purple); color: var(--color-purple); }
.queue-git-link {
  display: inline-block;
  font-size: 0.68rem;
  margin-top: 0.35rem;
  color: var(--color-purple);
  text-decoration: none;
}
.queue-git-link:hover { text-decoration: underline; }
.queue-gate-checklist {
  border: none;
  padding: 0;
  margin: 0.75rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.queue-gate-checklist label {
  display: flex;
  gap: 0.45rem;
  align-items: flex-start;
  font-size: 0.8125rem;
  line-height: 1.35;
  cursor: pointer;
}

.sidebar-foot { padding: 0.55rem 0.75rem; border-top: 1px solid var(--color-line); background: var(--color-softer); }
.foot-line { display: flex; align-items: baseline; gap: 0.4rem; font-size: 0.72rem; line-height: 1.5; }
.foot-line + .foot-line { margin-top: 0.2rem; }
.foot-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--color-muted-2);
  min-width: 4.5rem;
  flex-shrink: 0;
}
.foot-value { color: var(--color-muted); word-break: break-word; }
.foot-value.branch { color: var(--color-navy); font-weight: 500; }
.hint { font-size: 0.72rem; color: var(--color-muted-2); line-height: 1.4; }

/* —— Main editor —— */
.main { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }

.empty-state { padding: 2.5rem; max-width: 540px; }
.eyebrow {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: var(--text-xs);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--color-purple);
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.eyebrow::before {
  content: '';
  width: 22px;
  height: 2px;
  background: var(--gradient-brand);
  border-radius: 2px;
}
.empty-state h2 { font-family: var(--font-display); color: var(--color-navy); margin: 0.75rem 0 0.5rem; font-size: 1.35rem; }

.doc-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--color-line);
  background: var(--color-softer);
  font-size: 0.8125rem;
}

.editor-tab-bar {
  display: flex;
  gap: 0.15rem;
  padding: 0.35rem 0.5rem 0;
  overflow-x: auto;
  background: var(--color-softer);
  border-bottom: 1px solid var(--color-line);
  flex-shrink: 0;
}
.editor-tab-bar.hidden { display: none; }
.editor-tab {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  max-width: 200px;
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--color-line);
  border-bottom: none;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: var(--color-bg);
  font-size: 0.72rem;
  font-family: ui-monospace, monospace;
  color: var(--color-muted);
  cursor: pointer;
  flex-shrink: 0;
}
.editor-tab:hover { color: var(--color-navy); }
.editor-tab.active {
  background: var(--color-bg);
  color: var(--color-navy);
  border-color: var(--color-purple);
  font-weight: 500;
}
.editor-tab.dirty .editor-tab-name { font-style: italic; }
.editor-tab-dot { color: var(--color-purple); font-size: 0.55rem; line-height: 1; }
.editor-tab-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.editor-tab-close {
  opacity: 0.45;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0 0.1rem;
}
.editor-tab-close:hover { opacity: 1; color: #991b1b; }

.ai-msg-actions { background: #f0f4ff; border: 1px dashed var(--color-line); font-size: 0.78rem; }
.doc-path { flex: 1; min-width: 120px; font-family: ui-monospace, monospace; color: var(--color-muted); font-size: 0.75rem; word-break: break-all; }
.read-only { font-family: var(--font-display); font-size: 0.65rem; font-weight: 600; color: var(--color-purple); text-transform: uppercase; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }

.md-view-modes { display: flex; gap: 0.25rem; flex-shrink: 0; }
.md-view-btn.active {
  border-color: var(--color-purple);
  color: var(--color-purple);
  background: var(--color-soft);
}
.doc-status-wrap { display: flex; align-items: center; gap: 0.25rem; }
.doc-status-select {
  font-family: var(--font-display);
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-pill);
  background: var(--color-bg);
  color: var(--color-navy);
  cursor: pointer;
}
.doc-status-select:focus { outline: none; border-color: var(--color-purple); }
.status-inferred-hint {
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-magenta);
  cursor: help;
}

/* Markdown view modes — hide Toast UI built-in switch; control preview layout */
#viewer-host.md-view-markdown .toastui-editor-md-preview,
#viewer-host.md-view-markdown .toastui-editor-md-splitter { display: none !important; }
#viewer-host.md-view-markdown .toastui-editor-md-container { width: 100% !important; }
#viewer-host.md-view-wysiwyg .toastui-editor-defaultUI-toolbar + .toastui-editor-md-tab-style { display: none; }
#viewer-host .toastui-editor-mode-switch { display: none !important; }

.editor-wrap { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.monaco-host {
  flex: 1;
  min-height: 0;
  width: 100%;
}
#viewer-host { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#viewer-host .toastui-editor-defaultUI,
#viewer-host .toastui-editor-defaultUI-container { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#toast-md-root,
#editor { flex: 1; min-height: 0; }
#viewer-host.md-view-readonly .toastui-editor-toolbar { display: none !important; }
#viewer-host.md-view-readonly .toastui-editor-md-splitter,
#viewer-host.md-view-readonly .toastui-editor-md-preview,
#viewer-host.md-view-readonly .toastui-editor-md-preview-panel { display: none !important; }
#viewer-host.md-view-readonly .toastui-editor-ww-container { width: 100% !important; }
#viewer-host.md-view-readonly .toastui-editor-md-container { display: none !important; }
.code-view {
  flex: 1;
  margin: 0;
  padding: 1rem 1.25rem;
  overflow: auto;
  font-family: ui-monospace, 'Cascadia Code', monospace;
  font-size: 0.8125rem;
  line-height: 1.55;
  background: #faf9fe;
  border: none;
  tab-size: 2;
}
.code-view[contenteditable="true"] { outline: none; }
.image-view { flex: 1; display: flex; align-items: center; justify-content: center; padding: 1rem; background: var(--color-soft); }
.image-view img { max-width: 100%; max-height: 100%; border-radius: var(--radius-sm); box-shadow: var(--shadow-card); }

.manifestation-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  padding: 0.35rem 0.75rem;
  background: var(--color-soft);
  border-bottom: 1px solid var(--color-border);
}
.manifestation-bar.hidden { display: none; }
.manifestation-chip {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  background: #fff;
  color: var(--color-navy);
  text-decoration: none;
  cursor: pointer;
}
.manifestation-cmd { font-family: inherit; }
.manifestation-hint { font-size: 0.75rem; color: var(--color-muted); }

.html-view-modes { display: inline-flex; gap: 0.15rem; margin-left: auto; }
.html-view-modes.hidden { display: none; }

.artifact-canvas-host {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}
.artifact-canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--color-line);
  background: linear-gradient(90deg, rgba(125, 44, 206, 0.06), rgba(0, 179, 255, 0.04));
}
.artifact-canvas-label {
  font-family: var(--font-display, 'Poppins', sans-serif);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-purple);
}
.artifact-canvas-hint {
  font-size: 0.68rem;
  color: var(--color-muted);
}
.artifact-canvas-split {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}
.artifact-canvas-host.artifact-canvas-preview .artifact-canvas-split {
  flex-direction: row;
}
.artifact-canvas-code {
  flex: 1;
  min-height: 0;
}
.artifact-canvas-frame,
.html-preview-frame {
  flex: 1;
  width: 100%;
  min-height: 320px;
  border: none;
  background: #fff;
}
.artifact-canvas-host.artifact-canvas-preview .artifact-canvas-code {
  flex: 0 0 42%;
  border-right: 1px solid var(--color-line);
  max-width: 50%;
}
.artifact-canvas-host.artifact-canvas-preview .artifact-canvas-frame {
  flex: 1;
}
.html-preview-frame.hidden { display: none; }
#html-code-host.hidden { display: none; }

/* Design Workflow v1 — live progress + canvas focus */
.shell.design-focus .main-col {
  box-shadow: inset 0 0 0 2px rgba(125, 44, 206, 0.35);
}
.artifact-canvas-host.design-active .artifact-canvas-toolbar {
  background: linear-gradient(90deg, rgba(125, 44, 206, 0.12), rgba(0, 179, 255, 0.08));
}
.design-canvas-progress-wrap { flex: 1; min-width: 0; }
.design-canvas-progress {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: rgba(125, 44, 206, 0.1);
  border: 1px solid rgba(125, 44, 206, 0.25);
  font-size: 0.72rem;
  color: var(--color-purple);
}
.design-canvas-progress-pulse {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--color-purple);
  animation: design-pulse 1.2s ease-in-out infinite;
}
@keyframes design-pulse {
  0%, 100% { opacity: 0.35; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.1); }
}
.design-canvas-progress-count {
  font-variant-numeric: tabular-nums;
  color: var(--color-muted);
}

.ai-msg-design-progress { padding: 0.65rem 0.75rem; }
.design-progress-head {
  font-family: var(--font-display, 'Poppins', sans-serif);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--color-purple);
  margin-bottom: 0.4rem;
}
.design-progress-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.design-step {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.75rem;
  color: var(--color-muted);
}
.design-step-active { color: var(--color-ink, #0c1330); font-weight: 500; }
.design-step-active .design-step-icon { color: var(--color-purple); }
.design-step-done { color: var(--color-ink, #0c1330); }
.design-step-done .design-step-icon { color: #16a34a; }
.design-step-error .design-step-icon { color: #dc2626; }
.design-step-icon {
  width: 1rem;
  text-align: center;
  flex-shrink: 0;
}

.server-offline {
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: #fff3f3;
  border: 1px solid #e8a0a0;
  color: #8b1a1a;
  font-size: 0.9rem;
  text-align: left;
  max-width: 36rem;
}
.steward-savings { margin: 0.2rem 0 0; font-size: 0.68rem; color: var(--color-purple); }
.steward-trace { margin: 0.25rem 0 0; font-size: 0.65rem; color: var(--text-muted); }
.steward-trace summary { cursor: pointer; color: var(--color-purple); }
.steward-trace-list { margin: 0.35rem 0 0; padding-left: 1.1rem; max-height: 7rem; overflow: auto; }
.steward-trace-list li { margin-bottom: 0.2rem; line-height: 1.3; }
.ai-msg-steward { border-left: 3px solid var(--color-purple); }
.ai-msg-steward-deep { border-left-color: #7c3aed; opacity: 0.95; }
.ai-msg-guardrail { border-left: 3px solid var(--text-muted); font-style: normal; }
.ai-msg-premium { border-left: 3px solid var(--color-accent, #2563eb); }
.ai-msg-design { border-left: 3px solid var(--color-purple, #7D2CCE); }

.routing-hint-inline { margin: 0 0 0.35rem; font-size: 0.68rem; }
.ai-route-badge {
  margin-top: 0.35rem;
  font-size: 0.62rem;
  color: var(--text-muted);
  font-family: var(--font-mono, monospace);
}
.server-offline.hidden { display: none; }
.server-offline code { font-size: 0.85em; }
.binary-view { padding: 2rem; color: var(--color-muted); text-align: center; }

/* —— AI panel —— */
.ai-panel {
  grid-area: ai;
  background: var(--color-bg);
  border-left: 1px solid var(--color-line);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.ai-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--color-line);
}
.ai-head h3 { font-family: var(--font-display); font-size: 0.95rem; color: var(--color-navy); margin: 0; }

.context-meter { padding: 0.5rem 1rem; border-bottom: 1px solid var(--color-line); background: var(--color-softer); }
.context-meter label {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-display);
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-muted);
  margin-bottom: 0.35rem;
}
.context-bar {
  height: 6px;
  border-radius: 999px;
  background: var(--color-line);
  overflow: hidden;
}
.context-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--gradient-brand);
  transition: width 0.2s;
}
.context-fill.warn { background: linear-gradient(90deg, #e7a405, #e127f4); }
.context-fill.hot { background: #dc2626; }

.attach-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid var(--color-line);
  min-height: 0;
}
.attach-bar:empty { display: none; }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-pill);
  background: var(--color-soft);
  border: 1px solid var(--color-line);
  font-size: 0.68rem;
  font-family: ui-monospace, monospace;
  max-width: 180px;
}
.attach-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip button { border: none; background: none; cursor: pointer; color: var(--color-muted); padding: 0 2px; }

.ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.ai-msg { padding: 0.6rem 0.75rem; border-radius: var(--radius-sm); line-height: 1.45; white-space: pre-wrap; font-size: 0.8125rem; }
.ai-msg-formatted { white-space: normal; }
.ai-msg-user { background: var(--color-soft); align-self: flex-end; max-width: 92%; border: 1px solid var(--color-line); }
.ai-msg-assistant { background: var(--color-softer); align-self: flex-start; max-width: 95%; }
.ai-msg-error { background: #fee2e2; color: #991b1b; }

.ai-msg-md { font-size: inherit; line-height: 1.45; }
.ai-msg-md .toastui-editor-contents { font-size: inherit; }
.ai-msg-md .toastui-editor-contents > *:first-child { margin-top: 0; }
.ai-msg-md .toastui-editor-contents > *:last-child { margin-bottom: 0; }
.ai-msg-md .toastui-editor-contents h1,
.ai-msg-md .toastui-editor-contents h2,
.ai-msg-md .toastui-editor-contents h3 { font-family: var(--font-display); font-weight: 600; margin: 0.65em 0 0.3em; line-height: 1.25; }
.ai-msg-md .toastui-editor-contents h1 { font-size: 1.05em; }
.ai-msg-md .toastui-editor-contents h2 { font-size: 1em; }
.ai-msg-md .toastui-editor-contents h3 { font-size: 0.95em; }
.ai-msg-md .toastui-editor-contents p,
.ai-msg-md .toastui-editor-contents ul,
.ai-msg-md .toastui-editor-contents ol { margin: 0.35em 0; }
.ai-msg-md .toastui-editor-contents ul,
.ai-msg-md .toastui-editor-contents ol { padding-left: 1.25em; }
.ai-msg-md .toastui-editor-contents code {
  font-family: ui-monospace, monospace;
  font-size: 0.9em;
  background: rgba(0, 0, 0, 0.06);
  padding: 0.1em 0.3em;
  border-radius: 3px;
}
.ai-msg-md .toastui-editor-contents pre {
  margin: 0.5em 0;
  padding: 0.5rem 0.65rem;
  background: #0c1330;
  color: #e8ecf8;
  border-radius: var(--radius-sm);
  overflow-x: auto;
  font-size: 0.78em;
}
.ai-msg-md .toastui-editor-contents pre code { background: none; padding: 0; color: inherit; }
.ai-msg-md .toastui-editor-contents blockquote {
  margin: 0.5em 0;
  padding-left: 0.75em;
  border-left: 3px solid var(--color-line);
  color: var(--color-muted);
}
.ai-msg-md .toastui-editor-contents a { color: var(--color-purple); }
.ai-msg-md .toastui-editor-contents table { border-collapse: collapse; font-size: 0.9em; margin: 0.5em 0; }
.ai-msg-md .toastui-editor-contents th,
.ai-msg-md .toastui-editor-contents td { border: 1px solid var(--color-line); padding: 0.25rem 0.45rem; }

.ai-input { padding: 0.75rem; border-top: 1px solid var(--color-line); }
.ai-chat-ctas {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-bottom: 0.5rem;
}
.ai-chat-ctas.hidden { display: none; }
.ai-chat-cta {
  border: 1px solid var(--color-line);
  background: var(--color-soft);
  color: var(--color-navy);
  border-radius: var(--radius-pill);
  padding: 0.28rem 0.65rem;
  font-size: 0.72rem;
  font-family: var(--font-display);
  font-weight: 600;
  cursor: pointer;
}
.ai-chat-cta:hover { border-color: var(--color-purple); color: var(--color-purple); }
.ai-msg-md .ai-chat-cta-link { cursor: pointer; font-weight: 600; }
.ai-input textarea {
  width: 100%;
  border: 1px solid var(--color-line);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.65rem;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  resize: vertical;
  min-height: 72px;
}
.ai-input textarea:focus { outline: none; border-color: var(--color-purple); }
.ai-actions { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-top: 0.5rem; justify-content: flex-end; }

/* —— Terminal —— */
.terminal-panel {
  display: none;
  flex-direction: column;
  height: var(--term-h);
  flex-shrink: 0;
  border-top: 1px solid var(--color-line);
  background: #0c1330;
  color: #c8d0e8;
  font-family: ui-monospace, monospace;
  font-size: 0.75rem;
}
.term-out { flex: 1; overflow-y: auto; padding: 0.5rem 0.75rem; white-space: pre-wrap; }
.term-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.75rem;
  border-top: 1px solid #1e2a4a;
}
.term-prompt { color: var(--color-blue); flex-shrink: 0; }
.term-input-row input {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  font-family: inherit;
  font-size: inherit;
  outline: none;
}

/* —— Mobile bottom nav —— */
.mob-nav {
  display: none;
  height: var(--mob-nav-height);
  border-top: 1px solid var(--color-line);
  background: var(--color-bg);
  grid-column: 1 / -1;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 40;
}
.mob-nav button {
  flex: 1;
  border: none;
  background: none;
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.68rem;
  color: var(--color-muted);
  padding: 0.35rem;
  cursor: pointer;
}
.mob-nav button.active { color: var(--color-purple); }

dialog {
  border: none;
  border-radius: var(--radius-md);
  padding: 1.5rem;
  max-width: 440px;
  box-shadow: var(--shadow-card);
}
dialog h2 { font-family: var(--font-display); color: var(--color-navy); margin: 0 0 1rem; font-size: 1.1rem; }
dialog label { display: block; margin-bottom: 0.85rem; font-size: 0.8125rem; font-weight: 500; }
dialog input { width: 100%; margin-top: 0.35rem; padding: 0.5rem; border: 1px solid var(--color-line); border-radius: var(--radius-sm); }
.dialog-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }

@media (max-width: 900px) {
  .north-star { display: none; }
  .shell,
  .shell.ai-open {
    display: block;
    height: calc(100vh - var(--nav-height) - var(--mob-nav-height));
  }
  .panel-resize { display: none !important; }
  .main-col { height: 100%; }
  .sidebar, .ai-panel {
    display: none;
    position: fixed;
    top: var(--nav-height);
    left: 0;
    right: 0;
    bottom: var(--mob-nav-height);
    z-index: 25;
  }
  .sidebar.mobile-show, .ai-panel.mobile-show { display: flex; }
  .mob-nav { display: flex; }
  .topbar-actions .btn-ghost:not(#btn-settings) { display: none; }
  body { padding-bottom: var(--mob-nav-height); }
}

@media (min-width: 901px) {
  .mob-nav { display: none; height: 0; }
  .shell { height: calc(100vh - var(--nav-height)); }
}
