/* Wikilinks */
.wikilink {
  color: #7aa2f7;
  text-decoration: none;
  border-bottom: 1px solid rgba(122, 162, 247, 0.3);
  cursor: pointer;
}

.wikilink:hover {
  color: #a4c0ff;
  border-bottom-color: rgba(164, 192, 255, 0.6);
}

.wikilink-broken {
  color: #888;
  border-bottom: 1px dashed #888;
  cursor: not-allowed;
}

.wikilink-broken:hover {
  color: #aaa;
}

.toastui-editor-toolbar-icons.wikilink-toolbar-btn {
  width: auto !important;
  padding: 0 6px !important;
  font-size: 12px;
  font-weight: 600;
  color: #eee !important;
  background-image: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.wikilink-autocomplete {
  position: fixed;
  z-index: 10002;
  background-color: var(--bg-secondary, #303030);
  border: 1px solid var(--border-color, #444);
  border-radius: 6px;
  min-width: 220px;
  max-width: 360px;
  max-height: 240px;
  overflow-y: auto;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  display: none;
  font-size: 13px;
}

.wikilink-autocomplete-item {
  padding: 6px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--text-primary, #eaeaea);
}

.wikilink-autocomplete-item:hover,
.wikilink-autocomplete-item.selected {
  background-color: var(--link-color, #3a86ff);
  color: #fff;
}

.wikilink-autocomplete-path {
  font-size: 11px;
  color: var(--text-muted, #999);
  font-family: monospace;
}

.wikilink-autocomplete-item.selected .wikilink-autocomplete-path {
  color: rgba(255, 255, 255, 0.8);
}

.conflict-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10001;
  padding: 10px 20px;
  background-color: #b04545;
  color: #fff;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  display: none;
}

.conflict-banner code {
  background-color: rgba(0, 0, 0, 0.25);
  padding: 1px 5px;
  border-radius: 3px;
  font-family: monospace;
  color: #fff;
}

/* Theme CSS Variables */
:root {
  --bg-primary: #181818;
  --bg-secondary: #303030;
  --bg-tertiary: #0a0a0a;
  --bg-input: #1e1e1e;
  --text-primary: #fff;
  --text-secondary: #ccc;
  --text-muted: #888;
  --border-color: #555;
  --border-light: #333;
  --accent-color: gold;
  --accent-hover: #ffe780;
  --link-color: #1890ff;
  --link-hover: #68c0ff;
  --success-color: #4CAF50;
  --error-color: #f44336;
  --warning-color: #ff9800;
  
  --bg-primary-alt: #f5f5f5;
  --bg-secondary-alt: #e0e0e0;
  --bg-tertiary-alt: #ffffff;
  --bg-input-alt: #ffffff;
  --text-primary-alt: #1a1a1a;
  --text-secondary-alt: #444;
  --text-muted-alt: #666;
  --border-color-alt: #ccc;
  --border-light-alt: #ddd;
  --accent-color-alt: #b8860b;
  --accent-hover-alt: #996515;
  --link-color-alt: #0066cc;
  --link-hover-alt: #004499;
}

/* Light mode overrides */
body.light-mode {
  --bg-primary: #f5f5f5;
  --bg-secondary: #e0e0e0;
  --bg-tertiary: #ffffff;
  --bg-input: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #444;
  --text-muted: #666;
  --border-color: #ccc;
  --border-light: #ddd;
  --accent-color: #b8860b;
  --accent-hover: #996515;
  --link-color: #0066cc;
  --link-hover: #004499;

  --bg-primary-alt: #181818;
  --bg-secondary-alt: #303030;
  --bg-tertiary-alt: #0a0a0a;
  --bg-input-alt: #1e1e1e;
  --text-primary-alt: #fff;
  --text-secondary-alt: #ccc;
  --text-muted-alt: #888;
  --border-color-alt: #555;
  --border-light-alt: #333;
  --accent-color-alt: #b8860b;
  --accent-hover-alt: #ffe780;
  --link-color-alt: #1890ff;
  --link-hover-alt: #68c0ff;
  --success-color-alt: #4CAF50;
  --error-color-alt: #f44336;
  --warning-color-alt: #ff9800;
}

body {
  display: flex;
  flex-direction: column;
  background-color: var(--bg-primary);
  margin: 0 0 120px 0;
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  font-family: Arial, Helvetica, sans-serif;
  transition: background-color 0.3s ease, color 0.3s ease;
}

#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin: 0 20px 0 20px;
}

#mainContent {
  flex: 1;
  display: flex;
  overflow: hidden;
}

#userMenuContainer {
  position: fixed;
  top: 10px;
  right: 20px;
  z-index: 10001;
}

#sites-list-panel {
  text-align: center;
  min-width: 40%;
  max-width: 80%;
  width: 100%;
  margin: 0 auto 0 auto;
  padding: 20px;
  max-height: 100vh;
  overflow-y: auto;
}

.site-button {
  width: 100%;
  height: auto;
}

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

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
  cursor: pointer;
}

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

footer a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

nav {
  background-color: var(--bg-secondary);
  padding: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
  transition: background-color 0.3s ease;
}

.menu-link {
  display: inline-block;
  color: var(--text-primary);
  text-decoration: none;
  padding: 15px 20px;
  font-size: 20pt;
  transition: background-color 0.3s ease, color 0.3s ease;
}

.menu-link:hover {
  background-color: var(--border-color);
}

.menu-link:active {
  background-color: #1890ff;
}

.h-entry {
  margin-left: 10%;
  margin-right: 10%;
  margin-bottom: 20px;
  background-color: var(--bg-secondary);
  border-radius: 8px;
  padding: 20px;
  transition: background-color 0.3s ease;
}

.h-entry h1 {
  text-align: center;
  font-size: 24pt;
}

.h-entry h2 {
  text-align: center;
  font-size: 20pt;
}

.h-entry h3,
.h-entry h4,
.h-entry h5,
.h-entry h6 {
  text-align: center;
  font-size: 18pt;
}

.h-entry p {
  font-size: 16pt;
}

.form-control {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.input-group-addon {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.dropdown-menu {
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.dropdown-menu li a {
  color: var(--text-primary);
}

.dropdown-menu li a:hover,
.dropdown-menu li a:focus {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.dropdown-menu .divider {
  background-color: var(--border-color);
}

#commitModal {
  z-index: 10003;
}

.modal {
  z-index: 11000 !important;
}

.modal-content {
  background-color: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.modal-content,
.modal-header,
.modal-body,
.modal-footer {
  border-color: var(--border-color);
}

.modal-header .close {
  color: #ff4444;
  opacity: 1;
  text-shadow: none;
}

.modal-header .close:hover {
  color: #ff0000;
}

/* Site type cards */
.site-type-cards {
  display: flex;
  gap: 12px;
}

.site-type-card {
  flex: 1;
  padding: 16px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  background: var(--bg-secondary);
  cursor: pointer;
  transition: border-color 0.2s ease, background-color 0.2s ease;
  text-align: center;
}

.site-type-card:hover {
  border-color: var(--text-muted);
}

.site-type-card.selected {
  border-color: var(--accent-color);
  background: var(--bg-primary);
}

.site-type-card-icon {
  font-size: 28px;
  margin-bottom: 8px;
}

.site-type-card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.site-type-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Folder-import modal */
.import-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  background: var(--bg-secondary);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.import-dropzone:hover,
.import-dropzone.drag-over {
  border-color: var(--accent-color);
  background: var(--bg-primary);
}

.import-dropzone-icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.import-dropzone-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.import-dropzone-hint {
  font-size: 12px;
  color: var(--text-muted);
}

.import-summary {
  margin-top: 16px;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-secondary);
  font-size: 13px;
}

.import-summary-skipped {
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 4px;
}

.import-summary-list {
  list-style: none;
  margin: 8px 0 0 0;
  padding: 0;
  max-height: 200px;
  overflow-y: auto;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  color: var(--text-secondary);
}

.import-summary-list li {
  padding: 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* List group styles */
.list-group {
  margin-bottom: 0;
  padding-left: 0;
  background-color: transparent;
}

.list-group-item {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 10px 15px;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.list-group-item:first-child {
  border-top-left-radius: 4px;
  border-top-right-radius: 4px;
}

.list-group-item:last-child {
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
}

.list-group-item + .list-group-item {
  border-top-width: 0;
}

.list-group-item:hover {
  background-color: var(--border-color);
}

/* Fix input-group button alignment */
.input-group .input-group-btn .btn {
  margin: 0;
  height: 34px;
  padding: 6px 12px;
}

#sidebar {
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#editorSection {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100%;
}

#editorContainer {
  display: flex;
  flex-direction: column;
}

#editorBody {
  display: flex;
  flex: 1;
  min-height: 0;
  margin-left: 220px;
  transition: margin-left 0.2s ease;
}

#editorBody.sidebar-collapsed {
  margin-left: 36px;
}

#editor {
  flex: 1;
  min-width: 0;
}

#editor-topbar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10000;
  display: block;
  text-align: center;
  background-color: var(--bg-tertiary);
  width: 100%;
  padding: 10px 0 5px 0;
}

.publish-status {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
  margin: 10px 20px;
  vertical-align: middle;
}

.discard-changes-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  padding: 2px 6px;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  vertical-align: middle;
  margin-right: 4px;
  display: none;
}
.discard-changes-btn:hover {
  background-color: rgba(220, 53, 69, 0.12);
  border-color: rgba(220, 53, 69, 0.3);
}
.discard-changes-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.publish-status.pending-changes {
  background-color: #ffc107;
  color: #212529;
}

.publish-status.published {
  background-color: #28a745;
  color: white;
}

.auto-save-status {
  display: inline-block;
  padding: 4px 10px;
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  vertical-align: middle;
}

/* Editor Sidebar */
.editor-sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 220px;
  height: 100vh;
  /* top and height are set dynamically by positionEditorBody() */
  background-color: var(--bg-tertiary);
  border-right: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 101;
  transition: width 0.2s ease;
}

.editor-sidebar.collapsed {
  width: 36px;
}

.editor-sidebar.collapsed #editorSidebarContent {
  display: none;
}

.sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-light);
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  padding: 8px;
  text-align: center;
  transition: background-color 0.2s ease, color 0.2s ease;
  flex-shrink: 0;
}

.sidebar-toggle:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

#editorSidebarContent {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

#sidebarActions {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.sidebar-action-btn {
  flex: 1;
  padding: 5px 8px;
  font-size: 12px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.sidebar-action-btn:hover {
  background-color: var(--link-color);
  border-color: var(--link-color);
  color: white;
}

#sidebarSearch {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-light);
  flex-shrink: 0;
}

.sidebar-search-input {
  width: 100%;
  padding: 5px 8px;
  font-size: 12px;
  background-color: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease;
  box-sizing: border-box;
}

.sidebar-search-input:focus {
  border-color: var(--link-color);
}

.sidebar-search-results {
  margin-top: 6px;
  max-height: 50vh;
  overflow-y: auto;
}

.sidebar-search-result {
  display: block;
  padding: 5px 6px;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  border-radius: 3px;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.sidebar-search-result:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-search-result-title {
  font-size: 13px;
  font-weight: 600;
}

.sidebar-search-result-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  overflow-wrap: anywhere;
}

.sidebar-search-empty {
  padding: 5px 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}

#sidebarTree {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}

.sidebar-tree-node {
  display: flex;
  align-items: center;
  padding: 4px 8px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color 0.15s ease, color 0.15s ease;
  user-select: none;
}

.sidebar-tree-node:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.sidebar-tree-node.active {
  background-color: var(--link-color);
  color: white;
}

.sidebar-tree-node.folder {
  font-weight: 600;
  color: var(--text-primary);
}

.sidebar-tree-arrow {
  display: inline-block;
  width: 14px;
  font-size: 10px;
  text-align: center;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.sidebar-tree-arrow.expanded {
  transform: rotate(90deg);
}

.sidebar-tree-icon {
  margin-right: 6px;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar-tree-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-tree-actions {
  display: none;
  gap: 2px;
  margin-left: 4px;
  flex-shrink: 0;
}

.sidebar-tree-node:hover .sidebar-tree-actions {
  display: flex;
}

.sidebar-tree-action-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 14px;
  cursor: pointer;
  padding: 0 3px;
  line-height: 1;
}

.sidebar-tree-action-btn:hover {
  color: var(--text-primary);
}

.sidebar-tree-action-btn.delete:hover {
  color: var(--error-color);
}

.sidebar-tree-action-btn.folder-move {
  font-size: 9px;
  padding: 0 2px;
}

.sidebar-tree-children {
  display: block;
}

.sidebar-tree-children.collapsed {
  display: none;
}

.sidebar-inline-input {
  width: 100%;
  padding: 3px 6px;
  font-size: 13px;
  background-color: var(--bg-input);
  border: 1px solid var(--link-color);
  border-radius: 3px;
  color: var(--text-primary);
  outline: none;
}

.sidebar-tree-node.dragging {
  opacity: 0.4;
}

.sidebar-tree-node.drop-above {
  border-top: 2px solid var(--link-color);
}

.sidebar-tree-node.drop-below {
  border-bottom: 2px solid var(--link-color);
}

.sidebar-tree-node.drop-into {
  background-color: var(--link-color);
  opacity: 0.6;
}

#footer {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 10px 20px;
  background-color: var(--bg-tertiary);
  border-top: 1px solid var(--border-light);
  z-index: 100;
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

@media (max-width: 768px) {
  #footer {
    padding: 10px 20px 70px 20px;
  }

  #sites-list-panel {
    margin-bottom: 110px;
  }
}

.toastui-editor-popup,
.toastui-editor-popup-add-link {
  position: relative !important;
  max-width: 90% !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%,0%) !important;
  margin: 0 !important;
}

.toastui-editor-toolbar-item-wrapper {
  margin: 0 !important;
}

.btn {
  padding: 10px 20px;
  font-size: 16px;
  margin: 5px;
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
  display: inline-block;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.btn:hover {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
}

.btn.loading {
  pointer-events: none;
}

.btn.loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  top: 50%;
  left: 50%;
  margin-left: -8px;
  margin-top: -8px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: spinner 0.6s linear infinite;
}

@keyframes spinner {
  to {
    transform: rotate(360deg);
  }
}

/* Inline throbber for buttons that kick off long-running work (e.g. the
 * folder-import "Create Site" button — a 1000-page vault takes ~30 s to
 * commit + upload, and without visible motion the page reads as frozen). */
.btn-throbber {
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-right: 8px;
  vertical-align: -2px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spinner 0.6s linear infinite;
}

.alert-bar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  padding: 15px 20px;
  text-align: center;
  font-size: 16px;
  z-index: 10005;
  display: none;
  animation: slideDown 0.3s ease-out;
}

.alert-bar.show {
  display: block;
}

.alert-bar.success {
  background-color: #4CAF50;
  color: white;
}

.alert-bar.error {
  background-color: #f44336;
  color: white;
}

@keyframes slideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.sidebar-file-item {
  margin: auto;
  border-radius: 3px;
  background-color: var(--bg-tertiary);
  cursor: pointer;
  font-size: 14px;
  border: 1px solid var(--border-light);
  transition: background-color 0.3s ease, border-color 0.3s ease;
}

.sidebar-file-item:hover {
  background-color: var(--link-color);
  border-color: var(--link-hover);
}

.sidebar-file-item.active {
  background-color: #1890ff;
  color: white;
  border-color: #68c0ff;
}

.sidebar-file-text {
  flex: 1;
  cursor: pointer;
  padding: 5px 10px;
}

#sidebar {
  display: flex;
  min-width: 120px;
  max-width: 20%;
  border-right: 1px solid rgb(204, 204, 204);
}

#sidebarContentWrapper {
  margin-right: 20px;
}

#footer p {
  margin: 0 !important;
}

/* HTML embed popup styles */
.html-embed-popup {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  background-color: #1e1e1e;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 20px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 10001 !important;
}

.html-embed-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.html-embed-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.html-embed-header h3 {
  margin: 0;
  color: #fff;
  font-size: 18px;
}

.html-embed-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 30px;
  height: 30px;
  line-height: 1;
}

.html-embed-close:hover {
  color: #ff4444;
}

.html-embed-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.html-embed-form label {
  color: #ccc;
  font-size: 14px;
  margin-bottom: 5px;
}

.html-embed-form textarea {
  width: 100%;
  padding: 10px;
  background-color: #0a0a0a;
  border: 1px solid #555;
  border-radius: 4px;
  color: #fff;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  resize: vertical;
  min-height: 150px;
}

.html-embed-form textarea:focus {
  outline: none;
  border-color: #1890ff;
}

.html-embed-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 10px;
}

.html-embed-insert-btn,
.html-embed-cancel-btn {
  padding: 8px 16px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 4px;
}

/* PDF upload popup styles */
.pdf-upload-popup {
  position: fixed !important;
  top: 50% !important;
  left: 50% !important;
  transform: translate(-50%, -50%) !important;
  background-color: #1e1e1e;
  border: 1px solid #555;
  border-radius: 8px;
  padding: 20px;
  width: 90%;
  max-width: 400px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 10001 !important;
}

.pdf-upload-container {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.pdf-upload-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.pdf-upload-header h3 {
  margin: 0;
  color: #fff;
  font-size: 18px;
}

.pdf-upload-close {
  background: transparent;
  border: 1px solid #555;
  border-radius: 4px;
  color: #ff4444;
  font-size: 28px;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.pdf-upload-close:hover {
  background-color: #ff4444;
  border-color: #ff4444;
  color: #fff;
}

.pdf-upload-dropzone {
  border: 2px dashed #555;
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
  background-color: transparent;
}

.pdf-upload-dropzone:hover {
  border-color: #1890ff;
  background-color: rgba(24, 144, 255, 0.05);
}

.pdf-upload-progress {
  text-align: center;
}

/* Document list section */
.document-list-section {
  margin-top: 20px;
}

.document-list-section h4 {
  margin: 0 0 10px 0;
  color: #fff;
  font-size: 16px;
}

.document-list {
  max-height: 200px;
  overflow-y: auto;
  background-color: #0a0a0a;
  border-radius: 8px;
  border: 1px solid #333;
  padding: 8px;
}

.document-list-empty {
  color: #888;
  font-size: 14px;
  text-align: center;
  padding: 20px;
  font-style: italic;
}

.document-list-item {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  background-color: #1e1e1e;
  border-radius: 4px;
  margin-bottom: 5px;
  transition: background-color 0.2s ease;
}

.document-list-item:last-child {
  margin-bottom: 0;
}

.document-list-item:hover {
  background-color: #2a2a2a;
}

.document-icon {
  font-size: 18px;
  margin-right: 10px;
  flex-shrink: 0;
}

.document-name {
  flex: 1;
  color: #fff;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

.document-insert-btn {
  background-color: #1890ff;
  border: none;
  color: #fff;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s ease;
}

.document-insert-btn:hover {
  background-color: #40a9ff;
}

.document-delete-btn {
  background-color: transparent;
  border: 1px solid #ff4444;
  color: #ff4444;
  width: 24px;
  height: 24px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.document-delete-btn:hover {
  background-color: #ff4444;
  color: #fff;
}

/* Theme toggle button */
.theme-toggle {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: background-color 0.3s ease, border-color 0.3s ease, color 0.3s ease;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.theme-toggle:hover {
    background-color: var(--bg-primary-alt);
    color: var(--text-primary-alt);
}

.theme-toggle-icon {
  font-size: 14px;
}

/* Deploy overlay styles */
.deploy-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 10005;
  display: flex;
  align-items: center;
  justify-content: center;
}

.deploy-overlay-content {
  text-align: center;
  color: #fff;
}

.deploy-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #1890ff;
  animation: spinner 0.8s linear infinite;
  margin: 0 auto 20px auto;
}

.deploy-message {
  font-size: 20px;
  font-weight: 500;
}

/* Mode Selection Panel */
#modeSelectionPanel {
  text-align: center;
  min-width: 40%;
  max-width: 80%;
  width: 100%;
  margin: 0 auto;
  padding: 20px;
}

#modeSelectionHeader {
  text-align: left;
  margin-bottom: 30px;
}

#modeSelectionContent {
  padding: 20px;
}

#modeSelectionContent p {
  font-size: 18px;
  color: var(--text-secondary);
  margin-bottom: 30px;
}

#modeSelectionButtons {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-button {
  width: 250px;
  height: auto;
  padding: 30px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  border-radius: 8px;
  transition: all 0.3s ease;
}

.mode-button:hover {
  transform: translateY(-5px);
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.mode-button-icon {
  font-size: 48px;
}

.mode-button-title {
  font-size: 18px;
  font-weight: bold;
}

.mode-button-subtitle {
  font-size: 14px;
  font-weight: bold;
}

.mode-button-desc {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: normal;
  max-width: 100%;
}

/* File Manager */
#fileManagerContainer {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  height: 100%;
  max-height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}

#fileManagerTopbar {
  margin-bottom: 20px;
}

#fileManagerTopbar h3 {
  margin: 0;
  vertical-align: middle;
}

#fileManagerContent {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#fileListSection {
  background-color: var(--bg-secondary);
  border-radius: 8px;
  padding: 20px;
  border: 2px dashed var(--border-color);
  transition: all 0.3s ease;
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

#fileListSection.dragover {
  border-color: var(--link-color);
  background-color: rgba(24, 144, 255, 0.1);
}

#fileListHeader {
  display: flex;
  align-items: center;
  gap: 15px;
  margin-bottom: 15px;
  flex-wrap: wrap;
}

#fileBreadcrumbs {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  color: var(--text-primary);
  font-size: 14px;
}

.breadcrumb-up-btn {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.breadcrumb-up-btn:hover:not(:disabled) {
  background-color: var(--bg-primary);
  border-color: var(--link-color);
}

.breadcrumb-up-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.breadcrumb-item {
  cursor: pointer;
  color: var(--text-primary);
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  padding: 6px 12px;
  border-radius: 4px;
  transition: all 0.2s ease;
  font-size: 13px;
}

.breadcrumb-item:hover {
  background-color: var(--bg-primary);
  border-color: var(--link-color);
}

.breadcrumb-item.active {
  background-color: var(--link-color);
  border-color: var(--link-color);
  color: white;
  cursor: default;
}

.breadcrumb-item.active:hover {
  background-color: var(--link-color);
}

.breadcrumb-separator {
  color: var(--text-muted);
  font-size: 12px;
}

#fileDropzoneOverlay {
  display: none;
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(24, 144, 255, 0.15);
  border-radius: 6px;
  z-index: 10;
  pointer-events: none;
}

#fileListSection.dragover #fileDropzoneOverlay {
  display: flex;
  align-items: center;
  justify-content: center;
}

.dropzone-overlay-content {
  text-align: center;
}

.dropzone-overlay-content .dropzone-icon {
  font-size: 64px;
  margin-bottom: 10px;
}

.dropzone-overlay-content p {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
  font-weight: 500;
}

#fileList {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-height: 400px;
  overflow-y: auto;
}

.file-list-loading {
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
}

.file-item {
  display: flex;
  align-items: center;
  padding: 10px 15px;
  background-color: var(--bg-tertiary);
  border-radius: 4px;
  border: 1px solid var(--border-light);
  transition: background-color 0.2s ease;
}

.file-item:hover {
  background-color: var(--bg-primary);
}

.file-item-icon {
  font-size: 20px;
  margin-right: 10px;
  width: 24px;
  text-align: center;
}

.file-item-name {
  flex: 1;
  color: var(--text-primary);
  word-break: break-all;
}

.file-item-size {
  color: var(--text-muted);
  font-size: 12px;
  margin-right: 15px;
}

.file-item-actions {
  display: flex;
  gap: 5px;
}

.file-item-download,
.file-item-delete {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 16px;
  padding: 5px 8px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  border-radius: 4px;
}

.file-item-download {
  color: var(--link-color);
}

.file-item-delete {
  color: var(--error-color);
}

.file-item-download:hover,
.file-item-delete:hover {
  opacity: 1;
  background-color: var(--bg-secondary);
}

.file-item.folder-item {
  cursor: pointer;
}

.file-item.folder-item:hover {
  background-color: rgba(24, 144, 255, 0.1);
}

.file-list-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 30px;
  font-style: italic;
}

/* Block Editor Styles */
.block-editor {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 20px;
  height: 100%;
  overflow-y: auto;
  background-color: var(--bg-primary);
  padding-bottom: 300px; /* Extra space for adding new blocks at the end */
}

.block-item {
  position: relative;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.block-item:hover {
  border-color: var(--link-color);
}


.block-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
  border-radius: 8px 8px 0 0;
}

.block-controls-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.block-controls-right {
  display: flex;
  align-items: center;
  gap: 5px;
}

.block-type-label {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.block-move-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.block-move-btn:hover:not(:disabled) {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border-color: var(--link-color);
}

.block-move-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.block-edit-btn,
.block-delete-btn {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.block-edit-btn:hover {
  background-color: var(--link-color);
  border-color: var(--link-color);
  color: white;
}

.block-delete-btn:hover {
  background-color: var(--error-color);
  border-color: var(--error-color);
  color: white;
}

.block-preview {
  padding: 15px;
  min-height: 50px;
}

.block-preview-clickable {
  cursor: text;
}

.block-preview-editing {
  padding: 0;
}

.block-preview-editing .inline-panel-editor {
  width: 100%;
}

.block-preview-editing .toastui-editor-defaultUI {
  border: none;
  border-radius: 0 0 8px 8px;
}

/* Block preview content styling - match owo-template */
.block-preview .h-entry {
  margin: 0;
  background-color: transparent;
  border: none;
  padding: 0;
}

.block-preview .h-entry h1,
.block-preview .h-entry h2,
.block-preview .h-entry h3,
.block-preview .h-entry h4,
.block-preview .h-entry h5,
.block-preview .h-entry h6 {
  margin-top: 0;
}

.block-preview .e-content blockquote {
  margin: 0.75rem 0;
  padding: 0.5rem 1rem;
  border-left: 3px solid var(--link-color, #3a86ff);
  background-color: rgba(255, 255, 255, 0.04);
  color: var(--text-secondary, #ccc);
  font-style: italic;
  border-radius: 0 4px 4px 0;
}

.block-preview .e-content blockquote p {
  margin: 0.4rem 0;
}

.block-preview .e-content blockquote p:first-child { margin-top: 0; }
.block-preview .e-content blockquote p:last-child { margin-bottom: 0; }

.block-preview .e-content code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.9em;
  padding: 0.15em 0.35em;
  background-color: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

.block-preview .e-content pre {
  margin: 0.75rem 0;
  padding: 0.85rem 1rem;
  background-color: var(--bg-tertiary, #0a0a0a);
  border: 1px solid var(--border-color, #404040);
  border-radius: 6px;
  overflow-x: auto;
  line-height: 1.5;
  font-size: 0.9rem;
}

.block-preview .e-content pre code {
  background: transparent;
  padding: 0;
  border-radius: 0;
  font-size: inherit;
  white-space: pre;
}

.block-preview .embed-container {
  text-align: center;
}

.block-preview .embed-container iframe {
  max-width: 100%;
  border-radius: 8px;
}

.block-preview .embed-container img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.block-preview .pdf-download-container {
  text-align: center;
  padding: 20px 0;
}

.block-preview .pdf-download-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 25px;
  background-color: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 16px;
  transition: all 0.2s ease;
}

.block-preview .pdf-download-btn:hover {
  border-color: var(--link-color);
  background-color: var(--bg-secondary);
}

.block-preview .pdf-icon {
  font-size: 24px;
}

/* Link Button Block Preview */
.block-preview .link-button-container {
  text-align: center;
  padding: 20px 0;
}

.block-preview .link-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 15px 25px;
  background-color: var(--bg-tertiary);
  border: 2px solid var(--border-color);
  border-radius: 8px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 16px;
  transition: all 0.2s ease;
}

.block-preview .link-button:hover {
  border-color: var(--border-color);
  background-color: var(--bg-secondary);
}

.block-preview .link-icon {
  font-size: 24px;
}

/* Link Button Popup */
.link-button-form .form-group {
  margin-bottom: 16px;
}

.link-button-form .form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-primary);
}

.link-button-form .form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
}

.link-button-form .form-group input:focus {
  outline: none;
  border-color: var(--link-color);
}

.link-button-form .form-hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

/* External Image Popup (Toast UI toolbar) */
.external-image-form .form-group {
  margin-bottom: 16px;
}

.external-image-form .form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 500;
  color: var(--text-primary);
}

.external-image-form .form-group input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
}

.external-image-form .form-group input:focus {
  outline: none;
  border-color: var(--link-color);
}

.external-image-form .form-hint {
  margin-top: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.external-image-preview-wrap {
  margin: 12px 0 16px;
  padding: 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.external-image-preview {
  max-width: 100%;
  max-height: 280px;
  border-radius: 4px;
  display: block;
}

.external-image-preview-status {
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
  text-align: center;
}

/* Toolbar button label styling. Avoid the .toastui-editor-toolbar-icons
   base class on this button — that class paints a sprite background
   (showing the heading icon by default) and uses text-indent: -9999px
   to hide the button's text. We want the emoji visible, so we style
   the standalone class from scratch and force a readable color. */
.external-image-toolbar-btn {
  width: auto !important;
  min-width: 32px;
  height: 24px;
  padding: 0 6px !important;
  background-image: none !important;
  text-indent: 0 !important;
  border: none !important;
  font-size: 16px;
  line-height: 24px;
  color: var(--text-primary) !important;
  white-space: nowrap;
}

/* Add Block Button */
.add-block-wrapper {
  position: relative;
  width: 100%;
}

.add-block-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 8px;
  margin: 8px 0;
  background: transparent;
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.add-block-btn:hover {
  border-color: var(--link-color);
  color: var(--link-color);
  background-color: rgba(24, 144, 255, 0.05);
}

/* Add Block Menu */
.add-block-menu {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  z-index: 10001;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
  padding: 8px 0;
  width: 180px;
}

.add-block-menu.drop-down {
  top: 100%;
  margin-top: 4px;
}

.add-block-menu.drop-up {
  bottom: 100%;
  margin-bottom: 4px;
}


.add-block-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 16px;
  color: var(--text-primary);
  background: transparent;
  border: none;
  text-align: left;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.add-block-menu-item:hover {
  background-color: var(--link-color);
  color: white;
}

.add-block-menu-icon {
  font-size: 18px;
  width: 24px;
  text-align: center;
}

.add-block-menu-label {
  font-size: 14px;
}

/* Panel Edit Modal */
.panel-edit-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-edit-modal-content {
  position: relative;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 90%;
  max-height: 700px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-edit-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
}

.panel-edit-modal-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
}

.panel-edit-modal-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--error-color);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.panel-edit-modal-close:hover {
  background-color: var(--error-color);
  border-color: var(--error-color);
  color: white;
}

.panel-edit-modal-body {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-edit-modal-body #panelEditor {
  flex: 1;
}

.panel-edit-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  background-color: var(--bg-tertiary);
  border-top: 1px solid var(--border-light);
}

.panel-edit-confirm-btn,
.panel-edit-cancel-btn {
  padding: 10px 20px;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-edit-confirm-btn {
  background-color: var(--link-color);
  border: 1px solid var(--link-color);
  color: white;
}

.panel-edit-confirm-btn:hover {
  background-color: var(--link-hover);
  border-color: var(--link-hover);
}

.panel-edit-cancel-btn {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.panel-edit-cancel-btn:hover {
  background-color: var(--bg-secondary);
}

/* Empty state for block editor */
.block-editor-empty {
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
}

.block-editor-empty p {
  margin: 10px 0;
  font-size: 16px;
}

/* Popup overlay for block editor */
.block-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.6);
  z-index: 9999;
}

/* Block popup styles (reused by image, embed, document popups) */
.block-popup {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 0;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
  z-index: 10001;
}

.block-popup .popup-content {
  padding: 20px;
}

.block-popup .popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 15px;
  border-bottom: 1px solid var(--border-light);
}

.block-popup .popup-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
}

.block-popup .popup-close {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--error-color);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.block-popup .popup-close:hover {
  background-color: var(--error-color);
  border-color: var(--error-color);
  color: white;
}

.block-popup .popup-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 15px;
  padding-top: 15px;
  border-top: 1px solid var(--border-light);
}

.block-popup .popup-cancel,
.block-popup .popup-confirm {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.block-popup .popup-cancel {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.block-popup .popup-cancel:hover {
  background-color: var(--bg-tertiary);
}

.block-popup .popup-confirm {
  background-color: var(--link-color);
  border: 1px solid var(--link-color);
  color: white;
}

.block-popup .popup-confirm:hover {
  background-color: var(--link-hover);
  border-color: var(--link-hover);
}

.block-popup .popup-confirm:disabled {
  background-color: var(--bg-tertiary);
  border-color: var(--border-color);
  color: var(--text-muted);
  cursor: not-allowed;
}

.block-popup .popup-confirm:disabled:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--border-color);
}

/* Embed popup specific styles */
.embed-popup .embed-form {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.embed-popup .embed-type-selector {
  display: flex;
  gap: 15px;
  flex-wrap: wrap;
}

.embed-popup .embed-type-selector label {
  display: flex;
  align-items: center;
  gap: 5px;
  color: var(--text-primary);
  cursor: pointer;
}

.embed-popup input[type="text"],
.embed-popup textarea {
  width: 100%;
  padding: 10px;
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--text-primary);
  font-size: 14px;
  box-sizing: border-box;
}

.embed-popup input[type="text"]:focus,
.embed-popup textarea:focus {
  outline: none;
  border-color: var(--link-color);
}

.embed-popup textarea {
  min-height: 100px;
  resize: vertical;
  font-family: 'Courier New', monospace;
}

.embed-popup label {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 5px;
  display: block;
}

/* Document popup specific styles */
.document-upload-popup .document-upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 15px;
}

.document-upload-popup .document-upload-dropzone:hover,
.document-upload-popup .document-upload-dropzone.dragover {
  border-color: var(--link-color);
  background-color: rgba(24, 144, 255, 0.05);
}

.document-upload-popup .document-list-section h4 {
  margin: 0 0 10px 0;
  color: var(--text-primary);
  font-size: 14px;
}

.document-upload-popup .document-list {
  background-color: var(--bg-tertiary);
  border-radius: 4px;
  padding: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.document-upload-popup .document-list-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: 4px;
  transition: background-color 0.2s ease;
}

.document-upload-popup .document-list-item:hover {
  background-color: var(--bg-secondary);
}

.document-upload-popup .document-icon {
  font-size: 18px;
}

.document-upload-popup .document-name {
  flex: 1;
  color: var(--text-primary);
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-upload-popup .document-select-btn {
  background-color: var(--link-color);
  border: none;
  color: white;
  padding: 4px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s ease;
}

.document-upload-popup .document-select-btn:hover {
  background-color: var(--link-hover);
}

.document-upload-popup .list-empty {
  color: var(--text-muted);
  text-align: center;
  padding: 15px;
  font-style: italic;
}

/* Panel edit modal overlay */
.panel-edit-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.panel-edit-modal-overlay .panel-edit-modal {
  position: relative;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 90%;
  max-height: 700px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-edit-modal .panel-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  background-color: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-light);
  width: 100%;
}

.panel-edit-modal .panel-edit-header h3 {
  margin: 0;
  color: var(--text-primary);
  font-size: 18px;
}

.panel-edit-modal .panel-edit-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  color: var(--error-color);
  font-size: 24px;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  z-index: 10;
}

.panel-edit-modal .panel-edit-close:hover {
  background-color: var(--error-color);
  border-color: var(--error-color);
  color: white;
}

.panel-edit-modal .panel-edit-body {
  flex: 1;
  overflow: hidden;
  padding: 0;
  max-width: 100vw;
  width: 100%;
  overflow-x: hidden;
}

.panel-edit-modal .panel-edit-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 15px 20px;
  background-color: var(--bg-tertiary);
  border-top: 1px solid var(--border-light);
}

.panel-edit-modal .panel-edit-cancel,
.panel-edit-modal .panel-edit-confirm {
  padding: 8px 16px;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.panel-edit-modal .panel-edit-cancel {
  background-color: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-primary);
}

.panel-edit-modal .panel-edit-cancel:hover {
  background-color: var(--bg-secondary);
}

.panel-edit-modal .panel-edit-confirm {
  background-color: var(--link-color);
  border: 1px solid var(--link-color);
  color: white;
}

.panel-edit-modal .panel-edit-confirm:hover {
  background-color: var(--link-hover);
  border-color: var(--link-hover);
}


@media (max-width: 768px) {

  #main {
    margin: 0;
    /* padding-top handled by editorBody margin-top set via JavaScript */
  }

  #userMenuContainer {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    text-align: right;
    background-color: var(--bg-tertiary);
    z-index: 10002;
  }

  .dropdown {
    display: inline-block;
  }

  #sites-list-panel {
    min-width: 80%;
    max-width: 95%;
  }

  .sidebar-toggle {
    display: block;
  }

  .editor-sidebar {
    width: 36px !important;
  }

  .editor-sidebar #editorSidebarContent {
    display: none;
  }

  .editor-sidebar:not(.collapsed) {
    width: 220px !important;
    box-shadow: 4px 0 12px rgba(0, 0, 0, 0.3);
  }

  .editor-sidebar:not(.collapsed) #editorSidebarContent {
    display: flex;
  }

  #editorBody {
    margin-left: 36px !important;
  }

  .toastui-editor-tooltip {
    display: none !important;
  }

  .toastui-editor-dropdown-toolbar {
    left: auto !important;
    right: 0 !important;
    max-width: 100% !important;
    height: auto !important;
    flex-wrap: wrap !important;
    height: auto !important;
    overflow: visible !important;
    white-space: normal !important;
  }

  .menu-link {
    font-size: 14pt;
  }

  .h-entry h1 {
    font-size: 16pt;
  }

  .h-entry h2 {
    font-size: 14pt;
  }

  .h-entry h3,
  .h-entry h4,
  .h-entry h5,
  .h-entry h6 {
    font-size: 12pt;
  }

  .h-entry p {
    font-size: 10pt;
  }

  .html-embed-popup {
    width: 95%;
    max-width: none;
    padding: 15px;
  }

  /* Block editor responsive */
  .block-editor {
    padding: 10px;
  }

  .block-controls {
    flex-wrap: wrap;
    gap: 5px;
  }

  .block-popup {
    width: 95%;
    max-width: none;
  }

  .panel-edit-modal-overlay .panel-edit-modal {
    width: 95%;
    max-height: none;
  }

  .add-block-menu {
    min-width: 150px;
  }
}

/* ==================== Onboarding Tour ==================== */

.tour-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 20000;
}

.tour-highlight {
  position: relative;
  z-index: 20001 !important;
  box-shadow: 0 0 0 4px var(--accent-color), 0 0 20px rgba(255, 215, 0, 0.4) !important;
  border-radius: 6px;
}

.tour-popup {
  position: fixed;
  z-index: 20002;
  background: var(--bg-secondary);
  border: 2px solid var(--accent-color);
  border-radius: 10px;
  padding: 16px 20px;
  max-width: 360px;
  min-width: 280px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  color: var(--text-primary);
}

.tour-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.tour-step-indicator {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.tour-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.tour-close-btn:hover {
  color: var(--error-color);
}

.tour-title {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 600;
  color: var(--accent-color);
}

.tour-text {
  margin: 0 0 14px 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary);
}

.tour-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.tour-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 5px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}

.tour-btn-next {
  background: var(--accent-color);
  color: #000;
}

.tour-btn-next:hover {
  background: var(--accent-hover);
}

.tour-btn-back {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
}

.tour-btn-back:hover {
  background: var(--bg-input);
}

/* Math (KaTeX) — block layout and fallback styling for the editor preview. */
.block-preview .math-display {
  margin: 1rem 0;
  overflow-x: auto;
}

.block-preview .katex-fallback {
  color: var(--text-muted, #b89a4d);
  border: 1px dashed var(--text-muted, #b89a4d);
  background: transparent;
}

.block-preview .katex-fallback-display {
  display: block;
  padding: 0.5rem 0.75rem;
  margin: 1rem 0;
  text-align: center;
  white-space: pre-wrap;
}
