:root {
  --ink: #172033;
  --muted: #687188;
  --line: #e5e9f2;
  --surface: rgba(255,255,255,.94);
  --primary: #6d4aff;
  --primary-dark: #5231df;
  --success: #16845b;
  --warning: #bd6a16;
  --danger: #c53d4d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: #f5f7fb;
}
* { box-sizing: border-box; }
html, body { width: 100%; max-width: 100%; overflow-x: hidden; }
body { margin: 0; min-height: 100vh; background:
  radial-gradient(circle at 10% 0%, rgba(109,74,255,.13), transparent 32rem),
  radial-gradient(circle at 100% 20%, rgba(22,132,91,.09), transparent 28rem), #f5f7fb; }
.shell { width: min(980px, calc(100% - 32px)); margin: 0 auto; padding: 44px 0 72px; }
#workspace { display: flex; flex-direction: column; }
#workspace.execution-active .activity-panel { order: -1; border-color: rgba(109,74,255,.32); box-shadow: 0 20px 60px rgba(72,52,160,.12); }
.hero { padding: 0 4px 22px; }
.eyebrow { color: var(--primary); font-size: 12px; letter-spacing: .18em; font-weight: 800; }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; }
h1 { margin: 8px 0 4px; font-size: clamp(34px, 5vw, 54px); letter-spacing: -.04em; }
.hero p, .section-heading p { margin: 0; color: var(--muted); }
.badge { border-radius: 999px; padding: 8px 13px; background: #ebe7ff; color: #5636d8; font-size: 13px; font-weight: 750; white-space: nowrap; }
.badge.started, .badge.approved, .badge.revision_requested { background: #e6f1ff; color: #2366b3; }
.badge.completed { background: #e7f7f0; color: var(--success); }
.badge.failed, .badge.expired, .badge.cancelled, .badge.needs_attention { background: #fff0f1; color: var(--danger); }
.panel { min-width: 0; max-width: 100%; margin-top: 18px; padding: clamp(20px, 4vw, 32px); border: 1px solid rgba(224,228,238,.92); border-radius: 22px; background: var(--surface); box-shadow: 0 18px 55px rgba(30,42,70,.075); backdrop-filter: blur(14px); }
.meta-grid { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 12px; margin-bottom: 24px; }
.meta-grid div { min-width: 0; padding: 13px 15px; border-radius: 14px; background: #f7f8fc; }
.meta-grid span { display: block; margin-bottom: 4px; color: var(--muted); font-size: 12px; }
.meta-grid strong { display: block; overflow-wrap: anywhere; font-size: 14px; }
#countdown { white-space: nowrap; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.summary-panel h2 { margin: 0 0 16px; font-size: 25px; line-height: 1.35; overflow-wrap: anywhere; }
.plan-steps { margin: 0; padding-left: 28px; }
.plan-steps li { padding: 7px 0 7px 5px; line-height: 1.55; }
.plan-steps li::marker { color: var(--primary); font-weight: 800; }
.plan-body { min-width: 0; max-width: 100%; margin-top: 22px; border-top: 1px solid var(--line); padding-top: 18px; }
.plan-body summary { cursor: pointer; color: #443177; font-weight: 750; }
.rendered-plan { margin-top: 16px; padding: clamp(16px, 3vw, 24px); max-width: 100%; overflow-wrap: anywhere; border: 1px solid var(--line); border-radius: 14px; background: #fafbfe; color: var(--ink); line-height: 1.72; }
.rendered-plan > :first-child { margin-top: 0; }
.rendered-plan > :last-child { margin-bottom: 0; }
.rendered-plan h1, .rendered-plan h2, .rendered-plan h3, .rendered-plan h4 { margin: 1.35em 0 .55em; color: var(--ink); line-height: 1.3; letter-spacing: -.015em; }
.rendered-plan h1 { padding-bottom: .38em; border-bottom: 1px solid var(--line); font-size: clamp(24px, 5vw, 32px); }
.rendered-plan h2 { padding-bottom: .3em; border-bottom: 1px solid var(--line); font-size: clamp(20px, 4vw, 25px); }
.rendered-plan h3 { font-size: 18px; }
.rendered-plan p { margin: .75em 0; }
.rendered-plan ul, .rendered-plan ol { margin: .7em 0; padding-left: 1.55em; }
.rendered-plan li { margin: .4em 0; padding-left: .15em; }
.rendered-plan li::marker { color: var(--primary); font-weight: 750; }
.rendered-plan blockquote { margin: 1em 0; padding: .7em 1em; border-left: 4px solid var(--primary); border-radius: 0 10px 10px 0; background: #f1efff; color: #4f4668; }
.rendered-plan code { padding: .15em .38em; border-radius: 5px; background: #eceff5; color: #9a3150; font: .9em/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.rendered-plan pre { max-width: 100%; overflow-x: auto; margin: 1em 0; padding: 16px; border-radius: 11px; background: #171b28; color: #eef1ff; }
.rendered-plan pre code { padding: 0; background: transparent; color: inherit; white-space: pre; }
.rendered-plan table { display: block; width: 100%; max-width: 100%; overflow-x: auto; border-collapse: collapse; margin: 1em 0; }
.rendered-plan th, .rendered-plan td { min-width: 110px; padding: 9px 11px; border: 1px solid var(--line); text-align: left; vertical-align: top; }
.rendered-plan th { background: #f1f3f8; }
.rendered-plan a { color: var(--primary-dark); font-weight: 650; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.rendered-plan hr { margin: 1.5em 0; border: 0; border-top: 1px solid var(--line); }
.rendered-plan .omitted-image { display: inline-block; padding: 3px 7px; border-radius: 6px; background: #eef0f5; color: var(--muted); font-size: 13px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.section-heading h2 { margin: 0 0 5px; font-size: 20px; }
.button-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.button { min-height: 46px; border: 1px solid transparent; border-radius: 12px; padding: 10px 15px; font: inherit; font-weight: 750; cursor: pointer; transition: transform .15s ease, box-shadow .15s ease, opacity .15s ease; }
.button:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 7px 18px rgba(45,42,80,.12); }
.button:disabled { cursor: not-allowed; opacity: .45; }
.primary { background: var(--primary); color: white; }
.primary:hover:not(:disabled) { background: var(--primary-dark); }
.secondary { background: #e9f2ff; color: #245e9d; }
.danger-ghost { background: #fff1f2; color: var(--danger); }
.outline { background: white; border-color: #d8dcea; color: #454d62; }
.warning { background: #fff0d9; color: #9a5510; }
.revision-box { margin-top: 18px; padding: 18px; border: 1px solid #eadfca; border-radius: 14px; background: #fffbf3; }
.revision-box label { display: block; margin-bottom: 8px; font-weight: 750; }
textarea { width: 100%; resize: vertical; border: 1px solid #d7dce8; border-radius: 11px; padding: 13px; font: inherit; line-height: 1.55; outline: none; }
textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(109,74,255,.12); }
.revision-footer { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 10px; color: var(--muted); font-size: 12px; }
.decision-confirm { margin-top: 18px; padding: 18px; border: 1px solid #d9d0ff; border-radius: 14px; background: #f7f5ff; }
.decision-confirm > strong { display: block; color: #4f35bc; font-size: 16px; }
.decision-confirm p { margin: 8px 0 0; color: var(--muted); line-height: 1.55; }
.decision-confirm-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 14px; }
.decision-error { padding: 10px 12px; border-radius: 10px; background: #fff0f1; color: var(--danger) !important; }
.connection-badge { display: inline-flex; align-items: center; gap: 9px; max-width: 100%; border-radius: 999px; padding: 8px 12px; background: #e9f8f2; color: #147452; font-size: 12px; font-weight: 750; white-space: nowrap; }
.connection-badge.connecting { background: #fff5df; color: #9a5b12; }
.connection-badge.disconnected { background: #fff0f1; color: var(--danger); }
.live-dot { flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%; background: #26b47e; box-shadow: 0 0 0 5px rgba(38,180,126,.12); }
.connecting .live-dot { background: #e49a25; box-shadow: 0 0 0 5px rgba(228,154,37,.13); animation: pulse 1.4s ease-in-out infinite; }
.disconnected .live-dot { background: var(--danger); box-shadow: 0 0 0 5px rgba(197,61,77,.12); animation: none; }
@keyframes pulse { 50% { opacity: .38; } }
.execution-dashboard { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .8fr); gap: 14px; }
.current-activity { min-width: 0; padding: 18px; border: 1px solid #ded8ff; border-radius: 16px; background: linear-gradient(135deg, #f7f5ff, #f4f8ff); }
.activity-caption { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-bottom: 11px; color: var(--muted); font-size: 12px; }
.stage-chip { display: inline-flex; align-items: center; min-height: 25px; border-radius: 999px; padding: 4px 9px; background: #e8e2ff; color: #5336c5; font-weight: 800; }
.stage-chip.completed { background: #dcf5e9; color: #13724f; }
.stage-chip.failed, .stage-chip.needs_attention { background: #ffe5e8; color: var(--danger); }
.current-activity strong { display: block; min-height: 3em; color: #292341; font-size: clamp(16px, 2.5vw, 20px); line-height: 1.5; overflow-wrap: anywhere; }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.metric-grid div { min-width: 0; padding: 13px 14px; border-radius: 14px; background: #f7f8fc; }
.metric-grid span { display: block; margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.metric-grid strong { display: block; font-size: 21px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.timeline-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin: 22px 0 10px; }
.timeline-heading strong, .timeline-heading span { display: block; }
.timeline-heading span { margin-top: 3px; color: var(--muted); font-size: 12px; }
.timeline-toggle { flex: 0 0 auto; border: 1px solid #d8dcea; border-radius: 999px; padding: 7px 10px; background: white; color: #4e5669; font: inherit; font-size: 12px; font-weight: 700; cursor: pointer; }
.timeline-empty { padding: 25px 16px; border: 1px dashed #d8ddea; border-radius: 13px; color: var(--muted); text-align: center; }
.timeline { display: grid; gap: 10px; max-height: 520px; overflow: auto; overscroll-behavior: contain; }
.timeline-entry { position: relative; padding: 12px 14px 12px 42px; border-radius: 13px; background: #f8f9fc; color: #40495f; line-height: 1.5; overflow-wrap: anywhere; }
.timeline-entry::before { content: ""; position: absolute; left: 17px; top: 19px; width: 9px; height: 9px; border-radius: 50%; background: var(--primary); box-shadow: 0 0 0 4px #ebe7ff; }
.timeline-entry.command::before { background: #2472bd; box-shadow: 0 0 0 4px #e1efff; }
.timeline-entry.file_change::before { background: #16845b; box-shadow: 0 0 0 4px #dff5eb; }
.timeline-entry.approval_review::before { background: #bd6a16; box-shadow: 0 0 0 4px #fff0dc; }
.timeline-entry.error::before, .timeline-entry.needs_attention::before { background: var(--danger); box-shadow: 0 0 0 4px #ffe6e9; }
.timeline-entry-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 5px 12px; margin-bottom: 5px; }
.timeline-entry-label { color: #5d6680; font-size: 12px; font-weight: 800; }
.timeline-message { white-space: pre-wrap; }
.timeline-entry time { display: flex; flex-wrap: wrap; gap: 2px 8px; color: #8a92a5; font-size: 11px; font-variant-numeric: tabular-nums; }
.timeline-entry time span { white-space: nowrap; }
.error-panel { border-color: #f2cbd0; background: #fff7f8; }
.error-panel h2 { color: var(--danger); }
.hidden { display: none !important; }
:root[data-time-theme="night"] {
  --ink: #f3f4f6;
  --muted: #cbd5e1;
  --line: #334155;
  --surface: rgba(17,24,39,.96);
  --primary: #a78bfa;
  --primary-dark: #8b5cf6;
  --success: #86efac;
  --warning: #fcd34d;
  --danger: #fca5a5;
  color-scheme: dark;
  background: #070b14;
}
:root[data-time-theme="night"] body { background:
  radial-gradient(circle at 10% 0%, rgba(139,92,246,.20), transparent 32rem),
  radial-gradient(circle at 100% 20%, rgba(34,197,94,.10), transparent 28rem), #070b14; }
:root[data-time-theme="night"] .panel { border-color: rgba(71,85,105,.72); box-shadow: 0 18px 55px rgba(0,0,0,.30); }
:root[data-time-theme="night"] .meta-grid div,
:root[data-time-theme="night"] .timeline-entry,
:root[data-time-theme="night"] .metric-grid div { background: #1e293b; color: #e5e7eb; }
:root[data-time-theme="night"] .current-activity { border-color: #4c3f7d; background: linear-gradient(135deg, #211b38, #14213a); }
:root[data-time-theme="night"] .current-activity strong { color: #f5f3ff; }
:root[data-time-theme="night"] .stage-chip { background: #33275d; color: #ddd6fe; }
:root[data-time-theme="night"] .stage-chip.completed { background: #052e24; color: #86efac; }
:root[data-time-theme="night"] .stage-chip.failed,
:root[data-time-theme="night"] .stage-chip.needs_attention { background: #450a0a; color: #fecaca; }
:root[data-time-theme="night"] .connection-badge { background: #052e24; color: #86efac; }
:root[data-time-theme="night"] .connection-badge.connecting { background: #422006; color: #fde68a; }
:root[data-time-theme="night"] .connection-badge.disconnected { background: #450a0a; color: #fecaca; }
:root[data-time-theme="night"] .timeline-toggle { border-color: #475569; background: #1e293b; color: #e2e8f0; }
:root[data-time-theme="night"] .timeline-empty { border-color: #475569; }
:root[data-time-theme="night"] .timeline-entry-label { color: #cbd5e1; }
:root[data-time-theme="night"] .rendered-plan { border-color: #334155; background: #0f172a; color: #e5e7eb; }
:root[data-time-theme="night"] .rendered-plan h1,
:root[data-time-theme="night"] .rendered-plan h2,
:root[data-time-theme="night"] .rendered-plan h3,
:root[data-time-theme="night"] .rendered-plan h4 { color: #f8fafc; }
:root[data-time-theme="night"] .rendered-plan blockquote { background: #1e1b36; color: #ddd6fe; }
:root[data-time-theme="night"] .rendered-plan code { background: #1e293b; color: #fda4af; }
:root[data-time-theme="night"] .rendered-plan pre { background: #020617; color: #f8fafc; }
:root[data-time-theme="night"] .rendered-plan th { background: #1e293b; }
:root[data-time-theme="night"] .rendered-plan a { color: #c4b5fd; }
:root[data-time-theme="night"] .rendered-plan .omitted-image { background: #1e293b; color: #cbd5e1; }
:root[data-time-theme="night"] .badge { background: #2e1065; color: #ddd6fe; }
:root[data-time-theme="night"] .badge.started,
:root[data-time-theme="night"] .badge.approved,
:root[data-time-theme="night"] .badge.revision_requested { background: #172554; color: #bfdbfe; }
:root[data-time-theme="night"] .badge.completed { background: #052e24; color: #86efac; }
:root[data-time-theme="night"] .badge.failed,
:root[data-time-theme="night"] .badge.expired,
:root[data-time-theme="night"] .badge.cancelled,
:root[data-time-theme="night"] .badge.needs_attention { background: #450a0a; color: #fecaca; }
:root[data-time-theme="night"] .secondary { background: #172554; color: #bfdbfe; }
:root[data-time-theme="night"] .danger-ghost { background: #450a0a; color: #fecaca; }
:root[data-time-theme="night"] .outline { background: #1e293b; border-color: #475569; color: #e2e8f0; }
:root[data-time-theme="night"] .warning { background: #422006; color: #fde68a; }
:root[data-time-theme="night"] .revision-box { border-color: #713f12; background: #271505; }
:root[data-time-theme="night"] .decision-confirm { border-color: #5b4a91; background: #1e1b36; }
:root[data-time-theme="night"] .decision-confirm > strong { color: #c4b5fd; }
:root[data-time-theme="night"] .decision-error { background: #450a0a; color: #fecaca !important; }
:root[data-time-theme="night"] textarea { border-color: #475569; background: #0f172a; color: #f8fafc; }
:root[data-time-theme="night"] .error-panel { border-color: #7f1d1d; background: #2b0b10; }
@media (max-width: 680px) {
  .shell { width: calc(100% - 20px); padding-top: 26px; }
  .hero-row { align-items: flex-start; flex-direction: column; }
  .meta-grid, .button-grid { grid-template-columns: 1fr; }
  .panel { padding: 20px 16px; border-radius: 17px; }
  .meta-grid { gap: 8px; }
  .meta-grid div { padding: 11px 13px; }
  .rendered-plan { padding: 15px 13px; }
  .execution-dashboard { grid-template-columns: 1fr; }
  .timeline-heading { align-items: flex-start; flex-direction: column; }
  .timeline { max-height: min(56vh, 520px); }
  .timeline-entry { padding-right: 12px; }
  .decision-confirm-actions { display: grid; grid-template-columns: 1fr; }
}
@media (max-width: 360px) {
  .shell { width: calc(100% - 12px); padding-top: 18px; }
  .panel { padding: 18px 13px; }
  #countdown { font-size: 13px; }
  .metric-grid div { padding: 11px; }
}