body {
  font-family: 'Segoe UI', Arial, sans-serif;
  background: #121212; /* fallback default */
  color: #ddd;
  margin: 0;
  min-height: 100vh;
}

body.work-bg {
  background: #ff897c; /* pastel red */
  color: #4a1c1c;
}

body.break-bg {
  background: #7abdff; /* pastel blue */
  color: #1c3d5a;
}

main {
  background: inherit;
  min-height: 100vh;
  width: 100%;
  padding: 40px 0;
  transition: background-color 0.6s ease, color 0.6s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

h1, .subtitle {
  text-align: center;
  font-weight: 700;
  letter-spacing: 1px;
  color: inherit;
}

.subtitle {
  margin-top: 0;
  font-size: 1.2rem;
  color: #ee4444;
}

.timer-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin: 24px 0 14px;
}

#timer-box {
  width: 280px;
  height: 120px;
  border-radius: 20px;
  box-shadow: 0 6px 32px rgba(5, 4, 4, 0.07);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
  transition: background 0.3s;
}

.red-bg {
  background: linear-gradient(135deg, #e57373 80%, #ff7979 100%);
  box-shadow: 0 6px 32px rgba(220,0,0,0.4);
}

.blue-bg {
  background: linear-gradient(135deg, #65a2ff 80%, #6dd5fa 100%);
  box-shadow: 0 6px 32px rgba(50,120,250,0.4);
}

#timer-label {
  font-size: 1.1em;
  font-weight: 600;
  color: #fff;
  margin-bottom: 4px;
}

#timer {
  font-size: 2.8em;
  font-weight: bold;
  color: #fff;
  letter-spacing: 2px;
}

.control-row {
  display: flex;
  gap: 12px;
}

/* Base button style: subtle shadows for minimal shine */
button {
  background: linear-gradient(145deg, #ededed, #e4e4e4);
  color: #333;
  border: none;
  padding: 12px 20px;
  border-radius: 30px;
  box-shadow:
    2px 2px 5px #bebebe,
    -2px -2px 5px #ffffff;
  cursor: pointer;
  font-size: 1em;
  user-select: none;
  transition: all 0.25s ease;
  margin: 0 6px;
  font-weight: 600;
}

/* Buttons in work state (red hue) */
button.work-btn {
  background: linear-gradient(145deg, #cc6464, #da6060);
  color: #7a2c2c;
  box-shadow:
    2px 2px 5px #c58787,
    -2px -2px 5px #da7c7c;
}
button.work-btn:hover {
  background: linear-gradient(145deg, #d48282, #c27878);
  color: #601f1f;
  box-shadow:
    1px 1px 4px #a46464,
    -1px -1px 4px #e98181;
}
button.work-btn:active {
  transform: translateY(3px);
  box-shadow:
    inset 2px 2px 4px #a45454,
    inset -2px -2px 4px #b45d5d;
  color: #500d0d;
}

/* Buttons in break state (blue hue) */
button.break-btn {
  background: linear-gradient(145deg, #7294d8, #5292e6);
  color: #255b9d;
  box-shadow:
    2px 2px 5px #749dd3,
    -2px -2px 5px #638aac;
}
button.break-btn:hover {
  background: linear-gradient(145deg, #7aa7cc, #6087b8);
  color: #1c4476;
  box-shadow:
    1px 1px 4px #5a87c4,
    -1px -1px 4px #71a3c7;
}
button.break-btn:active {
  transform: translateY(3px);
  box-shadow:
    inset 2px 2px 4px #5279b5,
    inset -2px -2px 4px #7a9bbe;
  color: #153459;
}

/* Stats row base style */
.stats-row {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-bottom: 24px;
  width: 100%;
}

/* Base stats box style */
.stat-box {
  background: #fafafa;
  color: #333;
  padding: 8px 18px;
  border-radius: 12px;
  box-shadow: 6px 6px 12px #dcdcdc,
              -6px -6px 12px #ffffff;
  font-size: 1em;
  text-align: center;
  transition: background-color 0.35s, color 0.35s;
}

/* Stats boxes - work color */
.stat-box.work-color {
  background: #e28080;
  color: #7e2c2c;
  box-shadow:
    6px 6px 12px #bc8a8a,
    -6px -6px 12px #cc6464;
}

/* Stats boxes - break color */
.stat-box.break-color {
  background: #78aae4;
  color: #1868bd;
  box-shadow:
    6px 6px 12px #7d9aca,
    -6px -6px 12px #4e789c;
}

/* Tasks section base style (neutral fallback) */
.tasks-section {
  width: 330px;
  border-radius: 14px;
  padding: 21px 16px 27px;
  margin: 32px 0 12px;
  transition: background 0.35s ease, color 0.35s ease, box-shadow 0.35s ease;
}

/* Work mode tasks section - matching work button hues */
.tasks-section.work-task {
  background: linear-gradient(145deg, #cc6464, #da6060);
  color: #7a2c2c;
  box-shadow:
    6px 6px 12px #c58787,
    -6px -6px 12px #da7c7c;
}

/* Break mode tasks section - matching break button hues */
.tasks-section.break-task {
  background: linear-gradient(145deg, #7294d8, #5292e6);
  color: #255b9d;
  box-shadow:
    6px 6px 12px #749dd3,
    -6px -6px 12px #638aac;
}

/* Heading matches color for current mode */
.tasks-section h2 {
  margin: 0 0 14px;
  font-size: 1.18em;
  color: inherit;
  transition: color 0.35s ease;
}

/* Task list */
#tasksList {
  list-style: none;
  padding: 0;
  margin: 0 0 8px;
  max-height: 260px;
  overflow-y: auto;
}

/* Task item layout */
.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.15);
}

/* Task content: checkbox + text inline */
.task-content {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-grow: 1;
  overflow-wrap: anywhere;
}

/* Task text with smooth color transition */
.task-text {
  font-size: 1em;
  color: inherit;
  transition: color 0.35s ease;
}

/* Checked task style */
.checked {
  color: rgba(255,255,255,0.7);
  text-decoration: line-through;
}

/* Buttons container aligned */
.task-actions {
  display: flex;
  gap: 12px;
  margin-left: 12px;
  flex-shrink: 0;
}

/* Action buttons base */
.action-btn {
  background: none;
  border: none;
  font-size: 1em;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 24px;
  transition: background 0.25s ease, color 0.25s ease;
  font-weight: 600;
  user-select: none;
  white-space: nowrap;
  box-shadow:
    2px 2px 4px rgba(0,0,0,0.08),
    -2px -2px 4px rgba(214, 95, 95, 0.7);
}

/* Work mode action buttons */
.action-btn.work-btn {
  background: linear-gradient(145deg, #cc6464, #da6060);
  color: #b6abab;
  border: 1px solid #4a1c1c;
  box-shadow:
    2px 2px 5px #e96969,
    -2px -2px 5px #d46969;
}

.action-btn.work-btn:hover {
  background: linear-gradient(145deg, #d48282, #c27878);
  color: #601f1f;
  box-shadow:
    1px 1px 4px #a46464,
    -1px -1px 4px #e98181;
}

.action-btn.work-btn:active {
  transform: translateY(3px);
  box-shadow:
    inset 2px 2px 4px #a45454,
    inset -2px -2px 4px #b45d5d;
  color: #500d0d;
}

/* Break mode action buttons */
.action-btn.break-btn {
  background: linear-gradient(145deg, #7294d8, #5292e6);
  color: #255b9d;
  border: 1px solid #3d5d99;
  box-shadow:
    2px 2px 5px #749dd3,
    -2px -2px 5px #638aac;
}

.action-btn.break-btn:hover {
  background: linear-gradient(145deg, #7aa7cc, #6087b8);
  color: #1c4476;
  box-shadow:
    1px 1px 4px #5a87c4,
    -1px -1px 4px #71a3c7;
}

.action-btn.break-btn:active {
  transform: translateY(3px);
  box-shadow:
    inset 2px 2px 4px #5279b5,
    inset -2px -2px 4px #7a9bbe;
  color: #153459;
}

/* Checkbox styling */
.task-content input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
  accent-color: currentColor;
  transition: accent-color 0.35s ease;
}

/* Checkbox color tweaks for modes */
body.work-bg .task-content input[type="checkbox"] {
  accent-color: #cc6464;
}

body.break-bg .task-content input[type="checkbox"] {
  accent-color: #5292e6;
}

/* Dialog backdrop */
.dialog-backdrop {
  display: none;
  position: fixed;
  left: 0; top: 0;
  width: 100vw; height: 100vh;
  background: rgba(255, 255, 255, 0.404);
  z-index: 999;
  transition: background-color 0.35s;
}

/* Dialog base style */
.dialog {
  display: none;
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
  padding: 24px;
  background: #8e9fbb; /* neutral light blue-gray */
  color: #333;
  border-radius: 24px;
  box-shadow: 8px 8px 32px rgba(150, 160, 190, 0.7);
  z-index: 1000;
  min-width: 260px;
  transition: opacity 0.35s cubic-bezier(.4,0,.2,1), transform 0.4s cubic-bezier(.4,0,.2,1), background-color 0.35s;
}

.dialog.show {
  display: block;
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Dialog heading */
.dialog h3 {
  margin: 0 0 18px;
}

/* Dialog label/input styling */
.dialog label {
  display: block;
  margin-bottom: 10px;
  font-size: 1em;
}

.dialog input {
  width: 55px;
  margin-left: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  border: 1px solid #c08f8f;
  background: #9eb9e0;
  color: #222;
  transition: background-color 0.35s;
}

/* Dialog buttons container */
.dialog-buttons {
  display: flex;
  gap: 15px;
  margin-top: 18px;
  justify-content: flex-end;
}

/* Dialog "Save" button */
.dialog-buttons button {
  background: linear-gradient(145deg, #4a90e2, #357abd);
  color: rgb(230, 230, 230);
  box-shadow:
    4px 4px 8px #2a5ca8,
    -4px -4px 6px #5fa5ff;
  border-radius: 8px;
  border: none;
  padding: 7px 18px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s;
}

/* Dialog "Cancel" button */
#dialogCancel {
  background: linear-gradient(145deg, #e95353, #bb2a2a);
  box-shadow:
    4px 4px 8px #7a2222,
    -4px -4px 6px #f35d5d;
}

#dialogReset {
    background: linear-gradient(145deg, #f0ad4e, #d99a3e);
    box-shadow: 4px 4px 8px #8c6427, -4px -4px 6px #ffc675;
}

/* Dialog buttons hover and active */
.dialog-buttons button:hover {
  filter: brightness(1.1);
}

.dialog-buttons button:active {
  transform: translateY(2px);
  filter: brightness(0.9);
}


/* Gravity Toggle Button */
#gravityToggle {
  appearance: none;
  -webkit-appearance: none;
  background: #db6565;
  border-radius: 12px;
  position: relative;
  outline: none;
  transition: background 0.3s;
  box-shadow: inset 1px 1px 3px rgba(0,0,0,0.2);
}

#gravityToggle:checked {
  background: #4a90e2;
}

#gravityToggle::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: white;
  top: 1px;
  left: 2px;
  transition: transform 0.3s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

#gravityToggle:checked::before {
  transform: translateX(20px);
}

/* Stats Modal */
.stats-modal-backdrop {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1999;
  justify-content: center;
  align-items: center;
}

.stats-modal-content {
  background: #f0f0f0;
  color: #333;
  border-radius: 16px;
  padding: 20px;
  width: 90%;
  max-width: 800px;
  box-shadow: 0 5px 20px rgba(0,0,0,0.3);
  position: relative;
}

.stats-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  border-bottom: 1px solid #ccc;
  padding-bottom: 10px;
}

.stats-modal-header h3 {
  margin: 0;
  font-size: 1.4em;
}

.stats-modal-close {
  font-size: 2em;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

/* Time View Controls */
.time-view-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.time-view-btn {
  padding: 8px 16px;
  border: 2px solid #ccc;
  border-radius: 6px;
  background: white;
  color: #333;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.2s ease;
}

.time-view-btn:hover {
  background: #f5f5f5;
  border-color: #999;
}

.time-view-btn.active {
  background: #007bff;
  border-color: #007bff;
  color: white;
}

.time-view-btn.active:hover {
  background: #0056b3;
  border-color: #0056b3;
}

/* Download Controls */
.download-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
  justify-content: center;
  flex-wrap: wrap;
}

.download-btn {
  padding: 8px 16px;
  border: 2px solid #28a745;
  border-radius: 6px;
  background: #28a745;
  color: white;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.2s ease;
}

.download-btn:hover {
  background: #218838;
  border-color: #218838;
}

/* Enhanced Stats Controls */
.enhanced-stats-toggle {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
}

.enhanced-stats-btn {
  padding: 8px 16px;
  border: 2px solid #6f42c1;
  border-radius: 6px;
  background: #6f42c1;
  color: white;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  transition: all 0.2s ease;
}

.enhanced-stats-btn:hover {
  background: #5a359a;
  border-color: #5a359a;
}

/* Enhanced Stats Modal */
.enhanced-stats-modal-backdrop {
  display: none;
  position: fixed;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.8);
  z-index: 2500;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease-out;
}

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

.enhanced-stats-modal-content {
  background: #ffffff;
  color: #333;
  border-radius: 12px;
  width: 95vw;
  height: 90vh;
  max-width: 1200px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  position: relative;
  animation: slideIn 0.3s ease-out;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@keyframes slideIn {
  from { 
    opacity: 0;
    transform: translateY(-50px) scale(0.9);
  }
  to { 
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.enhanced-stats-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 30px;
  border-bottom: 2px solid #e9ecef;
  background: linear-gradient(135deg, #6f42c1, #5a359a);
  color: white;
}

.enhanced-stats-modal-header h2 {
  margin: 0;
  font-size: 1.8em;
  font-weight: 600;
}

.enhanced-stats-modal-close {
  font-size: 2.5em;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  color: white;
  opacity: 0.8;
  transition: opacity 0.2s ease;
}

.enhanced-stats-modal-close:hover {
  opacity: 1;
  transform: scale(1.1);
}

.enhanced-stats-content {
  flex: 1;
  overflow-y: auto;
  padding: 30px;
  background: #f8f9fa;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.stat-card {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.stat-card h4 {
  margin: 0 0 8px 0;
  font-size: 0.9em;
  color: #666;
  text-transform: uppercase;
  font-weight: 600;
}

.stat-card .stat-value {
  font-size: 1.8em;
  font-weight: bold;
  color: #333;
  margin: 0;
}

.stat-card .stat-subtitle {
  font-size: 0.8em;
  color: #999;
  margin-top: 4px;
}

.productivity-chart {
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 16px;
  margin-top: 16px;
}

.chart-title {
  font-size: 1.1em;
  font-weight: 600;
  margin-bottom: 12px;
  color: #333;
}

.heatmap-container {
  display: grid;
  grid-template-columns: repeat(24, 1fr);
  gap: 2px;
  margin: 10px 0;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: #f0f0f0;
  position: relative;
  cursor: pointer;
}

.heatmap-cell.intensity-1 { background: #c6e48b; }
.heatmap-cell.intensity-2 { background: #7bc96f; }
.heatmap-cell.intensity-3 { background: #239a3b; }
.heatmap-cell.intensity-4 { background: #196127; }

.heatmap-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7em;
  color: #666;
  margin-top: 4px;
}

.focus-trends {
  display: flex;
  gap: 16px;
  margin-top: 16px;
}

.trend-item {
  flex: 1;
  text-align: center;
  padding: 12px;
  background: white;
  border: 1px solid #e9ecef;
  border-radius: 6px;
}

.trend-value {
  font-size: 1.2em;
  font-weight: bold;
  color: #28a745;
}

.trend-label {
  font-size: 0.8em;
  color: #666;
  margin-top: 4px;
}

/* Enhanced Modal Specific Styles */
.enhanced-overview {
  display: flex;
  flex-direction: column;
  gap: 30px;
}

.overview-section h3 {
  margin: 0 0 20px 0;
  color: #333;
  font-size: 1.4em;
  border-bottom: 2px solid #6f42c1;
  padding-bottom: 8px;
}

.charts-section .chart-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.half-chart {
  margin-bottom: 0 !important;
}

.session-breakdown {
  margin-top: 15px;
}

.breakdown-item {
  display: flex;
  align-items: center;
  margin: 10px 0;
  font-size: 0.9em;
}

.breakdown-bar {
  height: 20px;
  margin-right: 12px;
  border-radius: 10px;
  min-width: 40px;
  transition: width 0.3s ease;
}

.work-bar { background: #e57373; }
.short-bar { background: #65a2ff; }
.long-bar { background: #81c784; }
.skipped-bar { background: #999999; }

.weekly-chart {
  display: flex;
  justify-content: space-around;
  align-items: end;
  height: 150px;
  margin: 20px 0;
  padding: 10px;
  background: #f8f9fa;
  border-radius: 8px;
}

.weekly-bar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex: 1;
}

.weekly-bar {
  width: 30px;
  background: #28a745;
  border-radius: 4px 4px 0 0;
  margin-bottom: 5px;
  min-height: 10px;
  transition: height 0.3s ease;
}

.weekly-label {
  font-size: 0.8em;
  font-weight: bold;
  color: #666;
}

.weekly-count {
  font-size: 0.7em;
  color: #999;
}

.insights-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.insight-card {
  background: linear-gradient(135deg, #f8f9fa, #e9ecef);
  border-left: 4px solid #6f42c1;
  padding: 15px;
  border-radius: 8px;
  font-size: 0.95em;
}

.raw-data-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.raw-data-item {
  background: #f8f9fa;
  padding: 12px;
  border-radius: 6px;
  font-size: 0.9em;
}

.summary-section {
  background: linear-gradient(135deg, #6f42c1, #5a359a);
  color: white;
  padding: 20px;
  border-radius: 12px;
  margin: 20px 0;
}

.summary-section .focus-trends {
  margin: 0;
}

.summary-section .trend-item {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.summary-section .trend-value {
  color: white;
}

.summary-section .trend-label {
  color: rgba(255, 255, 255, 0.8);
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .enhanced-stats-modal-content {
    width: 98vw;
    height: 95vh;
  }
  
  .charts-section .chart-row {
    grid-template-columns: 1fr;
  }
  
  .stats-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  }
}

.stats-chart-container {
  display: grid;
  /* A column for labels and a column for the graph */
  grid-template-columns: 100px 1fr; 
  grid-template-rows: repeat(3, 1fr) 20px; /* 3 rows for data, 1 for x-axis labels */
  height: 220px;
  background: #fff;
  border-radius: 8px;
  padding: 10px;
}

.chart-y-label {
  grid-column: 1;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 10px;
  border-right: 1px solid #eee;
  color: #555;
}

.chart-row {
  grid-column: 2;
  position: relative;
  border-bottom: 1px solid #f0f0f0;
}

.chart-row:last-of-type {
  border-bottom: none;
}

.chart-bar {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 25px; /* Make bars thicker */
  border-radius: 4px;
  opacity: 0.85;
}

.chart-labels-x {
  grid-column: 2;
  grid-row: 4;
  position: relative;
  display: flex;
  justify-content: space-between;
  font-size: 10px;
  color: #888;
  padding-top: 5px;
}