:root {
  color-scheme: light;
  --bg: #f7f4ef;
  --panel: rgba(255, 252, 247, 0.86);
  --ink: #201b16;
  --muted: #70675e;
  --line: #ded5ca;
  --accent: #6f5b45;
  --accent-strong: #3d3024;
  --node: #f5d7a1;
  --node-stroke: #6f4f2a;
  --edge: #8a8178;
  --danger: #9f3a2f;
  --shadow: 0 22px 70px rgba(57, 45, 32, 0.11);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(245, 215, 161, 0.35), transparent 34rem),
    linear-gradient(135deg, #fbf8f2 0%, var(--bg) 52%, #eee7df 100%);
  color: var(--ink);
}

button, textarea { font: inherit; }

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 56px 0;
}

.hero { max-width: 760px; margin-bottom: 28px; }
.eyebrow {
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  margin: 0 0 12px;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 {
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 8vw, 6.8rem);
  font-weight: 400;
  letter-spacing: -0.07em;
  line-height: 0.86;
  margin-bottom: 18px;
}

h2 { font-size: 1rem; letter-spacing: -0.02em; margin-bottom: 8px; }
.lede { color: var(--muted); font-size: clamp(1.05rem, 2vw, 1.28rem); line-height: 1.6; }
p { color: var(--muted); line-height: 1.55; }
code {
  background: #efe6d8;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--accent-strong);
  padding: 0.12rem 0.38rem;
}

.panel {
  background: var(--panel);
  border: 1px solid rgba(222, 213, 202, 0.9);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.intro {
  display: grid;
  gap: 24px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 18px;
  padding: 24px;
}

.workspace { margin-bottom: 18px; padding: 24px; }
.input-head, .section-head, .actions {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}
.input-head p, .section-head p { margin-bottom: 0; }

textarea {
  background: #fffdf9;
  border: 1px solid var(--line);
  border-radius: 20px;
  color: var(--ink);
  display: block;
  line-height: 1.55;
  margin: 18px 0;
  min-height: 210px;
  outline: none;
  padding: 18px;
  resize: vertical;
  width: 100%;
}
textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(111, 91, 69, 0.12); }

button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 700;
  padding: 0.82rem 1.15rem;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}
button:hover { transform: translateY(-1px); }
button:disabled { cursor: not-allowed; opacity: 0.52; transform: none; }
#render-button { background: var(--accent-strong); color: #fffaf2; }
.secondary, .ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--accent-strong);
}
.ghost { white-space: nowrap; }
#status { color: var(--muted); margin: 0; min-height: 1.5em; }
#status.error { color: var(--danger); }

.grid {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1.7fr) minmax(280px, 0.8fr);
}
.graph-panel { min-height: 600px; padding: 24px; }
.graph {
  align-items: center;
  border: 1px dashed var(--line);
  border-radius: 22px;
  display: flex;
  justify-content: center;
  margin-top: 18px;
  min-height: 500px;
  overflow: hidden;
  position: relative;
}
.graph svg { height: 100%; min-height: 500px; width: 100%; }
.graph.empty p { color: var(--muted); }
.edge { stroke: var(--edge); stroke-linecap: round; stroke-opacity: 0.62; }
.node circle { fill: var(--node); stroke: var(--node-stroke); stroke-width: 1.6; }
.node text { fill: var(--accent-strong); font-size: 0.82rem; font-weight: 800; text-anchor: middle; dominant-baseline: middle; }
.node .label { fill: var(--muted); font-size: 0.72rem; font-weight: 600; transform: translateY(24px); }

.metrics { padding: 24px; }
dl { margin: 0; }
dl div {
  align-items: baseline;
  border-bottom: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 0;
}
dl div:last-child { border-bottom: 0; }
dt { color: var(--muted); }
dd { color: var(--ink); font-feature-settings: "tnum"; font-weight: 800; margin: 0; text-align: right; }

.sr-only {
  border: 0;
  clip: rect(0, 0, 0, 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  white-space: nowrap;
  width: 1px;
}

@media (max-width: 840px) {
  .intro, .grid { grid-template-columns: 1fr; }
  .input-head, .actions { align-items: flex-start; flex-direction: column; }
  .shell { padding: 32px 0; }
}
