:root {
  --bg: #f7f5ef;
  --surface: #fffdf8;
  --surface-strong: #f0eadf;
  --text: #1f2933;
  --muted: #667085;
  --line: #ded6c9;
  --accent: #2f6f73;
  --accent-strong: #225357;
  --accent-soft: #e1f0ef;
  --shadow: 0 18px 50px rgba(48, 58, 64, 0.1);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.6;
}

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

button,
textarea,
input {
  font: inherit;
}

button,
.button,
.file-button {
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  font-weight: 700;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

button:hover,
.button:hover,
.file-button:hover {
  transform: translateY(-1px);
}

.hero {
  min-height: 78vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(47, 111, 115, 0.14), transparent 30%),
    linear-gradient(135deg, #fffdf8 0%, #f5efe3 58%, #e7f0ef 100%);
  border-bottom: 1px solid var(--line);
}

.topbar {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand {
  font-weight: 900;
  letter-spacing: 0;
  color: var(--accent-strong);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-size: 0.95rem;
}

.nav-links a:hover {
  color: var(--accent-strong);
}

.hero-content {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 92px 0 120px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
h3 {
  line-height: 1.1;
  margin: 0;
}

h1 {
  max-width: 760px;
  font-size: clamp(2.45rem, 6vw, 5.4rem);
  letter-spacing: 0;
}

h2 {
  font-size: clamp(2rem, 4vw, 3.45rem);
}

h3 {
  font-size: 1.05rem;
}

.hero-copy {
  max-width: 680px;
  margin: 22px 0 0;
  color: var(--muted);
  font-size: 1.12rem;
}

.hero-actions,
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.button,
.file-button,
button {
  min-height: 42px;
  padding: 0 16px;
  background: var(--accent);
  color: white;
}

.button.primary,
button:not(.ghost) {
  box-shadow: 0 10px 24px rgba(47, 111, 115, 0.2);
}

.button.secondary,
.ghost {
  background: #ffffff;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  box-shadow: none;
}

.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.88rem;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.section {
  padding: 88px 0;
}

.viewer-section,
.tree-section {
  background: var(--surface);
}

.editor-section {
  background: #eef4f1;
}

.wiki-section {
  background: var(--bg);
}

.section-heading,
.viewer-grid,
.editor-grid,
.tree-layout,
.wiki-grid {
  width: min(1120px, calc(100% - 32px));
  margin-left: auto;
  margin-right: auto;
}

.section-heading {
  margin-bottom: 32px;
}

.section-heading p:last-child {
  max-width: 720px;
  margin: 12px 0 0;
  color: var(--muted);
}

.viewer-grid,
.editor-grid,
.tree-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: stretch;
}

.panel {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-width: 0;
  overflow: hidden;
}

.editor-section .panel {
  background: #fffdf8;
}

.panel-header {
  min-height: 58px;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 0.82rem;
  font-weight: 800;
}

textarea {
  flex: 1;
  width: 100%;
  min-height: 430px;
  padding: 18px;
  resize: none;
  border: 0;
  outline: 0;
  background: #fffaf0;
  color: var(--text);
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 0.96rem;
  line-height: 1.65;
}

.input-panel .panel-actions {
  padding: 0 16px 16px;
  margin-top: 0;
  background: #fffaf0;
}

.markdown-preview {
  flex: 1;
  min-height: 430px;
  padding: 18px;
  overflow: auto;
}

.markdown-preview > :first-child {
  margin-top: 0;
}

.markdown-preview h1,
.markdown-preview h2,
.markdown-preview h3,
.markdown-preview h4,
.markdown-preview h5,
.markdown-preview h6 {
  margin: 1.2rem 0 0.65rem;
}

.markdown-preview p,
.markdown-preview ul,
.markdown-preview ol,
.markdown-preview blockquote,
.markdown-preview pre,
.markdown-preview table {
  margin: 0 0 1rem;
}

.markdown-preview code,
.wiki-card code {
  border-radius: 6px;
  background: #efe7d8;
  padding: 0.12rem 0.36rem;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

.markdown-preview pre,
.wiki-card pre,
#treeOutput {
  overflow: auto;
  border-radius: 8px;
  background: #263238;
  color: #f6f3ea;
  padding: 16px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  line-height: 1.6;
}

.markdown-preview pre code {
  background: transparent;
  padding: 0;
}

.markdown-preview blockquote {
  border-left: 4px solid var(--accent);
  padding: 0.1rem 0 0.1rem 1rem;
  color: var(--muted);
}

.markdown-preview table {
  width: 100%;
  border-collapse: collapse;
}

.markdown-preview th,
.markdown-preview td {
  border: 1px solid var(--line);
  padding: 0.7rem;
  text-align: left;
  vertical-align: top;
}

.markdown-preview th {
  background: var(--surface-strong);
}

.toolbar {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.toolbar button {
  background: #fffdf8;
  color: var(--accent-strong);
  border: 1px solid var(--line);
  box-shadow: none;
}

.tree-panel pre {
  min-height: 430px;
  margin: 0;
  border-radius: 0;
  background: #fffdf8;
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.75;
}

.tree-panel textarea {
  min-height: 430px;
}

.wiki-card pre code {
  display: block;
  padding: 0;
  background: transparent;
  color: #f6f3ea;
  white-space: pre-wrap;
}

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

.wiki-card {
  min-width: 0;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(48, 58, 64, 0.07);
}

.wiki-card p {
  color: var(--muted);
}

.wiki-card pre {
  margin: 12px 0 0;
  white-space: pre-wrap;
}

footer {
  padding: 28px 16px;
  text-align: center;
  background: #fffdf8;
  border-top: 1px solid var(--line);
  color: var(--muted);
}

@media (max-width: 820px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .nav-links {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .hero-content {
    padding: 72px 0 88px;
  }

  .section {
    padding: 64px 0;
  }

  .viewer-grid,
  .editor-grid,
  .tree-layout,
  .wiki-grid {
    grid-template-columns: 1fr;
  }

  textarea,
  .markdown-preview {
    min-height: 330px;
  }
}
