:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --ink: #111827;
  --ink-soft: #374151;
  --muted: #6b7280;
  --line: #e5e7eb;
  --line-soft: #f1f2f5;
  --divider: #cbd5e1;
  --alt: #fafbfc;
  --header-bg: #0f172a;
  --label-col: 220px;
  --col-min: 110px;
  --lane-h: 34px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body { font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--ink); padding: 32px; -webkit-font-smoothing: antialiased; }

h1 { font-size: 22px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.01em; }
.subtitle { font-size: 13px; color: var(--muted); margin-bottom: 22px; }

.toolbar { display: flex; gap: 6px; justify-content: flex-end; align-items: center; margin-bottom: 14px; }
.toolbar .toast { font-size: 12px; color: var(--muted); padding-right: 6px; opacity: 0; transition: opacity 0.2s; }
.toolbar .toast.show { opacity: 1; }
.toolbar button { background: var(--card); color: var(--ink-soft); border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; font: inherit; font-size: 12px; cursor: pointer; transition: background 0.1s, border-color 0.1s; }
.toolbar button:hover { background: #f9fafb; border-color: var(--divider); }
.toolbar button.primary { background: var(--header-bg); color: #fff; border-color: var(--header-bg); }
.toolbar button.primary:hover { background: #1e293b; }

.editor { display: flex; flex-direction: column; gap: 10px; }
.editor textarea { width: 100%; min-height: 60vh; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px; font: 13px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--card); color: var(--ink); resize: vertical; }

.chart-container { background: var(--card); border-radius: 14px; box-shadow: 0 1px 3px rgba(16,24,40,0.06), 0 1px 2px rgba(16,24,40,0.04); overflow: hidden; }
.chart-scroll { overflow-x: auto; }

.header-row, .swim-row { display: grid; }

.header-row { background: var(--header-bg); color: #fff; }
.header-label, .header-month { padding: 13px 12px; font-size: 11px; font-weight: 600; letter-spacing: 0.6px; text-transform: uppercase; color: #e5e7eb; }
.header-label { padding-left: 16px; padding-right: 16px; }
.header-month { text-align: center; border-left: 1px solid rgba(255,255,255,0.07); }
.header-month.q-divider { border-left: 1px solid rgba(255,255,255,0.32); }

.swim-row { border-top: 1px solid var(--line-soft); position: relative; padding: 6px 0; align-content: stretch; }
.swim-row.alt { background: var(--alt); }

.swimlane-label { grid-column: 1; padding: 0 16px; display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 600; color: var(--ink-soft); border-right: 1px solid var(--line); }
.pillar-num { width: 22px; height: 22px; border-radius: 6px; color: #fff; font-size: 11px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }

.month-bg { border-right: 1px solid var(--line-soft); }
.month-bg:last-child { border-right: none; }
.month-bg.q-divider { border-left: 2px solid var(--divider); }

.bar {
  margin: 3px 6px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  line-height: 1.35;
  align-self: center;
  z-index: 1;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  min-width: 0;
  overflow-wrap: break-word;
  word-break: break-word;
  box-shadow: 0 1px 2px rgba(16,24,40,0.08);
  cursor: default;
}
.bar.has-details { cursor: pointer; }
.bar.has-details::after { content: " ›"; opacity: 0.7; font-weight: 700; }
.bar:hover { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(16,24,40,0.12); }
.bar.decision { background: #fff !important; color: inherit; border: 2px solid currentColor; font-weight: 700; box-shadow: none; }
.bar.decision::before { content: "◆ "; }

/* Timeline-mode bars live in an overlay positioned absolutely. */
.chart-overlay { position: relative; pointer-events: none; }
.chart-overlay .bar { position: absolute; pointer-events: auto; margin: 0; align-self: stretch; display: flex; align-items: center; }

.legend { display: flex; gap: 20px; margin-top: 18px; flex-wrap: wrap; align-items: center; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.legend-swatch { width: 14px; height: 14px; border-radius: 3px; }
.legend-swatch.decision { background: #fff; border: 2px solid var(--muted); }

.config-error { background: #fef2f2; color: #b91c1c; padding: 16px; border-radius: 8px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; white-space: pre-wrap; }

.popover { position: absolute; z-index: 100; max-width: 340px; background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; box-shadow: 0 8px 24px rgba(16,24,40,0.16), 0 2px 6px rgba(16,24,40,0.08); font-size: 13px; line-height: 1.5; color: var(--ink); }
.popover[hidden] { display: none; }
.popover-title { font-weight: 600; margin-bottom: 6px; color: var(--ink); }
.popover-body { white-space: pre-wrap; color: var(--ink-soft); }

@media print {
  @page { size: landscape; margin: 0.35in; }

  *, *::before, *::after {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  html, body { background: #fff !important; padding: 0 !important; margin: 0 !important; }
  body { padding: 8px 12px !important; }

  :root {
    --label-col: 165px;
    --col-min: 78px;
    --lane-h: 28px;
  }

  h1 { font-size: 16px; margin-bottom: 2px; }
  .subtitle { font-size: 11px; margin-bottom: 10px; }

  .toolbar, .popover { display: none !important; }

  .chart-container { box-shadow: none !important; border: 1px solid #d1d5db; border-radius: 8px; }
  .chart-scroll { overflow: visible !important; }

  .header-label, .header-month { padding: 8px 8px; font-size: 10px; }
  .swimlane-label { font-size: 11px; padding: 0 10px; gap: 8px; }
  .pillar-num { width: 18px; height: 18px; font-size: 10px; border-radius: 4px; }

  .bar { font-size: 10px; padding: 5px 7px; margin: 2px 4px; border-radius: 5px; box-shadow: none !important; }
  .bar.has-details::after { content: ""; }
  .bar:hover { transform: none !important; box-shadow: none !important; }

  .swim-row { page-break-inside: avoid; break-inside: avoid; }
  .legend { margin-top: 10px; font-size: 10px; }
}
