:root {
  color-scheme: light;
  --bg: #edf0ea;
  --surface: #ffffff;
  --surface-alt: #f4efe4;
  --surface-strong: #e5ece4;
  --ink: #182019;
  --muted: #617063;
  --line: #d4d9cf;
  --accent: #1f8b72;
  --accent-strong: #176b59;
  --accent-soft: #dbefe8;
  --amber: #b97922;
  --amber-soft: #f5e6ce;
  --danger: #b44436;
  --danger-soft: #f7dfdb;
  --shadow: 0 18px 48px rgba(34, 42, 35, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  background:
    radial-gradient(circle at top left, rgba(31, 139, 114, 0.08), transparent 28%),
    linear-gradient(180deg, #f6f7f2 0%, var(--bg) 100%);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea,
summary {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 20px;
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(320px, 1fr);
  gap: 20px;
  align-items: end;
}

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

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

h1,
h2 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: 34px;
}

h2 {
  font-size: 18px;
}

.lead,
.panel-copy,
.band-head p,
.composer-hint,
.empty-copy {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.lead {
  margin-top: 10px;
  max-width: 52rem;
}

.header-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.metric,
.timeline-panel,
.sidebar-band,
.composer,
.context-visual {
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(212, 217, 207, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.metric {
  padding: 14px 16px;
  min-width: 0;
}

.metric-label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}

.metric-value {
  display: block;
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.status-badge.is-idle {
  background: #ecefe9;
  color: var(--muted);
}

.status-badge.is-running {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.status-badge.is-warning {
  background: var(--amber-soft);
  color: #7a4f16;
}

.status-badge.is-done {
  background: var(--surface-strong);
  color: var(--ink);
}

.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(320px, 0.92fr);
  gap: 20px;
}

.timeline-panel,
.sidebar {
  min-height: 0;
}

.timeline-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.panel-head,
.band-head {
  padding: 18px 20px 0;
}

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

.panel-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.timeline {
  padding: 18px 20px 10px;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
}

.empty-state {
  padding: 24px;
  background: linear-gradient(180deg, rgba(244, 239, 228, 0.78), rgba(255, 255, 255, 0.95));
  border: 1px dashed rgba(31, 139, 114, 0.22);
  border-radius: 8px;
}

.empty-title {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 700;
}

.timeline-entry {
  position: relative;
  padding: 14px 14px 14px 18px;
  background: #fcfcfa;
  border: 1px solid #e4e8df;
  border-radius: 8px;
}

.timeline-entry::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
  border-radius: 8px 0 0 8px;
  background: var(--surface-strong);
}

.timeline-entry.is-step::before,
.timeline-entry.is-status::before,
.timeline-entry.is-phase::before,
.timeline-entry.is-result_saved::before,
.timeline-entry.is-result::before {
  background: var(--accent);
}

.timeline-entry.is-prompt::before,
.timeline-entry.is-review::before {
  background: var(--amber);
}

.timeline-entry.is-warning::before,
.timeline-entry.is-error::before {
  background: var(--danger);
}

.timeline-entry.is-speaker::before,
.timeline-entry.is-user::before {
  background: #6d8c4d;
}

.entry-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
}

.entry-label {
  min-width: 0;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.entry-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #eff3ed;
  color: var(--ink);
  font-size: 13px;
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.entry-context,
.entry-time {
  color: var(--muted);
  font-size: 12px;
}

.entry-content {
  margin-top: 10px;
  display: grid;
  gap: 8px;
}

.entry-content p {
  margin: 0;
  line-height: 1.6;
  overflow-wrap: anywhere;
}

.entry-content-checklist {
  display: block;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(244, 239, 228, 0.72), rgba(255, 255, 255, 0.96));
  white-space: pre-wrap;
  line-height: 1.7;
}

.timeline-entry.is-checklist-entry .entry-content-checklist {
  margin-top: 12px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

.debug-panel {
  border-top: 1px solid var(--line);
  padding: 0 20px 18px;
}

.debug-panel summary {
  padding-top: 14px;
  color: var(--muted);
  font-weight: 700;
  cursor: pointer;
}

.debug-log {
  margin: 12px 0 0;
  min-height: 120px;
  max-height: 260px;
  overflow: auto;
  padding: 14px;
  background: #131715;
  color: #eef5ee;
  border-radius: 8px;
  font-family:
    "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.sidebar {
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  gap: 16px;
}

.context-visual {
  position: relative;
  overflow: hidden;
  min-height: 220px;
  margin: 0;
}

.context-visual img {
  display: block;
  width: 100%;
  height: 220px;
  object-fit: cover;
}

.context-visual figcaption {
  position: absolute;
  inset: auto 0 0 0;
  padding: 16px;
  color: #ffffff;
  font-weight: 700;
  background: linear-gradient(180deg, transparent, rgba(24, 32, 25, 0.78));
}

.sidebar-band {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.step-list {
  list-style: none;
  margin: 0;
  padding: 10px 20px 20px;
  display: grid;
  gap: 12px;
}

.step-item {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-width: 0;
  color: var(--muted);
}

.step-marker {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #d8ddd3;
  border: 2px solid #d8ddd3;
}

.step-item.is-active {
  color: var(--ink);
  font-weight: 700;
}

.step-item.is-active .step-marker {
  background: #ffffff;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(31, 139, 114, 0.14);
}

.step-item.is-complete .step-marker {
  background: var(--accent);
  border-color: var(--accent);
}

.step-label {
  overflow-wrap: anywhere;
}

.prompt-card,
.result-empty,
.result-content {
  margin: 12px 20px 20px;
  padding: 14px;
  border-radius: 8px;
  background: #fbfbf8;
  border: 1px solid #e7eadf;
}

.prompt-card {
  background: linear-gradient(180deg, rgba(245, 230, 206, 0.62), rgba(255, 255, 255, 0.96));
  border-color: rgba(185, 121, 34, 0.26);
}

.prompt-card p,
.result-empty {
  margin: 0;
  line-height: 1.6;
}

.result-content {
  display: grid;
  gap: 14px;
  overflow: auto;
}

.result-meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.result-type {
  font-weight: 700;
}

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

.result-summary {
  display: grid;
  gap: 8px;
}

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

.artifact-item {
  border: 1px solid #e0e5da;
  border-radius: 8px;
  background: #ffffff;
  overflow: hidden;
}

.artifact-item summary {
  list-style: none;
  padding: 12px 14px;
  font-weight: 700;
  cursor: pointer;
}

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

.artifact-body {
  padding: 0 14px 14px;
}

.composer {
  padding: 16px 18px 18px;
  position: sticky;
  bottom: 0;
  backdrop-filter: blur(10px);
}

.composer-label {
  display: block;
  margin-bottom: 10px;
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

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

textarea {
  width: 100%;
  min-height: 56px;
  max-height: 220px;
  resize: none;
  padding: 14px;
  color: var(--ink);
  background: #fcfcfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  line-height: 1.6;
}

textarea:focus {
  border-color: var(--accent);
  outline: 2px solid rgba(31, 139, 114, 0.16);
}

button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

button:hover:not(:disabled) {
  background: var(--accent-strong);
}

button.secondary {
  background: #ffffff;
  color: var(--danger);
  border-color: rgba(180, 68, 54, 0.28);
}

button.secondary:hover:not(:disabled) {
  background: rgba(180, 68, 54, 0.06);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.composer-hint {
  margin-top: 10px;
  font-size: 12px;
}

@media (max-width: 1100px) {
  .app-header,
  .workspace {
    grid-template-columns: 1fr;
  }

  .sidebar {
    grid-template-rows: auto auto auto auto;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
    gap: 12px;
  }

  h1 {
    font-size: 28px;
  }

  .header-status,
  .composer-row {
    grid-template-columns: 1fr;
  }

  .panel-head {
    flex-direction: column;
  }

  .panel-actions {
    width: 100%;
  }

  .panel-actions button {
    flex: 1 1 0;
  }

  .timeline {
    padding: 14px 14px 8px;
  }

  .debug-panel {
    padding: 0 14px 14px;
  }

  .step-list,
  .prompt-card,
  .result-empty,
  .result-content {
    margin-left: 14px;
    margin-right: 14px;
  }
}
