:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #262820;
  background: #f9f8f3;
  --paper: #f9f8f3;
  --ink: #262820;
  --muted: #55594f;
  --line: #d8d8cd;
  --tools: #efd8cb;
  --instructions: #e6e9f2;
  --context: #e2ead6;
  --mono: Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }
body { margin: 0; }
h1, h2, h3, p { margin: 0; }
button, input { font: inherit; }
[hidden] { display: none !important; }

:where(button, summary, a, input):focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 3px;
}

.frame {
  width: min(1440px, calc(100% - 2 * clamp(12px, 3.5vw, 52px)));
  margin-inline: auto;
}

.site-header { border-bottom: 1px solid var(--line); }

.wordmark {
  display: flex;
  min-height: 60px;
  align-items: center;
  gap: 9px;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-mark {
  width: 24px;
  height: 15px;
  border: 1.5px solid var(--ink);
  border-radius: 100% 100% 45% 45%;
  background: #ffbe6b;
  transform: rotate(-13deg);
  box-shadow: inset 0 -3px #e89753;
}

main.frame { padding-block: clamp(20px, 4vw, 44px) 32px; }
.intro { margin-bottom: clamp(17px, 2.4vw, 30px); }

.intro h1 {
  font-size: clamp(36px, 4.7vw, 62px);
  font-weight: 790;
  line-height: 1.02;
  letter-spacing: -0.06em;
}

.workspace {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: clamp(14px, 2.2vw, 30px);
}

.map-column {
  min-width: 0;
  container-type: inline-size;
}

.board {
  position: relative;
  display: grid;
  grid-template:
    "tools instructions" auto
    "agent agent" auto
    "context context" auto
    / minmax(0, 1fr) minmax(0, 1fr);
  align-items: start;
  gap: clamp(20px, 3.5cqw, 34px) clamp(14px, 6cqw, 84px);
  padding: clamp(23px, 4.3cqw, 45px) clamp(9px, 4.5cqw, 64px) clamp(24px, 4.3cqw, 45px);
  border: 1px solid var(--line);
  border-radius: 15px;
  background: radial-gradient(#d9dacd 0.8px, transparent 0.8px) center / 21px 21px;
}

.board-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.board-lines path {
  fill: none;
  stroke: #858875;
  stroke-width: 1.25;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.map-section {
  position: relative;
  min-width: 0;
}

.map-section h2 {
  margin-bottom: 13px;
  font-size: clamp(16px, 4.3cqw, 30px);
  line-height: 1.1;
  letter-spacing: -0.055em;
}

.tools-section {
  --entry-tone: var(--tools);
  grid-area: tools;
  justify-self: end;
}

.instructions-section {
  --entry-tone: var(--instructions);
  grid-area: instructions;
}

.context-section {
  --entry-tone: var(--context);
  grid-area: context;
  justify-self: center;
  width: min(100%, 565px);
}

.tools-section, .instructions-section { width: min(100%, 350px); }

.context-section h2 {
  width: fit-content;
  margin-inline: auto;
  text-align: center;
}

.entry-list {
  display: grid;
  gap: 7px;
}

.context-section .entry-list { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.context-section .entry-title { overflow-wrap: normal; }

.entry {
  display: grid;
  grid-template-columns: 31px minmax(0, 1fr);
  gap: 3px 9px;
  align-items: center;
  min-width: 0;
  min-height: 48px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fdfcf7;
  color: var(--ink);
  text-align: start;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.entry:hover, .entry[aria-current="true"] {
  border-color: #747668;
  background: var(--entry-tone, #eeeae1);
}

.entry[aria-current="true"] {
  border-color: var(--ink);
  transition: none;
}

.entry-title {
  font-size: clamp(13px, 2.3cqw, 16px);
  font-weight: 680;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.entry-filename {
  grid-column: 2;
  color: var(--muted);
  font: 11px ui-monospace, monospace;
  overflow-wrap: anywhere;
}

.entry-icon {
  position: relative;
  display: grid;
  grid-row: 1 / span 2;
  align-self: center;
  width: 31px;
  height: 31px;
  place-items: center;
  border-radius: 6px;
  background: var(--entry-tone, #eeeae1);
}

.entry:not(:has(.entry-filename)) .entry-icon { grid-row: 1; }

.entry-icon::before, .entry-icon::after { content: ""; }

.entry-icon::before {
  width: 11px;
  height: 11px;
  border: 1.5px solid currentColor;
}

.entry-icon::after { position: absolute; }

.icon-circle::before, .icon-search::before { border-radius: 50%; }

.icon-file::before, .icon-book::before, .icon-chat::before {
  width: 11px;
  height: 14px;
  border-radius: 2px;
}

.icon-file::after, .icon-book::after {
  width: 6px;
  border-top: 1px solid currentColor;
  box-shadow: 0 4px currentColor;
  translate: 0 -2px;
}

.icon-book::before { border-left-width: 3px; }

.icon-chat::before {
  width: 14px;
  height: 10px;
  border-radius: 4px;
}

.icon-chat::after {
  width: 4px;
  height: 3px;
  border-left: 1px solid currentColor;
  translate: -3px 7px;
}

.icon-search::before { translate: -2px -2px; }

.icon-search::after {
  width: 6px;
  border-top: 1.5px solid currentColor;
  rotate: 45deg;
  translate: 6px 6px;
}

.agent {
  grid-area: agent;
  justify-self: center;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 3px;
  width: clamp(91px, 21cqw, 155px);
  aspect-ratio: 1;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
}

.agent p {
  font-size: clamp(11px, 2.5cqw, 19px);
  font-weight: 790;
  letter-spacing: -0.04em;
}

.mascot {
  display: grid;
  width: 57%;
  aspect-ratio: 1.18;
  place-items: center;
  container-type: inline-size;
  filter: drop-shadow(0 4px #241a1318);
}

.mascot-body {
  display: grid;
  width: 100%;
  height: 95%;
  place-items: center;
  rotate: -9deg;
  border: 1px solid #b66a33;
  border-radius: 53% 47% 51% 49% / 62% 61% 39% 38%;
  background:
    radial-gradient(ellipse at 34% 29%, #fff3bd 0%, transparent 58%),
    linear-gradient(145deg, #ffcb71 29%, #f2a050 78%);
  box-shadow: inset 0 -5cqw #cc7136, inset 0 0 0 2cqw #fff4c062;
}

.mascot i {
  position: relative;
  width: 4cqw;
  height: 6cqw;
  margin-left: -17cqw;
  border-radius: 50%;
  background: #392b23;
  box-shadow: 17cqw 0 #392b23;
}

.mascot i::after {
  content: "";
  position: absolute;
  top: 8cqw;
  left: 8cqw;
  width: 5cqw;
  height: 3cqw;
  border-bottom: 1.5px solid #392b23;
  border-radius: 0 0 90% 90%;
}

#inspector {
  position: sticky;
  top: 14px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  max-height: calc(100dvh - 28px);
  min-height: 220px;
  border: 1px solid var(--line);
  border-radius: 15px;
  background: #fdfcf7;
  overflow: hidden;
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 20px clamp(14px, 2vw, 26px) 16px;
  border-bottom: 1px solid var(--line);
}

.inspector-header div { min-width: 0; }

.inspector-label {
  margin-bottom: 6px;
  color: var(--muted);
  font: 12px ui-monospace, monospace;
  overflow-wrap: anywhere;
}

.inspector-header h2 {
  outline: none;
  font-size: clamp(25px, 3.5vw, 38px);
  line-height: 1.08;
  letter-spacing: -0.055em;
  overflow-wrap: anywhere;
}

.close-button {
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--ink);
  font-size: 25px;
  cursor: pointer;
}

.close-button:hover { background: var(--line); }

.inspector-content {
  padding: 18px clamp(14px, 2vw, 26px) 23px;
  font-size: 15px;
  line-height: 1.5;
  overflow: auto;
  overscroll-behavior: contain;
}

.markdown-preview > * + * { margin-top: 12px; }
.markdown-preview h3, .related h3 { font-size: 17px; }

.markdown-preview ul, .markdown-preview blockquote {
  margin-inline: 0;
  margin-bottom: 0;
  padding-inline-start: 18px;
}

.markdown-preview blockquote {
  padding-block: 6px;
  border-inline-start: 3px solid #a6aa96;
  color: var(--muted);
}

.markdown-preview :not(pre) > code {
  padding-inline: 3px;
  border-radius: 4px;
  background: #ecebe2;
  overflow-wrap: anywhere;
}

#inspector-empty { color: var(--muted); }

.document-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 14px;
}

.document-modes {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.document-modes button {
  min-height: 36px;
  padding: 4px 8px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

.document-modes button[aria-pressed="true"] {
  border-color: var(--line);
  background: var(--instructions);
}

.file-link {
  color: var(--ink);
  font-size: 13px;
  font-weight: 650;
  text-underline-offset: 3px;
}

.markdown-file {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  font: 14px/1.65 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.markdown-file code { font: inherit; }

.source-view {
  margin-top: 16px;
  padding-block: 9px;
  border-block: 1px solid var(--line);
}

.source-view summary {
  font-weight: 680;
  cursor: pointer;
}

.source-view pre {
  margin: 9px 0 0;
  padding: 10px;
  border-radius: 6px;
  background: #edede5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 2;
}

.related {
  margin-top: 24px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.related h3 { margin-bottom: 8px; }

.tool-form {
  display: grid;
  grid-template-columns: minmax(75px, 1fr) auto auto;
  align-items: end;
  gap: 8px;
  margin-top: 16px;
}

.tool-form label {
  display: grid;
  min-width: 0;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.tool-form input {
  height: 44px;
  padding: 5px 8px;
  border: 1px solid #777a6e;
  border-radius: 6px;
  background: white;
  color: var(--ink);
}

.tool-form input[type="color"] { width: 44px; padding: 4px; }

.action-button {
  min-height: 44px;
  padding: 6px 11px;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: var(--ink);
  color: var(--paper);
  font-size: 13px;
  font-weight: 690;
  cursor: pointer;
}

.action-button:hover { background: #404537; }

.canvas {
  position: relative;
  margin-top: 14px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff radial-gradient(#d9dacd 0.7px, transparent 0.7px) center / 13px 13px;
}

.canvas svg { display: block; width: 100%; }

.canvas > p {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 14px;
  pointer-events: none;
}

.canvas-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.text-button {
  min-height: 40px;
  padding: 2px 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 650;
  text-decoration: underline;
  cursor: pointer;
}

.text-button:disabled {
  color: var(--muted);
  opacity: 0.65;
  cursor: default;
}

@container (max-width: 600px) {
  .context-section { width: min(72%, 272px); }
  .context-section .entry-list { grid-template-columns: 1fr; }
}

@container (max-width: 450px) {
  .map-section h2 { margin-bottom: 9px; }
  .map-section .entry { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding-block: 6px; }
  .map-section .entry-icon { display: none; }
  .context-section .entry { align-items: center; text-align: center; }
  .entry-filename { font-size: 10px; }
}

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

  #inspector {
    position: static;
    min-height: 0;
    max-height: none;
    scroll-margin-top: 12px;
  }
}

@media (max-height: 480px) {
  #inspector { position: static; max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .entry { transition: none; }
}
