:root {
  color-scheme: light;
  --bg: #eef3f8;
  --bg-accent: #d9e3ee;
  --panel: rgba(248, 251, 255, 0.88);
  --panel-strong: #ffffff;
  --line: rgba(30, 53, 79, 0.12);
  --line-strong: rgba(26, 93, 160, 0.24);
  --text: #152231;
  --muted: #5e6d7d;
  --primary: #165ea5;
  --primary-strong: #0f457a;
  --secondary: #cf4a3d;
  --success: #0c7b5f;
  --danger: #a92f36;
  --shadow: 0 18px 45px rgba(23, 39, 57, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Bahnschrift", "Segoe UI", "Microsoft JhengHei UI", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(207, 74, 61, 0.14), transparent 22rem),
    radial-gradient(circle at bottom right, rgba(22, 94, 165, 0.14), transparent 26rem),
    linear-gradient(135deg, var(--bg), var(--bg-accent));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(22, 94, 165, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(22, 94, 165, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.95), transparent);
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(19rem, 24rem) minmax(0, 1fr);
  gap: 1.5rem;
  min-height: 100vh;
  padding: 1.5rem;
}

.sidebar,
.chat-stage {
  position: relative;
  z-index: 1;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.brand-card,
.panel,
.job-spotlight,
.composer,
.chat-log {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 1.4rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.brand-card,
.panel,
.job-spotlight,
.composer {
  padding: 1.25rem;
}

.eyebrow,
.panel-title {
  margin: 0 0 0.5rem;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--secondary);
}

.brand-card h1,
.spotlight-head h2 {
  margin: 0 0 0.75rem;
  line-height: 1;
}

.brand-card h1 {
  font-size: clamp(1.9rem, 3vw, 2.8rem);
}

.lead,
.steps,
.meta-stack,
.drop-subtitle,
.job-status,
.spotlight-tip {
  color: var(--muted);
}

.steps {
  margin: 0;
  padding-left: 1.15rem;
  line-height: 1.75;
}

.meta-stack {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.95rem;
}

.chat-stage {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 1rem;
}

.job-spotlight {
  overflow: hidden;
  border-color: var(--line-strong);
  background:
    linear-gradient(135deg, rgba(22, 94, 165, 0.08), rgba(207, 74, 61, 0.08)),
    var(--panel);
}

.job-spotlight.is-running {
  animation: spotlightPulse 2.8s ease-in-out infinite;
}

.spotlight-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: start;
}

.spotlight-head h2 {
  font-size: clamp(1.3rem, 2vw, 1.8rem);
}

.spotlight-elapsed {
  min-width: 5.5rem;
  padding: 0.45rem 0.8rem;
  border-radius: 999px;
  background: rgba(22, 94, 165, 0.1);
  text-align: center;
  font-weight: 700;
  color: var(--primary-strong);
}

.spotlight-dashboard {
  display: grid;
  grid-template-columns: 7rem minmax(0, 1fr);
  gap: 1rem;
  align-items: center;
  margin-top: 1rem;
}

.spotlight-visual {
  display: flex;
  align-items: end;
  justify-content: space-between;
  height: 4.75rem;
  padding: 0.8rem;
  border-radius: 1.1rem;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(22, 94, 165, 0.16);
}

.signal-bar {
  width: 0.55rem;
  height: 24%;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--secondary), var(--primary));
  transform-origin: bottom center;
  opacity: 0.45;
}

.job-spotlight.is-running .signal-bar {
  animation: signalBounce 1s ease-in-out infinite;
}

.job-spotlight.is-running .signal-bar:nth-child(2) { animation-delay: 0.12s; }
.job-spotlight.is-running .signal-bar:nth-child(3) { animation-delay: 0.24s; }
.job-spotlight.is-running .signal-bar:nth-child(4) { animation-delay: 0.36s; }
.job-spotlight.is-running .signal-bar:nth-child(5) { animation-delay: 0.48s; }

.spotlight-metrics {
  display: grid;
  gap: 0.45rem;
}

.spotlight-percent {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  font-weight: 700;
  line-height: 1;
  color: var(--primary-strong);
}

.spotlight-feed {
  min-height: 2.8rem;
  padding: 0.8rem 0.95rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(22, 94, 165, 0.14);
  color: var(--muted);
  line-height: 1.5;
}

.spotlight-stages {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0.7rem;
  margin-top: 1rem;
}

.stage-chip {
  padding: 0.78rem;
  border-radius: 1rem;
  border: 1px solid rgba(22, 94, 165, 0.12);
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  font-size: 0.92rem;
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease, color 180ms ease;
}

.stage-chip.is-active {
  transform: translateY(-2px) scale(1.02);
  border-color: rgba(22, 94, 165, 0.4);
  background: rgba(22, 94, 165, 0.18);
  color: var(--primary-strong);
  box-shadow: 0 10px 24px rgba(22, 94, 165, 0.14);
}

.stage-chip.is-complete {
  border-color: rgba(12, 123, 95, 0.26);
  background: rgba(12, 123, 95, 0.1);
  color: var(--success);
}

.stage-chip.is-failed {
  border-color: rgba(169, 47, 54, 0.3);
  background: rgba(169, 47, 54, 0.1);
  color: var(--danger);
}

.spotlight-tip {
  margin-top: 1rem;
  min-height: 1.5rem;
  line-height: 1.6;
}

.spotlight-events {
  display: grid;
  gap: 0.55rem;
  margin-top: 1rem;
}

.event-pill {
  padding: 0.75rem 0.9rem;
  border-radius: 0.95rem;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(22, 94, 165, 0.14);
  color: var(--text);
  line-height: 1.5;
}

.spotlight-downloads,
.spotlight-files,
.file-list,
.message-files,
.message-downloads {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.spotlight-downloads,
.spotlight-files {
  margin-top: 1rem;
}

.chat-log {
  overflow: auto;
  padding: 1.25rem;
  min-height: 52vh;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 100%;
  text-align: center;
  color: var(--muted);
}

.message {
  padding: 1rem 1.1rem;
  border: 1px solid rgba(21, 34, 49, 0.08);
  border-radius: 1.2rem;
  background: var(--panel-strong);
}

.message + .message {
  margin-top: 0.9rem;
}

.message.user { border-left: 4px solid var(--secondary); }
.message.assistant { border-left: 4px solid var(--primary); }

.message-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.65rem;
  font-size: 0.9rem;
}

.message-role {
  font-weight: 700;
  color: var(--primary-strong);
}

.message-body {
  white-space: pre-wrap;
  line-height: 1.7;
}

.message-files,
.message-downloads {
  margin-top: 0.8rem;
}

.pill,
.download-link {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.5rem 0.8rem;
  border-radius: 999px;
  border: 1px solid rgba(22, 94, 165, 0.12);
  background: rgba(22, 94, 165, 0.06);
  text-decoration: none;
  color: var(--primary-strong);
  font-size: 0.9rem;
}

.pill-button {
  cursor: pointer;
}

.download-link {
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.76);
  border-color: rgba(22, 94, 165, 0.18);
}

.download-pill:hover,
.download-link:hover,
.pill-button:hover {
  transform: translateY(-1px);
}

.composer {
  padding: 1rem;
}

.drop-zone {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 1rem;
  border: 1.5px dashed rgba(22, 94, 165, 0.25);
  border-radius: 1.1rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.46);
}

.drop-zone.is-dragging {
  border-color: var(--secondary);
  background: rgba(207, 74, 61, 0.08);
}

#file-input {
  display: none;
}

.drop-copy {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.drop-title {
  font-weight: 700;
}

.prompt-label {
  display: block;
  margin: 1rem 0 0.55rem;
  font-weight: 700;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 7rem;
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: 0.9rem 1rem;
  font: inherit;
  color: inherit;
  background: rgba(255, 255, 255, 0.85);
}

textarea:focus {
  outline: 2px solid rgba(22, 94, 165, 0.22);
  border-color: rgba(22, 94, 165, 0.2);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-top: 1rem;
}

.primary-btn,
.secondary-btn {
  border: 0;
  border-radius: 999px;
  padding: 0.8rem 1.2rem;
  font: inherit;
  cursor: pointer;
  transition: transform 140ms ease, opacity 140ms ease, background 140ms ease;
}

.primary-btn {
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
}

.secondary-btn {
  background: rgba(22, 94, 165, 0.08);
  color: var(--primary-strong);
}

.primary-btn:hover,
.secondary-btn:hover {
  transform: translateY(-1px);
}

.primary-btn:disabled,
.secondary-btn:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

.job-status {
  font-size: 0.95rem;
}

@keyframes spotlightPulse {
  0%, 100% { box-shadow: 0 18px 45px rgba(23, 39, 57, 0.12); }
  50% { box-shadow: 0 22px 56px rgba(22, 94, 165, 0.2); }
}

@keyframes signalBounce {
  0%, 100% { height: 20%; opacity: 0.4; }
  50% { height: 100%; opacity: 1; }
}

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

  .chat-log {
    min-height: 40vh;
  }

  .drop-zone,
  .spotlight-stages,
  .spotlight-dashboard {
    grid-template-columns: 1fr;
  }

  .composer-actions,
  .spotlight-head {
    flex-direction: column;
    align-items: stretch;
  }

  .spotlight-elapsed {
    width: fit-content;
  }
}
