:root {
  color-scheme: light;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  color: #25231f;
  background: #f6f4ef;
  --paper: #f6f4ef;
  --surface: #fffdf9;
  --ink: #25231f;
  --muted: #655e53;
  --line: #ded7cb;
  --accent: #9a4223;
  --selected: #fff0e5;
  --tools: #f3e5d8;
  --instructions: #eae7ee;
  --context: #e7ebdf;
  --mono: Menlo, Consolas, "DejaVu Sans Mono", monospace;
}

* { box-sizing: border-box; }
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  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(--accent);
  outline-offset: 3px;
}

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

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

.wordmark {
  display: flex;
  min-height: 52px;
  align-items: center;
  gap: 9px;
  font-size: 18px;
  font-weight: 760;
  letter-spacing: -0.025em;
}

.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, 3vw, 38px) 32px; }

.intro {
  margin-bottom: clamp(16px, 2.2vw, 26px);
}

.intro h1 {
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: clamp(27px, 3.35vw, 44px);
  font-weight: 740;
  line-height: 1.13;
  letter-spacing: -0.037em;
}

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

.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.2cqw, 30px) clamp(14px, 6cqw, 64px);
  padding: clamp(20px, 4.3cqw, 32px) clamp(11px, 4.5cqw, 36px) clamp(22px, 4.3cqw, 32px);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #f0ece4;
}

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

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

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

.map-section h2 {
  margin-bottom: 10px;
  color: #4d463c;
  font-size: clamp(14px, 3cqw, 19px);
  font-weight: 720;
  line-height: 1.22;
  letter-spacing: -0.017em;
}

.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; }

.context-section .entry-list:has(> .entry:only-child) {
  grid-template-columns: minmax(0, 1fr);
  width: min(100%, 248px);
  margin-inline: auto;
}

.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: 10px;
  background: var(--surface);
  color: var(--ink);
  text-align: start;
  cursor: pointer;
  transition: border-color 140ms ease, background-color 140ms ease;
}

.entry:hover {
  border-color: #ab9e8e;
  background: #faf7f0;
}

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

.entry-title {
  font-size: clamp(13px, 2.4cqw, 15px);
  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;
  justify-items: center;
  gap: 7px;
  max-width: 100%;
  text-align: center;
}

.agent-orb {
  display: grid;
  place-items: center;
  width: clamp(70px, 17cqw, 104px);
  aspect-ratio: 1;
  border: 1px solid #d8cab5;
  border-radius: 50%;
  background: #fffbf3;
}

#agent-name {
  max-width: min(100%, 272px);
  padding: 3px 10px 4px;
  border-radius: 7px;
  background: #f0ece4;
  font-size: clamp(13px, 2.9cqw, 18px);
  font-weight: 730;
  line-height: 1.25;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
  text-wrap: balance;
}

.mascot {
  display: grid;
  width: 64%;
  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: 16px;
  background: var(--surface);
  overflow: hidden;
}

.inspector-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  padding: 18px clamp(14px, 2vw, 24px) 15px;
  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(22px, 2.6vw, 31px);
  line-height: 1.17;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
}

.close-button {
  flex: 0 0 38px;
  width: 38px;
  height: 38px;
  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(--selected);
  color: var(--accent);
}

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

#agent-trace { color: var(--accent); }

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

.markdown-file code { font: inherit; }

#mcp-tools {
  margin: 0;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

#mcp-tools dd { margin: 4px 0 0; }
#mcp-tools dd + dt { margin-top: 12px; }
#mcp-tools details { margin-top: 8px; }

#catalog-changes {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
}

#catalog-changes summary, #mcp-tools summary { cursor: pointer; }
#catalog-changes ul { margin-bottom: 0; }
.viewer-version {
  margin-top: auto;
  padding-bottom: 12px;
  text-align: right;
  color: var(--muted);
  font-size: 13px;
}

.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: 9px;
  color: var(--muted);
  font-size: 14px;
}

.related .entry-list {
  display: flex;
  flex-wrap: wrap;
}

.related .entry {
  display: inline-flex;
  flex-wrap: wrap;
  min-height: 39px;
  gap: 6px;
  padding: 5px 9px;
}

.related .entry-icon {
  width: 24px;
  height: 24px;
}

.related .entry-title { font-size: 13px; }

.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; }
}

.agent-choice {
  min-inline-size: 0;
  margin: 16px 0 0;
  padding: 0;
  border: 0;
}

.agent-choice legend {
  margin-bottom: 9px;
  padding: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 680;
}

.agent-list {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.agent-option {
  position: relative;
  display: grid;
  min-width: 0;
  max-width: 100%;
}

.agent-option input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.agent-option-card {
  display: flex;
  min-height: 43px;
  align-items: center;
  gap: 7px;
  padding: 4px 12px 4px 7px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13px;
  font-weight: 660;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.agent-option:hover .agent-option-card { border-color: #ab9e8e; }

.agent-option input:checked + .agent-option-card {
  border-color: #bd7755;
  background: var(--selected);
  color: var(--accent);
}

.agent-option input:focus-visible + .agent-option-card {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.cheburek-portrait {
  display: block;
  flex: 0 0 auto;
  width: 30px;
  height: auto;
}

.agent-orb .cheburek-portrait { width: 82%; }

@media (max-width: 520px) {
  .agent-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .agent-option-card {
    gap: 4px;
    padding-inline: 5px;
    font-size: 12px;
  }

  .agent-option-card .cheburek-portrait { width: 22px; }
}

.empty-group, #catalog-status {
  color: var(--muted);
  font-size: 14px;
}

.embed .site-header { display: none; }
.embed main.frame { padding-block: 12px; }
.embed .intro h1 { font-size: clamp(22px, 3vw, 38px); }
