:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #e4e7ec;
  --nav: #172033;
  --nav-soft: #273449;
  --teal: #0f766e;
  --teal-strong: #115e59;
  --amber: #b45309;
  --rose: #be123c;
  --blue: #1d4ed8;
  --shadow: 0 18px 48px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fafc 0%, var(--bg) 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 28px;
  height: 100vh;
  min-height: 0;
  overflow: hidden;
  padding: 24px;
  background: var(--nav);
  color: #f8fafc;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  background: var(--teal);
  font-weight: 800;
}

.brand h1,
.workspace-header h2,
.section-heading h3,
.auth-panel h2,
.dialog-head h3 {
  margin: 0;
}

.brand h1 {
  font-size: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.sidebar .eyebrow {
  color: #9fb3c8;
}

.tool-nav {
  display: grid;
  gap: 8px;
}

.tool-group {
  display: grid;
  gap: 2px;
}

.tool-group .chevron {
  width: 16px;
  height: 16px;
  margin-left: auto;
  transition: transform 200ms ease;
}

.tool-group.expanded .chevron {
  transform: rotate(180deg);
}

.tool-sub-nav {
  display: none;
  gap: 2px;
  padding-left: 12px;
}

.tool-group.expanded .tool-sub-nav {
  display: flex;
  flex-direction: column;
}

.tool-sub-item {
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px 7px 14px;
  background: transparent;
  color: #cbd5e1;
  text-align: left;
  cursor: pointer;
  font-size: 13px;
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.tool-sub-item:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #f1f5f9;
}

.tool-sub-item.active {
  border-color: rgba(255, 255, 255, 0.14);
  background: var(--nav-soft);
  color: #dbeafe;
}

.tool-sub-item .nav-icon {
  width: 28px;
  height: 28px;
}

.tool-nav-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 10px;
  background: transparent;
  color: #dbeafe;
  text-align: left;
  cursor: pointer;
  transition: border-color 160ms ease, background 160ms ease;
}

.tool-nav-item:hover {
  border-color: rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
}

.tool-nav-item.active {
  border-color: rgba(255, 255, 255, 0.14);
  background: var(--nav-soft);
}

.tool-nav-item.muted {
  color: #94a3b8;
  cursor: not-allowed;
  opacity: 0.76;
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.status-dot.ready {
  background: #34d399;
  box-shadow: 0 0 0 4px rgba(52, 211, 153, 0.12);
}

.sidebar-footer {
  display: grid;
  gap: 10px;
  margin-top: auto;
  padding-top: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.signal-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #bac7d6;
  font-size: 13px;
}

.signal-row strong {
  overflow: hidden;
  max-width: 140px;
  color: #ffffff;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  height: 100vh;
  overflow: auto;
  padding: 28px;
}

.auth-page {
  display: grid;
  grid-template-columns: minmax(420px, 1fr) minmax(360px, 460px);
  gap: 28px;
  align-items: center;
  min-height: 100vh;
  padding: 32px;
  background:
    linear-gradient(90deg, rgba(23, 32, 51, 0.96) 0%, rgba(23, 32, 51, 0.92) 52%, rgba(245, 247, 251, 0) 52%),
    linear-gradient(180deg, #f8fafc 0%, #eef3f8 100%);
}

.auth-hero {
  display: grid;
  gap: 34px;
  min-height: calc(100vh - 64px);
  border-radius: 8px;
  padding: 28px;
  color: #ffffff;
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.auth-brand h1 {
  margin: 0;
  font-size: 20px;
}

.auth-brand .eyebrow,
.auth-copy .eyebrow {
  color: #9fb3c8;
}

.auth-visual {
  align-self: center;
  overflow: hidden;
  width: min(100%, 680px);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: #eef3f8;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.26);
}

.visual-toolbar {
  display: flex;
  gap: 7px;
  align-items: center;
  height: 42px;
  border-bottom: 1px solid #d7dee8;
  background: #ffffff;
  padding: 0 14px;
}

.visual-toolbar span {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #cbd5e1;
}

.visual-toolbar span:nth-child(1) {
  background: #fb7185;
}

.visual-toolbar span:nth-child(2) {
  background: #f59e0b;
}

.visual-toolbar span:nth-child(3) {
  background: #0f766e;
}

.visual-canvas {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  grid-template-rows: 220px 88px;
  gap: 14px;
  padding: 18px;
  background:
    linear-gradient(#dbe3ee 1px, transparent 1px),
    linear-gradient(90deg, #dbe3ee 1px, transparent 1px),
    #f8fafc;
  background-size: 24px 24px;
}

.visual-frame {
  border: 1px solid #d1dae6;
  border-radius: 8px;
  background: #ffffff;
}

.frame-main {
  background:
    linear-gradient(135deg, #0f766e 0%, #0f766e 44%, #f8fafc 44%, #f8fafc 100%);
}

.frame-side {
  background:
    linear-gradient(180deg, #ffffff 0 28%, #e8f3f1 28% 54%, #fff7ed 54% 78%, #ffe4e6 78%);
}

.frame-strip {
  grid-column: 1 / -1;
  background:
    linear-gradient(90deg, #ffffff 0 22%, #e8f3f1 22% 46%, #fff7ed 46% 72%, #ffe4e6 72%);
}

.auth-copy {
  align-self: end;
  max-width: 620px;
}

.auth-copy h2 {
  margin: 0;
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.05;
}

.auth-copy p:last-child {
  margin: 14px 0 0;
  color: #cbd5e1;
  font-size: 17px;
}

.auth-page .auth-panel {
  justify-self: center;
  width: min(100%, 420px);
}

.auth-view {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 56px);
}

.auth-panel,
.control-panel,
.config-summary-panel,
.settings-panel,
.tasks-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
}

.auth-panel {
  display: grid;
  gap: 16px;
  width: min(100%, 420px);
  padding: 24px;
}

.auth-panel form {
  display: grid;
  gap: 14px;
}

.workspace-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  max-width: 1240px;
  margin: 0 auto 20px;
}

.tool-tabs {
  display: flex;
  overflow: hidden;
  width: fit-content;
  max-width: 1240px;
  margin: 0 auto 18px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
}

.tool-tab {
  min-width: 112px;
  min-height: 38px;
  border: 0;
  border-right: 1px solid #cfd8e3;
  background: transparent;
  color: #344054;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.tool-tab:last-child {
  border-right: 0;
}

.tool-tab.active {
  background: var(--teal);
  color: #ffffff;
}

.workspace-header h2 {
  font-size: 28px;
}

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

.tool-grid {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(320px, 0.85fr);
  gap: 18px;
  max-width: 1240px;
  margin: 0 auto;
}

.control-panel,
.config-summary-panel,
.settings-panel {
  display: grid;
  gap: 16px;
  padding: 20px;
}

.settings-section {
  max-width: 980px;
  margin: 0 auto;
}

.settings-form {
  display: grid;
  gap: 14px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-heading h3 {
  font-size: 18px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.field {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.field span {
  color: #344054;
  font-size: 13px;
  font-weight: 800;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input,
.field select {
  height: 44px;
  padding: 0 12px;
}

.field textarea {
  min-height: 220px;
  resize: vertical;
  padding: 12px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.14);
}

.icon-button,
.primary-button,
.secondary-button,
.text-button,
.tool-tab,
.segmented button {
  cursor: pointer;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #ffffff;
  color: #344054;
}

.icon-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.icon-button.compact {
  width: 38px;
  height: 38px;
}

.primary-button,
.secondary-button,
.text-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 800;
}

.primary-button {
  border: 1px solid var(--teal-strong);
  background: var(--teal);
  color: #ffffff;
  padding: 0 16px;
}

.primary-button:hover {
  background: var(--teal-strong);
}

.secondary-button {
  border: 1px solid #cfd8e3;
  background: #ffffff;
  color: #344054;
  padding: 0 14px;
}

.secondary-button:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.secondary-button.danger:hover {
  border-color: var(--rose);
  color: var(--rose);
}

.secondary-button.small {
  min-height: 36px;
  padding: 0 12px;
  font-size: 13px;
}

.text-button {
  justify-self: start;
  border: 0;
  background: transparent;
  color: var(--teal);
  padding: 0;
}

.advanced-fields {
  display: grid;
  gap: 12px;
}

.feedback {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.feedback.error {
  color: var(--rose);
}

.feedback.success {
  color: var(--teal);
}

.inline-hint {
  margin: -8px 0 0;
  color: var(--amber);
  font-size: 13px;
  font-weight: 700;
}

.summary-list {
  display: grid;
  gap: 10px;
}

.summary-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 42px;
  border-bottom: 1px solid var(--line);
}

.summary-item span,
.summary-empty span {
  color: var(--muted);
  font-size: 13px;
}

.summary-item strong {
  overflow: hidden;
  max-width: 64%;
  color: #344054;
  font-size: 13px;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.summary-empty {
  display: grid;
  gap: 6px;
  min-height: 130px;
  border: 1px dashed #cfd8e3;
  border-radius: 8px;
  align-content: center;
  padding: 16px;
}

.summary-empty strong {
  font-size: 14px;
}

.model-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: rgba(190, 18, 60, 0.1);
  color: var(--rose);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.model-pill.ready {
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-strong);
}

.config-grid {
  display: grid;
  gap: 8px;
  max-height: 280px;
  overflow: auto;
  padding-right: 2px;
}

.config-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.config-card:hover,
.config-card.active {
  border-color: var(--teal);
}

.config-card strong,
.config-card span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.config-card strong {
  font-size: 13px;
}

.config-card span {
  color: var(--muted);
  font-size: 12px;
}

.visibility-pill {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 22px;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-strong);
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.visibility-pill.private {
  background: rgba(29, 78, 216, 0.1);
  color: var(--blue);
}

.tasks-section {
  max-width: 1240px;
  margin: 18px auto 0;
  padding: 20px;
}

.segmented {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #cfd8e3;
  border-radius: 8px;
  background: #ffffff;
}

.segmented button {
  min-height: 34px;
  border: 0;
  border-right: 1px solid #cfd8e3;
  background: transparent;
  color: #344054;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 800;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--teal);
  color: #ffffff;
}

.task-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.task-empty {
  display: grid;
  place-items: center;
  min-height: 110px;
  border: 1px dashed #cfd8e3;
  border-radius: 8px;
  color: var(--muted);
  font-size: 13px;
}

.task-card {
  display: grid;
  gap: 10px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  padding: 10px;
  text-align: left;
}

.task-card:hover {
  border-color: var(--teal);
}

.task-image,
.task-placeholder {
  display: grid;
  place-items: center;
  overflow: hidden;
  aspect-ratio: 4 / 3;
  border-radius: 6px;
  background: var(--surface-soft);
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.task-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.task-card h4 {
  overflow: hidden;
  margin: 0;
  color: var(--ink);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.task-card p {
  display: -webkit-box;
  overflow: hidden;
  min-height: 40px;
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 800;
}

.status-badge.queued {
  background: rgba(29, 78, 216, 0.1);
  color: var(--blue);
}

.status-badge.running {
  background: rgba(180, 83, 9, 0.12);
  color: var(--amber);
}

.status-badge.succeeded {
  background: rgba(15, 118, 110, 0.1);
  color: var(--teal-strong);
}

.status-badge.failed {
  background: rgba(190, 18, 60, 0.1);
  color: var(--rose);
}

.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.task-dialog {
  width: min(900px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0;
  color: var(--ink);
}

.task-dialog::backdrop {
  background: rgba(15, 23, 42, 0.46);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  padding: 14px;
}

.dialog-body {
  display: grid;
  gap: 14px;
  padding: 14px;
}

.dialog-body img {
  width: 100%;
  max-height: 68vh;
  object-fit: contain;
  border-radius: 8px;
  background: #0f172a;
}

.detail-block {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  padding: 10px;
}

.detail-block strong {
  font-size: 13px;
}

.detail-block p {
  overflow-wrap: anywhere;
  margin: 0;
  color: #344054;
  font-size: 13px;
}

[hidden] {
  display: none !important;
}

@media (max-width: 1020px) {
  .auth-page {
    grid-template-columns: 1fr;
    background: linear-gradient(180deg, #172033 0%, #172033 42%, #f5f7fb 42%, #f5f7fb 100%);
  }

  .auth-hero {
    min-height: auto;
    padding: 12px 0 0;
  }

  .auth-visual {
    display: none;
  }

  .auth-copy {
    align-self: auto;
  }

  .auth-copy h2 {
    font-size: 36px;
  }

  .app-shell {
    height: auto;
    overflow: visible;
    grid-template-columns: 1fr;
  }

  .sidebar {
    height: auto;
    min-height: auto;
  }

  .workspace {
    height: auto;
    overflow: visible;
  }

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

@media (max-width: 640px) {
  .auth-page {
    gap: 18px;
    padding: 18px;
  }

  .auth-copy h2 {
    font-size: 30px;
  }

  .workspace,
  .sidebar {
    padding: 16px;
  }

  .tool-tabs {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
    margin: 0 0 16px;
  }

  .tool-tab {
    min-width: 0;
  }

  .workspace-header,
  .section-heading {
    align-items: flex-start;
    flex-direction: column;
  }

  .workspace-header h2 {
    font-size: 22px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .auth-panel,
  .control-panel,
  .config-summary-panel,
  .settings-panel,
  .tasks-section {
    padding: 14px;
  }

  .form-actions,
  .header-actions {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }

  .primary-button,
  .secondary-button {
    width: 100%;
  }

  .segmented {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    width: 100%;
  }

  .segmented button {
    border-right: 0;
    border-bottom: 1px solid #cfd8e3;
  }

  .segmented button:nth-last-child(-n + 2) {
    border-bottom: 0;
  }
}
