:root {
  --bg: #f1eadc;
  --ink: #1f1a17;
  --panel: #f8f4ec;
  --accent: #7c4a21;
  --accent-soft: #c9a468;
  --border: #d6c8b2;
  --shadow: rgba(32, 24, 18, 0.18);
  --muted: #6e5b4f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Georgia", "Times New Roman", serif;
  color: var(--ink);
  background: radial-gradient(circle at 20% 10%, #f7f0e2 0%, #efe4d0 40%, #e3d2b4 100%);
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.page {
  padding: 32px 24px 64px;
}

.topbar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 16px 24px;
  background: rgba(248, 244, 236, 0.85);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: 0 8px 18px var(--shadow);
}

.crumbs {
  font-size: 14px;
  color: var(--muted);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.search {
  display: flex;
  gap: 8px;
}

.search input {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  min-width: 220px;
  background: #fffdf8;
}

.search button {
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
}

.panel {
  margin-top: 28px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 22px;
  box-shadow: 0 18px 30px var(--shadow);
  padding: 24px 28px 32px;
}

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

.panel-header h1 {
  margin: 0;
  font-size: 30px;
  letter-spacing: 1px;
  color: var(--accent);
}

.panel-actions {
  display: flex;
  gap: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-size: 14px;
}

.btn.back {
  background: var(--accent);
  color: #fff;
}

.btn.back.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.layout {
  display: grid;
  grid-template-columns: minmax(190px, 240px) 1fr;
  gap: 28px;
  margin-top: 24px;
}

.toc {
  background: #fff8ee;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  position: sticky;
  top: 24px;
  height: fit-content;
}

.toc h2 {
  margin-top: 0;
  font-size: 18px;
  color: var(--accent);
}

.toc ul {
  padding-left: 18px;
  margin: 0;
}

.content {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.doc-section {
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  background: #fffdf7;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.6);
}

.doc-section.is-highlight {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(124, 74, 33, 0.25);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.section-header h2 {
  margin: 0;
  font-size: 22px;
}

.section-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.anchor-link {
  font-weight: bold;
  color: var(--muted);
}

.edit-toggle,
.edit-actions button {
  border-radius: 10px;
  border: 1px solid var(--border);
  background: #f3e5cf;
  color: var(--ink);
  cursor: pointer;
  padding: 6px 10px;
}

.edit-disabled {
  font-size: 13px;
  color: var(--muted);
}

.doc-body pre {
  margin: 12px 0 0;
  white-space: pre-wrap;
  font-family: "Georgia", "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.5;
}

.edit-form {
  display: none;
  margin-top: 12px;
}

.doc-section.is-editing .edit-form {
  display: block;
}

.doc-section.is-editing .doc-body {
  display: none;
}

.edit-form textarea {
  width: 100%;
  min-height: 240px;
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 12px;
  font-family: "Courier New", monospace;
  font-size: 14px;
}

.edit-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.resources {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-top: 28px;
}

.resource-block {
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  background: #fffdf7;
}

.resource-block h2 {
  margin-top: 0;
  color: var(--accent);
  font-size: 18px;
}

.gallery {
  margin-top: 28px;
}

.gallery h2 {
  color: var(--accent);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.gallery-item {
  margin: 0;
  background: #fff8ee;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px;
  text-align: center;
}

.gallery-item img {
  width: 100%;
  height: auto;
  border-radius: 10px;
}

.search-results {
  margin-top: 18px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  padding: 12px 16px;
  background: #fff7ea;
}

.empty {
  color: var(--muted);
  font-style: italic;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .toc {
    position: static;
  }

  .search input {
    min-width: 160px;
  }
}
