/* ============================================
   FOLIO — Markdown Editor
   Aesthetic: Dark editorial / print-inspired
   ============================================ */

:root {
  --bg: #0f0f0f;
  --bg-raised: #171717;
  --bg-hover: #1e1e1e;
  --bg-active: #242424;
  --border: #2a2a2a;
  --border-mid: #333;
  --ink: #e8e3d9;
  --ink-mid: #a09890;
  --ink-muted: #555;
  --accent: #c9a96e;
  --accent-dim: rgba(201,169,110,0.12);
  --danger: #c0605a;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;
  --font-prose: 'Lora', Georgia, serif;
  --sidebar-w: 260px;
  --toolbar-h: 52px;
  --radius: 6px;
  --shadow: 0 4px 24px rgba(0,0,0,0.15);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #faf9f7;
    --bg-raised: #f2f0ec;
    --bg-hover: #ece9e3;
    --bg-active: #e4e0d8;
    --border: #dddad3;
    --border-mid: #ccc8c0;
    --ink: #1e1c18;
    --ink-mid: #6b6560;
    --ink-muted: #aaa49c;
    --accent: #9a6f2e;
    --accent-dim: rgba(154,111,46,0.1);
    --danger: #b03030;
    --shadow: 0 4px 24px rgba(0,0,0,0.1);
  }
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ---- SCREENS ---- */
.screen { display: none; position: fixed; inset: 0; }
.screen.active { display: flex; }

/* ---- AUTH SCREEN ---- */
#auth-screen {
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 40% at 20% 80%, rgba(201,169,110,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 40% 60% at 80% 20%, rgba(201,169,110,0.04) 0%, transparent 60%);
  pointer-events: none;
}

.auth-content {
  position: relative;
  z-index: 1;
  text-align: center;
  max-width: 360px;
  padding: 2rem;
  animation: fadeUp 0.6s ease both;
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}

.auth-logo {
  margin-bottom: 1.5rem;
  opacity: 0.7;
}

.auth-title {
  font-family: var(--font-display);
  font-size: 3rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--ink);
  margin-bottom: 0.75rem;
}

.auth-subtitle {
  font-family: var(--font-prose);
  font-size: 1rem;
  color: var(--ink-mid);
  line-height: 1.7;
  margin-bottom: 2.5rem;
}

.auth-note {
  margin-top: 1rem;
  font-size: 0.72rem;
  color: var(--ink-muted);
  line-height: 1.5;
}

/* ---- BUTTONS ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  background: var(--ink);
  color: var(--bg);
  border: none;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}
.btn-primary:hover { opacity: 0.9; }
.btn-primary:active { transform: scale(0.98); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-secondary {
  padding: 0.6rem 1.2rem;
  background: transparent;
  color: var(--ink-mid);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
}
.btn-secondary:hover { border-color: var(--ink-mid); color: var(--ink); }

.btn-ghost {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  cursor: pointer;
  padding: 0.4rem 0.6rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.btn-ghost:hover { color: var(--ink); }

.btn-ghost-sm {
  background: none;
  border: none;
  color: var(--ink-muted);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  cursor: pointer;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.btn-ghost-sm:hover { color: var(--ink); }

.btn-save {
  padding: 0.35rem 0.9rem;
  background: var(--accent);
  color: var(--bg);
  border: none;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-save:hover { opacity: 0.85; }

.icon-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0.4rem;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s, background 0.15s;
}
.icon-btn:hover { color: var(--ink); background: var(--bg-hover); }

/* ---- FOLDER SCREEN ---- */
#folder-screen {
  flex-direction: column;
  background: var(--bg);
}

.screen-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.logo-sm {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 400;
  letter-spacing: 0.05em;
  color: var(--accent);
}

.folder-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 2rem;
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
  animation: fadeUp 0.4s ease both;
}

.folder-content h2 {
  font-family: var(--font-display);
  font-size: 1.8rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
}

.folder-subtitle {
  color: var(--ink-mid);
  margin-bottom: 1.5rem;
  font-family: var(--font-prose);
}

.folder-subtitle code {
  font-family: var(--font-mono);
  background: var(--bg-raised);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--accent);
}

.folder-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  min-height: 200px;
  max-height: 400px;
}

.folder-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}
.folder-item:last-child { border-bottom: none; }
.folder-item:hover { background: var(--bg-hover); }
.folder-item.selected { background: var(--accent-dim); color: var(--accent); }
.folder-item.already-added { opacity: 0.45; cursor: default; }

.folder-item svg { opacity: 0.5; flex-shrink: 0; }
.folder-item.selected svg { opacity: 1; }

.folder-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
}

/* ---- MAIN APP LAYOUT ---- */
#app-screen {
  flex-direction: row;
  overflow: hidden;
}

/* ---- SIDEBAR ---- */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-raised);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.25s ease, width 0.25s ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-actions {
  display: flex;
  gap: 0.1rem;
}

.search-wrap {
  position: relative;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 1.1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-muted);
  pointer-events: none;
}

#search-input {
  width: 100%;
  background: var(--bg-active);
  border: 1px solid var(--border-mid);
  border-radius: 4px;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.4rem 0.6rem 0.4rem 1.8rem;
  outline: none;
  transition: border-color 0.15s;
}
#search-input:focus { border-color: var(--accent); }
#search-input::placeholder { color: var(--ink-muted); }

.folder-sections {
  flex: 1;
  overflow-y: auto;
}

/* ---- FOLDER SECTION ---- */
.folder-section { border-bottom: 1px solid var(--border); }

.folder-section-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.75rem 0.5rem 0.6rem;
  cursor: pointer;
  user-select: none;
  position: sticky;
  top: 0;
  background: var(--bg-raised);
  z-index: 1;
}
.folder-section-header:hover { background: var(--bg-hover); }

.folder-chevron {
  color: var(--ink-muted);
  transition: transform 0.2s;
  flex-shrink: 0;
}
.folder-section.collapsed .folder-chevron { transform: rotate(-90deg); }

.folder-section-name {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--ink-mid);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.folder-remove-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  cursor: pointer;
  padding: 0.2rem;
  border-radius: 3px;
  display: flex;
  align-items: center;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
}
.folder-section-header:hover .folder-remove-btn { opacity: 1; }
.folder-remove-btn:hover { color: var(--danger); }

.folder-section-files { }
.folder-section.collapsed .folder-section-files { display: none; }

.folder-section-loading {
  padding: 0.5rem 1rem 0.75rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.folder-empty-msg {
  padding: 0.5rem 1rem 0.75rem;
  font-size: 0.75rem;
  color: var(--ink-muted);
  font-style: italic;
}

.file-item {
  padding: 0.55rem 1rem 0.55rem 1.2rem;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: background 0.1s, border-color 0.1s;
}
.file-item:hover { background: var(--bg-hover); }
.file-item.active {
  background: var(--bg-active);
  border-left-color: var(--accent);
}

.file-item-name {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.2rem;
}
.file-item.active .file-item-name { color: var(--accent); }

.file-item-meta {
  font-size: 0.68rem;
  color: var(--ink-muted);
}

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}
.modal-overlay.hidden { display: none; }

.modal {
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  max-height: 80vh;
  animation: fadeUp 0.2s ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1rem 0.5rem;
  flex-shrink: 0;
}

.modal-header h3 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 1.2rem;
}

.modal-subtitle {
  padding: 0 1rem 0.75rem;
  color: var(--ink-mid);
  font-family: var(--font-prose);
  font-size: 0.85rem;
  flex-shrink: 0;
}

.modal .folder-list {
  flex: 1;
  overflow-y: auto;
  margin: 0 1rem;
  border-radius: var(--radius);
  min-height: 120px;
  max-height: 320px;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  padding: 0.75rem 1rem 1rem;
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  margin-top: 0.75rem;
}

.sidebar-footer {
  border-top: 1px solid var(--border);
  padding: 0.6rem 0.75rem;
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ---- EDITOR AREA ---- */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ---- TOOLBAR ---- */
/* ---- TITLE BAR ---- */
.title-bar {
  height: var(--toolbar-h);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.75rem;
  flex-shrink: 0;
  background: var(--bg-raised);
}

.mobile-sidebar-toggle { display: none; }

.toolbar-filename { flex: 1; min-width: 0; }

#filename-input {
  background: none;
  border: none;
  color: var(--ink-mid);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  outline: none;
  width: 100%;
  max-width: 260px;
}
#filename-input:focus { color: var(--ink); }

.toolbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.view-toggle {
  display: flex;
  background: var(--bg-active);
  border-radius: 4px;
  padding: 2px;
  gap: 1px;
}

.view-btn {
  background: none;
  border: none;
  color: var(--ink-muted);
  padding: 0.3rem 0.45rem;
  border-radius: 3px;
  cursor: pointer;
  display: flex;
  align-items: center;
  transition: background 0.1s, color 0.1s;
}
.view-btn:hover { color: var(--ink); }
.view-btn.active { background: var(--bg-raised); color: var(--accent); }

.save-status {
  font-size: 0.72rem;
  color: var(--ink-muted);
  white-space: nowrap;
}
.save-status.saved { color: #7ab87a; }
.save-status.unsaved { color: var(--accent); }
.save-status.saving { color: var(--ink-muted); animation: pulse 1s infinite; }

@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }

/* ---- MENU BAR ---- */
.menu-bar {
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 0.5rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 32px;
}

.menu-item {
  position: relative;
}

.menu-trigger {
  background: none;
  border: none;
  color: var(--ink-mid);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.1s, color 0.1s;
}
.menu-trigger:hover,
.menu-item.open .menu-trigger {
  background: var(--bg-hover);
  color: var(--ink);
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 2px);
  left: 0;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 200px;
  z-index: 1000;
  padding: 0.25rem 0;
  animation: fadeIn 0.1s ease;
}
.menu-item.open .menu-dropdown { display: block; }

.menu-dropdown button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  background: none;
  border: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 0.45rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.menu-dropdown button:hover { background: var(--bg-hover); }
.menu-dropdown hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 0.25rem 0;
}

.menu-shortcut {
  font-size: 0.7rem;
  color: var(--ink-muted);
  margin-left: 1rem;
}

/* ---- MARKDOWN TOOLBAR ---- */
.md-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.1rem;
  padding: 0 0.75rem;
  background: var(--bg-raised);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  height: 38px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}
.md-toolbar::-webkit-scrollbar { display: none; }

.md-btn {
  background: none;
  border: none;
  color: var(--ink-mid);
  cursor: pointer;
  padding: 0.3rem 0.45rem;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  transition: background 0.1s, color 0.1s;
  flex-shrink: 0;
}
.md-btn:hover { background: var(--bg-hover); color: var(--ink); }
.md-btn:active { background: var(--bg-active); }

.md-divider {
  width: 1px;
  height: 18px;
  background: var(--border-mid);
  margin: 0 0.3rem;
  flex-shrink: 0;
}

.md-stats {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--ink-muted);
  margin-left: auto;
  white-space: nowrap;
  padding-left: 0.5rem;
}

/* ---- PANES ---- */
.panes {
  flex: 1;
  display: flex;
  overflow: hidden;
  position: relative;
}

.pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1;
}

/* view modes */
.panes.edit-mode .pane-preview { display: none; }
.panes.preview-mode .pane-editor { display: none; }

/* ---- TEXTAREA EDITOR ---- */
#editor {
  flex: 1;
  width: 100%;
  background: var(--bg);
  color: var(--ink);
  border: none;
  outline: none;
  resize: none;
  font-family: var(--font-mono);
  font-size: 0.9rem;
  line-height: 1.8;
  padding: 2rem 2.5rem;
  caret-color: var(--accent);
  tab-size: 2;
}

#editor::placeholder { color: var(--ink-muted); }

/* ---- PREVIEW ---- */
.pane-preview {
  overflow-y: auto;
  background: var(--bg);
}

.preview-content {
  padding: 2rem 2.5rem;
  max-width: 720px;
  margin: 0 auto;
  font-family: var(--font-prose);
  font-size: 1rem;
  line-height: 1.8;
  color: var(--ink);
}

.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4 {
  font-family: var(--font-display);
  font-weight: 400;
  margin-top: 2em;
  margin-bottom: 0.6em;
  color: var(--ink);
  line-height: 1.3;
}

.preview-content h1 { font-size: 2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.preview-content h2 { font-size: 1.5rem; }
.preview-content h3 { font-size: 1.2rem; }

.preview-content p { margin-bottom: 1.2em; }
.preview-content a { color: var(--accent); text-decoration: none; border-bottom: 1px solid var(--accent-dim); }
.preview-content a:hover { border-bottom-color: var(--accent); }

.preview-content code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  padding: 0.1em 0.4em;
  border-radius: 3px;
  color: var(--accent);
}

.preview-content pre {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
  overflow-x: auto;
  margin-bottom: 1.2em;
}

.preview-content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85rem;
  color: var(--ink);
}

.preview-content blockquote {
  border-left: 3px solid var(--accent);
  padding-left: 1.2rem;
  margin: 1.5em 0;
  color: var(--ink-mid);
  font-style: italic;
}

.preview-content ul, .preview-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1.2em;
}

.preview-content li { margin-bottom: 0.3em; }

.preview-content table {
  border-collapse: collapse;
  width: 100%;
  margin-bottom: 1.2em;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.preview-content th, .preview-content td {
  border: 1px solid var(--border-mid);
  padding: 0.5rem 0.75rem;
  text-align: left;
}

.preview-content th { background: var(--bg-raised); color: var(--accent); }

.preview-content hr {
  border: none;
  border-top: 1px solid var(--border-mid);
  margin: 2em 0;
}

.preview-content img { max-width: 100%; border-radius: var(--radius); }

/* ---- EMPTY STATE ---- */
.empty-state {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  height: 100%;
  color: var(--ink-muted);
  font-family: var(--font-prose);
  font-style: italic;
}

.empty-state.visible { display: flex; }
.empty-state p { font-size: 0.95rem; }

/* ---- DROPDOWN MENU ---- */
.dropdown-menu {
  position: fixed;
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 180px;
  z-index: 1000;
  overflow: hidden;
  animation: fadeIn 0.15s ease;
}

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

.dropdown-menu button {
  display: block;
  width: 100%;
  background: none;
  border: none;
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.65rem 1rem;
  text-align: left;
  cursor: pointer;
  transition: background 0.1s;
}
.dropdown-menu button:hover { background: var(--bg-hover); }
.dropdown-menu button.danger { color: var(--danger); }
.dropdown-menu hr { border: none; border-top: 1px solid var(--border); }

/* ---- LOADING ---- */
.loading-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 2rem;
  color: var(--ink-muted);
  font-size: 0.82rem;
}

.spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border-mid);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  display: inline-block;
}

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes fadeIn { from { opacity:0; transform: translateY(-4px); } to { opacity:1; transform: translateY(0); } }

/* ---- TOAST ---- */
.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-raised);
  border: 1px solid var(--border-mid);
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  padding: 0.6rem 1.2rem;
  border-radius: 99px;
  box-shadow: var(--shadow);
  z-index: 2000;
  transition: opacity 0.3s;
}
.toast.hidden { opacity: 0; pointer-events: none; }

/* ---- SCROLLBARS ---- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-muted); }

/* ============================================
   RESPONSIVE — TABLET & MOBILE
   ============================================ */

@media (max-width: 900px) {
  :root { --sidebar-w: 240px; }
}

@media (max-width: 640px) {
  .mobile-sidebar-toggle { display: flex; }

  /* Hide menu bar on mobile */
  .menu-bar { display: none; }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(-100%);
    box-shadow: var(--shadow);
  }

  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
  }

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

  #editor {
    padding: 1.25rem 1rem;
    font-size: 0.85rem;
  }

  .preview-content {
    padding: 1.25rem 1rem;
    font-size: 0.95rem;
  }

  .title-bar { padding: 0 0.5rem; gap: 0.3rem; }

  #filename-input { max-width: 120px; font-size: 0.75rem; }

  .save-status { display: none; }

  .auth-title { font-size: 2.2rem; }
  .auth-subtitle { font-size: 0.9rem; }
}

@media (max-width: 400px) {
  #filename-input { max-width: 80px; }
  .btn-save { padding: 0.3rem 0.65rem; font-size: 0.72rem; }
}
