:root {
  color-scheme: light;
  font-family: "Inter", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #eef2f6;
  color: #1d2430;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --line: #e1e7ef;
  --line-strong: #cdd6e2;
  --text-muted: #667085;
  --blue: #2563eb;
  --blue-soft: #e8f0ff;
  --green: #12805c;
  --orange: #b45309;
  --teal: #0f766e;
  --teal-bright: #14b8a6;
  --ink: #111827;
  --accent: linear-gradient(135deg, #2dd4bf, #22b8d6);
  --shadow: 0 18px 50px rgba(17, 24, 39, 0.08);
  --shadow-soft: 0 4px 18px rgba(17, 24, 39, 0.05);
  --radius: 12px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
}

button,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(340px, 410px) minmax(0, 1fr);
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(45, 212, 191, 0.1), transparent 32%),
    linear-gradient(180deg, rgba(37, 99, 235, 0.08), transparent 38%),
    #eef2f6;
}

.side-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 24px;
  background:
    radial-gradient(120% 60% at 0% 0%, rgba(45, 212, 191, 0.14), transparent 55%),
    linear-gradient(180deg, rgba(27, 38, 54, 0.97), rgba(15, 21, 33, 0.99)),
    #18212f;
  color: #f8fafc;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 16px 0 50px rgba(17, 24, 39, 0.14);
}

.side-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 3px;
  background: var(--accent);
  opacity: 0.9;
}

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

.brand-mark {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent);
  color: #04201f;
  font-weight: 800;
  letter-spacing: 0.5px;
  box-shadow: 0 8px 22px rgba(45, 212, 191, 0.32);
}

.brand h1,
.workspace-header h2,
.panel-block h2,
.agent-rail h2,
.insight-band h3 {
  margin: 0;
}

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

.brand p,
.panel-block label,
.eyebrow,
.metric-row span,
.status-strip,
.muted,
.run-label {
  color: #94a3b8;
}

.brand p {
  margin: 3px 0 0;
  font-size: 13px;
}

.panel-block {
  display: grid;
  gap: 8px;
}

.input-card,
.run-card,
.agent-rail {
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.05);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.input-card:focus-within {
  border-color: rgba(94, 234, 212, 0.45);
}

.input-card {
  padding: 14px;
}

.input-card.compact {
  padding-bottom: 12px;
}

.run-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
}

.run-card strong {
  display: block;
  margin-top: 4px;
  max-width: 240px;
  color: #ecfeff;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-label {
  font-size: 12px;
}

.signal-bars {
  display: inline-flex;
  align-items: end;
  gap: 4px;
  height: 30px;
}

.signal-bars span {
  width: 6px;
  border-radius: 999px;
  background: #2dd4bf;
}

.signal-bars span:nth-child(1) {
  height: 11px;
  opacity: 0.45;
}

.signal-bars span:nth-child(2) {
  height: 17px;
  opacity: 0.65;
}

.signal-bars span:nth-child(3) {
  height: 23px;
  opacity: 0.82;
}

.signal-bars span:nth-child(4) {
  height: 29px;
}

.panel-block h2 {
  font-size: 15px;
}

.panel-block label {
  font-size: 13px;
  line-height: 1.5;
}

textarea {
  width: 100%;
  resize: vertical;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  padding: 12px;
  line-height: 1.6;
  background: rgba(255, 255, 255, 0.08);
  color: #f8fafc;
  outline: none;
}

textarea:focus {
  border-color: #5eead4;
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.16);
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 48px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #04201f;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: 0.3px;
  box-shadow: 0 12px 30px rgba(45, 212, 191, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease, filter 0.18s ease;
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.04);
  box-shadow: 0 18px 40px rgba(45, 212, 191, 0.36);
}

.primary-button:active:not(:disabled) {
  transform: translateY(0);
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.button-icon {
  font-size: 13px;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
}

.status-strip span {
  padding: 5px 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
}

.agent-rail {
  display: grid;
  gap: 12px;
  padding: 14px;
}

.agent-rail h2 {
  font-size: 15px;
}

.agent-rail-list {
  position: relative;
  display: grid;
  gap: 8px;
}

.agent-rail-list::before {
  content: "";
  position: absolute;
  left: 13px;
  top: 16px;
  bottom: 16px;
  width: 2px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0.04));
  border-radius: 2px;
}

.rail-item {
  position: relative;
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  color: #cbd5e1;
  font-size: 13px;
}

.rail-index {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: #233042;
  color: #94a3b8;
  font-weight: 700;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.rail-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rail-state {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #64748b;
}

.rail-item.running .rail-index {
  background: #2dd4bf;
  color: #052e2b;
}

.rail-item.running .rail-state {
  background: #2dd4bf;
  box-shadow: 0 0 0 5px rgba(45, 212, 191, 0.14);
}

.rail-item.done .rail-index {
  background: rgba(34, 197, 94, 0.18);
  color: #bbf7d0;
}

.rail-item.done .rail-state {
  background: #22c55e;
}

.rail-item.error .rail-index {
  background: rgba(248, 113, 113, 0.18);
  color: #fecaca;
}

.rail-item.error .rail-state {
  background: #ef4444;
}

.workspace {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 24px;
  gap: 16px;
}

.workspace-header {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

.workspace-header h2 {
  font-size: 28px;
  line-height: 1.2;
  color: var(--ink);
}

.header-copy {
  max-width: 650px;
  margin: 9px 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.eyebrow {
  display: inline-block;
  margin: 0 0 10px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--teal);
  background: #e6fffb;
  border: 1px solid rgba(20, 184, 166, 0.22);
}

.metric-row {
  display: grid;
  grid-template-columns: repeat(3, 92px);
  gap: 10px;
}

.metric-row div {
  display: grid;
  gap: 2px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-soft);
}

.metric-row strong {
  font-size: 24px;
  background: linear-gradient(135deg, var(--ink), #334155);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.metric-row span {
  font-size: 12px;
}

.tabs {
  display: inline-flex;
  align-self: flex-start;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
}

.tab-button {
  border: 0;
  border-radius: 8px;
  padding: 9px 16px;
  background: transparent;
  cursor: pointer;
  color: #475467;
  font-weight: 600;
  transition: background 0.18s ease, color 0.18s ease;
}

.tab-button:hover:not(.active) {
  background: #f1f5f9;
  color: var(--ink);
}

.tab-button.active {
  background: var(--blue-soft);
  color: var(--blue);
  font-weight: 700;
}

.insight-band {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.insight-band article {
  position: relative;
  min-height: 128px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.97), rgba(248, 250, 252, 0.92)),
    var(--panel);
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.insight-band article:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: var(--shadow);
}

.insight-icon {
  display: inline-grid;
  place-items: center;
  min-width: 44px;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  background: #e6fffb;
  color: var(--teal);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.5px;
  border: 1px solid rgba(20, 184, 166, 0.18);
}

.insight-band h3 {
  margin-top: 12px;
  color: var(--ink);
  font-size: 16px;
}

.insight-band p {
  margin: 7px 0 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.tab-page {
  display: none;
  min-height: 0;
}

.tab-page.active {
  display: block;
}

.timeline {
  display: grid;
  gap: 14px;
  counter-reset: agent;
}

.agent-panel,
.resource-card,
.course-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow-soft);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.resource-card:hover,
.course-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 22px 60px rgba(17, 24, 39, 0.11);
}

.agent-panel {
  position: relative;
  overflow: hidden;
  counter-increment: agent;
}

/* status-keyed left accent border driven by the inner state badge */
.agent-panel::after {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 3px;
  background: transparent;
  transition: background 0.2s ease;
}

.agent-panel:has(.agent-state.running)::after {
  background: var(--blue);
}

.agent-panel:has(.agent-state.done)::after {
  background: var(--teal-bright);
}

.agent-panel:has(.agent-state.error)::after {
  background: #ef4444;
}

.agent-panel:has(.agent-state.running) {
  box-shadow: 0 0 0 1px rgba(37, 99, 235, 0.18), var(--shadow);
}

.agent-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(232, 240, 255, 0.7), rgba(248, 250, 252, 0.96)),
    var(--panel-soft);
}

.agent-head::before {
  content: counter(agent);
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: #fff;
  border: 1px solid var(--line-strong);
  color: #475467;
  font-size: 14px;
  font-weight: 800;
  box-shadow: var(--shadow-soft);
}

.agent-panel:has(.agent-state.running) .agent-head::before {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}

.agent-panel:has(.agent-state.done) .agent-head::before {
  background: #e6fffb;
  border-color: rgba(20, 184, 166, 0.4);
  color: var(--teal);
}

.agent-head h3 {
  margin: 0;
  font-size: 16px;
}

.agent-head p {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: 13px;
}

.agent-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex: none;
  padding: 5px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #475467;
  background: #edf2f7;
  border: 1px solid transparent;
}

.agent-state::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
}

.agent-state.running {
  color: var(--blue);
  background: #dbeafe;
  border-color: rgba(37, 99, 235, 0.2);
}

.agent-state.running::before {
  opacity: 1;
  animation: pulse-dot 1.1s ease-in-out infinite;
}

.agent-state.done {
  color: var(--green);
  background: #dff7ed;
  border-color: rgba(18, 128, 92, 0.2);
}

.agent-state.error {
  color: #b42318;
  background: #fee4e2;
  border-color: rgba(180, 35, 24, 0.2);
}

@keyframes pulse-dot {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(37, 99, 235, 0.5);
  }
  50% {
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0);
  }
}

.agent-output {
  padding: 16px;
  line-height: 1.75;
  overflow-wrap: anywhere;
  min-height: 72px;
}

.agent-output.muted {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 56px;
  color: #94a3b8;
  font-size: 13px;
}

.agent-output.muted::before {
  content: "";
  flex: none;
  width: 18px;
  height: 18px;
  border: 2px dashed #cbd5e1;
  border-radius: 50%;
}

.agent-output h1,
.agent-output h2,
.agent-output h3,
.agent-output h4 {
  margin: 18px 0 8px;
  line-height: 1.35;
}

.agent-output h1 {
  font-size: 20px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}

.agent-output h2 {
  font-size: 18px;
}

.agent-output h3 {
  font-size: 16px;
}

.agent-output h4 {
  font-size: 14px;
  color: #334155;
}

.agent-output h1:first-child,
.agent-output h2:first-child,
.agent-output h3:first-child,
.agent-output h4:first-child {
  margin-top: 0;
}

.agent-output hr {
  margin: 18px 0;
  border: 0;
  border-top: 1px solid var(--line);
}

.agent-output a {
  color: var(--blue);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.agent-output strong {
  color: var(--ink);
  font-weight: 700;
}

.agent-output pre.ascii {
  font-size: 12.5px;
  line-height: 1.5;
  white-space: pre;
  color: #334155;
  background: #f8fafc;
  border: 1px solid var(--line);
}

.agent-output ul,
.agent-output ol {
  margin: 8px 0;
  padding-left: 20px;
}

.agent-output li {
  margin: 4px 0;
}

.agent-output blockquote {
  margin: 12px 0;
  padding: 10px 14px;
  border-left: 3px solid var(--orange);
  border-radius: 0 8px 8px 0;
  background: #fff7ed;
  color: #92400e;
  font-size: 14px;
}

.agent-output .md-table-wrap {
  margin: 12px 0;
  overflow-x: auto;
  border-radius: 8px;
}

.agent-output table {
  width: auto;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.agent-output th,
.agent-output td {
  border: 1px solid var(--line);
  padding: 8px 10px;
  min-width: 80px;
  vertical-align: top;
  line-height: 1.5;
}

.agent-output th {
  background: var(--panel-soft);
  font-weight: 700;
  text-align: left;
  white-space: nowrap;
}

.agent-output code,
.agent-output pre {
  background: #f1f5f9;
  border-radius: 6px;
}

.agent-output code {
  padding: 2px 5px;
}

.agent-output pre {
  padding: 12px;
  overflow-x: auto;
}

.resource-grid,
.course-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.resource-card,
.course-card {
  padding: 16px;
}

.resource-card h3,
.course-card h3 {
  margin: 0 0 8px;
  font-size: 16px;
}

.resource-card h3::before,
.course-card h3::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 2px;
  background: #2dd4bf;
  vertical-align: middle;
}

.resource-card p,
.course-card p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.6;
}

.course-meta {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  color: var(--orange);
  font-size: 12px;
}

@media (max-width: 920px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .side-panel {
    min-height: auto;
  }

  .workspace-header {
    flex-direction: column;
  }

  .insight-band {
    grid-template-columns: 1fr;
  }

  .metric-row {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 540px) {
  .workspace,
  .side-panel {
    padding: 16px;
  }

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

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

  .tab-button {
    padding: 9px 6px;
    font-size: 13px;
  }
}
