main.container:has(.wiki-page) {
  width: min(1640px, calc(100vw - 1.5rem));
  max-width: none;
  padding-bottom: 0.5rem;
}

.wiki-overline {
  margin: 0 0 0.45rem;
  color: #e59a5f;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.wiki-page {
  width: 100%;
}

.wiki-page .wiki-workspace {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr);
  height: calc(100dvh - 116px);
  min-height: 560px;
  margin: 0;
  padding: 0;
  border-color: rgba(255, 255, 255, 0.08);
  background: #14171c;
  overflow: hidden;
}

.wiki-sidebar {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.15rem 0.85rem 0.85rem;
  border-right: 1px solid rgba(255, 255, 255, 0.075);
  background: linear-gradient(180deg, #1b1f25, #171a1f 70%);
}

.wiki-sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 0.3rem 0.55rem;
}

.wiki-sidebar-head h2 {
  margin: 0;
  font-size: 0.9rem;
}

.wiki-sidebar-head .wiki-overline {
  display: block;
  margin-bottom: 0.1rem;
  color: #888d95;
  font-size: 0.55rem;
}

.wiki-icon-button {
  display: grid;
  width: 1.65rem;
  height: 1.65rem;
  place-items: center;
  padding: 0;
  border: 1px solid rgba(217, 108, 29, 0.35);
  border-radius: 0.65rem;
  background: rgba(217, 108, 29, 0.1);
  color: #f2a46c;
  font-size: 1.05rem;
  line-height: 1;
}

.wiki-icon-button:hover,
.wiki-add-child:hover {
  border-color: rgba(217, 108, 29, 0.65);
  background: rgba(217, 108, 29, 0.16);
}

.wiki-add-child,
.wiki-quiet-button {
  width: auto;
  margin: 0;
  padding: 0.48rem 0.65rem;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 0.55rem;
  background: rgba(255, 255, 255, 0.025);
  color: #c8c5c0;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.3;
  box-shadow: none;
}

.wiki-actions { display: flex; align-items: center; justify-content: flex-end; gap: 0.45rem; flex-wrap: wrap; }
.wiki-language-link { padding: .28rem .42rem; border-radius: .35rem; color: #9298a0; font-size: .72rem; font-weight: 700; text-decoration: none; }
.wiki-language-link[aria-current="page"] { background: rgba(217,108,29,.15); color: #f2b17e; }
.wiki-actions .wiki-quiet-button,
.wiki-actions .wiki-submit-button { width: auto; margin: 0; text-decoration: none; cursor: pointer; }
.wiki-reader { flex: 1; }
.wiki-article-body { counter-reset: wiki-section; }
.wiki-article-body h2 { counter-increment: wiki-section; counter-reset: wiki-subsection; }
.wiki-article-body h2::before { content: counter(wiki-section) ". "; color: #dc8a52; }
.wiki-article-body h3 { counter-increment: wiki-subsection; }
.wiki-article-body h3::before { content: counter(wiki-section) "." counter(wiki-subsection) ". "; color: #dc8a52; }
.wiki-submit-button {
  width: auto; margin: 0; padding: 0.48rem 0.8rem; border: 1px solid rgba(217,108,29,.42);
  border-radius: .55rem; background: #9a4d1d; color: #fff3e8; font-size: .75rem; font-weight: 700;
}
.wiki-submit-button:hover { background: #b35b23; }
.wiki-submit-button:disabled { opacity: .55; cursor: wait; }
.wiki-fallback-notice { margin: .65rem 0 0; padding: .55rem .75rem; border-left: 2px solid #c66c30; background: rgba(217,108,29,.06); color: #d9a476; font-size: .76rem; }
.wiki-comments { margin-top: 2.3rem; padding-top: 1.1rem; border-top: 1px solid rgba(255,255,255,.09); }
.wiki-comments h2 { margin: 0 0 .8rem; font-size: 1.1rem; }
.wiki-comment { position: relative; margin: 0 0 .7rem; padding: .75rem .85rem; border: 1px solid rgba(255,255,255,.075); border-radius: .55rem; background: rgba(255,255,255,.018); }
.wiki-comment p { margin: .45rem 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.wiki-comment-meta { display: flex; align-items: baseline; gap: .7rem; color: #a6aab0; font-size: .73rem; }
.wiki-comment-meta strong { color: #dedbd6; }
.wiki-comment-meta time { color: #747a82; }
.wiki-comment-delete { width: auto; margin: .4rem 0 0; padding: .2rem .35rem; border: 0; background: transparent; color: #a08078; font-size: .68rem; box-shadow: none; }
.wiki-comment-form { margin-top: 1rem; }
.wiki-comment-form textarea { margin-bottom: .55rem; background: #111418; }
.wiki-comment-form .wiki-actions { justify-content: space-between; color: #9298a0; font-size: .73rem; }
.wiki-comments-login, .wiki-comments-empty { color: #9298a0; font-size: .8rem; }
.wiki-comments-login a { color: #f0a16b; }

.wiki-add-child {
  width: 100%;
  margin-bottom: 0.6rem;
  padding: 0.36rem 0.5rem;
  border-style: dashed;
  font-size: 0.66rem;
  text-align: left;
}

.wiki-tree {
  flex: 1;
  min-height: 0;
  overflow: auto;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
  scrollbar-width: thin;
}

.wiki-tree-list {
  display: grid;
  gap: 0.06rem;
}

.wiki-tree-row {
  display: flex;
  align-items: center;
  min-width: 0;
}

.wiki-tree-row.is-dragging { opacity: .45; }
.wiki-tree-row.is-drop-target > .wiki-tree-link { outline: 1px solid rgba(240, 161, 107, .8); }
.wiki-tree-hint { margin: .5rem 0 0; color: #777e87; font-size: .62rem; line-height: 1.4; }

.wiki-tree-toggle,
.wiki-tree-toggle-spacer {
  display: grid;
  flex: 0 0 1.15rem;
  width: 1.15rem;
  height: 1.55rem;
  place-items: center;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0.3rem;
  background: transparent;
  color: #858b93;
  font-size: 0.85rem;
  line-height: 1;
  box-shadow: none;
}

.wiki-tree-toggle:hover {
  background: rgba(255, 255, 255, 0.06);
  color: #f0a16b;
}

.wiki-tree-children {
  margin-left: 0.52rem;
  padding-left: 0.23rem;
  border-left: 1px solid rgba(255, 255, 255, 0.07);
}

.wiki-tree-children .wiki-tree-list {
  padding-top: 0.04rem;
}

.wiki-tree-link {
  display: block;
  flex: 1;
  min-width: 0;
  width: auto;
  margin: 0;
  padding: 0.28rem 0.38rem;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: #adb1b8;
  font-size: 0.68rem;
  font-weight: 550;
  line-height: 1.28;
  text-align: left;
  box-shadow: none;
  overflow-wrap: anywhere;
}

.wiki-tree-link:hover {
  background: rgba(255, 255, 255, 0.045);
  color: #f4eee7;
}

.wiki-tree-link.is-active {
  background: linear-gradient(90deg, rgba(217, 108, 29, 0.18), rgba(217, 108, 29, 0.055));
  box-shadow: inset 2px 0 #dc7b39;
  color: #ffd0a8;
}

.wiki-tree-order { flex: 0 0 auto; margin-right: .32rem; color: #737a83; font-variant-numeric: tabular-nums; }
.wiki-tree-link[draggable="true"] { cursor: grab; }
.wiki-tree-link[draggable="true"]:active { cursor: grabbing; }

.wiki-tree-row:has(.wiki-tree-toggle) .wiki-tree-link {
  color: #c6c8cc;
  font-weight: 650;
}

.wiki-tree-row:has(.wiki-tree-toggle) .wiki-tree-link.is-active {
  color: #ffd0a8;
}

.wiki-editor-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 1rem clamp(1.1rem, 3vw, 2.4rem) 0.9rem;
}

.wiki-editor-topline,
.wiki-modebar,
.wiki-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
}

.wiki-editor-topline {
  padding-bottom: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.065);
}

.wiki-breadcrumb {
  min-width: 0;
  overflow: hidden;
  color: #898e96;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wiki-editor-mode {
  color: #737981;
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  white-space: nowrap;
}

.wiki-document-fields {
  display: grid;
  padding: 1.1rem 0 0.65rem;
}

.wiki-field-label {
  margin-bottom: 0.35rem;
  color: #8c929a;
  font-size: 0.68rem;
  font-weight: 650;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.wiki-title-input,
.wiki-description-input {
  width: 100%;
  margin: 0 0 0.75rem;
  border-color: rgba(255, 255, 255, 0.075);
  border-radius: 0.45rem;
  background: rgba(0, 0, 0, 0.13);
  color: #f2eee9;
  box-shadow: none;
}

.wiki-title-input {
  min-height: 3.25rem;
  padding: 0.5rem 0.7rem;
  font-family: "Space Grotesk", "Segoe UI", sans-serif;
  font-size: 1.55rem;
  font-weight: 650;
  letter-spacing: -0.025em;
}

.wiki-description-input {
  min-height: 2.5rem;
  margin-bottom: 0.1rem;
  font-size: 0.85rem;
}

.wiki-title-input:focus,
.wiki-description-input:focus,
.wiki-body-input:focus {
  border-color: rgba(217, 108, 29, 0.45);
  box-shadow: 0 0 0 2px rgba(217, 108, 29, 0.08);
}

.wiki-title-input::placeholder,
.wiki-description-input::placeholder,
.wiki-body-input::placeholder {
  color: #646a72;
}

.wiki-modebar {
  justify-content: flex-start;
  padding-top: 0.2rem;
}

.wiki-tabs {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.2rem;
  border: 1px solid rgba(255, 255, 255, 0.065);
  border-radius: 0.6rem;
  background: rgba(0, 0, 0, 0.15);
}

.wiki-tab {
  width: auto;
  margin: 0;
  padding: 0.38rem 0.8rem;
  border: 0;
  border-radius: 0.42rem;
  background: transparent;
  color: #898e96;
  font-size: 0.75rem;
  font-weight: 650;
  box-shadow: none;
}

.wiki-tab.is-active {
  background: #2b3037;
  color: #f2eee9;
}

.wiki-markdown-hint {
  margin-left: auto;
  color: #747a82;
  font-family: monospace;
  font-size: 0.68rem;
}

.wiki-writing-view {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  margin-top: 0.6rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 0.7rem;
  background: #111418;
}

.wiki-toolbar {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 0.22rem;
  padding: 0.42rem 0.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.065);
  background: #191d22;
}

.wiki-toolbar button {
  min-width: 1.9rem;
  width: auto;
  height: 1.85rem;
  margin: 0;
  padding: 0 0.45rem;
  border: 0;
  border-radius: 0.35rem;
  background: transparent;
  color: #b1b4b9;
  font-size: 0.76rem;
  font-weight: 700;
  box-shadow: none;
}

.wiki-toolbar button:hover {
  background: rgba(255, 255, 255, 0.075);
  color: white;
}

.wiki-toolbar .wiki-image-tool {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: 0.15rem;
  padding: 0 0.6rem;
  border: 1px solid rgba(217, 108, 29, 0.22);
  background: rgba(217, 108, 29, 0.08);
  color: #e6a171;
}

.wiki-toolbar .wiki-image-tool span {
  font-size: 0.7rem;
}

.wiki-toolbar-divider {
  width: 1px;
  height: 1.15rem;
  margin: 0 0.25rem;
  background: rgba(255, 255, 255, 0.1);
}

.wiki-body-input {
  flex: 1;
  width: 100%;
  min-height: 0;
  margin: 0;
  padding: 1.1rem 1.15rem;
  resize: vertical;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: #d9d9d6;
  font-family: "IBM Plex Mono", "Cascadia Code", monospace;
  font-size: 0.83rem;
  line-height: 1.75;
  box-shadow: none;
}

.wiki-body-input:focus {
  border: 0;
  box-shadow: none;
}

.wiki-editor-footnote {
  padding: 0.5rem 0.8rem;
  border-top: 1px solid rgba(255, 255, 255, 0.055);
  color: #727880;
  font-size: 0.66rem;
}

.wiki-preview {
  flex: 1;
  min-height: 320px;
  margin: 0.6rem 0 0;
  padding: clamp(1.3rem, 4vw, 3rem);
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 0.7rem;
  background: #111418;
  color: #d2d2cf;
  overflow: auto;
}

.wiki-preview h1,
.wiki-preview h2,
.wiki-preview h3 {
  margin-top: 1.4em;
  color: #f2eee9;
}

.wiki-preview h1:first-child {
  margin-top: 0;
}

.wiki-preview p,
.wiki-preview li,
.wiki-preview blockquote {
  color: #c6c6c1;
  line-height: 1.75;
}

.wiki-preview-description {
  margin-top: -0.7rem;
  color: #999fa7 !important;
  font-size: 1.05rem;
}

.wiki-preview img {
  display: block;
  max-width: 100%;
  max-height: 640px;
  margin: 1.4rem auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 0.65rem;
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.25);
}

.wiki-preview code,
.wiki-preview pre {
  border-color: rgba(255, 255, 255, 0.08);
  background: #1b2026;
}

.wiki-preview blockquote {
  padding-left: 1rem;
  border-left: 2px solid #c66c30;
}

.wiki-preview-empty {
  color: #777e86 !important;
  font-style: italic;
}

.wiki-editor-footer {
  padding-top: 0.7rem;
  color: #777e86;
  font-size: 0.66rem;
}

.wiki-delete-button {
  width: auto;
  margin: 0;
  padding: 0.35rem 0.5rem;
  border: 0;
  background: transparent;
  color: #9d746d;
  font-size: 0.68rem;
  box-shadow: none;
}

.wiki-delete-button:hover {
  background: rgba(150, 55, 45, 0.1);
  color: #e89b8c;
}

@media (max-width: 760px) {
  main.container:has(.wiki-page) {
    width: calc(100vw - 1rem);
    padding-bottom: 0.25rem;
  }

  .wiki-page .wiki-workspace {
    grid-template-columns: 1fr;
    height: calc(100dvh - 142px);
    min-height: 600px;
  }

  .wiki-sidebar {
    max-height: 185px;
    padding: 0.65rem;
    border-right: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.075);
  }

  .wiki-tree {
    max-height: 78px;
  }

  .wiki-editor-pane {
    min-height: 0;
    padding: 0.65rem;
  }

  .wiki-editor-topline > .wiki-actions { justify-content: flex-start; }

  .wiki-editor-topline {
    align-items: flex-start;
    flex-direction: column;
}
