:root {
  color-scheme: light;
  --bg: #edf3f1;
  --surface: rgba(255, 255, 255, 0.62);
  --surface-soft: rgba(246, 251, 248, 0.56);
  --surface-strong: rgba(255, 255, 255, 0.78);
  --glass: rgba(255, 255, 255, 0.56);
  --glass-strong: rgba(255, 255, 255, 0.74);
  --ink: #13211f;
  --muted: #5e6f6c;
  --line: rgba(102, 124, 119, 0.26);
  --line-strong: rgba(83, 105, 100, 0.34);
  --sow: #2e8f68;
  --transplant: #6f68cf;
  --growth: #1f849c;
  --harvest: #c87f26;
  --danger: #b84d44;
  --shadow: 0 22px 60px rgba(29, 48, 46, 0.16);
  --blur: blur(18px) saturate(138%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    linear-gradient(135deg, rgba(31, 132, 156, 0.16), transparent 38%),
    linear-gradient(315deg, rgba(200, 127, 38, 0.13), transparent 42%),
    linear-gradient(180deg, #eef5f3 0%, #f7f4ec 100%);
  background-attachment: fixed;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

button,
input {
  font: inherit;
}

.planner-page {
  min-height: 100vh;
  padding: 22px clamp(14px, 3vw, 34px) 32px;
}

.planner-header,
.control-strip,
.planner-layout {
  max-width: 1580px;
  margin-inline: auto;
}

.planner-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.kicker,
.board-kicker {
  margin: 0 0 6px;
  color: var(--growth);
  font-size: 13px;
  font-weight: 800;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 58px);
  line-height: 1.04;
}

h2 {
  font-size: 22px;
  line-height: 1.2;
}

.back-link,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  color: #18543b;
  font-size: 14px;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 10px 28px rgba(24, 43, 40, 0.07);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.back-link:hover,
.ghost-button:hover {
  border-color: rgba(46, 143, 104, 0.38);
  background: rgba(230, 244, 236, 0.76);
}

.control-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 14px;
}

.field-control {
  display: grid;
  grid-template-columns: auto 104px auto;
  gap: 8px;
  align-items: center;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  box-shadow: 0 10px 28px rgba(24, 43, 40, 0.07);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.field-control span,
.field-control em {
  color: var(--muted);
  font-size: 13px;
  font-style: normal;
  font-weight: 800;
}

.field-control input,
.palette-search input,
.plan-area-input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.planner-layout {
  display: grid;
  grid-template-columns: minmax(280px, 350px) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.crop-panel,
.board {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
}

.crop-panel {
  position: sticky;
  top: 14px;
  max-height: calc(100vh - 28px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.panel-head span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.palette-search {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  margin: 12px 14px 8px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
}

.palette-search span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.category-filter {
  display: flex;
  flex: 0 0 auto;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  overflow: visible;
  padding: 0 14px 12px;
}

.category-filter button {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 12px;
  line-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.5);
  color: var(--muted);
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, color 160ms ease, transform 160ms ease;
}

.category-filter button:hover {
  transform: translateY(-1px);
}

.category-filter button.active {
  border-color: rgba(46, 143, 104, 0.38);
  background: rgba(222, 240, 230, 0.72);
  color: #18543b;
  font-weight: 800;
}

.palette-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: 0 14px 14px;
  scrollbar-width: thin;
}

.crop-option {
  width: 100%;
  margin: 0 0 9px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(246, 251, 248, 0.52)),
    rgba(255, 255, 255, 0.34);
  color: var(--ink);
  text-align: left;
  cursor: grab;
  animation: softEnter 220ms ease both;
  transition: border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.crop-option:hover {
  border-color: rgba(46, 143, 104, 0.38);
  box-shadow: 0 12px 26px rgba(24, 43, 40, 0.12);
  transform: translateY(-1px);
}

.crop-option:active {
  cursor: grabbing;
}

.crop-option strong,
.crop-option span,
.crop-option small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crop-option strong {
  font-size: 14px;
}

.crop-option span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.crop-option small {
  margin-top: 5px;
  color: #266c78;
  font-size: 11px;
}

.board {
  overflow: hidden;
}

.stage-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

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

.stage-legend i {
  width: 28px;
  height: 10px;
  border-radius: 999px;
}

.legend-sow {
  background: var(--sow);
}

.legend-transplant {
  background: var(--transplant);
}

.legend-growth {
  background: var(--growth);
}

.legend-harvest {
  background: var(--harvest);
}

.board-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(31, 132, 156, 0.12), rgba(200, 127, 38, 0.1)),
    rgba(255, 255, 255, 0.52);
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(88px, 1fr));
  gap: 8px;
}

.metric-grid div {
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.42);
}

.metric-grid strong,
.metric-grid span {
  display: block;
}

.metric-grid strong {
  font-size: 21px;
  line-height: 1;
}

.metric-grid span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
}

.metric-grid div.danger {
  border-color: rgba(190, 77, 66, 0.36);
  background: rgba(255, 243, 241, 0.72);
}

.metric-grid div.danger strong {
  color: var(--danger);
}

.month-capacity {
  display: grid;
  grid-template-columns: repeat(12, minmax(72px, 1fr));
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  overflow-x: auto;
}

.capacity-card {
  min-width: 72px;
}

.capacity-card b,
.capacity-card span,
.capacity-card small {
  display: block;
  font-size: 12px;
}

.capacity-card small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 11px;
}

.capacity-card b {
  color: var(--muted);
}

.capacity-track {
  height: 8px;
  margin: 7px 0 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(222, 232, 226, 0.72);
}

.capacity-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--growth), var(--harvest));
  transition: width 220ms ease, background 160ms ease;
}

.capacity-card.over .capacity-fill {
  background: var(--danger);
}

.capacity-card.over span,
.capacity-card.over small {
  color: var(--danger);
  font-weight: 800;
}

.dropzone {
  position: relative;
  overflow: auto;
  min-height: 430px;
  max-height: calc(100vh - 330px);
  background: rgba(255, 255, 255, 0.28);
  scrollbar-width: thin;
}

.dropzone.is-over {
  background: rgba(235, 248, 241, 0.5);
}

.timeline-head,
.plan-row {
  display: grid;
  grid-template-columns: 260px repeat(12, 74px);
  min-width: 1148px;
}

.timeline-head {
  position: sticky;
  top: 0;
  z-index: 4;
  min-height: 42px;
  background: rgba(250, 253, 251, 0.76);
  backdrop-filter: var(--blur);
  -webkit-backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line-strong);
}

.timeline-head div {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  border-right: 1px solid var(--line);
}

.timeline-head div:first-child {
  position: sticky;
  left: 0;
  z-index: 5;
  justify-content: flex-start;
  padding-left: 14px;
  background: rgba(250, 253, 251, 0.82);
  border-right-color: var(--line-strong);
  box-shadow: 8px 0 14px rgba(23, 33, 27, 0.06);
}

.plan-row {
  min-height: calc(38px + var(--lane-count, 1) * 20px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.18);
  animation: softEnter 220ms ease both;
  transition: opacity 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.plan-row.dragging {
  opacity: 0.56;
}

.plan-row.drop-before {
  box-shadow: inset 0 3px 0 var(--growth);
}

.plan-meta {
  position: sticky;
  left: 0;
  z-index: 2;
  display: grid;
  grid-template-columns: 20px minmax(112px, 1fr) 58px 28px;
  gap: 7px;
  align-items: center;
  padding: 9px 8px 9px 10px;
  border-right: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(14px) saturate(132%);
  -webkit-backdrop-filter: blur(14px) saturate(132%);
  box-shadow: 8px 0 14px rgba(23, 33, 27, 0.06);
}

.plan-title strong,
.plan-title span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-title strong {
  font-size: 13px;
  line-height: 1.2;
}

.plan-title span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.plan-area-input {
  min-height: 34px;
  padding: 0 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.drag-handle {
  width: 20px;
  height: 34px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: #7a8b82;
  font-size: 18px;
  line-height: 34px;
  cursor: grab;
}

.drag-handle:active {
  cursor: grabbing;
}

.remove-plan {
  width: 28px;
  height: 28px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.58);
  color: var(--muted);
  cursor: pointer;
}

.plan-track {
  position: relative;
  grid-column: span 12;
  background:
    repeating-linear-gradient(
      to right,
      transparent 0,
      transparent 73px,
      rgba(88, 110, 105, 0.18) 73px,
      rgba(88, 110, 105, 0.18) 74px
    ),
    linear-gradient(90deg, rgba(46, 143, 104, 0.055), rgba(200, 127, 38, 0.05)),
    rgba(255, 255, 255, 0.2);
}

.plan-segment {
  position: absolute;
  left: calc(var(--left) * 1%);
  top: var(--top, 50%);
  transform: translateY(-50%);
  width: max(calc(var(--width) * 1%), 18px);
  height: 16px;
  border-radius: 999px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.2),
    inset 0 -1px 0 rgba(0, 0, 0, 0.12),
    0 5px 12px rgba(20, 42, 39, 0.1);
  transition: left 180ms ease, width 180ms ease, opacity 180ms ease;
}

.plan-segment.sow,
.plan-segment.seedling,
.plan-segment.direct {
  background: var(--sow);
}

.plan-segment.transplant {
  background: var(--transplant);
}

.plan-segment.growth {
  background: var(--growth);
}

.plan-segment.harvest {
  background: var(--harvest);
}

.empty-plan {
  position: absolute;
  inset: 56px 16px auto;
  display: grid;
  place-items: center;
  min-height: 220px;
  border: 1px dashed rgba(99, 124, 115, 0.44);
  border-radius: 8px;
  color: var(--muted);
  font-weight: 800;
  background: rgba(255, 255, 255, 0.36);
  backdrop-filter: blur(10px) saturate(120%);
  -webkit-backdrop-filter: blur(10px) saturate(120%);
}

.empty-plan.hidden {
  display: none;
}

@media (max-width: 980px) {
  .planner-layout {
    grid-template-columns: 1fr;
  }

  .crop-panel {
    position: static;
    max-height: 390px;
  }

  .board-top {
    grid-template-columns: 1fr;
  }

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

@media (max-width: 620px) {
  .planner-header {
    align-items: flex-start;
    flex-direction: column;
  }

  h1 {
    font-size: 36px;
  }

  .field-control {
    width: 100%;
  }
}
@keyframes softEnter {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}
