/* Studio chrome. Colors come from html[data-theme] in theme.css. */
body.studio {
  color: var(--ink);
  background: var(--bg0);
  color-scheme: inherit;
  caret-color: var(--ember);
}
body.studio ::selection {
  background: rgba(224, 138, 60, 0.28);
  color: var(--ink);
}

.shell {
  --chat-w: 400px;
  display: grid;
  grid-template-columns: var(--chat-w) 5px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  grid-template-areas: "chat split workspace";
  height: 100dvh;
  max-height: 100dvh;
  overflow: hidden;
  background: var(--shell-bg);
  color: var(--ink);
  color-scheme: inherit;
  font-family: Outfit, "DM Sans", system-ui, sans-serif;
}

.shell-split {
  grid-area: split;
  background: transparent;
}
.shell-split:hover,
.shell-split:focus-visible,
.shell.resizing .shell-split {
  background: var(--ember);
}

/* —— Chat column —— */
.shell .chat {
  grid-area: chat;
  min-height: 0;
  overflow: hidden;
  background: var(--chat-bg);
  border-right: 1px solid var(--chat-border);
}
.shell .chat-head {
  padding: 0.85rem 1rem 0.7rem;
  border-bottom: 1px solid var(--line);
}
.shell .head-top {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}
.chat-home {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0;
  padding: 0.25rem 0.4rem 0.25rem 0.2rem;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  border-radius: 10px;
  min-height: 44px;
}
.chat-home .brand {
  font-size: 1.45rem;
  line-height: 1;
}
.chat-home svg {
  width: 1.05rem;
  height: 1.05rem;
  color: var(--muted);
  flex: 0 0 auto;
}
.chat-home:hover svg { color: var(--ink); }
.chat-home:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}
.shell .logout {
  min-height: 40px;
  font-size: 0.78rem;
}
.shell .proj-bar {
  margin-top: 0.55rem;
  gap: 0.35rem;
}
.shell .mini-select {
  background: var(--select-bg);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.88rem;
  padding: 0.5rem 0.65rem;
  min-height: 40px;
}
.shell .mini-select:focus {
  border-color: rgba(224, 138, 60, 0.7);
  outline: 2px solid rgba(224, 138, 60, 0.28);
}
.shell .sub {
  margin: 0.4rem 0 0;
  color: var(--muted);
  font-size: 0.78rem;
}
.shell .btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
}
.shell .btn-ghost:hover {
  border-color: rgba(224, 138, 60, 0.35);
  color: var(--ink);
}
.shell .btn-ghost.active {
  color: var(--ink);
  border-color: rgba(224, 138, 60, 0.45);
  background: rgba(224, 138, 60, 0.1);
}
.shell .btn-ghost:focus-visible,
.shell .btn-publish:focus-visible,
.shell .chat-send:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}
.shell .btn-ghost.mini {
  min-height: 40px;
}

.shell .messages {
  padding: 1rem 1rem 1.1rem;
  gap: 0.7rem;
}
.shell .bubble {
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.5;
}
.shell .bubble.user {
  background: var(--user-bg);
  color: var(--user-fg);
  border: 1px solid var(--user-line);
  max-width: 92%;
}
.shell .bubble.assistant {
  background: var(--assistant-bg);
  border: 1px solid var(--line);
  box-shadow: var(--assistant-shadow);
}
.shell .bubble.assistant code {
  background: var(--code-chip);
  border-color: var(--line);
  color: var(--ink);
}
.shell .bubble.system {
  color: var(--muted);
}
.shell .bubble.tool {
  background: var(--tool-bg);
  border-color: var(--line);
  color: var(--muted);
}
.shell .bubble.tool strong { color: var(--ember); }
.shell .trace-bar {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
  color: var(--muted);
}
.shell .preview-shot-note {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line);
}
.shell .preview-shot-note img { background: #0a0908; }
.shell .preview-shot-note p { color: var(--muted); }

.shell .composer.chat-composer-wrap {
  border-top: 1px solid var(--line);
  background: var(--composer-wrap);
  padding: 0.75rem 0.85rem 0.95rem;
}
.shell .chat-composer {
  background: var(--composer-bg);
  border: 1px solid var(--composer-line);
  border-radius: 18px;
  box-shadow: var(--composer-shadow);
}
.shell textarea#prompt {
  color: var(--ink);
}
.shell textarea#prompt::placeholder { color: var(--ph-fg); }
.shell .composer-toolbar { border-top-color: var(--toolbar-line); }
.shell .pill-select,
.shell .tool-icon {
  background: var(--icon-bg);
  color: var(--icon-fg);
  border-color: var(--line);
}
.shell .tool-icon {
  width: 2.5rem;
  height: 2.5rem;
  transition: border-color 160ms ease, color 160ms ease, transform 140ms var(--ease-out);
}
.shell .tool-icon:active { transform: scale(0.97); }
.shell .attach-chip { background: #f1f5f9; border-color: var(--line); }

/* —— Workspace / browser —— */
.shell .workspace {
  grid-area: workspace;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background: transparent;
  padding: 0.7rem 0.75rem 0.75rem 0.35rem;
  gap: 0;
}
.shell .topbar {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.35rem 0.45rem 0.55rem 0.2rem;
  border: 0;
  background: transparent;
  min-height: 0;
  flex-wrap: wrap;
}
.shell .tabs {
  display: flex;
  padding: 0.18rem;
  background: var(--tabs-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  gap: 0.15rem;
}
.shell .tabs .btn-ghost {
  border: 0;
  background: transparent;
  border-radius: 9px;
  min-height: 36px;
  padding: 0.35rem 0.85rem;
}
.shell .tabs .btn-ghost.active {
  background: var(--tab-on);
  box-shadow: none;
  border: 0;
  color: var(--ink);
}

.browser {
  flex: 1;
  min-width: 12rem;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  background: var(--browser-bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.28rem 0.45rem 0.28rem 0.7rem;
  min-height: 40px;
}
.browser-dots {
  display: flex;
  gap: 0.28rem;
  flex: 0 0 auto;
}
.browser-dots i {
  width: 0.48rem;
  height: 0.48rem;
  border-radius: 50%;
  background: var(--browser-dot);
  display: block;
}
.shell .url {
  flex: 1;
  font-size: 0.78rem;
  color: var(--url-fg);
  font-family: "IBM Plex Mono", ui-monospace, monospace;
}
.browser-icon {
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  text-decoration: none;
}
.browser-icon svg {
  width: 1.05rem;
  height: 1.05rem;
}
.browser-icon:hover { color: var(--ink); background: var(--icon-hover); }
.browser-icon[hidden] { display: none !important; }
.browser-icon.is-on {
  color: var(--ink);
  background: var(--icon-hover);
  outline: 1px solid var(--line);
}
.preview-stage.is-picking {
  outline: 2px solid var(--ink);
  outline-offset: -2px;
}

.bridge-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0 0 0.45rem;
}
.bridge-chips[hidden] { display: none !important; }
.bridge-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  max-width: 100%;
  padding: 0.28rem 0.35rem 0.28rem 0.55rem;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  font-size: 0.78rem;
  line-height: 1.2;
}
.bridge-chip span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bridge-chip button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.25rem;
  font-size: 1rem;
  line-height: 1;
}
.bridge-chip button:hover { color: var(--ink); }

.studio-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-wrap: wrap;
}
.shell .topbar a:not(.browser-icon) {
  color: var(--link-chip-fg);
  font-size: 0.78rem;
  padding: 0.4rem 0.65rem;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--link-chip-bg);
}
.shell .topbar a:not(.browser-icon):hover { color: var(--ink); }
.btn-publish {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  font-size: 0.85rem;
  border-radius: 10px;
  padding: 0.5rem 0.95rem;
  min-height: 40px;
  background: linear-gradient(180deg, #f0a35a, var(--ember));
  color: #1a1008;
  transition: transform 140ms var(--ease-out), opacity 160ms ease;
}
.btn-publish:hover { filter: brightness(1.03); }
.btn-publish:active { transform: scale(0.97); }
.btn-publish:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn-publish[hidden] { display: none !important; }

.shell .stage {
  position: relative;
  min-height: min(52vh, 420px);
  height: 100%;
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: var(--stage-bg);
  box-shadow: var(--stage-shadow);
}
.shell .preview-stage,
.shell .code-stage {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  min-height: 0;
}
.shell iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  background: #fff;
  z-index: 2;
}
.shell .placeholder {
  background: var(--placeholder-bg);
  color: var(--muted);
}
.shell .placeholder strong {
  color: var(--ink);
  font-family: "Instrument Serif", Georgia, serif;
  font-size: 1.85rem;
}
.shell .code-stage {
  background: #0c0b0a;
  color-scheme: dark;
}
.shell .tree {
  background: #12100e;
  border-right-color: rgba(242, 235, 227, 0.12);
}
.shell .tree-item { color: #a8998c; }
.shell .tree-item:hover { background: rgba(255,255,255,0.05); color: #f2ebe3; }
.shell .editor-bar {
  background: #161311;
  border-bottom-color: rgba(242, 235, 227, 0.12);
}
.shell .editor-bar .path { color: #a8998c; }
.shell #editor {
  background: #0e0d0c;
  color: #e8dfd4;
}

/* —— Activity drawer (collapsed by default) —— */
.shell .bottom {
  height: auto;
  max-height: none;
  min-height: 0;
  background: transparent;
  border: 0;
  margin-top: 0.45rem;
}
.bottom-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--toggle-bg);
  color: var(--muted);
  border-radius: 10px;
  padding: 0.4rem 0.7rem;
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  min-height: 36px;
}
.bottom-toggle svg {
  width: 0.85rem;
  height: 0.85rem;
  transition: transform 180ms var(--ease-out);
}
.bottom.is-open .bottom-toggle {
  border-radius: 10px 10px 0 0;
  border-bottom-color: transparent;
  color: var(--ink);
}
.bottom.is-open .bottom-toggle svg { transform: rotate(180deg); }
.bottom-body {
  display: none;
  flex-direction: column;
  min-height: 0;
  border: 1px solid var(--line);
  border-top: 0;
  border-radius: 0 0 10px 10px;
  background: var(--bottom-bg);
  overflow: hidden;
}
.bottom.is-open .bottom-body {
  display: flex;
  height: min(26vh, 200px);
}
.shell .bottom-tabs {
  background: var(--bottom-bg);
  border-bottom-color: var(--line);
}
.shell .bottom-tabs .label { color: var(--muted); }
.shell #activity {
  color: var(--activity-fg);
  background: var(--bottom-bg);
}
.shell .hist-row { border-bottom-color: var(--hist-line); }
.shell .hist-row .msg { color: var(--hist-msg); }
.shell .hist-empty { color: var(--muted); }

/* —— Mobile dock: Chat | Preview —— */
.shell-dock {
  display: none;
  position: relative;
  z-index: 5;
  background: var(--dock-bg);
  border-top: 1px solid var(--line);
  padding: 0.4rem 0.7rem calc(0.45rem + env(safe-area-inset-bottom));
  gap: 0.4rem;
  justify-content: center;
}
.shell-dock button {
  flex: 1;
  max-width: 10rem;
  min-height: 44px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--muted);
  border-radius: 12px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.shell-dock button.is-on {
  background: var(--dock-on-bg);
  color: var(--ink);
  border-color: var(--dock-on-line);
}
.shell-dock button:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

/* —— Drawer (Datos) on the light studio —— */
body.studio .drawer-overlay {
  background: var(--drawer-dim);
}
body.studio .drawer {
  background: var(--panel);
  color: var(--ink);
  border-left-color: var(--line);
  font-family: Outfit, system-ui, sans-serif;
}
body.studio .drawer input,
body.studio .drawer select {
  background: rgba(12, 11, 10, 0.6);
  color: var(--ink);
  border-color: var(--line);
}
body.studio .drawer .btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}

.auth-overlay {
  background: var(--auth-bg);
  color: var(--ink);
  color-scheme: inherit;
  font-family: Outfit, system-ui, sans-serif;
}
.auth-overlay .brand { color: var(--ink); }
.auth-card p,
.auth-invite,
.auth-or { color: var(--muted); }
.auth-card input {
  background: var(--dialog-input-bg);
  color: var(--ink);
  border-color: var(--dialog-input-line);
}
.auth-card input:focus {
  border-color: rgba(224, 138, 60, 0.7);
  box-shadow: 0 0 0 3px rgba(224, 138, 60, 0.16);
}

@media (max-width: 900px) {
  .shell {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
    grid-template-areas:
      "main"
      "dock";
    height: 100dvh;
    max-height: 100dvh;
    min-height: 0;
  }
  .shell-split { display: none; }
  .shell .chat,
  .shell .workspace {
    display: none;
    min-height: 0;
    height: 100%;
  }
  .shell[data-pane="chat"] .chat {
    display: flex;
    grid-area: main;
  }
  .shell[data-pane="preview"] .workspace {
    display: grid;
    grid-area: main;
    height: 100%;
    padding: 0.55rem 0.55rem 0.4rem;
  }
  .shell-dock {
    display: flex;
    grid-area: dock;
  }
  .shell .topbar { padding-bottom: 0.4rem; }
  .browser { min-width: 0; flex: 1 1 100%; order: 3; }
  .studio-actions { margin-left: auto; }
  .shell .stage { border-radius: 14px; }
  .bottom.is-open .bottom-body { height: min(32vh, 220px); }
}

.composer-toolbar .pill-select,
.home .composer-toolbar .pill-select,
.shell .pill-select {
  display: none !important;
}
.theme-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  min-height: 40px;
  margin: 0;
  padding: 0.35rem 0.6rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
}
.theme-pick svg {
  width: 0.85rem;
  height: 0.85rem;
  flex: 0 0 auto;
  opacity: 0.7;
}
.theme-pick:hover,
.theme-pick[aria-expanded="true"] {
  color: var(--ink);
  border-color: rgba(224, 138, 60, 0.4);
}
.theme-pick:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}
.home-top-actions,
.head-top-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
}

.cursor-picks {
  display: flex;
  align-items: center;
  gap: 0.1rem;
  min-width: 0;
}
.cursor-pick {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  max-width: 14rem;
  min-height: 28px;
  margin: 0;
  padding: 0.2rem 0.4rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #94a3b8;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.2;
  cursor: pointer;
}
.cursor-pick span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cursor-pick svg {
  width: 0.7rem;
  height: 0.7rem;
  flex: 0 0 auto;
  opacity: 0.65;
}
.cursor-pick:hover,
.cursor-pick[aria-expanded="true"] {
  background: var(--pick-on-bg);
  color: var(--pick-on-fg);
}
.cursor-pick:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}
.cursor-pick:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
.cursor-pick[hidden] { display: none !important; }
.pick-menu {
  position: fixed;
  z-index: 80;
  min-width: 16rem;
  max-width: min(22rem, calc(100vw - 1.5rem));
  max-height: min(22rem, 60vh);
  overflow: auto;
  padding: 0.3rem;
  background: var(--menu-bg);
  color: var(--menu-fg);
  color-scheme: inherit;
  border: 1px solid var(--menu-line);
  border-radius: 12px;
  box-shadow: var(--menu-shadow);
  font-family: Outfit, system-ui, sans-serif;
}
.pick-menu[hidden] { display: none !important; }
.pick-group {
  padding: 0.45rem 0.6rem 0.2rem;
  color: #94a3b8;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.02em;
}
.pick-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  margin: 0;
  padding: 0.42rem 0.55rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--menu-fg);
  font: inherit;
  font-size: 0.85rem;
  text-align: left;
  cursor: pointer;
}
.pick-item:hover,
.pick-item:focus-visible {
  background: var(--menu-hover);
  outline: none;
}
.pick-item.is-on {
  background: rgba(224, 138, 60, 0.1);
}
.pick-item-note {
  margin-left: auto;
  color: #94a3b8;
  font-size: 0.7rem;
}
.pick-item-check {
  width: 0.85rem;
  height: 0.85rem;
  margin-left: auto;
  color: #c2410c;
  flex: 0 0 auto;
}

.app-dialog-overlay {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  place-items: center;
  padding: 1.25rem;
  background: rgba(15, 23, 42, 0.42);
}
.app-dialog-overlay[hidden] { display: none !important; }
.app-dialog {
  width: min(100%, 420px);
  background: var(--dialog-bg);
  color: var(--dialog-fg);
  color-scheme: inherit;
  border: 1px solid var(--menu-line);
  border-radius: 18px;
  padding: 1.2rem 1.25rem 1.1rem;
  box-shadow: var(--dialog-shadow);
  font-family: Outfit, system-ui, sans-serif;
  animation: dialogIn 180ms cubic-bezier(0.23, 1, 0.32, 1) both;
}
.app-dialog h2 {
  margin: 0;
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
}
.app-dialog-body {
  margin: 0.45rem 0 0;
  color: var(--dialog-muted);
  font-size: 0.9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.app-dialog-field {
  display: block;
  margin-top: 0.9rem;
}
.app-dialog-field[hidden],
.app-dialog-body[hidden],
.app-dialog-err[hidden] { display: none !important; }
.app-dialog input {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--dialog-input-line);
  background: var(--dialog-input-bg);
  color: var(--dialog-fg);
  border-radius: 12px;
  padding: 0.65rem 0.8rem;
  font: inherit;
  font-size: 1rem;
  outline: none;
}
.app-dialog input:focus {
  border-color: rgba(224, 138, 60, 0.75);
  box-shadow: 0 0 0 3px rgba(224, 138, 60, 0.2);
}
.app-dialog-err {
  margin: 0.55rem 0 0;
  color: #dc2626;
  font-size: 0.82rem;
}
.app-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  margin-top: 1.05rem;
}
.app-dialog-actions .btn-ghost {
  background: transparent;
  color: var(--dialog-muted);
  border: 1px solid var(--dialog-input-line);
  border-radius: 10px;
  min-height: 40px;
}
.app-dialog-ok {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-weight: 650;
  font-size: 0.88rem;
  border-radius: 10px;
  padding: 0.5rem 0.95rem;
  min-height: 40px;
  background: linear-gradient(180deg, #f0a35a, var(--ember));
  color: #1a1008;
  transition: transform 140ms cubic-bezier(0.23, 1, 0.32, 1), opacity 160ms ease;
}
.app-dialog-ok:hover { filter: brightness(1.03); }
.app-dialog-ok:active,
.app-dialog-actions .btn-ghost:active { transform: scale(0.97); }
.app-dialog-ok:disabled,
.app-dialog-actions .btn-ghost:disabled { opacity: 0.45; cursor: wait; transform: none; }
.app-dialog-ok.is-danger {
  background: #dc2626;
  color: #fff;
}
.app-dialog-ok:focus-visible,
.app-dialog-actions .btn-ghost:focus-visible {
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

@keyframes dialogIn {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .shell .tool-icon,
  .btn-publish,
  .bottom-toggle svg,
  .app-dialog {
    transition: none;
    animation: none;
  }
}
