:root {
  --bg: #0A1F1F;
  --bg-light: #f9f9f9;
  --text: #F8F9FA;
  --accent: #50E3C2;
  --highlight: #2BAF95;
  --border: #2f4f4f;
  --link: #2BAF95;
  --font-serif: 'IBM Plex Serif', serif;
  --font-mono: 'JetBrains Mono', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font-serif);
  background-color: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
  height: 100vh;
  padding-top: 50px; /* desktop topbar height */
}

@media (max-width: 768px) {
  body {
    padding-top: 40px; /* mobile topbar height */
  }
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.topbar, .topbar a, .nav-links {
  font-family: var(--font-mono);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between; /* puts space between toggle, title, and login */
  height: 50px;
  padding: 0 1rem;
  background-color: #061616;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--link);
  box-sizing: border-box;
  position: fixed; /* keeps it at top */
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000;
}

#sidebar-toggle {
  background: transparent;
  border: none;
  font-size: 1.8rem;
  color: var(--accent);
  cursor: pointer;
  /* no position fixed or absolute! */
  padding: 0;
  margin: 0;
}

.site-name a {
  color: var(--link);
  text-decoration: none;
  font-size: 1.2rem;
  font-weight: 700;
}

#login-link {
  font-family: var(--font-mono);
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
  cursor: pointer;
}

#login-link:hover {
  color: var(--highlight);
}


.topbar a {
  color: var(--link);
  text-decoration: none;
  font-weight: 500;
  letter-spacing: 0.5px;
}

.topbar a:hover {
  color: var(--accent);
}

.nav-links a {
  margin-right: 2rem;
}

.nav-links a:last-child {
  margin-right: 0;
}

.site-name a {
  font-size: 1.0rem;
  color: var(--link);
}

#container {
  display: flex;
  flex: 1;
  overflow: hidden;
}

#sidebar {
  width: 250px;
  background-color: #122828;
  padding: 1rem;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  box-sizing: border-box;

  scrollbar-width: none;        /* Firefox: hide scrollbar */
  -ms-overflow-style: none;     /* IE and Edge: hide scrollbar */
}

#sidebar::-webkit-scrollbar {
  display: none;
}

#sidebar input {
  width: 100%;
  padding: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  background-color: #0d1d1d;
  color: var(--text);
  font-family: var(--font-mono);
}

#page-list {
  display: flex;
  flex-direction: column;
}

#page-list a {
  padding: 0.3rem 0;
  color: var(--text);
}

#page-list a.current {
  color: var(--accent);
  font-weight: bold;
}

main {
  padding: 2rem;
  overflow-y: auto;
  flex-grow: 1;
  max-width: none;
  min-width: 0;
}

.content-box {
  margin-top: 1rem;
  line-height: 1.7;
}

/* Buttons */
button {
  background-color: var(--accent);
  color: var(--bg);
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 6px;
  font-weight: bold;
  cursor: pointer;
  margin-top: 1rem;
  font-family: var(--font-mono);
  transition: background 0.2s ease;
}

button:hover {
  background-color: var(--highlight);
}

textarea, input[type="text"] {
  width: 100%;
  margin-top: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background-color: #0d1d1d;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--font-mono);
}

#create-page-form {
  margin-top: 1rem;
}

#create-page-msg {
  margin-top: 0.5rem;
  font-size: 0.9rem;
}

#login-link {
  font-family: var(--font-mono);
}

.markdown-body {
  font-family: var(--font-serif);
}

.content-box h1, .content-box h2, .content-box h3 {
  color: var(--accent);
  margin-top: 1.5rem;
}

.content-box h1 {
  font-size: 2em;
}

.content-box h2 {
  font-size: 1.6em;
}

.content-box h3 {
  font-size: 1.3em;
}

.content-box code {
  background-color: #132020;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-family: var(--font-mono);
}

.content-box pre {
  background-color: #132020;
  padding: 1rem;
  overflow-x: auto;
  border-radius: 6px;
  font-family: var(--font-mono);
}

.content-box ul, .content-box ol {
  margin-left: 1.5rem;
}

.content-box blockquote {
  border-left: 4px solid var(--accent);
  padding-left: 1rem;
  color: #ccc;
  font-style: italic;
}

#editor-container {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background-color: #fff;
  box-sizing: border-box;
}

#markdown-editor {
  width: 100%;
  height: 300px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 1rem;
  background-color: #0d1d1d;
  color: #F8F9FA;
  border: 1px solid #2f4f4f;
  border-radius: 6px;
  padding: 1rem;
  box-sizing: border-box;
  resize: vertical;
}

#version-history {
  background-color: #132020;
  color: #F4C542;
}

#content a.visited-link {
  color: #3bb9ae;
}

/* --- MOBILE SIDEBAR TOGGLE --- */
@media (max-width: 768px) {
  /* Sidebar hidden offscreen by default */
  .site-name {
    display: none;
  }

  /* Ensure toggle button and login button remain visible */
  #sidebar-toggle,
  #login-link {
    display: inline-block; /* or flex, if you want */
  }
  #sidebar {
    position: fixed;
    top: 40px; /* below mobile topbar */
    left: 0;
    height: calc(100vh - 40px);
    width: 250px;
    max-width: 80vw;
    background-color: #122828;
    padding: 1rem;
    border-right: 1px solid var(--border);
    overflow-y: auto;
    box-sizing: border-box;

    transform: translateX(-110%);
    transition: transform 0.3s ease;
    z-index: 1000;
  }

  /* Sidebar visible when active */
  #sidebar.active {
    transform: translateX(0);
  }

  /* Show toggle button */
#sidebar-toggle {
  position: fixed;
  top: 8px;
  left: 8px; /* keep it left, but with margin */
  font-size: 1.8rem;
  background: transparent;
  border: none;
  color: var(--accent);
  z-index: 1100;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}

  /* Container stacked vertically */
  #container {
    flex-direction: column;
  }

  main {
    padding: 1rem;
    margin-left: 0;
  }
}

/* --- DESKTOP STYLES --- */
@media (min-width: 769px) {
  #sidebar {
    position: static;
    transform: none !important;
    width: 250px;
    height: auto;
    max-width: none;
    border-right: 1px solid var(--border);
  }

  #sidebar-toggle {
    display: none;
  }

  #container {
    flex-direction: row;
  }

  main {
    padding: 2rem;
    margin-left: 0;
  }
}
@media (max-width: 768px) {
  body.no-topbar-mobile .topbar {
    display: none !important;
  }

  /* Also adjust body padding so no extra space */
  body.no-topbar-mobile {
    padding-top: 0 !important;
  }
}
