:root {
  --bg: #14161a;
  --bg-raised: #1a1d23;
  --bg-inset: #101216;
  --border: #262a33;
  --border-strong: #333947;
  --text: #dfe3ea;
  --text-dim: #8b93a3;
  --text-faint: #626b7c;
  --accent: #d97757;
  --accent-dim: #8a4a34;
  --ok: #4ea672;
  --err: #d05a5a;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --font-mono: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  --explorer-w: 240px;
  --assistant-w: 420px;
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  display: flex;
  flex-direction: column;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

.spacer {
  flex: 1;
}

/* ---------------------------------------------------------- titlebar */

.titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 36px;
  padding: 0 12px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.logo {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.workspace-name {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.model-badge {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 11px;
}

/* Who is signed in, at the right-hand end of the titlebar. */
.account {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.account-email {
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11.5px;
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The titlebar is 36px tall; the page-level button padding is too tall for it. */
.account .ghost-btn {
  padding: 4px 10px;
  font-size: 11.5px;
}

.account [hidden] { display: none; }

/* ------------------------------------------------------------ layout */

.layout {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: var(--explorer-w) 4px 1fr 4px var(--assistant-w);
}

/* `display: grid` outranks the hidden attribute's display: none. */
.layout[hidden] {
  display: none;
}

.pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.splitter {
  background: var(--border);
  cursor: col-resize;
  transition: background 0.12s;
}

.splitter:hover,
.splitter.dragging {
  background: var(--accent-dim);
}

.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 30px;
  padding: 0 6px 0 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
}

.pane-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}

.pane-actions button {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1;
}

.pane-actions button:hover {
  background: var(--border);
  color: var(--text);
}

/* ---------------------------------------------------------- explorer */

.explorer {
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
}

.tree {
  flex: 1;
  overflow: auto;
  padding: 6px 0 20px;
}

.tree ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree li > .row {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px 3px calc(8px + var(--depth, 0) * 12px);
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-dim);
  border-left: 2px solid transparent;
}

.tree li > .row:hover {
  background: #1f232b;
  color: var(--text);
}

.tree li > .row.active {
  background: #232833;
  color: var(--text);
  border-left-color: var(--accent);
}

.tree li > .row.changed {
  animation: flash 1.1s ease-out;
}

@keyframes flash {
  from {
    background: var(--accent-dim);
  }
}

.tree .caret {
  width: 10px;
  color: var(--text-faint);
  font-size: 9px;
  flex: 0 0 auto;
}

.tree .icon {
  flex: 0 0 auto;
  opacity: 0.75;
}

.tree li.collapsed > ul {
  display: none;
}

/* ------------------------------------------------------------ editor */

.editor-pane {
  background: var(--bg-inset);
}

.tabs {
  display: flex;
  height: 32px;
  overflow-x: auto;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex: 0 0 auto;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 8px 0 12px;
  border-right: 1px solid var(--border);
  color: var(--text-faint);
  cursor: pointer;
  white-space: nowrap;
  font-size: 12px;
  border-top: 2px solid transparent;
}

.tab:hover {
  color: var(--text-dim);
}

.tab.active {
  background: var(--bg-inset);
  color: var(--text);
  border-top-color: var(--accent);
}

.tab .close {
  width: 16px;
  height: 16px;
  border-radius: 3px;
  font-size: 11px;
  line-height: 16px;
  text-align: center;
  opacity: 0;
}

.tab:hover .close,
.tab.active .close {
  opacity: 0.6;
}

.tab .close:hover {
  background: var(--border-strong);
  opacity: 1;
}

.tab.dirty .close::before {
  content: "●";
}

.tab.dirty .close:hover::before {
  content: "✕";
}

.tab:not(.dirty) .close::before {
  content: "✕";
}

.editor-host {
  flex: 1;
  min-height: 0;
  position: relative;
}

.empty-editor {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-faint);
  pointer-events: none;
}

.empty-editor .hint {
  font-size: 12px;
  color: #4b5361;
}

/* ---------------------------------------------------- terminal dock */

.terminal-dock {
  --term-h: 220px;
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: #0d0f13;
  height: 26px;
  position: relative;
}

.terminal-dock.open {
  height: var(--term-h);
}

.term-resize {
  position: absolute;
  top: -3px;
  left: 0;
  right: 0;
  height: 6px;
  cursor: row-resize;
  z-index: 2;
}

.terminal-dock:not(.open) .term-resize {
  display: none;
}

.term-resize:hover {
  background: var(--accent-dim);
}

.term-head {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 26px;
  flex: 0 0 auto;
  padding: 0 6px 0 8px;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
}

.term-tab {
  padding: 3px 10px;
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-faint);
}

.term-tab:hover {
  color: var(--text-dim);
}

.term-tab.active {
  background: #0d0f13;
  color: var(--text);
}

.term-tab.busy::after {
  content: " ●";
  color: var(--accent);
  animation: blink 1s steps(2) infinite;
}

.term-head button:not(.term-tab) {
  width: 22px;
  height: 20px;
  border-radius: 4px;
  color: var(--text-faint);
  font-size: 11px;
}

.term-head button:not(.term-tab):hover {
  background: var(--border);
  color: var(--text);
}

.term-body {
  flex: 1;
  min-height: 0;
  position: relative;
}

.terminal-dock:not(.open) .term-body {
  display: none;
}

.term-view {
  position: absolute;
  inset: 0;
  padding: 4px 6px;
}

.term-view[hidden] {
  display: none;
}

/* -------------------------------------------------------- services */

.term-tab.has-running::after {
  content: " ●";
  color: var(--ok);
}

.term-tab.has-failure::after {
  content: " ●";
  color: var(--err);
}

.services-view {
  display: flex;
  padding: 0;
  font-size: 11.5px;
}

.services-view[hidden] {
  display: none;
}

.svc-sidebar {
  width: 190px;
  flex: 0 0 auto;
  overflow-y: auto;
  border-right: 1px solid var(--border);
  padding-bottom: 8px;
}

.svc-section {
  padding: 6px 10px 3px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.svc-empty {
  padding: 2px 10px 6px;
  color: #4b5361;
  font-size: 11px;
}

.svc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 4px 10px;
  text-align: left;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  border-left: 2px solid transparent;
}

.svc-row:hover {
  background: #1a1d23;
  color: var(--text);
}

.svc-row.active {
  background: #232833;
  color: var(--text);
  border-left-color: var(--accent);
}

.svc-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.svc-count,
.svc-apply {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--text-faint);
}

.svc-row.manifest .svc-apply {
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 0 5px;
}

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: 0 0 auto;
  background: var(--text-faint);
}

.dot.ok {
  background: var(--ok);
}

.dot.warn {
  background: var(--accent);
  animation: blink 1.4s steps(2) infinite;
}

.dot.err {
  background: var(--err);
}

.dot.idle {
  background: #4b5361;
}

.svc-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.svc-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.svc-head.empty {
  color: var(--text-faint);
  font-size: 11px;
}

.svc-phase {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}

.svc-phase.ok {
  color: var(--ok);
  border-color: #2c5a41;
}

.svc-phase.err {
  color: var(--err);
  border-color: #4a2a2a;
}

.svc-phase.warn {
  color: var(--accent);
  border-color: var(--accent-dim);
}

.svc-title {
  font-family: var(--font-mono);
  color: var(--text);
  font-weight: 600;
}

.svc-meta,
.svc-message {
  font-size: 10.5px;
  color: var(--text-faint);
}

.svc-message {
  color: var(--err);
}

.svc-url {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-dim);
}

.svc-btn {
  flex: 0 0 auto;
  font-size: 10.5px;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
}

.svc-btn:hover {
  background: var(--border);
  color: var(--text);
}

.svc-btn.start:hover {
  border-color: var(--ok);
  color: var(--ok);
}

.svc-btn.stop:hover,
.svc-btn.remove:hover {
  border-color: var(--err);
  color: var(--err);
}

.svc-logs {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 5px 0 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.45;
}

.log-line {
  display: flex;
  gap: 8px;
  padding: 0 10px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--text-dim);
}

.log-line:hover {
  background: #16191f;
}

.log-replica {
  flex: 0 0 auto;
  width: 92px;
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: right;
  opacity: 0.75;
}

.log-line.stderr {
  color: #e0a0a0;
}

.log-line.system {
  color: var(--accent);
}

.statusbar {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 24px;
  padding: 0 12px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-faint);
  background: var(--bg-raised);
  border-top: 1px solid var(--border);
  flex: 0 0 auto;
}

.status-save.saving {
  color: var(--accent);
}

.status-save.saved {
  color: var(--ok);
}

/* --------------------------------------------------------- assistant */

.assistant {
  background: var(--bg-raised);
  border-left: 1px solid var(--border);
}

.toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text-faint);
  cursor: pointer;
  padding: 0 4px;
}

.toggle input {
  accent-color: var(--accent);
  margin: 0;
}

.toggle:has(input:checked) {
  color: var(--accent);
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.welcome {
  color: var(--text-faint);
  padding: 20px 4px;
}

.welcome h2 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--text-dim);
}

.welcome p {
  margin: 0 0 16px;
  line-height: 1.5;
}

.examples {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.example {
  text-align: left;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.4;
}

.example:hover {
  border-color: var(--border-strong);
  background: #1f232b;
  color: var(--text);
}

.msg {
  display: flex;
  flex-direction: column;
  gap: 8px;
  animation: rise 0.18s ease-out;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(3px);
  }
}

.msg.user .bubble {
  align-self: flex-end;
  max-width: 90%;
  background: #232833;
  border: 1px solid var(--border-strong);
  border-radius: 10px 10px 2px 10px;
  padding: 8px 11px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg.assistant .bubble {
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.bubble > :first-child {
  margin-top: 0;
}

.bubble > :last-child {
  margin-bottom: 0;
}

.bubble p {
  margin: 0 0 8px;
}

.bubble ul,
.bubble ol {
  margin: 0 0 8px;
  padding-left: 20px;
}

.bubble li {
  margin: 2px 0;
}

.bubble h1,
.bubble h2,
.bubble h3 {
  font-size: 13px;
  margin: 12px 0 6px;
}

.bubble code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
}

.bubble pre {
  margin: 0 0 8px;
  padding: 9px 11px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow-x: auto;
}

.bubble pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 11.5px;
  line-height: 1.5;
}

.bubble a {
  color: var(--accent);
}

.bubble .fileref {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  cursor: pointer;
  border-bottom: 1px dotted var(--accent-dim);
}

/* thinking */

.thinking {
  border-left: 2px solid var(--border-strong);
  padding-left: 10px;
}

.thinking summary {
  cursor: pointer;
  color: var(--text-faint);
  font-size: 11px;
  list-style: none;
  user-select: none;
}

.thinking summary::-webkit-details-marker {
  display: none;
}

.thinking summary::before {
  content: "▸ ";
}

.thinking[open] summary::before {
  content: "▾ ";
}

.thinking .body {
  margin-top: 6px;
  color: var(--text-faint);
  font-size: 11.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  max-height: 260px;
  overflow-y: auto;
}

/* tool chips */

.tool {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 5px 9px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.tool .name {
  color: var(--text);
  flex: 0 0 auto;
}

.tool .arg {
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.tool .state {
  flex: 0 0 auto;
  font-size: 10px;
}

.tool.running .state::after {
  content: "running…";
  color: var(--accent);
}

.tool.ok .state::after {
  content: "✓";
  color: var(--ok);
}

.tool.err {
  border-color: #4a2a2a;
}

.tool.err .state::after {
  content: "✕";
  color: var(--err);
}

.tool .diff-btn {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--accent);
  border: 1px solid var(--accent-dim);
  border-radius: 3px;
  padding: 1px 6px;
}

.tool .diff-btn:hover {
  background: var(--accent-dim);
  color: #fff;
}

.stat-add {
  color: var(--ok);
}

.stat-del {
  color: var(--err);
}

.error-bubble {
  padding: 8px 11px;
  border: 1px solid #4a2a2a;
  background: #241a1a;
  border-radius: 6px;
  color: #e5a0a0;
  font-size: 12px;
  line-height: 1.5;
}

.cursor-dot {
  display: inline-block;
  width: 7px;
  height: 13px;
  background: var(--accent);
  vertical-align: text-bottom;
  animation: blink 1s steps(2) infinite;
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* --------------------------------------------------------- composer */

.composer {
  flex: 0 0 auto;
  border-top: 1px solid var(--border);
  padding: 8px 10px 10px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  background: var(--bg-raised);
}

.context-chip {
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 7px;
}

.composer textarea {
  width: 100%;
  resize: none;
  max-height: 180px;
  padding: 9px 11px;
  font: inherit;
  line-height: 1.45;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  outline: none;
}

.composer textarea:focus {
  border-color: var(--accent-dim);
}

.composer textarea::placeholder {
  color: var(--text-faint);
}

.composer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.usage {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-faint);
}

#send-btn {
  padding: 5px 14px;
  border-radius: 6px;
  background: var(--accent);
  color: #14161a;
  font-weight: 600;
  font-size: 12px;
}

#send-btn:hover {
  filter: brightness(1.08);
}

#send-btn:disabled {
  opacity: 0.4;
  cursor: default;
  filter: none;
}

.stop {
  padding: 5px 12px;
  border-radius: 6px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 12px;
}

.stop:hover {
  border-color: var(--err);
  color: var(--err);
}

/* ------------------------------------------------------------ modal */

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}

.modal[hidden] {
  display: none;
}

.modal-box {
  width: min(1100px, 92vw);
  height: min(680px, 86vh);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  height: 36px;
  padding: 0 8px 0 14px;
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-raised);
}

.modal-head button {
  margin-left: auto;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  color: var(--text-dim);
}

.modal-head button:hover {
  background: var(--border);
  color: var(--text);
}

.diff-host {
  flex: 1;
  min-height: 0;
}

/* --------------------------------------------------------- scrollbar */

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: #2c313b;
  border-radius: 5px;
  border: 2px solid var(--bg-raised);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--border-strong);
}

::-webkit-scrollbar-track {
  background: transparent;
}

/* --------------------------------------------------------- view nav */

.view-nav {
  display: flex;
  gap: 2px;
  margin-left: 6px;
}

.view-btn {
  padding: 3px 11px;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-faint);
}

.view-btn:hover {
  color: var(--text-dim);
  background: var(--border);
}

.view-btn.active {
  background: var(--border-strong);
  color: var(--text);
}

/* --------------------------------------------------- practice page */

.practice {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  background: var(--bg);
}

.practice[hidden] {
  display: none;
}

.practice-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 34px 28px 80px;
}

.practice-title {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.practice-lede {
  margin: 0 0 26px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.55;
}

.back-link {
  color: var(--text-faint);
  font-size: 12px;
  padding: 0 0 14px;
  display: block;
}

.back-link:hover {
  color: var(--accent);
}

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  margin-bottom: 16px;
}

.panel-title {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text);
}

.panel-hint {
  margin: 0 0 12px;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.5;
}

.panel-body {
  color: var(--text-dim);
  font-size: 13.5px;
  line-height: 1.62;
}

.panel-body > :first-child { margin-top: 0; }
.panel-body > :last-child { margin-bottom: 0; }
.panel-body p { margin: 0 0 10px; }
.panel-body ul, .panel-body ol { margin: 0 0 10px; padding-left: 20px; }
.panel-body li { margin: 4px 0; }
.panel-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 4px;
}
.panel-body pre {
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  overflow-x: auto;
  margin: 0 0 10px;
}
.panel-body pre code { background: none; border: none; padding: 0; }

/* connect form */

.connect-form {
  display: flex;
  gap: 8px;
}

.connect-input {
  flex: 1;
  padding: 8px 11px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  outline: none;
}

.connect-input:focus {
  border-color: var(--accent-dim);
}

.connect-input::placeholder {
  color: var(--text-faint);
  font-family: var(--font-mono);
  font-size: 12px;
}

.primary-btn {
  flex: 0 0 auto;
  padding: 7px 15px;
  border-radius: 7px;
  background: var(--accent);
  color: #14161a;
  font-weight: 600;
  font-size: 12.5px;
}

.primary-btn:hover { filter: brightness(1.08); }

.cta-btn {
  display: block;
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  text-align: center;
}

.ghost-btn {
  padding: 7px 13px;
  border-radius: 7px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-size: 12.5px;
}

.ghost-btn:hover { background: var(--border); color: var(--text); }
.ghost-btn.danger:hover { border-color: var(--err); color: var(--err); background: none; }

/* repo cards */

.repo-card {
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 14px 15px;
  margin-bottom: 12px;
  background: var(--bg-inset);
}

.repo-card:last-child { margin-bottom: 0; }

.repo-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 7px;
}

.repo-name {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text);
  font-weight: 600;
}

.repo-lang, .repo-meta {
  font-size: 11px;
  color: var(--text-faint);
}

.repo-summary {
  margin: 0 0 8px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
}

.repo-meta {
  display: flex;
  gap: 12px;
  margin-bottom: 4px;
}

.repo-details summary {
  cursor: pointer;
  font-size: 11.5px;
  color: var(--text-faint);
  padding: 6px 0;
  list-style: none;
}

.repo-details summary::-webkit-details-marker { display: none; }
.repo-details summary::before { content: "▸ "; }
.repo-details[open] summary::before { content: "▾ "; }
.repo-details summary:hover { color: var(--accent); }

.repo-details-body {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-faint);
  padding: 4px 0 2px;
}

.repo-details-body code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-dim);
}

.repo-details-body ul { padding-left: 18px; margin: 6px 0; }

/* pull request list */

.filter-row { display: flex; gap: 8px; margin-bottom: 14px; }

.filter-btn {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
  font-size: 12px;
}

.filter-btn:hover { color: var(--text-dim); }

.filter-btn.active {
  background: var(--accent-dim);
  border-color: var(--accent-dim);
  color: #fff;
}

.pr-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 11px 4px;
  border-bottom: 1px solid var(--border);
}

.pr-row:last-child { border-bottom: none; }
.pr-main { flex: 1; min-width: 0; }

.pr-number {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
  margin-right: 7px;
}

.pr-title { font-size: 13px; color: var(--text); }

.pr-meta {
  display: flex;
  gap: 11px;
  margin-top: 4px;
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
}

/* challenge view */

.challenge-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.challenge-time { font-size: 11.5px; color: var(--text-faint); }

.challenge-source {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-dim);
}

.challenge-actions { display: flex; gap: 8px; margin: 18px 0 10px; }

.scaffold-note {
  margin: 0 0 22px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--text-faint);
}

.challenge-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border);
}

.challenge-row:last-child { border-bottom: none; }
.challenge-row:hover .challenge-name { color: var(--accent); }
.challenge-name { flex: 1; font-size: 13px; color: var(--text); }

.challenge-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
}

.pill {
  flex: 0 0 auto;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 2px 7px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  color: var(--text-faint);
}

.pill.easy { color: var(--ok); border-color: #2c5a41; }
.pill.medium { color: var(--accent); border-color: var(--accent-dim); }
.pill.hard { color: var(--err); border-color: #4a2a2a; }

.hints summary {
  cursor: pointer;
  font-size: 12.5px;
  color: var(--text-faint);
  list-style: none;
}

.hints summary::-webkit-details-marker { display: none; }
.hints summary::before { content: "▸ "; }
.hints[open] summary::before { content: "▾ "; }
.hints summary:hover { color: var(--accent); }
.hints .panel-body { margin-top: 10px; }

/* diff */

.diff-block {
  margin: 10px 0 0;
  padding: 10px 0;
  background: var(--bg-inset);
  border: 1px solid var(--border);
  border-radius: 7px;
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 11.5px;
  line-height: 1.5;
  max-height: 460px;
  overflow-y: auto;
}

.diff-line { padding: 0 12px; white-space: pre; color: var(--text-dim); }
.diff-line.add { background: #16291d; color: #8fce9f; }
.diff-line.del { background: #2a1a1a; color: #e0a0a0; }
.diff-line.hunk { color: var(--accent); }
.diff-line.meta { color: var(--text-faint); }

/* notices + progress */

.notice {
  padding: 10px 13px;
  border-radius: 7px;
  font-size: 12.5px;
  line-height: 1.5;
  margin-bottom: 14px;
}

.notice.err { border: 1px solid #4a2a2a; background: #241a1a; color: #e5a0a0; }
.notice.idle { border: 1px solid var(--border); background: var(--bg-raised); color: var(--text-faint); }
.notice code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  padding: 1px 5px;
}

.progress-line {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--text-dim);
}

.spinner {
  width: 11px;
  height: 11px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: 0 0 auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* -------------------------------------------------- workspaces page */

.repo-card.active-workspace { border-color: var(--accent-dim); }

.capability-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 4px;
}

.cap-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 12px;
  border: 1px solid var(--border);
  color: var(--text-faint);
}

.cap-chip.on { color: var(--ok); border-color: #2c5a41; }
.cap-mark { font-size: 10px; opacity: 0.9; }

.ws-actions { display: flex; gap: 7px; margin-top: 12px; }

.share-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.share-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
}

.share-form { display: flex; flex-direction: column; gap: 11px; }

.capability-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 7px;
}

.capability {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 7px;
  cursor: pointer;
  background: var(--bg-raised);
}

.capability:hover { border-color: var(--border-strong); }
.capability:has(input:checked) { border-color: var(--accent-dim); background: #23201e; }
.capability input { accent-color: var(--accent); margin-top: 2px; }
.capability-text { display: flex; flex-direction: column; gap: 2px; }
.capability-label { font-size: 12.5px; color: var(--text); }
.capability-hint { font-size: 11px; color: var(--text-faint); line-height: 1.4; }

.share-form .primary-btn { align-self: flex-start; }

.member-list { margin-top: 14px; }

.member-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.member-email {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text);
  flex: 0 0 auto;
}

.member-caps { flex: 1; font-size: 11.5px; color: var(--text-faint); }

/* permission-driven IDE chrome */

.composer.disabled textarea { opacity: 0.55; cursor: not-allowed; }
.term-tab[hidden] { display: none; }
.toggle[hidden] { display: none; }

/* --------------------------------------------- generate-from-PR modal */

.pr-modal-box {
  width: min(820px, 94vw);
  height: min(760px, 90vh);
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pr-modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 22px 26px;
}

.pr-modal-body .panel-hint { margin-bottom: 16px; }

.pr-select-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.pr-select-label {
  font-size: 12px;
  color: var(--text-faint);
  flex: 0 0 auto;
}

.pr-select {
  flex: 1;
  padding: 8px 11px;
  font: inherit;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  outline: none;
  cursor: pointer;
}

.pr-select:focus { border-color: var(--accent-dim); }

.pr-connect {
  padding: 13px 14px;
  border: 1px solid var(--accent-dim);
  border-radius: 9px;
  background: var(--bg-raised);
  margin-bottom: 16px;
}

.pr-connect .panel-hint { margin: 10px 0 0; }

.pr-list {
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--bg-raised);
  padding: 2px 14px;
}

.pr-list-wrap { margin-top: 4px; }

.challenge-view .panel { background: var(--bg-raised); }

.challenge-title {
  margin: 4px 0 2px;
  font-size: 17px;
  font-weight: 600;
}

.pr-result .notice.ok {
  border: 1px solid #2c5a41;
  background: #16241d;
  color: #8fce9f;
}

.notice.ok {
  border: 1px solid #2c5a41;
  background: #16241d;
  color: #8fce9f;
}

/* ---------------------------------- workspace description + generation */

.ws-description {
  margin: 2px 0 8px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-dim);
}

.ws-source {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 11px;
}

.ws-source-pr {
  font-family: var(--font-mono);
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-dim);
  flex: 0 0 auto;
}

.ws-source-title {
  color: var(--text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 340px;
}

.ws-source-tag {
  color: var(--text-faint);
  font-family: var(--font-mono);
}

.gen-row {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--bg-raised);
}

.gen-row.running { border-color: var(--accent-dim); }
.gen-row.done { border-color: #2c5a41; }
.gen-row.error { border-color: #4a2a2a; background: #241a1a; }

.gen-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gen-title { font-size: 12.5px; color: var(--text); }

.gen-message {
  font-size: 11px;
  color: var(--text-faint);
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gen-row.error .gen-message { color: #e0a0a0; }
.gen-row .primary-btn,
.gen-row .ghost-btn { flex: 0 0 auto; padding: 5px 11px; font-size: 11.5px; }

/* ------------------------------------------------ workspace action modals */

.app-modal-box {
  width: min(520px, 94vw);
  /* .modal-box sets a fixed height for the diff viewer; these size to content. */
  height: auto;
  max-height: 88vh;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 11px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-modal-form {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.app-modal-body {
  padding: 18px 20px;
  overflow-y: auto;
  min-height: 0;
}

.app-modal-subtitle {
  margin: 0 0 16px;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--text-faint);
}

.app-modal-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: var(--bg-raised);
  flex: 0 0 auto;
}

.app-modal-footer .primary-btn:disabled {
  opacity: 0.4;
  cursor: default;
  filter: none;
}

.primary-btn.danger {
  background: var(--err);
  color: #14161a;
}

.modal-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Several fields stacked in one modal, e.g. Edit workspace. */
.modal-fields {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.modal-para {
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-dim);
}

.modal-hint {
  align-self: flex-end;
  font-size: 10.5px;
  font-family: var(--font-mono);
  color: var(--text-faint);
}

.modal-textarea {
  width: 100%;
  resize: vertical;
  padding: 9px 11px;
  font: inherit;
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg-inset);
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  outline: none;
}

.modal-textarea:focus { border-color: var(--accent-dim); }
.modal-textarea::placeholder { color: var(--text-faint); }

.invite-link {
  font-family: var(--font-mono);
  font-size: 11px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
  padding: 2px 5px;
  margin: 0 6px;
  word-break: break-all;
}

.notice.ok .ghost-btn { padding: 2px 9px; font-size: 11px; }

/* workspaces toolbar */

.ws-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.ws-toolbar-count {
  font-size: 12px;
  color: var(--text-faint);
}

/* ------------------------------------------------- sandbox preview bar */

.svc-preview {
  display: flex;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  padding: 7px 10px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-raised);
  font-size: 11.5px;
}

.svc-preview[hidden] { display: none; }

.preview-label {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.preview-url {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted var(--accent-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 46%;
}

.preview-state {
  font-size: 9.5px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 1px 6px;
  border-radius: 9px;
  border: 1px solid currentColor;
}

.preview-state.public { color: var(--ok); }
.preview-state.private { color: var(--text-faint); }

/* sandbox chip in the title bar */

.sandbox-chip {
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--text-faint);
  padding: 2px 7px;
  border: 1px solid var(--border);
  border-radius: 4px;
}

.sandbox-chip.remote { color: var(--accent); border-color: var(--accent-dim); }

/* --------------------------------------------------------- sign-in */

.signin-providers { display: flex; flex-direction: column; gap: 8px; margin-bottom: 14px; }

.provider-btn {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 7px;
  color: var(--text);
  font-size: 13px;
  text-align: center;
}

.provider-btn:hover { background: var(--border); border-color: var(--text-faint); }

.signin-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 4px 0 14px;
  font-size: 11px;
  color: var(--text-faint);
}

.signin-divider::before,
.signin-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.signin-form { display: flex; flex-direction: column; gap: 8px; }
.signin-form .primary-btn { align-self: stretch; padding: 9px; }

.signin-links {
  display: flex;
  gap: 16px;
  margin-top: 12px;
}

.link-btn {
  font-size: 12px;
  color: var(--text-faint);
  padding: 0;
}

.link-btn:hover { color: var(--accent); text-decoration: underline; }

