:root {
  --bg-color: #050505;
  --dot-empty: #1a1a1a;
  --dot-filled: #3b82f6;
  --dot-current: #ffffff;
  --text-primary: #ffffff;
  --text-secondary: #666666;
  --text-link: #7f9fd3;
  --scrollbar-color: #333;
  --dot-filled-journal: #8b76ff;
  --font-main: "Outfit", sans-serif;
  --font-mono: "Space Mono", monospace;
  --font-pixel: "Pixelify Sans", sans-serif;

  /* Modal & Input Variables (Dark Default) */
  --modal-bg: #111111;
  --modal-border: #333333;
  --separator-color: #222222;
  --input-bg: #0a0a0a;
  --input-border: #333333;
}

[data-theme="light"] {
  --bg-color: #ffffff;
  --dot-empty: #e5e5e5;
  --dot-filled: #3b82f6;
  --dot-current: #14275d;
  --text-primary: #171717;
  --text-secondary: #737373;
  --text-link: #2c446b;
  --scrollbar-color: #d3d3d3;
  --dot-filled-journal: #8b76ff;

  /* Modal & Input Variables (Light) */
  --modal-bg: #ffffff;
  --modal-border: #e5e5e5;
  --separator-color: #f3f4f6;
  --input-bg: #f9fafb;
  --input-border: #d1d5db;
}

body {
  background-color: var(--bg-color);
  color: var(--text-primary);
  margin: 0;
  height: 100vh;
  font-family: var(--font-main);
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Setup Overlay */
.overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-color);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

.overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

.setup-message {
  text-align: center;
  animation: fadeIn 1s ease;
}

.setup-message h1 {
  font-weight: 300;
  letter-spacing: -0.5px;
}

.setup-message p {
  color: var(--text-secondary);
}

/* Main Visualization */
.main-container {
  display: flex;
  gap: 40px;
  opacity: 0;
  transition: opacity 1s ease;
  padding-left: 60px;
  max-width: calc(100vw); /* Leave space for right side panel */
  width: 100%; /* Use available space */
  box-sizing: border-box;
  justify-content: flex-start; /* Align grid to the left */
  position: absolute;
  left: 0;
}

.main-container.visible {
  opacity: 1;
}

.grid-scroll-area {
  overflow-x: auto;
  overflow-y: hidden;
  max-width: 100%;
  min-width: 0; /* Allow flexing below content size */
  /* No flex-grow: let it be natural width so main-container centers the group */
  flex: 0 1 auto;
}

/* Custom scrollbar for horizontal scroll */
.grid-scroll-area::-webkit-scrollbar {
  height: 8px;
}
.grid-scroll-area::-webkit-scrollbar-thumb {
  background: var(--scrollbar-color);
  border-radius: 4px;
}

.grid-wrapper {
  display: grid;
  /* Y-Title | Y-Labels | Grid */
  grid-template-columns: auto auto 1fr;
  /* X-Title | X-Labels | Grid */
  grid-template-rows: auto auto 1fr;
  gap: 0;
  align-items: start;
  justify-content: start; /* Align to start for scrolling */
  width: max-content; /* Force full width */
  padding-bottom: 5px; /* Space for scrollbar */
  margin: 0 auto; /* Optional: Center grid inside scroll area if it was wider than content?
                             No, wrapper is max-content. Scroll area is constrained.
                             This margin helps if scroll area is forced wide but wrapper is small. */
}

.xtitle {
  grid-column: 3;
  grid-row: 1;
  text-align: right;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.xaxis {
  grid-column: 3;
  grid-row: 2;
  /* Axis will be a grid matching the main grid columns */
  display: grid;
  /* Columns set by JS variable or class matching grid */
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  margin-bottom: 8px;
  /* Ensure height allows labels */
  min-height: 15px;
}

.ytitle {
  grid-column: 1;
  grid-row: 3;
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  text-align: left;
  align-self: end;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-right: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.yaxis {
  grid-column: 2;
  grid-row: 3;
  /* Axis will be a grid matching the main grid rows */
  display: grid;
  gap: 3px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-secondary);
  margin-right: 8px;
  text-align: right;
  line-height: 5px; /* Match dot height approx to center text? No, use flex align */
}

/* Individual label cells in axes */
.axis-label {
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.yaxis .axis-label {
  justify-content: flex-end;
  height: 8px; /* Force height to match dot */
}
.xaxis .axis-label {
  justify-content: center; /* Center horizontally */
  width: 8px; /* Force width to match dot */
  position: relative;
}
/* For X-axis, we might want to spare only some labels but keep the grid structure empty for others to maintain spacing */

.grid-container {
  grid-column: 3;
  grid-row: 3;
  display: grid;
  gap: 3px;
  /* Remove padding to align with labels */
  padding: 0;
  overflow: visible;
}

/* Reset gap for axes to match grid container */
.grid-container,
.xaxis,
.yaxis {
  gap: 3px;
}

/* Default Horizontal Grid (Years on X) for Weeks unit */
.horizontal-weeks {
  grid-auto-flow: column;
  grid-template-rows: repeat(52, 8px);
  grid-template-columns: repeat(var(--cols), 8px);
}
.xaxis.horizontal-weeks {
  grid-template-columns: repeat(var(--cols), 8px);
  grid-template-rows: auto;
}
.yaxis.horizontal-weeks {
  grid-template-rows: repeat(52, 8px);
  grid-template-columns: auto;
}

/* Horizontal Months (12 Rows x Age Columns) */
.horizontal-months {
  grid-auto-flow: column;
  grid-template-rows: repeat(12, 10px);
  grid-template-columns: repeat(var(--cols), 10px);
}
.xaxis.horizontal-months {
  grid-template-columns: repeat(var(--cols), 10px);
  grid-template-rows: auto;
  display: grid;
}
.yaxis.horizontal-months {
  grid-template-rows: repeat(12, 10px);
  grid-template-columns: auto;
  display: grid;
}
.horizontal-months .unit-block {
  width: 10px;
  height: 10px;
  border-radius: 3px;
}
/* Restore axis-label logic for months */
.xaxis.horizontal-months .axis-label {
  justify-content: center;
  width: 10px;
  position: relative;
  display: flex;
}
.yaxis.horizontal-months .axis-label {
  justify-content: flex-end;
  height: 10px;
  display: flex;
}

/* Horizontal Years (5 Rows x N Columns) */
.horizontal-years {
  grid-auto-flow: column;
  grid-template-rows: repeat(5, 30px); /* 5 rows */
  grid-template-columns: repeat(var(--cols), 30px);
}
.xaxis.horizontal-years {
  display: none;
}
.yaxis.horizontal-years {
  display: none;
}
.horizontal-years .unit-block {
  width: 30px;
  height: 30px;
  border-radius: 6px;
}
/* Revert dot size for horizontal compact view */
.horizontal-weeks .unit-block {
  width: 8px;
  height: 8px;
  border-radius: 2px;
}

/* Scrollbar styling for grid */
.grid-container::-webkit-scrollbar {
  width: 6px;
}
.grid-container::-webkit-scrollbar-thumb {
  background: #333;
  border-radius: 3px;
}

.unit-block {
  width: 8px;
  height: 8px;
  background-color: var(--dot-empty);
  border-radius: 2px;
  transition: all 0.3s ease;
}

.unit-block.filled {
  background-color: var(--dot-filled);
  box-shadow: 0 0 2px rgba(59, 130, 246, 0.3);
}

.unit-block.current {
  background-color: var(--dot-current);
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.8);
  position: relative;
  z-index: 2;
  animation: pulse 2s infinite;
}

/* Global Floating Tooltip (JS controlled to avoid scrollbars) */
#global-tooltip {
  position: fixed;
  background: var(--modal-bg);
  color: var(--text-primary);
  padding: 4px 6px;
  border-radius: 4px;
  font-size: 9px;
  font-family: var(--font-mono);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease 0s, visibility 0s ease 0s;
  z-index: 2000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--modal-border);
  transform: translateY(-50%);
}

/* Arrow for the tooltip */
#global-tooltip::before {
  content: "";
  position: absolute;
  top: 50%;
  left: -9px;
  transform: translateY(-50%);
  border: 5px solid transparent;
  border-right-color: var(--modal-bg);
}

#global-tooltip.visible {
  opacity: 1;
  visibility: visible;
  /* Delay only on show */
  transition: opacity 0.15s ease 0.5s, visibility 0s ease 0.5s;
}

/* Info Panel */
.info-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 200px;
}

#stats {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
  white-space: nowrap; /* Prevent stats from wrapping awkwardly */
}

.stat-highlight {
  color: var(--text-primary);
  font-weight: 600;
}

/* Clock Container Removed */

/* Bottom right controls (settings + auth) */
.controls {
  position: absolute;
  top: 30px;
  right: 40px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
}

/* Time and Date Removed */

/* Search Bar Removed */

/* Top Sites Removed */

.title-container {
  position: absolute;
  top: 20px;
  left: 40px;
  line-height: 1.6;
  z-index: 20;
}

.app-title {
  font-family: var(--font-pixel);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: 4px;
  color: var(--text-primary);
  text-transform: uppercase;
  animation: fadeIn 1.5s ease;
}

.app-subtitle {
  position: absolute;
  bottom: 8px;
  right: 10px;
  font-family: var(--font-main);
  font-size: 12px;
  font-weight: 400;
  color: var(--text-secondary);
  animation: fadeIn 1.5s ease;
}

a {
  color: var(--text-link);
  text-decoration: underline;
}

/* Extra Time/Date Styles Removed */

/* Animations */
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.25);
    opacity: 0.8;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

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

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

/* Settings Button */
.settings-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 0px;
  border-radius: 50%;
  transition: all 0.3s ease;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

.settings-btn:hover {
  color: var(--text-primary);
  transform: rotate(90deg);
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(5px);
  z-index: 1000;
  display: flex;
  justify-content: center;
  align-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Modal Content */
.modal-content {
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 12px;
  padding: 0;
  width: 90%;
  max-width: 400px;
  transform: translateY(20px);
  transition: transform 0.3s ease;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
}

.modal-overlay.active .modal-content {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--separator-color);
}

.modal-header h2 {
  margin: 0;
  font-size: 18px;
  font-weight: 500;
  color: var(--text-primary);
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 24px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}

.close-btn:hover {
  color: var(--text-primary);
}

.modal-body {
  padding: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
  font-family: var(--font-mono);
}

.modal-footer {
  padding: 20px 24px;
  border-top: 1px solid var(--separator-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Inputs */
input[type="date"],
input[type="number"] {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: 6px;
  font-family: var(--font-main);
  font-size: 14px;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

input[type="date"]:focus,
input[type="number"]:focus {
  outline: none;
  border-color: var(--dot-filled);
}

/* Radio Group */
/* Radio Group */
.radio-group {
  display: flex;
  gap: 24px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  padding: 4px 0;
}

.radio-label:hover {
  color: var(--text-primary);
}

/* Custom Radio Input */
input[type="radio"] {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--text-secondary);
  border-radius: 50%;
  margin: 0;
  display: grid;
  place-content: center;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  background-color: transparent;
}

input[type="radio"]::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  transform: scale(0);
  transition: 0.2s transform cubic-bezier(0.4, 0, 0.2, 1);
  background-color: var(--dot-filled);
  box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

input[type="radio"]:checked {
  border-color: var(--dot-filled);
  background-color: rgba(59, 130, 246, 0.1);
}

input[type="radio"]:checked::before {
  transform: scale(1);
}

input[type="radio"]:focus {
  outline: none;
  border-color: var(--dot-filled);
  box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.2);
}

/* Label interaction when checked */
.radio-label:has(input:checked) {
  color: var(--text-primary);
}

/* Buttons */
.btn-primary,
.btn-secondary,
.action-btn {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  font-family: var(--font-main);
}

.btn-primary {
  background: var(--dot-filled);
  color: white;
}

.btn-primary:hover {
  background: #2563eb;
}

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

.btn-secondary:hover {
  color: var(--text-primary);
  border-color: #666;
}

/* Action Button (Reuse setup button style) */
.action-btn {
  background: var(--dot-filled);
  color: white;
  margin-top: 20px;
}
.action-btn:hover {
  background: #2563eb;
}

/* Search styles moved to Clock section */

/* Pre-birth dots (months before birthday in birth year) */
.unit-block.pre-birth {
  visibility: hidden;
  pointer-events: none;
}

/* ========================================
   AUTHENTICATION STYLES
   ======================================== */

/* bottom-left-container removed - controls moved to bottom right */

.auth-container {
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 12px;
}

.auth-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  background: #ffffff0d;
  border: 1px solid var(--input-border);
  border-radius: 25px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
  backdrop-filter: blur(10px);
}

.auth-btn:hover {
  background: #ffffff1a;
  border-color: var(--dot-filled);
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.2);
}

.google-signin-icon {
  flex-shrink: 0;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px 6px 6px;
  background: #ffffff0d;
  border: 1px solid var(--input-border);
  border-radius: 25px;
  backdrop-filter: blur(10px);
}

.user-info.hidden {
  display: none;
}

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--dot-filled);
}

#user-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sign-out-btn {
  padding: 6px 12px;
  background: transparent;
  border: 1px solid var(--text-secondary);
  border-radius: 15px;
  color: var(--text-secondary);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.sign-out-btn:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* Light theme adjustments */
[data-theme="light"] .auth-btn {
  background: rgba(0, 0, 0, 0.03);
}

[data-theme="light"] .auth-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .user-info {
  background: rgba(0, 0, 0, 0.03);
}

/* ========================================
   JOURNAL MODAL STYLES
   ======================================== */

.journal-modal-content {
  max-width: 500px;
  width: 95%;
}

.journal-body {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.journal-date {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--dot-filled);
  padding: 10px 15px;
  background: rgba(59, 130, 246, 0.1);
  border-radius: 8px;
  text-align: center;
  font-weight: 600;
}

/* Emoji Picker Container */
.emoji-picker-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
  position: relative; /* For popup positioning */
}

.emoji-trigger-wrapper {
  display: flex;
  align-items: center;
  gap: 15px;
}

.emoji-trigger-wrapper > label {
  font-size: 14px;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  margin: 0;
}

.emoji-trigger-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 20px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.emoji-trigger-btn:hover {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--dot-filled);
}

.trigger-icon {
  font-size: 18px;
  line-height: 1;
}

.clear-emoji-btn {
  padding: 4px 8px;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 18px;
  cursor: pointer;
  transition: color 0.2s;
  line-height: 1;
}

.clear-emoji-btn:hover {
  color: #ef4444;
}

/* Emoji Popup */
.emoji-popup {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 10px;
  z-index: 100;
  background: var(--modal-bg);
  border: 1px solid var(--modal-border);
  border-radius: 12px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  padding: 12px;
  width: 300px;
  animation: fadeIn 0.2s ease;
}

.emoji-popup.hidden {
  display: none;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 8px;
  max-height: 200px;
  overflow-y: auto;
}

.emoji-option {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.emoji-option:hover {
  background: rgba(59, 130, 246, 0.1);
  transform: scale(1.15);
}

.emoji-option.selected {
  background: rgba(59, 130, 246, 0.2);
  border-color: var(--dot-filled);
  transform: scale(1.1);
}

/* Journal Textarea */
.journal-textarea-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.journal-textarea-container > label {
  font-size: 14px;
  color: var(--text-secondary);
}

#journal-text {
  width: 100%;
  min-height: 150px;
  padding: 15px;
  background: var(--input-bg);
  border: 1px solid var(--input-border);
  border-radius: 8px;
  color: var(--text-primary);
  font-family: var(--font-main);
  font-size: 14px;
  line-height: 1.6;
  resize: vertical;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

#journal-text:focus {
  outline: none;
  border-color: var(--dot-filled);
}

#journal-text::placeholder {
  color: var(--text-secondary);
  opacity: 0.6;
}

/* Journal Footer */
.journal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.footer-right {
  display: flex;
  gap: 12px;
}

.btn-danger {
  padding: 10px 20px;
  background: transparent;
  border: 1px solid #ef4444;
  border-radius: 6px;
  color: #ef4444;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  font-family: var(--font-main);
}

.btn-danger:hover {
  background: #ef4444;
  color: white;
}

.btn-danger.hidden {
  display: none;
}

/* ========================================
   INTERACTIVE GRID UNITS
   ======================================== */

.unit-block.clickable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.unit-block.clickable:hover {
  transform: scale(1.3);
  z-index: 10;
  box-shadow: 0 0 10px rgba(59, 130, 246, 0.4);
}

.unit-block.has-emoji {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent !important;
  overflow: visible;
}

.unit-emoji {
  font-size: inherit;
  line-height: 1;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Emoji sizes for different modes */
.horizontal-weeks .unit-emoji {
  font-size: 10px;
}

.horizontal-months .unit-emoji {
  font-size: 14px;
}

.horizontal-years .unit-emoji {
  font-size: 24px;
}

/* Text-only journal unit styling */
.unit-block[data-has-journal="true"]:not(.has-emoji) {
  background-color: var(--dot-filled-journal) !important;
}

/* Loading state for saving */
.saving-indicator {
  position: fixed;
  top: 20px;
  right: 20px;
  padding: 10px 20px;
  background: rgba(59, 130, 246, 0.9);
  color: white;
  border-radius: 8px;
  font-size: 13px;
  animation: fadeIn 0.3s ease;
  z-index: 2000;
}

/* Scrollbar for emoji grid */
.emoji-grid::-webkit-scrollbar {
  width: 6px;
}

.emoji-grid::-webkit-scrollbar-thumb {
  background: var(--scrollbar-color);
  border-radius: 3px;
}

.emoji-grid::-webkit-scrollbar-track {
  background: transparent;
}
/* ========================================
   LOCKED JOURNAL STATE
   ======================================== */

.journal-locked-message {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  color: var(--text-secondary);
  gap: 15px;
}

.journal-locked-message svg {
  color: var(--text-secondary);
  opacity: 0.5;
}

.journal-locked-message p {
  font-size: 16px;
  font-weight: 500;
  margin: 0;
}

.journal-modal-content.locked .journal-locked-message {
  display: flex; /* Show when locked */
}

.journal-modal-content.locked .emoji-picker,
.journal-modal-content.locked .journal-textarea-container,
.journal-modal-content.locked .journal-footer .footer-right,
.journal-modal-content.locked .journal-footer #delete-journal {
  display: none !important;
}

.journal-modal-content.locked .journal-footer {
  justify-content: center; /* Center content (though it might be empty if we hide everything) */
  border-top: none; /* Remove border if empty */
}

.hidden {
  display: none !important;
}

/* ========================================
   MOBILE RESPONSIVENESS
   ======================================== */

/* ========================================
   MOBILE RESPONSIVENESS
   ======================================== */

@media (max-width: 768px) {
  body {
    overflow: auto; /* Allow body scrolling on mobile */
    align-items: flex-start; /* Align to top */
    height: auto;
    min-height: 100vh;
  }

  .main-container {
    padding: 5px; /* Minimal padding to max width */
    padding-top: 80px; /* Space for fixed header/title */
    left: 0;
    justify-content: center;
    position: relative; /* Not absolute on mobile */
    max-width: 100%;
    margin: 0;
    flex-direction: column-reverse; /* Stats above grid */
    align-items: center;
    gap: 20px;
  }
  
  .title-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px; /* Fixed height for header */
    padding: 0 15px;
    background: rgba(var(--bg-rgb), 0.95);
    background: var(--bg-color);
    z-index: 50;
    border-bottom: 1px solid var(--separator-color);
    box-sizing: border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }
  
  .app-title {
    font-size: 18px;
    margin: 0;
  }
  
  .app-subtitle {
    display: none;
  }

  .controls {
    position: fixed;
    top: 0;
    right: 15px;
    height: 60px; /* Match header height */
    z-index: 60;
    margin: 0;
    align-items: center;
    gap: 10px;
  }
  
  /* Compact User Info */
  #user-name {
    display: none;
  }
  
  .user-info {
    padding: 0;
    border: none;
    background: transparent;
    gap: 8px;
  }
  
  /* Hide Sign Out Text, keep button for click target but make it icon-like if possible or just small */
  .sign-out-btn {
    font-size: 0; /* Hide text */
    padding: 5px;
    border: 1px solid var(--separator-color);
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .sign-out-btn::after {
    content: "✕"; /* Simple close/exit icon substitute */
    font-size: 12px;
    color: var(--text-secondary);
  }
  
  /* GRID TRANSFORMATION */

  .grid-scroll-area {
    width: 100% !important;
    max-width: none !important;
    overflow: visible; /* Let the body scroll handle it */
    flex: 1 1 auto; /* Allow growing */
  }

  .grid-wrapper {
    /* Simplified wrapper: Just the grid, no axes */
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
    width: 100%;
    max-width: 100%;
    justify-content: center;
  }
  
  /* Update Grid Orientation */
  .grid-container {
    grid-auto-flow: row;
    grid-column: 1;
    grid-row: 1;
    justify-self: center;
    width: 100%; /* Full width */
    max-width: 100%; 
  }

  /* WEEKS MODE MOBILE */
  .horizontal-weeks {
    grid-template-rows: repeat(var(--cols), 1fr);
    grid-template-columns: repeat(52, 1fr); 
    gap: 1.5px; /* Tighter gap for max size */
  }
  
  .grid-container.horizontal-weeks {
    width: 100%;
    padding: 0;
  }
  
  .grid-container.horizontal-weeks .unit-block {
    width: 100%;
    height: auto;
    aspect-ratio: 1 / 1;
    min-width: 2px; /* Allow getting very small */
    border-radius: 1px;
  }
  
  /* YEARS MODE MOBILE */
  .horizontal-years {
    grid-template-columns: repeat(10, 1fr);
    grid-template-rows: repeat(var(--cols), 1fr);
    gap: 4px;
    display: grid;
  }
  
  .grid-container.horizontal-years .unit-block {
     width: 100%;
     height: auto;
     aspect-ratio: 1/1;
     border-radius: 4px;
  }

  /* MONTHS MODE MOBILE */
  .horizontal-months {
    grid-template-columns: repeat(12, 1fr);
    grid-template-rows: repeat(var(--cols), 1fr);
    gap: 2px;
    display: grid;
  }
  
  .grid-container.horizontal-months .unit-block {
     width: 100%;
     height: auto;
     aspect-ratio: 1/1;
     border-radius: 2px;
  }
  
  /* HIDE AXES ON MOBILE */
  .xtitle, .xaxis, .ytitle, .yaxis {
    display: none !important;
  }

  /* Info Panel */
  .info-panel {
    width: 100%;
    align-items: center;
    padding-bottom: 20px;
    text-align: center;
  }
  
  /* Overlay adjustments */
  .setup-message h1 {
    font-size: 24px;
    padding: 0 20px;
  }
  
  /* Modal Mobile */
  .modal-content {
    width: 95%;
    max-height: 90vh;
    overflow-y: auto;
  }
  
  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
  }
  
  /* Hide tooltip on touch, rely on click modal */
  #global-tooltip {
    display: none !important;
  }
}
