/* ═══════════════════════════════════════════════════════════════
   NotepadAG – Adaptive Theme Stylesheet (Dark + Light)
   ═══════════════════════════════════════════════════════════════ */

/* ── Design Tokens ────────────────────────────────────────────── */
:root {
  /* Palette */
  --clr-bg:          #0d0f1a;
  --clr-surface:     #13162a;
  --clr-surface-2:   #1a1e35;
  --clr-surface-3:   #202540;
  --clr-border:      rgba(255,255,255,0.06);
  --clr-border-soft: rgba(255,255,255,0.04);

  /* Accent */
  --clr-accent:      #6c63ff;
  --clr-accent-glow: rgba(108,99,255,0.25);
  --clr-accent-2:    #00d9ff;
  --clr-accent-3:    #ff6b9d;
  --clr-accent-soft: rgba(108,99,255,0.14);
  --clr-accent-soft-2: rgba(108,99,255,0.08);
  --clr-focus-ring:  rgba(108,99,255,0.30);
  --clr-selected-text: #f7f8ff;
  --clr-selected-icon: #f7f8ff;
  --clr-selected-meta: rgba(247,248,255,0.78);
  --clr-selected-badge-bg: rgba(247,248,255,0.14);
  --clr-selected-bg:  var(--clr-accent);
  --clr-selection-fill: rgba(108,99,255,0.30);
  --clr-accent-hover: #7c74ff;
  --clr-danger-hover: #e0284c;
  --shadow-danger: 0 4px 16px rgba(244,63,94,0.3);

  /* Text */
  --clr-text:        #e4e6f0;
  --clr-text-muted:  #7a7fa0;
  --clr-text-faint:  #474b70;
  --clr-brand-text-start: #f2f5ff;
  --clr-brand-text-end:   #7be3ff;
  --clr-button-hover-border: rgba(255,255,255,0.12);
  --clr-thumb-border: rgba(255,255,255,0.92);
  --clr-overlay: rgba(0,0,0,0.55);
  --clr-overlay-soft: rgba(0,0,0,0.50);

  /* Control Surfaces */
  --clr-key-surface: var(--clr-surface-2);
  --clr-key-surface-hover: var(--clr-surface-3);

  /* Shadows */
  --shadow-elevated: 0 24px 64px rgba(0,0,0,0.6);
  --shadow-floating: 0 12px 40px rgba(0,0,0,0.5);
  --shadow-toast:    0 8px 30px rgba(0,0,0,0.4);
  --shadow-panel:   -24px 0 60px rgba(0,0,0,0.45);
  --shadow-card:
    0 40px 80px rgba(0,0,0,0.5),
    0 0 0 1px rgba(255,255,255,0.04),
    inset 0 1px 0 rgba(255,255,255,0.06);
  --shadow-auth-key: 0 4px 16px rgba(0,0,0,0.2);
  --shadow-thumb: 0 0 8px var(--clr-accent-glow), 0 2px 6px rgba(0,0,0,0.3);
  --shadow-thumb-hover: 0 0 16px var(--clr-accent-glow), 0 2px 8px rgba(0,0,0,0.4);

  /* Status */
  --clr-success:     #22d3a5;
  --clr-warning:     #f59e0b;
  --clr-danger:      #f43f5e;
  --clr-danger-bg:   rgba(244,63,94,0.12);

  /* Geometry */
  --radius-sm:   6px;
  --radius-md:   10px;
  --radius-lg:   14px;
  --radius-xl:   18px;

  /* Motion */
  --ease-out:    cubic-bezier(0.22, 1, 0.36, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Typography */
  --ui-font:      'Inter', system-ui, sans-serif;
  --pane-font:    'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
  --ui-font-size: 14px;

  /* Sidebar */
  --sidebar-w:  260px;
  --sidebar-current-w: var(--sidebar-w);
  --sidebar-header-h: 56px;
  --topbar-h:   44px;
}

/* ── Light Theme Tokens ───────────────────────────────────────── */
[data-theme="light"] {
  /* Palette */
  --clr-bg:          #f0f2f8;
  --clr-surface:     #ffffff;
  --clr-surface-2:   #edf0f7;
  --clr-surface-3:   #e2e6f0;
  --clr-border:      rgba(0,0,0,0.08);
  --clr-border-soft: rgba(0,0,0,0.05);

  /* Accent – same vibrancy, slightly deeper for contrast */
  --clr-accent:      #5a52e0;
  --clr-accent-glow: rgba(90,82,224,0.18);
  --clr-accent-2:    #0099cc;
  --clr-accent-3:    #e8457a;
  --clr-accent-soft: rgba(90,82,224,0.12);
  --clr-accent-soft-2: rgba(90,82,224,0.08);
  --clr-focus-ring:  rgba(90,82,224,0.24);
  --clr-selected-text: #ffffff;
  --clr-selected-icon: rgba(255,255,255,0.96);
  --clr-selected-meta: rgba(255,255,255,0.78);
  --clr-selected-badge-bg: rgba(255,255,255,0.18);
  --clr-selected-bg:  var(--clr-accent);
  --clr-selection-fill: rgba(90,82,224,0.22);
  --clr-accent-hover: #4d45cf;
  --clr-danger-hover: #c8244a;
  --shadow-danger: 0 4px 16px rgba(220,38,83,0.2);

  /* Text */
  --clr-text:        #1a1d2e;
  --clr-text-muted:  #474e67;
  --clr-text-faint:  #727b96;
  --clr-brand-text-start: #243055;
  --clr-brand-text-end:   #167aa8;
  --clr-button-hover-border: rgba(15,23,42,0.12);
  --clr-thumb-border: rgba(255,255,255,0.96);
  --clr-overlay: rgba(23,33,62,0.26);
  --clr-overlay-soft: rgba(23,33,62,0.22);

  /* Control Surfaces */
  --clr-key-surface: #f4f6fc;
  --clr-key-surface-hover: #e8ecf8;

  /* Shadows */
  --shadow-elevated: 0 22px 56px rgba(44,59,101,0.18);
  --shadow-floating: 0 14px 36px rgba(44,59,101,0.16);
  --shadow-toast:    0 10px 28px rgba(44,59,101,0.14);
  --shadow-panel:   -24px 0 60px rgba(44,59,101,0.18);
  --shadow-card:
    0 40px 80px rgba(44,59,101,0.18),
    0 0 0 1px rgba(90,82,224,0.08);
  --shadow-auth-key: 0 2px 8px rgba(44,59,101,0.10);
  --shadow-thumb: 0 0 8px var(--clr-accent-glow), 0 2px 6px rgba(44,59,101,0.18);
  --shadow-thumb-hover: 0 0 16px var(--clr-accent-glow), 0 4px 10px rgba(44,59,101,0.22);

  /* Status */
  --clr-success:     #0faa82;
  --clr-warning:     #d97706;
  --clr-danger:      #dc2653;
  --clr-danger-bg:   rgba(220,38,83,0.10);
}

/* ── Theme Transition ─────────────────────────────────────────── */
html.theme-transitioning {
  transition:
    background-color 0.22s ease,
    color 0.22s ease;
}

html.theme-transitioning *,
html.theme-transitioning *::before,
html.theme-transitioning *::after {
  transition-property: background-color, border-color, color, box-shadow, outline-color;
  transition-duration: 0.22s;
  transition-timing-function: ease;
}

@media (prefers-reduced-motion: reduce) {
  html.theme-transitioning,
  html.theme-transitioning *,
  html.theme-transitioning *::before,
  html.theme-transitioning *::after {
    transition: none !important;
  }
}

/* ── Reset ────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: var(--ui-font);
  font-size: var(--ui-font-size);
  background: var(--clr-bg);
  color: var(--clr-text);
  -webkit-font-smoothing: antialiased;
}

input, textarea, button { font-family: var(--ui-font); }
ul { list-style: none; }
a { color: inherit; text-decoration: none; }

/* ── Scrollbar ────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--clr-surface-3); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--clr-text-faint); }

/* ══════════════════════════════════════════════════════════════
   LAYOUT
   ══════════════════════════════════════════════════════════════ */

body {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ──────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-current-w);
  min-width: var(--sidebar-current-w);
  height: 100vh;
  background: var(--clr-surface);
  border-right: 1px solid var(--clr-border);
  display: flex;
  flex-direction: column;
  transition: width 0.28s var(--ease-out), min-width 0.28s var(--ease-out),
              transform 0.28s var(--ease-out);
  overflow: hidden;
  flex-shrink: 0;
  z-index: 100;
}

.sidebar.collapsed {
  width: 0;
  min-width: 0;
  border-right-color: transparent;
}

.sidebar-resizer {
  width: 5px;
  flex-shrink: 0;
  cursor: col-resize;
  background: var(--clr-border-soft);
  position: relative;
  z-index: 110;
  transition: background 0.15s, width 0.2s var(--ease-out), opacity 0.2s var(--ease-out);
}

.sidebar-resizer:hover,
.sidebar-resizer.active {
  background: var(--clr-accent);
}

.sidebar-resizer::after {
  content: '';
  position: absolute;
  inset: 0 -4px;
  background: transparent;
}

.sidebar.collapsed + .sidebar-resizer {
  width: 0;
  opacity: 0;
  pointer-events: none;
}

body.sidebar-resizing {
  cursor: col-resize;
  user-select: none;
}

/* ── Sidebar Header ─────────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  height: var(--sidebar-header-h);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
  min-width: 0;
}

.brand-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px var(--clr-accent-glow);
  overflow: hidden;
}

.brand-icon-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: inherit;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
  background: linear-gradient(135deg, var(--clr-brand-text-start) 30%, var(--clr-brand-text-end) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-description {
  margin-top: 1px;
  font-size: 10px;
  line-height: 1.2;
  color: var(--clr-text-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Sidebar Actions ─────────────────────────────────────────── */
.sidebar-actions {
  padding: 12px 12px 8px;
  flex-shrink: 0;
}

.sidebar-action-row {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.sidebar-action-btn {
  flex: 1;
  justify-content: center;
  align-items: center;
  min-width: 0;
  padding: 0;
  height: 40px;
  aspect-ratio: 1;
}

.sidebar-action-btn svg {
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
}

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

#searchInput {
  width: 100%;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  color: var(--clr-text);
  padding: 7px 34px 7px 30px;
  font-size: 13px;
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}

#searchInput::placeholder { color: var(--clr-text-faint); }
#searchInput:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-glow);
}

.search-clear-btn {
  position: absolute;
  right: 7px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: var(--clr-text-faint);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.search-clear-btn:hover {
  background: var(--clr-surface-3);
  color: var(--clr-text);
}

.search-clear-btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--clr-accent-soft);
}

/* ── Notes List Label ─────────────────────────────────────────── */
.notes-list-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--clr-text-faint);
  flex-shrink: 0;
}

.notes-list-heading {
  display: flex;
  align-items: center;
  gap: 8px;
}

.notes-count {
  background: var(--clr-surface-3);
  border-radius: 99px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  color: var(--clr-text-muted);
}

.tree-toggle-btn {
  width: 24px;
  height: 24px;
  min-width: 24px;
  border-radius: 7px;
  color: var(--clr-text-faint);
}

.tree-toggle-btn:hover:not(:disabled),
.tree-toggle-btn.active {
  color: var(--clr-text);
  background: var(--clr-surface-2);
}

.tree-toggle-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ── Notes List ───────────────────────────────────────────────── */
.notes-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.folder-node {
  display: block;
  min-width: 0;
}

.folder-children {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.folder-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  padding-left: calc(10px + var(--tree-depth, 0) * 14px);
  border-radius: var(--radius-sm);
  color: var(--clr-text-muted);
  cursor: pointer;
  user-select: none;
  min-width: 0;
}

.folder-row[draggable="true"] {
  cursor: grab;
}

.folder-row.dragging {
  opacity: 0.35;
}

.folder-row:hover {
  background: var(--clr-surface-2);
  color: var(--clr-text);
}

.folder-row.selected {
  background: var(--clr-selected-bg);
  color: var(--clr-selected-text);
  box-shadow: inset 0 0 0 1px var(--clr-focus-ring);
}

.folder-row.selected .folder-icon { color: var(--clr-selected-icon); }
.folder-row.selected .folder-count {
  color: var(--clr-selected-meta);
  background: var(--clr-selected-badge-bg);
}

.folder-row.drag-over {
  background: var(--clr-accent-soft-2);
  outline: 1px dashed var(--clr-accent);
  outline-offset: -2px;
}

.root-folder-row {
  margin-bottom: 2px;
  border-bottom: 1px solid var(--clr-border-soft);
}

.folder-toggle {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.folder-toggle:hover {
  background: var(--clr-surface-3);
}

.folder-toggle.hidden {
  visibility: hidden;
}

.folder-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--clr-accent-2);
  flex-shrink: 0;
}

.folder-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-count {
  font-size: 10px;
  color: var(--clr-text-faint);
  padding: 1px 6px;
  border-radius: 99px;
  background: var(--clr-surface-3);
  flex-shrink: 0;
}

.note-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  padding-left: calc(10px + var(--tree-depth, 0) * 14px);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  position: relative;
  user-select: none;
  white-space: nowrap;
  overflow: hidden;
  min-width: 0;
}

.note-item:hover { background: var(--clr-surface-2); }
.note-item.active {
  background: var(--clr-selected-bg);
  color: var(--clr-selected-text);
}
.note-item.active .note-icon { color: var(--clr-selected-icon); }
.note-item.active .note-meta { color: var(--clr-selected-meta); }

.note-item[draggable="true"] { cursor: grab; }
.note-item.dragging { opacity: 0.35; }

.note-icon {
  flex-shrink: 0;
  color: var(--clr-text-faint);
  transition: color 0.15s;
}

.note-title {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-meta {
  font-size: 10px;
  color: var(--clr-text-faint);
  flex-shrink: 0;
}

.note-modified-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--clr-accent);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.2s;
}

.note-modified-dot.visible { opacity: 1; }

.notes-empty-state {
  color: var(--clr-text-faint);
  font-size: 12px;
  padding: 10px 12px 10px 24px;
}

/* ── Sidebar Footer ───────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid var(--clr-border);
  padding: 10px 16px;
  flex-shrink: 0;
}

.sidebar-footer-info {
  font-size: 11px;
  color: var(--clr-text-faint);
}

/* ══════════════════════════════════════════════════════════════
   MAIN LAYOUT
   ══════════════════════════════════════════════════════════════ */

.main-layout {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ── Topbar ───────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 0 12px;
  border-bottom: 1px solid var(--clr-border);
  background: var(--clr-surface);
  flex-shrink: 0;
  backdrop-filter: blur(12px);
  z-index: 90;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.topbar-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--clr-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  flex-shrink: 0;
}

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

/* ── View Mode Switcher ───────────────────────────────────────── */
.view-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.view-mode-switcher {
  display: flex;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.layout-mode-switcher {
  display: flex;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  padding: 3px;
  gap: 2px;
}

.view-mode-btn,
.layout-mode-btn {
  width: 32px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 5px;
  color: var(--clr-text-faint);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.view-mode-btn {
  font-size: 12px;
  font-weight: 700;
}

.view-mode-btn:hover,
.layout-mode-btn:hover {
  background: var(--clr-surface-3);
  color: var(--clr-text);
}

.view-mode-btn.active,
.layout-mode-btn.active {
  background: var(--clr-accent);
  color: #fff;
  box-shadow: 0 0 10px var(--clr-accent-glow);
}

.layout-mode-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.layout-mode-btn:disabled:hover {
  background: transparent;
  color: var(--clr-text-faint);
}

.pane-count-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  height: 36px;
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  background: var(--clr-surface-2);
  color: var(--clr-text-muted);
}

.pane-count-control span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#viewModeCount {
  width: 58px;
  border: 1px solid var(--clr-border);
  border-radius: 5px;
  background: var(--clr-surface);
  color: var(--clr-text);
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  outline: none;
}

#viewModeCount:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-glow);
}

/* ── Auto-save indicator ──────────────────────────────────────── */
.autosave-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--clr-text-faint);
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  background: var(--clr-surface-2);
  transition: color 0.3s;
}

.autosave-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--clr-success);
  transition: background 0.3s;
}

.autosave-indicator.saving { color: var(--clr-warning); }
.autosave-indicator.saving .autosave-dot { background: var(--clr-warning); animation: pulse 0.8s infinite; }
.autosave-indicator.saved  { color: var(--clr-success); }
.autosave-indicator.saved  .autosave-dot { background: var(--clr-success); }
.autosave-indicator.error  { color: var(--clr-danger); }
.autosave-indicator.error  .autosave-dot { background: var(--clr-danger); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.4; transform: scale(0.7); }
}

/* ══════════════════════════════════════════════════════════════
   EDITOR AREA
   ══════════════════════════════════════════════════════════════ */

.editor-area {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
  background: var(--clr-bg);
}

.editor-area.layout-vertical {
  flex-direction: row;
}

.editor-area.layout-horizontal {
  flex-direction: column;
}

.pane-row {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  width: 100%;
}

/* Empty state */
.empty-state {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--clr-text-muted);
  pointer-events: none;
}

.empty-state.hidden { display: none; }

.empty-state-icon {
  color: var(--clr-text-faint);
  opacity: 0.4;
}

.empty-state h2 { font-size: 20px; font-weight: 600; color: var(--clr-text-muted); }
.empty-state p { font-size: 13px; color: var(--clr-text-faint); }
.empty-state .btn-primary { pointer-events: all; margin-top: 4px; }

/* ── Pane ─────────────────────────────────────────────────────── */
.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  position: relative;
  background: var(--clr-bg);
  transition: outline 0.15s;
}

.pane.focused { outline: 1px solid var(--clr-focus-ring); outline-offset: -1px; }

/* Drag-over highlight */
.pane.drag-over {
  background: var(--clr-accent-soft-2);
  outline: 2px dashed var(--clr-accent);
  outline-offset: -3px;
}

/* ── Pane Tab Bar ─────────────────────────────────────────────── */
.pane-header {
  display: flex;
  flex-direction: column;
  background: var(--clr-surface);
  border-bottom: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.pane-tabbar,
.pane-toolbar {
  display: flex;
  align-items: center;
  min-width: 0;
}

.pane-tabbar {
  padding: 2px 8px 0;
  gap: 8px;
}

.pane-toolbar {
  min-height: 22px;
  padding: 0 8px 2px;
  gap: 6px;
}

.pane-tabs {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.pane-tabs::-webkit-scrollbar {
  display: none;
}

.pane-tabs-empty {
  font-size: 11px;
  font-weight: 600;
  color: var(--clr-text-faint);
  padding-left: 2px;
  white-space: nowrap;
}

.pane-tab {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  max-width: 220px;
  min-width: 0;
  border: 1px solid var(--clr-border);
  border-radius: 8px 8px 0 0;
  background: var(--clr-surface-2);
  color: var(--clr-text-faint);
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pane-tab.active {
  background: var(--clr-bg);
  color: var(--clr-text);
  border-color: var(--clr-border);
  border-bottom-color: var(--clr-bg);
}

.pane-tab-button,
.pane-tab-close-btn {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

.pane-tab-button {
  min-width: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 10px;
  color: inherit;
  line-height: 1.1;
}

.pane-tab-close-btn {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  margin-right: 3px;
}

.pane-tab-close-btn:hover {
  background: var(--clr-surface);
  color: var(--clr-text);
}

.pane-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11px;
  font-weight: 600;
}

.pane-tab-dirty-dot {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--clr-accent);
  opacity: 0;
  transform: scale(0.7);
  transition: opacity 0.15s, transform 0.15s;
  flex-shrink: 0;
}

.pane-tab.dirty .pane-tab-dirty-dot {
  opacity: 1;
  transform: scale(1);
}

.pane-title {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  color: var(--clr-text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.pane-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 1;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.pane-actions::-webkit-scrollbar {
  display: none;
}

.pane-list-select {
  height: 20px;
  max-width: 96px;
  padding: 0 20px 0 6px;
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  background: var(--clr-surface-2);
  color: var(--clr-text-muted);
  font-family: inherit;
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.pane-list-select:hover {
  background: var(--clr-surface);
  color: var(--clr-text);
}

.pane-list-select:focus {
  border-color: var(--clr-accent);
  color: var(--clr-text);
  box-shadow: 0 0 0 3px var(--clr-accent-soft);
}

.pane-action-group {
  display: flex;
  align-items: center;
  gap: 1px;
  padding: 0;
  border: 1px solid var(--clr-border);
  border-radius: 6px;
  background: var(--clr-surface-2);
  flex-shrink: 0;
}

.pane-font-controls {
  gap: 2px;
  padding-inline: 2px;
}

.pane-font-size-label {
  min-width: 30px;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--clr-text-faint);
  font-variant-numeric: tabular-nums;
}

.pane-icon-btn,
.pane-download-btn,
.pane-close-btn {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--clr-text-faint);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.pane-icon-btn:hover { background: var(--clr-surface); color: var(--clr-text); }
.pane-download-btn:hover { background: var(--clr-surface-2); color: var(--clr-text); }
.pane-close-btn:hover { background: var(--clr-danger-bg); color: var(--clr-danger); }
.pane-icon-btn.active {
  background: var(--clr-accent-soft);
  color: var(--clr-accent-2);
}

.pane-icon-btn svg {
  display: block;
}

.pane-action-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.topbar-icon-action {
  display: inline-flex;
  align-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  gap: 0;
  justify-content: center;
  font-size: 0;
}

.topbar-icon-action svg {
  width: 18px;
  height: 18px;
  display: block;
  flex-shrink: 0;
  vector-effect: non-scaling-stroke;
}

.pane-icon-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pane-download-btn:disabled,
.pane-tab-button:disabled,
.pane-tab-close-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pane-icon-btn:disabled:hover {
  background: transparent;
  color: var(--clr-text-faint);
}

.pane-download-btn:disabled:hover,
.pane-tab-button:disabled:hover,
.pane-tab-close-btn:disabled:hover {
  background: transparent;
  color: inherit;
}

@media (max-width: 900px) {
  .pane-tabbar {
    gap: 6px;
  }

  .pane-toolbar {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 4px 6px;
    padding-top: 2px;
    padding-bottom: 4px;
  }

  .pane-tab {
    max-width: 160px;
  }

  .pane-title {
    flex-basis: 100%;
  }

  .pane-actions {
    width: 100%;
  }

  .pane-list-select {
    max-width: 84px;
    padding-right: 20px;
  }

  .pane-font-size-label {
    min-width: 24px;
    font-size: 9px;
  }
}

.pane-drop-indicator {
  font-size: 11px;
  color: var(--clr-text-faint);
  padding: 4px 8px;
  border: 1px dashed var(--clr-border);
  border-radius: var(--radius-sm);
  white-space: nowrap;
}

/* ── Textarea ─────────────────────────────────────────────────── */
.pane-editor {
  flex: 1;
  width: 100%;
  resize: none;
  background: var(--clr-bg);
  color: var(--clr-text);
  border: none;
  outline: none;
  padding: 18px 22px;
  font-family: var(--pane-font);
  font-size: 14px;
  line-height: 1.7;
  tab-size: 2;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  overflow-y: auto;
  caret-color: var(--clr-accent);
  scrollbar-width: auto;
  scrollbar-color: var(--clr-surface-3) transparent;
}

.pane-editor-nowrap {
  white-space: pre;
  overflow-x: auto;
  overflow-wrap: normal;
}

.pane-editor::-webkit-scrollbar {
  width: 7px;
  height: 7px;
}

.pane-editor::-webkit-scrollbar-track {
  background: transparent;
}

.pane-editor::-webkit-scrollbar-thumb {
  background: var(--clr-surface-3);
  border-radius: 99px;
}

.pane-editor::-webkit-scrollbar-thumb:hover {
  background: var(--clr-text-faint);
}

.pane-editor::selection { background: var(--clr-selection-fill); }

/* ── Pane Status Bar ──────────────────────────────────────────── */
.pane-statusbar {
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  font-size: 10px;
  color: var(--clr-text-faint);
  background: var(--clr-surface);
  border-top: 1px solid var(--clr-border);
  flex-shrink: 0;
}

.pane-statusbar-left { display: flex; align-items: center; gap: 10px; }
.pane-statusbar-right { display: flex; align-items: center; gap: 10px; }

/* ── Resizer ──────────────────────────────────────────────────── */
.resizer {
  flex-shrink: 0;
  background: var(--clr-border-soft);
  transition: background 0.15s;
  position: relative;
  z-index: 10;
}

.resizer.vertical {
  width: 5px;
  cursor: col-resize;
}

.resizer.horizontal {
  height: 5px;
  cursor: row-resize;
  width: 100%;
}

.resizer:hover,
.resizer.active {
  background: var(--clr-accent);
}

.resizer::after {
  content: '';
  position: absolute;
  background: transparent;
}
.resizer.vertical::after   { inset: 0 -4px; }
.resizer.horizontal::after { inset: -4px 0; }

/* ── Layout Modes ─────────────────────────────────────────────── */
.editor-area.layout-grid {
  flex-direction: column;
}

/* ══════════════════════════════════════════════════════════════
   BUTTONS
   ══════════════════════════════════════════════════════════════ */

.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--clr-accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
}

.btn-primary:hover {
  background: var(--clr-accent-hover);
  box-shadow: 0 4px 20px var(--clr-accent-glow);
}

.btn-primary:active { transform: scale(0.97); }
.btn-primary:disabled,
.btn-ghost:disabled {
  opacity: 0.6;
  cursor: wait;
  box-shadow: none;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--clr-surface-2);
  color: var(--clr-text-muted);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

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

.btn-danger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--clr-danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
}

.btn-danger:hover {
  background: var(--clr-danger-hover);
  box-shadow: var(--shadow-danger);
}

.btn-danger:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  box-shadow: none;
}

.icon-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--clr-text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

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

/* ── Theme Toggle Button ──────────────────────────────────────── */
#fullscreenToggle,
#themeToggle {
  position: relative;
  overflow: hidden;
}

#fullscreenToggle .fullscreen-icon-enter,
#fullscreenToggle .fullscreen-icon-exit,
#themeToggle .theme-icon-dark,
#themeToggle .theme-icon-light {
  position: absolute;
  inset: 0;
  margin: auto;
  display: block;
  pointer-events: none;
  transform-origin: center;
  transition: opacity 0.2s, transform 0.25s var(--ease-spring);
}

#fullscreenToggle .fullscreen-icon-exit {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

#themeToggle .theme-icon-light {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

[data-fullscreen="true"] #fullscreenToggle .fullscreen-icon-enter {
  opacity: 0;
  transform: rotate(90deg) scale(0.6);
}

[data-fullscreen="true"] #fullscreenToggle .fullscreen-icon-exit {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

[data-theme="light"] #themeToggle .theme-icon-dark {
  opacity: 0;
  transform: rotate(-90deg) scale(0.6);
}

[data-theme="light"] #themeToggle .theme-icon-light {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* ══════════════════════════════════════════════════════════════
   CONTEXT MENU
   ══════════════════════════════════════════════════════════════ */

.context-menu {
  position: fixed;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-floating), 0 0 0 1px var(--clr-border);
  min-width: 160px;
  z-index: 9999;
  overflow: hidden;
  backdrop-filter: blur(10px);
  animation: ctxFadeIn 0.12s var(--ease-out);
}

@keyframes ctxFadeIn {
  from { opacity: 0; transform: scale(0.95) translateY(-4px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.context-menu.hidden { display: none; }

.ctx-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 14px;
  font-size: 13px;
  color: var(--clr-text);
  cursor: pointer;
  transition: background 0.1s;
}

.ctx-item:hover { background: var(--clr-surface-3); }
.ctx-item.danger { color: var(--clr-danger); }
.ctx-item.danger:hover { background: var(--clr-danger-bg); }
.ctx-item.hidden { display: none; }

/* ══════════════════════════════════════════════════════════════
   CUSTOM TOOLTIP
   ══════════════════════════════════════════════════════════════ */

.app-tooltip {
  --tooltip-anchor: 50%;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 100000;
  max-width: min(280px, calc(100vw - 24px));
  padding: 10px 13px;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  background:
    linear-gradient(135deg, rgba(108,99,255,0.18), rgba(0,217,255,0.08)),
    rgba(13,15,26,0.92);
  color: var(--clr-text);
  box-shadow:
    0 18px 40px rgba(4, 8, 18, 0.42),
    0 0 0 1px rgba(255,255,255,0.03);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.01em;
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px) scale(0.96);
  transform-origin: center;
  transition: opacity 0.16s var(--ease-out), transform 0.18s var(--ease-out);
}

.app-tooltip::after {
  content: '';
  position: absolute;
  left: clamp(18px, var(--tooltip-anchor), calc(100% - 18px));
  width: 12px;
  height: 12px;
  background: inherit;
  border-radius: 3px;
  border: inherit;
  transform: translateX(-50%) rotate(45deg);
}

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

.app-tooltip[data-placement="top"]::after {
  bottom: -7px;
  border-left: 0;
  border-top: 0;
}

.app-tooltip[data-placement="bottom"] {
  transform: translateY(-8px) scale(0.96);
}

.app-tooltip[data-placement="bottom"].visible {
  transform: translateY(0) scale(1);
}

.app-tooltip[data-placement="bottom"]::after {
  top: -7px;
  border-right: 0;
  border-bottom: 0;
}

[data-theme="light"] .app-tooltip {
  border-color: rgba(90,82,224,0.12);
  background:
    linear-gradient(135deg, rgba(90,82,224,0.14), rgba(0,153,204,0.06)),
    rgba(255,255,255,0.92);
  box-shadow:
    0 18px 36px rgba(44, 59, 101, 0.16),
    0 0 0 1px rgba(255,255,255,0.4);
}

/* ══════════════════════════════════════════════════════════════
   MODALS
   ══════════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--clr-overlay);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  animation: fadeIn 0.18s var(--ease-out);
}

.modal-overlay.hidden { display: none; }

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal {
  background: var(--clr-surface);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-lg);
  width: 420px;
  max-width: calc(100vw - 32px);
  box-shadow: var(--shadow-elevated);
  animation: modalIn 0.22s var(--ease-spring);
}

@keyframes modalIn {
  from { opacity: 0; transform: scale(0.92) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

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

.modal-header h3 { font-size: 16px; font-weight: 600; }

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

.modal-body label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--clr-text-muted);
  letter-spacing: 0.04em;
  margin-bottom: 7px;
}

.modal-body input,
.modal-body select {
  width: 100%;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-sm);
  color: var(--clr-text);
  padding: 10px 12px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.modal-body input:focus,
.modal-body select:focus {
  border-color: var(--clr-accent);
  box-shadow: 0 0 0 3px var(--clr-accent-glow);
}

.modal-field-spacer {
  margin-top: 14px;
}

.input-hint { font-size: 11px; color: var(--clr-text-faint); margin-top: 6px; }

.modal-body p { font-size: 14px; color: var(--clr-text-muted); line-height: 1.5; }
.modal-body .danger-text { font-size: 12px; color: var(--clr-danger); margin-top: 4px; }
.modal-body input[aria-invalid="true"] {
  border-color: var(--clr-danger);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--clr-danger) 20%, transparent);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  padding: 14px 20px 18px;
  border-top: 1px solid var(--clr-border);
}

/* ══════════════════════════════════════════════════════════════
   TOASTS
   ══════════════════════════════════════════════════════════════ */

.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 99999;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-toast);
  font-size: 13px;
  color: var(--clr-text);
  min-width: 240px;
  max-width: 360px;
  backdrop-filter: blur(8px);
  animation: toastIn 0.25s var(--ease-spring);
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(24px) scale(0.95); }
  to   { opacity: 1; transform: translateX(0) scale(1); }
}

.toast.removing { animation: toastOut 0.2s var(--ease-out) forwards; }
@keyframes toastOut {
  to { opacity: 0; transform: translateX(24px) scale(0.95); }
}

.toast-icon { flex-shrink: 0; }
.toast.success .toast-icon { color: var(--clr-success); }
.toast.error   .toast-icon { color: var(--clr-danger); }
.toast.info    .toast-icon { color: var(--clr-accent-2); }
.toast.warning .toast-icon { color: var(--clr-warning); }

/* ══════════════════════════════════════════════════════════════
   MISC UTILITIES
   ══════════════════════════════════════════════════════════════ */

.hidden { display: none !important; }

/* Drag-ghost style */
.drag-ghost {
  background: var(--clr-surface-2);
  border: 1px solid var(--clr-accent);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--clr-text);
  position: fixed;
  top: -100px;
  left: -100px;
  pointer-events: none;
  z-index: 99999;
}

/* Pane drop zone empty text */
.pane-drop-zone {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 10px;
  color: var(--clr-text-faint);
  font-size: 13px;
  padding: 20px;
  text-align: center;
}

.pane-drop-zone svg { opacity: 0.3; }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  :root { --sidebar-w: 240px; }
  .sidebar { position: fixed; left: 0; top: 0; height: 100%; z-index: 200; transform: translateX(0); }
  .sidebar.collapsed { transform: translateX(-100%); width: var(--sidebar-w) !important; min-width: var(--sidebar-w) !important; }
  .sidebar-resizer { display: none; }
  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    padding: 8px 12px;
    flex-wrap: wrap;
    align-items: flex-start;
  }
  .topbar-left,
  .topbar-center,
  .topbar-right {
    width: 100%;
  }
  .topbar-center,
  .topbar-right {
    justify-content: flex-start;
  }
  .topbar-right {
    flex-wrap: wrap;
  }
  .view-controls {
    width: 100%;
    flex-wrap: wrap;
  }
  .pane-count-control {
    width: 100%;
    justify-content: space-between;
  }
  #viewModeCount {
    width: 72px;
  }
  #downloadAllBtn,
  #saveAllBtn {
    width: 32px;
    height: 32px;
    padding: 0;
    gap: 0;
    font-size: 0;
    justify-content: center;
  }
}
