:root {
  --bg: #f7f2e8;
  --panel: #ffffff;
  --panel-soft: rgba(255, 255, 255, 0.86);
  --text: #16323a;
  --muted: #5d7279;
  --line: #dbe5e3;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --accent: #dd6b20;
  --success: #16784c;
  --danger: #b94f3b;
  --shadow: 0 20px 60px rgba(22, 50, 58, 0.1);
  --radius-lg: 22px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --container: min(1160px, calc(100vw - 2rem));
}

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

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: "Instrument Sans", sans-serif;
  color: var(--text);
  overflow-x: hidden;
  background:
    radial-gradient(circle at top left, rgba(15, 118, 110, 0.14), transparent 28%),
    radial-gradient(circle at top right, rgba(221, 107, 32, 0.14), transparent 22%),
    linear-gradient(180deg, #faf6ee 0%, #f6f0e4 100%);
  line-height: 1.6;
}

img {
  display: block;
  max-width: 100%;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(15, 118, 110, 0.25);
  outline-offset: 3px;
}

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

.skip-link:focus {
  width: auto;
  height: auto;
  margin: 1rem;
  padding: 0.75rem 1rem;
  clip: auto;
  z-index: 20;
  background: var(--panel);
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.container {
  width: var(--container);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(247, 242, 232, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(22, 50, 58, 0.08);
}

.header-inner {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-copy {
  display: grid;
  gap: 0.1rem;
}

.brand-copy strong,
h1,
h2,
h3,
summary,
.view-tab,
.tool-button {
  font-family: "Space Grotesk", sans-serif;
  letter-spacing: -0.03em;
}

.brand-copy strong {
  font-size: 1rem;
}

.brand-copy span:last-child {
  color: var(--muted);
  font-size: 0.88rem;
}

.site-nav {
  display: inline-flex;
  justify-content: center;
  gap: 1.25rem;
  flex-wrap: wrap;
}

.site-nav a {
  color: var(--muted);
  font-weight: 600;
}

.site-nav a:hover,
.text-link:hover {
  color: var(--primary-dark);
}

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 14px;
  padding: 0.65rem;
}

.nav-toggle span {
  display: block;
  width: 100%;
  height: 2px;
  margin: 4px 0;
  background: var(--text);
  border-radius: 999px;
}

.workspace-section,
.content-section {
  padding: 2rem 0;
}

h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(2.6rem, 7vw, 4.6rem);
  line-height: 0.95;
}

h2 {
  margin: 0 0 0.8rem;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  line-height: 1.05;
}

h3 {
  margin: 0 0 0.65rem;
  font-size: 1.2rem;
}

.intro-copy,
.content-section p,
.faq-list p,
.footer-copy,
.local-note,
.tree-stats {
  color: var(--muted);
}

.benefit-list,
.content-list,
.footer-links {
  margin: 0;
  padding-left: 1.15rem;
}

.benefit-list li,
.content-list li,
.footer-links li {
  margin: 0.45rem 0;
}

.panel,
.feature-card,
.faq-list details,
.site-footer,
.example-block {
  background: var(--panel-soft);
  border: 1px solid rgba(22, 50, 58, 0.1);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
  overflow: hidden;
}

.status-tags,
.split-grid,
.feature-grid,
.footer-grid,
.graph-root {
  display: grid;
  gap: 1rem;
}

.workspace-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px minmax(0, 1fr);
  gap: 0;
  height: 74vh;
  min-height: 720px;
  max-height: 860px;
  border: 10px solid #21b9a5;
  background: #21b9a5;
  box-shadow: var(--shadow);
  overflow: hidden;
}

.code-pane {
  display: grid;
  grid-template-rows: 36px minmax(0, 1fr) 24px;
  height: 100%;
  min-width: 0;
  min-height: 0;
  background: #fff;
  border-inline: 1px solid rgba(0, 0, 0, 0.06);
}

.control-column {
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: start;
  gap: 1.25rem;
  padding: 0.5rem 1rem 1rem;
  background: #21b9a5;
  min-height: 0;
  overflow-y: auto;
}

.control-stack {
  display: grid;
  gap: 0.9rem;
}

.control-stack-bottom {
  align-self: end;
}

.center-button,
.center-select,
.center-link {
  width: 100%;
  min-height: 36px;
  padding: 0.45rem 0.85rem;
  border: 2px solid rgba(255, 255, 255, 0.9);
  border-radius: 2px;
  background: transparent;
  color: #fff;
  font-family: "Instrument Sans", sans-serif;
  font-size: 0.98rem;
  font-weight: 700;
}

.center-select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, #51616d 50%) calc(100% - 18px) calc(50% - 2px) / 7px 7px no-repeat,
    linear-gradient(135deg, #51616d 50%, transparent 50%) calc(100% - 13px) calc(50% - 2px) / 7px 7px no-repeat,
    #fff;
  color: #324552;
  border-color: #e9efee;
  font-weight: 500;
}

.center-link {
  border: 0;
  min-height: auto;
  padding-block: 0.2rem;
  text-align: center;
}

.control-column-meta {
  display: grid;
  align-content: start;
  gap: 0.75rem;
  padding-top: 0.25rem;
}

.control-column-meta p {
  margin: 0;
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
  font-size: 0.92rem;
}

.status-tags {
  grid-template-columns: 1fr;
  gap: 0.5rem;
}

.status-tags span {
  padding: 0.35rem 0.5rem;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.95);
  font-size: 0.84rem;
  text-align: center;
}

.editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  padding: 0 0.5rem;
  background: #2f4054;
  color: #fff;
}

.editor-icons,
.editor-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex-shrink: 0;
}

.editor-icons span {
  width: 12px;
  height: 2px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 0 rgba(255, 255, 255, 0.35);
}

.editor-toolbar-label {
  color: rgba(255, 255, 255, 0.92);
  font-size: 0.96rem;
  flex: 1;
  min-width: 0;
  text-align: center;
}

.icon-button {
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 0.95rem;
  line-height: 1;
  padding: 0.1rem;
}

.icon-button svg {
  display: block;
  width: 15px;
  height: 15px;
}

.editor-surface {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  min-height: 0;
  height: 100%;
  overflow: hidden;
  background:
    linear-gradient(180deg, #fff8c6 0, #fff8c6 20px, #ffffff 20px, #ffffff 100%);
}

.line-numbers {
  padding: 2px 0.55rem;
  background: #ebebeb;
  color: #49596b;
  font-family: "SFMono-Regular", Consolas, monospace;
  font-size: 0.9rem;
  line-height: 1.7;
  text-align: right;
  user-select: none;
  white-space: pre;
  overflow: hidden;
}

textarea,
pre,
.tree-root,
.graph-root {
  min-height: 0;
  min-width: 0;
  margin: 0;
  padding: 2px 0.75rem 0.75rem;
  border: 0;
  background: transparent;
  color: #1a2e3e;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.93rem;
  line-height: 1.7;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
  scrollbar-gutter: stable;
}

textarea {
  width: 100%;
  height: 100%;
  resize: none;
  outline: 0;
  overflow-x: scroll;
  overflow-y: scroll;
}

pre,
.tree-root,
.graph-root {
  height: 100%;
  overflow-x: scroll;
  overflow-y: scroll;
}

textarea::-webkit-scrollbar,
pre::-webkit-scrollbar,
.tree-root::-webkit-scrollbar,
.graph-root::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

textarea::-webkit-scrollbar-track,
pre::-webkit-scrollbar-track,
.tree-root::-webkit-scrollbar-track,
.graph-root::-webkit-scrollbar-track {
  background: #ececec;
}

textarea::-webkit-scrollbar-thumb,
pre::-webkit-scrollbar-thumb,
.tree-root::-webkit-scrollbar-thumb,
.graph-root::-webkit-scrollbar-thumb {
  background: #9aa8b4;
  border: 2px solid #ececec;
  border-radius: 999px;
}

.view-select {
  min-width: 88px;
  max-width: 100%;
  padding: 0 1rem 0 0.35rem;
  border: 0;
  background: transparent;
  color: #fff;
  font-size: 0.96rem;
  text-align: center;
  text-align-last: center;
  color-scheme: light;
}

.view-select option,
.center-select option {
  color: #16323a;
  background: #ffffff;
}

.view-select:focus,
.view-select:active {
  background: #ffffff;
  color: #16323a;
}

.viewer-body {
  min-height: 0;
  height: 100%;
  background:
    linear-gradient(180deg, #fff8c6 0, #fff8c6 20px, #ffffff 20px, #ffffff 100%);
}

.tree-entry {
  margin: 0.35rem 0;
}

.tree-entry summary {
  cursor: pointer;
  list-style: none;
  color: var(--primary-dark);
}

.tree-entry summary::-webkit-details-marker {
  display: none;
}

.tree-node {
  margin-left: 1rem;
  padding-left: 0.85rem;
  border-left: 1px dashed rgba(22, 50, 58, 0.16);
}

.tree-key {
  color: var(--accent);
  font-weight: 700;
}

.tree-type {
  color: var(--muted);
  font-size: 0.88rem;
}

.tree-value {
  color: var(--text);
}

.tree-value-image {
  text-decoration: underline;
  text-decoration-style: dotted;
  cursor: pointer;
}

.graph-root {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
}

.graph-card {
  padding: 1rem;
  border: 1px solid rgba(22, 50, 58, 0.08);
  border-radius: var(--radius-md);
  background: #fff;
}

.graph-card strong {
  display: block;
  font-size: 1.7rem;
  line-height: 1;
  margin-top: 0.25rem;
}

.graph-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

.graph-bars {
  grid-column: 1 / -1;
  padding: 1rem;
  border: 1px solid rgba(22, 50, 58, 0.08);
  border-radius: var(--radius-md);
  background: #fff;
}

.bar-row {
  display: grid;
  grid-template-columns: 110px 1fr 48px;
  gap: 0.75rem;
  align-items: center;
  margin: 0.65rem 0;
}

.bar-track {
  height: 10px;
  border-radius: 999px;
  background: #edf3f2;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(135deg, var(--primary), var(--accent));
}

.image-hover-preview {
  position: fixed;
  z-index: 40;
  width: 220px;
  padding: 0.5rem;
  border-radius: 18px;
  border: 1px solid rgba(22, 50, 58, 0.12);
  background: #fff;
  box-shadow: var(--shadow);
  pointer-events: none;
}

.editor-status {
  display: flex;
  gap: 1rem;
  align-items: center;
  padding: 0 0.6rem;
  background: #f1f1f1;
  color: #6a7784;
  font-size: 0.82rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
}

.view-panel {
  display: none;
  height: 100%;
  min-height: 0;
}

.view-panel.is-active {
  display: block;
  height: 100%;
  min-height: 0;
}

.image-hover-preview img {
  width: 100%;
  height: auto;
  border-radius: 12px;
}

.split-grid,
.footer-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.feature-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.feature-card {
  padding: 1.2rem;
}

.section-intro {
  max-width: 860px;
  margin-bottom: 1.25rem;
}

.section-intro p {
  margin: 0.4rem 0 0;
  color: var(--muted);
}

.mini-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin: 0.8rem 0 0;
  padding: 0;
  list-style: none;
}

.mini-badges li {
  padding: 0.3rem 0.6rem;
  border-radius: 999px;
  background: rgba(15, 118, 110, 0.09);
  color: var(--primary-dark);
  font-size: 0.86rem;
  font-weight: 700;
}

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

.tool-card {
  padding: 1.2rem;
  border: 1px solid rgba(22, 50, 58, 0.1);
  border-radius: var(--radius-lg);
  background: var(--panel-soft);
  box-shadow: var(--shadow);
}

.tool-card p {
  margin: 0 0 0.9rem;
  color: var(--muted);
}

.tool-card a {
  color: var(--primary-dark);
  font-weight: 700;
}

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

.example-block {
  padding: 1rem;
  overflow: auto;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.93rem;
  line-height: 1.65;
}

.alternate {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.28), rgba(255, 255, 255, 0.12));
}

.narrow {
  max-width: 780px;
}

.faq-list {
  display: grid;
  gap: 1rem;
}

.faq-list details {
  padding: 1rem 1.1rem;
}

.faq-list summary {
  font-size: 1.1rem;
}

.site-footer {
  margin: 2rem auto 1rem;
}

.footer-grid {
  padding: 2rem 0;
}

.footer-links {
  list-style: none;
  padding-left: 0;
}

.footer-links a {
  color: var(--muted);
}

.footer-links a:hover {
  color: var(--primary-dark);
}

.footer-bottom {
  padding: 1rem 0 1.4rem;
  border-top: 1px solid rgba(22, 50, 58, 0.08);
}

.footer-bottom p {
  margin: 0;
  color: var(--muted);
}

.is-valid {
  color: var(--success) !important;
}

.is-error {
  color: var(--danger) !important;
}

@media (max-width: 1120px) {
  .workspace-shell,
  .tools-grid,
  .content-grid-2,
  .feature-grid,
  .split-grid,
  .footer-grid {
    grid-template-columns: 1fr;
  }

  .workspace-shell {
    gap: 1rem;
    height: auto;
    min-height: auto;
    max-height: none;
    border-width: 8px;
  }

  .control-column {
    order: 2;
    grid-template-rows: auto;
    padding: 1rem;
  }

  .control-stack,
  .control-column-meta {
    width: 100%;
    max-width: 520px;
    justify-self: center;
  }

  .control-column-meta {
    order: 3;
  }

  .code-pane {
    min-height: 54vh;
    height: auto;
  }
}

@media (max-width: 1024px) {
  .site-header {
    position: static;
  }

  .header-inner {
    grid-template-columns: auto auto;
  }

  .nav-toggle {
    display: inline-block;
    justify-self: end;
  }

  .site-nav {
    display: none;
    grid-column: 1 / -1;
    justify-content: start;
    gap: 0.75rem;
    padding-top: 0.8rem;
  }

  .site-nav.is-open {
    display: grid;
  }

  .code-pane {
    min-height: 52vh;
  }
}

@media (max-width: 640px) {
  :root {
    --container: min(100vw - 1rem, 100%);
  }

  .workspace-shell {
    grid-template-columns: 1fr;
    width: min(100%, 360px);
    margin-inline: auto;
    gap: 0;
    border-width: 6px;
  }

  .input-pane {
    order: 1;
  }

  .control-column {
    order: 2;
  }

  .output-pane {
    order: 3;
  }

  .workspace-section,
  .content-section {
    padding: 1.25rem 0;
  }

  .graph-root {
    grid-template-columns: 1fr;
  }

  .bar-row {
    grid-template-columns: 90px 1fr 36px;
  }

  .control-column {
    gap: 0.7rem;
    padding: 0.7rem 0.65rem 0.85rem;
  }

  .center-button,
  .center-select {
    min-height: 42px;
    font-size: 0.92rem;
  }

  .code-pane {
    grid-template-rows: 34px minmax(0, 1fr) 24px;
    min-height: 460px;
    border-inline: 0;
  }

  .editor-toolbar {
    padding: 0 0.4rem;
  }

  .editor-toolbar-label,
  .view-select {
    font-size: 0.88rem;
  }

  .editor-icons,
  .editor-actions {
    gap: 0.35rem;
  }

  .editor-icons span {
    width: 10px;
  }

  .editor-surface {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .input-pane .editor-surface,
  .output-pane .editor-surface {
    min-height: 400px;
  }

  .line-numbers {
    padding: 2px 0.35rem;
    font-size: 0.8rem;
  }

  textarea,
  pre,
  .tree-root,
  .graph-root {
    padding: 2px 0.55rem 0.6rem;
    font-size: 0.84rem;
  }

  .status-tags span {
    font-size: 0.8rem;
  }

  .control-stack,
  .control-column-meta {
    width: 100%;
    max-width: none;
  }

  .control-stack {
    gap: 0.65rem;
  }

  .feature-card,
  .tool-card,
  .faq-list details,
  .example-block {
    padding: 1rem;
  }
}
