/* ===================================================================
   VARIABLES
   =================================================================== */
/* ===================================================================
   VARIABLES
   =================================================================== */
:root {
  --bg: #fafafa;
  --bg2: #ffffff;
  --text: #0a0a0a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ring: #d4d4d8;
  --emerald: #10b981;
  --emerald-600: #059669;
  --sky: #0ea5e9;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --indigo: #6366f1;
  --radius: 16px;
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.06);
  --histrow-bg: #fafafa;
  --summary-bg: #f4f4f5;
  --chart-grid: #e5e7eb;
  --input-bg: #f4f4f5;
}

[data-theme="dark"] {
  --bg: #282c34;
  --bg2: #3c4049;
  --text: #ffffff;
  --muted: #bdbdbd;
  --border: #4b515c;
  --ring: #5c6370;
  --summary-bg: #4c5059;
  --chart-grid: #5c6370;
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  --histrow-bg: #3c4049;
  --input-bg: #4c5059;
}

/*
:root {
  --bg: #fafafa;
  --bg2: #ffffff;
  --text: #0a0a0a;
  --muted: #6b7280;
  --border: #e5e7eb;
  --ring: #d4d4d8;
  --emerald: #0c6245;
  --emerald-600: #059669;
  --sky: #0ea5e9;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --indigo: #6366f1;
  --radius: 16px;
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.06);
  --histrow-bg: #fafafa;
  --summary-bg: #f4f4f5;
  --chart-grid: #e5e7eb;
  --input-bg: #f4f4f5;
}

[data-theme="dark"] {
  --bg: #282c34;
  --bg2: #3c4049;
  --text: #ffffff;
  --muted: #bdbdbd;
  --border: #4b515c;
  --ring: #5c6370;
  --summary-bg: #4c5059;
  --chart-grid: #5c6370;
  --shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  --histrow-bg: #3c4049;
  --input-bg: #4c5059;
}
*/

/* ===================================================================
   BASE STYLES
   =================================================================== */
* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: linear-gradient(to bottom, #f4f4f5, #fff);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, sans-serif;
  transition: background 0.3s, color 0.3s;
}

[data-theme="dark"] body {
  background: linear-gradient(to bottom, var(--bg2), var(--bg));
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 16px 56px;
  position: relative;
}

/* ===================================================================
   COMPONENTS
   =================================================================== */

/* --- Tabs --- */
.tabs {
  display: grid;
  gap: 8px;
  background: #eef0f3;
  border-radius: 14px;
  padding: 6px;
  transition: background 0.3s;
}

[data-theme="dark"] .tabs {
  background: var(--bg);
}

.tab {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: none;
  border-radius: 10px;
  padding: 10px 12px;
  background: transparent;
  color: #52525b;
  cursor: pointer;
  font-size: 13px;
  transition: background 0.3s, color 0.3s;
}

[data-theme="dark"] .tab {
  color: var(--muted);
}

.tab.active {
  background: var(--bg2);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* --- Card --- */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: background 0.3s, border-color 0.3s;
}

.card .hdr {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: border-color 0.3s;
}

.card .cnt {
  padding: 20px 24px;
}

/* --- Buttons --- */
.btn {
  border: 1px solid var(--border);
  background: #f4f4f5;
  color: #0a0a0a;
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  transition: background 0.3s, border-color 0.3s, color 0.3s;
}

[data-theme="dark"] .btn {
  background: var(--bg2);
  color: var(--text);
}

.btn.primary {
  background: var(--emerald-600);
  color: white;
  border-color: transparent;
}

.btn.warning {
  background: var(--amber);
  color: white;
  border-color: transparent;
}

.btn:disabled {
  opacity: .6;
  cursor: not-allowed;
}

.btn.ghost {
  background: transparent;
}

.btn.ghost:hover {
  background: var(--border);
}

.btn-icon-square {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

/* --- Forms --- */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

input,
select,
textarea {
  border: 1px solid var(--border);
  background: var(--input-bg);
  border-radius: 10px;
  padding: 8px 10px;
  font-family: inherit;
  color: var(--text);
  transition: background 0.3s, border-color 0.3s, color 0.3s;
}

.field input {
  width: 100%;
}

input[type="date"]::-webkit-calendar-picker-indicator,
input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: none; /* Default for light theme */
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background: var(--input-bg);
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator {
  filter: invert(1); /* Invert color for dark theme */
}

textarea {
  resize: vertical;
}

input[type="color"] {
  padding: 4px;
  height: 38px;
}

/* --- Circle --- */
.circle {
  height: 220px;
  width: 220px;
  border-radius: 50%;
  background: var(--bg2);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  box-shadow: inset 0 0 0 2px var(--ring);
  transition: background 0.3s, box-shadow 0.3s;
}

.circle .pill {
  position: absolute;
  bottom: -10px;
  background: #f4f4f5;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  color: #6b7280;
  transition: background 0.3s, color 0.3s;
}

[data-theme="dark"] .circle .pill {
  background: var(--bg2);
  color: var(--muted);
}

/* Pomodoro Timer Colors */
.circle.focus-active {
  background-color: var(--emerald);
  box-shadow: inset 0 0 0 2px var(--emerald-600);
}

.circle.break-active {
  background-color: var(--amber);
  box-shadow: inset 0 0 0 2px #d97706; /* A darker amber */
}

.focus-active #timer-text,
.focus-active .pill,
.break-active #timer-text,
.break-active .pill {
  color: white;
}

[data-theme="dark"] .focus-active .pill,
[data-theme="dark"] .break-active .pill {
    background-color: rgba(0,0,0,0.2);
}

[data-theme="light"] .focus-active .pill,
[data-theme="light"] .break-active .pill {
    background-color: rgba(0,0,0,0.1);
}

/* --- Badge --- */
.badge {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 999px;
}

/* --- Progress Bar --- */
.progress {
  height: 8px;
  border-radius: 6px;
  background: #e5e7eb;
  overflow: hidden;
  transition: background 0.3s;
}

[data-theme="dark"] .progress {
  background: var(--ring);
}

.progress > span {
  display: block;
  height: 100%;
  background-color: var(--emerald-600);
}

/* --- Title Pills --- */
.title-pill {
  border-radius: 14px;
  padding: 9px 15px;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .08);
  border: 0;
  backdrop-filter: saturate(140%) blur(2px);
  background-clip: padding-box;
  font-size: 18px;
}

.title-pilier {
  color: #fff;
  background: linear-gradient(90deg, #10b981, #059669);
  box-shadow: 0 10px 22px rgba(16, 185, 129, .3);
}

.title-marathonien {
  color: #fff;
  background: linear-gradient(90deg, #f59e0b, #d97706);
  box-shadow: 0 10px 22px rgba(245, 158, 11, .3);
}

.title-matheux {
  color: #fff;
  background: linear-gradient(90deg, #d946ef, #a21caf);
  box-shadow: 0 10px 22px rgba(217, 70, 239, .3);
}

.title-physicien {
  color: #fff;
  background: linear-gradient(90deg, #0ea5e9, #1d4ed8);
  box-shadow: 0 10px 22px rgba(37, 99, 235, .24), 0 4px 10px rgba(14, 165, 233, .22);
  filter: saturate(1.02);
}

.title-informaticien {
  color: #fff;
  background: linear-gradient(90deg, #fb7185, #e11d48);
  box-shadow: 0 10px 22px rgba(241, 71, 111, .3);
}

.title-ecrivain {
  color: #fff;
  background: linear-gradient(90deg, #a6e4ed, #194d6b);
  box-shadow: 0 10px 22px rgba(77, 182, 252, 0.3);
}

.title-bilingue {
  color: #fff;
  background: linear-gradient(90deg, #7c76e4, #3731a2);
  box-shadow: 0 10px 22px rgba(99, 102, 241, .3);
}

.title-legende {
  color: #fff;
  background: linear-gradient(270deg, #fa3553, #0370f6, #d423f0);
  background-size: 400% 400%;
  box-shadow: 0 10px 22px rgba(0, 0, 0, .3);
  animation: legende-glow 10s ease-in-out infinite;
}

@keyframes legende-glow {
  0% {
    background-position: 0% 50%;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .3);
  }
  50% {
    background-position: 100% 50%;
    box-shadow: 0 10px 35px rgba(0, 0, 0, .5);
  }
  100% {
    background-position: 0% 50%;
    box-shadow: 0 10px 22px rgba(0, 0, 0, .3);
  }
}

.title-divinite {
  color: #fff;
  background: linear-gradient(90deg, #fde68a, #fcd34d, #f59e0b);
  background-size: 200% 200%;
  box-shadow: 0 0 20px 5px rgba(252, 211, 77, 0.7);
  text-shadow: 0 0 5px rgba(0,0,0,0.5);
  animation: divine-halo 4s ease-in-out infinite;
}

@keyframes divine-halo {
  0% {
    background-position: 0% 50%;
    box-shadow: 0 0 20px 5px rgba(252, 211, 77, 0.7);
  }
  50% {
    background-position: 100% 50%;
    box-shadow: 0 0 30px 10px rgba(252, 211, 77, 0.9);
  }
  100% {
    background-position: 0% 50%;
    box-shadow: 0 0 20px 5px rgba(252, 211, 77, 0.7);
  }
}

.title-alien {
  color: #fff;
  background: linear-gradient(45deg, #ff00ff, #00ffff, #ffff00, #ff0000);
  background-size: 400% 400%;
  animation: psychedelic-bg 5s ease infinite;
  text-shadow: 2px 2px 4px #000000;
}

@keyframes psychedelic-bg {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* --- History Row --- */
.histrow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border);
  background: var(--histrow-bg);
  border-radius: 12px;
  padding: 8px 10px;
  transition: background 0.3s, border-color 0.3s;
}

[data-theme="dark"] .histrow {
  background: var(--histrow-bg);
}

.histrow-title {
  font-weight: 600;
  color: var(--text);
}

/* --- Sub Navigation --- */
.sub-nav-btn {
  padding: 6px 12px;
  font-size: 12px;
  background: var(--bg2);
}

.sub-nav-btn.active {
  background: var(--sky);
  color: white;
  border-color: transparent;
}

.sub-nav-btn .ico svg {
  width: 14px;
  height: 14px;
}

/* --- Details/Summary --- */
details > summary {
  list-style: none;
  cursor: pointer;
}

details > summary::-webkit-details-marker {
  display: none;
}

.summary-item {
  padding: 10px 12px;
  background: var(--summary-bg);
  border-radius: 10px;
  margin-bottom: 8px;
  font-weight: 600;
  transition: background 0.3s;
}

[data-theme="dark"] .summary-item {
  background: var(--summary-bg);
  border: 1px solid var(--border);
}

.details-content {
  padding-left: 16px;
  border-left: 2px solid var(--border);
  margin-bottom: 8px;
  transition: border-color 0.3s;
}

.comment-box {
  font-size: 12px;
  background: #f3f4f6;
  border-radius: 8px;
  padding: 8px 12px;
  margin-top: 6px;
  white-space: pre-wrap;
  cursor: pointer;
  transition: background 0.3s;
}

[data-theme="dark"] .comment-box {
  background: var(--ring);
}

/* Reduce margin for paragraphs generated by Markdown */
.news-content p,
#broadcastMessageContent p {
  margin-top: 0;
  margin-bottom: 0.75em; /* Conserve un petit espace après chaque paragraphe */
}

details.card > summary.hdr {
  border-bottom: 1px solid var(--border);
}

details.card[open] > summary.hdr {
  border-bottom: 1px solid var(--border);
}

details.card:not([open]) > summary.hdr {
  border-bottom: none;
}

/* --- Theme Switch --- */
.theme-switch-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.theme-switch {
  display: inline-block;
  height: 24px;
  position: relative;
  width: 44px;
}

.theme-switch input {
  display: none;
}

.slider {
  background-color: #ccc;
  bottom: 0;
  cursor: pointer;
  left: 0;
  position: absolute;
  right: 0;
  top: 0;
  transition: .4s;
  border-radius: 24px;
}

.slider:before {
  background-color: #fff;
  bottom: 4px;
  content: "";
  height: 16px;
  left: 4px;
  position: absolute;
  transition: .4s;
  width: 16px;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--sky);
}

input:checked + .slider:before {
  transform: translateX(20px);
}

input:disabled,
select:disabled,
textarea:disabled {
  color: var(--muted);
  background-color: var(--border);
  cursor: not-allowed;
  opacity: 0.7;
}

/* --- Impersonation --- */
.impersonate-link {
  text-decoration: none;
  color: var(--sky);
  font-weight: 500;
}

.impersonate-link:hover {
  text-decoration: underline;
}

.impersonation-banner {
  background: var(--amber);
  color: black;
  padding: 12px;
  text-align: center;
  font-weight: 500;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.impersonation-banner .btn {
  background: rgba(0, 0, 0, 0.1);
  border-color: rgba(0, 0, 0, 0.2);
  color: black;
  padding: 4px 10px;
}

/* --- Subject Selection --- */
.subject-clickable {
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  text-align: center;
  font-weight: 500;
  background-color: transparent;
}

.subject-clickable:hover {
  background-color: var(--border);
}

.subject-selected {
  border: 2px solid currentColor;
  padding: 7px 11px; /* Adjust padding for thicker border */
  background-color: transparent;
}

.subject-selected:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .subject-selected:hover {
  background-color: rgba(255, 255, 255, 0.05);
}

.subject-color-display {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  border: 1px solid var(--border);
  flex-shrink: 0;
}

/* --- Toast Notifications --- */
#toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  padding: 12px 18px;
  border-radius: 8px;
  color: white;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.4s cubic-bezier(0.21, 1.02, 0.73, 1);
}

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

.toast.success {
  background-color: var(--emerald-600);
}

.toast.error {
  background-color: var(--rose);
}

.toast.info {
  background-color: var(--sky);
}

/* --- Disabled Section --- */
.disabled-section {
  pointer-events: none; /* Désactive tous les événements de pointeur */
  opacity: 0.6; /* Grise visuellement */
}
.disabled-section input[type="number"],
.disabled-section input[type="checkbox"] {
  cursor: not-allowed;
}

/* --- Table --- */
.table {
  width: 100%;
  border-collapse: collapse;
}

.table th,
.table td {
  border: 1px solid var(--muted);
  padding: 8px 12px;
}

.table th {
  background-color: var(--summary-bg);
  font-weight: 600;
}

.table tbody tr:nth-child(even) {
  background-color: var(--bg);
}

.table tbody tr:hover {
  background-color: var(--border);
  cursor: pointer;
}

/* --- Ranking List --- */
.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ranking-header,
.ranking-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background-color: var(--bg2);
  transition: background-color 0.3s, border-color 0.3s;
}

.ranking-header {
  font-weight: 600;
  background-color: var(--summary-bg);
  border-bottom: 1px solid var(--border);
}

.ranking-item {
  justify-content: space-between;
}

.ranking-col {
  padding: 0 4px;
}

.position-col {
  flex-basis: 10%;
  text-align: center;
}

.name-col {
  flex-basis: 50%;
}

.xp-col {
  flex-basis: 20%;
  text-align: center;
}

.action-col {
  flex-basis: 20%;
  text-align: right;
}

.name-col span {
  display: inline-block;
  margin-right: 4px;
}

.current-user-rank {
  background-color: var(--emerald);
  color: white;
  border-color: var(--emerald-600);
}

.current-user-rank .muted {
  color: rgba(255, 255, 255, 0.8);
}

/* --- Accordion --- */
.accordion-header {
  cursor: pointer;
  padding: 12px;
  background-color: var(--summary-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  margin-bottom: 4px;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.accordion-content {
  padding: 12px;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  display: none;
}

.accordion-content.show {
  display: block;
}

.accordion-icon {
  transition: transform 0.3s ease;
}

.accordion-header.active .accordion-icon {
  transform: rotate(180deg);
}

/* --- User Menu Dropdown --- */
.user-menu-container {
  position: relative;
  display: inline-block;
}

.user-menu {
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: opacity 0.2s ease-out, transform 0.2s ease-out, visibility 0.2s;
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  background-color: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-width: 200px;
  z-index: 100;
  padding: 8px;
  overflow: hidden;
}

.user-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.user-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: 10px;
  font-size: 13px;
}

.user-menu-item:hover {
  background-color: var(--border);
}

.user-menu-item .ico svg {
  width: 16px;
  height: 16px;
}

/* ===================================================================
   UTILITY CLASSES
   =================================================================== */
.row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media(min-width: 992px) {
  .row.lg-3 {
    grid-template-columns: 0.75fr 0.85fr 1.4fr;
  }

  .row.lg-3 > .card {
    min-width: 0;
  }

  .row.lg-3.row-dashboard-bottom {
    grid-template-columns: 2fr 1fr; /* Adjust for two cards: Objectif hebdo (2 parts) and Titres (1 part) */
  }
}

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

.grid {
  display: grid;
}

.gap-8 {
  gap: 8px;
}

.gap-12 {
  gap: 12px;
}

.gap-16 {
  gap: 16px;
}

.justify-start {
  justify-content: flex-start;
}

.muted {
  color: var(--muted);
}

.right-fixed {
  position: fixed;
  right: 16px;
  top: 16px;
  z-index: 20;
}

.scroller {
  max-height: 320px;
  overflow: auto;
  padding-right: 14px;
}

.ico {
  display: inline-flex;
  gap: 6px;
}

.ico svg {
  width: 20px;
  height: 20px;
  vertical-align: -3px;
}

.sep {
  height: 1px;
  background: var(--border);
  margin: 16px 0;
  transition: background 0.3s;
}

.sortable-header {
  cursor: pointer;
}

.sortable-header:hover {
  color: var(--sky);
}

.list-unstyled {
  list-style: none;
  padding-left: 0;
  margin-top: 0;
  margin-bottom: 0;
}

#compositeTitlesModal .grid label {
  justify-content: flex-start;
}

/* --- Save Indicator --- */
#save-indicator {
    position: fixed;
    top: 22px;
    right: 250px; /* Adjust as needed */
    padding: 4px 10px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: white;
    opacity: 0;
    transition: opacity 0.5s ease-in-out;
    pointer-events: none; /* Make it non-interactive */
}

#save-indicator.saving,
#save-indicator.saved,
#save-indicator.error {
    opacity: 1;
}

#save-indicator.saving {
    background-color: var(--muted);
    color: var(--text);
}

#save-indicator.saved {
    background-color: var(--emerald);
}

#save-indicator.error {
    background-color: var(--rose);
}


.composite-title-reqs {
  justify-items: start;
}

/* Routines Page */
.routine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 16px;
}

.routines-container .card:not(:last-child) {
  margin-bottom: 24px;
}

.task-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.task-item {
  display: flex;
  align-items: center;
  gap: 16px;
  background-color: var(--bg);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: background-color 0.2s, opacity 0.3s;
}

.task-item:hover {
  background-color: var(--summary-bg);
}

.task-details {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-grow: 1;
}

.task-description {
  font-weight: 500;
  transition: color 0.3s;
}

.task-streaks-info {
  display: flex;
  gap: 8px; /* Space between current and longest streak */
  align-items: center;
}

.task-streak,
.task-longest-streak {
  font-size: 13px;
  font-weight: 500;
  background-color: var(--summary-bg);
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap; /* Prevent wrapping */
}

.task-streak {
  color: var(--amber);
}

.task-longest-streak {
  color: var(--indigo); /* A different color to distinguish */
}

[data-theme="dark"] .task-streak,
[data-theme="dark"] .task-longest-streak {
  background-color: var(--bg);
}

/* Custom Checkbox */
.task-checkbox {
  position: relative;
  cursor: pointer;
  font-size: 22px;
  user-select: none;
  display: flex;
  align-items: center;
}

.task-checkbox input {
  position: absolute;
  opacity: 0;
  cursor: pointer;
  height: 0;
  width: 0;
}

.custom-checkbox {
  height: 24px;
  width: 24px;
  background-color: var(--summary-bg);
  border: 2px solid var(--ring);
  border-radius: 6px;
  transition: all 0.2s;
  display: inline-block;
}

.task-checkbox:hover input ~ .custom-checkbox {
  border-color: var(--emerald);
}

.task-checkbox input:checked ~ .custom-checkbox {
  background-color: var(--emerald);
  border-color: var(--emerald-600);
}

.custom-checkbox:after {
  content: "";
  position: absolute;
  display: none;
  left: 8px;
  top: 4px;
  width: 6px;
  height: 12px;
  border: solid white;
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.task-checkbox input:checked ~ .custom-checkbox:after {
  display: block;
}

/* Completed State */
.task-item.completed {
  opacity: 0.6;
}

.task-item.completed .task-description {
  text-decoration: line-through;
  color: var(--muted);
}

/* Routines List */
.routines-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.routine-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: var(--bg);
  padding: 12px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  transition: background-color 0.2s, opacity 0.3s, border-color 0.3s;
}

.routine-item:hover {
  background-color: var(--summary-bg);
}

.routine-info {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 4px;
}

.routine-description {
  font-weight: 600;
  font-size: 15px;
}

.routine-frequency {
  font-size: 12px;
}

.routine-streaks {
  display: flex;
  gap: 8px;
  font-size: 13px;
}

.routine-streaks span {
  background-color: var(--summary-bg);
  padding: 4px 8px;
  border-radius: 8px;
  white-space: nowrap;
}

[data-theme="dark"] .routine-streaks span {
  background-color: var(--bg);
}

.routine-actions {
  display: flex;
  gap: 8px;
  margin-left: 16px; /* Space between info and actions */
}

.routine-actions .btn-icon {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background-color: var(--bg2);
  color: var(--text);
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
}

.routine-actions .btn-icon:hover {
  background-color: var(--summary-bg);
  border-color: var(--ring);
}

.routine-actions .btn-icon i {
  font-size: 16px;
}

/* Paused State */
.routine-item.paused {
  opacity: 0.7;
  border-color: var(--muted);
  background-color: var(--summary-bg);
}

.routine-item.paused .routine-description,
.routine-item.paused .routine-frequency,
.routine-item.paused .routine-streaks span {
  color: var(--muted);
}

.routine-item.paused .routine-actions .btn-icon {
  border-color: var(--muted);
  color: var(--muted);
  background-color: var(--bg);
}

.routine-item.paused .routine-actions .btn-icon:hover {
  background-color: var(--border);
}

/* ===================================================================
   MODALS
   =================================================================== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.3s ease-out;
}

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

.modal-content {
  background-color: var(--bg2);
  margin: 10% auto;
  padding: 24px; /* Restore padding here */
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 90%;
  max-width: 500px;
  position: relative;
  animation: slideIn 0.3s ease-out;
  overflow: hidden; /* Ensure rounded corners apply to header */
}

/* Specific styling for the friend titles modal content */
#friend-titles-modal .modal-content {
  padding: 0; /* Remove padding for this specific modal */
}

/* Reduce top padding for specific modals */
#thresholdsModal .modal-content,
#compositeTitlesModal .modal-content {
  padding-top: 16px;
}

.modal-header {
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: var(--sky); /* Blue background */
  color: white; /* White text */
}

.modal-header h2 {
  margin: 0;
  color: white;
}

.modal-header .btn-icon-square {
  background-color: transparent;
  border: none;
  color: white; /* White icon */
}

.modal-header .btn-icon-square:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

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

.close-modal {
  color: var(--muted);
  position: absolute;
  top: 10px;
  right: 20px;
  font-size: 28px;
  font-weight: bold;
  transition: color 0.2s;
}

.close-modal:hover,
.close-modal:focus {
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

#routine-modal h3,
#edit-pomodoro-modal h3,
#add-grade-modal h3,
#edit-grade-modal h3,
#thresholdsModal h3,
#compositeTitlesModal h3 {
  margin-top: 0;
  margin-bottom: 24px;
  font-size: 18px;
}

#routine-form .form-group {
  margin-bottom: 16px;
  display: flex; /* Use flexbox */
  align-items: center; /* Vertically align items */
  gap: 8px; /* Space between elements */
  justify-content: flex-start;
}

#routine-form .form-group label {
  flex-shrink: 0; /* Prevent label from shrinking */
  margin-bottom: 0; /* Remove default margin */
}

#routine-form .form-group input[type="number"] {
  flex-grow: 0; /* Prevent input from growing */
}

#routine-form .form-group span {
  /* flex-grow: 1; */ /* Allow span to take remaining space */
}

#routine-form .form-group:last-child {
  margin-bottom: 0;
  margin-top: 24px;
  justify-content: center;
}



#routine-form label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  color: var(--muted);
}

#routine-form input[type="text"],
#routine-form select {
  width: 100%;
}

.form-group-checkbox {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.form-group-checkbox label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: normal;
}

.monthly-dates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(40px, 1fr));
  gap: 8px;
}

.monthly-dates-grid label {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.monthly-dates-grid label:hover {
  background-color: var(--summary-bg);
}

.monthly-dates-grid input[type="checkbox"] {
  display: none;
}

.monthly-dates-grid input[type="checkbox"]:checked + span {
  background-color: var(--emerald);
  color: white;
  border-radius: 6px;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.monthly-dates-grid span {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  border-radius: 6px;
}

.weekly-days-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center; /* Center the buttons */
}

.day-button {
  background-color: var(--summary-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px; /* Adjust padding for better button size */
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  min-width: 40px; /* Ensure a minimum width for single letters */
  text-align: center;
}

.day-button:hover {
  background-color: var(--border);
}

.day-button.selected {
  background-color: var(--sky);
  color: white;
  border-color: var(--sky);
}

[data-theme="dark"] .day-button {
  background-color: var(--bg2);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .day-button.selected {
  background-color: var(--sky);
  border-color: var(--sky);
  color: white;
}


/* Monthly Day Buttons */
.monthly-days-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center; /* Center the buttons */
}

.monthly-day-button {
  background-color: var(--summary-bg);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s;
  min-width: 40px; /* Ensure a minimum width */
  text-align: center;
}

.monthly-day-button:hover {
  background-color: var(--border);
}

.monthly-day-button.selected {
  background-color: var(--sky);
  color: white;
  border-color: var(--sky);
}

[data-theme="dark"] .monthly-day-button {
  background-color: var(--bg2);
  border-color: var(--border);
  color: var(--text);
}

[data-theme="dark"] .monthly-day-button.selected {
  background-color: var(--sky);
  border-color: var(--sky);
  color: white;
}

/* ===================================================================
   MOBILE NAVIGATION (Hamburger Menu)
   =================================================================== */
.hamburger-menu-toggle {
  display: none; /* Hidden by default on desktop */
  position: fixed; /* Use fixed to ensure it's always in the viewport */
  top: 0px;
  left: 0px;
  padding: 10px; /* Add padding for better click area */
  z-index: 30; /* Above user-menu-container */
  cursor: pointer;
  background: transparent; /* Ensure no background interferes */
  border: none; /* Remove any default button border */
}

.hamburger-menu-toggle svg {
  width: 24px; /* Adjust size as needed */
  height: 24px; /* Adjust size as needed */
  display: block; /* Ensure it takes up its own space */
  stroke: var(--text); /* Use text color for the lines */
  stroke-width: 2;
}

.mobile-nav-close-btn {
  background: transparent;
  border: none;
  border-radius: 0;
  width: auto; /* Allow the icon to dictate width */
  height: auto; /* Allow the icon to dictate height */
  padding: 0; /* Remove padding from the button itself */
}

.mobile-nav-close-btn .ico svg {
  width: 24px; /* Adjust size as needed */
  height: 24px; /* Adjust size as needed */
  stroke: var(--text); /* Use text color for the lines */
  stroke-width: 2;
}





.mobile-nav-menu {
  display: none; /* Hidden by default */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: var(--bg2);
  z-index: 25; /* Below hamburger toggle, above app content */
  overflow-y: auto;
  transform: translateX(-100%); /* Start off-screen to the left */
  transition: transform 0.3s ease-out;
  box-shadow: var(--shadow);
}

.mobile-nav-menu.show {
  transform: translateX(0); /* Slide in */
}

.mobile-nav-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background-color: var(--summary-bg);
}

.mobile-nav-title {
  font-size: 1.2em;
  font-weight: bold;
  color: var(--text);
}

.mobile-nav-content {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mobile-nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--text);
  text-decoration: none;
  border-radius: 10px;
  font-size: 16px;
  transition: background-color 0.2s;
}

.mobile-nav-item:hover {
  background-color: var(--border);
}

.mobile-nav-item.active {
  background-color: var(--sky);
  color: white;
}

.mobile-nav-item .ico svg {
  width: 20px;
  height: 20px;
}

/* Media Queries for responsiveness */
@media (max-width: 768px) { /* Adjust breakpoint as needed */
  .tabs {
    display: none; /* Hide desktop tabs on mobile */
  }

  .hamburger-menu-toggle {
    display: flex; /* Show hamburger icon on mobile */
  }

  .mobile-nav-menu {
    display: block; /* Make mobile menu block-level for transitions */
  }

  .right-fixed {
    right: 16px; /* Keep it on the right */
    left: auto; /* Ensure it's not affected by left positioning */
  }
}

@media (max-width: 768px) {
  .routine-item {
    flex-direction: column;
    align-items: flex-start; /* Align items to the start when stacked vertically */
  }

  .routine-info {
    width: 100%; /* Take full width when stacked */
    margin-bottom: 8px; /* Add some space below info */
  }

  .routine-actions {
    width: 100%; /* Take full width */
    justify-content: center; /* Center the buttons */
    margin-left: 0; /* Remove left margin */
  }

  .routine-streaks span {
    white-space: normal; /* Allow text to wrap */
  }

  /* Hide the user menu dropdown on mobile, as navigation is handled by the hamburger menu */
  .user-menu.show {
    display: none !important;
  }
}

@media (min-width: 769px) { /* Adjust breakpoint as needed */
  .hamburger-menu-toggle,
  .mobile-nav-menu {
    display: none !important; /* Hide mobile elements on desktop */
  }
}

/* --- Title Selection in User Menu --- */
.user-menu-section-header {
  font-size: 12px;
  color: var(--muted);
  padding: 8px 12px 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
 
.title-selection-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 0 8px;
}

.title-option {
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
  font-size: 13px;
  color: var(--text);
}

.title-option:hover {
  background-color: var(--border);
}

.title-option.selected {
  background-color: var(--sky);
  color: white;
  font-weight: 600;
}



/* --- Mobile Responsiveness Fixes --- */
@media (max-width: 768px) {
  .mobile-two-col-grid {
    grid-template-columns: 1fr !important; /* Force single column for these grids */
  }

  .mobile-auto-fit-grid {
    grid-template-columns: 1fr !important; /* Force single column for these grids */
  }
}

/* --- Unlocked Titles Modal Styling --- */
.unlocked-titles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 0px;
}

.unlocked-title-item {
  background-color: var(--bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.unlocked-title-item:hover {
  transform: translateY(-3px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.unlocked-title-item .title-name {
  font-weight: 700;
  color: var(--text);
  font-size: 1.1em;
  margin-bottom: 5px;
}

.unlocked-title-item .title-date {
  font-size: 0.9em;
  color: var(--muted);
}

[data-theme="dark"] .unlocked-title-item {
  background-color: var(--bg2);
}

.hide-on-create {
    display: none;
}