:root {
  color-scheme: light;
  --color-text: #000000;
  --color-label: #626264;
  --color-link: #0017c1;
  --color-background: #f8f8fb;
  --color-highlight: #0017c1;
  --color-control: #f1f1f4;
  --color-blue-1200: #000060;
  --color-blue-900: #0017c1;
  --color-blue-600: #3460fb;
  --color-blue-400: #7096f8;
  --color-blue-200: #c5d7fb;
  --color-blue-50: #e8f1fe;
  --color-yellow-600: #d2a400;
  --color-yellow-400: #ffc700;
  --color-gray-800: #333333;
  --color-gray-600: #666666;
  --color-gray-400: #999999;
  --color-gray-200: #cccccc;
  --color-success: #197a4b;
  --color-error: #ce0000;
  --pico-font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  --pico-color: var(--color-text);
  --pico-muted-color: var(--color-label);
  --pico-primary: var(--color-highlight);
  --pico-primary-background: var(--color-highlight);
  --pico-primary-border: var(--color-highlight);
  --pico-primary-hover-background: var(--color-blue-600);
  --pico-primary-hover-border: var(--color-blue-600);
  --pico-primary-focus: rgba(52, 96, 251, 0.24);
  --pico-background-color: var(--color-background);
  --pico-card-background-color: #ffffff;
  --pico-card-border-color: var(--color-blue-200);
  --pico-form-element-background-color: #ffffff;
  --pico-form-element-border-color: var(--color-gray-400);
  --pico-form-element-active-border-color: var(--color-blue-600);
  --pico-form-element-focus-color: rgba(52, 96, 251, 0.18);
  --pico-border-radius: 8px;
  --pico-spacing: 1rem;
  --pico-typography-spacing-vertical: 0;
  --brand-hue: 233;
  --background: 240 27% 98%;
  --foreground: 0 0% 0%;
  --card: 0 0% 100%;
  --card-foreground: 0 0% 0%;
  --muted: 240 12% 95%;
  --muted-foreground: 240 1% 39%;
  --border: 218 82% 88%;
  --input: 0 0% 60%;
  --primary: var(--brand-hue) 100% 38%;
  --primary-foreground: 0 0% 100%;
  --accent: 47 100% 50%;
  --accent-foreground: 0 0% 20%;
  --destructive: 0 100% 40%;
  --ring: 225 96% 59%;
  --radius: 8px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 1px 18px rgba(0, 23, 193, 0.05);
  --shadow-lifted: 0 2px 4px rgba(15, 23, 42, 0.05), 0 14px 38px rgba(0, 23, 193, 0.08);
  --shadow-bar: 0 1px 0 hsl(var(--card)) inset, 0 1px 2px rgba(15, 23, 42, 0.18);
  --shadow-bar-hover: 0 1px 0 hsl(var(--card)) inset, 0 4px 12px rgba(15, 23, 42, 0.22);
  --row-height: 68px;
  --sheet-header-height: 62px;
  --header-band: linear-gradient(180deg, hsl(225 100% 98%), hsl(225 70% 95%));
  --grid-line: hsl(var(--border) / 0.6);
  --grid-line-strong: hsl(var(--border));
  --g-bar-color: hsl(var(--primary));
  --g-bar-progress-color: var(--color-blue-1200);
  --g-weekend-highlight-color: rgba(148, 163, 184, 0.16);
  --g-today-highlight-color: rgba(255, 199, 0, 0.2);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

:root,
html:root[data-theme="light"],
html[data-theme="light"] {
  --pico-color: var(--color-text);
  --pico-muted-color: var(--color-label);
  --pico-primary: var(--color-highlight);
  --pico-primary-background: var(--color-highlight);
  --pico-primary-border: var(--color-highlight);
  --pico-primary-hover-background: var(--color-blue-600);
  --pico-primary-hover-border: var(--color-blue-600);
  --pico-primary-focus: rgba(52, 96, 251, 0.24);
  --pico-background-color: var(--color-background);
  --pico-card-background-color: #ffffff;
  --pico-card-border-color: var(--color-blue-200);
  --pico-form-element-background-color: #ffffff;
  --pico-form-element-border-color: var(--color-gray-400);
  --pico-form-element-active-border-color: var(--color-blue-600);
  --pico-form-element-focus-color: rgba(52, 96, 251, 0.18);
  --pico-border-radius: 8px;
  --pico-spacing: 1rem;
  --pico-typography-spacing-vertical: 0;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(1100px 360px at 12% -160px, hsl(225 100% 92% / 0.55), transparent 65%),
    radial-gradient(900px 320px at 92% -120px, hsl(47 100% 92% / 0.4), transparent 60%),
    hsl(var(--background));
  color: hsl(var(--foreground));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  letter-spacing: -0.005em;
  accent-color: hsl(var(--primary));
}

body.is-resizing-timeline {
  cursor: ew-resize;
  user-select: none;
}

body.is-moving-timeline {
  cursor: grabbing;
  user-select: none;
}

button,
input,
select {
  font: inherit;
}

button {
  margin: 0;
  color: inherit;
}

:where(button, input, select) {
  min-height: 44px;
}

.app-shell {
  min-height: 100vh;
  padding: 24px;
  display: grid;
  gap: 16px;
}

.surface,
.topbar {
  background: var(--pico-card-background-color);
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.topbar {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  padding: 18px 22px;
  overflow: hidden;
}

.topbar::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, hsl(var(--primary)) 0%, hsl(var(--ring)) 55%, hsl(var(--accent)) 100%);
}

.eyebrow {
  margin: 0 0 6px;
  color: hsl(var(--primary));
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

h2 {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.2;
  letter-spacing: -0.005em;
}

.chart-toolbar p {
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 600;
}

.controls {
  padding: 14px 16px;
}

.controls form {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(150px, 0.65fr) minmax(160px, 0.7fr) auto auto auto auto;
  gap: 10px;
  align-items: end;
}

.field {
  display: grid;
  gap: 6px;
  color: hsl(var(--muted-foreground));
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.field-with-action {
  gap: 5px;
}

.field-label-row {
  display: flex;
  min-height: 18px;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.inline-action {
  margin: 0;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid hsl(var(--border));
  border-radius: 999px;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--card));
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  box-shadow: none;
  cursor: pointer;
}

.inline-action:hover,
.inline-action:focus-visible {
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
  background: var(--color-blue-50);
}

.field input,
.field select {
  width: 100%;
  margin: 0;
  height: 42px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 0 12px;
  color: hsl(var(--foreground));
  background: var(--pico-form-element-background-color);
  outline: none;
  font-weight: 600;
  font-size: 13px;
  accent-color: hsl(var(--primary));
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}

.field input::placeholder {
  color: hsl(var(--muted-foreground) / 0.7);
  font-weight: 500;
}

.field input:focus,
.field select:focus,
.switch:focus-within,
.button:focus-visible,
.tab-trigger:focus-visible {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

.view-control {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.view-control legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.tabs {
  min-height: 42px;
  padding: 3px;
  display: grid;
  grid-template-columns: repeat(3, 46px);
  gap: 2px;
  border-radius: 8px;
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
}

.tab-trigger {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  font-size: 12px;
  font-weight: 750;
  transition: background 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}

.tab-trigger:hover {
  color: hsl(var(--foreground));
}

.tab-trigger[aria-pressed="true"] {
  background: hsl(var(--card));
  color: hsl(var(--primary));
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.08),
    0 0 0 1px hsl(var(--border));
}

.switch {
  margin: 0;
  min-height: 42px;
  display: grid;
  grid-template-columns: 32px max-content;
  gap: 8px;
  align-items: center;
  padding: 0 12px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  color: hsl(var(--foreground));
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  background: hsl(var(--card));
  transition: border-color 0.12s ease;
}

.switch input {
  position: absolute;
  opacity: 0;
  accent-color: hsl(var(--primary));
}

.switch-track {
  position: relative;
  width: 32px;
  height: 18px;
  border-radius: 999px;
  background: hsl(var(--muted-foreground) / 0.32);
  transition: background 0.16s ease;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.18);
  transition: transform 0.16s ease;
}

.switch input:checked + .switch-track {
  background: hsl(var(--primary));
}

.switch input:checked + .switch-track::after {
  transform: translateX(14px);
}

.button {
  margin: 0;
  min-height: 42px;
  display: inline-grid;
  place-content: center;
  border: 1px solid hsl(var(--primary));
  border-radius: 8px;
  background: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
  padding: 0 16px;
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease, transform 0.06s ease;
}

.button:active {
  transform: translateY(1px);
}

.button.ghost {
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  border-color: hsl(var(--border));
  box-shadow: var(--shadow-sm);
}

.button:hover,
.tab-trigger[aria-pressed="true"]:hover {
  background: var(--color-blue-600);
  border-color: var(--color-blue-600);
  color: #ffffff;
}

.button.ghost:hover {
  background: var(--color-blue-50);
  border-color: hsl(var(--primary));
  color: hsl(var(--primary));
}

.file-button input {
  display: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
}

.chart-panel {
  min-height: 0;
}

.chart-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.toolbar-actions {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  align-items: center;
}

.toolbar-actions .button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 11px;
}

.chart-panel {
  padding: 16px 18px 18px;
  overflow: hidden;
  content-visibility: auto;
  contain-intrinsic-size: auto 1020px;
}

.chart-toolbar {
  margin-bottom: 14px;
  padding: 0 2px;
}

.chart-toolbar > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.chart-toolbar > div:first-child p {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.schedule-board {
  display: grid;
  grid-template-columns: minmax(260px, 420px) minmax(0, 1fr);
  min-height: 520px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--card));
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.task-sheet {
  display: grid;
  grid-template-rows: var(--sheet-header-height) auto;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid hsl(var(--border));
  background: hsl(var(--card));
}

.task-sheet-head {
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) minmax(86px, 92px);
  align-items: end;
  gap: 8px;
  padding: 0 16px 12px 14px;
  border-bottom: 1px solid hsl(var(--border));
  background: var(--header-band);
  color: hsl(var(--muted-foreground));
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

#taskList {
  min-height: 0;
  overflow: visible;
}

.task-row {
  width: 100%;
  height: var(--row-height);
  min-height: var(--row-height);
  display: grid;
  grid-template-columns: 50px minmax(0, 1fr) minmax(86px, 92px);
  grid-template-rows: 1fr;
  align-items: center;
  gap: 0 8px;
  border: 0;
  border-bottom: 1px solid var(--grid-line);
  border-left: 3px solid var(--area-color, hsl(var(--primary)));
  border-radius: 0;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  padding: 8px 18px 8px 11px;
  text-align: left;
  cursor: grab;
  overflow: hidden;
  transition: background 0.12s ease, border-left-width 0.12s ease;
}

.task-row:hover {
  background: hsl(225 100% 98%);
  border-left-width: 5px;
  padding-left: 9px;
}

.task-row[aria-current="true"] {
  background: hsl(var(--primary) / 0.06);
  border-left-width: 5px;
  padding-left: 9px;
  box-shadow: inset 0 0 0 1px hsl(var(--primary) / 0.18);
}

.task-row-number {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: 0.01em;
}

.task-row-main {
  min-width: 0;
  width: 100%;
  height: 100%;
  align-self: stretch;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  font-size: 0;
  line-height: 0;
  margin: 0;
  padding: 0;
}

.task-row-title {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: hsl(var(--foreground));
  font-size: 15px;
  font-weight: 800;
  line-height: 20px;
  letter-spacing: -0.005em;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: keep-all;
}

.task-row-meta {
  display: block;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 600;
  line-height: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-break: keep-all;
}

.task-row-progress {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: grid;
  gap: 5px;
  align-content: center;
  padding-left: 8px;
  background: inherit;
}

.task-row-progress span {
  color: hsl(var(--muted-foreground));
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.task-row-progress progress {
  width: 100%;
  height: 8px;
  overflow: hidden;
  border: 0;
  border-radius: 999px;
  background: hsl(var(--muted));
  accent-color: hsl(var(--primary));
}

.task-row-progress progress::-webkit-progress-bar {
  background: hsl(var(--muted));
}

.task-row-progress progress::-webkit-progress-value {
  border-radius: 999px;
  background: hsl(var(--primary));
}

.task-row-progress progress::-moz-progress-bar {
  border-radius: 999px;
  background: hsl(var(--primary));
}

.task-row.is-done {
  color: hsl(var(--muted-foreground));
  background: hsl(var(--muted) / 0.5);
}

.task-row.is-done .task-row-title {
  font-weight: 600;
  text-decoration: line-through;
  text-decoration-color: hsl(var(--muted-foreground) / 0.5);
}

.task-row.is-risk {
  border-left-color: hsl(var(--destructive));
}

.task-row.is-dragging {
  opacity: 0.58;
}

.task-row.is-drop-target {
  box-shadow: inset 0 2px 0 hsl(var(--primary));
}

.task-row-main {
  min-height: 0;
  align-self: stretch;
  overflow: hidden;
  border: 0;
  background: transparent;
  color: inherit;
  margin: 0;
  padding: 0;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
  appearance: none;
}

.task-row-main:focus-visible {
  outline: 2px solid hsl(var(--ring) / 0.45);
  outline-offset: 2px;
}

.timeline-pane {
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.gantt-host {
  width: 100%;
  min-height: 0;
  overflow: auto;
  border: 0;
  border-radius: 0;
  background: #fff;
  overscroll-behavior-x: contain;
  overscroll-behavior-y: auto;
  scrollbar-gutter: stable;
}

.timeline-grid {
  min-width: calc(var(--timeline-columns) * var(--timeline-column-width));
}

.timeline-header,
.timeline-marker-layer,
.timeline-row {
  display: grid;
  grid-template-columns: repeat(var(--timeline-columns), var(--timeline-column-width));
}

.timeline-header {
  position: sticky;
  top: 0;
  z-index: 3;
  min-height: var(--sheet-header-height);
  border-bottom: 1px solid hsl(var(--border));
  background: var(--header-band);
}

.timeline-header-cell {
  display: grid;
  align-content: end;
  gap: 4px;
  padding: 0 8px 10px;
  border-right: 1px solid hsl(var(--border) / 0.55);
  color: hsl(var(--muted-foreground));
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
}

.timeline-header-cell strong {
  font-size: 13px;
  font-weight: 800;
  color: hsl(var(--foreground));
  letter-spacing: 0;
  text-transform: none;
  order: 2;
}

.timeline-header-cell span {
  color: hsl(var(--muted-foreground));
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  order: 1;
}

.timeline-body {
  position: relative;
  background: #fff;
}

.timeline-marker-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.timeline-marker {
  border-right: 1px solid var(--grid-line);
}

.timeline-marker.is-weekend {
  background: var(--g-weekend-highlight-color);
}

.timeline-marker.is-holiday {
  background: var(--g-today-highlight-color);
}

.timeline-marker.is-today {
  box-shadow: inset 2px 0 0 hsl(var(--accent));
  background: hsl(var(--accent) / 0.06);
}

.dependency-layer {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 2;
  overflow: visible;
  pointer-events: none;
}

.dependency-path {
  fill: none;
  stroke: rgba(71, 85, 105, 0.62);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  cursor: pointer;
  filter: drop-shadow(0 1px 1px rgba(255, 255, 255, 0.8));
  pointer-events: stroke;
  transition: stroke 0.12s ease, stroke-width 0.12s ease;
}

.dependency-path:hover,
.dependency-path:focus-visible {
  stroke: hsl(var(--destructive) / 0.82);
  stroke-width: 4;
  outline: none;
}

.dependency-arrow-head {
  fill: rgba(71, 85, 105, 0.82);
}

.dependency-draft-layer {
  position: absolute;
  inset: 0 auto auto 0;
  z-index: 5;
  overflow: visible;
  pointer-events: none;
}

.dependency-draft-path {
  fill: none;
  stroke: rgba(71, 85, 105, 0.88);
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-dasharray: 6 4;
}

.timeline-row {
  position: relative;
  z-index: 1;
  min-height: var(--row-height);
  border-bottom: 1px solid var(--grid-line);
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--timeline-column-width) - 1px),
      var(--grid-line) calc(var(--timeline-column-width) - 1px),
      var(--grid-line) var(--timeline-column-width)
    );
}

.timeline-row[aria-current="true"] {
  background:
    linear-gradient(0deg, hsl(var(--primary) / 0.05), hsl(var(--primary) / 0.05)),
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent calc(var(--timeline-column-width) - 1px),
      var(--grid-line) calc(var(--timeline-column-width) - 1px),
      var(--grid-line) var(--timeline-column-width)
    );
}

.timeline-bar {
  position: relative;
  align-self: center;
  min-width: 16px;
  min-height: 22px;
  margin-inline: 4px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 0;
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.16), rgba(255, 255, 255, 0) 55%),
    var(--area-color, hsl(var(--primary)));
  color: var(--bar-text-color, #f4f4f4);
  cursor: grab;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.01em;
  line-height: 1.1;
  padding: 0 14px;
  text-align: left;
  box-shadow: var(--shadow-bar);
  text-shadow: none;
  transition: box-shadow 0.14s ease, transform 0.06s ease;
}

.timeline-bar-progress {
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--task-progress, 0%);
  border-radius: inherit;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0) 60%),
    rgba(255, 255, 255, 0.2);
  pointer-events: none;
}

.timeline-bar:hover,
.timeline-bar:focus-visible {
  box-shadow: var(--shadow-bar-hover);
}

.timeline-bar:active {
  transform: translateY(1px);
}

body.is-moving-timeline .timeline-bar {
  cursor: grabbing;
}

.timeline-bar-label {
  position: relative;
  z-index: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dependency-link-handle,
.dependency-target-handle {
  position: absolute;
  z-index: 4;
  top: 50%;
  width: 14px;
  height: 14px;
  transform: translateY(-50%);
  border: 2px solid #fff;
  border-radius: 999px;
  background: hsl(var(--primary));
  box-shadow: 0 1px 6px rgba(10, 22, 40, 0.26);
  cursor: crosshair;
  opacity: 0;
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.dependency-link-handle {
  right: -7px;
}

.dependency-target-handle {
  left: -7px;
  background: #fff;
  border-color: hsl(var(--primary));
  pointer-events: none;
}

.timeline-bar:hover .dependency-link-handle,
.timeline-bar:hover .dependency-target-handle,
.timeline-bar:focus-visible .dependency-link-handle,
.timeline-bar:focus-visible .dependency-target-handle,
body.is-linking-dependency .dependency-link-handle,
body.is-linking-dependency .dependency-target-handle {
  opacity: 1;
}

.dependency-link-handle:hover {
  transform: translateY(-50%) scale(1.12);
}

.timeline-bar.is-milestone {
  justify-self: center;
  width: max-content;
  max-width: min(180px, calc(var(--timeline-column-width) * 1.4));
  min-width: 28px;
  min-height: 22px;
  padding: 0 9px 0 5px;
  gap: 6px;
  overflow: visible;
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 55%),
    var(--area-color, hsl(var(--primary)));
  color: var(--bar-text-color, #f4f4f4);
  box-shadow: var(--shadow-bar);
  text-shadow: none;
}

.timeline-bar.is-milestone .dependency-link-handle {
  right: -10px;
}

.timeline-bar.is-milestone .dependency-target-handle {
  left: -10px;
}

.timeline-bar.is-milestone .timeline-bar-label {
  max-width: min(150px, calc(var(--timeline-column-width) * 1.1));
  color: inherit;
}

.timeline-milestone-marker {
  position: relative;
  z-index: 1;
  width: 14px;
  height: 14px;
  flex: 0 0 auto;
  transform: rotate(45deg);
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.16);
  box-shadow: none;
}

.timeline-resize-handle {
  position: absolute;
  z-index: 2;
  top: 3px;
  bottom: 3px;
  width: 10px;
  border-radius: 4px;
  cursor: ew-resize;
  opacity: 0;
  transition: opacity 0.12s ease, background 0.12s ease;
}

.timeline-resize-handle::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 2px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
}

.timeline-resize-handle.is-start {
  left: 1px;
}

.timeline-resize-handle.is-start::after {
  left: 3px;
}

.timeline-resize-handle.is-end {
  right: 1px;
}

.timeline-resize-handle.is-end::after {
  right: 3px;
}

.timeline-bar:hover .timeline-resize-handle,
.timeline-bar:focus-visible .timeline-resize-handle,
body.is-resizing-timeline .timeline-resize-handle {
  background: rgba(255, 255, 255, 0.18);
  opacity: 1;
}

.timeline-bar:focus-visible {
  outline: 2px solid hsl(var(--ring) / 0.5);
  outline-offset: 2px;
}

.timeline-bar.is-done {
  background:
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.12) 0,
      rgba(255, 255, 255, 0.12) 4px,
      transparent 4px,
      transparent 8px
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0) 55%),
    var(--color-gray-600);
  color: rgba(255, 255, 255, 0.94);
}

.timeline-bar.is-risk {
  box-shadow:
    inset 0 0 0 2px hsl(var(--destructive) / 0.78),
    var(--shadow-bar);
}

.load-error {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: var(--radius);
  background: hsl(var(--destructive) / 0.08);
  color: hsl(var(--destructive));
  font-weight: 700;
}

.task-dialog {
  display: block;
  position: fixed;
  inset: auto;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(920px, calc(100dvw - 32px));
  min-width: 0;
  min-height: 0;
  max-height: min(780px, calc(100dvh - 32px));
  overflow: auto;
  border: 1px solid hsl(var(--border));
  border-radius: 12px;
  background: hsl(var(--card));
  color: hsl(var(--foreground));
  box-shadow: 0 30px 80px rgba(15, 35, 48, 0.28), 0 2px 6px rgba(15, 35, 48, 0.08);
  padding: 22px;
}

.task-dialog::backdrop {
  background:
    radial-gradient(800px 600px at 50% 30%, rgba(0, 23, 193, 0.18), transparent 70%),
    rgba(15, 35, 48, 0.42);
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 14px;
  margin-bottom: 16px;
  border-bottom: 1px solid hsl(var(--border));
}

.dialog-head h2 {
  min-width: 0;
  overflow: hidden;
  font-size: 17px;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dialog-close {
  flex: 0 0 auto;
}

.task-editor {
  display: grid;
  grid-template-columns: repeat(2, minmax(150px, 1fr)) minmax(260px, 1.2fr) minmax(108px, max-content);
  gap: 12px 16px;
  align-items: end;
  padding: 14px;
  margin-bottom: 16px;
  border: 1px solid hsl(var(--border));
  border-radius: 10px;
  background: hsl(var(--muted) / 0.4);
}

.editor-field-wide {
  grid-column: 1 / -1;
}

.editor-field input {
  height: 40px;
}

.editor-field textarea {
  width: 100%;
  min-height: 82px;
  margin: 0;
  resize: vertical;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 10px 12px;
  color: hsl(var(--foreground));
  background: var(--pico-form-element-background-color);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  outline: none;
}

.editor-field textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

.editor-actions {
  display: flex;
  justify-content: flex-end;
  padding-top: 2px;
}

.editor-actions .button-danger {
  display: inline-grid;
  flex: 0 0 auto;
  place-content: center;
}

.button-danger {
  width: auto;
  min-height: 36px;
  padding: 0 14px;
  border-color: hsl(0 78% 48%);
  color: hsl(0 78% 48%);
  background: hsl(0 78% 48% / 0.08);
  font-size: 12px;
  font-weight: 800;
}

.button-danger:hover,
.button-danger:focus-visible {
  border-color: hsl(0 78% 42%);
  color: hsl(0 78% 42%);
  background: hsl(0 78% 48% / 0.14);
}

.editor-switch {
  grid-column: 4;
  align-self: end;
  justify-self: start;
  width: max-content;
  min-height: 40px;
  height: 40px;
  padding: 0 12px;
  margin: 0;
  transform: none;
}

.progress-field {
  grid-column: 1 / 4;
  min-width: 260px;
}

.progress-control {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 78px;
  gap: 12px;
  align-items: center;
}

.progress-control input[type="range"] {
  height: 40px;
  padding: 0;
  accent-color: hsl(var(--primary));
}

.progress-control input[type="number"] {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

@supports not (accent-color: hsl(var(--primary))) {
  .progress-control input[type="range"] {
    appearance: none;
    background: transparent;
  }

  .progress-control input[type="range"]::-webkit-slider-runnable-track {
    height: 8px;
    border-radius: 999px;
    background: linear-gradient(to right, hsl(var(--primary)) var(--progress, 0%), hsl(var(--muted)) var(--progress, 0%));
  }

  .progress-control input[type="range"]::-webkit-slider-thumb {
    appearance: none;
    width: 16px;
    height: 16px;
    margin-top: -4px;
    border-radius: 999px;
    background: hsl(var(--primary));
  }

  .progress-control input[type="range"]::-moz-range-track {
    height: 8px;
    border-radius: 999px;
    background: hsl(var(--muted));
  }

  .progress-control input[type="range"]::-moz-range-progress {
    height: 8px;
    border-radius: 999px;
    background: hsl(var(--primary));
  }

  .progress-control input[type="range"]::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border: 0;
    border-radius: 999px;
    background: hsl(var(--primary));
  }
}

.task-dialog dl {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 10px 16px;
  margin: 0;
  font-size: 13px;
}

.task-dialog dt {
  color: hsl(var(--muted-foreground));
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
}

.task-dialog dd {
  margin: 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.add-task-dialog {
  width: min(760px, calc(100dvw - 32px));
}

.category-dialog {
  width: min(720px, calc(100dvw - 32px));
}

.add-task-form {
  margin: 0;
}

.category-add-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: 10px;
  align-items: end;
  margin: 0 0 14px;
}

.category-list {
  display: grid;
  gap: 8px;
}

.category-row {
  display: grid;
  grid-template-columns: 14px minmax(0, 1fr) 56px max-content;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted) / 0.28);
}

.category-swatch {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  box-shadow: inset 0 0 0 1px hsl(0 0% 100% / 0.7);
}

.category-row input {
  min-width: 0;
  margin: 0;
  font-size: 14px;
  font-weight: 800;
}

.category-count {
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.category-delete {
  min-height: 32px;
  padding: 0 12px;
}

.category-delete:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.add-task-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.item-type-field {
  grid-column: 1 / -1;
  min-width: 0;
  padding: 0;
  margin: 0;
  border: 0;
}

.item-type-field legend {
  width: 100%;
  margin-bottom: 6px;
  color: hsl(var(--muted-foreground));
  font-size: 12px;
  font-weight: 700;
}

.item-type-control {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  background: hsl(var(--muted) / 0.45);
}

.item-type-control label {
  position: relative;
  margin: 0;
  min-width: 0;
}

.item-type-control input {
  position: absolute;
  inset: 0;
  opacity: 0;
}

.item-type-control span {
  display: grid;
  min-height: 36px;
  place-items: center;
  padding: 0 12px;
  color: hsl(var(--muted-foreground));
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.item-type-control input:checked + span {
  border-radius: 6px;
  color: #fff;
  background: hsl(var(--primary));
  box-shadow: var(--shadow-sm);
}

.item-type-control input:focus-visible + span {
  outline: 2px solid hsl(var(--ring) / 0.5);
  outline-offset: -2px;
}

.add-task-title-field,
.add-task-note-field {
  grid-column: 1 / -1;
}

.add-task-grid textarea {
  width: 100%;
  min-height: 92px;
  margin: 0;
  resize: vertical;
  border: 1px solid hsl(var(--border));
  border-radius: 8px;
  padding: 10px 12px;
  color: hsl(var(--foreground));
  background: var(--pico-form-element-background-color);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.5;
  outline: none;
}

.add-task-grid textarea:focus {
  border-color: hsl(var(--ring));
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.15);
}

.dialog-actions {
  display: grid;
  grid-template-columns: minmax(120px, max-content) minmax(220px, 1fr);
  gap: 10px;
}

@media (max-width: 1020px) {
  .controls form {
    grid-template-columns: 1fr 1fr;
  }

  .task-editor {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .editor-switch {
    grid-column: 1 / -1;
    justify-self: start;
    width: max-content;
  }

  .progress-field {
    grid-column: 1 / -1;
    min-width: 0;
  }
}

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

  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .controls form {
    grid-template-columns: 1fr;
  }

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

  .schedule-board {
    grid-template-columns: minmax(210px, 48%) minmax(520px, 1fr);
    overflow-x: auto;
  }

  .task-dialog dl {
    grid-template-columns: 88px 1fr;
  }

  .task-editor {
    grid-template-columns: 1fr;
  }

  .toolbar-actions,
  .dialog-actions {
    align-items: stretch;
    flex-direction: column;
  }

  .add-task-grid {
    grid-template-columns: 1fr;
  }

  .category-add-form,
  .category-row {
    grid-template-columns: 1fr;
  }

  .category-swatch {
    display: none;
  }

  .category-count {
    text-align: left;
  }
}
