/* projects#show — workspace shell: switcher rail + main column */
.workspace {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ---- Status-switcher rail -------------------------------------------- */
.switcher {
  flex-shrink: 0;
  width: 14rem;
  border-inline-end: 1px solid var(--color-border);
  background-color: var(--color-surface);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-4);
  overflow-y: auto;
}

@media (max-width: 48rem) {
  .switcher { display: none; }
}

.switcher-brand {
  font-size: 1.35rem;
  text-decoration: none;
}

.switcher-projects {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.switcher-project {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2);
  border-radius: var(--radius);
  border: 1px solid transparent;
  text-decoration: none;
  color: inherit;
}

.switcher-project .status-dot { flex-shrink: 0; }

.switcher-project.is-current {
  border-color: oklch(from var(--color-accent) l c h / 0.35);
  background: oklch(from var(--color-accent) l c h / 0.06);
}

.switcher-project-name {
  min-width: 0;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Status dots (switcher + index rows) ----------------------------- */
.status-dot {
  --dot: var(--color-muted);
  display: inline-block;
  inline-size: 0.7rem;
  block-size: 0.7rem;
  border-radius: 999px;
  background: var(--dot);
  box-shadow: 0 0 0 1px oklch(from var(--dot) l c h / 0.3);
}

a.status-dot { cursor: pointer; }
.status-dot.is-active { outline: 2px solid var(--color-ink); outline-offset: 1px; }
.status-dot-working { --dot: var(--color-warning); animation: pulse 1.6s ease-in-out infinite; }
.status-dot-ready   { --dot: var(--color-positive); }
.status-dot-failed  { --dot: var(--color-negative); }
.status-dot-empty   { --dot: var(--color-border); box-shadow: none; }

/* ---- Main column ----------------------------------------------------- */
.workspace-main {
  position: relative;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.workspace-header {
  position: relative;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* Title group: back-link, status dot, then the truncating title. Sits under
   the action bar (lower z-index) so a long title never overlaps the controls. */
.workspace-heading {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.workspace-title {
  min-width: 0;
  font-size: clamp(1.15rem, 4vw, 1.5rem);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-heading .status-dot { flex-shrink: 0; }

/* Action bar: chat/preview toggle + options menu, grouped on the title row. */
.workspace-actions {
  position: relative;
  z-index: 2;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* Back link styled as a subtle button so it reads as tappable at any size. */
.back-link {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.875rem;
  color: var(--color-muted);
  text-decoration: none;
  padding: var(--space-1) var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 999px;
}

.back-link:hover {
  color: var(--color-ink);
  border-color: oklch(from var(--color-ink) l c h / 0.4);
}

.back-arrow { line-height: 1; }

@media (max-width: 48rem) {
  .back-label { display: none; }
}

/* Wrapper for the toggle + whichever panel is active. */
.task-view {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* Conversation panel: scrolls within its allocated space. The bottom padding
   clears the floating composer so the last message isn't hidden behind it. */
.conversation-view {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-block-end: 12rem;   /* always scroll the last message clear of the composer */
}

.workspace-main.chat-hidden .conversation-view { padding-block-end: var(--space-6); }

/* ---- Turns ------------------------------------------------------------ */
/* Centered chat column, aligned to the composer's max-width. */
.conversation-view > * {
  inline-size: 100%;
  max-inline-size: 42rem;
  margin-inline: auto;
}

/* No card container — the conversation reads as a chat. */
.turn {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* User prompt: right-aligned bubble, normal body colour. */
.turn-prompt {
  align-self: flex-end;
  max-inline-size: 85%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-radius: 1.25rem;
  color: var(--color-ink);
}

.turn-entries {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

/* Queued turn: muted, awaiting the running turn to finish. */
.turn-queued {
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 0.8rem;
  color: var(--color-muted);
}

.turn-cancel.turn-cancel {
  inline-size: auto;
  padding: 0.1rem 0.5rem;
  font-size: 0.75rem;
  color: var(--color-muted);
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  cursor: pointer;
}

/* ---- Entry base ------------------------------------------------------- */
.entry {
  overflow-wrap: anywhere;
}

/* ---- Assistant message ----------------------------------------------- */
.entry-assistant p { margin-block: var(--space-2); }
.entry-assistant p:first-child { margin-block-start: 0; }
.entry-assistant p:last-child { margin-block-end: 0; }

/* ---- Tool use: compact collapsible ------------------------------------ */
.entry-tool-use summary {
  cursor: pointer;
  list-style: none;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--color-muted);
  padding: var(--space-1) 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.entry-tool-use summary::-webkit-details-marker { display: none; }
.entry-tool-use summary::before { content: "▶ "; font-size: 0.6rem; opacity: 0.6; }
.entry-tool-use[open] summary::before { content: "▼ "; }

.entry-tool-output {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--color-muted);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  padding: var(--space-2) 0;
  max-block-size: 14rem;
  overflow-y: auto;
  margin: 0;
}

/* ---- Thinking: collapsed by default ----------------------------------- */
.entry-thinking summary {
  cursor: pointer;
  list-style: none;
  font-size: 0.9rem;
  color: var(--color-muted);
  padding: var(--space-1) 0;
}

.entry-thinking summary::-webkit-details-marker { display: none; }
.entry-thinking summary::after { content: " ⌄"; opacity: 0.7; }
.entry-thinking[open] summary::after { content: " ⌃"; }

/* Expanded reasoning sits behind a left rail (Claude-style). */
.entry-thinking-bodies {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-block-start: var(--space-2);
  margin-inline-start: var(--space-2);
  padding-inline-start: var(--space-4);
  border-inline-start: 2px solid var(--color-border);
}

.entry-thinking-body {
  font-size: 0.9rem;
  color: var(--color-muted);
  white-space: pre-wrap;
}

/* ---- System message (non-noise only) ---------------------------------- */
.entry-system small {
  font-size: 0.72rem;
  color: var(--color-muted);
  font-style: italic;
}

/* ---- Status badges ---------------------------------------------------- */
.task-status-running {
  animation: pulse 1.6s ease-in-out infinite;
}

@keyframes pulse {
  50% { opacity: 0.45; }
}

/* ---- Conversation/Preview segmented toggle ---------------------------- */
/* Gradient ring to match the index disclosure / brand styling. */
.view-toggle {
  display: inline-flex;
  flex-shrink: 0;
  block-size: 2.25rem;       /* total height matches the round buttons (border-box) */
  gap: 0;
  padding: 0;
  border: 1.5px solid transparent;
  border-radius: 999px;
  background:
    linear-gradient(var(--color-bg), var(--color-bg)) padding-box,
    linear-gradient(120deg, #f43f5e, #f59e0b) border-box;
}

/* Reload-preview button — circular, same gradient ring as the disclosure. */
.workspace-actions .reload-btn {
  display: none;   /* only the preview reloads — shown in preview mode (below) */
  align-items: center;
  justify-content: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  padding: 0;
  border: 1.5px solid transparent;
  border-radius: 999px;
  color: #f43f5e;
  cursor: pointer;
  background:
    linear-gradient(var(--color-bg), var(--color-bg)) padding-box,
    linear-gradient(120deg, #f43f5e, #f59e0b) border-box;
}

.workspace-main.preview-mode .reload-btn { display: inline-flex; }

.workspace-actions .reload-btn:hover {
  background:
    linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
    linear-gradient(120deg, #f43f5e, #f59e0b) border-box;
}

/* Disclosure "•••" in the action bar gets the same gradient ring. */
.workspace-actions .menu-trigger {
  border: 1.5px solid transparent;
  color: #f43f5e;
  background:
    linear-gradient(var(--color-bg), var(--color-bg)) padding-box,
    linear-gradient(120deg, #f43f5e, #f59e0b) border-box;
}

.workspace-actions .menu-trigger:hover {
  background:
    linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
    linear-gradient(120deg, #f43f5e, #f59e0b) border-box;
}

/* Scoped under .view-toggle so these beat the global `button:not(.btn)` rule. */
.view-toggle .toggle-btn {
  flex: 1;                   /* each segment fills exactly half the capsule */
  block-size: 100%;          /* fill the capsule (height set on .view-toggle) */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 var(--space-4);
  background: transparent;
  border: none;
  border-radius: 0;          /* square inner edge accentuates the divider */
  color: #f43f5e;            /* inactive icon — matches the refresh button */
}

/* Outer corners follow the capsule; the shared inner edge stays square. */
.view-toggle .toggle-btn:first-child { border-radius: 999px 0 0 999px; }
.view-toggle .toggle-btn:last-child  { border-radius: 0 999px 999px 0; }

/* Active segment fills its full half with the rose→amber brand gradient; its
   icon is "cut out" to the page background colour. */
.view-toggle .toggle-btn.is-active {
  background: linear-gradient(to right, #f43f5e, #f59e0b);
  color: var(--color-bg);
}

/* Selection is shown by the gradient fill — drop the focus ring. */
.view-toggle .toggle-btn:focus-visible { outline: none; }

/* ---- Preview panel ---------------------------------------------------- */
.preview-pane {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-status {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-4);
  text-align: center;
  color: var(--color-muted);
}

.preview-status-msg {
  max-inline-size: 26rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

/* Spinner while the dev server boots (default state). */
.preview-spinner {
  inline-size: 1.75rem;
  block-size: 1.75rem;
  border-radius: 50%;
  border: 2.5px solid var(--color-border);
  border-block-start-color: var(--color-accent);
  animation: preview-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
  .preview-spinner { animation: none; }
}

/* The "no server detected" icon — hidden until the empty state. */
.preview-status-icon { display: none; line-height: 0; opacity: 0.7; }

.preview-status.is-empty .preview-spinner { display: none; }
.preview-status.is-empty .preview-status-icon { display: block; }

.preview-frame {
  inline-size: 100%;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  background: white;
}

/* ---- Hero (no task selected) ----------------------------------------- */
.hero {
  margin: auto;
  text-align: center;
  color: var(--color-muted);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.hero h2 { font-size: clamp(1.3rem, 4vw, 1.8rem); color: var(--color-ink); }

/* ---- Composer: floats over the bottom of the column ------------------ */
.composer {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: var(--space-4) var(--space-4) var(--space-8);
  pointer-events: none;   /* the empty strip passes clicks to content below */
  z-index: 15;
}

/* Centered rounded card: textarea on top, meta row beneath. */
.composer-card {
  pointer-events: auto;
  inline-size: 100%;
  max-inline-size: 42rem;
  margin-inline: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-4) var(--space-4) var(--space-2);
  background: var(--color-surface);
  border: 1.5px solid var(--color-border);
  border-radius: 1.5rem;
  box-shadow: 0 8px 30px oklch(0% 0 0 / 0.28);
}

/* Busy state: spin the gradient around the composer border while the agent
   is working. Falls back to a static gradient ring where @property is
   unsupported, and stops entirely under reduced-motion. */
@property --busy-angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

.agent-busy .composer-card {
  border-color: transparent;
  background:
    linear-gradient(var(--color-surface), var(--color-surface)) padding-box,
    conic-gradient(from var(--busy-angle), #f43f5e, #f59e0b, #f43f5e, #f59e0b, #f43f5e) border-box;
  animation: composer-busy 3s linear infinite, composer-glow 1.8s ease-in-out infinite;
}

@keyframes composer-busy {
  to { --busy-angle: 360deg; }
}

/* Pulsing rose/amber glow to make the busy animation obvious. */
@keyframes composer-glow {
  0%, 100% { box-shadow: 0 0 8px 0 oklch(65% 0.21 18 / 0.35), 0 8px 30px oklch(0% 0 0 / 0.28); }
  50%      { box-shadow: 0 0 22px 4px oklch(72% 0.19 45 / 0.6),  0 8px 30px oklch(0% 0 0 / 0.28); }
}

@media (prefers-reduced-motion: reduce) {
  .agent-busy .composer-card { animation: none; }
}

/* Borderless field that blends into the card. */
.composer-input.composer-input {
  inline-size: 100%;
  resize: none;
  background: transparent;
  border: none;
  padding: 0;
  font-size: 1rem;
  color: var(--color-ink);
}

.composer-input:focus { outline: none; border: none; }

.composer-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

/* "Hide chat" pill — styled like the old model-name badge. Only shown in
   preview mode; hiding the chat in conversation mode is pointless. */
.composer-hide {
  display: none;
  flex-shrink: 0;
  border: none;
  border-radius: 999px;
  background: oklch(from var(--color-muted) l c h / 0.14);
  color: var(--color-muted);
  font-size: 0.72rem;
  padding: 0.2rem var(--space-3);
  cursor: pointer;
}

.workspace-main.preview-mode .composer-hide { display: inline-flex; }

.composer-hide:hover { color: var(--color-ink); }

/* Circular rose→amber gradient send button with an up-arrow. */
.composer-send.composer-send {
  flex-shrink: 0;
  margin-inline-start: auto;   /* stays right even when "Hide chat" is absent */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  inline-size: 2.25rem;
  block-size: 2.25rem;
  padding: 0;
  border: none;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(to right, #f43f5e, #f59e0b);
  box-shadow: 0 1px 2px oklch(0% 0 0 / 0.15);
  transition: box-shadow 0.15s ease;
}

.composer-send:hover { box-shadow: 0 4px 10px oklch(0% 0 0 / 0.2); }
.composer-send:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: 0 1px 2px oklch(0% 0 0 / 0.15); }

/* ---- Hide-chat FAB --------------------------------------------------- */
/* Double class beats the global `button:not(.btn)` rule (border/bg/padding). */
.chat-fab.chat-fab {
  display: none;
  position: absolute;
  bottom: var(--space-6);
  inset-inline-end: var(--space-6);
  inline-size: 3rem;
  block-size: 3rem;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(to right, #f43f5e, #f59e0b);
  box-shadow: 0 6px 18px oklch(0% 0 0 / 0.3);
  cursor: pointer;
  z-index: 16;
}

.workspace-main.chat-hidden .composer { display: none; }
.workspace-main.chat-hidden .chat-fab { display: inline-flex; }

.danger-zone {
  margin-block-start: var(--space-8);
  padding: var(--space-6);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
}
.danger-zone h2 { margin: 0 0 var(--space-2); }
.danger-note { color: var(--color-muted); margin-block-end: var(--space-4); }
.danger-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-4); padding-block: var(--space-4);
  border-block-start: 1px solid var(--color-border);
}
.danger-copy { display: flex; flex-direction: column; gap: var(--space-1); }
.danger-copy span { color: var(--color-muted); font-size: 0.9rem; }
.danger-confirm { display: flex; align-items: center; gap: var(--space-2); font-size: 0.9rem; }
.btn-danger { color: #fff; background: var(--color-negative); border: 0; border-radius: var(--radius); }
.btn-danger:disabled { opacity: 0.5; cursor: not-allowed; }
