:root {
  color-scheme: light;
  --brand-dark-blue: oklch(22.33% 0.0433 227.52);
  --brand-cream-white: oklch(95.67% 0.0107 100.82);
  --brand-light-blue: oklch(30.05% 0.0536 218.8);
  --brand-red: oklch(47.86% 0.178 24.25);
  --brand-orange: oklch(67.03% 0.1498 56.04);
  --bg: var(--brand-cream-white);
  --panel: color-mix(in oklch, var(--brand-cream-white) 92%, oklch(99% 0.004 100) 8%);
  --panel-soft: color-mix(in oklch, var(--brand-cream-white) 88%, var(--brand-light-blue) 12%);
  --ink: var(--brand-dark-blue);
  --muted: color-mix(in oklch, var(--brand-dark-blue) 68%, var(--brand-cream-white) 32%);
  --line: color-mix(in oklch, var(--brand-dark-blue) 18%, var(--brand-cream-white) 82%);
  --line-strong: color-mix(in oklch, var(--brand-dark-blue) 30%, var(--brand-cream-white) 70%);
  --calendar-head: color-mix(in oklch, var(--brand-light-blue) 9%, var(--brand-cream-white) 91%);
  --row-alt: color-mix(in oklch, var(--brand-light-blue) 4%, var(--brand-cream-white) 96%);
  --accent: var(--brand-light-blue);
  --accent-strong: var(--brand-dark-blue);
  --accent-soft: color-mix(in oklch, var(--brand-light-blue) 12%, var(--brand-cream-white) 88%);
  --used: var(--brand-orange);
  --used-strong: color-mix(in oklch, var(--brand-orange) 70%, var(--brand-dark-blue) 30%);
  --blackout-soft: color-mix(in oklch, var(--brand-orange) 18%, var(--brand-cream-white) 82%);
  --blackout-line: color-mix(in oklch, var(--brand-orange) 34%, var(--brand-cream-white) 66%);
  --updated-line: color-mix(in oklch, var(--brand-light-blue) 72%, var(--brand-cream-white) 28%);
  --red: var(--brand-red);
  --shadow: 0 18px 42px oklch(22.33% 0.0433 227.52 / 0.13);
  --radius: 8px;
  --left-width: 340px;
  --timeline-width: 1200px;
  --row-height: 78px;
  --header-height: 72px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: "Fira Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, color-mix(in oklch, var(--brand-light-blue) 9%, var(--bg) 91%), var(--bg) 320px);
}

button,
input {
  font: inherit;
}

button {
  color: var(--ink);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 28px;
  align-items: end;
  padding: 28px 32px 22px;
  border-bottom: 1px solid var(--line);
}

.title-block {
  display: flex;
  gap: 14px;
  align-items: center;
}

.header-right {
  display: flex;
  gap: 16px;
  align-items: center;
}

.brand-mark {
  flex: 0 0 auto;
  width: 68px;
  height: 68px;
  object-fit: contain;
  filter: drop-shadow(0 10px 18px oklch(22.33% 0.0433 227.52 / 0.16));
}

.kicker {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 2rem;
  line-height: 1.08;
  font-weight: 760;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.2;
  font-weight: 720;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(130px, auto));
  gap: 10px;
}

.summary-grid > div {
  min-width: 0;
  padding: 11px 13px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 1px 0 oklch(98% 0.006 100 / 0.65) inset;
}

.summary-label {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 650;
  text-transform: uppercase;
}

.summary-grid strong {
  display: block;
  overflow: hidden;
  font-size: 1rem;
  font-weight: 760;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.page-shell {
  display: grid;
  gap: 18px;
  padding: 20px 32px 38px;
}

.control-strip {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.tempo-control {
  display: grid;
  grid-template-columns: auto minmax(160px, 1fr) auto;
  gap: 12px;
  align-items: center;
}

.tempo-control label {
  font-weight: 700;
}

input[type="range"] {
  accent-color: var(--accent);
}

.number-field {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 126px;
  color: var(--muted);
  font-weight: 650;
}

.number-field input {
  width: 68px;
  padding: 7px 8px;
  color: var(--ink);
  background: var(--panel-soft);
  border: 1px solid var(--line-strong);
  border-radius: 6px;
}

.notes-head button {
  min-height: 32px;
  padding: 0 11px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 700;
}

.notes-head button:hover {
  background: var(--panel);
  border-color: var(--line-strong);
}

.switch {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 34px;
  padding: 0 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  font-weight: 680;
  white-space: nowrap;
}

.switch input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
}

.capacity-note {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.capacity-note span,
.pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 2px 8px;
  color: var(--muted);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.76rem;
  font-weight: 720;
}

.warnings {
  display: none;
  padding: 12px 14px;
  color: var(--brand-red);
  background: color-mix(in oklch, var(--brand-red) 10%, var(--brand-cream-white) 90%);
  border: 1px solid color-mix(in oklch, var(--brand-red) 35%, var(--brand-cream-white) 65%);
  border-radius: var(--radius);
}

.optional-panel {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  padding: 14px 16px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.optional-panel.is-hidden {
  display: none;
}

.optional-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.optional-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.optional-button {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  max-width: min(100%, 460px);
  min-height: 36px;
  padding: 7px 10px;
  color: var(--ink);
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
  cursor: pointer;
  text-align: left;
}

.optional-button:hover,
.optional-button:focus-visible {
  border-color: var(--accent);
  outline: none;
}

.optional-button.is-selected {
  color: var(--brand-cream-white);
  background: var(--accent);
  border-color: var(--accent);
}

.optional-button span {
  overflow-wrap: anywhere;
  font-weight: 720;
}

.optional-button strong {
  flex: 0 0 auto;
  font-size: 0.82rem;
}

.warnings.is-visible {
  display: block;
}

.warnings ul {
  margin: 0;
  padding-left: 18px;
}

.timeline-shell,
.budget-shell,
.notes-shell {
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.notes-shell.is-hidden {
  display: none;
}

.timeline-toolbar,
.budget-head,
.notes-head {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.timeline-toolbar > *,
.budget-head > *,
.notes-head > * {
  min-width: 0;
}

.timeline-toolbar p,
.budget-head p,
.notes-head p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.budget-head {
  align-items: center;
}

.budget-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, auto));
  gap: 8px;
}

.budget-stats > div {
  min-width: 0;
  padding: 8px 10px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 7px;
}

.budget-stats span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 760;
  text-transform: uppercase;
}

.budget-stats strong {
  display: block;
  overflow: hidden;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  justify-content: flex-end;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 720;
}

.legend span {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.legend-bar {
  width: 24px;
  height: 9px;
  background: var(--accent);
  border: 1px solid var(--accent-strong);
  border-radius: 999px;
}

.legend-bar.is-used {
  background: var(--used);
  border-color: var(--used-strong);
}

.timeline-scroller {
  overflow: auto;
  max-height: none;
  background: var(--panel);
}

.budget-scroller {
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--panel);
}

.budget-scroller:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.budget-timeline {
  position: relative;
  width: calc(var(--left-width) + var(--timeline-width));
  min-width: 100%;
}

.budget-header-row {
  display: grid;
  grid-template-columns: var(--left-width) var(--timeline-width);
  height: var(--header-height);
  background: var(--calendar-head);
  border-bottom: 1px solid var(--line-strong);
}

.budget-heading {
  position: sticky;
  left: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  background: var(--calendar-head);
  box-shadow: 1px 0 0 var(--line-strong);
  font-size: 0.76rem;
  font-weight: 760;
  text-transform: uppercase;
}

.budget-row {
  display: grid;
  grid-template-columns: var(--left-width) var(--timeline-width);
  min-height: 88px;
}

.budget-axis-label {
  position: sticky;
  left: 0;
  z-index: 10;
  display: grid;
  gap: 2px;
  align-content: center;
  min-width: 0;
  padding: 10px 14px;
  background: var(--row-alt);
  box-shadow: 1px 0 0 var(--line-strong);
}

.budget-axis-label span {
  font-size: 1rem;
  font-weight: 730;
}

.budget-axis-label small {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 720;
}

.budget-track {
  position: relative;
  min-height: 88px;
}

.budget-marker {
  position: absolute;
  top: 31px;
  z-index: 8;
  padding: 2px 5px;
  transform: translateX(-50%);
  color: var(--accent-strong);
  background: color-mix(in oklch, var(--brand-cream-white) 86%, var(--brand-light-blue) 14%);
  border: 1px solid color-mix(in oklch, var(--brand-light-blue) 30%, var(--brand-cream-white) 70%);
  border-radius: 5px;
  box-shadow: 0 1px 0 oklch(98% 0.006 100 / 0.65) inset;
  font-size: 0.84rem;
  font-weight: 820;
  line-height: 1.15;
  white-space: nowrap;
}

.timeline-scroller:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.timeline-canvas {
  position: relative;
  width: calc(var(--left-width) + var(--timeline-width));
  min-width: 100%;
}

.timeline-header-row,
.timeline-row {
  display: grid;
  grid-template-columns: var(--left-width) var(--timeline-width);
}

.timeline-header-row {
  position: sticky;
  top: 0;
  z-index: 20;
  height: var(--header-height);
  background: var(--calendar-head);
  border-bottom: 1px solid var(--line-strong);
}

.task-heading,
.task-cell {
  position: sticky;
  left: 0;
  z-index: 10;
  background: var(--panel);
}

.task-heading {
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  box-shadow: 1px 0 0 var(--line-strong);
  font-size: 0.76rem;
  font-weight: 760;
  text-transform: uppercase;
}

.task-heading {
  background: var(--calendar-head);
}

.time-rail {
  position: relative;
  height: var(--header-height);
}

.month-rail,
.week-rail {
  position: relative;
  height: 36px;
}

.month-block,
.week-block {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  border-right: 1px solid var(--line);
  color: color-mix(in oklch, var(--brand-dark-blue) 76%, var(--brand-cream-white) 24%);
}

.month-block {
  padding-left: 10px;
  font-size: 0.77rem;
  font-weight: 800;
  text-transform: uppercase;
}

.week-block {
  justify-content: center;
  border-top: 1px solid var(--line);
  font-size: 0.68rem;
  font-weight: 760;
}

.updated-line {
  position: absolute;
  z-index: 6;
  width: 2px;
  transform: translateX(-1px);
  background: var(--updated-line);
  box-shadow: 0 0 0 1px color-mix(in oklch, var(--updated-line) 30%, transparent);
  pointer-events: auto;
}

.updated-line.header {
  top: 0;
  bottom: 0;
}

.updated-line.track {
  top: 0;
  bottom: 0;
}

.updated-line.is-before-start {
  transform: translateX(0);
}

.month-block.is-blackout {
  color: var(--used-strong);
  background: repeating-linear-gradient(
    135deg,
    var(--blackout-soft),
    var(--blackout-soft) 7px,
    var(--blackout-line) 7px,
    var(--blackout-line) 14px
  );
}

.timeline-row {
  min-height: var(--row-height);
  border-bottom: 1px solid var(--line);
}

.timeline-row:nth-of-type(odd) .task-cell,
.timeline-row:nth-of-type(odd) .track,
.budget-row .budget-track {
  background: var(--row-alt);
}

.task-cell {
  display: grid;
  gap: 7px;
  align-content: center;
  min-width: 0;
  padding: 10px 14px;
  box-shadow: 1px 0 0 var(--line-strong);
}

.task-title {
  overflow-wrap: anywhere;
  font-size: 0.94rem;
  font-weight: 730;
}

.task-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 680;
}

.task-hours-summary {
  overflow-wrap: anywhere;
}

.pill.is-optional {
  color: var(--used-strong);
  background: color-mix(in oklch, var(--brand-orange) 12%, var(--brand-cream-white) 88%);
  border-color: color-mix(in oklch, var(--brand-orange) 32%, var(--brand-cream-white) 68%);
}

.pill.is-done {
  color: var(--brand-light-blue);
  background: color-mix(in oklch, var(--brand-light-blue) 10%, var(--brand-cream-white) 90%);
  border-color: color-mix(in oklch, var(--brand-light-blue) 28%, var(--brand-cream-white) 72%);
}

.pill.is-lopande {
  color: var(--brand-dark-blue);
  background: color-mix(in oklch, var(--brand-dark-blue) 10%, var(--brand-cream-white) 90%);
  border-color: color-mix(in oklch, var(--brand-dark-blue) 28%, var(--brand-cream-white) 72%);
}

.track {
  position: relative;
  min-height: var(--row-height);
}

.week-grid-cell {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 0;
  border-right: 1px solid color-mix(in oklch, var(--brand-dark-blue) 12%, var(--brand-cream-white) 88%);
}

.blackout-band {
  position: absolute;
  top: 0;
  bottom: 0;
  z-index: 1;
  background: repeating-linear-gradient(
    135deg,
    color-mix(in oklch, var(--blackout-soft) 72%, transparent),
    color-mix(in oklch, var(--blackout-soft) 72%, transparent) 7px,
    color-mix(in oklch, var(--blackout-line) 72%, transparent) 7px,
    color-mix(in oklch, var(--blackout-line) 72%, transparent) 14px
  );
}

.bar {
  position: absolute;
  top: 23px;
  z-index: 8;
  display: flex;
  align-items: center;
  min-width: 8px;
  height: 31px;
  padding: 0 9px;
  overflow: hidden;
  color: var(--brand-cream-white);
  background: var(--accent);
  border: 1px solid var(--accent-strong);
  border-radius: 7px;
  box-shadow: 0 8px 20px oklch(22.33% 0.0433 227.52 / 0.2);
  white-space: nowrap;
  transition: border-color 160ms ease, box-shadow 160ms ease, filter 160ms ease, transform 160ms ease;
}

.used-bar {
  position: absolute;
  top: 23px;
  z-index: 7;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 8px;
  height: 31px;
  padding: 0 9px;
  overflow: hidden;
  color: var(--brand-dark-blue);
  background: var(--used);
  border: 1px solid var(--used-strong);
  border-radius: 7px 0 0 7px;
  box-shadow: 0 6px 14px oklch(22.33% 0.0433 227.52 / 0.16);
  white-space: nowrap;
  transition: border-color 160ms ease, box-shadow 160ms ease, filter 160ms ease, transform 160ms ease;
}

.bar-label {
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 780;
  text-overflow: ellipsis;
}

.bar.is-tiny {
  padding: 0;
}

.bar.joins-used {
  border-left-width: 0;
  border-radius: 0 7px 7px 0;
}

.bar.continues-after {
  border-right-width: 0;
  border-radius: 7px 0 0 7px;
}

.bar.continues-before {
  border-left-width: 0;
  border-radius: 0 7px 7px 0;
}

.bar.continues-after.joins-used {
  border-radius: 0;
}

.bar.is-tiny .bar-label {
  display: none;
}

.used-bar.is-floating {
  border-radius: 7px;
}

.used-bar.continues-after {
  border-right-width: 0;
  border-radius: 7px 0 0 7px;
}

.used-bar.continues-before {
  border-left-width: 0;
  border-radius: 0;
}

.used-bar.is-tiny {
  padding: 0;
}

.used-bar.is-tiny .bar-label {
  display: none;
}

.zero-marker {
  position: absolute;
  top: 25px;
  z-index: 8;
  width: 9px;
  height: 27px;
  background: var(--used);
  border-radius: 999px;
  transition: box-shadow 160ms ease, filter 160ms ease, transform 160ms ease;
}

.dep-layer {
  position: absolute;
  z-index: 6;
  overflow: visible;
  pointer-events: none;
}

.dep-layer > path {
  fill: none;
  stroke: oklch(22.33% 0.0433 227.52 / 0.38);
  stroke-linecap: round;
  stroke-width: 1.2;
  transition: opacity 160ms ease, stroke 160ms ease, stroke-width 160ms ease;
}

.dep-layer marker path {
  fill: oklch(22.33% 0.0433 227.52 / 0.46);
  stroke: none;
}

.dep-layer marker#arrowhead-active path {
  fill: oklch(22.33% 0.0433 227.52 / 0.78);
}

.task-cell.is-hovered {
  color: var(--accent-strong);
}

.timeline-row.is-hovered .task-cell,
.timeline-row.is-hovered .track {
  background-color: color-mix(in oklch, var(--brand-light-blue) 7%, var(--brand-cream-white) 93%);
}

.bar.is-hovered,
.used-bar.is-hovered,
.zero-marker.is-hovered {
  filter: saturate(1.12) brightness(1.04);
  transform: translateY(-1px);
  box-shadow:
    0 0 0 2px color-mix(in oklch, var(--brand-orange) 38%, transparent),
    0 10px 24px oklch(22.33% 0.0433 227.52 / 0.24);
}

.bar.is-incoming,
.used-bar.is-incoming,
.zero-marker.is-incoming {
  box-shadow:
    0 0 0 2px color-mix(in oklch, var(--brand-light-blue) 28%, transparent),
    0 8px 20px oklch(22.33% 0.0433 227.52 / 0.18);
}

.dep-layer > path.is-outgoing {
  stroke: oklch(22.33% 0.0433 227.52 / 0.76);
  stroke-width: 1.9;
}

.dep-layer > path.is-muted {
  opacity: 0.24;
}

.dep-layer.is-hidden {
  display: none;
}

.comments-block {
  min-height: 120px;
  padding: 16px;
  color: var(--ink);
  background: color-mix(in oklch, var(--brand-cream-white) 86%, oklch(99% 0.004 100) 14%);
  line-height: 1.5;
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .topbar,
  .control-strip,
  .optional-panel {
    grid-template-columns: 1fr;
  }

  .header-right {
    align-items: flex-start;
    justify-content: space-between;
  }

  .summary-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .capacity-note {
    justify-content: flex-start;
  }

  .legend {
    justify-content: flex-start;
  }

  .timeline-toolbar,
  .budget-head,
  .notes-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .budget-stats {
    width: 100%;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .topbar,
  .page-shell {
    padding-right: 16px;
    padding-left: 16px;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .budget-stats {
    grid-template-columns: 1fr;
  }

  .header-right {
    align-items: flex-start;
  }

  .brand-mark {
    width: 52px;
    height: 52px;
  }

  .tempo-control {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

}
