* {
  box-sizing: border-box;
  margin: 0;
  padding: 0
}

body {
  line-height: 1.6;
  color: #222;
  font: normal 87.5%/1.4 Arial, system-ui, sans-serif;
  /* default font size: 100% => 16px; 93.75% => 15px; 87.5% => 14px; 81.25% => 13px; 75% => 12px */
  -webkit-text-size-adjust: 100%;
  background: #fbfaf9;
}

/* ── Login screen ── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: #f4f4f5;
  padding: 1rem
}

#login-box {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 360px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, .07)
}

#login-box h2 {
  font-size: 1.3rem;
  margin-bottom: 1.5rem;
  text-align: center
}

#login-box label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: .9rem
}

#login-box input {
  display: block;
  width: 100%;
  margin-top: .25rem;
  padding: .55rem .75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 1rem;
  outline: none
}

#login-box input:focus {
  border-color: #05c
}

#login-box button {
  width: 100%;
  margin-top: 1.2rem;
  padding: .65rem;
  background: #05c;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center
}

#login-box button:hover {
  background: #004ab3
}

#login-error {
  margin-top: .75rem;
  font-size: .85rem;
  color: #c00;
  text-align: center;
  min-height: 1.2rem
}

/* ── Wiki screen ── */
#wiki-screen {
  max-width: 860px;
  margin: 110px auto 50px;
  padding: 1rem 1.5rem 2rem;
  clear: both;
  background: #fff;
  color: inherit;
  border: 1px solid #eee;
  box-shadow: 0 0 .5em #999;
  border-radius: 2px;
  overflow: hidden;
  word-wrap: break-word;
}

header {
  border-bottom: 2px solid #222;
  padding: .5rem 1.5rem;
  margin-bottom: .75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #fff;
  z-index: 1000;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
  min-height: 50px;
}

header a {
  font-size: 1.4rem;
  font-weight: 700;
  color: #111;
  text-decoration: none
}

#header-right {
  display: flex;
  gap: .5rem;
  align-items: center
}

#mobile-menu-btn { display: none; }

#header-buttons {
  display: flex;
  gap: .5rem;
  align-items: center
}

@media (max-width: 899px) {
  #mobile-menu-btn { display: inline-flex; }

  #header-buttons {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    flex-direction: column;
    background: #fff;
    border: 1px solid #eee;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
    padding: .5rem;
    gap: .25rem;
    z-index: 1001
  }

  #header-buttons.is-open { display: flex; }

  #header-buttons .btn { width: 100%; }
}

#user-badge {
  font-size: .78rem;
  color: #666;
  padding: .2rem .6rem;
  background: #f0f0f0;
  border-radius: 3px
}

nav {
  font-size: .85rem;
  color: #666;
  margin-bottom: 1.5rem;
  min-height: 1.2rem
}

nav a {
  color: #05c;
  text-decoration: none
}

nav a:hover {
  text-decoration: underline
}

/* ── headers ── */
/*
#content h1{font-size:1.9rem;margin:.25rem 0 .8rem}
#content h2{font-size:1.3rem;margin:1.5rem 0 .4rem;padding-bottom:.2rem;border-bottom:1px solid #eee}
#content h3{font-size:1.1rem;margin:1rem 0 .3rem}
*/
#content h1,
h2,
h3,
h4,
h5,
h6 {
  font-weight: bold;
  padding: 0;
  line-height: 1.2;
  clear: left;
  color: #8A0808;
  font-family: Arial, sans-serif;
}

#content h1 {
  font-size: 1.9em;
  margin: 0 0 0.444em;
  text-align: center;
  border-style: solid;
  border-width: 2px;
  padding: 0.45em 1em;
  margin: 0.6em 0 1em 0;
  background-color: #8A0808;
  color: #FFF;
}

#content h2 {
  font-size: 1.7em;
  margin: 1em 0 0.5em;
  border-bottom-style: double;
  border-bottom-width: 6px;
  border-color: #8A0808;
}

#content h3 {
  font-size: 1.6em;
  margin: 0.5em 0;
}

#content h4 {
  font-size: 1.25em;
  margin: 0.4em 0;
}

#content h5 {
  font-size: 1em;
  margin: 0.3em 0;
}

#content h6 {
  font-size: .75em;
  margin: 0.3em 0;
}

/* --- */
#content p {
  margin: .5rem 0
}

#content a {
  color: #05c
}

#content ul,
#content ol {
  margin: 0rem 0 0rem 1.5rem
}

#content pre {
  background: #f5f5f5;
  padding: .8rem 1rem;
  border-radius: 4px;
  overflow-x: auto;
  margin: .8rem 0
}

#content code {
  background: #f0f0f0;
  padding: .1em .3em;
  border-radius: 3px;
  font-size: 1.1em
}

#content pre code {
  background: none;
  padding: 0
}

/* ── Line numbers ── */
#content pre.ln-enabled {
  padding: .8rem 0
}
#content pre.ln-enabled code {
  counter-reset: ln;
  display: block
}
#content pre.ln-enabled .ln-line {
  counter-increment: ln;
  display: block;
  padding: 0 1rem 0 0
}
#content pre.ln-enabled .ln-line::before {
  content: counter(ln);
  display: inline-block;
  width: 2.5em;
  margin-right: .75em;
  padding-right: .5em;
  text-align: right;
  border-right: 1px solid #ddd;
  color: #aaa;
  user-select: none;
  -webkit-user-select: none
}

#content blockquote {
  font-family: 'Times New Roman', Times, serif;
  font-size: 1.1em;
  border: 2px dashed #ccc;
  border-left: 8px solid #ccc;
  padding: 1.1rem 1rem;
  color: #555;
  margin: 1.5rem 0;
  background-color: #ffc;
}

#content table {
  border-collapse: collapse;
  width: 100%;
  margin: .8rem 0
}

#content th,
#content td {
  border: 1px solid #ddd;
  padding: .35rem .7rem;
  text-align: left
}

#content th {
  background: #f5f5f5
}

#content img {
  max-width: 100%;
  height: auto
}

#content hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 1.2rem 0
}

/* Editor */
#editor {
  display: none;
  flex-direction: column;
  gap: .5rem
}

#editor textarea {
  width: 100%;
  height: 70vh;
  font-family: ui-monospace, monospace;
  font-size: .9rem;
  line-height: 1.5;
  padding: .75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  resize: vertical;
  outline: none
}

#editor textarea:focus {
  border-color: #05c
}

#editor-bar {
  display: flex;
  gap: .5rem
}

.btn {
  padding: .4rem .55rem;
  font-size: .85rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  background: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center
}

.btn:hover {
  background: #f5f5f5
}

button svg {
  display: block;
  width: 1rem;
  height: 1rem;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  overflow: visible
}

.btn-primary {
  background: #05c;
  color: #fff;
  border-color: #05c
}

.btn-primary:hover {
  background: #004ab3
}

.btn-danger {
  color: #c00;
  border-color: #c00
}

.btn-danger:hover {
  background: #fff5f5
}

#save-status {
  font-size: .8rem;
  color: #666;
  line-height: 2
}

/* Index panel */
#index-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 100
}

#index-panel {
  display: none;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(340px, 90vw);
  background: #fff;
  box-shadow: -4px 0 20px rgba(0, 0, 0, .15);
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  z-index: 101
}

#index-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center
}

#index-panel button.close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
  line-height: 1
}

#index-tree {
  font-size: .88rem
}

#index-tree ul {
  list-style: none;
  padding-left: 1rem;
  margin: 0
}

#index-tree>ul {
  padding-left: 0
}

#index-tree li {
  margin: .2rem 0
}

#index-tree a {
  color: #05c;
  text-decoration: none
}

#index-tree a:hover {
  text-decoration: underline
}

#index-tree .index-dir-label {
  color: #444;
  font-weight: 600;
  cursor: default;
}

#index-tree .index-no-page {
  font-size: .7em;
  color: #aaa;
  vertical-align: middle;
  margin-left: .3em;
}

#index-tree .folder {
  font-weight: 600;
  color: #444;
  display: block;
  margin-top: .5rem
}

/* TOC panel */
#toc-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .35);
  z-index: 100
}

#toc-panel {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(300px, 90vw);
  background: #fff;
  box-shadow: 4px 0 20px rgba(0, 0, 0, .15);
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
  z-index: 101
}

#toc-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center
}

#toc-panel button.close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
  line-height: 1
}

#toc-list {
  font-size: .88rem
}

#toc-list ul {
  list-style: none;
  padding-left: 0;
  margin: 0
}

#toc-list li {
  margin: .2rem 0
}

#toc-list a {
  color: #05c;
  text-decoration: none;
  display: block
}

#toc-list a:hover {
  text-decoration: underline
}

.toc-h1 {
  font-weight: 700;
}

.toc-h2 {
  padding-left: 1.5rem
}

.toc-h3 {
  padding-left: 2.5rem;
  font-size: .83rem;
  color: #555
}

/* Toast notification */
#toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%) translateY(1rem);
  background: #1a7f37;
  color: #fff;
  padding: .6rem 1.2rem;
  border-radius: 6px;
  font-size: .9rem;
  font-weight: 500;
  box-shadow: 0 4px 14px rgba(0, 0, 0, .2);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  z-index: 200
}

#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0)
}

#toast.error {
  background: #c62828
}

/* ── Guest mode ── */
.guest-mode header {
  /* No special positioning for guest mode, it uses the global fixed header */
}

/* ── Go-to-top button (hidden by default, shown by themes that opt in) ── */
.go-top-btn {
  display: none;
}

.guest-mode #user-badge {
  display: none
}

/* ── Users management panel ── */
#users-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 100
}

#users-panel {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, 92vw);
  background: #fff;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .22);
  border-radius: 8px;
  padding: 1.5rem 1.75rem 1.75rem;
  z-index: 101
}

#users-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center
}

#users-panel button.close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
  line-height: 1
}

#users-form fieldset {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: .75rem 1rem .85rem;
  margin-bottom: 1rem
}

#users-form legend {
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: #555;
  padding: 0 .35rem
}

#users-form label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: #333;
  margin-top: .6rem
}

#users-form label:first-of-type {
  margin-top: 0
}

#users-form input[type="text"],
#users-form input[type="password"] {
  display: block;
  width: 100%;
  margin-top: .2rem;
  padding: .45rem .65rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: .92rem;
  outline: none;
  font-family: inherit
}

#users-form input:focus {
  border-color: #05c
}

#users-form-actions {
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  margin-top: .25rem
}

#users-save-status {
  font-size: .8rem;
  color: #666;
  flex: 1;
  line-height: 2.1
}

/* ── Settings panel ── */
#settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .45);
  z-index: 100
}

#settings-panel {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(360px, 92vw);
  background: #fff;
  box-shadow: 0 8px 40px rgba(0, 0, 0, .22);
  border-radius: 8px;
  padding: 1.5rem 1.75rem 1.75rem;
  z-index: 101
}

#settings-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center
}

#settings-panel button.close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
  line-height: 1
}

#settings-form label {
  display: block;
  font-size: .82rem;
  font-weight: 600;
  color: #333;
  margin-top: .85rem
}

#settings-form label:first-of-type {
  margin-top: 0
}

#settings-form input[type="text"],
#settings-form select {
  display: block;
  width: 100%;
  margin-top: .2rem;
  padding: .45rem .65rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: .92rem;
  outline: none;
  font-family: inherit
}

#settings-form input:focus,
#settings-form select:focus {
  border-color: #05c
}

#settings-form-actions {
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
  margin-top: 1.25rem
}

#settings-save-status {
  font-size: .8rem;
  color: #666;
  flex: 1;
  line-height: 2.1
}

/* ── Plugins panel ────────────────────────────────────────────────────────── */
#plugins-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 100;
}
#plugins-panel {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(480px, 94vw);
  max-height: 80vh;
  overflow-y: auto;
  background: #fff;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  border-radius: 8px;
  padding: 1.5rem 1.75rem 1.75rem;
  z-index: 101;
}
#plugins-panel h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#plugins-panel .close-btn {
  background: none;
  border: none;
  font-size: 1.2rem;
  cursor: pointer;
  color: #666;
  line-height: 1;
}
.plugin-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem 0;
  border-bottom: 1px solid #eee;
}
.plugin-card:last-child { border-bottom: none; }
.plugin-info strong { font-size: .92rem; }
.plugin-info small  { color: #666; font-size: .78rem; }
.plugin-version { font-size: .75rem; color: #888; margin-left: .4rem; font-weight: 400; }
.plugin-toggle { flex-shrink: 0; padding-top: .15rem; }
.toggle-switch { position: relative; display: inline-block; width: 38px; height: 22px; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute;
  inset: 0;
  background: #ccc;
  border-radius: 22px;
  cursor: pointer;
  transition: .25s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: .25s;
}
.toggle-switch input:checked + .toggle-slider { background: #2a7ae2; }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }
.toggle-switch input:disabled + .toggle-slider { opacity: .6; cursor: not-allowed; }
#plugins-empty { color: #888; font-size: .9rem; padding: .5rem 0; }

/* ── Confirm delete dialog ────────────────────────────────────────────── */
#confirm-delete-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
}
#confirm-delete-dialog {
  display: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(380px, 92vw);
  background: #fff;
  box-shadow: 0 8px 40px rgba(0,0,0,.22);
  border-radius: 8px;
  padding: 1.75rem 2rem;
  z-index: 201;
}
#confirm-delete-dialog p { margin: 0 0 .5rem; font-weight: 600; font-size: 1rem; }
#confirm-delete-dialog .confirm-delete-subtitle { font-weight: 400; font-size: .875rem; color: #666; margin-bottom: 1.5rem; }
.confirm-delete-actions { display: flex; justify-content: flex-end; gap: .75rem; }

#footer {
  text-align: center;
  margin: 1rem auto 2rem;
}

#footer a {
  font-size: 0.75rem;
  color: #8A0808;
}