/* ==========================================================================
   Privates Notizentool – Editorial Design System (Light & Dark Mode + PWA)
   ========================================================================== */

:root {
  /* Light Mode (Bright, Fresh & Airy) */
  --bg-app: #f8fafc;
  --bg-sidebar: #f1f5f9;
  --bg-sidebar-hover: #e2e8f0;
  --bg-sidebar-active: #ccfbf1;
  --text-sidebar: #334155;
  --text-sidebar-muted: #64748b;
  --text-sidebar-active: #0f766e;
  --sidebar-border: #e2e8f0;
  --sidebar-title-color: #0f172a;
  --sidebar-input-bg: #ffffff;
  --sidebar-input-border: #cbd5e1;

  --bg-list: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-hover: #f0fdfa;
  --bg-card-active: #f0fdfa;
  --border-card-active: #14b8a6;

  --bg-editor: #ffffff;
  --bg-toolbar: rgba(255, 255, 255, 0.95);
  --bg-subtle: #f1f5f9;
  --bg-input: #ffffff;

  --text-primary: #0f172a;
  --text-secondary: #334155;
  --text-muted: #64748b;
  --text-faint: #94a3b8;

  --border-color: #e2e8f0;
  --border-strong: #cbd5e1;

  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-gradient: linear-gradient(135deg, #14b8a6 0%, #0284c7 100%);
  --accent-soft: #ccfbf1;
  --accent-text: #0f766e;

  --danger: #e11d48;
  --danger-soft: #ffe4e6;
  --success: #059669;
  --success-soft: #d1fae5;

  --mark-bg: #fef08a;
  --mark-text: #854d0e;

  --shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-md: 0 4px 14px rgba(15, 23, 42, 0.07);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.12);

  --font-sans: 'Plus Jakarta Sans', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', Consolas, monospace;

  --sidebar-width: 270px;
  --list-width: 360px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
}

[data-theme="dark"] {
  --bg-app: #0b1120;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: rgba(255, 255, 255, 0.06);
  --bg-sidebar-active: rgba(20, 184, 166, 0.18);
  --text-sidebar: #cbd5e1;
  --text-sidebar-muted: #64748b;
  --text-sidebar-active: #2dd4bf;
  --sidebar-border: #1e293b;
  --sidebar-title-color: #f8fafc;
  --sidebar-input-bg: rgba(255, 255, 255, 0.05);
  --sidebar-input-border: rgba(255, 255, 255, 0.12);

  --bg-list: #0f172a;
  --bg-card: #162032;
  --bg-card-hover: #1e293b;
  --bg-card-active: #132a2e;
  --border-card-active: #14b8a6;

  --bg-editor: #111827;
  --bg-toolbar: rgba(17, 24, 39, 0.92);
  --bg-subtle: #1e293b;
  --bg-input: #1e293b;

  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  --border-color: #1e293b;
  --border-strong: #334155;

  --accent: #14b8a6;
  --accent-hover: #0d9488;
  --accent-gradient: linear-gradient(135deg, #14b8a6 0%, #0284c7 100%);
  --accent-soft: rgba(20, 184, 166, 0.18);
  --accent-text: #2dd4bf;

  --danger: #fb7185;
  --danger-soft: rgba(225, 29, 72, 0.2);
  --success: #34d399;
  --success-soft: rgba(5, 150, 105, 0.2);

  --mark-bg: rgba(250, 204, 21, 0.3);
  --mark-text: #fef08a;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 14px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.6);
}

/* ==========================================================================
   Reset & Base
   ========================================================================== */
*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font-sans);
  font-size: 15px;
  color: var(--text-primary);
  background: var(--bg-app);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  background: none;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.35);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(148, 163, 184, 0.55);
}

/* ==========================================================================
   Login Screen
   ========================================================================== */
.login-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at top right, #e0f2fe 0%, #f0fdfa 55%, #f8fafc 100%);
  padding: 20px;
}

[data-theme="dark"] .login-overlay {
  background: radial-gradient(circle at top right, #1e293b 0%, #090d16 100%);
}

.login-overlay.is-hidden {
  display: none !important;
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  padding: 36px 32px;
  box-shadow: var(--shadow-lg);
  color: var(--text-primary);
  text-align: center;
}

.login-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(20, 184, 166, 0.25);
}

.login-card h1 {
  margin: 0 0 6px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-card p {
  margin: 0 0 24px;
  font-size: 13.5px;
  color: var(--text-muted);
}

.login-input-wrap {
  margin-bottom: 16px;
  text-align: left;
}

.login-input-wrap label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.login-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 15px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

.login-btn {
  width: 100%;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--accent-gradient);
  color: #ffffff;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 4px 14px rgba(13, 148, 136, 0.3);
  transition: transform 0.12s, opacity 0.12s;
}

.login-btn:hover {
  opacity: 0.95;
  transform: translateY(-1px);
}

.login-error {
  margin-top: 12px;
  font-size: 13px;
  color: var(--danger);
  min-height: 18px;
}

/* ==========================================================================
   Main App 3-Column Shell
   ========================================================================== */
.app-shell {
  display: flex;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: var(--bg-app);
}

/* Focus Mode hides Sidebar & Note List on Desktop */
.app-shell.focus-mode .app-sidebar,
.app-shell.focus-mode .app-list-pane {
  display: none;
}

/* ==========================================================================
   Column 1: Navigation Sidebar
   ========================================================================== */
.app-sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  color: var(--text-sidebar);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--sidebar-border);
  user-select: none;
  z-index: 30;
}

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

.brand-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 16px;
  color: var(--sidebar-title-color);
  letter-spacing: -0.01em;
}

.brand-title img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}

.sidebar-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.icon-btn-sidebar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-sidebar);
  transition: background 0.15s, color 0.15s;
}

.icon-btn-sidebar:hover {
  background: var(--bg-sidebar-hover);
  color: var(--sidebar-title-color);
}

.sidebar-cta {
  padding: 0 14px 14px;
  display: flex;
  gap: 8px;
}

.btn-new-note {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-md);
  background: var(--accent-gradient);
  color: #ffffff;
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
  transition: transform 0.12s, box-shadow 0.12s;
}

.btn-new-note:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(13, 148, 136, 0.35);
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 10px 16px;
}

.sidebar-section {
  margin-bottom: 18px;
}

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

.sidebar-section-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-mini-btn {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--text-sidebar-muted);
  transition: background 0.15s, color 0.15s;
}

.sidebar-mini-btn:hover,
.sidebar-mini-btn.is-active {
  background: var(--bg-sidebar-hover);
  color: var(--sidebar-title-color);
}

.nav-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-radius: 8px;
  color: var(--text-sidebar);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.12s, color 0.12s;
  margin-bottom: 2px;
}

.nav-item:hover {
  background: var(--bg-sidebar-hover);
  color: var(--sidebar-title-color);
}

.nav-item.is-active {
  background: var(--bg-sidebar-active);
  color: var(--text-sidebar-active);
  font-weight: 600;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nb-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-badge {
  font-size: 11.5px;
  color: var(--text-sidebar-muted);
  font-weight: 600;
  padding-left: 6px;
}

.nav-item.is-active .nav-badge {
  color: var(--text-sidebar-active);
}

/* Sidebar Tag Filter Input */
.tag-filter-box {
  padding: 4px 6px 8px;
}

.tag-filter-input {
  width: 100%;
  padding: 6px 10px;
  border-radius: 7px;
  border: 1px solid var(--sidebar-input-border);
  background: var(--sidebar-input-bg);
  color: var(--sidebar-title-color);
  font-size: 12.5px;
  outline: none;
}

.tag-filter-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.sidebar-tags-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  max-height: 360px;
  overflow-y: auto;
}

.sidebar-footer {
  padding: 10px 14px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: var(--text-sidebar-muted);
}

/* ==========================================================================
   Column 2: Note List & Global Search Pane
   ========================================================================== */
.app-list-pane {
  width: var(--list-width);
  min-width: var(--list-width);
  background: var(--bg-list);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 20;
}

.list-header {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-card);
}

.list-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.list-view-title {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}

.list-count-pill {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.sort-select {
  font-size: 12.5px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-input);
  color: var(--text-secondary);
  outline: none;
}

/* Global Search Input */
.search-box-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.search-icon {
  position: absolute;
  left: 11px;
  color: var(--text-muted);
  pointer-events: none;
  font-size: 14px;
}

.global-search-input {
  width: 100%;
  padding: 9px 68px 9px 34px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 13.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

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

.search-Clear-btn {
  position: absolute;
  right: 8px;
  padding: 3px 7px;
  font-size: 11px;
  border-radius: 5px;
  background: var(--bg-subtle);
  color: var(--text-muted);
}

.search-Clear-btn:hover {
  color: var(--text-primary);
}

/* Live Tag Suggestions Bar under Search */
.search-tag-suggestions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  background: var(--bg-subtle);
  border: 1px solid var(--border-color);
}

.search-tag-suggestions.is-hidden {
  display: none;
}

.search-tag-suggestions-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-right: 2px;
}

.search-tag-suggestion-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  box-shadow: var(--shadow-sm);
  transition: background 0.12s, border-color 0.12s, transform 0.1s;
}

.search-tag-suggestion-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.search-tag-suggestion-count {
  font-size: 10.5px;
  opacity: 0.75;
  font-weight: 500;
}

/* Active Tag Filter Bar */
.active-filters-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-color);
}

.active-filters-bar.is-hidden {
  display: none;
}

.filter-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
}

.filter-tag-chip button {
  color: inherit;
  font-size: 13px;
  line-height: 1;
  padding: 0 2px;
}

.tag-mode-btn {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  margin-left: auto;
}

/* Note Cards List */
.notes-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, transform 0.1s, box-shadow 0.12s;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  position: relative;
}

.note-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-sm);
}

.note-card.is-active {
  background: var(--bg-card-active);
  border-color: var(--border-card-active);
  box-shadow: 0 0 0 1px var(--border-card-active), var(--shadow-sm);
}

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

.note-card-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-bottom: 5px;
}

.note-card-nb {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.note-card-pin {
  color: var(--accent);
  font-size: 12px;
}

.note-card-title {
  margin: 0 0 5px;
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-snippet {
  margin: 0 0 8px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.note-card-snippet mark,
.note-card-pdf-match mark,
.note-card-title mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  padding: 0 3px;
  border-radius: 3px;
  font-weight: 600;
}

.note-card-pdf-match {
  margin: 4px 0 8px;
  padding: 5px 8px;
  border-radius: 6px;
  background: var(--bg-subtle);
  border-left: 3px solid var(--accent);
  font-size: 11.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}

.note-card-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.card-tag-pill {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
}

.card-tag-pill:hover {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.card-media-badge {
  font-size: 11px;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--bg-subtle);
  color: var(--text-muted);
  font-weight: 600;
}

.note-card-thumb {
  width: 58px;
  height: 58px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

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

/* ==========================================================================
   Column 3: Note Editor & Reader Pane
   ========================================================================== */
.app-editor-pane {
  flex: 1;
  min-width: 0;
  background: var(--bg-editor);
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  position: relative;
}

/* Top Metadata Bar (Slim 1-Line Header) */
.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 14px;
  min-height: 48px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-editor);
  gap: 8px;
  flex-wrap: nowrap;
}

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

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

.mobile-back-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

.notebook-select {
  padding: 5px 9px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 600;
  font-size: 13px;
  outline: none;
  max-width: 170px;
  text-overflow: ellipsis;
}

.sync-status {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 6px;
  border-radius: 6px;
  white-space: nowrap;
}

.sync-status.is-saving {
  color: var(--accent);
}

.sync-status.is-saved {
  color: var(--success);
}

.top-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-editor);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
  flex-shrink: 0;
}

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

.top-icon-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

.top-icon-btn.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}

.top-action-btn {
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-editor);
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

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

.top-action-btn.is-active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

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

/* Inline Tags & Metadata inside scrollable Note Header */
.note-header-meta-block {
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.note-inline-tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.active-note-tags-list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
}

.note-tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-size: 12px;
  font-weight: 600;
  border: 1px solid transparent;
  cursor: pointer;
}

.note-tag-chip button {
  color: var(--accent-text);
  opacity: 0.7;
  font-size: 13px;
  padding: 0 2px;
  line-height: 1;
}

.note-tag-chip button:hover {
  opacity: 1;
  color: var(--danger);
}

.tag-input-wrapper {
  position: relative;
  min-width: 90px;
  max-width: 180px;
}

.note-tag-input {
  width: 100%;
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 12px;
  padding: 2px 10px;
  outline: none;
}

.note-tag-input:focus {
  border-style: solid;
  border-color: var(--accent);
  background: var(--bg-input);
}

.tag-autocomplete-menu {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  width: 240px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 100;
  padding: 4px;
}

.tag-autocomplete-menu.is-hidden {
  display: none;
}

.tag-autocomplete-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
  text-align: left;
  color: var(--text-primary);
}

.tag-autocomplete-item:hover,
.tag-autocomplete-item.is-selected {
  background: var(--accent-soft);
  color: var(--accent-text);
}

/* Rich Text Formatting Toolbar */
.editor-toolbar {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 6px 14px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-toolbar);
  backdrop-filter: blur(10px);
  overflow-x: auto;
  flex-shrink: 0;
}

.editor-toolbar.is-collapsed {
  display: none;
}

.toolbar-btn {
  min-width: 31px;
  height: 31px;
  padding: 0 7px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  transition: background 0.12s, color 0.12s;
  flex-shrink: 0;
}

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

.toolbar-btn.is-active {
  background: var(--accent-soft);
  color: var(--accent-text);
}

.toolbar-divider {
  width: 1px;
  height: 18px;
  background: var(--border-color);
  margin: 0 5px;
  flex-shrink: 0;
}

/* Scrollable Editor Canvas */
.editor-scroll-canvas {
  flex: 1;
  overflow-y: auto;
  padding: 32px 28px 96px;
}

.editor-inner-container {
  max-width: 820px;
  margin: 0 auto;
}

.note-title-input {
  width: 100%;
  border: none;
  background: transparent;
  font-size: 28px;
  font-weight: 800;
  line-height: 1.25;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  margin-bottom: 10px;
  outline: none;
  resize: none;
}

.note-submeta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.note-source-link {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--accent);
  text-decoration: none;
  max-width: 420px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-source-link:hover {
  text-decoration: underline;
}

/* ==========================================================================
   Unified Editorial Typography (.note-editor-content)
   ========================================================================== */
.note-editor-content {
  min-height: 420px;
  outline: none;
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.72;
  color: var(--text-primary);
  word-wrap: break-word;
}

.note-editor-content p {
  margin: 0 0 0.95em;
}

.note-editor-content h1,
.note-editor-content h2,
.note-editor-content h3,
.note-editor-content h4 {
  color: var(--text-primary);
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.015em;
  margin: 1.4em 0 0.5em;
}

.note-editor-content h1 { font-size: 1.55em; }
.note-editor-content h2 { font-size: 1.35em; border-bottom: 1px solid var(--border-color); padding-bottom: 0.25em; }
.note-editor-content h3 { font-size: 1.15em; }
.note-editor-content h4 { font-size: 1.02em; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-secondary); }

.note-editor-content strong,
.note-editor-content b {
  font-weight: 700;
  color: var(--text-primary);
}

.note-editor-content a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.note-editor-content mark {
  background: var(--mark-bg);
  color: var(--mark-text);
  padding: 1px 4px;
  border-radius: 4px;
}

.note-editor-content ul,
.note-editor-content ol {
  margin: 0 0 1em;
  padding-left: 1.5em;
}

.note-editor-content li {
  margin-bottom: 0.35em;
}

/* Interactive Checklists */
.note-editor-content ul.task-list {
  list-style: none;
  padding-left: 0.2em;
}

.note-editor-content li.task-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 0.45em;
}

.note-editor-content li.task-item label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  width: 100%;
}

.note-editor-content li.task-item input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin-top: 4px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.note-editor-content li.task-item.is-checked span {
  text-decoration: line-through;
  color: var(--text-muted);
}

.note-editor-content blockquote {
  margin: 1.1em 0;
  padding: 10px 18px;
  border-left: 4px solid var(--accent);
  background: var(--bg-subtle);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  color: var(--text-secondary);
  font-style: italic;
}

.note-editor-content pre,
.note-editor-content code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.note-editor-content code {
  background: var(--bg-subtle);
  padding: 2px 6px;
  border-radius: 5px;
}

.note-editor-content pre {
  background: var(--bg-subtle);
  padding: 14px 16px;
  border-radius: var(--radius-md);
  overflow-x: auto;
  border: 1px solid var(--border-color);
}

.note-editor-content hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 1.8em 0;
}

.note-editor-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1.2em 0;
  font-size: 14.5px;
}

.note-editor-content th,
.note-editor-content td {
  border: 1px solid var(--border-color);
  padding: 8px 12px;
  text-align: left;
}

.note-editor-content th {
  background: var(--bg-subtle);
  font-weight: 700;
}

/* ==========================================================================
   Inline Images & Multi-Image Grids (e.g. Heart of Men)
   ========================================================================== */
.note-editor-content figure.note-image {
  margin: 1.2em 0;
  display: inline-block;
  max-width: 100%;
}

.note-editor-content figure.note-image img {
  display: block;
  max-width: 100%;
  max-height: 540px;
  width: auto;
  height: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  cursor: zoom-in;
  transition: transform 0.15s, box-shadow 0.15s;
}

.note-editor-content figure.note-image img:hover {
  box-shadow: var(--shadow-md);
}

/* Multi-Image Grid */
.note-editor-content .note-image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  margin: 1.2em 0;
}

.note-editor-content figure.note-image-card {
  margin: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-editor-content figure.note-image-card img {
  width: 100%;
  height: 190px;
  object-fit: cover;
  display: block;
  cursor: zoom-in;
  transition: transform 0.2s;
}

.note-editor-content figure.note-image-card img:hover {
  transform: scale(1.03);
}

/* ==========================================================================
   Evernote-Style Inline PDF Viewer (.note-pdf-embed)
   ========================================================================== */
.note-pdf-embed {
  margin: 1.4em 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--bg-subtle);
  box-shadow: var(--shadow-sm);
  user-select: none;
}

.pdf-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  font-size: 13px;
  gap: 10px;
  flex-wrap: wrap;
}

.pdf-header-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pdf-badge {
  background: #0d9488;
  color: #ffffff;
  font-size: 10.5px;
  font-weight: 800;
  padding: 2px 6px;
  border-radius: 4px;
  letter-spacing: 0.04em;
}

.pdf-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pdf-ctrl-btn {
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 600;
  transition: background 0.12s, border-color 0.12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.pdf-ctrl-btn:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
}

.pdf-ctrl-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

.pdf-page-indicator {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 0 6px;
  font-variant-numeric: tabular-nums;
}

.pdf-canvas-Stage {
  width: 100%;
  max-height: 680px;
  overflow: auto;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 16px;
  background: var(--bg-list);
}

.pdf-canvas-Stage.is-collapsed {
  display: none;
}

.pdf-canvas-Stage canvas {
  max-width: 100%;
  height: auto !important;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  border-radius: 4px;
  background: #ffffff;
}

/* File Attachment Cards & Video */
.note-file-card {
  margin: 1em 0;
}

.file-card-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-strong);
  background: var(--bg-subtle);
  color: var(--text-primary) !important;
  text-decoration: none !important;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.file-card-link:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.file-card-ext {
  padding: 6px 10px;
  border-radius: 7px;
  background: var(--accent-soft);
  color: var(--accent-text);
  font-weight: 800;
  font-size: 11.5px;
}

.file-card-info {
  display: flex;
  flex-direction: column;
}

.file-card-title {
  font-weight: 600;
  font-size: 14px;
}

.file-card-meta {
  font-size: 11.5px;
  color: var(--text-muted);
}

.note-video-embed {
  margin: 1.2em 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border-color);
  background: #000;
  max-width: 680px;
}

.note-video-embed video {
  width: 100%;
  max-height: 440px;
  display: block;
}

.note-video-embed .video-caption {
  padding: 6px 12px;
  font-size: 12px;
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

/* Drag & Drop Upload Overlay */
.dropzone-overlay {
  position: absolute;
  inset: 12px;
  border: 3px dashed var(--accent);
  border-radius: var(--radius-lg);
  background: rgba(20, 184, 166, 0.12);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
  color: var(--accent-text);
  pointer-events: none;
}

.dropzone-overlay.is-hidden {
  display: none;
}

/* ==========================================================================
   Lightbox Modal (Full-Screen Image Zoom)
   ========================================================================== */
.lightbox-modal {
  position: fixed;
  inset: 0;
  z-index: 9500;
  background: rgba(9, 13, 22, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox-modal.is-hidden {
  display: none;
}

.lightbox-topbar {
  position: absolute;
  top: 16px;
  right: 20px;
  left: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #f8fafc;
}

.lightbox-img-stage {
  max-width: 92vw;
  max-height: 84vh;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.lightbox-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.lightbox-nav-btn:hover {
  background: rgba(255, 255, 255, 0.25);
}

.lightbox-nav-btn.prev { left: 20px; }
.lightbox-nav-btn.next { right: 20px; }

/* ==========================================================================
   Modals (Tag Manager & Settings / Backup)
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 8000;
  background: rgba(9, 13, 22, 0.65);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal-backdrop.is-hidden {
  display: none;
}

.modal-dialog {
  width: 100%;
  max-width: 620px;
  max-height: 85vh;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-dialog.tag-discovery-dialog {
  max-width: 860px;
  max-height: 88vh;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

/* Serendipity / Inspiration Box */
.serendipity-box {
  background: linear-gradient(135deg, rgba(20, 184, 166, 0.08) 0%, rgba(2, 132, 199, 0.08) 100%);
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 18px;
}

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

.serendipity-title {
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--accent-text);
}

.serendipity-reroll-btn {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
  transition: transform 0.12s, border-color 0.12s;
}

.serendipity-reroll-btn:hover {
  border-color: var(--accent);
  transform: scale(1.03);
}

.serendipity-content {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.serendipity-tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.serendipity-note-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.serendipity-note-card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-sm);
}

/* Discovery Tabs & Search */
.discovery-tabs-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color);
}

.discovery-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.disc-tab {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-subtle);
  color: var(--text-secondary);
  transition: background 0.12s, color 0.12s;
}

.disc-tab:hover {
  background: var(--border-color);
}

.disc-tab.is-active {
  background: var(--accent-gradient);
  color: #ffffff;
}

.disc-search-input {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--bg-input);
  color: var(--text-primary);
  font-size: 12.5px;
  outline: none;
  min-width: 180px;
}

.disc-search-input:focus {
  border-color: var(--accent);
}

/* Tag Cloud Stage */
.tag-cloud-wrap {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 10px 4px;
}

.cloud-tag-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
  color: var(--text-primary);
  transition: transform 0.12s, background 0.12s, border-color 0.12s, box-shadow 0.12s;
  line-height: 1.2;
}

.cloud-tag-pill:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-text);
  box-shadow: var(--shadow-sm);
}

.cloud-tag-pill.tier-xl {
  font-size: 18px;
  font-weight: 800;
  padding: 9px 18px;
  background: var(--accent-soft);
  color: var(--accent-text);
  border-color: rgba(20, 184, 166, 0.35);
}

.cloud-tag-pill.tier-lg {
  font-size: 15.5px;
  font-weight: 700;
  padding: 7px 14px;
  background: var(--bg-card);
  border-color: var(--border-strong);
}

.cloud-tag-pill.tier-md {
  font-size: 13.5px;
  font-weight: 600;
  padding: 5px 12px;
}

.cloud-tag-pill.tier-sm {
  font-size: 12.5px;
  font-weight: 500;
  padding: 4px 10px;
  color: var(--text-secondary);
}

.cloud-tag-pill span.cnt {
  font-size: 0.78em;
  opacity: 0.65;
  font-weight: 500;
}

/* A-Z Groups */
.az-group {
  margin-bottom: 18px;
}

.az-letter {
  font-size: 14px;
  font-weight: 800;
  color: var(--accent-text);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border-color);
}

.tag-manager-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tag-manager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-subtle);
}

/* ==========================================================================
   Responsive / Mobile PWA Viewports
   ========================================================================== */
.mobile-sidebar-backdrop {
  display: none;
}

.mobile-only-btn {
  display: none !important;
}

.mobile-fab-new-note {
  display: none;
}

@media (max-width: 980px) {
  .desktop-only-btn {
    display: none !important;
  }

  .mobile-only-btn {
    display: inline-flex !important;
  }

  .mobile-fab-new-note {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    right: 20px;
    bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--accent-gradient);
    color: #ffffff;
    font-size: 28px;
    font-weight: 700;
    line-height: 1;
    box-shadow: 0 8px 24px rgba(13, 148, 136, 0.42);
    z-index: 22;
    transition: transform 0.15s, box-shadow 0.15s;
  }

  .mobile-fab-new-note:active {
    transform: scale(0.93);
  }

  .app-shell.mobile-editor-open .mobile-fab-new-note,
  .app-shell.mobile-sidebar-open .mobile-fab-new-note {
    display: none;
  }

  .mobile-sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(9, 13, 22, 0.55);
    backdrop-filter: blur(2px);
    z-index: 28;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
  }

  .app-shell.mobile-sidebar-open .mobile-sidebar-backdrop {
    opacity: 1;
    pointer-events: auto;
  }

  .app-sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 82vw;
    max-width: 310px;
    min-width: 260px;
    transform: translateX(-100%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
    box-shadow: var(--shadow-lg);
    z-index: 30;
  }

  .app-shell.mobile-sidebar-open .app-sidebar {
    transform: translateX(0);
  }

  .app-list-pane {
    width: 100vw;
    min-width: 100vw;
  }

  .app-editor-pane {
    position: fixed;
    inset: 0;
    z-index: 25;
    transform: translateX(100%);
    transition: transform 0.24s cubic-bezier(0.22, 1, 0.36, 1);
  }

  .app-shell.mobile-editor-open .app-editor-pane {
    transform: translateX(0);
  }

  .mobile-back-btn {
    display: inline-flex;
  }

  .editor-scroll-canvas {
    padding: 20px 16px 88px;
  }

  .note-title-input {
    font-size: 22px;
  }
}
