/* #region common */

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  /* box-sizing: border-box; */
}


:root {

  --color-bg-1: #252525;
  --color-bg-2: #222;

  --color-txt-1: white;
  --color-txt-code: #f8f8f2;

  --color-border: #676767;
  --color-border-lite: #3c3c3c;

}

:root[data-theme="white"] {
  
  --color-bg-1: rgb(214, 214, 214);
  --color-bg-2:  rgb(241, 241, 241);

  --color-txt-1: black;
  --color-txt-code: black;

}


.hidden {
  display: none !important;
}

.no-pointer-events {
  /* block focus gain on input */
  pointer-events: none; 
}

/* #endregion */


/* #region layout top */

/*

body
  topbar
  main-layout
    left-toolbox|left-sidebar|   content   |right-sidebar|right-toolbox
  /main-layout
  bottombar

*/

body {
  display: flex;
  flex-direction: column;
  /* stacks its direct children vertically (top → bottom) == each element one row */
  min-height: 100vh;
  /* Use full window height even if no content */
}



/* Main layout below the top bar 
* The default flex-direction is row, so its children will be laid out horizontally (left → right).
*/
.main-layout {
  display: flex;
  flex: 1;
  /* Grow to fill available space in the parent flex container (the body). Since body uses flex-direction: column, .main-layout will expand vertically between top-bar and bottom-bar */
  min-height: 0;
  /* prevents overflow issues when nested flexboxes have children that might stretch in some browsers */
  position: relative;
  /* Set a positioning context for any absolutely positioned children inside it. */
}

.bottombar {
  text-align: left;
  padding: 2px 10px;
}

.content {
  flex: 1;
  padding: 50px;
  padding-top: 30px;
}

.right-sidebar {
  width: 15vw;
  padding-top: 30px;
  padding-left: 40px;
  padding-right: 40px;

}


/* #endregion */


/* #region fonts */

body {
  font-family: Arial, sans-serif;
  font-size: 16px;

}

.topbar {
  font-size: 18px;
  font-weight: bold;
  ;

}

.bottombar {
  font-size: 10px;
  font-weight: normal;
}

/* #endregion */


/* #region main borders and colors */

body {
  background-color: var(--color-bg-1);
  color: var(--color-txt-1);
}

.topbar {
  background-color: var(--color-bg-1);

  border-bottom: 1px solid var(--color-border);
  margin-bottom: 1px;

}

.bottombar {
  border-top: 1px solid var(--color-border-lite);
  margin-top: 1px;
}

.left-sidebar {
  color: var(--color-txt-1);
  border-right: 1px solid var(--color-border);;
}

.content {
  background-color: var(--color-bg-2);
  color: #f2f2f2;
}

.right-sidebar {
  border-radius: 10px;
  border-left: 1px solid var(--color-border);;
}

/* #endregion */


/* #region topbar */

.topbar {
  display: flex;
  align-items: center;
  padding: 20px 20px 20px 20px;
}

.topbar-left {
  flex: 0 0 auto;
  white-space: nowrap;

  display: flex;
  align-items: center;
  gap: 10px;
}


/* When window width > 800px */
@media (min-width: 1581px) {
  .topbar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
  }

  .input-top-search {
    width: 300px;
    padding: 7px 140px;
  }
}

/* When window width ≤ 800px */
@media (max-width: 1580px) {
  .topbar-center {
    position: absolute;
    right: 80px;
  }

  .input-top-search {
    width: 250px;
    padding: 7px 50px;
  }
}


.topbar-right {
  position: absolute;
  right: 20px;
}




.topbar-icon {
  filter: invert(1);
}

.topbar-icon img {
  width: 32px;
  height: auto;
}

.topbar-settings img:hover {
  filter: invert(1);
}


.topbar-title {
  font-size: 24px;
  font-weight: bold;
}

.input-top-search {
  border-radius: 20px;
  border: 1px solid #555;
  background-color: #333;
  color: var(--color-txt-1);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

/* Center placeholder text */
.input-top-search::placeholder {
  text-align: center;
}

/* #endregion */


/* #region Left sidebar */

.left-sidebar {
  /* Remove duplicate min-width, set width and max-width */
  width: 20vw;
  display: flex;
  /* flex: 1; */
  flex-direction: column;
  padding-top: 30px;
  border-radius: 10px;
  padding-right: 15px;
  padding-left: 15px;
  padding-bottom: 15px;
  box-sizing: border-box;
}

.left-sidebar-scroll-pane {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow-y: auto;
  padding-top: 5px;


}

.left-sidebar a {
  color: var(--color-txt-1);
  text-decoration: none;
  padding: 2px;
  display: block;
  border-radius: 6px;
}

.left-sidebar a {
  padding-left: 20px;
  font-size: 15px;
}

.left-sidebar a.active {
  background-color: #555;
  font-weight: bold;
}

.left-sidebar a:hover {
  background-color: #444;
}


/* --- Tree menu styles --- */
.left-sidebar ul.tree-root {
  padding-top: 10px;
}

.left-sidebar ul.tree-root,
.left-sidebar ul.tree-root ul {
  list-style: none;
  white-space: nowrap;
}

.left-sidebar ul.tree-root>li {
  margin-left: 0;
}



.left-sidebar ul.tree-root ul {
  margin-left: 20px;
  border-left: 1px solid #444;
}

.tree-folder-btn {
  background: none;
  border: none;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  padding: 1px 0 1px 18px;
  text-align: left;
  width: 100%;
  position: relative;
  font-size: 15px;
  outline: none;
  transition: background 0.2s;
}

.tree-folder-btn:before {
  /* content: "▶"; */
  content: ">";
  display: inline-block;
  margin-right: 6px;
  font-size: 16px;
  font-weight: 300;
  transition: transform .5s;
}

.tree-folder-btn.open:before {
  /* content: "▼"; */
  /* content: "v"; */
}
.tree-folder-btn.open::before { transform: rotate(90deg); }


.tree-folder-btn:hover {
  background: #444;
  border-radius: 8px;
}

.left-sidebar ul.tree-root ul {
  display: none;
}

.left-sidebar ul.tree-root ul.open {
  display: block;
}



.tree-filter-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding-right: 8px;
}

#tree-filter-input {
  margin-left: 8px;
  margin-bottom: 0;
  padding: 6px;
  border-radius: 6px;
  border: 1px solid #555;
  background: #333;
  color: #fff;
  width: 100%;
  min-width: 0;
  flex: 1 1 auto;
}

#collapse-all-tree-btn,
#expand-all-tree-btn {
  background: #333;
  color: #fff;
  border: 1px solid #555;
  border-radius: 1px;
  font-size: 14px;
  width: 16px;
  height: 16px;
  padding: 0;
  margin-bottom: 0;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

#collapse-all-tree-btn:hover,
#expand-all-tree-btn:hover {
  background: #444;
  border-color: #888;
}

/* #endregion */


/* #region right sidebar */

.right-sidebar header {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 10px;
}


.outline ol {
  margin-left: .5rem;
  /* indent each nested list */
  list-style-position: outside;
}

.outline li {
  list-style-type: none;
  line-height: 1.4;

  /* ... for long line */
  white-space: nowrap;
  /* Don’t wrap text */
  overflow: hidden;
  /* Hide the overflow */
  text-overflow: ellipsis;
}

.outline a {
  color: var(--color-txt-1);
  text-decoration: none;
}

.outline a:hover {
  font-weight: bold;
}


/* #endregion */


/* #region topmenu */
.topmenu {
  display: flex;
  gap: 20px;
  position: relative;
  margin-left: 20px;
}

.topmenu-item {
  position: relative;
}

.topmenu-label {
  cursor: pointer;
  padding: 6px 1px;
  border-radius: 8px;
  transition: background 0.2s;
  font-weight: bold;
  font-size: 14px;
  display: inline-block;
  color: var(--color-txt-1);
}

.topmenu-label:hover,
.topmenu-item:hover>.topmenu-label {
  background: #333;
}

.topmenu-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: #333;
  border-radius: 6px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  padding: 8px 0;
  z-index: 200;
  flex-direction: column;
}

.topmenu-item:hover>.topmenu-dropdown {
  display: flex;
}

.topmenu-dropdown a,
.topmenu-submenu-label {
  display: block;
  color: #fff;
  text-decoration: none;
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
}

.topmenu-dropdown a:hover,
.topmenu-submenu-label:hover {
  background: #444;
}

.topmenu-separator {
  border: none;
  border-top: 1px solid #8e8e8e;
  margin: 6px 15px;
}

.topmenu-submenu-parent {
  position: relative;
}

.topmenu-submenu-label {
  position: relative;
  padding-right: 28px;
}

.topmenu-submenu {
  display: none;
  position: absolute;
  top: 0;
  left: 100%;
  min-width: 200px;
  background: #333;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
  padding: 8px 0;
  z-index: 210;
}

.topmenu-submenu-parent:hover>.topmenu-submenu,
.topmenu-submenu-label:focus+.topmenu-submenu {
  display: flex;
  flex-direction: column;
}

.topmenu-submenu a {
  padding: 8px 20px;
  font-size: 15px;
}

/* #endregion */


/* #region popup overlay */
.popup-overlay {
  position: absolute;
  /* Change from fixed to absolute */
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100%;
  background: rgba(34, 34, 34, 0.7);
  backdrop-filter: blur(3px);
  z-index: 1000;
}

/* Popup Modal */
.popup-modal {
  position: fixed;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  width: 800px;
  height: 600px;
  background: #333;
  color: #c6c6c6;
  border-radius: 20px;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  padding: 0;
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 16px 16px;
}

.popup-title {
  margin-left: 8px;
  font-size: 20px;
  font-weight: bold;
  color: #fff;
}

.popup-close {
  background: none;
  border: none;
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  padding: 0 4px;
  border-radius: 50%;
  transition: background 0.2s;
}

.popup-close:hover {
  background: #444;
}

.popup-separator {
  border: none;
  border-top: 1px solid #555;
  margin: 0 0 8px 0;
}

.popup-content {
  flex: 1;
  padding: 10px 46px;
  overflow-x: auto;
}

.popup-content a {
  color: #fff;
}

.popup-confirm {
  margin: 0 16px 16px 16px;
  padding: 6px 0;
  border: none;
  border-radius: 10px;
  background: #555;
  color: #fff;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s;
}

.popup-confirm:hover {
  background: #676767;
}

/* #endregion */


/* #region article */

article {
  max-width: 800px;
  margin: 0 auto;
  line-height: 1.6;
  font-size: 16px;
}

/* article * {
  margin-bottom: 20px
} */


article > p, hr {
  margin-bottom: 10px
}


article h1 {
  padding-top: 10px;
  padding-bottom: 5px;

  margin-top: 40px;
  margin-bottom: 30px;
  font-size: 28px;
}

article h2 {
  margin-top: 40px;
  margin-bottom: 20px;
}

article h3 {
  margin-top: 10px;
  margin-bottom: 10px;
}

article h1,
h2 {
  border-bottom: 1px solid #444;
}

article ol,
article ul {
  margin-left: 30px;
  margin-bottom: 20px;
}

article pre code {
  background-color: #2f2f2f;
  color: var(--color-txt-code);
  /* padding: 2px 4px; */
  border-radius: 4px;
  border: 1px solid #444;
  font-size: 12px;
  line-height: 2;
  font-family: 'Courier New', Courier, monospace;
  display: block;
  /* width: 85%; */
  padding: 20px;
  margin-left: 10px;
  margin-bottom: 20px;
  margin-top: 20px;
  white-space: pre-wrap;
  /* allow line breaks */
  word-break: break-word;
}

article h1 + pre code,
article h2 + pre code {
  margin-top: 40px;
}

article p > code {
  background-color: #353535;
  font-size: 12px;
}

article a:visited {
  color: #6590cc;
  font-weight: bold;
}

article a:link {
  color: #6590cc;
  font-weight: bold;
}

article img {
  /* skip missing alt text for missing imgs for now */
  font-size: 0;
}

article p > img,
article > img {
  /* center image */
  display: block;
  margin-left: auto;
  margin-right: auto;
}

article table {
  /* center table */
  margin-left: auto; 
  margin-right: auto;

  border-collapse: collapse; /* merge touching borders into one shared border (single line instead of two) */

  margin-top: 40px;
  margin-bottom: 30px;
}

table td,
table th {
  border: 1px solid;
  padding: 10px; 
}

table th {
  border-width: 2px;
  background-color: #353535;
}

tbody tr:nth-child(even) {
  background-color: #272727;
}


/* #endregion */


