:root {
  --bg: #f0f0ec;
  --box-bg: #ffffff;
  --box-border: #d4d4d0;
  --box-header-bg: #f7f7f5;
  --text-primary: #1a1a1a;
  --text-secondary: #6b6b6b;
  --text-muted: #999;
  --accent: #2d6a4f;
  --accent-light: #d8f3dc;
  --done-text: #888;
  --card-bg: #ffffff;
  --card-hover: #fafaf8;
  --card-border: #e8e8e4;
  --card-done-bg: #f5f5f3;
  --danger: #c0392b;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 30px rgba(0,0,0,0.12);
  --radius: 8px;
  --radius-lg: 12px;

  --topbar-bg: #ffffff;
  --surface-hover: rgba(0,0,0,0.06);
  --danger-overlay: rgba(192,57,43,0.08);
  --card-border-hover: #d0d0cc;
  --scroll-thumb: #ccc;
  --resize-handle: #bbb;
  --resize-handle-active: #999;
  --tooltip-bg: #1a1a1a;
  --danger-bg: #fff2f1;
  
  /* Habit Specific */
  --habit-grid-border: #e8e8e4;
  --habit-cell-inactive: #e0e0e0;
  --habit-cell-hover: #d0d0d0;
}

html[data-theme="dark"] {
  --bg: #0f1116;
  --box-bg: #141a24;
  --box-border: #2a3240;
  --box-header-bg: #182032;
  --text-primary: #e7edf6;
  --text-secondary: #a9b2c1;
  --text-muted: #7f8898;
  --accent: #3ba57a;
  --accent-light: rgba(59,165,122,0.18);
  --done-text: #9aa4b6;
  --card-bg: #121722;
  --card-hover: #182032;
  --card-border: #273045;
  --card-done-bg: #101521;
  --danger: #ff5c5c;
  --topbar-bg: #101521;
  --surface-hover: rgba(255,255,255,0.08);
  --danger-overlay: rgba(255,92,92,0.14);
  --card-border-hover: #34405a;
  --scroll-thumb: #3b465f;
  --resize-handle: #6d788f;
  --resize-handle-active: #a9b2c1;
  --tooltip-bg: #0b0e14;
  --danger-bg: rgba(255,92,92,0.12);
  
  /* Habit Specific Dark */
  --habit-grid-border: #2a3240;
  --habit-cell-inactive: #2a3240;
  --habit-cell-hover: #34405a;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  overflow: auto;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px;
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--box-border);
  box-shadow: var(--shadow-sm);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

.topbar-brand svg { opacity: 0.8; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center; /* Centering for icon-only buttons */
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--box-border);
  border-radius: var(--radius);
  background: var(--box-bg);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.btn:hover { background: var(--box-header-bg); border-color: #bbb; }

.btn-primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn-primary:hover { background: #245a42; }

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover { background: #a93226; }

/* Dashboard */
#dashboard {
  position: relative;
  min-height: calc(100vh - 53px);
  padding: 24px;
}

/* Box */
.box {
  position: absolute;
  background: var(--box-bg);
  border: 1.5px solid var(--box-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: box-shadow 0.2s;
  min-width: 260px;
  min-height: 120px;
}

.box:hover { box-shadow: var(--shadow-md); }

.box.dragging {
  box-shadow: var(--shadow-lg);
  opacity: 0.92;
  z-index: 500 !important;
}

.box.resizing {
  box-shadow: var(--shadow-lg);
}

/* Box header */
.box-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--box-header-bg);
  border-bottom: 1px solid var(--card-border);
  cursor: default;
  user-select: none;
  flex-shrink: 0;
}

.box-header:active { cursor: grabbing; }

/* When in Edit Mode */
body.is-editing .box-header {
  cursor: grab;
}

body.is-editing .box-header:active {
  cursor: grabbing;
}

/* Visual cue when editing */
body.is-editing .box {
  border-color: var(--accent);
}

.box-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: -0.3px;
  border: 1px solid transparent;
  padding: 2px 6px;
  border-radius: 4px;
  outline: none;
  background: transparent;
  cursor: default;
  min-width: 60px;
}

.box-title.editing {
  border-color: var(--accent);
  background: var(--box-bg);
  cursor: text;
}

.box-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.box-header-btn {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.box-header-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

.box-header-btn.delete-box:hover { color: var(--danger); background: var(--danger-overlay); }

/* Cards container (KANBAN) */
.box-cards {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.box-cards::-webkit-scrollbar { width: 10px; }
.box-cards::-webkit-scrollbar-track { background: rgba(0,0,0,0.03); }
.box-cards::-webkit-scrollbar-thumb { 
    background: var(--scroll-thumb); 
    border-radius: 4px; 
    border: 2px solid var(--box-bg);
}
.box-cards::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* Card */
.card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  margin: 0;
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  cursor: grab;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s, margin 0.2s, border-color 0.15s;
  user-select: none;
}

.card:active { cursor: grabbing; }

.card:hover { background: var(--card-hover); border-color: var(--card-border-hover); }

.card.done {
  background: var(--card-done-bg);
}

.card.done .card-title {
  text-decoration: line-through;
  color: var(--done-text);
}

.card.overdue {
  border-color: var(--danger);
  background: var(--danger-bg);
  box-shadow: inset 3px 0 0 var(--danger);
}

.card.overdue .card-bullet { background: var(--danger); }

/* The visual gap/placeholder */
.card-placeholder {
  background: rgba(0, 0, 0, 0.04);
  border: 1.5px dashed var(--card-border-hover);
  border-radius: var(--radius);
  margin-bottom: 12px;
  flex-shrink: 0;
  pointer-events: none;
}

/* While dragging, hide the original card so only the ghost image and placeholder exist */
.card.is-dragging {
  display: none;
}

/* Dark mode adjustment for placeholder */
html[data-theme="dark"] .card-placeholder {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--card-border);
}

.card.done.overdue {
  background: var(--card-done-bg);
}

.card-bullet {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-primary);
  margin-top: 7px;
  flex-shrink: 0;
}

.card.done .card-bullet { background: var(--done-text); }

.card-content {
  flex: 1;
  min-width: 0;
}

.card-title {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Updated Horizontal Meta Style */
.card-meta {
  font-family: 'JetBrains Mono', monospace;
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.4;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.card-meta span {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.card-meta .separator {
  color: var(--card-border-hover);
  font-size: 8px;
}

.card-meta .label { color: var(--text-secondary); margin-right: 3px; }

/* In-progress spinner animation */
.spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid rgba(0,0,0,0.1);
  border-radius: 50%;
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
  margin-right: 5px;
}

/* Done Check Icon */
.check-icon {
  display: inline-block;
  margin-right: 5px;
  color: var(--accent);
  vertical-align: -1px;
}

html[data-theme="dark"] .spinner {
  border-color: rgba(255,255,255,0.1);
  border-top-color: var(--accent);
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ========================================= */
/* ========================================= */
/* HABIT TRACKER STYLES (Refactored)         */
/* ========================================= */
.habit-container {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  font-size: 13px;
  position: relative;
  /* Define sidebar width as a variable for easy resizing */
  --sidebar-width: 140px; 
}

/* Navigation Header (Month/Year) - Remains the same */
.habit-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--box-bg);
  border-bottom: 1px solid var(--habit-grid-border);
  flex-shrink: 0;
  z-index: 50; /* Above everything */
}

.habit-month-label { font-weight: 700; color: var(--text-primary); user-select: none; }
.habit-nav-btn {
  background: transparent; border: 1px solid var(--box-border); border-radius: 4px;
  cursor: pointer; color: var(--text-secondary); width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center; transition: all 0.1s;
}
.habit-nav-btn:hover { background: var(--surface-hover); color: var(--text-primary); }

/* --- UNIFIED SCROLL CONTAINER --- */
.habit-scroll-container {
  flex: 1;
  overflow: auto; /* Handles both X and Y scrolling */
  display: flex;
  flex-direction: column;
  position: relative;
  scroll-behavior: auto;
}

/* Custom scrollbar for the container */
.habit-scroll-container::-webkit-scrollbar { height: 10px; width: 10px; }
.habit-scroll-container::-webkit-scrollbar-thumb { 
  background: var(--scroll-thumb); border-radius: 4px; border: 2px solid var(--box-bg); 
}
.habit-scroll-container::-webkit-scrollbar-corner { background: var(--box-bg); }

/* --- ROWS --- */
.habit-unified-row {
  display: flex;
  min-width: min-content; /* Ensure row expands to fit all columns */
  border-bottom: 1px solid var(--habit-grid-border);
}

/* --- CELLS --- */

/* 1. The Sidebar Cell (Sticky Left) */
.habit-cell-sidebar {
  position: sticky;
  left: 0;
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--box-bg); /* Opaque background is crucial for sticky */
  border-right: 1px solid var(--habit-grid-border);
  z-index: 20; 
  display: flex;
  align-items: center;
  padding: 0 10px;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}

/* Header version of the sidebar cell (Top-Left Corner) */
.habit-cell-sidebar.header-col {
  background: var(--box-header-bg);
  z-index: 40; /* Highest z-index: sits on top of sidebar AND date headers */
  top: 0;      /* Also sticky to top */
  height: 40px;
  border-bottom: 1px solid var(--habit-grid-border);
}

/* 2. The Date Cell */
.habit-cell-date {
  width: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-right: 1px solid var(--habit-grid-border);
}

/* Header version of the date cell (Sticky Top) */
.habit-cell-date.header-col {
  position: sticky;
  top: 0;
  height: 40px;
  background: var(--box-header-bg);
  z-index: 30; /* Higher than content, lower than top-left corner */
  flex-direction: column;
  font-size: 10px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--habit-grid-border);
}

.habit-cell-date.header-col.today {
  color: #000000;          /* Black text */
  background: #d4d4d0;     /* Slightly darker gray background */
  font-weight: 700;        /* Bold */
}

/* Dark Mode Override */
html[data-theme="dark"] .habit-cell-date.header-col.today {
  color: #ffffff;          /* White text */
  background: #121827;     /* Black background */
}

/* Content version of date cell (Checkboxes) */
.habit-cell-date.content-col {
  height: 36px;
  cursor: pointer;
  transition: background 0.1s;
}

/* UPDATED: Only apply hover color if NOT completed */
.habit-cell-date.content-col:not(.completed):hover .habit-check-box {
  background: var(--habit-cell-hover);
}

/* The Checkbox Logic */
.habit-check-box {
  width: 18px; height: 18px; border-radius: 4px;
  background: var(--habit-cell-inactive);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none; /* Let clicks pass to the cell */
}
.habit-cell-date.completed .habit-check-box {
  background: var(--accent);
  transform: scale(1.1);
  box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

/* Draggable Row Styles */
.habit-unified-row.content-row {
  cursor: grab;
  user-select: none;
  transition: transform 0.2s cubic-bezier(0.2, 0, 0, 1), box-shadow 0.2s, border-color 0.15s;
}
.habit-unified-row.content-row:active { cursor: grabbing; }
.habit-unified-row.content-row:hover .habit-cell-sidebar {
  background: var(--card-hover);
}
.habit-unified-row.is-dragging {
  display: none;
}
/* Placeholder for habit row drag */
.habit-row-placeholder {
  background: rgba(0, 0, 0, 0.04);
  border: 1.5px dashed var(--card-border-hover);
  border-radius: 0;
  min-height: 36px;
  min-width: min-content;
  pointer-events: none;
  border-bottom: 1px solid var(--habit-grid-border);
}
html[data-theme="dark"] .habit-row-placeholder {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--card-border);
}

.habit-name-text {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Resizer Handle (Lives in the Top-Left Header Cell) */
.habit-sidebar-resizer {
  position: absolute; top: 0; right: -4px; bottom: 0;
  width: 9px; cursor: col-resize; z-index: 50;
  opacity: 0; transition: opacity 0.2s;
}
.habit-cell-sidebar:hover .habit-sidebar-resizer,
.habit-sidebar-resizer:hover { opacity: 1; }
.habit-sidebar-resizer::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: 4px;
  width: 1px; background: var(--accent);
}

/* Resize handle */
.resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
  /* HIDDEN for non-diagonal resize mode */
  display: none;
}

.box.show-resize .resize-handle,
.box.resizing .resize-handle {
  opacity: 1;
  pointer-events: auto;
}

.resize-handle::after {
  content: '';
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--resize-handle);
  border-bottom: 2px solid var(--resize-handle);
  border-radius: 0 0 2px 0;
  transition: border-color 0.15s;
}

.box.show-resize .resize-handle::after { border-color: var(--resize-handle-active); }

/* Size tooltip */
.size-tooltip {
  position: absolute;
  bottom: 10px;
  right: 28px;
  background: var(--tooltip-bg);
  color: #fff;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.15s;
}

.box.resizing .size-tooltip { opacity: 1; }

/* Modal overlay */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s;
}

.modal-overlay.active { opacity: 1; visibility: visible; }

.modal {
  background: var(--box-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 480px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  transform: translateY(10px);
  transition: transform 0.2s;
  display: flex;
  flex-direction: column;
}

.modal-overlay.active .modal { transform: translateY(0); }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--card-border);
  flex-shrink: 0;
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-close {
  width: 32px; height: 32px;
  display: flex; align-items: center; justify-content: center;
  border: none; background: transparent;
  border-radius: 6px; cursor: pointer;
  color: var(--text-secondary);
  font-size: 18px;
  transition: all 0.15s;
}

.modal-close:hover { background: var(--surface-hover); }

.modal-body { padding: 18px 22px; flex: 1; overflow-y: auto; }

.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--box-header-bg);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input[type="color"] {
  height: 38px;
  padding: 0;
  background: transparent;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  background: var(--box-bg);
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row .form-group { flex: 1; }

/* History Section */
.history-section {
  margin-top: 20px;
  padding-top: 15px;
  border-top: 1px solid var(--card-border);
}

.history-section h4 {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.history-list {
  list-style: none;
  max-height: 120px;
  overflow-y: auto;
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
}

.history-list li {
  padding: 4px 0;
  color: var(--text-muted);
  border-bottom: 1px dashed var(--surface-hover);
  display: flex;
  gap: 10px;
}

.history-list li:last-child { border-bottom: none; }

.history-date {
  color: var(--text-secondary);
  min-width: 110px;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px 18px;
  border-top: 1px solid var(--card-border);
  flex-shrink: 0;
}

.modal-footer-left {
  display: flex;
  gap: 8px;
}

.modal-footer-right {
  display: flex;
  gap: 8px;
}

/* Box settings sizes table */
#boxSizeReadout { font-family: 'JetBrains Mono', monospace; }
.sizes-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 12.5px;
}

.sizes-table th, .sizes-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--card-border);
  vertical-align: top;
}

.sizes-table th {
  font-size: 11px;
  letter-spacing: 0.6px;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.sizes-table tr.active-row td {
  background: var(--accent-light);
}

.sizes-table .mono {
  font-family: 'JetBrains Mono', monospace;
}

/* Checkbox toggle for done */
.toggle-done {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.toggle-done input { display: none; }

.toggle-done .check {
  width: 20px; height: 20px;
  border: 2px solid var(--box-border);
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.toggle-done input:checked + .check {
  background: var(--accent);
  border-color: var(--accent);
}

.toggle-done input:checked + .check::after {
  content: '✓';
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

.empty-state svg { opacity: 0.3; margin-bottom: 16px; }
.empty-state p { font-size: 14px; line-height: 1.6; }

/* Confirm dialog */
.confirm-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 5000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s;
}

.confirm-overlay.active { opacity: 1; visibility: visible; }

.confirm-box {
  background: var(--box-bg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
  width: 360px;
  max-width: 90vw;
  text-align: center;
}

.confirm-box p {
  font-size: 14px;
  margin-bottom: 18px;
  color: var(--text-primary);
  line-height: 1.5;
}

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; }
  #dashboard { padding: 12px; }
}

/* Login Screen */
.login-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--bg);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}

.login-overlay.active { opacity: 1; visibility: visible; }

.login-box {
  background: var(--box-bg);
  border: 1px solid var(--box-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  width: 380px;
  max-width: 90vw;
}

.login-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--text-primary);
}

.login-brand h1 { font-size: 24px; letter-spacing: -1px; }

.login-subtitle {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 30px;
}

#authToggleLink:hover { text-decoration: underline !important; }

/* User Menu & Dropdown */
.user-menu-container { position: relative; }

.btn-icon { padding: 4px; border-radius: 50%; width: 36px; height: 36px; overflow: hidden; }

.user-avatar {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%; /* Circular container */
  overflow: hidden;   /* Clips square images to circle */
}

.user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* Prevents image stretching/squishing */
}

.create-menu-container {
  position: relative;
}

.create-dropdown {
  position: absolute;
  top: 45px;
  right: -60px; /* Aligns slightly differently than user menu */
  width: 180px;
  background: var(--box-bg);
  border: 1px solid var(--box-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  padding: 6px 0;
  z-index: 2000;
}

.create-dropdown.active {
  display: flex;
}

.dropdown-menu {
  position: absolute; top: 45px; right: 0;
  width: 200px;
  background: var(--box-bg);
  border: 1px solid var(--box-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  padding: 6px 0;
  z-index: 2000;
}
.dropdown-menu.active { display: flex; }

.dropdown-header { padding: 8px 16px; font-weight: 700; color: var(--text-primary); font-size: 14px; border-bottom: 1px solid var(--box-border); margin-bottom: 4px; }

.dropdown-item {
  background: none; border: none; width: 100%; text-align: left;
  padding: 8px 16px; font-size: 13px; color: var(--text-primary); cursor: pointer;
  display: flex; align-items: center; gap: 8px; font-family: inherit;
}
.dropdown-item:hover { background: var(--surface-hover); }
.dropdown-item.danger { color: var(--danger); }
.dropdown-item.danger:hover { background: var(--danger-overlay); }
.dropdown-divider { height: 1px; background: var(--box-border); margin: 4px 0; }

/* Profile Modal Specifics */
.profile-header { display: flex; flex-direction: column; align-items: center; margin-bottom: 20px; }
.profile-avatar-edit {
  width: 80px; height: 80px; border-radius: 50%; overflow: hidden;
  position: relative; cursor: pointer; border: 2px solid var(--box-border);
}
.profile-avatar-edit img { width: 100%; height: 100%; object-fit: cover; }
.avatar-placeholder { width: 100%; height: 100%; background: var(--box-header-bg); display: flex; align-items: center; justify-content: center; font-size: 24px; color: var(--text-secondary); }
.avatar-overlay {
  position: absolute; bottom: 0; left: 0; right: 0; background: rgba(0,0,0,0.6);
  color: white; font-size: 10px; text-align: center; padding: 4px 0; opacity: 0; transition: opacity 0.2s;
}
.profile-avatar-edit:hover .avatar-overlay { opacity: 1; }
.profile-hint { font-size: 11px; color: var(--text-muted); margin-top: 8px; }