/* ================================================
   LadiPage Admin — GitBook-style Redesign
   ================================================ */

:root {
  --color-bg: #FFFFFF;
  --color-surface: #FFFFFF;
  --color-sidebar-bg: #FBFBFB;
  --color-surface-hover: #F6F8FA;
  --color-surface-active: #EFF2F5;
  --color-border: #E6E6E6;
  --color-border-light: #F0F0F0;
  --color-text: #1F2328;
  --color-text-secondary: #656D76;
  --color-text-muted: #8B949E;
  --color-primary: #346DDB;
  --color-primary-hover: #2B5FC7;
  --color-primary-soft: rgba(52, 109, 219, 0.08);
  --color-primary-medium: rgba(52, 109, 219, 0.15);
  --color-success: #1A7F37;
  --color-success-soft: rgba(26, 127, 55, 0.08);
  --color-warning: #9A6700;
  --color-warning-soft: rgba(154, 103, 0, 0.08);
  --color-danger: #CF222E;
  --color-danger-soft: rgba(207, 34, 46, 0.06);
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
  --sidebar-width: 260px;
  --right-panel-width: 280px;
  --topbar-height: 48px;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition: 0.2s ease;
  --transition-fast: 0.15s ease;
}

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

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: #D0D7DE;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #8B949E;
}

/* ============ LOGIN ============ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #f0f4ff 0%, #e8eeff 50%, #f5f0ff 100%);
}

.login-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo svg {
  margin-bottom: 16px;
}

.login-logo h1 {
  font-size: 1.375rem;
  font-weight: 700;
}

.login-logo p {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

/* ============ FORMS ============ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"],
.form-group input[type="url"],
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 0.8125rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.form-group small {
  display: block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.form-group input[type="checkbox"] {
  accent-color: var(--color-primary);
}

.error-message {
  background: var(--color-danger-soft);
  color: var(--color-danger);
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  margin-bottom: 16px;
}

.input-prefix-wrap {
  display: flex;
  align-items: center;
}

.input-prefix {
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  background: var(--color-surface-hover);
  padding: 9px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius) 0 0 var(--radius);
  border-right: none;
  line-height: 1;
}

.input-prefix-wrap input {
  border-radius: 0 var(--radius) var(--radius) 0 !important;
  flex: 1;
}

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  border: none;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--color-primary);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--color-text-secondary);
  border: 1px solid var(--color-border);
}

.btn-ghost:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.btn-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.btn-danger:hover {
  background: var(--color-danger);
  color: #fff;
}

.btn-block {
  width: 100%;
  justify-content: center;
  padding: 10px;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.btn-icon:hover {
  color: var(--color-text);
  background: var(--color-surface-active);
}

/* ============ PANEL SPLITTERS ============ */
.panel-splitter {
  position: fixed;
  top: 0;
  bottom: 0;
  width: 6px;
  cursor: col-resize;
  z-index: 150;
  transition: background 0.15s;
}

.panel-splitter::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 2px;
  width: 2px;
  background: transparent;
  transition: background 0.15s;
}

.panel-splitter:hover::after,
.panel-splitter.dragging::after {
  background: var(--color-primary, #346DDB);
}

#splitter-left {
  left: calc(var(--sidebar-width) - 3px);
}

#splitter-right {
  right: calc(var(--right-panel-width) - 3px);
  display: none;
}

body.panel-resizing {
  user-select: none !important;
  cursor: col-resize !important;
}

body.panel-resizing * {
  cursor: col-resize !important;
}

/* ============ APP SHELL ============ */
#app-shell {
  display: flex;
  min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar-bg);
  border-right: 1px solid var(--color-border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-header {
  padding: 16px 16px 8px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-text);
  text-decoration: none;
}

.sidebar-brand svg {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}

.product-switcher {
  display: none;
  width: 100%;
  margin-top: 8px;
  padding: 6px 8px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
}

.product-switcher:hover {
  border-color: var(--color-primary);
}

.product-switcher:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(52, 109, 219, 0.15);
}

.sidebar-search {
  padding: 0 12px 8px;
}

.sidebar-search-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.sidebar-search-btn:hover {
  border-color: var(--color-primary);
}

.sidebar-search-btn span {
  flex: 1;
  text-align: left;
}

.sidebar-search-btn kbd {
  font-size: 0.625rem;
  padding: 1px 5px;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font);
}

.sidebar-actions {
  padding: 0 12px 8px;
  display: flex;
  gap: 6px;
}

.sidebar-new-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: transparent;
  border: 1px dashed var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.sidebar-new-folder-btn {
  flex: 0 0 auto;
  padding: 6px 8px;
}

.sidebar-new-btn:hover {
  border-color: var(--color-primary);
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.sidebar-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 8px 8px 4px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-toggle-all {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: all 0.15s;
}

.sidebar-toggle-all:hover {
  color: var(--color-text);
  background: var(--color-surface-hover);
}

.sidebar-toggle-all svg {
  transition: transform 0.2s;
  transform: rotate(-90deg);
}

.sidebar-toggle-all.expanded svg {
  transform: rotate(0deg);
}

/* Sidebar Tree Nav Items */
.sidebar-tree-nav .tree-folder {
  margin-bottom: 2px;
}

.sidebar-tree-nav .tree-folder-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--color-text);
  transition: all var(--transition);
  user-select: none;
  overflow: hidden;
  min-width: 0;
}

.sidebar-tree-nav .tree-folder-header>span:not(.folder-icon):not(.tree-actions) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  flex: 1;
}

.sidebar-tree-nav .tree-folder-header:hover {
  background: var(--color-surface-hover);
}

/* Folder arrow icon — hidden */
.sidebar-tree-nav .tree-folder-header .folder-icon {
  display: none;
}

/* Collapsed: arrow points right */
.sidebar-tree-nav .tree-folder-header.collapsed .folder-icon {
  transform: rotate(-90deg);
  opacity: 0.4;
}

/* Expanded folder: blue text/icon only, no background */
.sidebar-tree-nav .tree-folder-header:not(.collapsed) {
  color: var(--color-primary);
}

.sidebar-tree-nav .tree-folder-header:not(.collapsed) .folder-icon {
  color: var(--color-primary);
  opacity: 0.8;
}

.sidebar-tree-nav .tree-folder-header:not(.collapsed) .tree-icon {
  color: var(--color-primary);
}

.sidebar-tree-nav .tree-folder-header .tree-icon {
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: color var(--transition);
}

/* Folder children — vertical guide line */
.sidebar-tree-nav .tree-folder-children {
  padding-left: 10px;
  margin-left: 12px;
  border-left: 1.5px solid var(--color-border);
  margin-top: 2px;
  margin-bottom: 2px;
}

.sidebar-tree-nav .tree-folder-children.hidden {
  display: none;
}

/* File items */
.sidebar-tree-nav .tree-file {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  gap: 8px;
  margin-bottom: 2px;
}

.sidebar-tree-nav .tree-file:hover {
  background: var(--color-surface-hover);
}

/* Active file: color only, no background */
.sidebar-tree-nav .tree-file.active {
  background: none;
}

.sidebar-tree-nav .tree-file.active .tree-file-title {
  color: var(--color-text);
  font-weight: 600;
}

.sidebar-tree-nav .tree-file.active .tree-icon {
  color: var(--color-primary);
}

.sidebar-tree-nav .tree-file .tree-icon {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

/* ---- Tree Action Buttons ---- */
.tree-actions {
  margin-left: auto;
  display: flex;
  opacity: 0;
  transition: opacity 0.1s;
  flex-shrink: 0;
}

.tree-folder-header:hover .tree-actions,
.tree-file:hover .tree-actions {
  opacity: 1;
}

.tree-action-btn {
  background: none;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--color-text-muted);
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  transition: all 0.1s;
}

.tree-action-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
}

/* ---- Drag & Drop States ---- */
.sidebar-tree-nav .tree-file {
  cursor: grab;
  transition: all 0.15s ease;
  position: relative;
}

.sidebar-tree-nav .tree-file:active {
  cursor: grabbing;
}

.tree-dragging {
  opacity: 0.35;
  transform: scale(0.97);
  background: var(--color-surface-hover);
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Drop indicator line — above */
.tree-drop-above {
  position: relative;
}

.tree-drop-above::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--color-primary);
  border-radius: 1px;
  z-index: 10;
  animation: dropLineAppear 0.15s ease;
}

.tree-drop-above::after {
  content: '';
  position: absolute;
  top: -4px;
  left: 4px;
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
  z-index: 11;
  animation: dropLineAppear 0.15s ease;
}

/* Drop indicator line — below */
.tree-drop-below {
  position: relative;
}

.tree-drop-below::before {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 8px;
  right: 8px;
  height: 2px;
  background: var(--color-primary);
  border-radius: 1px;
  z-index: 10;
  animation: dropLineAppear 0.15s ease;
}

.tree-drop-below::after {
  content: '';
  position: absolute;
  bottom: -4px;
  left: 4px;
  width: 8px;
  height: 8px;
  background: var(--color-primary);
  border-radius: 50%;
  z-index: 11;
  animation: dropLineAppear 0.15s ease;
}

/* Drop inside folder — class on header directly or on folder>header */
.tree-folder-header.tree-drop-inside,
.tree-drop-inside>.tree-folder-header,
.tree-file.tree-drop-inside {
  background: var(--color-primary-soft) !important;
  border-radius: 6px;
  outline: 2px dashed var(--color-primary);
  outline-offset: -2px;
}

/* Folder header drag cursor */
.sidebar-tree-nav .tree-folder-header {
  cursor: grab;
}

.sidebar-tree-nav .tree-folder-header:active {
  cursor: grabbing;
}

@keyframes dropLineAppear {
  from {
    opacity: 0;
    transform: scaleX(0.5);
  }

  to {
    opacity: 1;
    transform: scaleX(1);
  }
}

/* Make tree-file flex for action alignment */
.sidebar-tree-nav .tree-file {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tree-file-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.tree-file-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

/* ---- Floating Tooltip (appended to body via JS) ---- */
.tree-tooltip {
  position: fixed;
  padding: 5px 10px;
  background: var(--color-text);
  color: var(--color-bg);
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.4;
  white-space: normal;
  word-break: break-word;
  max-width: 400px;
  border-radius: 6px;
  z-index: 9999;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.1s ease, transform 0.1s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.tree-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Sidebar Footer */
.sidebar-footer {
  border-top: 1px solid var(--color-border);
  padding: 8px;
}

.sidebar-footer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  font-family: var(--font);
  width: 100%;
  text-align: left;
  text-decoration: none;
}

.sidebar-footer-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.sidebar-footer-item.active {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.sidebar-footer-divider {
  height: 1px;
  background: var(--color-border-light);
  margin: 4px 8px;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
}

.sidebar-user-avatar {
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: var(--color-primary-soft);
  color: var(--color-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  flex-shrink: 0;
}

.sidebar-user-name {
  flex: 1;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.sidebar-user-settings {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

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

/* Settings Dropdown (fixed to avoid overflow clip) */
.settings-dropdown {
  display: none;
  position: fixed;
  min-width: 210px;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.15);
  padding: 6px;
  z-index: 300;
  animation: settingsSlideUp 0.15s ease;
}

.settings-dropdown.open {
  display: block;
}

@keyframes settingsSlideUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: none;
  border: none;
  border-radius: var(--radius-md);
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  cursor: pointer;
  transition: all 0.1s;
  text-decoration: none;
}

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

.settings-dropdown-item svg {
  flex-shrink: 0;
  opacity: 0.6;
}

.settings-dropdown-divider {
  height: 1px;
  background: var(--border-color);
  margin: 4px 8px;
}

.settings-dropdown-logout:hover {
  color: var(--color-danger);
}

.settings-dropdown-logout:hover svg {
  opacity: 1;
}

/* Sidebar Overlay (mobile) */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  z-index: 89;
}

.sidebar-overlay.active {
  display: block;
}

/* ============ MAIN CONTENT ============ */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ============ TOPBAR (minimal) ============ */
.topbar {
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 60;
}

.hamburger-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.hamburger-btn:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.breadcrumbs {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  flex: 1;
  min-width: 0;
}

.breadcrumbs .separator {
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin: 0 6px;
  font-size: 0.875rem;
}

.breadcrumb-parent {
  display: inline-block;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  vertical-align: middle;
}

.breadcrumbs .current {
  display: inline-block;
  color: var(--color-text);
  font-weight: 500;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.save-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  padding: 4px 8px;
}

.save-status .save-icon-check {
  color: var(--color-success);
}

.topbar-dot-menu {
  position: relative;
}

.dropdown-menu {
  position: absolute;
  top: 100%;
  right: 0;
  min-width: 200px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  padding: 4px;
  z-index: 500;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 10px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.dropdown-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.dropdown-item-danger:hover {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--color-border-light);
  margin: 4px 0;
}

/* ============ PAGE CONTENT ============ */
.page-content-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ============ RIGHT PANEL ============ */
.right-panel {
  width: var(--right-panel-width);
  min-width: var(--right-panel-width);
  background: var(--color-surface);
  border-left: 1px solid var(--color-border);
  position: fixed;
  top: var(--topbar-height);
  right: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 50;
  display: flex;
  flex-direction: column;
}

.right-panel-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  background: var(--color-surface);
  z-index: 1;
  flex-shrink: 0;
}

.right-panel-tab {
  flex: 1;
  padding: 10px 8px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
  border-bottom: 2px solid transparent;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.right-panel-tab:hover {
  color: var(--color-text);
}

.right-panel-tab.active {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
}

.right-panel-content {
  padding: 16px;
  flex: 1;
  overflow-y: auto;
}

/* ---- Right panel form groups ---- */
.right-panel-group {
  margin-bottom: 16px;
}

.right-panel-group label {
  display: block;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.right-panel-group input,
.right-panel-group textarea {
  width: 100%;
  padding: 8px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 0.8125rem;
  outline: none;
  transition: all var(--transition);
  box-sizing: border-box;
}

.right-panel-group textarea {
  resize: vertical;
  min-height: 52px;
}

.right-panel-group input:focus,
.right-panel-group textarea:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

/* Input prefix (slug field) */
.input-prefix-wrap {
  display: flex;
  align-items: center;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--color-surface);
  transition: all var(--transition);
}

.input-prefix-wrap:focus-within {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.input-prefix {
  padding: 8px 6px 8px 10px;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
  font-family: var(--font);
  user-select: none;
  flex-shrink: 0;
}

.input-prefix-wrap input {
  border: none !important;
  box-shadow: none !important;
  padding-left: 0;
  flex: 1;
  min-width: 0;
}

/* ---- Outline ---- */
.outline-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.outline-item {
  display: block;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  border: none;
  background: none;
  font-family: var(--font);
  width: 100%;
  text-align: left;
  text-decoration: none;
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.outline-item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text);
}

.outline-item.level-1 {
  font-weight: 600;
}

.outline-item.level-2 {
  padding-left: 20px;
  font-size: 0.8125rem;
}

.outline-item.level-3 {
  padding-left: 32px;
  font-size: 0.75rem;
}

.outline-item.level-4 {
  padding-left: 44px;
  font-size: 0.75rem;
}

.outline-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

/* ---- Editor status info ---- */
.editor-status-info {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-status-info .meta-tag {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  word-break: break-all;
  line-height: 1.4;
}

/* ============ TOGGLE SWITCHES ============ */
.right-panel-toggles {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--color-border-light);
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  gap: 10px;
}

.toggle-label {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  flex: 1;
  min-width: 0;
}

.toggle-switch {
  position: relative;
  width: 36px;
  height: 20px;
  border: none;
  border-radius: 10px;
  background: #d1d5db;
  cursor: pointer;
  transition: background 0.2s;
  padding: 0;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.toggle-switch.active {
  background: var(--color-primary);
}

.toggle-switch.active::after {
  transform: translateX(16px);
}

/* ============ TAGS ============ */
.tags-container {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: var(--color-primary-soft);
  color: var(--color-primary);
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
}

.tag-chip .tag-remove {
  cursor: pointer;
  font-size: 0.75rem;
  opacity: 0.6;
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  line-height: 1;
}

.tag-chip .tag-remove:hover {
  opacity: 1;
}

.welcome-page {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
}

.welcome-content {
  text-align: center;
  max-width: 400px;
  padding: 40px 20px;
}

.welcome-content h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.welcome-content p {
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  margin-bottom: 24px;
  line-height: 1.7;
}

/* ============ EDITOR ============ */
.editor-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  margin-right: var(--right-panel-width);
  overflow: hidden;
}

.editor-container {
  flex: 1;
  overflow: hidden;
}

.toastui-editor-defaultUI {
  border: none !important;
}

.toastui-editor-defaultUI .toastui-editor-toolbar {
  background: var(--color-surface) !important;
  border-bottom: 1px solid var(--color-border) !important;
}

.toastui-editor-defaultUI .toastui-editor-toolbar button {
  color: var(--color-text-secondary) !important;
  border: none !important;
}

.toastui-editor-defaultUI .toastui-editor-toolbar button:hover,
.toastui-editor-defaultUI .toastui-editor-toolbar button.active {
  background: var(--color-primary-soft) !important;
  color: var(--color-primary) !important;
}

.toastui-editor-defaultUI .toastui-editor-mode-switch {
  background: var(--color-surface) !important;
  border-top: 1px solid var(--color-border) !important;
}

.toastui-editor-defaultUI .toastui-editor-mode-switch .tab-item {
  background: transparent !important;
  color: var(--color-text-secondary) !important;
  border: 1px solid var(--color-border) !important;
}

.toastui-editor-defaultUI .toastui-editor-mode-switch .tab-item.active {
  background: var(--color-primary-soft) !important;
  color: var(--color-primary) !important;
}

.toastui-editor-contents {
  font-family: var(--font);
  font-size: 0.9375rem;
}

.toastui-editor-ww-container {
  background: var(--color-surface) !important;
}

.ProseMirror {
  min-height: 500px;
  padding: 20px 28px !important;
}

/* ============ SUBPAGE LAYOUT ============ */
.subpage-layout {
  padding: 24px 28px;
  max-width: 900px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
}

/* Media page needs full width */
.subpage-layout:has(.media-layout) {
  max-width: 100%;
}

.subpage-header {
  margin-bottom: 20px;
}

.subpage-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-top: 8px;
}

.subpage-header .page-subtitle {
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  margin-top: 2px;
}

.subpage-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
}

.subpage-body {
  max-width: 720px;
}

/* ============ BADGES ============ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-published {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.badge-draft {
  background: var(--color-warning-soft);
  color: var(--color-warning);
}

.badge-deleted {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.badge-success {
  background: var(--color-success-soft);
  color: var(--color-success);
}

.badge-danger {
  background: var(--color-danger-soft);
  color: var(--color-danger);
}

.badge-primary {
  background: rgba(52, 109, 219, 0.12);
  color: #346DDB;
}

.badge-muted {
  background: var(--bg-tertiary);
  color: var(--text-muted);
}

/* Data Table */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

.data-table th,
.data-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.data-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--bg-secondary);
}

.data-table tbody tr:hover {
  background: var(--bg-secondary);
}

.data-table code {
  font-size: 0.75rem;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

/* Button extra-small */
.btn-xs {
  padding: 3px 6px;
  font-size: 0.6875rem;
  border-radius: var(--radius-sm);
}

.text-danger {
  color: var(--color-danger) !important;
}

/* Page panel section */
.page-panel-section h3 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 12px;
  color: var(--text-primary);
}

/* Lock Banner */
.lock-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(245, 166, 35, 0.12);
  border: 1px solid rgba(245, 166, 35, 0.3);
  border-radius: var(--radius-md);
  color: #b5840a;
  font-size: 0.8125rem;
  margin-bottom: 12px;
}

.lock-banner svg {
  flex-shrink: 0;
  color: #d4960b;
}

/* Presence Bar */
.presence-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  margin-right: 8px;
}

.presence-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  font-size: 0.5625rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: default;
  border: 2px solid var(--bg-primary);
}

.presence-avatar:nth-child(2) {
  background: linear-gradient(135deg, #10b981, #059669);
}

.presence-avatar:nth-child(3) {
  background: linear-gradient(135deg, #f59e0b, #d97706);
}

.presence-avatar:nth-child(4) {
  background: linear-gradient(135deg, #ef4444, #dc2626);
}

.presence-avatar+.presence-avatar {
  margin-left: -6px;
}

/* Presence Dot (sidebar) */
.presence-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  margin-left: 4px;
  flex-shrink: 0;
  animation: presencePulse 2s ease-in-out infinite;
}

@keyframes presencePulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.4;
  }
}

/* Activity List */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  transition: background 0.1s;
}

.activity-item:hover {
  background: var(--bg-secondary);
}

.activity-icon {
  font-size: 0.8125rem;
  white-space: nowrap;
}

.activity-detail {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.activity-detail strong {
  color: var(--text-primary);
}

.activity-detail code {
  font-size: 0.75rem;
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
}

.activity-time {
  margin-left: 6px;
  color: var(--text-muted);
  font-size: 0.6875rem;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: var(--radius);
  background: var(--color-surface-hover);
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
}



/* ============ TOOLBAR ============ */
.toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 200px;
  position: relative;
}

.search-box input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  color: var(--color-text);
  font-family: var(--font);
  font-size: 0.8125rem;
  outline: none;
  transition: all var(--transition);
}

.search-box input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-soft);
}

.search-icon-svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-text-muted);
  pointer-events: none;
}

.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--color-surface-hover);
  border-radius: var(--radius);
  padding: 2px;
}

.view-toggle button {
  padding: 5px 8px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: all var(--transition);
}

.view-toggle button.active {
  background: var(--color-surface);
  color: var(--color-text);
  box-shadow: var(--shadow-xs);
}

/* ============ MEDIA PAGE ============ */
.media-page {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: 100%;
}

.media-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 20px 24px;
  min-width: 0;
}

/* Topbar */
.media-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.media-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
}

.media-bc-link {
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color 0.15s;
}

.media-bc-link:hover {
  color: var(--color-primary);
}

.media-bc-sep {
  color: var(--color-text-muted);
}

.media-bc-current {
  font-weight: 600;
  color: var(--color-text);
}

.media-topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Grid */
.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 16px;
  flex: 1;
  overflow-y: auto;
  align-content: start;
  padding-bottom: 20px;
}

/* Details Panel */
.media-details-panel {
  width: 300px;
  flex-shrink: 0;
  padding: 20px;
  border-left: 1px solid var(--color-border);
  overflow-y: auto;
  background: var(--color-surface);
}

.media-panel-title {
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 16px;
}

/* Cards */
.media-card {
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.media-card:hover .media-card-preview {
  border-color: #94a3b8;
  box-shadow: var(--shadow-sm);
}

.media-card.selected .media-card-preview {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary-soft);
}

.media-card .select-check {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: white;
  display: none;
  align-items: center;
  justify-content: center;
  font-size: 0.6875rem;
}

.media-card.selected .select-check {
  display: flex;
}

.media-card-preview {
  width: 100%;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  transition: all 0.15s;
}

.media-card-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.media-card-name {
  font-size: 0.75rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 8px;
  color: var(--color-text);
}

.media-card-meta {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

/* Video/PDF icons */
.media-video-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.4);
}

.media-file-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: var(--color-text-muted);
}

.media-file-icon span {
  font-size: 0.625rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-primary);
}

/* Drop zone */
.drop-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  margin-bottom: 16px;
  transition: all var(--transition);
  color: var(--color-text-muted);
  background: var(--color-surface);
  cursor: pointer;
}

.drop-zone:hover,
.drop-zone.active {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

.drop-zone p {
  font-size: 0.8125rem;
  margin-top: 4px;
}

/* File Details Panel sections */
.fd-preview {
  width: 100%;
  aspect-ratio: 4/3;
  border-radius: 10px;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  margin-bottom: 16px;
}

.fd-preview img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.fd-preview-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
}

.fd-section {
  margin-bottom: 14px;
}

.fd-label {
  font-size: 0.625rem;
  font-weight: 700;
  color: var(--color-primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 3px;
}

.fd-value {
  font-size: 0.8125rem;
  color: var(--color-text);
}

.fd-filename {
  font-weight: 600;
}

.fd-row {
  display: flex;
  gap: 16px;
}

.fd-divider {
  height: 1px;
  background: var(--color-border);
  margin: 16px 0;
}

.fd-copy-box {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin-top: 6px;
}

.fd-copy-inner {
  flex: 1;
  min-width: 0;
}

.fd-copy-label {
  display: block;
  font-size: 0.625rem;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.fd-copy-value {
  display: block;
  font-size: 0.75rem;
  font-family: monospace;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fd-copy-btn {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s;
  flex-shrink: 0;
}

.fd-copy-btn:hover {
  color: var(--color-primary);
  background: var(--color-primary-soft);
}

.fd-btn-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  transition: opacity 0.15s;
}

.fd-btn-copy:hover {
  opacity: 0.9;
}

.fd-btn-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 10px;
  background: white;
  color: var(--color-danger);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  margin-top: 10px;
  transition: all 0.15s;
}

.fd-btn-delete:hover {
  border-color: var(--color-danger);
  background: #fef2f2;
}

/* List view */
.media-grid.list-view {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.media-grid.list-view .media-card {
  display: flex;
  align-items: center;
  gap: 12px;
}

.media-grid.list-view .media-card-preview {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 6px;
}

.media-grid.list-view .media-card-name {
  margin-top: 0;
}

.media-grid.list-view .media-card-meta {
  margin-top: 0;
}

/* ============ SETTINGS ============ */
.settings-section {
  margin-bottom: 32px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--color-border);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.settings-section .section-desc {
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
  margin-bottom: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.settings-grid .form-group {
  margin-bottom: 0;
}

.branding-row {
  display: flex;
  gap: 32px;
  flex-wrap: wrap;
}

.branding-item {
  display: flex;
  align-items: center;
  gap: 16px;
}

.branding-preview {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  background: var(--color-surface-hover);
  border: 2px dashed var(--color-border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: 1.25rem;
}

.branding-info .branding-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.branding-info .branding-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-bottom: 6px;
}

/* ============ ACTIVITY ============ */
.activity-list .activity-item {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  align-items: flex-start;
  transition: all var(--transition);
}

.activity-item:hover {
  box-shadow: var(--shadow-sm);
}

.activity-item .activity-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.activity-icon.commit {
  background: var(--color-primary-soft);
}

.activity-icon.create {
  background: var(--color-success-soft);
}

.activity-icon.delete {
  background: var(--color-danger-soft);
}

.activity-icon.update {
  background: var(--color-warning-soft);
}

.activity-item .activity-info {
  flex: 1;
  min-width: 0;
}

.activity-item .activity-message {
  font-size: 0.8125rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.activity-item .activity-meta {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.activity-item .activity-hash {
  font-family: monospace;
  font-size: 0.6875rem;
  color: var(--color-primary);
  align-self: center;
}

/* ============ TRASH & HISTORY ============ */
.trash-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 6px;
}

.trash-item:hover {
  box-shadow: var(--shadow-sm);
}

.trash-item-info {
  flex: 1;
}

.trash-item-path {
  font-size: 0.8125rem;
  font-weight: 600;
}

.trash-item-date {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  margin-bottom: 6px;
  gap: 12px;
}

.history-item:hover {
  box-shadow: var(--shadow-sm);
}

.history-item-info {
  flex: 1;
}

.history-item-message {
  font-size: 0.8125rem;
  font-weight: 600;
}

.history-item-meta {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.history-item-hash {
  font-family: monospace;
  font-size: 0.6875rem;
  color: var(--color-primary);
}

.history-item-actions {
  display: flex;
  gap: 6px;
}

/* ============ SIDEBAR EDITOR ============ */
.sidebar-editor-hint {
  background: var(--color-primary-soft);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 0.8125rem;
  color: var(--color-primary);
}

.sidebar-tree .sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  margin-bottom: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: grab;
  transition: all var(--transition);
  font-size: 0.8125rem;
}

.sidebar-tree .sb-item:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-xs);
}

.sidebar-tree .sb-item.dragging {
  opacity: 0.5;
  background: var(--color-primary-soft);
}

.sidebar-tree .sb-item .sb-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.sidebar-tree .sb-item .sb-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-tree .sb-item .sb-label-input {
  flex: 1;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-primary);
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--color-text);
  font-family: var(--font);
  font-size: 0.8125rem;
  outline: none;
}

.sidebar-tree .sb-item .sb-type {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
  padding: 1px 6px;
  background: var(--color-surface-hover);
  border-radius: 4px;
}

.sidebar-tree .sb-item .sb-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity var(--transition);
}

.sidebar-tree .sb-item:hover .sb-actions {
  opacity: 1;
}

.sidebar-tree .sb-item .sb-actions button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
  padding: 2px;
  transition: color var(--transition);
}

.sidebar-tree .sb-item .sb-actions button:hover {
  color: var(--color-danger);
}

.sidebar-tree .sb-children {
  padding-left: 20px;
  border-left: 1px dashed var(--color-border);
  margin-left: 12px;
}

.sidebar-tree .sb-add-child {
  padding: 5px 10px;
  margin: 4px 0;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  cursor: pointer;
  border-radius: var(--radius);
  transition: all var(--transition);
}

.sidebar-tree .sb-add-child:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary);
}

/* ============ MODALS ============ */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: modalFadeIn 0.15s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.modal-content {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.15s ease;
}

@keyframes modalSlideIn {
  from {
    transform: translateY(-8px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.modal-content h3 {
  font-size: 1rem;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}

.modal-lg {
  max-width: 640px;
}

.modal-header-flex {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

/* ============ COMPONENT PALETTE ============ */
.component-categories {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.component-categories .cat-btn {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  color: var(--color-text-secondary);
  font-family: var(--font);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all var(--transition);
}

.component-categories .cat-btn:hover {
  border-color: var(--color-primary);
}

.component-categories .cat-btn.active {
  background: var(--color-primary-soft);
  border-color: var(--color-primary);
  color: var(--color-primary);
}

.component-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  max-height: 360px;
  overflow-y: auto;
}

.component-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}

.component-card:hover {
  border-color: var(--color-primary);
  background: var(--color-primary-soft);
}

.component-card .cc-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.component-card .cc-info {
  flex: 1;
  min-width: 0;
}

.component-card .cc-name {
  font-size: 0.8125rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.component-card .cc-desc {
  font-size: 0.625rem;
  color: var(--color-text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.component-form {
  margin-top: 12px;
}

.component-form-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.component-form-header h4 {
  font-size: 0.875rem;
}

.component-preview {
  margin-top: 10px;
  padding: 10px;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-family: monospace;
  font-size: 0.75rem;
  white-space: pre-wrap;
  color: var(--color-primary);
  max-height: 180px;
  overflow-y: auto;
}

/* ============ SEARCH OVERLAY ============ */
.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 120px;
}

.search-overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(2px);
}

.search-overlay-content {
  position: relative;
  width: 100%;
  max-width: 560px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.search-overlay-input-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--color-border);
}

.search-overlay-input-wrap svg {
  flex-shrink: 0;
  color: var(--color-text-muted);
}

.search-overlay-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font-family: var(--font);
  font-size: 0.9375rem;
  color: var(--color-text);
  background: transparent;
}

.search-overlay-input-wrap kbd {
  font-size: 0.625rem;
  padding: 2px 6px;
  background: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  font-family: var(--font);
  color: var(--color-text-muted);
}

.search-results {
  max-height: 400px;
  overflow-y: auto;
}

.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font);
}

.search-result-item:hover {
  background: var(--color-surface-hover);
}

.search-result-item .sr-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text);
}

.search-result-item .sr-path {
  font-size: 0.6875rem;
  color: var(--color-text-muted);
}

.search-no-results {
  text-align: center;
  padding: 24px;
  color: var(--color-text-muted);
  font-size: 0.8125rem;
}

/* ============ TOAST ============ */
.toast-container {
  position: fixed;
  top: 12px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: toastSlideIn 0.3s ease;
  display: flex;
  align-items: center;
  gap: 8px;
}

.toast-success {
  background: #fff;
  color: var(--color-success);
  border: 1px solid rgba(26, 127, 55, 0.15);
}

.toast-error {
  background: #fff;
  color: var(--color-danger);
  border: 1px solid rgba(207, 34, 46, 0.15);
}

.toast-info {
  background: #fff;
  color: var(--color-primary);
  border: 1px solid rgba(52, 109, 219, 0.15);
}

@keyframes toastSlideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* ============ LOADING ============ */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--color-text-secondary);
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

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

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--color-text-secondary);
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 10px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 0.875rem;
}

/* ============ PRODUCTS MANAGEMENT ============ */
.products-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.product-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color 0.15s;
}

.product-card:hover {
  border-color: var(--color-primary);
}

.product-card-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--color-primary-bg, rgba(52, 109, 219, 0.08));
  color: var(--color-primary);
  flex-shrink: 0;
}

.product-card-body {
  flex: 1;
  min-width: 0;
}

.product-card-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text);
}

.product-card-meta {
  display: flex;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 2px;
}

.product-card-meta code {
  background: var(--color-bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.7rem;
}

.product-card-actions {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-shrink: 0;
}

.badge-default {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 500;
  background: var(--color-primary-bg, rgba(52, 109, 219, 0.08));
  color: var(--color-primary);
}

/* Dynamic modal overlay (appended to body) */
.dyn-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
  animation: modalFadeIn 0.15s ease;
}

.dyn-modal {
  position: relative;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modalSlideIn 0.15s ease;
}

.dyn-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--color-border);
}

.dyn-modal-header h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin: 0;
}

.dyn-modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

.dyn-modal-close:hover {
  color: var(--color-text);
}

.dyn-modal-body {
  padding: 20px;
}

.dyn-modal-body .form-group {
  margin-bottom: 14px;
}

.dyn-modal-body .form-group:last-child {
  margin-bottom: 0;
}

.dyn-modal-body label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--color-text);
  margin-bottom: 6px;
}

.dyn-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px;
  border-top: 1px solid var(--color-border);
}

.form-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg);
  color: var(--color-text);
  font-size: 0.85rem;
  outline: none;
  box-sizing: border-box;
}

.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px rgba(52, 109, 219, 0.15);
}

/* ============ RESPONSIVE ============ */
@media (max-width: 1200px) {
  .right-panel {
    width: 240px;
  }

  .editor-wrap {
    margin-right: 240px;
  }
}

@media (max-width: 1024px) {
  .right-panel {
    display: none;
  }

  .editor-wrap {
    margin-right: 0;
  }

  .media-details-panel {
    display: none;
  }
}

@media (max-width: 768px) {
  .hamburger-btn {
    display: flex;
  }

  .sidebar {
    left: -260px;
    transition: left 0.3s ease;
    box-shadow: none;
  }

  .sidebar.open {
    left: 0;
    box-shadow: var(--shadow-lg);
  }

  .main-content {
    margin-left: 0;
  }

  .settings-grid {
    grid-template-columns: 1fr;
  }

  .branding-row {
    flex-direction: column;
    gap: 16px;
  }

  .media-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

@media (max-width: 480px) {
  .subpage-layout {
    padding: 16px;
  }

  .modal-content {
    margin: 12px;
    padding: 20px;
  }
}

/* ================================================
   Context Menu
   ================================================ */
.ctx-menu {
  position: fixed;
  z-index: 9999;
  min-width: 180px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
  padding: 4px;
  font-family: var(--font);
  animation: ctx-fade-in 0.12s ease-out;
}

@keyframes ctx-fade-in {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-4px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.ctx-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 5px;
  font-size: 0.8125rem;
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.1s;
}

.ctx-menu-item:hover {
  background: var(--color-surface-hover);
}

.ctx-menu-item svg {
  flex-shrink: 0;
  opacity: 0.55;
}

.ctx-menu-item.ctx-danger {
  color: #e53e3e;
}

.ctx-menu-item.ctx-danger:hover {
  background: #fff5f5;
}

.ctx-menu-item.ctx-disabled {
  opacity: 0.35;
  pointer-events: none;
}

.ctx-menu-sep {
  height: 1px;
  background: var(--color-border);
  margin: 3px 6px;
}