/* ═══════════════════════════════════════════════════════════
   style.css — Daily Echo
   Modern, sleek, themeable private journal CSS
   ═══════════════════════════════════════════════════════════ */

/* ── Design Tokens ─────────────────────────────────────── */
:root,
[data-theme="dark"] {
  /* Core palette - Dark */
  --bg-base:        #09090d;
  --bg-surface:     #12121a;
  --bg-elevated:    #191924;
  --bg-hover:       #212130;
  --bg-active:      #2a2a3c;

  /* Borders */
  --border:         rgba(255, 255, 255, 0.08);
  --border-hover:   rgba(255, 255, 255, 0.16);
  --border-focus:   rgba(99, 102, 241, 0.5);

  /* Accent — Indigo / Violet */
  --accent:         #6366f1;
  --accent-soft:    rgba(99, 102, 241, 0.12);
  --accent-hover:   #818cf8;
  --accent-glow:    rgba(99, 102, 241, 0.25);

  /* Text */
  --text-primary:   #f3f3f6;
  --text-secondary: #9494a8;
  --text-muted:     #56566a;
  --text-inverse:   #09090d;

  /* Semantic Colors */
  --success:        #22c55e;
  --success-soft:   rgba(34, 197, 94, 0.12);
  --warning:        #f59e0b;
  --warning-soft:   rgba(245, 158, 11, 0.12);
  --danger:         #ef4444;
  --danger-soft:    rgba(239, 68, 68, 0.12);
  --info:           #38bdf8;
  --info-soft:      rgba(56, 189, 248, 0.12);

  /* Shadows */
  --shadow-sm:      0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md:      0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg:      0 12px 32px rgba(0, 0, 0, 0.7);
  --shadow-modal:   0 24px 64px rgba(0, 0, 0, 0.85);

  /* Scrollbar */
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
}

[data-theme="light"] {
  /* Core palette - Light */
  --bg-base:        #f8f9fc;
  --bg-surface:     #ffffff;
  --bg-elevated:    #ffffff;
  --bg-hover:       #f1f3f9;
  --bg-active:      #e5e8f3;

  /* Borders */
  --border:         rgba(0, 0, 0, 0.08);
  --border-hover:   rgba(0, 0, 0, 0.16);
  --border-focus:   rgba(99, 102, 241, 0.4);

  /* Accent */
  --accent:         #4f46e5;
  --accent-soft:    rgba(79, 70, 229, 0.08);
  --accent-hover:   #6366f1;
  --accent-glow:    rgba(79, 70, 229, 0.2);

  /* Text */
  --text-primary:   #0f172a;
  --text-secondary: #475569;
  --text-muted:     #94a3b8;
  --text-inverse:   #ffffff;

  /* Semantic Colors */
  --success:        #16a34a;
  --success-soft:   rgba(22, 163, 74, 0.1);
  --warning:        #d97706;
  --warning-soft:   rgba(217, 119, 6, 0.1);
  --danger:         #dc2626;
  --danger-soft:    rgba(220, 38, 38, 0.1);
  --info:           #0284c7;
  --info-soft:      rgba(2, 132, 199, 0.1);

  /* Shadows */
  --shadow-sm:      0 1px 3px rgba(0, 0, 0, 0.05);
  --shadow-md:      0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg:      0 12px 32px rgba(0, 0, 0, 0.12);
  --shadow-modal:   0 20px 48px rgba(0, 0, 0, 0.16);

  /* Scrollbar */
  --scrollbar-thumb: rgba(0, 0, 0, 0.18);
}

:root {
  /* Common System Variables */
  --font-ui:        'Inter', system-ui, -apple-system, sans-serif;
  --font-display:   'Instrument Serif', Georgia, serif;

  --sidebar-w:      240px;
  --topbar-h:       54px;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --radius-xl:      20px;

  --ease:           cubic-bezier(0.16, 1, 0.3, 1);
  --duration:       180ms;
}

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

html {
  font-size: 15px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100dvh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background-color var(--duration) var(--ease), color var(--duration) var(--ease);
}

img, svg { display: block; }
button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
input, select, textarea { font-family: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }

/* Focus ring */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

/* Scrollbars */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* Force [hidden] attribute */
[hidden] { display: none !important; }

/* ── App Shell Layout ───────────────────────────────────── */
.app-shell {
  display: flex;
  min-height: 100dvh;
}

/* ── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0;
  z-index: 200;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--duration) var(--ease), background-color var(--duration) var(--ease);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

.brand-text { display: flex; flex-direction: column; }

.brand-name {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  line-height: 1.2;
}

.brand-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* Profile */
.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.profile-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-soft);
  border: 1.5px solid var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--accent);
  flex-shrink: 0;
  overflow: hidden;
}

.profile-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.profile-info strong {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--text-primary);
}

.profile-info small {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.profile-menu-btn {
  width: 28px;
  height: 28px;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: color var(--duration), background-color var(--duration);
}

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

/* Dropdown Menu */
.profile-dropdown {
  position: absolute;
  top: calc(100% - 4px);
  left: 12px;
  right: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: var(--shadow-lg);
  z-index: 300;
  animation: dropIn 160ms var(--ease);
}

@keyframes dropIn {
  from { opacity: 0; transform: translateY(-6px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: color var(--duration), background-color var(--duration);
}

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

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

/* Sync Bar */
.sync-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
  transition: background-color var(--duration);
}

.sync-dot[data-status="synced"]  { background: var(--success); box-shadow: 0 0 6px var(--success); }
.sync-dot[data-status="syncing"] { background: var(--warning); animation: pulse 1.2s ease infinite; }
.sync-dot[data-status="offline"] { background: var(--text-muted); }
.sync-dot[data-status="error"]   { background: var(--danger); }

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

/* Sidebar Nav */
.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 2px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--duration), background-color var(--duration);
  text-align: left;
  width: 100%;
}

.nav-item svg { flex-shrink: 0; opacity: 0.7; }

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

.nav-item.active {
  color: var(--accent-hover);
  background: var(--accent-soft);
  font-weight: 600;
}

.nav-item.active svg { opacity: 1; }

.nav-item--danger:hover,
.nav-item--danger.active {
  color: var(--danger);
  background: var(--danger-soft);
}

.nav-count {
  margin-left: auto;
  font-size: 0.68rem;
  font-weight: 600;
  background: var(--bg-active);
  padding: 1px 6px;
  border-radius: 99px;
  color: var(--text-muted);
  min-width: 20px;
  text-align: center;
}

.nav-item.active .nav-count {
  background: var(--accent-glow);
  color: var(--accent);
}

/* Sidebar Footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sidebar-new-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 9px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background-color var(--duration), transform var(--duration);
}

.sidebar-new-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
}

.sidebar-new-btn:active { transform: translateY(0); }

.sidebar-danger-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 7px;
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  transition: color var(--duration), background-color var(--duration);
}

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

/* ── MAIN WRAP & PAGE ───────────────────────────────────── */
.main-wrap {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

.topbar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title {
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  transition: color var(--duration), background-color var(--duration);
  flex-shrink: 0;
}

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

.page {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 1200px;
  width: 100%;
}

/* ── CONTENT HEADER & CONTROLS ──────────────────────────── */
.content-header {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
}

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

#searchInput {
  width: 100%;
  height: 38px;
  padding: 0 14px 0 38px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 0.83rem;
  color: var(--text-primary);
  transition: border-color var(--duration), box-shadow var(--duration);
  appearance: none;
}

#searchInput::placeholder { color: var(--text-muted); }

#searchInput:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

/* Sort Controls */
.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-label {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
}

.sort-wrap .select-wrap select {
  height: 38px;
  padding: 0 32px 0 12px;
  font-size: 0.8rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Mobile Tabs */
.mobile-tabs {
  display: none;
  gap: 6px;
  width: 100%;
}

.tab-btn {
  padding: 6px 14px;
  border-radius: var(--radius-md);
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  transition: color var(--duration), background-color var(--duration), border-color var(--duration);
  white-space: nowrap;
}

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

.tab-btn.active {
  color: var(--accent-hover);
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ── STATS STRIP ────────────────────────────────────────── */
.stats-strip {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 20px;
  overflow-x: auto;
}

.stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0 20px;
  flex: 1;
}

.stat-pill:first-child { padding-left: 0; }
.stat-pill:last-child  { padding-right: 0; }

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--text-primary);
  line-height: 1;
}

.stat-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.stat-sep {
  width: 1px;
  height: 24px;
  background: var(--border);
  flex-shrink: 0;
}

/* ── ENTRY GRID ──────────────────────────────────────────── */
.content-area { flex: 1; }

.entry-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
  align-content: start;
}

/* Empty State */
.empty-state {
  grid-column: 1 / -1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 64px 20px;
  text-align: center;
}

.empty-icon { font-size: 2.5rem; line-height: 1; }

.empty-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-sub {
  font-size: 0.82rem;
  color: var(--text-muted);
}

/* ── ENTRY CARD ──────────────────────────────────────────── */
.entry-card {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color var(--duration), transform var(--duration), box-shadow var(--duration);
  position: relative;
  overflow: hidden;
}

.entry-card::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: transparent;
  transition: background-color var(--duration);
}

.entry-card[data-type="note"]::before   { background: var(--accent); }
.entry-card[data-type="memory"]::before { background: var(--warning); }
.entry-card[data-deleted="true"]::before { background: var(--danger); }

.entry-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.card-type-badge {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--bg-active);
  color: var(--text-muted);
}

.entry-card[data-type="note"]   .card-type-badge { background: var(--accent-soft);  color: var(--accent-hover); }
.entry-card[data-type="memory"] .card-type-badge { background: var(--warning-soft); color: var(--warning); }

.card-date {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.card-title {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  white-space: pre-wrap;
}

.card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

.card-status {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: capitalize;
}

.entry-card[data-deleted="true"] .card-status { color: var(--danger); }

.card-actions {
  display: flex;
  gap: 4px;
}

.card-btn {
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.7rem;
  font-weight: 500;
  transition: color var(--duration), background-color var(--duration);
  background: var(--bg-active);
  color: var(--text-muted);
}

.card-btn:hover           { color: var(--text-primary); background: var(--bg-hover); }
.card-btn--view:hover     { color: var(--info);          background: var(--info-soft); }
.card-btn--edit:hover     { color: var(--accent-hover);  background: var(--accent-soft); }
.card-btn--delete:hover   { color: var(--danger);        background: var(--danger-soft); }
.card-btn--restore:hover  { color: var(--success);       background: var(--success-soft); }
.card-btn--danger:hover   { color: var(--danger);        background: var(--danger-soft); }

/* ── OVERLAYS & MODALS ───────────────────────────────────── */

/* Global hidden rule (Always at top level) */
.overlay[aria-hidden="true"],
[hidden] {
  display: none !important;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 160ms ease;
}

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

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 560px;
  max-height: 90dvh;
  overflow-y: auto;
  box-shadow: var(--shadow-modal);
  animation: slideUp 200ms var(--ease);
}

.modal--sm { max-width: 420px; }

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

/* Fullscreen modal */
.overlay.fullscreen .modal {
  max-width: 100%;
  max-height: 100%;
  width: 100%;
  height: 100%;
  border-radius: 0;
  border: none;
}

.overlay.fullscreen .entry-form { height: calc(100% - 64px); }
.overlay.fullscreen .field-group--grow { flex: 1; }
.overlay.fullscreen .field-group--grow textarea { height: 100%; resize: none; }

/* Modal Header */
.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--border);
}

.modal-header-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.modal-kicker {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  font-family: var(--font-display);
  font-style: italic;
}

/* ── VIEW MODAL ──────────────────────────────────────────── */
.modal--view .view-content {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.view-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.view-type {
  font-weight: 600;
  color: var(--accent-hover);
}

.view-description {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 50vh;
  overflow-y: auto;
}

.view-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* ── ENTRY FORM ──────────────────────────────────────────── */
.entry-form {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row { display: flex; gap: 12px; }
.form-row--half > * { flex: 1; }

.field-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-group label {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.02em;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.char-count {
  font-size: 0.68rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* Form Controls */
input[type="text"],
input[type="date"],
textarea {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 12px;
  font-size: 0.85rem;
  color: var(--text-primary);
  transition: border-color var(--duration), box-shadow var(--duration);
  width: 100%;
}

input[type="text"]:focus,
input[type="date"]:focus,
textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

input[type="text"]::placeholder,
textarea::placeholder { color: var(--text-muted); }

textarea {
  resize: vertical;
  line-height: 1.6;
  min-height: 140px;
}

.select-wrap { position: relative; }

.select-wrap select {
  width: 100%;
  appearance: none;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 9px 32px 9px 12px;
  font-size: 0.85rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color var(--duration), box-shadow var(--duration);
}

.select-wrap select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
  outline: none;
}

.select-chevron {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--text-muted);
}

.form-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  padding-top: 4px;
}

/* ── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-md);
  font-size: 0.82rem;
  font-weight: 600;
  transition: background-color var(--duration), color var(--duration), transform var(--duration), box-shadow var(--duration);
  white-space: nowrap;
  line-height: 1;
}

.btn:active { transform: scale(0.98); }

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

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

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

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

.btn--google {
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-hover);
  width: 100%;
  padding: 11px 18px;
}

.btn--google:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
}

/* ── AUTH & IMPORT MODALS ───────────────────────────────── */
.auth-body, .import-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-copy {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 20px;
  background: var(--bg-surface);
  border: 1.5px dashed var(--border-hover);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color var(--duration), background-color var(--duration);
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-align: center;
}

.file-drop:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.file-drop input { display: none; }

/* ── TOAST SYSTEM ────────────────────────────────────────── */
.toast-wrap {
  position: fixed;
  bottom: 20px;
  right: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 900;
  pointer-events: none;
  max-width: 320px;
}

.toast {
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 500;
  line-height: 1.4;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  color: var(--text-primary);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transform: translateX(12px);
  transition: opacity 220ms ease, transform 220ms var(--ease);
  pointer-events: auto;
}

.toast--visible {
  opacity: 1;
  transform: translateX(0);
}

.toast--success { border-left: 3px solid var(--success); }
.toast--error   { border-left: 3px solid var(--danger); }
.toast--warning { border-left: 3px solid var(--warning); }
.toast--info    { border-left: 3px solid var(--accent); }

/* ── SITE FOOTER ────────────────────────────────────────── */
.site-footer {
  margin-left: var(--sidebar-w);
  border-top: 1px solid var(--border);
  background: var(--bg-surface);
  transition: margin-left var(--duration) var(--ease);
}

.footer-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.footer-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 180px;
}

.footer-logo {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  flex-shrink: 0;
}

.footer-brand-name {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.footer-brand-sub {
  display: block;
  font-size: 0.68rem;
  color: var(--text-muted);
}

.footer-links {
  display: flex;
  align-items: center;
  gap: 4px;
}

.footer-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 10px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: color var(--duration), background-color var(--duration);
}

.footer-link:hover {
  color: var(--accent-hover);
  background: var(--accent-soft);
}

.footer-copy {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ── MOBILE & TABLET RESPONSIVE ──────────────────────────── */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    box-shadow: var(--shadow-lg);
  }

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

  .sidebar-backdrop.open { display: block; }

  .main-wrap, .site-footer { margin-left: 0; }

  .topbar { display: flex; }

  .mobile-tabs {
    display: flex;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 2px;
  }

  .page { padding: 16px; gap: 16px; }

  .stats-strip { padding: 10px 14px; }
  .stat-pill { padding: 0 10px; }
  .stat-value { font-size: 1.2rem; }

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

  .overlay { padding: 0; align-items: flex-end; }

  .modal {
    max-width: 100%;
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    max-height: 92dvh;
  }

  .modal--sm { max-height: 80dvh; }

  .toast-wrap {
    left: 16px;
    right: 16px;
    bottom: 16px;
    max-width: 100%;
  }

  .form-row--half { flex-direction: column; }

  .footer-inner {
    flex-direction: column;
    align-items: flex-start;
    gap: 14px;
    padding: 20px 16px;
  }

  .footer-copy { white-space: normal; }
}

@media (min-width: 769px) and (max-width: 1024px) {
  :root { --sidebar-w: 200px; }

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

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
