html.agent-studio-page,
html.agent-studio-page body {
  height: 100%;
  overflow: hidden;
}

.agent-studio-app {
  display: flex;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-app);
  color: var(--text);
  font-family: var(--font-body);
}

.agent-studio-sidebar {
  flex: 0 0 260px;
  width: 260px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: var(--surface-strong, var(--panel));
  min-height: 0;
}

.agent-studio-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line);
  font-weight: 600;
}

.agent-studio-brand .brand-logo {
  height: 22px;
  width: auto;
}

.agent-studio-sidebar-actions {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-bottom: 1px solid var(--line);
}

.agent-studio-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.agent-studio-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  width: 100%;
  min-width: 0;
  text-align: left;
  padding: 8px 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: background var(--dur-fast) var(--ease-out);
}

.agent-studio-row:hover {
  background: var(--hover-fill);
}

.agent-studio-row.is-active {
  background: var(--hover-fill-strong);
}

/* Agent names and slugs are user text — never let them wreck the sidebar. */
.agent-studio-row-title,
.agent-studio-row-sub {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-studio-row-title {
  font-size: 13px;
  font-weight: 600;
}

.agent-studio-row-sub {
  font-size: 11px;
  color: var(--text-muted);
}

.agent-studio-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.agent-studio-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.agent-studio-top h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-studio-status {
  font-size: 12px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.agent-studio-status[data-kind="error"] {
  color: var(--error-text);
}

.agent-studio-status[data-kind="ok"] {
  color: var(--success-text);
}

.agent-studio-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 16px;
}

.agent-studio-empty {
  max-width: 420px;
  margin: 12vh auto 0;
  text-align: center;
  color: var(--text-muted);
}

.agent-studio-empty h2 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.agent-studio-empty p {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
}

.agent-studio-empty .btn {
  margin-top: 16px;
}

.agent-studio-grid {
  display: grid;
  grid-template-columns: 1.2fr 0.9fr;
  gap: 16px;
  max-width: 1100px;
}

.agent-studio-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface-strong, var(--panel));
  padding: 16px;
}

/* Stacked cards inside a form column */
.agent-studio-grid .agent-studio-card + .agent-studio-card {
  margin-top: 16px;
}

.agent-studio-card > .panel-hint {
  margin-top: 0;
  margin-bottom: 12px;
}

.agent-studio-card h2 {
  margin: 0 0 12px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.agent-studio-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.agent-studio-field label {
  font-size: 12px;
  color: var(--text-muted);
}

.agent-studio-field input,
.agent-studio-field select,
.agent-studio-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--bg-app);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  padding: 8px 12px;
  transition: border-color var(--dur-fast) var(--ease-out);
}

.agent-studio-field input:hover,
.agent-studio-field select:hover,
.agent-studio-field textarea:hover {
  border-color: var(--border-mild);
}

.agent-studio-field input:focus-visible,
.agent-studio-field select:focus-visible,
.agent-studio-field textarea:focus-visible {
  outline: none;
  border-color: rgb(var(--focus-rgb));
}

.agent-studio-field textarea {
  min-height: 110px;
  resize: vertical;
  line-height: 1.45;
}

.agent-studio-field input[type="color"] {
  height: 40px;
  padding: 4px;
  cursor: pointer;
}

.agent-studio-slug-hint {
  margin: 0;
}

.agent-studio-field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.agent-studio-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.agent-studio-type-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: rgba(var(--on-rgb), 0.02);
  color: inherit;
  cursor: pointer;
  font: inherit;
  transition: background var(--dur-fast) var(--ease-out), border-color var(--dur-fast) var(--ease-out);
}

.agent-studio-type-card:hover {
  background: var(--hover-fill);
  border-color: var(--border-mild);
}

.agent-studio-type-card.is-selected {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.agent-studio-type-card strong {
  font-size: 13px;
}

.agent-studio-type-card span {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.35;
}

.agent-studio-type-summary {
  margin: 10px 0 0;
  font-size: 12px;
  color: var(--text-muted);
}

.agent-studio-preview-type {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.agent-studio-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  line-height: 1.45;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: rgba(var(--on-rgb), 0.03);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-out);
}

.agent-studio-check:hover {
  background: var(--hover-fill);
}

.agent-studio-check input {
  margin-top: 2px;
  cursor: pointer;
}

.agent-studio-preview {
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  overflow: hidden;
  min-height: 220px;
  background: var(--bg-app);
}

.agent-studio-preview-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.agent-studio-preview-bar > div {
  min-width: 0;
}

.agent-studio-preview-bar strong {
  display: block;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-studio-preview-logo {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: rgba(var(--on-rgb), 0.08);
}

.agent-studio-preview-logo.placeholder {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.agent-studio-preview-body {
  padding: 16px 16px 20px;
}

.agent-studio-preview-welcome {
  font-size: 14px;
  line-height: 1.5;
  margin: 0 0 12px;
}

.agent-studio-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.agent-studio-starter {
  font-size: 11px;
  padding: 4px 8px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-mild);
  background: rgba(var(--on-rgb), 0.04);
}

.agent-studio-url {
  margin: 12px 0 0;
  font-size: 12px;
  color: var(--text-muted);
  word-break: break-all;
}

.agent-studio-url a {
  color: inherit;
  transition: color var(--dur-fast) var(--ease-out);
}

.agent-studio-url a:hover {
  color: var(--text);
}

.agent-studio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.agent-studio-gate {
  max-width: 420px;
  margin: 18vh auto 0;
  padding: 24px;
  text-align: center;
}

@media (max-width: 900px) {
  .agent-studio-app {
    flex-direction: column;
  }

  .agent-studio-sidebar {
    flex: 0 0 auto;
    width: 100%;
    max-height: 34vh;
  }

  .agent-studio-grid,
  .agent-studio-field-row,
  .agent-studio-type-grid {
    grid-template-columns: 1fr;
  }
}
