:root {
  color-scheme: dark;
  --bg: #061012;
  --panel: rgba(255, 255, 255, 0.045);
  --panel-strong: rgba(255, 255, 255, 0.075);
  --text: #edf8f5;
  --muted: #8ba5a7;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(167, 232, 225, 0.22);
  --green: #46d6b0;
  --green-soft: #9ff3d7;
  --blue: #7fb8ff;
  --blue-soft: #d6ecff;
  --violet: #a996ff;
  --amber: #ffd27a;
  --red: #ff8b7f;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.34);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 20% -10%, rgba(58, 211, 185, 0.20), transparent 34%),
    radial-gradient(circle at 92% 0%, rgba(137, 119, 255, 0.20), transparent 32%),
    linear-gradient(180deg, #071719 0%, #050b0d 100%);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex: 0 0 auto;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.075);
  background: rgba(4, 11, 13, 0.76);
  backdrop-filter: blur(12px);
}

.brand,
.top-actions,
.button-row,
.panel-head {
  display: flex;
  align-items: center;
}

.brand {
  gap: 12px;
  min-width: 0;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border: 1px solid rgba(85, 227, 202, 0.32);
  background: rgba(85, 227, 202, 0.10);
  color: var(--green);
  border-radius: 8px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08), 0 0 28px rgba(70, 214, 176, 0.08);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 18px;
  line-height: 1.15;
  font-weight: 720;
}

h2 {
  font-size: 15px;
  line-height: 1.2;
  font-weight: 720;
}

.brand p,
small {
  color: var(--muted);
}

.brand p {
  margin-top: 3px;
  font-size: 13px;
}

.top-actions {
  gap: 8px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(280px, 0.8fr) minmax(440px, 1.35fr) minmax(340px, 1fr);
  gap: 16px;
  padding: 18px;
  max-width: min(1840px, calc(100vw - 24px));
  margin: 0 auto;
  align-items: start;
}

.session-band {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(300px, 1.1fr) minmax(380px, 1.15fr) minmax(250px, 0.75fr);
  gap: 18px;
  align-items: center;
  min-height: 180px;
  padding: 24px;
  border-radius: 10px;
  background:
    linear-gradient(135deg, rgba(8, 31, 38, 0.96), rgba(10, 42, 49, 0.88) 46%, rgba(42, 28, 72, 0.92)),
    #081b21;
  color: var(--text);
  border: 1px solid rgba(151, 238, 229, 0.14);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.44);
}

.session-copy {
  display: grid;
  gap: 10px;
}

.version-pill {
  width: fit-content;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  font-size: 12px;
  font-weight: 780;
}

.session-copy h2 {
  color: var(--text);
  font-size: clamp(30px, 4vw, 58px);
  line-height: 1.05;
  max-width: 740px;
}

.session-copy p,
.session-action p {
  color: rgba(237, 248, 245, 0.72);
  line-height: 1.45;
  max-width: 720px;
}

.session-rail {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.rail-step {
  min-height: 108px;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.055);
  color: rgba(255, 255, 255, 0.70);
}

.rail-step::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 5px;
  background: transparent;
}

.rail-step span {
  position: relative;
  font-size: 13px;
  font-weight: 820;
}

.rail-step.active {
  background: linear-gradient(180deg, rgba(87, 220, 208, 0.22), rgba(131, 118, 255, 0.10));
  color: #fff;
  border-color: rgba(122, 244, 224, 0.34);
}

.rail-step.active::before {
  background: linear-gradient(90deg, var(--green), var(--violet));
}

.rail-step.done {
  background: rgba(255, 255, 255, 0.12);
  color: #eaf6ef;
}

.rail-step.done::before {
  background: rgba(157, 224, 179, 0.9);
}

.session-action {
  display: grid;
  justify-items: start;
  gap: 9px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.session-action strong {
  font-size: 22px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
  backdrop-filter: blur(16px);
}

.panel-head {
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.project-panel,
.node-panel,
.checkpoint-panel {
  display: grid;
  gap: 12px;
}

.project-panel {
  grid-column: 1;
}

.node-panel {
  grid-column: 2;
  grid-row: span 2;
  background: rgba(255, 255, 255, 0.065);
  border-color: rgba(122, 244, 224, 0.18);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.42);
}

.checkpoint-panel {
  grid-column: 1;
}

.timeline-panel {
  grid-column: 3;
  grid-row: span 2;
  min-height: 640px;
}

label {
  display: grid;
  gap: 6px;
  color: #a9c7c6;
  font-size: 12px;
  font-weight: 690;
  letter-spacing: 0;
}

input,
select,
textarea {
  width: 100%;
  color: var(--text);
  background: rgba(0, 0, 0, 0.20);
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  padding: 10px 11px;
  outline: none;
}

textarea {
  resize: vertical;
  min-height: 74px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(70, 214, 176, 0.14), 0 0 28px rgba(70, 214, 176, 0.08);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.node-stage {
  display: none;
}

body.stage-study .stage-study,
body.stage-change .stage-study,
body.stage-change .stage-change,
body.stage-pressure .stage-study,
body.stage-pressure .stage-change,
body.stage-pressure .stage-pressure,
body.stage-next .stage-study,
body.stage-next .stage-change,
body.stage-next .stage-pressure,
body.stage-next .stage-next {
  display: grid;
}

body.stage-change .stage-study,
body.stage-pressure .stage-study,
body.stage-pressure .stage-change,
body.stage-next .stage-study,
body.stage-next .stage-change,
body.stage-next .stage-pressure {
  opacity: 0.58;
}

body.stage-change .stage-change,
body.stage-pressure .stage-pressure,
body.stage-next .stage-next {
  opacity: 1;
}

.button-row {
  gap: 8px;
  flex-wrap: wrap;
}

.starter-box {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: end;
  padding-top: 2px;
}

.loop-stepper {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.loop-step {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  color: var(--muted);
  overflow: hidden;
}

.loop-step span {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 11px;
  font-weight: 780;
  flex: 0 0 auto;
}

.loop-step strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 760;
}

.loop-step.active {
  color: var(--green-soft);
  border-color: rgba(70, 214, 176, 0.32);
  background: rgba(70, 214, 176, 0.09);
}

.loop-step.done {
  color: var(--blue);
  background: rgba(127, 184, 255, 0.07);
}

.current-move {
  display: grid;
  gap: 6px;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid rgba(127, 184, 255, 0.20);
  background: rgba(127, 184, 255, 0.07);
}

.current-move span {
  color: var(--blue);
  font-size: 12px;
  font-weight: 780;
}

.current-move p {
  color: #c9dce4;
  line-height: 1.45;
  font-size: 14px;
}

.teaching-card {
  border: 1px solid rgba(122, 244, 224, 0.18);
  border-radius: 8px;
  background: rgba(70, 214, 176, 0.07);
  padding: 12px;
}

.teaching-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  color: var(--green-soft);
  font-size: 13px;
  font-weight: 760;
}

.teaching-head strong {
  min-width: 80px;
  text-align: right;
}

.teaching-card p {
  margin-top: 7px;
  color: #c5dddb;
  line-height: 1.45;
  font-size: 13px;
}

.teaching-card.warn {
  background: rgba(255, 210, 122, 0.08);
  border-color: rgba(255, 210, 122, 0.26);
}

.teaching-card.warn .teaching-head {
  color: var(--amber);
}

.teaching-card.strong {
  background: rgba(70, 214, 176, 0.10);
  border-color: rgba(70, 214, 176, 0.34);
}

.teaching-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.prompt-chip {
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--blue);
  font-size: 12px;
  font-weight: 720;
}

.primary-button,
.secondary-button,
.danger-button,
.light-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 38px;
  border-radius: 7px;
  border: 1px solid transparent;
  padding: 0 12px;
  font-weight: 720;
  white-space: nowrap;
}

.primary-button {
  background: linear-gradient(135deg, #42d6b3, #7d8dff);
  color: #061012;
  border: 0;
}

.primary-button:hover {
  filter: brightness(1.08);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.055);
  color: var(--blue);
  border-color: var(--line-strong);
}

.danger-button {
  background: rgba(255, 139, 127, 0.08);
  color: var(--red);
  border-color: rgba(255, 139, 127, 0.22);
}

.light-button {
  background: rgba(255, 255, 255, 0.92);
  color: #0b1e25;
  border-color: rgba(255, 255, 255, 0.7);
}

.icon-button {
  width: 38px;
  padding: 0;
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border-color: var(--line-strong);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.stats-grid div {
  min-height: 70px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: rgba(0, 0, 0, 0.18);
}

.stats-grid span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 21px;
  font-weight: 780;
}

.stats-grid small {
  display: block;
  margin-top: 4px;
  font-size: 11px;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(70, 214, 176, 0.10);
  color: var(--green-soft);
  border: 1px solid rgba(70, 214, 176, 0.22);
  font-size: 12px;
  font-weight: 760;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  overflow: hidden;
}

.segmented button {
  min-height: 32px;
  border: 0;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  padding: 0 10px;
  font-size: 12px;
  font-weight: 720;
}

.segmented button + button {
  border-left: 1px solid var(--line-strong);
}

.segmented button.active {
  background: rgba(70, 214, 176, 0.12);
  color: var(--green-soft);
}

.timeline {
  display: grid;
  gap: 10px;
  max-height: 570px;
  overflow: auto;
  padding-right: 3px;
}

.entry {
  border: 1px solid var(--line);
  border-left: 4px solid var(--green);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
  padding: 12px;
}

.entry.checkpoint {
  border-left-color: var(--amber);
}

.entry-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.entry-title {
  font-weight: 780;
  line-height: 1.25;
}

.entry-source {
  display: block;
  margin-top: 3px;
  color: var(--blue);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.entry p {
  margin-top: 9px;
  color: #c5d6d4;
  line-height: 1.45;
  font-size: 13px;
}

.entry-actions {
  display: flex;
  gap: 5px;
}

.mini-button {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--muted);
}

.mini-button:hover {
  color: var(--red);
}

.empty {
  display: grid;
  place-items: center;
  min-height: 320px;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  text-align: center;
  padding: 24px;
}

.empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
}

.empty p {
  max-width: 330px;
  color: var(--muted);
  line-height: 1.45;
}

.checkpoint-nudge {
  display: grid;
  gap: 6px;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.checkpoint-nudge strong {
  color: var(--muted);
  font-size: 13px;
}

.checkpoint-nudge p {
  color: var(--muted);
  line-height: 1.4;
  font-size: 13px;
}

.checkpoint-nudge.ready {
  border-color: rgba(255, 210, 122, 0.28);
  background: rgba(255, 210, 122, 0.08);
}

.checkpoint-nudge.ready strong {
  color: var(--amber);
}

.corpus-output {
  display: none;
  width: 100%;
  min-height: 570px;
  max-height: 570px;
  resize: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.26);
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  max-width: min(420px, calc(100vw - 36px));
  padding: 11px 13px;
  background: #061012;
  color: #fff;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 1120px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .session-band {
    grid-template-columns: 1fr;
  }

  .project-panel,
  .checkpoint-panel,
  .node-panel,
  .timeline-panel {
    grid-column: auto;
    grid-row: auto;
  }

  .timeline-panel {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .top-actions {
    justify-content: flex-end;
  }

  .workspace,
  .form-grid,
  .starter-box,
  .loop-stepper,
  .session-rail {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding: 12px;
    max-width: 100%;
  }

  .session-band {
    padding: 16px;
  }

  .session-copy h2 {
    font-size: 32px;
  }

  .rail-step {
    min-height: 44px;
  }

  .timeline {
    max-height: none;
  }

  .corpus-output {
    max-height: none;
  }
}
