/* Project workspace — atelier bench */
.ws-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  background: var(--bg);
}

.ws-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  min-height: var(--header-h);
  padding: 10px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 20;
}

.ws-header-main {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  flex: 1;
}

.ws-title {
  margin: 0;
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ws-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.ws-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}
.ws-actions .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

.ws-body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 52px minmax(280px, 1fr) 6px minmax(320px, 1.1fr);
  grid-template-rows: 1fr;
}

.ws-body.layout-files {
  grid-template-columns: 52px minmax(220px, 0.85fr) 6px minmax(260px, 1fr) 6px minmax(280px, 1fr);
}

.ws-body.layout-chat-max {
  grid-template-columns: 52px 1fr 0 0;
}
.ws-body.layout-preview-max {
  grid-template-columns: 52px 0 0 1fr;
}

.ws-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px 6px;
  border-inline-end: 1px solid var(--border);
  background: var(--surface);
}

.ws-nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  font-size: 10px;
  font-weight: 560;
  line-height: 1.1;
}
.ws-nav-btn svg {
  width: 18px;
  height: 18px;
}
.ws-nav-btn:hover {
  background: var(--surface-3);
  color: var(--text);
}
.ws-nav-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}

.ws-pane {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.ws-right {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

.ws-right .preview-pane,
.ws-right .ws-side-host {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.ws-right .ws-side-host[hidden] {
  display: none !important;
}

.ws-right.is-side .preview-pane {
  display: none;
}

.ws-right.is-side .ws-side-host {
  display: flex;
}

.ws-splitter {
  background: var(--border);
  cursor: col-resize;
  position: relative;
  z-index: 5;
  transition: background var(--dur) var(--ease);
}
.ws-splitter:hover,
.ws-splitter.is-dragging {
  background: var(--accent);
}

/* Chat */
.chat-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-2);
}

.chat-toolbar {
  min-height: 52px;
  padding: 9px var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-toolbar > div {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  font-size: var(--fs-sm);
}
.chat-toolbar span {
  color: var(--text-3);
  font-size: 11px;
}

.chat-scroll {
  flex: 1;
  overflow: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.msg {
  max-width: min(720px, 92%);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.msg.user {
  align-self: flex-end;
}
.msg.agent {
  align-self: flex-start;
}

.msg-bubble {
  padding: 12px 14px;
  border-radius: 14px;
  font-size: var(--fs-sm);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.msg.user .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}
[dir="rtl"] .msg.user .msg-bubble {
  border-bottom-right-radius: 14px;
  border-bottom-left-radius: 4px;
}
.msg.agent .msg-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-1);
}
.msg.agent .msg-bubble.markdown {
  white-space: normal;
}
.msg-bubble.markdown > :first-child {
  margin-top: 0;
}
.msg-bubble.markdown > :last-child {
  margin-bottom: 0;
}
.msg-bubble.markdown p,
.msg-bubble.markdown ul,
.msg-bubble.markdown ol,
.msg-bubble.markdown pre {
  margin: 0 0 10px;
}
.msg-bubble.markdown ul,
.msg-bubble.markdown ol {
  padding-inline-start: 22px;
}
.msg-bubble.markdown code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--surface-2);
  border-radius: 4px;
  padding: 1px 4px;
}
.msg-bubble.markdown pre {
  overflow-x: auto;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  white-space: pre;
}
.msg-bubble.markdown pre code {
  padding: 0;
  background: transparent;
}
[dir="rtl"] .msg.agent .msg-bubble {
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}

.msg-meta {
  font-size: 11px;
  color: var(--text-3);
  padding: 0 4px;
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px;
}

.work-group {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
  max-width: min(720px, 92%);
}
.work-group summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  font-size: var(--fs-sm);
  font-weight: 560;
  background: var(--surface-2);
}
.work-group summary::-webkit-details-marker {
  display: none;
}
.work-group[open] summary {
  border-bottom: 1px solid var(--border);
}
.work-body {
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--fs-xs);
  color: var(--text-2);
  max-height: 220px;
  overflow: auto;
}
.work-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.work-item .mono {
  font-family: var(--font-mono);
  font-size: 11px;
}

.approval-card {
  max-width: min(720px, 92%);
  border: 1px solid color-mix(in srgb, var(--warning) 40%, var(--border));
  background: var(--surface);
  border-radius: var(--radius);
  padding: var(--space-4);
  box-shadow: var(--shadow-1);
  animation: approval-in 220ms var(--ease);
}
@keyframes approval-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.approval-card h4 {
  margin: 0 0 6px;
  font-size: var(--fs-md);
}
.approval-card p {
  margin: 0 0 8px;
  font-size: var(--fs-sm);
  color: var(--text-2);
}
.approval-meta {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  padding: 10px 12px;
  background: var(--warning-soft);
  border-radius: var(--radius-sm);
  font-size: var(--fs-xs);
  color: var(--warning);
}
.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ws-composer {
  border-top: 1px solid var(--border);
  background: var(--surface);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer-box {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.composer-box:focus-within {
  border-color: var(--accent);
  box-shadow: var(--focus);
}
.composer-box textarea {
  border: 0;
  background: transparent;
  resize: none;
  min-height: 56px;
  max-height: 180px;
  padding: 6px 8px;
  outline: none;
  box-shadow: none !important;
}
.composer-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.composer-left,
.composer-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.model-settings {
  position: relative;
}
.model-settings > summary {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-3);
  cursor: pointer;
  font-size: 11px;
  list-style: none;
  white-space: nowrap;
}
.model-settings > summary::-webkit-details-marker {
  display: none;
}
.model-settings > summary::after {
  content: "⌄";
  color: var(--text-3);
  font-size: 12px;
}
.model-settings[open] > summary {
  border-color: var(--accent);
  box-shadow: var(--focus);
}
.model-settings > summary strong {
  max-width: 150px;
  overflow: hidden;
  color: var(--text);
  font-weight: 600;
  text-overflow: ellipsis;
}
.model-settings-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  position: absolute;
  z-index: 30;
  left: 0;
  bottom: calc(100% + 8px);
  width: min(400px, calc(100vw - 40px));
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-2);
}
.model-picker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  color: var(--text-3);
  font-size: 11px;
}
.model-picker .select {
  width: min(260px, 70%);
  max-width: none;
  min-height: 32px;
  padding: 5px 28px 5px 9px;
  font-size: var(--fs-xs);
}
.model-variant-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.model-param {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--text-3);
  font-size: 11px;
}
.model-param .select {
  width: auto;
  min-height: 32px;
  padding: 5px 26px 5px 8px;
  font-size: var(--fs-xs);
}
.model-advanced {
  padding-top: 2px;
  border-top: 1px solid var(--border);
}
.model-advanced > summary {
  padding-top: 8px;
  cursor: pointer;
  color: var(--text-3);
  font-size: 11px;
  list-style: none;
}
.model-advanced > summary::-webkit-details-marker {
  display: none;
}
.model-advanced[open] > .model-variant-controls {
  padding-top: 8px;
}
.attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
}

/* Preview */
.preview-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--bg-tint);
}
.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.preview-url {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-family: var(--font-mono);
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.preview-frame-wrap {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: stretch;
  justify-content: center;
  padding: 0;
  position: relative;
}
.preview-frame-wrap[data-viewport="tablet"] {
  padding: 16px;
}
.preview-frame-wrap[data-viewport="mobile"] {
  padding: 16px;
}
.preview-frame {
  flex: 1;
  border: 0;
  background: #fff;
  width: 100%;
  height: 100%;
}
.preview-frame-wrap[data-viewport="tablet"] .preview-frame {
  max-width: 768px;
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-2);
}
.preview-frame-wrap[data-viewport="mobile"] .preview-frame {
  max-width: 390px;
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow-2);
}
.preview-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  padding: 24px;
  text-align: center;
}
.preview-overlay.is-visible {
  display: flex;
}
.preview-progress {
  width: min(320px, 100%);
}
.preview-progress .bar {
  height: 4px;
  background: var(--surface-3);
  border-radius: 99px;
  overflow: hidden;
  margin: 12px 0;
}
.preview-progress .bar > span {
  display: block;
  height: 100%;
  width: 30%;
  background: var(--accent);
  border-radius: inherit;
  animation: progress-pulse 1.4s var(--ease) infinite;
}
@keyframes progress-pulse {
  0% {
    transform: translateX(-100%);
    width: 30%;
  }
  50% {
    width: 55%;
  }
  100% {
    transform: translateX(280%);
    width: 30%;
  }
}

/* Files */
.files-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
  flex: 1;
}
.file-tree {
  border-inline-end: 1px solid var(--border);
  overflow: auto;
  padding: 8px;
  background: var(--surface-2);
  font-size: var(--fs-xs);
}
.file-tree-item {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  text-align: start;
  padding: 5px 8px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  cursor: pointer;
  color: var(--text-2);
}
.file-tree-item:hover {
  background: var(--surface);
}
.file-tree-item.is-active {
  background: var(--accent-soft);
  color: var(--accent-ink);
}
.file-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.file-tabs {
  display: flex;
  gap: 2px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  padding: 6px 6px 0;
}
.file-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  font-size: var(--fs-xs);
  cursor: pointer;
  color: var(--text-3);
}
.file-tab.is-active {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.file-tab .dirty {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
}
.editor-area {
  flex: 1;
  min-height: 0;
}
.editor-area textarea,
.editor-area pre {
  width: 100%;
  height: 100%;
  margin: 0;
  border: 0;
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.55;
  resize: none;
  background: var(--surface);
  outline: none;
}
.md-preview {
  padding: 20px 24px;
  overflow: auto;
  height: 100%;
  font-size: var(--fs-sm);
}
.md-preview h1,
.md-preview h2,
.md-preview h3 {
  font-family: var(--font-display);
  letter-spacing: -0.01em;
}

/* DB / deploy panes inside workspace */
.ws-side-pane {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: auto;
  padding: var(--space-4);
  gap: var(--space-4);
  background: var(--surface-2);
}

.logs-view {
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  max-height: 480px;
  overflow: auto;
  white-space: pre-wrap;
}
.logs-view .log-err {
  color: var(--danger);
}
.logs-view .log-warn {
  color: var(--warning);
}
.logs-view.no-wrap {
  white-space: pre;
}

.deploy-item {
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.deploy-item.is-production {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.deploy-item-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.deploy-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Mobile workspace */
@media (max-width: 900px) {
  .ws-actions {
    width: 100%;
    justify-content: flex-start;
  }
  .ws-body,
  .ws-body.layout-files,
  .ws-body.layout-chat-max,
  .ws-body.layout-preview-max {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .ws-nav {
    flex-direction: row;
    overflow-x: auto;
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
    padding: 6px;
  }
  .ws-nav-btn {
    flex-direction: row;
    gap: 6px;
    padding: 8px 10px;
    font-size: 12px;
    white-space: nowrap;
  }
  .ws-splitter {
    display: none;
  }
  .ws-pane.is-hidden-mobile {
    display: none !important;
  }
  .preview-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 60;
    display: flex !important;
  }
  .files-layout {
    grid-template-columns: 1fr;
  }
  .file-tree {
    max-height: 160px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--border);
  }
}

/* Public landing (unauthenticated feed) */
.feed-category-control {
  align-items: center;
  color: var(--text-3);
  display: inline-flex;
  font-size: 12px;
  gap: 6px;
}

.feed-category-control .input {
  min-height: 30px;
  padding: 4px 26px 4px 8px;
  width: auto;
}

.landing {
  min-height: 100vh;
}

.landing-bar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: 14px var(--space-5);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.landing-bar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.landing-intro {
  padding-top: var(--space-7);
  padding-bottom: var(--space-5);
  max-width: 720px;
}

.landing-eyebrow {
  margin: 0 0 8px;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}

.landing-cta {
  margin-top: var(--space-4);
}

.landing-feed {
  padding-top: 0;
}

.landing-feed .page-header {
  align-items: flex-start;
}

.auth-back {
  margin: var(--space-4) 0 0;
  text-align: center;
  font-size: var(--fs-sm);
}

.auth-back a {
  color: var(--text-3);
}

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

@media (max-width: 700px) {
  .landing-bar {
    padding: 12px 16px;
  }
  .landing-intro {
    padding-top: var(--space-5);
  }
}

/* Auth */
.auth-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.auth-card {
  width: min(420px, 100%);
  padding: var(--space-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
}
.auth-card .brand {
  margin-bottom: var(--space-5);
  justify-content: center;
}
.auth-card h1 {
  margin: 0 0 8px;
  text-align: center;
  font-family: var(--font-display);
  font-size: var(--fs-2xl);
  font-weight: 560;
}
.auth-card .lead {
  text-align: center;
  color: var(--text-3);
  font-size: var(--fs-sm);
  margin: 0 0 var(--space-5);
}
.auth-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: var(--space-4);
  background: var(--surface-3);
  padding: 4px;
  border-radius: var(--radius-sm);
}
.auth-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 560;
  font-size: var(--fs-sm);
  color: var(--text-3);
}
.auth-tabs button.is-active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.auth-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}
.auth-error {
  color: var(--danger);
  background: var(--danger-soft);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  display: none;
}
.auth-error.is-visible {
  display: block;
}

/* Create project */
.create-layout {
  display: grid;
  grid-template-columns: 1.3fr 0.9fr;
  gap: var(--space-5);
  align-items: start;
}
.create-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
}
.supported-stacks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.supported-stack-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-2);
  font-size: var(--fs-xs);
  font-weight: 600;
}
.stack-picker {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stack-option {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  background: var(--surface);
  text-align: start;
}
.stack-option.is-selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-soft) 70%, transparent);
}
.stack-option strong {
  display: block;
  margin-bottom: 4px;
}
.stack-option span {
  font-size: var(--fs-xs);
  color: var(--text-3);
}
.example-prompts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.example-prompt {
  text-align: start;
  border: 1px dashed var(--border);
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: var(--fs-xs);
  color: var(--text-2);
  cursor: pointer;
}
.example-prompt:hover {
  border-color: var(--accent);
  color: var(--accent-ink);
}
.limits-box {
  padding: 14px;
  background: var(--surface-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: var(--fs-xs);
  color: var(--text-2);
}
.limits-box ul {
  margin: 8px 0 0;
  padding-inline-start: 18px;
}

@media (max-width: 900px) {
  .create-layout {
    grid-template-columns: 1fr;
  }
}
