:root {
  --primary: #3d5a80;
  --primary-dark: #2f4761;
  --radius: 12px;
  --radius-sm: 10px;

  /* Theme tokens: swapped wholesale by the dark-mode toggle (see the
     [data-theme="dark"] block below), independent of any DIY block color. */
  --text: #2b2f36;
  --text-muted: #667085;
  --text-faint: #9aa4b0;
  --surface: #ffffff;
  --surface-alt: #f8f9fb;
  --surface-alt-2: #eef1f5;
  --border: #d5dbe3;
  --border-soft: #d8dee5;
  --track: #e5e9ee;
  --input-bg: #fbfbfa;
  --input-bg-focus: #ffffff;
  --divider: #eceff3;
  --success-bg: #eaf3ec;
  --success-fg: #2f7a43;
  --info-bg: #dfe7ee;

  /* DIY block tokens (web/js/appearance.js: APPEARANCE_BLOCKS). Each
     defaults to a theme token or --primary here so it "just works" and
     follows dark mode automatically until a user actually unlocks a color
     for that block -- at which point appearance.js inline-overrides the
     specific variable(s) below with a literal hex that no longer changes
     with the theme. */
  --bg-start: #f6f4ef;
  --bg-end: #e9eef4;
  --nav-bg: transparent;
  --card-bg: var(--surface);
  --card-text: var(--text);
  --primary-btn-bg: var(--primary);
  --primary-btn-text: #ffffff;
  --progress-fill: var(--primary);
  --secondary-btn-color: var(--primary);
  --cat-study-bg: #dfe7ee;
  --cat-study-fg: var(--primary);
  --cat-work-bg: #f7e6c4;
  --cat-work-fg: #8a5a10;
  --cat-life-bg: #dff0e3;
  --cat-life-fg: #2f7a43;
  --cat-health-bg: #fbe0e0;
  --cat-health-fg: #b23b3b;
}

/* Dark mode: an independent axis from preset/DIY colors (see
   web/js/appearance.js applyAppearanceToDom). Redefines the theme tokens
   plus every DIY block's *default* -- a block a user has actually
   customized gets its variables inline-overridden on <html> by JS, which
   beats these rules regardless of theme, so a picked color never changes
   between light and dark. */
html[data-theme="dark"] {
  --primary: #6f93c2;
  --text: #e6e8ec;
  --text-muted: #9aa8b8;
  --text-faint: #6b7684;
  --surface: #1e2530;
  --surface-alt: #262d3a;
  --surface-alt-2: #2d3644;
  --border: #3a4453;
  --border-soft: #3a4453;
  --track: #333c4a;
  --input-bg: #20262f;
  --input-bg-focus: #262d3a;
  --divider: #333c4a;
  --success-bg: #203a29;
  --success-fg: #5fbf82;
  --info-bg: #26364a;

  --bg-start: #14161b;
  --bg-end: #1b1f26;
  --cat-study-bg: #26364a;
  --cat-work-bg: #3a2f18;
  --cat-work-fg: #e0a94e;
  --cat-life-bg: #1e3326;
  --cat-life-fg: #5fbf82;
  --cat-health-bg: #3a2020;
  --cat-health-fg: #e08585;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
  min-height: 100vh;
}

a {
  color: inherit;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 0 20px 60px;
}

/* Home page: wide two-column layout (main + sidebar), stacks on narrow screens */
.home-layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 0 20px 60px;
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 24px;
  align-items: start;
}

.home-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: sticky;
  top: 20px;
}

@media (max-width: 900px) {
  .home-layout {
    grid-template-columns: 1fr;
  }
  .home-sidebar {
    position: static;
  }
}

/* Header / nav */
header.nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  max-width: 640px;
  margin: 0 auto;
  padding: 20px 20px 10px;
  background: var(--nav-bg);
  border-radius: var(--radius);
}

body.home header.nav {
  max-width: 1120px;
}

.brand {
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--nav-text, var(--primary));
  text-decoration: none;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.nav-links a {
  margin-right: 16px;
  text-decoration: none;
  color: var(--nav-text, var(--text-muted));
  font-size: 0.95rem;
}

.nav-links a:last-child {
  margin-right: 0;
}

.nav-links a.active {
  color: var(--nav-text, var(--primary));
  font-weight: 600;
}

.lang-switch {
  display: flex;
  gap: 6px;
}

.lang-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-muted);
}

.lang-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.logout-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.82rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}

.logout-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  color: var(--text-muted);
}

.icon-nav-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.icon-nav-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* Card */
.card {
  background: var(--card-bg);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 30px 26px;
  box-shadow: 0 6px 24px rgba(61, 90, 128, 0.1);
  margin-top: 12px;
}

h1 {
  font-size: 1.55rem;
  margin: 0 0 8px;
  color: var(--card-text);
}

h2 {
  font-size: 1.25rem;
  margin: 0 0 8px;
  color: var(--card-text);
}

.subtitle {
  color: var(--text-muted);
  line-height: 1.55;
  margin: 0 0 22px;
}

textarea {
  width: 100%;
  min-height: 120px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  background: var(--input-bg);
  color: var(--card-text);
}

textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.15);
  background: var(--input-bg-focus);
}

/* Auth form fields */
.field-label {
  display: block;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--card-text);
  margin: 18px 0 6px;
}

.field-label:first-of-type {
  margin-top: 0;
}

input[type="text"],
input[type="password"],
input[type="email"] {
  width: 100%;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--card-text);
}

input[type="text"]:focus,
input[type="password"]:focus,
input[type="email"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.15);
  background: var(--input-bg-focus);
}

.auth-toggle {
  margin: 22px 0 0;
  text-align: center;
}

.auth-toggle a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  margin-left: 4px;
}

.auth-toggle a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
}

button.primary {
  margin-top: 16px;
  background: var(--primary-btn-bg);
  color: var(--primary-btn-text);
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 24px;
  font-size: 1rem;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
}

button.primary:hover:not(:disabled) {
  opacity: 0.92;
}

button.primary:active:not(:disabled) {
  transform: translateY(1px);
}

button.primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

a.secondary,
button.secondary {
  display: inline-block;
  background: var(--surface);
  color: var(--secondary-btn-color);
  border: 1px solid var(--secondary-btn-color);
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}

a.danger,
button.danger {
  display: inline-block;
  background: var(--surface);
  color: #c0392b;
  border: 1px solid #c0392b;
  border-radius: var(--radius-sm);
  padding: 11px 20px;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
}

a.danger:hover,
button.danger:hover:not(:disabled) {
  background: #c0392b;
  color: #fff;
}

button.danger.primary-danger {
  background: #c0392b;
  color: #fff;
  border: none;
}

button.danger.primary-danger:hover:not(:disabled) {
  opacity: 0.9;
  background: #c0392b;
}

.warning-text {
  color: #c0392b;
  font-size: 0.88rem;
  margin-top: 10px;
  display: none;
}

.success-text {
  color: #2f7a43;
  font-size: 0.88rem;
  margin-top: 10px;
  display: none;
}

.success-text.show {
  display: block;
}

.settings-divider {
  border: none;
  border-top: 1px solid var(--surface-alt);
  margin: 24px 0;
}

.warning-text.show {
  display: block;
}

/* Loading dots */
.loading-row {
  display: none;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.loading-row.show {
  display: flex;
}

.spinner {
  width: 16px;
  height: 16px;
  border: 2px solid var(--border-soft);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Progress bar */
.progress-bar-track {
  height: 8px;
  background: var(--track);
  border-radius: 6px;
  overflow: hidden;
  margin: 4px 0 22px;
}

.progress-bar-fill {
  height: 100%;
  background: var(--progress-fill);
  width: 0%;
  transition: width 0.3s ease;
}

.progress-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* Steps */
.task-title-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
  margin-bottom: 4px;
}

.task-title {
  flex: 1;
  min-width: 0;
  font-size: 1.3rem;
  margin: 0;
  color: var(--card-text);
}

.icon-edit-btn {
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  width: 30px;
  height: 30px;
  font-size: 0.9rem;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
}

.icon-edit-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.task-title-edit-input {
  flex: 1;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  font-size: 1.1rem;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--card-text);
}

.task-title-edit-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(61, 90, 128, 0.15);
  background: var(--input-bg-focus);
}

/* Task color picker (creation preview screen) */
.color-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin: 4px 0 18px;
}

.color-swatch {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
}

.color-swatch.active {
  border-color: var(--card-text);
  box-shadow: 0 0 0 2px var(--card-bg) inset;
}

.color-swatch-custom {
  width: 34px;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: none;
  overflow: hidden;
}

.color-swatch-custom::-webkit-color-swatch-wrapper {
  padding: 0;
}

.color-swatch-custom::-webkit-color-swatch {
  border: none;
  border-radius: 50%;
}

.step-list {
  margin-top: 18px;
}

.step-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  margin-bottom: 10px;
  transition: background 0.2s ease;
}

.step-item.done {
  background: var(--success-bg);
}

.step-item input[type="checkbox"] {
  width: 20px;
  height: 20px;
  margin-top: 2px;
  accent-color: var(--primary);
  cursor: pointer;
  flex-shrink: 0;
}

.step-main {
  flex: 1;
}

.step-text {
  line-height: 1.5;
  color: var(--text);
}

.step-text.done {
  text-decoration: line-through;
  color: var(--text-faint);
}

.step-points {
  font-size: 0.78rem;
  color: var(--primary);
  font-weight: 600;
  white-space: nowrap;
  align-self: center;
}

/* Congrats */
.congrats {
  text-align: center;
  padding: 20px 4px 6px;
}

.congrats-emoji {
  font-size: 2.6rem;
  margin-bottom: 6px;
}

.congrats h2 {
  color: var(--primary);
}

.congrats p {
  color: var(--text-muted);
  margin-bottom: 22px;
}

.actions-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 22px;
}

.actions-row.center {
  justify-content: center;
}

/* Stats */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 6px;
}

.stat-box {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 22px 14px;
  text-align: center;
}

.stat-value {
  font-size: 2.1rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.stat-label {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin-top: 6px;
}

/* Task list on points page */
.section-label {
  font-size: 1rem;
  font-weight: 600;
  margin: 30px 0 12px;
  color: var(--card-text);
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.task-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  padding: 13px 15px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  text-decoration: none;
  color: inherit;
}

.task-list-item:hover {
  background: var(--surface-alt-2);
}

.task-list-title {
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--info-bg);
  color: var(--primary);
}

.badge.completed {
  background: var(--success-bg);
  color: var(--success-fg);
}

.badge-group {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Category badges + picker chips share the same color mapping */
.category-badge {
  flex-shrink: 0;
  font-size: 0.75rem;
  padding: 4px 10px;
  border-radius: 20px;
  white-space: nowrap;
}

.category-badge.study {
  background: var(--cat-study-bg);
  color: var(--cat-study-fg);
}

.category-badge.work {
  background: var(--cat-work-bg);
  color: var(--cat-work-fg);
}

.category-badge.life {
  background: var(--cat-life-bg);
  color: var(--cat-life-fg);
}

.category-badge.health {
  background: var(--cat-health-bg);
  color: var(--cat-health-fg);
}

.category-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 4px 0 18px;
}

.category-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}

.category-chip.active {
  background: var(--surface-alt-2);
  border-color: var(--primary);
  color: var(--primary);
}

.category-chip.active.study {
  background: var(--cat-study-bg);
  border-color: var(--cat-study-fg);
  color: var(--cat-study-fg);
}

.category-chip.active.work {
  background: var(--cat-work-bg);
  border-color: var(--cat-work-fg);
  color: var(--cat-work-fg);
}

.category-chip.active.life {
  background: var(--cat-life-bg);
  border-color: var(--cat-life-fg);
  color: var(--cat-life-fg);
}

.category-chip.active.health {
  background: var(--cat-health-bg);
  border-color: var(--cat-health-fg);
  color: var(--cat-health-fg);
}

/* Sidebar cards on Home (narrower padding to fit the 300px column) */
.sidebar-card {
  padding: 20px 18px;
}

.sidebar-card .section-label {
  margin-top: 0;
}

.sidebar-card .stats-grid {
  margin-top: 4px;
}

/* "My Tasks" cards on Home */
.my-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 22px;
}

.my-task-card {
  display: block;
  background: var(--card-bg);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 16px 18px;
  box-shadow: 0 4px 14px rgba(61, 90, 128, 0.08);
  text-decoration: none;
  color: inherit;
  transition: transform 0.1s ease, box-shadow 0.15s ease;
}

.my-task-card:hover {
  box-shadow: 0 6px 20px rgba(61, 90, 128, 0.14);
  transform: translateY(-1px);
}

.my-task-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.my-task-card-title {
  font-weight: 600;
  font-size: 0.98rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.my-task-progress-label {
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.my-task-progress-track {
  height: 6px;
  background: var(--track);
  border-radius: 6px;
  overflow: hidden;
}

.my-task-progress-fill {
  height: 100%;
  background: var(--progress-fill);
}

/* Floating +N point feedback on step completion */
.point-float {
  position: fixed;
  pointer-events: none;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
  z-index: 1000;
  animation: pointFloat 0.9s ease-out forwards;
}

@keyframes pointFloat {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.8);
  }
  15% {
    opacity: 1;
    transform: translate(-50%, -6px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -42px) scale(1);
  }
}

/* Confetti burst on task completion */
.confetti-piece {
  position: fixed;
  top: -12px;
  width: 8px;
  height: 14px;
  pointer-events: none;
  z-index: 1000;
  animation-name: confettiFall;
  animation-timing-function: ease-in;
  animation-fill-mode: forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(70vh) rotate(540deg);
    opacity: 0;
  }
}

.congrats-emoji.pop,
.congrats h2.pop {
  animation: congratsPop 0.5s ease;
}

@keyframes congratsPop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  60% {
    transform: scale(1.15);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.empty-state {
  color: var(--text-muted);
  text-align: center;
  padding: 20px 0 4px;
  line-height: 1.6;
}

/* Customize (wardrobe) placeholder page */
.customize-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.points-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-alt);
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

/* Preset color schemes (customize.html) */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 14px;
}

.preset-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  font-family: inherit;
}

.preset-swatch-preview {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.06);
}

.preset-swatch.active .preset-swatch-preview {
  box-shadow: 0 0 0 3px var(--primary);
}

.preset-swatch-card {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 6px;
}

.preset-swatch-btn {
  width: 16px;
  height: 6px;
  border-radius: 3px;
}

.preset-swatch-name {
  font-size: 0.78rem;
  color: var(--card-text);
  text-align: center;
}

/* Dark mode toggle (customize.html) */
.theme-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

/* DIY block accordion (customize.html) */
.block-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.block-item {
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 4px 14px;
  background: var(--surface-alt);
}

.block-summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
}

.block-summary::-webkit-details-marker {
  display: none;
}

.block-summary-arrow {
  color: var(--text-muted);
  font-size: 0.75rem;
  transition: transform 0.15s ease;
  flex-shrink: 0;
}

.block-item[open] .block-summary-arrow {
  transform: rotate(90deg);
}

.block-tier-badge {
  flex-shrink: 0;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 20px;
  background: var(--surface-alt-2);
  color: var(--text-muted);
  white-space: nowrap;
}

.block-name {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--card-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.block-current-swatch {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08) inset;
}

.block-progress-note {
  flex-shrink: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

.block-body {
  padding: 2px 0 16px;
}

.block-progress-track {
  height: 5px;
  background: var(--track);
  border-radius: 4px;
  overflow: hidden;
  margin: 2px 0 14px;
}

.block-progress-fill {
  height: 100%;
  background: var(--primary);
}

.block-graduated-note {
  font-size: 0.82rem;
  color: var(--success-fg);
  margin: 2px 0 14px;
}

.unlocked-colors-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

.unlocked-color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  cursor: pointer;
}

.unlocked-color-swatch.active {
  border-color: var(--card-text);
}

.unlock-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  padding: 9px 16px;
}

.block-insufficient-note {
  font-size: 0.78rem;
  color: #c0392b;
  margin-top: 8px;
}

footer.note {
  text-align: center;
  color: var(--text-faint);
  font-size: 0.8rem;
  margin-top: 26px;
}

/* Habit suggestion box (Home, shown alongside the AI's normal step preview) */
.habit-suggest-box {
  background: var(--surface-alt);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 16px 18px;
  margin-top: 18px;
}

.habit-suggest-text {
  margin: 0 0 12px;
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.5;
}

.habit-challenge-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 12px;
}

.habit-challenge-row input[type="number"] {
  width: 70px;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 0.95rem;
  font-family: inherit;
  background: var(--input-bg);
  color: var(--card-text);
}

/* Habit task detail card */
.habit-stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(90px, 1fr));
  gap: 12px;
  margin: 4px 0 18px;
}

.habit-stat {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 14px 10px;
  text-align: center;
}

.habit-stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.habit-stat-label {
  color: var(--text-muted);
  font-size: 0.78rem;
  margin-top: 4px;
}

.habit-projected {
  color: var(--text-muted);
  font-size: 0.88rem;
  margin: 0 0 16px;
}

.habit-checkin-btn {
  width: 100%;
  text-align: center;
  font-size: 1.05rem;
  padding: 14px 24px;
}

.habit-checkin-btn.checked {
  background: var(--success-fg);
}

.habit-view-toggle {
  display: flex;
  gap: 6px;
  margin: 22px 0 14px;
}

.habit-view-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  padding: 6px 14px;
  font-size: 0.85rem;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
}

.habit-view-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* Heatmap strip view */
.habit-heatmap {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.habit-heat-cell {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: var(--track);
}

.habit-heat-cell.on {
  background: var(--progress-fill);
}

/* Calendar view */
.habit-cal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 6px;
}

.habit-cal-month {
  font-weight: 600;
  color: var(--card-text);
  min-width: 80px;
  text-align: center;
}

.habit-cal-nav {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 1rem;
  line-height: 1;
}

.habit-cal-nav:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.habit-cal-rate {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-bottom: 10px;
}

.habit-cal-weekdays,
.habit-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  text-align: center;
}

.habit-cal-weekdays {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-bottom: 4px;
}

.habit-cal-cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: var(--surface-alt);
  font-size: 0.8rem;
  color: var(--card-text);
}

.habit-cal-cell.empty {
  background: transparent;
}

.habit-cal-cell.on {
  background: var(--progress-fill);
  color: #fff;
  font-weight: 600;
}

.habit-cal-cell.future {
  color: var(--text-faint);
}

/* Home page: big multi-task activity calendar (full width, below the
   main input + sidebar layout, not inside the narrow sidebar column) */
.home-calendar-section {
  max-width: 1120px;
  margin: 24px auto 0;
  padding: 0 20px 60px;
}

.calendar-card {
  margin-top: 0;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-bottom: 4px;
}

.calendar-month-label {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--card-text);
  min-width: 100px;
  text-align: center;
}

.calendar-weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
}

.calendar-weekdays {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-align: center;
  margin: 18px 0 6px;
}

.calendar-cell {
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  cursor: pointer;
}

.calendar-cell:hover {
  background: var(--surface-alt-2);
}

.calendar-cell.empty {
  background: transparent;
  cursor: default;
}

.calendar-cell.today {
  background: var(--info-bg);
  box-shadow: inset 0 0 0 2px var(--primary);
}

.calendar-cell-day {
  font-size: 0.82rem;
  color: var(--card-text);
}

.calendar-cell.today .calendar-cell-day {
  color: var(--primary);
  font-weight: 700;
}

.calendar-dots {
  display: flex;
  align-items: center;
  gap: 3px;
  min-height: 8px;
}

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

.calendar-dot-more {
  font-size: 0.62rem;
  color: var(--text-muted);
  line-height: 1;
}

.calendar-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 18px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--divider);
}

.calendar-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.calendar-legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Day-detail modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(31, 45, 61, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1100;
}

.modal-box {
  background: var(--card-bg);
  color: var(--card-text);
  border-radius: var(--radius);
  padding: 22px 24px;
  max-width: 420px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(31, 45, 61, 0.25);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 16px;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--card-text);
}

.modal-close-btn {
  border: none;
  background: none;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--text-muted);
  line-height: 1;
  padding: 4px;
}

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

.modal-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.calendar-day-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--card-text);
}

.calendar-day-item:hover {
  background: var(--surface-alt);
}

.calendar-day-item-title {
  line-height: 1.4;
}

/* First-run onboarding modal (step-by-step, one screen at a time) */
.onboarding-box {
  position: relative;
  max-width: 380px;
  text-align: center;
  padding-top: 40px;
}

.onboarding-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
}

.onboarding-icon {
  font-size: 2.4rem;
  margin-bottom: 8px;
  line-height: 1;
}

.onboarding-title {
  font-size: 1.15rem;
  margin: 0 0 10px;
  color: var(--card-text);
}

.onboarding-text {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 0.92rem;
  margin: 0;
  min-height: 72px;
}

.onboarding-dots {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 20px 0 2px;
}

.onboarding-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--track);
  transition: width 0.15s ease, background 0.15s ease;
}

.onboarding-dot.active {
  width: 18px;
  border-radius: 4px;
  background: var(--primary);
}

.onboarding-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}

.onboarding-footer .secondary {
  padding: 10px 16px;
}

.onboarding-footer .primary {
  flex: 1;
  margin-top: 0;
}

.onboarding-cta-btn {
  font-weight: 700;
}
