:root {
  --bg: #0b1020;
  --panel: #111a33;
  --panel-2: #0f1730;
  --text: #e7ecff;
  --muted: #aab3d6;
  --border: rgba(231, 236, 255, 0.12);
  --accent: #6aa6ff;
  --danger: #ff6a6a;
  --ok: #31d0aa;
  --deployed: #5bdc73;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono",
    "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu,
    Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-header {
  border-bottom: 1px solid var(--border);
  background: rgba(9, 14, 30, 0.7);
  backdrop-filter: blur(10px);
}

.app-header .container {
  margin-top: 0;
  margin-bottom: 0;
}

.app-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 14px;
  padding-bottom: 14px;
}

.app-header-left {
  display: flex;
  align-items: baseline;
  gap: 12px;
  flex-wrap: wrap;
  min-width: 0;
}

.app-brand {
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.02em;
  color: var(--text);
}

.app-brand:hover {
  text-decoration: none;
}

.app-meta {
  font-size: 12px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.app-nav {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.app-nav a {
  color: var(--muted);
  font-weight: 700;
  padding: 6px 8px;
  border: 1px solid transparent;
}

.app-nav a:hover {
  text-decoration: none;
  color: var(--text);
}

.app-nav a.active {
  color: var(--text);
  border-color: var(--border);
  background: rgba(255, 255, 255, 0.03);
}

.app-main {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.mono {
  font-family: var(--mono);
  overflow-wrap: anywhere;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

.container {
  width: 100%;
  margin: 32px auto;
  padding: 0 16px;
}

.row {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 16px;
}

.card h2,
.card h3 {
  margin: 0 0 12px;
}

.muted {
  color: var(--muted);
}

.pill {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 0;
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--muted);
  max-width: 100%;
  overflow-wrap: anywhere;
}
.pill.ok {
  color: var(--ok);
}
.pill.deployed {
  color: var(--deployed);
}
.pill.bad {
  color: var(--danger);
}

textarea,
input,
select {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 10px 12px;
  font-family: inherit;
}

textarea {
  min-height: 120px;
  resize: vertical;
}

button {
  background: rgba(106, 166, 255, 0.12);
  color: var(--text);
  border: 1px solid rgba(106, 166, 255, 0.35);
  border-radius: 0;
  padding: 10px 12px;
  cursor: pointer;
  font-weight: 600;
}

button:hover {
  background: rgba(106, 166, 255, 0.18);
}

button.danger {
  background: rgba(255, 106, 106, 0.12);
  border-color: rgba(255, 106, 106, 0.35);
}

button.ok {
  background: rgba(49, 208, 170, 0.12);
  border-color: rgba(49, 208, 170, 0.35);
}

.actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

pre {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.35;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  border-radius: 0;
  margin: 0;
  padding: 12px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.error {
  border: 1px solid rgba(255, 106, 106, 0.35);
  background: rgba(255, 106, 106, 0.08);
  color: var(--text);
  border-radius: 0;
  padding: 12px;
}

.workspace {
  display: flex;
  gap: 16px;
  padding: 16px;
  height: 100%;
  min-height: 0;
}

.workspace-sidebar {
  width: 380px;
  min-width: 280px;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.workspace-main {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.workspace-card {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.workspace-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.workspace-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

details.collapsible summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: baseline;
  justify-content: flex-start;
  gap: 12px;
  font-weight: 700;
}

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

details.collapsible summary::after {
  content: "▾";
  margin-left: auto;
  color: var(--muted);
  font-weight: 700;
}

details.collapsible:not([open]) summary::after {
  content: "▸";
}

details.collapsible .collapsible-body {
  margin-top: 12px;
}

.job-card {
  height: 100%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.job-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.job-head-main {
  min-width: 0;
}

.job-title {
  font-weight: 800;
  font-size: 18px;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}

.job-head-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  font-size: 12px;
}

.job-head-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.job-prompt #promptFull {
  max-height: min(240px, 25vh);
}

.tabs {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

button.tab {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--border);
  padding: 8px 10px;
}

button.tab.active {
  background: rgba(106, 166, 255, 0.18);
  border-color: rgba(106, 166, 255, 0.35);
}

.tab-panels {
  flex: 1;
  min-height: 0;
}

.tab-panel {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel > pre,
.tab-panel > .chat {
  flex: 1;
  min-height: 0;
}

.iterate-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
  background: var(--panel-2);
}

.iterate-footer textarea {
  max-height: 40vh;
}

#panel-details {
  overflow: auto;
}

.chat {
  flex: 1;
  min-height: 240px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--border);
  padding: 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-msg {
  max-width: 100%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  padding: 10px 12px;
}

.chat-msg.user {
  border-color: rgba(106, 166, 255, 0.35);
  background: rgba(106, 166, 255, 0.08);
}

.chat-msg.assistant {
  border-color: rgba(49, 208, 170, 0.3);
  background: rgba(49, 208, 170, 0.06);
}

.chat-meta {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.chat-text {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  white-space: pre-wrap;
  word-break: break-word;
}

.action-status {
  min-height: 22px;
}

.meta-grid {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 6px 10px;
  font-size: 12px;
  margin-top: 10px;
}

.meta-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 11px;
}

.meta-value {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

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

.details .job-section:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.job-section-title {
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 6px;
}

.job-item {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-2);
  color: var(--text);
}

.job-item:hover {
  background: rgba(255, 255, 255, 0.03);
  text-decoration: none;
}

.job-item.active {
  border-color: rgba(106, 166, 255, 0.45);
  background: rgba(106, 166, 255, 0.08);
}

.job-item-main {
  min-width: 0;
}

.job-item .title {
  font-weight: 700;
  margin-bottom: 6px;
  overflow-wrap: anywhere;
}

.job-item .meta {
  color: var(--muted);
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(6, 10, 24, 0.72);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 24px 16px;
}

.modal.show {
  display: flex;
}

.modal-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 18px 20px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.modal-title {
  font-weight: 700;
  margin-top: 10px;
  margin-bottom: 6px;
}

.spinner {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 3px solid rgba(231, 236, 255, 0.2);
  border-top-color: var(--accent);
  margin: 0 auto;
  animation: spin 0.9s linear infinite;
}

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

@media (max-width: 720px) {
  .container {
    margin: 20px auto;
    padding: 0 14px;
  }

  button,
  input,
  select {
    min-height: 44px;
  }

  .app-meta {
    width: 100%;
    text-align: left;
    overflow-wrap: anywhere;
  }

  .meta-grid {
    grid-template-columns: 1fr;
  }

  .meta-label {
    margin-top: 10px;
  }

  .meta-label:first-child {
    margin-top: 0;
  }

  .chat {
    min-height: 180px;
  }

  .job-item {
    flex-direction: column;
  }

  .job-item .actions {
    width: 100%;
    justify-content: flex-start;
  }

  .modal {
    padding: 20px 14px;
  }
}

@media (max-width: 980px) {
  .workspace {
    flex-direction: column;
  }

  .workspace-sidebar {
    width: 100%;
    max-width: none;
    max-height: 45vh;
    overflow: auto;
  }

  .workspace-scroll {
    max-height: 45vh;
  }

}
