:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-soft: #f7f9fc;
  --line: #d9e1eb;
  --text: #2f2f2f;
  --muted: #5f6c7b;
  --accent: #2f5c87;
  --support: #0a6;
  --conflict: #d23;
  --focus: #2f7de6;
  --radius: 12px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #ffffff;
  color: var(--text);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  line-height: 1.45;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.wre-shell {
  width: min(900px, calc(100% - 1.4rem));
  margin: 0 auto;
}

.skip-link {
  position: fixed;
  top: 0.5rem;
  left: 0.5rem;
  z-index: 1000;
  background: #ffffff;
  color: #2f5c87;
  border: 1px solid #c6d2e0;
  border-radius: 8px;
  padding: 0.34rem 0.54rem;
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 700;
  transform: translateY(-140%);
  transition: transform 0.2s ease;
}

.skip-link:focus-visible {
  transform: translateY(0);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(47, 125, 230, 0.3);
  outline-offset: 2px;
}

.wre-topbar {
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.wre-topbar .wre-shell {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.8rem;
  padding: 0.75rem 0;
}

.wre-home-link {
  text-decoration: none;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.9rem;
}

.wre-title {
  margin: 0;
  font-size: clamp(1.08rem, 2.2vw, 1.4rem);
  font-weight: 600;
  text-align: center;
}

.lesson-picker-wrap {
  display: grid;
  gap: 0.25rem;
}

.lesson-picker-wrap label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  font-weight: 700;
}

#lessonPicker {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.35rem 0.45rem;
  min-width: 220px;
  font: inherit;
  color: var(--text);
  background: #ffffff;
}

.wre-main {
  display: grid;
  gap: 0.8rem;
  padding: 0.85rem 0 1.6rem;
}

.progress-card,
.graph-card,
.gauge-card,
.explanation-card,
.lesson-card,
.sep-method-card {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 0.75rem;
}

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: baseline;
}

.progress-head p {
  margin: 0;
}

#progressLabel {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

#progressTitle {
  font-size: 0.9rem;
  color: #435062;
}

.progress-track {
  margin-top: 0.55rem;
  width: 100%;
  height: 9px;
  border-radius: 999px;
  background: #edf2f7;
  overflow: hidden;
}

#progressFill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 300ms ease;
  background: linear-gradient(90deg, #5ca6ff 0%, #2f5c87 100%);
}

.sep-method-card p {
  margin: 0;
}

.sep-method-title {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 700;
  margin-bottom: 0.3rem !important;
}

.sep-method-links {
  margin-top: 0.34rem !important;
}

.sep-method-links a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px dotted rgba(47, 92, 135, 0.45);
}

.sep-method-links a:hover,
.sep-method-links a:focus-visible {
  color: #ff5f35;
  border-bottom-color: rgba(255, 95, 53, 0.6);
}

.workspace {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 0.8rem;
  align-items: start;
}

.workspace-left,
.workspace-right {
  display: grid;
  gap: 0.8rem;
}

.graph-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.7rem;
  margin-bottom: 0.4rem;
}

.graph-card-head h2,
.gauge-card h2,
.explanation-card h2,
.lesson-card h2 {
  margin: 0;
  font-size: 1.02rem;
  font-weight: 650;
}

.btn {
  border: 1px solid #c6d2e0;
  border-radius: 8px;
  padding: 0.4rem 0.66rem;
  background: #ffffff;
  color: #25384f;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 650;
  cursor: pointer;
}

.btn:hover {
  background: #f4f8fc;
}

.btn:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.btn-primary {
  border-color: #2f5c87;
  color: #ffffff;
  background: #2f5c87;
}

.btn-primary:hover {
  background: #274f76;
}

.btn-ghost {
  border-color: #cdd7e2;
  background: #ffffff;
}

.lesson-card {
  display: grid;
  gap: 0.65rem;
}

.lesson-stage-label {
  margin: 0;
  color: #42566f;
  font-size: 0.85rem;
  font-weight: 600;
}

.lesson-card-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 0.75rem;
  align-items: start;
}

.lesson-card-col {
  min-width: 0;
  display: grid;
  gap: 0.65rem;
  align-content: start;
}

.lesson-case {
  border: 1px solid #dbe4ee;
  background: #f8fbff;
  border-radius: 10px;
  padding: 0.55rem 0.6rem;
}

.lesson-case p {
  margin: 0.22rem 0 0;
}

.label-lite {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 700;
}

.question-text {
  margin: 0.2rem 0 0;
  font-size: 1rem;
  font-weight: 600;
}

.answer-summary {
  margin: 0;
  border: 1px solid #d7e3f0;
  background: #f6faff;
  border-radius: 8px;
  padding: 0.45rem 0.55rem;
  color: #2f4c6c;
  font-size: 0.86rem;
  font-weight: 600;
}

.lesson-sources {
  border: 1px solid #d8e0e8;
  border-radius: 10px;
  background: #f5f5f2;
  padding: 0.48rem 0.56rem;
  display: grid;
  gap: 0.35rem;
}

.lesson-source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.45rem;
}

.lesson-source-grid p,
.lesson-source-grid ul,
.lesson-source-grid li,
.lesson-source-method,
.lesson-source-caveat {
  margin: 0;
}

.lesson-source-grid ul {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.22rem;
}

.lesson-source-head {
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-weight: 700;
  color: #5d615f;
  margin-bottom: 0.15rem;
}

.lesson-source-label,
.lesson-source-grid li {
  font-size: 0.78rem;
  color: #4e5351;
}

.lesson-source-link {
  color: #2f3d53;
  text-decoration: none;
  border-bottom: 1px dotted rgba(47, 61, 83, 0.45);
}

.lesson-source-link:hover,
.lesson-source-link:focus-visible {
  color: #ff5f35;
  border-bottom-color: rgba(255, 95, 53, 0.65);
}

.lesson-source-method {
  font-size: 0.79rem;
  color: #4f5553;
}

.lesson-source-caveat {
  font-size: 0.79rem;
  color: #5a605d;
}

.lesson-diagnostic {
  border: 1px solid #d9e3ee;
  border-radius: 10px;
  background: #f8fbff;
  padding: 0.5rem 0.58rem;
  display: grid;
  gap: 0.34rem;
}

.lesson-diagnostic-grid {
  display: grid;
  gap: 0.25rem;
}

.lesson-diagnostic-grid p,
.lesson-diagnostic-note,
.lesson-diagnostic-list,
.lesson-diagnostic-links {
  margin: 0;
}

.lesson-diagnostic-note {
  color: #425a74;
  font-size: 0.82rem;
}

.lesson-diagnostic-list {
  padding-left: 1rem;
  color: #41576f;
  font-size: 0.82rem;
  display: grid;
  gap: 0.14rem;
}

.lesson-diagnostic-links {
  font-size: 0.78rem;
}

.answer-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.45rem;
}

.answer-btn[aria-pressed="true"] {
  border-color: #2f5c87;
  background: #2f5c87;
  color: #ffffff;
}

.confidence-row {
  display: grid;
  gap: 0.3rem;
}

.confidence-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.confidence-meta p {
  margin: 0;
}

.confidence-value {
  font-weight: 700;
  color: #2f5c87;
}

.confidence-input {
  width: 100%;
}

.revision-box {
  border-top: 1px solid #dfe7f0;
  padding-top: 0.55rem;
  display: grid;
  gap: 0.45rem;
}

.revision-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.revision-item {
  border: 1px solid #d0dbe8;
  background: #ffffff;
  border-radius: 999px;
  padding: 0.28rem 0.58rem;
  font-size: 0.79rem;
  color: #2f3e50;
}

.revision-item:hover {
  background: #f4f8fc;
}

.revision-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.lesson-step-controls {
  display: flex;
  justify-content: flex-end;
}

.lesson-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.mini-graph-svg {
  width: 100%;
  height: auto;
  border: 1px solid #dbe3ee;
  border-radius: 10px;
  background: #ffffff;
  touch-action: none;
}

.graph-pan-surface {
  cursor: grab;
}

.graph-pan-surface:active {
  cursor: grabbing;
}

.graph-edge-path {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-width 260ms ease, opacity 260ms ease, stroke 220ms ease;
}

.graph-edge-path.is-support {
  stroke-dasharray: none;
}

.graph-edge-path.is-conflict {
  stroke-dasharray: 6 4;
}

.graph-edge-path.is-changed {
  animation: edgePulse 600ms ease-out 1;
}

.graph-edge-hit {
  fill: none;
  cursor: pointer;
}

.graph-edge-hit:focus-visible {
  stroke: rgba(47, 125, 230, 0.42) !important;
}

.graph-edge-path.is-focused {
  stroke-width: 4.8px !important;
  opacity: 1;
  filter: drop-shadow(0 0 2px rgba(47, 125, 230, 0.32));
}

.graph-node-shape {
  transition: fill 280ms ease, stroke-width 220ms ease;
}

.graph-node {
  cursor: pointer;
}

.graph-node:focus-visible .graph-node-shape {
  stroke: var(--focus);
  stroke-width: 3;
}

.graph-node-label {
  font-size: 10.8px;
  font-weight: 600;
  fill: #1f2a36;
  pointer-events: none;
  user-select: none;
}

@keyframes edgePulse {
  0% {
    opacity: 0.95;
    filter: drop-shadow(0 0 0 rgba(47, 125, 230, 0));
  }
  50% {
    opacity: 1;
    filter: drop-shadow(0 0 3px rgba(47, 125, 230, 0.45));
  }
  100% {
    opacity: 0.9;
    filter: drop-shadow(0 0 0 rgba(47, 125, 230, 0));
  }
}

.gauge-wrap {
  display: grid;
  gap: 0.42rem;
}

.gauge-track {
  height: 12px;
  background: #ecf1f7;
  border-radius: 999px;
  overflow: hidden;
}

.gauge-fill {
  height: 100%;
  width: 50%;
  transition: width 140ms linear;
}

.gauge-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gauge-value {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
  color: #233951;
}

.gauge-detail {
  margin: 0;
  color: #5f6f82;
  font-size: 0.82rem;
}

.inspector-wrap {
  display: grid;
  gap: 0.55rem;
}

.inspect-hover,
.inspect-list {
  border: 1px solid #dce5ef;
  border-radius: 10px;
  background: #f9fbff;
  padding: 0.55rem 0.6rem;
}

.inspect-hover h3,
.inspect-list h3 {
  margin: 0 0 0.35rem;
  font-size: 0.92rem;
}

.inspect-list ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.edge-rank-list {
  display: grid;
  gap: 0.55rem;
}

.edge-rank-item {
  border: 1px solid #d7e1ed;
  border-radius: 10px;
  background: #ffffff;
  padding: 0.45rem 0.55rem;
  cursor: pointer;
}

.edge-rank-item.is-active {
  border-color: #7fa4cc;
  background: #f3f8ff;
}

.edge-rank-item:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.edge-rank-head {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.86rem;
}

.edge-rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  border-radius: 999px;
  border: 1px solid #cad7e5;
  background: #f3f7fc;
  color: #42566f;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.08rem 0.35rem;
}

.edge-rank-principle {
  min-width: 0;
}

.edge-rank-relation {
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #55667c;
  font-size: 0.72rem;
  font-weight: 700;
}

.edge-rank-delta {
  font-variant-numeric: tabular-nums;
  font-size: 0.82rem;
  font-weight: 700;
}

.delta-positive {
  color: #0a6;
}

.delta-negative {
  color: #d23;
}

.delta-neutral {
  color: #5f6f82;
}

.edge-delta-track {
  margin-top: 0.32rem;
  width: 100%;
  height: 6px;
  background: #e7eef6;
  border-radius: 999px;
  overflow: hidden;
}

.edge-delta-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
}

.edge-delta-fill.delta-positive {
  background: linear-gradient(90deg, #94e3c1 0%, #0a6 100%);
}

.edge-delta-fill.delta-negative {
  background: linear-gradient(90deg, #f4b1b7 0%, #d23 100%);
}

.edge-delta-fill.delta-neutral {
  background: #9baabd;
}

.edge-contrib-meta {
  margin: 0.3rem 0 0;
  color: #607086;
  font-size: 0.77rem;
  font-variant-numeric: tabular-nums;
}

.edge-source {
  margin: 0.22rem 0 0;
  color: #5a6c83;
  font-size: 0.78rem;
}

.edge-basis {
  color: #425266;
}

.edge-link {
  color: #2f5c87;
  text-decoration: none;
}

.edge-link:hover,
.edge-link:focus-visible {
  text-decoration: underline;
}

.empty-note {
  margin: 0;
  color: #5f6f82;
  font-size: 0.85rem;
}

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

  .wre-topbar .wre-shell {
    grid-template-columns: 1fr;
    gap: 0.5rem;
    text-align: left;
  }

  .wre-title {
    text-align: left;
  }

  #lessonPicker {
    min-width: 0;
    width: 100%;
  }
}

@media (max-width: 760px) {
  .lesson-card-grid {
    grid-template-columns: minmax(0, 1fr);
  }

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

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

/* Home-style alignment (Forethought-like) */
:root {
  --home-bg: #efefea;
  --home-surface: #f7f7f4;
  --home-line: #dfe2de;
  --home-line-strong: #d2d8d3;
  --home-ink: #2f2d2b;
  --home-muted: #5d615f;
  --home-accent: #2f3d53;
  --home-accent-hover: #263247;
}

body {
  background: var(--home-bg);
  color: var(--home-ink);
}

.wre-topbar {
  background: rgba(255, 255, 255, 0.95);
  border-bottom-color: #e6e8e2;
}

.wre-title,
.graph-card-head h2,
.gauge-card h2,
.explanation-card h2,
.lesson-card h2 {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Garamond, serif;
  font-weight: 500;
  color: var(--home-ink);
}

.wre-home-link {
  color: #4d5350;
}

.progress-card,
.graph-card,
.gauge-card,
.explanation-card,
.lesson-card,
.lesson-case,
.lesson-diagnostic,
.answer-summary,
.inspect-hover,
.inspect-list,
.edge-rank-item {
  background: var(--home-surface);
  border-color: var(--home-line);
  box-shadow: none;
}

#progressLabel,
#progressTitle,
.lesson-stage-label,
.label-lite,
.gauge-detail,
.empty-note {
  color: var(--home-muted);
}

#progressFill {
  background: linear-gradient(90deg, #6f7f95 0%, #2f3d53 100%);
}

.btn {
  border-radius: 8px;
  border-color: var(--home-line-strong);
  color: #4b5150;
  font-weight: 600;
}

.btn:hover {
  background: #f5f5f2;
}

.btn-primary {
  border-color: var(--home-accent);
  background: var(--home-accent);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--home-accent-hover);
}
