/* ─── HFZ Notes — style.css ──────────────────────────────────────────────────
   Premium note-taking app styles.
   Design: minimal, clean, modern, responsive.
   Theme: light (default) + dark mode via [data-theme="dark"]
─────────────────────────────────────────────────────────────────────────────── */

/* ─── Google Fonts ───────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── CSS Variables ──────────────────────────────────────────────────────────── */
:root {
  /* Brand */
  --color-primary:    #0F172A;
  --color-accent:     #6366F1;
  --color-accent-2:   #22D3EE;
  --color-accent-rgb: 99, 102, 241;

  /* Light Mode */
  --bg-app:           #F8FAFC;
  --bg-sidebar:       #FFFFFF;
  --bg-panel:         #FFFFFF;
  --bg-card:          #FFFFFF;
  --bg-hover:         #F1F5F9;
  --bg-input:         #F8FAFC;
  --bg-overlay:       rgba(15, 23, 42, 0.35);

  --text-primary:     #0F172A;
  --text-secondary:   #475569;
  --text-muted:       #94A3B8;
  --text-inverse:     #FFFFFF;

  --border-color:     #E2E8F0;
  --border-strong:    #CBD5E1;

  --shadow-sm:        0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md:        0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg:        0 12px 32px rgba(0,0,0,.10), 0 4px 8px rgba(0,0,0,.06);

  --radius-sm:        6px;
  --radius-md:        10px;
  --radius-lg:        16px;
  --radius-xl:        20px;

  --sidebar-width:    240px;
  --editor-width:     380px;
  --topbar-h:         56px;

  --font:             'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --transition:       0.18s ease;
}

[data-theme="dark"] {
  --bg-app:           #0F172A;
  --bg-sidebar:       #1E293B;
  --bg-panel:         #1E293B;
  --bg-card:          #1E293B;
  --bg-hover:         #293548;
  --bg-input:         #0F172A;
  --bg-overlay:       rgba(0,0,0,.6);

  --text-primary:     #F1F5F9;
  --text-secondary:   #94A3B8;
  --text-muted:       #64748B;
  --text-inverse:     #0F172A;

  --border-color:     #293548;
  --border-strong:    #334155;

  --shadow-sm:        0 1px 3px rgba(0,0,0,.3);
  --shadow-md:        0 4px 12px rgba(0,0,0,.4);
  --shadow-lg:        0 12px 32px rgba(0,0,0,.5);
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
  height: 100dvh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; background: none; border: none; font-family: var(--font); }
input, select, textarea { font-family: var(--font); }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
mark { background: rgba(var(--color-accent-rgb), 0.25); color: inherit; border-radius: 2px; padding: 0 1px; }

/* ─── Login Screen ───────────────────────────────────────────────────────────── */
#login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  background: var(--bg-app);
  padding: 24px;
}
.login-card {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 48px 40px;
  max-width: 400px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  width: 52px;
  height: 52px;
  background: var(--color-accent);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  font-size: 24px;
  color: #fff;
}
.login-title { font-size: 22px; font-weight: 700; color: var(--text-primary); margin-bottom: 6px; }
.login-subtitle { font-size: 14px; color: var(--text-secondary); margin-bottom: 32px; }
.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 12px 20px;
  background: var(--color-accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: opacity var(--transition);
}
.btn-google:hover { opacity: .88; }
.login-footer { margin-top: 28px; font-size: 11px; color: var(--text-muted); }

/* ─── App Layout ─────────────────────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
#sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  transition: transform var(--transition);
  z-index: 100;
}
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 16px 14px;
  border-bottom: 1px solid var(--border-color);
}
.sidebar-logo-icon {
  width: 30px;
  height: 30px;
  background: var(--color-accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  flex-shrink: 0;
}
.sidebar-logo-text { font-size: 15px; font-weight: 700; letter-spacing: -0.3px; }

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* ─── Workspace section ──────────────────────────────────────────────────────── */
.sidebar-section {
  padding: 16px 12px 8px;
}
.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 4px;
  margin-bottom: 6px;
}
.sidebar-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.btn-icon-sm {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 12px;
  transition: background var(--transition), color var(--transition);
}
.btn-icon-sm:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ─── Workspace items ────────────────────────────────────────────────────────── */
#workspace-list { display: flex; flex-direction: column; gap: 1px; }
.workspace-item {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.workspace-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.workspace-item.active .workspace-btn,
.workspace-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.workspace-item.active .workspace-btn { color: var(--color-accent); font-weight: 500; }
.workspace-emoji  { font-size: 15px; flex-shrink: 0; }
.workspace-name   { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.workspace-count  { font-size: 10px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.workspace-options {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  font-size: 11px;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
}
.workspace-item:hover .workspace-options { opacity: 1; }
.workspace-options:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ─── Nav items ──────────────────────────────────────────────────────────────── */
.nav-list { display: flex; flex-direction: column; gap: 1px; }
.nav-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 8px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}
.nav-item:hover, .nav-item.active { background: var(--bg-hover); color: var(--text-primary); }
.nav-item.active { color: var(--color-accent); font-weight: 500; }
.nav-item i { width: 16px; text-align: center; }

/* ─── Tag list ───────────────────────────────────────────────────────────────── */
#tag-list { display: flex; flex-direction: column; gap: 1px; }
.tag-item { border-radius: var(--radius-sm); }
.tag-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 12px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.tag-item.active .tag-btn, .tag-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.tag-item.active .tag-btn { color: var(--color-accent); }
.tag-empty { font-size: 12px; color: var(--text-muted); padding: 6px 8px; }

/* ─── Sidebar footer ─────────────────────────────────────────────────────────── */
.sidebar-footer {
  border-top: 1px solid var(--border-color);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.profile-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background var(--transition);
}
.profile-row:hover { background: var(--bg-hover); }
.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.profile-avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar-initials { color: #fff; font-size: 13px; font-weight: 600; }
.profile-info { flex: 1; overflow: hidden; }
.profile-name  { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.profile-email { font-size: 11px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-action-row {
  display: flex;
  gap: 4px;
}
.sidebar-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px;
  font-size: 12px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: background var(--transition), color var(--transition);
}
.sidebar-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.sidebar-btn--danger:hover { color: #EF4444; }

/* ─── Main Area ──────────────────────────────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* ─── Top bar ────────────────────────────────────────────────────────────────── */
#topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-panel);
  flex-shrink: 0;
}
.topbar-left  { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

#workspace-header { display: flex; align-items: center; gap: 8px; }
.ws-header-emoji  { font-size: 18px; }
.ws-header-name   { font-size: 15px; font-weight: 600; }

#note-count { font-size: 12px; color: var(--text-muted); margin-left: 8px; }

/* ─── Search bar ─────────────────────────────────────────────────────────────── */
.search-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0 12px;
  height: 36px;
  max-width: 320px;
  width: 100%;
  transition: border-color var(--transition);
}
.search-wrapper:focus-within { border-color: var(--color-accent); }
.search-wrapper i  { color: var(--text-muted); font-size: 13px; flex-shrink: 0; }
#search-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 13px;
  color: var(--text-primary);
}
#search-input::placeholder { color: var(--text-muted); }
#search-clear {
  display: none;
  width: 18px;
  height: 18px;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--transition);
}
#search-clear:hover { background: var(--bg-hover); color: var(--text-primary); }

.btn-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background var(--transition), color var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ─── Filter bar ─────────────────────────────────────────────────────────────── */
#filter-bar {
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
  flex-shrink: 0;
}
#filter-bar::-webkit-scrollbar { display: none; }
#category-filter { display: flex; gap: 6px; flex: 1; }
.filter-chip {
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  white-space: nowrap;
  transition: all var(--transition);
}
.filter-chip:hover, .filter-chip.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
}

#sort-select {
  padding: 4px 10px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 12px;
  background: var(--bg-card);
  color: var(--text-secondary);
  outline: none;
  cursor: pointer;
  margin-left: auto;
}

/* ─── Layout toggle ─────────────────────────────────────────────────────────── */
.layout-toggle {
  display: flex;
  align-items: center;
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 1px;
}
.layout-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  font-size: 12px;
  color: var(--text-muted);
  transition: background var(--transition), color var(--transition);
}
.layout-btn:hover { color: var(--text-primary); }
.layout-btn.active {
  background: var(--bg-panel);
  color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

/* ─── Notes grid ─────────────────────────────────────────────────────────────── */
#notes-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}
#notes-area::-webkit-scrollbar { width: 5px; }
#notes-area::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }
#notes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  align-items: start;
}

/* ─── List view ─────────────────────────────────────────────────────────────── */
#notes-grid.notes-list-view {
  display: flex;
  flex-direction: column;
  gap: 2px;
  grid-template-columns: unset;
}
#notes-grid.notes-list-view .note-card {
  border-radius: var(--radius-md);
  padding: 10px 14px;
  border-left: 3px solid transparent;
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-rows: auto auto;
  column-gap: 12px;
  row-gap: 0;
  align-items: center;
}
[data-theme="light"] #notes-grid.notes-list-view .note-card {
  background: transparent !important;
  border-color: transparent;
  border-bottom: 1px solid var(--border-color);
  border-radius: 0;
}
[data-theme="dark"] #notes-grid.notes-list-view .note-card {
  background: transparent !important;
  border-color: transparent;
  border-bottom: 1px solid var(--border-color);
  border-radius: 0;
}
#notes-grid.notes-list-view .note-card:hover {
  transform: none;
  box-shadow: none;
  background: var(--bg-hover) !important;
}
#notes-grid.notes-list-view .note-card:last-child {
  border-bottom: none;
}

/* List view — title row */
#notes-grid.notes-list-view .note-card-title {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
  display: block;
  -webkit-line-clamp: unset;
  grid-column: 1;
  grid-row: 1;
}

/* List view — preview */
#notes-grid.notes-list-view .note-card-preview {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0;
  display: block;
  -webkit-line-clamp: unset;
  grid-column: 1;
  grid-row: 2;
}
#notes-grid.notes-list-view .note-card-empty {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  margin-bottom: 0;
  grid-column: 1;
  grid-row: 2;
}

/* List view — footer (date) aligned right */
#notes-grid.notes-list-view .note-card-footer {
  grid-column: 2;
  grid-row: 1 / 3;
  margin-top: 0;
  justify-content: flex-end;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}
#notes-grid.notes-list-view .note-card-date {
  font-size: 11px;
  white-space: nowrap;
}
#notes-grid.notes-list-view .note-card-category {
  display: none;
}

/* List view — hide everything else */
#notes-grid.notes-list-view .card-checklist-preview,
#notes-grid.notes-list-view .card-checklist-progress,
#notes-grid.notes-list-view .note-card-tags,
#notes-grid.notes-list-view .note-card-actions,
#notes-grid.notes-list-view .note-card-corner,
#notes-grid.notes-list-view .note-card-emoji-row {
  display: none;
}

/* ─── Note card ──────────────────────────────────────────────────────────────── */
.note-card {
  background: var(--note-color, var(--bg-card));
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 14px;
  cursor: pointer;
  position: relative;
  transition: transform var(--transition), box-shadow var(--transition);
  overflow: hidden;
}
/* Apply note color based on theme */
[data-theme="light"] .note-card { background: var(--note-light, var(--bg-card)); }
[data-theme="dark"]  .note-card { background: var(--note-dark,  var(--bg-card)); }

.note-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.note-card-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  min-height: 0;
}
/* Hide header entirely when it only contains the type icon (no emoji, pin, fav) */
.note-card-header:empty { display: none; margin: 0; }
.note-emoji    { font-size: 16px; line-height: 1; }
.note-type-corner {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 11px;
  color: var(--text-muted);
}
.note-type-icon { font-size: 11px; color: var(--text-muted); margin-left: auto; }
.note-badge    { font-size: 10px; color: var(--text-muted); }
.note-badge--pin { color: var(--color-accent); }
.note-badge--fav { color: #F59E0B; }

.note-card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  margin-bottom: 6px;
  color: var(--text-primary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.note-card-preview {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 10px;
}
.note-card-empty { font-size: 12px; color: var(--text-muted); font-style: italic; margin-bottom: 10px; }

.note-card-tags { display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 10px; }
.tag-chip-sm {
  padding: 2px 7px;
  background: rgba(var(--color-accent-rgb), 0.1);
  color: var(--color-accent);
  border-radius: 10px;
  font-size: 10px;
  font-weight: 500;
}
.note-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.note-card-date     { font-size: 10px; color: var(--text-muted); }
.note-card-category { font-size: 10px; color: var(--text-muted); background: var(--bg-hover); padding: 2px 6px; border-radius: 4px; }

/* ─── Note card hover actions ────────────────────────────────────────────────── */
.note-card-actions {
  display: flex;
  gap: 2px;
  position: absolute;
  bottom: 10px;
  right: 10px;
  opacity: 0;
  transition: opacity var(--transition);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  padding: 2px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-color);
}
.note-card:hover .note-card-actions { opacity: 1; }
.note-action-btn {
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-muted);
  border-radius: 4px;
  transition: background var(--transition), color var(--transition);
}
.note-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.note-action-btn--danger:hover { color: #EF4444; }

/* ─── Floating new note button ───────────────────────────────────────────────── */
#btn-new-note {
  position: fixed;
  bottom: 24px;
  right: calc(var(--editor-width) + 24px);
  width: 52px;
  height: 52px;
  background: var(--color-accent);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  box-shadow: var(--shadow-lg);
  transition: transform var(--transition), background var(--transition);
  z-index: 50;
}
#btn-new-note:hover { transform: scale(1.06); }

/* ─── Editor panel ───────────────────────────────────────────────────────────── */
#editor-panel {
  width: var(--editor-width);
  min-width: var(--editor-width);
  background: var(--bg-panel);
  border-left: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  position: relative;
}
#editor-panel.editor-open { transform: translateX(0); }

.editor-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
  min-height: 44px;
}
.editor-ws-label { font-size: 11px; color: var(--text-muted); }
.editor-topbar-right { display: flex; align-items: center; gap: 8px; }

.save-status {
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 20px;
}
.save-status--saved  { color: #10B981; background: rgba(16,185,129,.1); }
.save-status--saving { color: var(--text-muted); }
.save-status--error  { color: #EF4444; background: rgba(239,68,68,.1); }

.editor-scroll { flex: 1; overflow-y: auto; padding: 14px 16px; }
.editor-scroll::-webkit-scrollbar { width: 4px; }
.editor-scroll::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 4px; }

/* Editor fields */
.editor-emoji-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
#editor-emoji {
  width: 36px;
  height: 36px;
  font-size: 18px;
  text-align: center;
  background: var(--bg-hover);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 2px;
  outline: none;
  flex-shrink: 0;
}
#editor-title {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
  resize: none;
  padding: 0;
}
#editor-title::placeholder { color: var(--text-muted); }

#editor-content {
  width: 100%;
  background: none;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.65;
  resize: none;
  min-height: 120px;
  overflow: hidden;
}
#editor-content::placeholder { color: var(--text-muted); }

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

.editor-meta-row { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.meta-field { display: flex; flex-direction: column; gap: 4px; }
.meta-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--text-muted); }
.meta-select {
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
}
.meta-select:focus { border-color: var(--color-accent); }

/* ─── Color picker ───────────────────────────────────────────────────────────── */
#editor-color-picker {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 4px 0;
}
.color-swatch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
  position: relative;
}
[data-theme="light"] .color-swatch { background: var(--swatch-light); border-color: var(--border-color); }
[data-theme="dark"]  .color-swatch { background: var(--swatch-dark);  border-color: var(--border-strong); }
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: var(--color-accent); transform: scale(1.15); }
.color-swatch.active::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--color-accent);
}

/* ─── Tag input ──────────────────────────────────────────────────────────────── */
#editor-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  padding: 6px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  min-height: 36px;
  cursor: text;
}
#editor-tags:focus-within { border-color: var(--color-accent); }
.tag-chip {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(var(--color-accent-rgb), 0.12);
  color: var(--color-accent);
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}
.tag-remove {
  color: var(--color-accent);
  font-size: 9px;
  opacity: .7;
  transition: opacity var(--transition);
}
.tag-remove:hover { opacity: 1; }
#editor-tag-input {
  flex: 1;
  min-width: 80px;
  background: none;
  border: none;
  outline: none;
  font-size: 12px;
  color: var(--text-primary);
}
#editor-tag-input::placeholder { color: var(--text-muted); }

/* ─── Checklist ──────────────────────────────────────────────────────────────── */
#editor-checklist { display: none; }
.checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid var(--border-color);
}
.checklist-item:last-of-type { border-bottom: none; }
.checklist-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  accent-color: var(--color-accent);
  flex-shrink: 0;
  cursor: pointer;
}
.checklist-text {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.4;
}
.checklist-item.checked .checklist-text {
  text-decoration: line-through;
  color: var(--text-muted);
}
.checklist-delete {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-muted);
  border-radius: 4px;
  opacity: 0;
  transition: opacity var(--transition), background var(--transition);
}
.checklist-item:hover .checklist-delete { opacity: 1; }
.checklist-delete:hover { background: var(--bg-hover); color: #EF4444; }
.checklist-add {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 0;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color var(--transition);
}
.checklist-add:hover { color: var(--color-accent); }

/* ─── Editor actions footer ──────────────────────────────────────────────────── */
.editor-actions {
  display: flex;
  gap: 6px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.editor-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  transition: all var(--transition);
}
.editor-action-btn:hover { background: var(--bg-hover); color: var(--text-primary); }
.editor-action-btn--active { color: var(--color-accent); border-color: var(--color-accent); background: rgba(var(--color-accent-rgb),.08); }
.editor-action-btn--danger:hover { color: #EF4444; border-color: #EF4444; }

/* ─── Empty state ────────────────────────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-icon { font-size: 40px; margin-bottom: 14px; opacity: .5; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p  { font-size: 13px; }

/* ─── Modals ─────────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.modal-overlay.modal-open { display: flex; }
.modal-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.modal-title { font-size: 16px; font-weight: 700; margin-bottom: 20px; }
.modal-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────────── */
.btn {
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 500;
  transition: opacity var(--transition), background var(--transition);
}
.btn-primary { background: var(--color-accent); color: #fff; }
.btn-primary:hover { opacity: .88; }
.btn-secondary { background: var(--bg-hover); color: var(--text-primary); border: 1px solid var(--border-color); }
.btn-secondary:hover { background: var(--border-color); }

/* ─── Form elements ──────────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.form-label { font-size: 12px; font-weight: 500; color: var(--text-secondary); }
.form-input, .form-select {
  padding: 9px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 13px;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
.form-input:focus, .form-select:focus { border-color: var(--color-accent); }

/* ─── Workspace color picker ─────────────────────────────────────────────────── */
.ws-color-grid { display: flex; gap: 8px; flex-wrap: wrap; }
.ws-color-swatch {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform var(--transition), border-color var(--transition);
}
.ws-color-swatch:hover  { transform: scale(1.15); }
.ws-color-swatch.active { border-color: var(--text-primary); transform: scale(1.15); }

/* ─── Confirm dialog ─────────────────────────────────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(2px);
}
.confirm-box {
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: 24px 28px;
  max-width: 360px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}
.confirm-message { font-size: 14px; color: var(--text-primary); margin-bottom: 20px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
.btn-cancel  { padding: 8px 16px; border-radius: var(--radius-md); font-size: 13px; background: var(--bg-hover); color: var(--text-secondary); border: 1px solid var(--border-color); }
.btn-confirm { padding: 8px 16px; border-radius: var(--radius-md); font-size: 13px; background: #EF4444; color: #fff; }
.btn-cancel:hover  { background: var(--border-color); }
.btn-confirm:hover { opacity: .88; }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.hfz-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: var(--color-primary);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: opacity 0.22s ease, transform 0.22s ease;
  z-index: 999;
  pointer-events: none;
  white-space: nowrap;
}
[data-theme="dark"] .hfz-toast { background: #F1F5F9; color: var(--color-primary); }
.hfz-toast--visible { opacity: 1; transform: translateX(-50%) translateY(0); }
.hfz-toast--success { background: #10B981; }
.hfz-toast--error   { background: #EF4444; }
.hfz-toast--info    { background: var(--color-primary); }
[data-theme="dark"] .hfz-toast--success { background: #10B981; color: #fff; }
[data-theme="dark"] .hfz-toast--error   { background: #EF4444; color: #fff; }

/* ─── Popover ────────────────────────────────────────────────────────────────── */
.popover {
  position: fixed;
  background: var(--bg-panel);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  box-shadow: var(--shadow-lg);
  z-index: 150;
  min-width: 160px;
}
.popover-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  border-radius: 6px;
  width: 100%;
  text-align: left;
  transition: background var(--transition), color var(--transition);
}
.popover-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.popover-item--danger:hover { color: #EF4444; }

/* ─── Export menu ────────────────────────────────────────────────────────────── */
.export-menu { min-width: 180px; }

/* ─── Loading overlay ────────────────────────────────────────────────────────── */
#loading-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  z-index: 400;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 16px;
}
.loading-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border-color);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-text { font-size: 13px; color: var(--text-muted); }

/* ─── Sidebar overlay (mobile) ───────────────────────────────────────────────── */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 99;
}
#sidebar-overlay.visible { display: block; }

/* ─── Footer ─────────────────────────────────────────────────────────────────── */
.app-footer {
  text-align: center;
  font-size: 10px;
  color: var(--text-muted);
  opacity: 0.4;
  padding: 6px;
  flex-shrink: 0;
}


/* ─── Checklist card preview ─────────────────────────────────────────────────── */
.card-checklist-preview {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 10px;
}
.card-checklist-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.card-checklist-item.checked {
  color: var(--text-muted);
}
.card-checklist-item.checked .card-checklist-text {
  text-decoration: line-through;
}
.card-checkbox {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1.5px solid var(--border-strong);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 8px;
  color: transparent;
}
.card-checkbox--checked {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #fff;
}
.card-checklist-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.card-checklist-more {
  font-size: 11px;
  color: var(--text-muted);
  padding-left: 22px;
}
.card-checklist-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.card-progress-bar {
  flex: 1;
  height: 4px;
  background: var(--border-color);
  border-radius: 2px;
  overflow: hidden;
}
.card-progress-fill {
  height: 100%;
  background: var(--color-accent);
  border-radius: 2px;
  transition: width 0.3s ease;
}
.card-progress-text {
  font-size: 10px;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --editor-width: 100vw; }

  #sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100dvh;
    transform: translateX(-100%);
    z-index: 100;
  }
  #sidebar.sidebar-open { transform: translateX(0); box-shadow: var(--shadow-lg); }

  #editor-panel {
    position: fixed;
    inset: 0;
    z-index: 90;
    transform: translateX(100%);
  }
  #editor-panel.editor-open { transform: translateX(0); }

  #btn-new-note { right: 20px; }

  .btn-menu-toggle { display: flex !important; }
}

@media (max-width: 600px) {
  #notes-grid { grid-template-columns: 1fr; }
  #topbar { padding: 0 12px; }
  #notes-area { padding: 12px; }
}

/* ─── Menu toggle (mobile only, hidden on desktop) ───────────────────────────── */
.btn-menu-toggle { display: none; }
