:root {
  color-scheme: dark;
  --bg: #06100f;
  --bg-2: #0a1614;
  --panel: rgba(255, 255, 255, 0.075);
  --panel-strong: rgba(255, 255, 255, 0.12);
  --border: rgba(216, 255, 236, 0.13);
  --border-strong: rgba(216, 255, 236, 0.22);
  --text: #f5fbf8;
  --muted: #91a79f;
  --soft: #60736c;
  --green: #35e58f;
  --cyan: #20d4f0;
  --purple: #9d5cff;
  --amber: #ffb84d;
  --coral: #ff6b6b;
  --ink: #03120c;
  --shadow: 0 22px 80px rgba(0, 0, 0, 0.38);
  --small-shadow: 0 16px 42px rgba(0, 0, 0, 0.28);
  --radius: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, #071211 0%, var(--bg) 42%, #030706 100%),
    var(--bg);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  background-image:
    linear-gradient(rgba(216, 255, 236, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(216, 255, 236, 0.035) 1px, transparent 1px),
    linear-gradient(135deg, rgba(53, 229, 143, 0.08), transparent 42%, rgba(32, 212, 240, 0.055));
  background-size: 42px 42px, 42px 42px, 100% 100%;
  mask-image: linear-gradient(180deg, rgba(0, 0, 0, 0.85), transparent 88%);
}

body:not(.is-authed) .topbar,
body:not(.is-authed) main {
  display: none;
}

.login-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: clamp(38px, 9svh, 92px) 24px 28px;
  overflow: hidden auto;
  background:
    radial-gradient(circle at 16% 24%, rgba(53, 229, 143, 0.2), transparent 30%),
    radial-gradient(circle at 82% 16%, rgba(32, 212, 240, 0.16), transparent 34%),
    linear-gradient(135deg, #071211, #03120c 46%, #0d1622);
}

body.is-authed .login-screen {
  display: none;
}

.login-screen::before {
  position: absolute;
  inset: -28%;
  content: "";
  background:
    conic-gradient(from 120deg, rgba(53, 229, 143, 0.18), rgba(32, 212, 240, 0.2), rgba(157, 92, 255, 0.14), rgba(53, 229, 143, 0.18));
  filter: blur(34px);
  animation: loginFlow 14s linear infinite;
}

.login-flow span {
  position: absolute;
  width: 36vw;
  height: 36vw;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(53, 229, 143, 0.18), rgba(32, 212, 240, 0.12));
  filter: blur(18px);
  animation: loginDrift 12s ease-in-out infinite alternate;
}

.login-flow span:nth-child(1) { left: -8vw; top: 10vh; }
.login-flow span:nth-child(2) { right: -10vw; top: -8vh; animation-delay: -4s; }
.login-flow span:nth-child(3) { left: 35vw; bottom: -16vh; animation-delay: -7s; }

.login-card {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 16px;
  width: min(440px, 100%);
  padding: 30px;
  border: 1px solid rgba(216, 255, 236, 0.24);
  border-radius: 24px;
  background: rgba(5, 13, 12, 0.72);
  box-shadow: 0 34px 110px rgba(0, 0, 0, 0.44);
  backdrop-filter: blur(26px);
}

.login-card h1 {
  font-size: 36px;
}

.login-copy {
  color: #d2e3dc;
  line-height: 1.65;
}

.login-error {
  min-height: 20px;
  color: #ffb1a5;
  font-size: 13px;
}

.login-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.login-meta span {
  padding: 7px 10px;
  border: 1px solid rgba(216, 255, 236, 0.18);
  border-radius: 999px;
  color: #d2e3dc;
  background: rgba(255, 255, 255, 0.07);
  font-size: 12px;
  font-weight: 800;
}

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

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:active {
  transform: translateY(0) scale(0.985);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0;
}

h2 {
  font-size: 26px;
  letter-spacing: 0;
}

h3 {
  font-size: 18px;
  letter-spacing: 0;
}

main,
.topbar {
  width: min(1180px, calc(100% - 36px));
  margin: 0 auto;
}

.topbar {
  position: sticky;
  top: 10px;
  z-index: 20;
  display: grid;
  grid-template-columns: auto minmax(220px, 0.55fr) minmax(420px, 1fr) auto;
  align-items: center;
  gap: 14px;
  min-height: 70px;
  margin-top: max(14px, env(safe-area-inset-top));
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgba(5, 13, 12, 0.78);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(24px);
}

.logout-button {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  text-decoration: none;
  font-weight: 850;
  white-space: nowrap;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 13px;
  color: var(--ink);
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 0 28px rgba(53, 229, 143, 0.35);
}

.title-block {
  min-width: 0;
}

.title-block h1 {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.eyebrow,
.muted,
small {
  color: var(--muted);
}

.eyebrow {
  margin-bottom: 7px;
  font-size: 12px;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.tabs {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
}

.menu-button {
  display: none;
  width: 46px;
  height: 46px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.075);
  color: var(--text);
  place-items: center;
  gap: 4px;
}

.menu-button span {
  display: block;
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: var(--text);
  transition:
    transform 180ms ease,
    opacity 180ms ease;
}

body.nav-open .menu-button span:nth-child(1) {
  transform: translateY(6px) rotate(45deg);
}

body.nav-open .menu-button span:nth-child(2) {
  opacity: 0;
}

body.nav-open .menu-button span:nth-child(3) {
  transform: translateY(-6px) rotate(-45deg);
}

.tab,
.primary-action,
.tool-action,
.quick-actions button {
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255, 255, 255, 0.075);
  backdrop-filter: blur(20px);
}

.tab {
  min-height: 38px;
  min-width: 70px;
  padding: 8px 12px;
  border-radius: 999px;
  color: #bad0c7;
  font-size: 14px;
  font-weight: 760;
}

.tab:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.11);
}

.tab.is-active {
  color: var(--ink);
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 14px 36px rgba(53, 229, 143, 0.22);
}

main {
  padding: 0 0 58px;
}

.summary-band {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(360px, 1.1fr);
  align-items: center;
  gap: 22px;
  padding: 58px 4px 24px;
}

body:not([data-active-tab="workflow"]) .summary-band {
  display: none;
}

.summary-copy {
  animation: floatIn 0.68s both;
}

.summary-copy h2 {
  max-width: 760px;
  font-size: clamp(40px, 6vw, 78px);
  line-height: 0.98;
}

.summary-copy p,
.section-heading p {
  margin-top: 16px;
  color: #a6bbb3;
  font-size: 16px;
  line-height: 1.65;
}

.hero-metrics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 22px;
}

.hero-metrics span,
.status-pill,
.status-pills span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: #d7e6df;
  font-size: 13px;
  font-weight: 760;
}

.hero-metrics span {
  padding: 0 13px;
}

.hero-metrics span::before {
  width: 7px;
  height: 7px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--green);
  box-shadow: 0 0 14px rgba(53, 229, 143, 0.56);
  content: "";
  transform: rotate(45deg);
}

.hero-metrics span:nth-child(2)::before {
  background: var(--cyan);
  box-shadow: 0 0 14px rgba(32, 212, 240, 0.52);
}

.hero-metrics span:nth-child(3)::before {
  background: var(--purple);
  box-shadow: 0 0 14px rgba(157, 92, 255, 0.5);
}

.hero-visual {
  position: relative;
  min-height: 380px;
  border: 1px solid var(--border);
  border-radius: 26px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.035)),
    rgba(7, 18, 16, 0.58);
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(28px);
  animation: panelIn 0.42s both;
}

.hero-visual::before,
.hero-visual::after {
  position: absolute;
  content: "";
  pointer-events: none;
}

.hero-visual::before {
  inset: 18px;
  border: 1px dashed rgba(216, 255, 236, 0.12);
  border-radius: 20px;
}

.hero-visual::after {
  inset: auto 24px 24px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(53, 229, 143, 0.55), rgba(32, 212, 240, 0.42), transparent);
  animation: scanLine 3.4s ease-in-out infinite;
}

.process-map {
  position: absolute;
  right: 22px;
  bottom: 22px;
  width: min(74%, 520px);
  max-height: 210px;
  object-fit: contain;
  opacity: 0.92;
  filter: invert(1) hue-rotate(125deg) saturate(1.2) drop-shadow(0 18px 32px rgba(0, 0, 0, 0.26));
}

.signal-card {
  position: absolute;
  z-index: 2;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.035)),
    rgba(6, 16, 15, 0.74);
  box-shadow: var(--small-shadow);
  backdrop-filter: blur(20px);
}

.signal-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 780;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.signal-card strong {
  font-size: 26px;
}

.signal-main {
  top: 26px;
  left: 26px;
  width: 210px;
}

.signal-ring {
  top: 44px;
  right: 34px;
  width: 156px;
}

.signal-copy {
  left: 42px;
  bottom: 34px;
  width: 190px;
}

.signal-bars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  align-items: end;
  gap: 6px;
  height: 54px;
}

.signal-bars i {
  border-radius: 999px;
  background: linear-gradient(180deg, var(--green), var(--cyan));
  box-shadow: 0 0 18px rgba(53, 229, 143, 0.24);
  animation: grow 1s both;
}

.signal-bars i:nth-child(1) { height: 44%; }
.signal-bars i:nth-child(2) { height: 72%; animation-delay: 0.08s; }
.signal-bars i:nth-child(3) { height: 56%; animation-delay: 0.16s; }
.signal-bars i:nth-child(4) { height: 88%; animation-delay: 0.24s; }

.mini-ring {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background: conic-gradient(var(--purple) 72%, rgba(255, 255, 255, 0.08) 0);
  box-shadow: 0 0 32px rgba(157, 92, 255, 0.18);
}

.mini-ring b {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #071211;
}

.sparkline {
  display: flex;
  align-items: center;
  gap: 5px;
  height: 34px;
}

.sparkline i {
  width: 22px;
  height: 6px;
  border-radius: 999px;
  background: var(--amber);
  transform: translateY(var(--y, 0));
}

.sparkline i:nth-child(1) { --y: 10px; }
.sparkline i:nth-child(2) { --y: 2px; background: var(--green); }
.sparkline i:nth-child(3) { --y: -8px; background: var(--cyan); }
.sparkline i:nth-child(4) { --y: -2px; background: var(--purple); }
.sparkline i:nth-child(5) { --y: -12px; background: var(--coral); }

.pattern-field {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.pattern-field i {
  position: absolute;
  width: 8px;
  height: 8px;
  border: 1px solid rgba(216, 255, 236, 0.22);
  border-radius: 2px;
  transform: rotate(45deg);
  animation: twinkle 3s ease-in-out infinite;
}

.pattern-field i:nth-child(1) { top: 34%; left: 34%; background: rgba(53, 229, 143, 0.28); }
.pattern-field i:nth-child(2) { top: 21%; left: 58%; background: rgba(32, 212, 240, 0.24); animation-delay: 0.3s; }
.pattern-field i:nth-child(3) { top: 66%; left: 78%; background: rgba(157, 92, 255, 0.24); animation-delay: 0.6s; }
.pattern-field i:nth-child(4) { top: 76%; left: 45%; background: rgba(255, 184, 77, 0.24); animation-delay: 0.9s; }
.pattern-field i:nth-child(5) { top: 48%; left: 88%; background: rgba(255, 107, 107, 0.24); animation-delay: 1.2s; }
.pattern-field i:nth-child(6) { top: 15%; left: 42%; animation-delay: 1.5s; }
.pattern-field i:nth-child(7) { top: 84%; left: 18%; animation-delay: 1.8s; }
.pattern-field i:nth-child(8) { top: 56%; left: 24%; animation-delay: 2.1s; }

.panel {
  display: none;
  padding: 28px 0 0;
}

.panel.is-visible {
  display: block;
  animation: panelIn 0.42s both;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

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

.workspace-flow {
  margin-bottom: 18px;
}

.workspace-flow-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}

.workspace-flow-head .eyebrow {
  margin-bottom: 6px;
}

.workspace-flow-head span {
  max-width: 360px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  text-align: right;
}

.stage,
.output-item,
.check-row,
.agent-side,
.chat-card,
.prompt-output,
.prompt-form input,
.prompt-form textarea {
  border: 1px solid var(--border);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.11), rgba(255, 255, 255, 0.035)),
    rgba(7, 18, 16, 0.56);
  box-shadow: var(--shadow);
  backdrop-filter: blur(28px);
}

.stage,
.output-item {
  position: relative;
  min-height: 230px;
  padding: 18px;
  border-radius: 22px;
  overflow: hidden;
  animation: floatIn 0.7s both;
}

.stage::after,
.output-item::after {
  position: absolute;
  right: 16px;
  bottom: 15px;
  width: 52px;
  height: 52px;
  border: 1px solid rgba(216, 255, 236, 0.12);
  border-radius: 16px;
  background:
    linear-gradient(135deg, color-mix(in srgb, var(--accent, var(--green)), transparent 58%), transparent),
    rgba(255, 255, 255, 0.035);
  content: "";
  transform: rotate(8deg);
}

.stage:nth-child(1),
.output-item:nth-child(1) { --accent: var(--green); }
.stage:nth-child(2),
.stage:nth-child(5),
.output-item:nth-child(2),
.output-item:nth-child(5) { --accent: var(--cyan); }
.stage:nth-child(3),
.stage:nth-child(6),
.output-item:nth-child(3),
.output-item:nth-child(6) { --accent: var(--amber); }
.stage:nth-child(4),
.output-item:nth-child(4) { --accent: var(--purple); }

.stage:hover,
.output-item:hover,
.check-row:hover,
.run-item:hover,
.upload-item:hover {
  border-color: color-mix(in srgb, var(--accent, var(--green)), white 5%);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.05)),
    rgba(7, 18, 16, 0.64);
  transform: translateY(-2px);
}

.stage-index {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  margin-bottom: 14px;
  border-radius: 12px;
  color: var(--ink);
  background: linear-gradient(135deg, var(--accent, var(--green)), color-mix(in srgb, var(--accent, var(--green)), white 16%));
  box-shadow: 0 0 24px color-mix(in srgb, var(--accent, var(--green)), transparent 68%);
  font-size: 14px;
  font-weight: 850;
}

.stage h3,
.output-item h3 {
  margin-bottom: 12px;
}

.stage ul,
.output-item ul {
  position: relative;
  z-index: 1;
  margin: 0;
  padding-left: 18px;
  color: #a5bbb3;
  line-height: 1.66;
}

.checklist {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 980px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: 88px;
  padding: 14px;
  border-radius: 18px;
  color: #d7e6df;
  cursor: pointer;
}

.check-row input {
  flex: 0 0 auto;
  width: 19px;
  height: 19px;
  margin-top: 2px;
  accent-color: var(--green);
}

.check-row span {
  display: grid;
  gap: 7px;
}

.check-row strong {
  color: var(--text);
  font-size: 15px;
}

.check-row small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.prompt-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  max-width: 980px;
}

.prompt-form label,
.agent-side label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 760;
}

.prompt-form textarea,
.prompt-form input,
.agent-side select,
.agent-side input[type="file"],
.chat-compose textarea {
  width: 100%;
  min-height: 46px;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
  outline: none;
  background: rgba(255, 255, 255, 0.075);
}

.prompt-form textarea {
  min-height: 118px;
  resize: vertical;
}

.prompt-form label:last-of-type {
  grid-column: 1 / -1;
}

.primary-action,
.tool-action,
.quick-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border-radius: 14px;
  font-weight: 820;
}

.primary-action {
  width: max-content;
  color: var(--ink);
  border-color: transparent;
  background: linear-gradient(135deg, var(--green), var(--cyan));
  box-shadow: 0 14px 36px rgba(53, 229, 143, 0.22);
}

.primary-action:hover {
  box-shadow: 0 18px 46px rgba(53, 229, 143, 0.28);
}

.tool-action,
.quick-actions button {
  color: #d9eee6;
  background: rgba(255, 255, 255, 0.075);
}

.tool-action:hover,
.quick-actions button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.12);
}

.primary-action:focus-visible,
.tool-action:focus-visible,
.quick-actions button:focus-visible,
.tab:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(53, 229, 143, 0.28);
  outline-offset: 2px;
}

.prompt-output {
  max-width: 980px;
  min-height: 220px;
  margin: 18px 0 0;
  padding: 18px;
  overflow: auto;
  border-radius: 20px;
  color: #d9eee6;
  line-height: 1.65;
  white-space: pre-wrap;
}

.agent-shell {
  display: grid;
  grid-template-columns: 336px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.agent-side {
  position: sticky;
  top: 96px;
  display: grid;
  align-content: start;
  gap: 14px;
  max-height: calc(100vh - 112px);
  padding: 16px;
  overflow: auto;
  border-radius: 22px;
}

.quick-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.quick-actions button {
  min-height: 40px;
  padding: 0 10px;
  font-size: 12px;
}

.upload-list,
.run-list,
.file-space-grid {
  display: grid;
  gap: 8px;
}

.upload-item,
.run-item,
.file-space-shell,
.file-space,
.agent-note,
.history-panel,
.empty-state {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.065);
}

.file-space-shell {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.file-space-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.file-space-head h3 {
  font-size: 14px;
}

.file-space-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.file-space {
  position: relative;
  display: grid;
  gap: 6px;
  min-height: 112px;
  padding: 12px;
  overflow: hidden;
  color: var(--text);
  text-align: left;
}

.file-space::before {
  position: absolute;
  right: 12px;
  top: 12px;
  width: 10px;
  height: 10px;
  border-radius: 3px;
  background: var(--accent, var(--green));
  box-shadow: 0 0 18px color-mix(in srgb, var(--accent, var(--green)), transparent 35%);
  content: "";
  transform: rotate(45deg);
}

.file-space::after {
  position: absolute;
  right: -18px;
  bottom: -22px;
  width: 82px;
  height: 82px;
  border: 1px solid color-mix(in srgb, var(--accent, var(--green)), transparent 55%);
  border-radius: 24px;
  content: "";
  transform: rotate(12deg);
}

.file-space:hover,
.file-space.is-active {
  border-color: color-mix(in srgb, var(--accent, var(--green)), white 8%);
  background:
    linear-gradient(145deg, color-mix(in srgb, var(--accent, var(--green)), transparent 82%), rgba(255, 255, 255, 0.04)),
    rgba(7, 18, 16, 0.68);
}

.file-space span {
  color: #d9eee6;
  font-size: 14px;
  font-weight: 820;
}

.file-space strong {
  color: var(--accent, var(--green));
  font-size: 32px;
  line-height: 1;
}

.file-space small {
  max-width: 110px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.file-space.is-active small {
  color: #cfe4dc;
}

.upload-item,
.run-item {
  position: relative;
  display: grid;
  gap: 5px;
  width: 100%;
  padding: 11px;
  color: var(--text);
  text-align: left;
  animation: floatIn 0.34s both;
}

.upload-item::before,
.run-item::before {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 8px;
  height: 8px;
  border-radius: 2px;
  background: var(--accent, var(--green));
  box-shadow: 0 0 14px color-mix(in srgb, var(--accent, var(--green)), transparent 50%);
  content: "";
  transform: rotate(45deg);
}

.upload-item b,
.run-item strong {
  padding-right: 18px;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.upload-item span,
.agent-note span,
.empty-state,
.run-item small {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}

.upload-item details {
  margin-top: 3px;
}

.upload-item summary,
.run-item span {
  color: var(--green);
  cursor: pointer;
  font-size: 12px;
  font-weight: 820;
}

.upload-item pre {
  max-height: 180px;
  margin: 8px 0 0;
  padding: 10px;
  overflow: auto;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.26);
  color: #d9eee6;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.agent-note,
.history-panel {
  display: grid;
  gap: 9px;
  padding: 12px;
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

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

.history-head h3 {
  font-size: 14px;
}

.run-item span {
  cursor: inherit;
}

.danger-action {
  color: #ffd8d8;
  border-color: rgba(255, 107, 107, 0.24);
}

.danger-action:hover {
  color: #fff;
  border-color: rgba(255, 107, 107, 0.42);
  background: rgba(255, 107, 107, 0.12);
}

.run-item strong {
  overflow: hidden;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-state {
  padding: 11px;
}

.chat-card {
  display: grid;
  grid-template-rows: auto auto minmax(500px, 62vh) auto;
  overflow: hidden;
  border-radius: 24px;
}

.chat-toolbar,
.chat-compose,
.insight-strip {
  background: rgba(255, 255, 255, 0.04);
}

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

.status-pill {
  padding: 0 12px;
  white-space: nowrap;
}

.status-pill::before {
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 2px;
  background: var(--muted);
  content: "";
  transform: rotate(45deg);
}

.status-pill.is-ok {
  color: #dbfff0;
  border-color: rgba(53, 229, 143, 0.28);
}

.status-pill.is-ok::before {
  background: var(--green);
  box-shadow: 0 0 16px rgba(53, 229, 143, 0.6);
}

.status-pill.is-warn::before {
  background: var(--amber);
}

.status-pill.is-error::before {
  background: var(--coral);
}

.insight-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}

.insight-strip article {
  min-height: 92px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.025)),
    rgba(7, 18, 16, 0.5);
}

.insight-strip article:nth-child(1) { --mini: var(--green); }
.insight-strip article:nth-child(2) { --mini: var(--cyan); }
.insight-strip article:nth-child(3) { --mini: var(--amber); }

.insight-strip span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 820;
}

.insight-strip span::before {
  width: 7px;
  height: 7px;
  border-radius: 2px;
  background: var(--mini, var(--green));
  content: "";
  transform: rotate(45deg);
}

.insight-strip strong {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 14px;
  padding: 20px;
  overflow: auto;
  scroll-behavior: smooth;
}

.chat-msg {
  position: relative;
  max-width: min(900px, 92%);
  padding: 15px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.105), rgba(255, 255, 255, 0.035)),
    rgba(7, 18, 16, 0.58);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.22);
  line-height: 1.7;
  animation: messageIn 0.28s both;
}

.chat-msg.user {
  justify-self: end;
  border-color: rgba(32, 212, 240, 0.28);
  background:
    linear-gradient(145deg, rgba(32, 212, 240, 0.17), rgba(157, 92, 255, 0.08)),
    rgba(7, 18, 16, 0.72);
}

.chat-msg.assistant {
  justify-self: start;
}

.chat-msg.is-loading {
  overflow: hidden;
}

.chat-msg.is-loading::after {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--green), var(--cyan), transparent);
  animation: loadingLine 1.18s ease-in-out infinite;
  content: "";
}

.chat-msg b {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 820;
}

.chat-msg p {
  margin: 0;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.chat-msg-body {
  overflow-wrap: anywhere;
}

.chat-msg-body > :last-child {
  margin-bottom: 0;
}

.chat-msg-body h3,
.chat-msg-body h4,
.chat-msg-body h5 {
  margin: 16px 0 8px;
}

.chat-msg-body ul,
.chat-msg-body ol {
  margin: 8px 0 12px;
  padding-left: 20px;
}

.chat-msg-body code {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: #dcfff1;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
}

.result-code {
  max-height: 360px;
  margin: 10px 0;
  padding: 12px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.28);
  color: #d9eee6;
  white-space: pre-wrap;
}

.result-code code {
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
}

.result-table-wrap {
  max-width: 100%;
  margin: 12px 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 16px;
}

.result-table-wrap table {
  width: 100%;
  min-width: 620px;
  border-collapse: collapse;
  background: rgba(5, 13, 12, 0.72);
}

.result-table-wrap th,
.result-table-wrap td {
  padding: 10px 11px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
  text-align: left;
  vertical-align: top;
}

.result-table-wrap th {
  color: var(--ink);
  background: linear-gradient(135deg, var(--green), var(--cyan));
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chat-compose {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--border);
}

.chat-compose textarea {
  min-height: 78px;
  max-height: 190px;
  resize: vertical;
}

@keyframes floatIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.992);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes messageIn {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.99);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes grow {
  from {
    transform: scaleY(0.18);
    transform-origin: bottom;
  }
}

@keyframes loadingLine {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(100%);
  }
}

@keyframes scanLine {
  0%,
  100% {
    opacity: 0.38;
    transform: translateX(-8%);
  }
  50% {
    opacity: 1;
    transform: translateX(8%);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.35;
    transform: rotate(45deg) scale(0.82);
  }
  50% {
    opacity: 1;
    transform: rotate(45deg) scale(1.16);
  }
}

@keyframes loginFlow {
  from {
    transform: rotate(0deg) scale(1);
  }
  to {
    transform: rotate(360deg) scale(1.08);
  }
}

@keyframes loginDrift {
  from {
    transform: translate3d(0, 0, 0) scale(0.96);
  }
  to {
    transform: translate3d(42px, -34px, 0) scale(1.08);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (max-width: 1120px) {
  .topbar {
    grid-template-columns: auto 1fr auto;
  }

  .tabs {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }

  .summary-band,
  .agent-shell {
    grid-template-columns: 1fr;
  }

  .agent-side {
    position: static;
    max-height: none;
  }
}

@media (max-width: 900px) {
  main,
  .topbar {
    width: min(100% - 24px, 1180px);
  }

  .topbar {
    top: 8px;
    grid-template-columns: auto 1fr auto auto;
    gap: 10px;
    min-height: 64px;
    padding: 9px;
    border-radius: 18px;
  }

  .brand {
    grid-column: auto;
  }

  .brand span:last-child {
    display: none;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    border-radius: 14px;
  }

  .title-block {
    grid-column: auto;
    min-width: 0;
  }

  .title-block .eyebrow {
    display: none;
  }

  .title-block h1 {
    font-size: 22px;
  }

  .menu-button {
    display: grid;
  }

  .tabs {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    display: none;
    grid-template-columns: 1fr;
    gap: 8px;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: rgba(5, 13, 12, 0.94);
    box-shadow: var(--shadow);
    backdrop-filter: blur(24px);
  }

  body.nav-open .tabs {
    display: grid;
  }

  .tab {
    justify-content: center;
    width: 100%;
    min-height: 46px;
  }

  .summary-band {
    gap: 16px;
    padding-top: 24px;
  }

  .summary-copy h2 {
    font-size: 34px;
  }

  .hero-visual {
    min-height: 300px;
  }

  .signal-main {
    top: 16px;
    left: 16px;
    width: 168px;
  }

  .signal-ring {
    top: 22px;
    right: 16px;
    width: 132px;
  }

  .signal-copy {
    left: 18px;
    bottom: 18px;
    width: 160px;
  }

  .signal-card strong {
    font-size: 21px;
  }

  .process-map {
    width: min(78%, 360px);
    max-height: 150px;
  }

  .stage-grid,
  .output-grid,
  .checklist,
  .prompt-form,
  .chat-compose,
  .insight-strip {
    grid-template-columns: 1fr;
  }

  .section-heading {
    display: block;
  }

  .workspace-flow-head {
    align-items: start;
    flex-direction: column;
  }

  .workspace-flow-head span {
    max-width: none;
    text-align: left;
  }

  .chat-toolbar {
    align-items: stretch;
    flex-direction: column;
  }
}

@media (max-width: 560px) {
  .login-card {
    padding: 22px;
  }

  h1 {
    font-size: 20px;
  }

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

  .tab {
    min-width: 64px;
    padding: 8px 10px;
  }

  .quick-actions {
    grid-template-columns: 1fr;
  }

  .chat-msg {
    max-width: 100%;
  }

  .signal-card {
    position: relative;
    inset: auto;
    width: auto;
    margin: 12px;
  }

  .process-map {
    position: relative;
    right: auto;
    bottom: auto;
    width: calc(100% - 24px);
    margin: 10px 12px 18px;
  }
}

@media (max-width: 900px) {
  .login-screen {
    padding-top: max(26px, env(safe-area-inset-top));
  }

  body[data-active-tab="agent"] main,
  body[data-active-tab="agent"] .topbar {
    width: min(100% - 10px, 1180px);
  }

  .agent-shell {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  .chat-card {
    order: 1;
    min-height: min(760px, calc(100svh - 178px));
    border-radius: 20px;
  }

  .agent-side {
    order: 2;
    max-height: none;
    padding: 12px;
    border-radius: 18px;
  }

  .chat-log {
    padding: 12px;
  }

  .chat-msg {
    max-width: 100%;
    padding: 13px;
  }

  .chat-msg-body {
    font-size: 14px;
    line-height: 1.72;
  }

  .chat-toolbar {
    align-items: stretch;
    gap: 8px;
    padding: 12px;
  }

  .insight-strip {
    display: none;
  }

  .chat-compose {
    position: sticky;
    bottom: 0;
    grid-template-columns: 1fr;
    padding: 10px;
    background: rgba(5, 13, 12, 0.92);
    backdrop-filter: blur(20px);
  }

  .chat-compose textarea {
    min-height: 84px;
    max-height: 140px;
  }

  .chat-compose .primary-action {
    width: 100%;
    min-height: 52px;
    font-size: 16px;
  }
}
