:root {
  --bg: #f5f5f7;
  --surface: rgba(255, 255, 255, 0.74);
  --surface-solid: #ffffff;
  --ink: #1d1d1f;
  --muted: #6e6e73;
  --line: rgba(0, 0, 0, 0.1);
  --line-soft: rgba(0, 0, 0, 0.06);
  --green: #58d57b;
  --blue: #5aa7ff;
  --gray: #b8bac0;
  --red: #ff756b;
  --orange: #ffbd63;
  --idea: #af7a22;
  --validate: #2f6fab;
  --experiment: #2f8a59;
  --writing: #d45a49;
  --radius: 18px;
  --stage-count: 4;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 255, 255, 0.95), transparent 34rem),
    var(--bg);
  color: var(--ink);
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Segoe UI",
    "Microsoft YaHei", system-ui, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  color: inherit;
}

code {
  color: var(--blue);
}

.monitor-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 18px;
  width: min(1680px, 100%);
  height: 100vh;
  margin: 0 auto;
  padding: 18px;
  overflow: hidden;
}

.command-bar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 24px;
  min-height: 54px;
}

.brand-cluster {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

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

h1 {
  margin-bottom: 0;
  font-size: clamp(24px, 2.4vw, 34px);
  font-weight: 760;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: 15px;
  font-weight: 650;
  color: var(--muted);
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
}

.ai-summary-button {
  justify-self: end;
  display: inline-flex;
  align-items: center;
  gap: 9px;
  height: 38px;
  border: 1px solid rgba(0, 122, 255, 0.16);
  border-radius: 999px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(246, 250, 255, 0.88)),
    #fff;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.75),
    0 10px 28px rgba(0, 122, 255, 0.12);
  color: #0a67d7;
  cursor: pointer;
  font-weight: 720;
  padding: 0 15px 0 10px;
  white-space: nowrap;
}

.ai-summary-button:hover,
.ai-summary-button:focus-visible {
  outline: none;
  border-color: rgba(0, 122, 255, 0.28);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.9),
    0 12px 32px rgba(0, 122, 255, 0.16);
}

.ai-summary-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.ai-button-logo {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border-radius: 50%;
  background: linear-gradient(135deg, #e8f3ff, #ffffff);
  color: #007aff;
}

.ai-button-logo svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.field {
  display: block;
  min-width: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}

.field input,
.field select {
  height: 36px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 0 0 1px var(--line-soft);
  color: var(--ink);
  outline: none;
  padding: 0 14px;
}

.field input {
  width: min(220px, 26vw);
  min-width: 140px;
}

.field select {
  width: min(104px, 16vw);
  min-width: 86px;
}

.field input:focus,
.field select:focus {
  box-shadow:
    inset 0 0 0 1px rgba(0, 122, 255, 0.55),
    0 0 0 4px rgba(0, 122, 255, 0.12);
}

.timeline-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.timeline-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 4px 10px;
}

.status-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
}

.legend-chip,
.meta-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.legend-chip .svg-icon {
  display: none;
}

.legend-chip::before {
  content: "";
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.board-scroll {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  backdrop-filter: blur(24px);
}

.timeline-grid {
  display: grid;
  grid-template-columns: 132px repeat(var(--stage-count), minmax(0, 1fr));
  width: 100%;
  min-width: 0;
}

.grid-cell {
  min-height: 92px;
  border-right: 1px solid var(--line-soft);
  border-bottom: 1px solid var(--line-soft);
}

.corner-cell,
.stage-header {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 50px;
  background: rgba(250, 250, 252, 0.9);
  backdrop-filter: blur(20px);
}

.corner-cell {
  left: 0;
  z-index: 7;
  display: flex;
  align-items: center;
  padding: 0 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.stage-header {
  display: flex;
  align-items: center;
  padding: 0 16px;
  border-top: 4px solid var(--stage-color);
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--stage-color) 18%, white),
    rgba(250, 250, 252, 0.92)
  );
}

.stage-header strong {
  font-size: 14px;
  font-weight: 700;
}

.student-cell {
  position: sticky;
  left: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 11px 12px;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(18px);
}

.student-button {
  width: 100%;
  border: 0;
  cursor: pointer;
  text-align: left;
}

.student-button:hover,
.student-button:focus-visible {
  outline: none;
  background: rgba(255, 255, 255, 0.98);
}

.student-name-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}

.student-cell h3 {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
  font-weight: 750;
  letter-spacing: 0;
  line-height: 1.1;
}

.student-name-line span {
  min-width: 0;
  color: var(--blue);
  font-size: 9px;
  font-weight: 700;
  white-space: nowrap;
}

.student-cell p {
  overflow: hidden;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.35;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-cell {
  position: relative;
  display: flex;
  align-items: center;
  padding: 0;
  background: color-mix(in srgb, var(--stage-color) 5%, white);
}

.trace-line {
  position: absolute;
  left: 0;
  right: auto;
  width: var(--stage-line-end);
  top: 50%;
  height: 12px;
  transform: translateY(-50%);
  border-radius: 0;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--student-color) 76%, white),
    color-mix(in srgb, var(--student-color) 56%, white)
  );
  box-shadow:
    inset 0 0 0 1px color-mix(in srgb, var(--student-color) 20%, transparent),
    0 6px 18px color-mix(in srgb, var(--student-color) 24%, transparent);
  opacity: 0.95;
}

.node-track {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  width: 100%;
  min-height: 60px;
  padding: 0;
}

.stage-cell.is-empty .node-track {
  min-height: 60px;
}

.timeline-node {
  display: grid;
  position: absolute;
  left: var(--node-position);
  top: 50%;
  width: 20px;
  min-width: 20px;
  height: 22px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  padding: 0;
  transform: translate(-50%, -50%);
}

.timeline-node:hover,
.timeline-node:focus-visible {
  outline: none;
}

.timeline-node:hover,
.timeline-node:focus-visible {
  transform: translate(-50%, -50%) scale(1.16);
}

.timeline-node:hover .node-dot,
.timeline-node:focus-visible .node-dot {
  box-shadow:
    0 0 0 5px color-mix(in srgb, currentColor 16%, transparent),
    0 8px 20px rgba(0, 0, 0, 0.16);
}

.node-dot {
  width: 15px;
  height: 15px;
  border: 2px solid rgba(255, 255, 255, 0.92);
  border-radius: 50%;
  background: currentColor;
  box-shadow:
    0 0 0 4px color-mix(in srgb, currentColor 14%, transparent),
    0 4px 12px rgba(0, 0, 0, 0.1);
  transition:
    box-shadow 150ms ease;
}

.status-done {
  color: var(--green);
}

.status-active {
  color: var(--blue);
}

.status-idle {
  color: var(--gray);
}

.status-idle .node-dot {
  background: var(--surface-solid);
}

.status-blocked {
  color: var(--red);
}

.status-review {
  color: var(--orange);
}

.empty-state {
  padding: 34px;
  text-align: center;
}

.empty-state h3 {
  margin-bottom: 8px;
}

.empty-state p,
.muted {
  margin-bottom: 0;
  color: var(--muted);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
  padding: 20px;
}

.modal-card {
  width: min(720px, 100%);
  max-height: min(820px, 92vh);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.18);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-kicker {
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.modal-head h2 {
  margin-bottom: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-size: 28px;
  font-weight: 760;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 auto;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.06);
  color: var(--muted);
  cursor: pointer;
  font-size: 26px;
  line-height: 1;
}

.icon-button:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--ink);
}

.modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 14px 26px;
  border-bottom: 1px solid var(--line-soft);
}

.modal-body {
  max-height: 520px;
  overflow: auto;
  padding: 22px 26px 28px;
  color: var(--ink);
  line-height: 1.75;
}

.modal-body p {
  margin-bottom: 12px;
}

.modal-body h3,
.modal-body h4 {
  margin: 20px 0 8px;
  color: var(--ink);
  font-size: 16px;
  font-weight: 760;
  letter-spacing: 0;
  line-height: 1.35;
}

.modal-body h3:first-child,
.modal-body h4:first-child {
  margin-top: 0;
}

.modal-body ul {
  margin: 0 0 14px;
  padding-left: 22px;
}

.modal-body li {
  margin-bottom: 7px;
}

.modal-body img {
  display: block;
  width: min(100%, 620px);
  max-height: 360px;
  object-fit: contain;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.svg-icon {
  display: inline-flex;
  width: 1em;
  height: 1em;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  vertical-align: -0.14em;
}

.svg-icon svg {
  width: 1em;
  height: 1em;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.hidden {
  display: none;
}

.modal-open {
  overflow: hidden;
}

@media (max-width: 860px) {
  .monitor-shell {
    height: auto;
    min-height: 100vh;
    padding: 16px;
  }

  .command-bar {
    align-items: stretch;
    grid-template-columns: 1fr;
  }

  .toolbar {
    width: 100%;
  }

  .ai-summary-button {
    justify-self: start;
  }

  .field {
    flex: 1;
  }

  .field input,
  .field select {
    width: 100%;
  }

  .timeline-grid {
    grid-template-columns: 120px repeat(var(--stage-count), minmax(0, 1fr));
    min-width: 0;
  }

  .student-cell,
  .corner-cell {
    width: 120px;
  }

  .stage-cell {
    padding: 0;
  }
}
