:root {
  --cell-width: 110px;
  --row-height: 56px;
}

body {
  font-family: "Noto Sans JP", system-ui, sans-serif;
  background-color: #f8fafc;
  color: #0f172a;
}

a {
  text-decoration: none;
}

a:hover {
  text-decoration: none;
}

.grid-scroll {
  overflow-x: auto;
}

.grid-root {
  position: relative;
}

.grid-table {
  display: grid;
  position: relative;
  border: 1px solid #e2e8f0;
  background-color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(148, 163, 184, 0.08);
}

.header-cell {
  position: sticky;
  top: 0;
  z-index: 20;
  background-color: #f8fafc;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  min-height: var(--row-height);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 4px 2px;
}

.header-cell.is-weekend {
  background-color: #fff7ed;
  color: #9a3412;
}

.item-cell {
  position: sticky;
  left: 0;
  z-index: 15;
  background-color: #ffffff;
  border-right: 1px solid #e2e8f0;
  border-bottom: 1px solid #e2e8f0;
  min-height: var(--row-height);
  display: flex;
  align-items: center;
  padding: 0 16px;
  box-shadow: 1px 0 0 rgba(226, 232, 240, 0.7);
}

/* ---- Item drag handle & sort ---- */
.item-drag-handle {
  touch-action: none;
  user-select: none;
  padding: 2px;
  border-radius: 4px;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.item-drag-handle:hover {
  background-color: #eef2ff;
  color: #6366f1;
}

.item-drag-ghost {
  font-family: "Noto Sans JP", system-ui, sans-serif;
}

.row-cells {
  position: relative;
  border-bottom: 1px solid #e2e8f0;
  min-height: var(--row-height);
}

.cells-grid {
  display: grid;
  grid-template-columns: repeat(var(--day-count), minmax(var(--cell-width), 1fr));
}

.grid-cell {
  min-height: var(--row-height);
  border-right: 1px solid #e2e8f0;
  background-color: transparent;
  position: relative;
  transition: background-color 0.15s ease-in-out;
}

.grid-cell:nth-child(even) {
  background-color: #f8fafc22;
}

.grid-cell.is-weekend {
  background-color: #fff7ed66;
}

/* Week boundary markers */
.grid-cell[data-weekday="日"] {
  border-right: 2px solid #cbd5e1;
}

.grid-cell.is-selected {
  background-color: rgba(59, 130, 246, 0.25);
}

.bars-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.bar {
  position: absolute;
  top: 6px;
  height: calc(var(--row-height) - 12px);
  border-radius: 12px;
  padding: 6px 12px;
  color: #0f172a;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 4px;
  box-shadow: 0 8px 16px rgba(15, 23, 42, 0.15);
  pointer-events: auto;
  cursor: grab;
  user-select: none;
  transition: box-shadow 0.2s ease, transform 0.2s ease;
}

.bar:hover {
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.2);
}

.bar:active {
  cursor: grabbing;
}

.bar[data-status="完了"],
.bar-status-完了 {
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.5);
  filter: brightness(0.85);
}

.bar[data-status="着手"],
.bar-status-着手 {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
  background-image: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.18) 3px,
    rgba(255, 255, 255, 0.18) 6px
  ) !important;
}

.bar[data-status="保留"],
.bar-status-保留 {
  opacity: 0.45;
  filter: grayscale(0.6);
  box-shadow: none;
}

.bar[data-partial-start="true"]::before,
.bar[data-partial-end="true"]::after {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  width: 8px;
  border-radius: 999px;
  background: linear-gradient(to right, rgba(15, 23, 42, 0.35), transparent);
}

.bar[data-partial-start="true"]::before {
  left: -6px;
}

.bar[data-partial-end="true"]::after {
  right: -6px;
  background: linear-gradient(to left, rgba(15, 23, 42, 0.35), transparent);
}

.bar-label {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 12px;
  font-weight: 600;
}

.bar-title {
  font-size: 13px;
  line-height: 1.1;
}

.bar-worker {
  font-size: 11px;
  color: #1f2937;
  padding: 2px 6px;
  background-color: rgba(255, 255, 255, 0.75);
  border-radius: 999px;
}

#modal-container.hidden {
  display: none;
}

#modal-container {
  position: fixed;
  inset: 0;
  z-index: 50;
}

textarea {
  resize: vertical;
}

@media (max-width: 1024px) {
  :root {
    --cell-width: 96px;
    --row-height: 52px;
  }

  .item-cell {
    padding: 0 12px;
  }

  .bar {
    padding: 6px 10px;
  }
}

@media (max-width: 640px) {
  :root {
    --cell-width: 88px;
    --row-height: 48px;
  }

  .header-cell {
    font-size: 11px;
  }

  .bar-label {
    font-size: 11px;
  }

  .bar-title {
    font-size: 12px;
  }
}

@media print {
  body {
    background: #ffffff;
  }

  .grid-scroll {
    overflow: visible;
  }
}