/* ============================================================
   DRIFT — Dark Minimalist Journal
   Palette: near-black bg, warm off-white text, muted amber accent
   Type: DM Serif Display (brand) + Inter (body) + JetBrains Mono (data)
   ============================================================ */

:root {
  --bg:        #0e0e0f;
  --bg-2:      #141415;
  --bg-3:      #1c1c1e;
  --bg-4:      #242426;
  --border:    #2a2a2d;
  --border-2:  #3a3a3e;

  --text:      #e8e6e1;
  --text-2:    #9e9c98;
  --text-3:    #5c5b58;

  --accent:    #c9a96e;
  --accent-2:  #a07840;
  --accent-glow: rgba(201, 169, 110, 0.12);

  --red:       #c96e6e;
  --green:     #6ec98a;
  --blue:      #6e9dc9;

  --radius:    8px;
  --radius-lg: 14px;
  --sidebar-w: 220px;
  --topbar-h:  52px;

  --font-brand: 'DM Serif Display', Georgia, serif;
  --font-body:  'Inter', system-ui, sans-serif;
  --font-mono:  'JetBrains Mono', 'Courier New', monospace;
}

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

html { font-size: 15px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-weight: 400;
  line-height: 1.6;
  height: 100dvh;
  overflow: hidden;
}

/* ─── UTILITIES ─────────────────────────────────────── */
.hidden { display: none !important; }

button { cursor: pointer; border: none; background: none; font: inherit; color: inherit; }

input, select, textarea {
  font: inherit;
  color: var(--text);
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  outline: none;
  transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
textarea { resize: vertical; }
select option { background: var(--bg-3); }

/* ─── LAYOUT ─────────────────────────────────────────── */
.app {
  display: flex;
  height: 100dvh;
}

/* ─── SIDEBAR ────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100dvh;
  overflow: hidden;
  transition: transform 0.25s ease;
  z-index: 100;
}

.sidebar-top {
  padding: 1.75rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
}

.logo {
  font-family: var(--font-brand);
  font-size: 1.7rem;
  color: var(--accent);
  letter-spacing: -0.02em;
  font-style: italic;
}

.tagline {
  font-size: 0.68rem;
  color: var(--text-3);
  margin-top: 0.15rem;
  letter-spacing: 0.06em;
  text-transform: lowercase;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.6rem 0.85rem;
  border-radius: var(--radius);
  font-size: 0.85rem;
  font-weight: 400;
  color: var(--text-2);
  text-align: left;
  width: 100%;
  transition: background 0.15s, color 0.15s;
}
.nav-btn:hover { background: var(--bg-3); color: var(--text); }
.nav-btn.active { background: var(--accent-glow); color: var(--accent); }

.nav-icon { font-size: 0.9rem; width: 1rem; text-align: center; }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.sidebar-date {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
}

/* ─── MAIN ───────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100dvh;
}

/* ─── TOPBAR ─────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-2);
  flex-shrink: 0;
}

.menu-toggle {
  font-size: 1.1rem;
  color: var(--text-2);
  display: none;
  padding: 0.25rem;
}
.menu-toggle:hover { color: var(--text); }

.topbar-title {
  font-family: var(--font-brand);
  font-size: 1rem;
  font-style: italic;
  color: var(--text-2);
  flex: 1;
}

.fab-small {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #000;
  border-radius: 50%;
  font-size: 1.2rem;
  font-weight: 300;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s;
}
.fab-small:hover { background: var(--accent-2); }

/* ─── VIEWS ──────────────────────────────────────────── */
.view {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 1.5rem;
}
.view.active { display: flex; flex-direction: column; gap: 1rem; }

/* ─── JOURNAL VIEW ───────────────────────────────────── */
.journal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  padding-bottom: 0.5rem;
}

.journal-date-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.date-nav-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: var(--text-2);
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.date-nav-btn:hover { background: var(--bg-3); color: var(--text); }

.journal-day {
  font-family: var(--font-brand);
  font-size: 1.35rem;
  font-style: italic;
  color: var(--accent);
  min-width: 200px;
  text-align: center;
}

.journal-entries {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

/* ─── ENTRY CARD ─────────────────────────────────────── */
.entry-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  transition: border-color 0.15s;
  position: relative;
}
.entry-card:hover { border-color: var(--border-2); }

.entry-cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 0.45rem;
  flex-shrink: 0;
}

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

.entry-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.entry-cat-label {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-3);
}

.entry-subtype {
  font-size: 0.8rem;
  color: var(--text-2);
}

.entry-time {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-3);
  margin-left: auto;
}

.entry-note {
  font-size: 0.85rem;
  color: var(--text);
  margin-top: 0.3rem;
  line-height: 1.5;
}

.entry-meta {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.chip {
  font-size: 0.68rem;
  padding: 0.15rem 0.55rem;
  border-radius: 999px;
  background: var(--bg-4);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.chip.person { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.entry-stars {
  font-size: 0.7rem;
  color: var(--accent);
  margin-top: 0.25rem;
  letter-spacing: 0.05em;
}

.entry-actions {
  display: flex;
  gap: 0.3rem;
  opacity: 0;
  transition: opacity 0.15s;
}
.entry-card:hover .entry-actions { opacity: 1; }

.entry-action-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--text-3);
  transition: background 0.15s, color 0.15s;
}
.entry-action-btn:hover { background: var(--bg-4); color: var(--text); }
.entry-action-btn.del:hover { color: var(--red); }

/* ─── EMPTY STATE ────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  padding: 3rem 1rem;
  color: var(--text-3);
  text-align: center;
}

.empty-icon {
  font-size: 2.5rem;
  color: var(--border-2);
}

/* ─── FILTER BAR ─────────────────────────────────────── */
.filter-bar {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0.85rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.filter-row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-select, .filter-input {
  height: 34px;
  font-size: 0.8rem;
  padding: 0 0.65rem;
}

.filter-input { flex: 1; min-width: 120px; }

.filter-tags {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.filter-tag-btn {
  font-size: 0.7rem;
  padding: 0.2rem 0.65rem;
  border-radius: 999px;
  background: var(--bg-4);
  color: var(--text-2);
  border: 1px solid var(--border);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.filter-tag-btn:hover, .filter-tag-btn.active {
  background: var(--accent-glow);
  border-color: var(--accent);
  color: var(--accent);
}

.log-entries {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* ─── STATS ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.stat-card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.stat-card-title {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: 1rem;
}

#stat-heatmap-card { grid-column: 1 / -1; }

.chart-wrap { position: relative; height: 180px; }

/* Heatmap */
.heatmap-container {
  overflow-x: auto;
  padding-bottom: 0.5rem;
}

.heatmap-grid {
  display: flex;
  gap: 3px;
}

.heatmap-week {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.heatmap-cell {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  background: var(--bg-4);
  transition: background 0.1s;
}
.heatmap-cell.l1 { background: #3a2e1a; }
.heatmap-cell.l2 { background: #7a5c2a; }
.heatmap-cell.l3 { background: #b08040; }
.heatmap-cell.l4 { background: var(--accent); }

/* Tag/People stat list */
.tag-stat-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.tag-stat-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.tag-stat-name {
  font-size: 0.82rem;
  color: var(--text);
  min-width: 80px;
}

.tag-stat-bar-wrap {
  flex: 1;
  height: 4px;
  background: var(--bg-4);
  border-radius: 2px;
  overflow: hidden;
}

.tag-stat-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.tag-stat-count {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-3);
}

/* Streaks */
.streaks-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.streak-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

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

.streak-label { font-size: 0.82rem; flex: 1; }

.streak-count {
  font-family: var(--font-mono);
  font-size: 0.9rem;
  color: var(--accent);
  font-weight: 500;
}

.streak-suffix { font-size: 0.7rem; color: var(--text-3); }

/* ─── SETTINGS ───────────────────────────────────────── */
.settings-section {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.settings-title {
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-3);
}

.settings-row { display: flex; align-items: center; }

.toggle-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  font-size: 0.85rem;
}

.toggle-input { display: none; }

.toggle-slider {
  width: 40px;
  height: 22px;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  border-radius: 11px;
  position: relative;
  transition: background 0.2s;
  flex-shrink: 0;
}
.toggle-slider::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--text-3);
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}
.toggle-input:checked + .toggle-slider { background: var(--accent-glow); border-color: var(--accent); }
.toggle-input:checked + .toggle-slider::after { transform: translateX(18px); background: var(--accent); }

.text-input {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  color: var(--text);
  font: inherit;
  outline: none;
  transition: border-color 0.15s;
}
.text-input:focus { border-color: var(--accent); }
.text-input.short { width: 100px; }
.text-input.textarea { width: 100%; }

.category-settings-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.cat-settings-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem;
  border-radius: var(--radius);
  background: var(--bg-3);
}

.cat-color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.cat-name { font-size: 0.85rem; flex: 1; }

.cat-sensitive-toggle {
  font-size: 0.7rem;
  color: var(--text-3);
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: all 0.15s;
}
.cat-sensitive-toggle.on { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }

/* ─── MODAL ──────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal {
  background: var(--bg-2);
  border: 1px solid var(--border-2);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-family: var(--font-brand);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--accent);
  flex: 1;
}

.modal-close {
  font-size: 0.9rem;
  color: var(--text-3);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--bg-4); color: var(--text); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  display: flex;
  gap: 0.5rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-3);
}

.optional { text-transform: none; letter-spacing: 0; font-weight: 400; font-style: italic; }

/* Category Picker */
.category-picker {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.cat-pick-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-2);
  background: var(--bg-3);
  transition: all 0.15s;
}
.cat-pick-btn:hover { border-color: var(--border-2); color: var(--text); }
.cat-pick-btn.selected { color: #000; font-weight: 500; }

/* Tag input */
.tag-input-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.4rem 0.5rem;
  min-height: 40px;
  align-items: center;
  transition: border-color 0.15s;
}
.tag-input-wrap:focus-within { border-color: var(--accent); }

.tag-input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 0.82rem;
  color: var(--text);
  flex: 1;
  min-width: 80px;
  padding: 0.1rem 0;
}

.tag-chip {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  border-radius: 999px;
  padding: 0.1rem 0.5rem 0.1rem 0.6rem;
  font-size: 0.72rem;
  color: var(--text-2);
}
.tag-chip.person { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.tag-chip-remove {
  font-size: 0.65rem;
  color: var(--text-3);
  cursor: pointer;
  line-height: 1;
}
.tag-chip-remove:hover { color: var(--red); }

/* Star rating */
.star-rating { display: flex; gap: 0.25rem; }

.star {
  font-size: 1.2rem;
  color: var(--bg-4);
  cursor: pointer;
  transition: color 0.1s;
  line-height: 1;
}
.star.active { color: var(--accent); }

/* ─── BUTTONS ────────────────────────────────────────── */
.btn-primary {
  background: var(--accent);
  color: #000;
  font-weight: 500;
  font-size: 0.82rem;
  padding: 0.5rem 1.1rem;
  border-radius: var(--radius);
  transition: background 0.15s;
}
.btn-primary:hover { background: var(--accent-2); }

.btn-ghost {
  background: transparent;
  color: var(--text-2);
  font-size: 0.82rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.15s;
}
.btn-ghost:hover { border-color: var(--border-2); color: var(--text); background: var(--bg-3); }

/* ─── PIN SCREEN ─────────────────────────────────────── */
.pin-screen {
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pin-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  padding: 2rem;
}

.pin-logo {
  font-family: var(--font-brand);
  font-size: 2.5rem;
  font-style: italic;
  color: var(--accent);
}

.pin-sub {
  font-size: 0.8rem;
  color: var(--text-3);
}

.pin-dots {
  display: flex;
  gap: 0.8rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--bg-4);
  border: 1px solid var(--border-2);
  transition: background 0.15s;
}
.dot.filled { background: var(--accent); border-color: var(--accent); }

.pin-pad {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  gap: 0.6rem;
}

.pin-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--bg-2);
  border: 1px solid var(--border);
  font-size: 1.1rem;
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.pin-btn:hover { background: var(--bg-3); }
.pin-btn:active { background: var(--bg-4); }
.pin-ok { background: var(--accent-glow); color: var(--accent); border-color: var(--accent); }
.pin-ok:hover { background: var(--accent); color: #000; }

.pin-error {
  font-size: 0.8rem;
  color: var(--red);
}

/* ─── RESPONSIVE ─────────────────────────────────────── */
@media (max-width: 700px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100dvh;
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 24px rgba(0,0,0,0.5); }
  .menu-toggle { display: flex; }
  .stats-grid { grid-template-columns: 1fr; }
  #stat-heatmap-card { grid-column: 1; }
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 3px; }
