/* ==========================================================================
   TaskFlow Components — Controls, Today View, Tasks, Drawer, Modals & Toasts
   ========================================================================== */

/* --------------------------------------------------------------------------
   Buttons & Keyboard Badges
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1-5);
  height: 36px;
  padding: 0 var(--space-3-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: 500;
  line-height: 1;
  white-space: nowrap;
  border: 1px solid transparent;
  user-select: none;
  flex-shrink: 0;
}

.btn svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

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

.btn-primary {
  background-color: var(--accent);
  color: var(--text-on-accent);
  border-color: var(--accent);
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.14);
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-primary:active:not(:disabled) {
  background-color: var(--accent-active);
}

.btn-secondary {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border-color: var(--border-subtle);
  box-shadow: var(--shadow-xs);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-default);
}

.btn-ghost {
  background-color: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background-color: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.btn-ghost.is-active {
  background-color: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-border);
}

.btn-danger {
  background-color: var(--danger-soft);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.btn-danger:hover:not(:disabled) {
  background-color: var(--danger);
  color: var(--text-on-accent);
  border-color: var(--danger);
}

.btn-danger-ghost:hover:not(:disabled) {
  background-color: var(--danger-soft);
  color: var(--danger-text);
  border-color: var(--danger-border);
}

.btn-sm {
  height: 30px;
  padding: 0 var(--space-2-5);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
}

.btn-xs {
  height: 26px;
  padding: 0 9px;
  border-radius: var(--radius-sm);
  font-size: var(--text-2xs);
}

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
}

.kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-xs);
  background-color: var(--bg-kbd);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 1px 0 var(--border-default);
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-secondary);
  line-height: 1;
}

/* --------------------------------------------------------------------------
   Forms & Select Controls
   -------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.form-label {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-secondary);
  letter-spacing: 0.01em;
}

.form-input,
.form-select,
.form-textarea,
.chip-select,
.sort-select,
.date-picker-input {
  height: 36px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: var(--text-sm);
  box-shadow: var(--shadow-xs);
  min-width: 0;
}

.form-textarea {
  height: auto;
  min-height: 88px;
  padding: var(--space-2-5) var(--space-3);
  resize: vertical;
  line-height: var(--leading-normal);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover,
.chip-select:hover,
.sort-select:hover,
.date-picker-input:hover {
  border-color: var(--border-default);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus,
.chip-select:focus,
.sort-select:focus,
.date-picker-input:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}

.chip-select,
.sort-select,
.date-picker-input {
  height: 30px;
  padding: 0 var(--space-2-5);
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--bg-surface-subtle);
  border-color: transparent;
  box-shadow: none;
  cursor: pointer;
}

.chip-select:hover,
.sort-select:hover,
.date-picker-input:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

/* --------------------------------------------------------------------------
   Today Date Strip
   -------------------------------------------------------------------------- */
.date-strip {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
  overflow-x: auto;
}

.date-strip-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(46px, 1fr));
  gap: var(--space-1-5);
  flex: 1 1 auto;
  min-width: 332px;
}

.date-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  border: 1px solid transparent;
  flex-shrink: 0;
}

.date-nav-btn:hover {
  background-color: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.date-chip {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 6px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  color: var(--text-secondary);
  min-width: 44px;
}

.date-chip:hover {
  background-color: var(--bg-surface-subtle);
  color: var(--text-primary);
}

.date-chip-day {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.date-chip-num {
  font-size: var(--text-sm);
  font-weight: 700;
  line-height: 1.2;
}

.date-chip-dots {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-height: 12px;
}

.date-chip-dot {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background-color: var(--accent);
  opacity: 0.8;
}

.date-chip-dot.is-done {
  background-color: var(--success);
}

.date-chip-count {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  line-height: 1;
}

.date-chip.is-today {
  border-color: var(--accent-border);
  background-color: var(--accent-soft);
}

.date-chip.is-today .date-chip-day,
.date-chip.is-today .date-chip-num {
  color: var(--accent-text);
}

.date-chip.active {
  background-color: var(--accent);
  border-color: var(--accent);
  color: var(--text-on-accent);
  box-shadow: 0 3px 10px var(--accent-glow);
}

.date-chip.active .date-chip-day,
.date-chip.active .date-chip-num,
.date-chip.active .date-chip-count {
  color: var(--text-on-accent);
}

.date-chip.active .date-chip-dot {
  background-color: var(--text-on-accent);
  opacity: 0.95;
}

.date-strip-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  flex-shrink: 0;
}

.date-today-btn {
  color: var(--accent-text);
  border-color: var(--accent-border);
  background-color: var(--accent-soft);
}

.date-today-btn:hover:not(:disabled) {
  background-color: var(--accent-soft-hover);
  border-color: var(--accent);
}

/* --------------------------------------------------------------------------
   Today Progress Hero Banner
   -------------------------------------------------------------------------- */
.progress-hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-5) var(--space-6);
  background:
    radial-gradient(circle at top right, var(--accent-soft), transparent 55%),
    var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.progress-hero-main {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  min-width: 0;
  flex: 1 1 auto;
}

.ring-wrapper {
  position: relative;
  width: 88px;
  height: 88px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-ring-svg {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.progress-ring-track {
  fill: none;
  stroke: var(--chart-track);
  stroke-width: 7;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  transition:
    stroke-dashoffset 0.55s var(--ease-out),
    stroke var(--duration-base) var(--ease-out);
}

.progress-ring-fill.is-complete {
  stroke: var(--success);
}

.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.hero-ring-percent {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: var(--tracking-tight);
  color: var(--text-primary);
  line-height: 1.1;
}

.hero-ring-fraction {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-weight: 500;
}

.hero-summary {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  flex: 1 1 auto;
}

.hero-headline-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.hero-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
}

.hero-insight {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.goal-meter-wrap {
  display: flex;
  flex-direction: column;
  gap: 5px;
  max-width: 380px;
}

.goal-meter-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.goal-meter {
  width: 100%;
  height: 7px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-subtle);
  overflow: hidden;
}

.goal-meter-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--accent), var(--success));
  transition: width 0.5s var(--ease-out);
}

.hero-stats-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(96px, 1fr));
  gap: var(--space-3);
  flex-shrink: 0;
}

.hero-stat {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: var(--space-2-5) var(--space-3);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
}

.hero-stat-label {
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.hero-stat-value {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.hero-stat-sub {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  background-color: var(--warning-soft);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  font-size: var(--text-xs);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Rollover Banner
   -------------------------------------------------------------------------- */
.rollover-banner {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3-5) var(--space-4);
  border-radius: var(--radius-lg);
  background: linear-gradient(135deg, var(--warning-soft), var(--accent-soft));
  border: 1px solid var(--warning-border);
  box-shadow: var(--shadow-xs);
  animation: tf-slide-up var(--duration-fast) var(--ease-out);
}

.rollover-banner-main,
.rollover-banner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.rollover-banner-info {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2-5);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.rollover-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
  flex-shrink: 0;
}

.rollover-sub {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.rollover-banner-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.rollover-review-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
  padding-top: var(--space-2-5);
  border-top: 1px solid var(--warning-border);
}

.rollover-review-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2-5);
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
}

.rollover-review-main {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
  flex: 1 1 auto;
}

.rollover-review-title {
  font-weight: 600;
  color: var(--text-primary);
}

.rollover-review-date {
  color: var(--text-muted);
  font-size: var(--text-2xs);
}

.rollover-review-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
}

/* --------------------------------------------------------------------------
   Quick-Add Card
   -------------------------------------------------------------------------- */
.quick-add-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-2-5);
  padding: var(--space-3-5) var(--space-4);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.quick-add-card:focus-within {
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}

.quick-add-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.quick-add-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  background-color: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: var(--text-md);
  flex-shrink: 0;
}

.quick-add-input {
  flex: 1 1 220px;
  min-width: 0;
  height: 38px;
  padding: 0 var(--space-1-5);
  border: none;
  background: transparent;
  font-size: var(--text-md);
  font-weight: 500;
  color: var(--text-primary);
}

.quick-add-input:focus-visible {
  outline: none;
}

.quick-add-input::placeholder {
  color: var(--text-muted);
  font-weight: 400;
}

.quick-add-submit-group {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  flex-shrink: 0;
}

.quick-add-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1-5);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
}

.quick-add-field {
  display: inline-flex;
  align-items: center;
}

.quick-add-hint {
  margin-left: auto;
  font-size: var(--text-2xs);
  color: var(--text-muted);
}

/* --------------------------------------------------------------------------
   Filter & Sort Toolbar
   -------------------------------------------------------------------------- */
.filter-toolbar {
  display: flex;
  flex-direction: column;
  gap: var(--space-2-5);
}

.filter-toolbar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2-5);
}

.filter-toolbar-right {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.segmented-tabs {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 2px;
  padding: 3px;
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
}

.segmented-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 11px;
  border-radius: calc(var(--radius-md) - 3px);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-secondary);
}

.segmented-tab:hover {
  color: var(--text-primary);
}

.segmented-tab.active {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  font-weight: 600;
  box-shadow: var(--shadow-xs);
}

.tab-count,
.segmented-tab-count {
  font-size: var(--text-2xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.filter-chips {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1-5);
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 var(--space-2-5);
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
}

.filter-chip:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-primary);
  border-color: var(--border-default);
}

.filter-chip.active {
  background-color: var(--accent-soft);
  color: var(--accent-text);
  border-color: var(--accent-border);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Task Groups & Task Cards
   -------------------------------------------------------------------------- */
#task-list-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.task-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.task-group-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0 var(--space-1);
}

.task-group-title {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
}

.task-group-meta,
.task-group-count {
  font-size: var(--text-2xs);
  font-weight: 600;
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-subtle);
  font-variant-numeric: tabular-nums;
}

.task-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.task-card {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: var(--space-2-5);
  padding: var(--space-3) var(--space-3-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-xs);
}

.task-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}

.task-card.is-in-progress {
  border-left: 3px solid var(--info);
}

.task-card.is-focused {
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}

.task-card.is-completed {
  background-color: var(--bg-surface-hover);
  opacity: 0.74;
}

.task-card.is-completed .task-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-card.is-dragging {
  opacity: 0.45;
  transform: scale(0.99);
  border-style: dashed;
}

.task-card.drag-over {
  border-color: var(--accent);
  box-shadow: 0 -2px 0 0 var(--accent), var(--shadow-sm);
}

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 22px;
  margin-top: 1px;
  color: var(--text-faint);
  cursor: grab;
  flex-shrink: 0;
  font-size: 13px;
  letter-spacing: -2px;
  opacity: 0.55;
  user-select: none;
  transition: opacity var(--duration-fast) ease, color var(--duration-fast) ease;
}

.drag-handle:active {
  cursor: grabbing;
}

.task-card:hover .drag-handle,
.task-card:focus-within .drag-handle {
  opacity: 1;
  color: var(--text-muted);
}

/* Custom Animated SVG Task Checkbox */
.task-check-btn {
  position: relative;
  width: 22px;
  height: 22px;
  margin-top: 0;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--border-strong);
  transition:
    color var(--duration-fast) var(--ease-out),
    transform var(--duration-fast) var(--ease-spring);
}

.task-check-svg {
  width: 22px;
  height: 22px;
}

.task-check-circle {
  fill: transparent;
  stroke: var(--border-strong);
  transition:
    fill var(--duration-fast) var(--ease-out),
    stroke var(--duration-fast) var(--ease-out);
}

.task-check-mark {
  opacity: 0;
  stroke: var(--accent);
  stroke-dasharray: 20;
  stroke-dashoffset: 20;
  transition:
    opacity var(--duration-fast) var(--ease-out),
    stroke-dashoffset var(--duration-base) var(--ease-out),
    stroke var(--duration-fast) var(--ease-out);
}

.task-check-btn:hover .task-check-circle {
  stroke: var(--accent);
  fill: var(--accent-soft);
}

.task-check-btn:hover .task-check-mark {
  opacity: 0.45;
  stroke-dashoffset: 0;
}

.task-check-btn:active {
  transform: scale(0.88);
}

.task-card.is-completed .task-check-circle,
.task-check-btn[aria-pressed="true"] .task-check-circle,
.task-check-btn[aria-checked="true"] .task-check-circle {
  fill: var(--success);
  stroke: var(--success);
}

.task-card.is-completed .task-check-mark,
.task-check-btn[aria-pressed="true"] .task-check-mark,
.task-check-btn[aria-checked="true"] .task-check-mark {
  opacity: 1;
  stroke: #ffffff;
  stroke-dashoffset: 0;
}

.task-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.task-title-row {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  min-width: 0;
}

.task-title {
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text-primary);
  line-height: var(--leading-snug);
  word-break: break-word;
  cursor: text;
}

.task-note-indicator {
  display: inline-flex;
  align-items: center;
  color: var(--text-muted);
  flex-shrink: 0;
}

.task-inline-input {
  width: 100%;
  height: 28px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: var(--text-base);
  font-weight: 500;
  box-shadow: var(--shadow-ring);
}

.task-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

/* Badges & Metadata Pills */
.priority-badge,
.category-badge,
.time-badge,
.status-badge,
.subtask-progress {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 8px;
  border-radius: var(--radius-full);
  font-size: var(--text-2xs);
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
}

.priority-badge[data-priority="high"] {
  background-color: var(--danger-soft);
  color: var(--danger-text);
  border: 1px solid var(--danger-border);
}

.priority-badge[data-priority="medium"] {
  background-color: var(--warning-soft);
  color: var(--warning-text);
  border: 1px solid var(--warning-border);
}

.priority-badge[data-priority="low"] {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.category-badge {
  background-color: var(--accent-soft);
  color: var(--accent-text);
}

.category-badge[data-category="work"] {
  background-color: var(--cat-work-soft);
  color: var(--cat-work-text);
}

.category-badge[data-category="health"] {
  background-color: var(--cat-health-soft);
  color: var(--cat-health-text);
}

.category-badge[data-category="learning"] {
  background-color: var(--cat-learning-soft);
  color: var(--cat-learning-text);
}

.category-badge[data-category="personal"] {
  background-color: var(--cat-personal-soft);
  color: var(--cat-personal-text);
}

.category-badge[data-category="admin"] {
  background-color: var(--cat-admin-soft);
  color: var(--cat-admin-text);
}

.time-badge {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-weight: 500;
}

.routine-origin-badge {
  background-color: var(--accent-soft);
  color: var(--accent-text);
}

.status-badge {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.status-badge:hover {
  border-color: var(--border-default);
  color: var(--text-primary);
}

.status-badge[data-status="in_progress"] {
  background-color: var(--info-soft);
  color: var(--info-text);
  border-color: var(--info-border);
}

.status-badge[data-status="done"] {
  background-color: var(--success-soft);
  color: var(--success-text);
  border-color: var(--success-border);
}

.subtask-progress {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  gap: 6px;
}

.subtask-progress-bar,
.subtask-mini-bar {
  width: 28px;
  height: 4px;
  border-radius: var(--radius-full);
  background-color: var(--border-subtle);
  overflow: hidden;
  display: inline-block;
}

.subtask-progress-fill,
.subtask-mini-fill {
  display: block;
  height: 100%;
  background-color: var(--accent);
  border-radius: var(--radius-full);
}

/* Task Actions (hover-revealed on desktop pointer, always accessible on focus/touch) */
.task-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-left: auto;
}

@media (hover: hover) and (pointer: fine) {
  .task-actions {
    opacity: 0;
    transition: opacity var(--duration-fast) var(--ease-out);
  }

  .task-card:hover .task-actions,
  .task-card:focus-within .task-actions,
  .task-card.is-focused .task-actions {
    opacity: 1;
  }
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: var(--space-2-5);
  padding: var(--space-10) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--border-default);
  background-color: var(--bg-surface);
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-full);
  background-color: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
}

.empty-state-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state-desc,
.empty-state-text {
  max-width: 390px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.empty-state-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

/* --------------------------------------------------------------------------
   Daily Check-in Card
   -------------------------------------------------------------------------- */
.checkin-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.checkin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2-5);
}

.checkin-title {
  font-size: var(--text-md);
  font-weight: 700;
  color: var(--text-primary);
}

.checkin-subtitle {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.checkin-saved-status {
  color: var(--success-text);
  font-weight: 500;
}

.mood-emoji {
  font-size: 14px;
  line-height: 1;
}

.mood-label {
  line-height: 1;
}

.checkin-routines-done {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  background-color: var(--success-soft);
  color: var(--success-text);
  font-size: var(--text-xs);
  font-weight: 600;
}

.checkin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.checkin-reflection-group {
  grid-column: 1 / -1;
}

.mood-selector {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1-5);
}

.mood-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: 500;
  transition:
    background-color var(--duration-fast) ease,
    border-color var(--duration-fast) ease,
    color var(--duration-fast) ease,
    transform var(--duration-fast) ease;
}

.mood-btn:hover {
  background-color: var(--bg-surface-hover);
  border-color: var(--border-default);
  color: var(--text-primary);
}

.mood-btn.active {
  background-color: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-text);
  font-weight: 600;
  box-shadow: 0 0 0 2px var(--accent-glow);
}

.checkin-textarea {
  width: 100%;
  min-height: 82px;
  padding: var(--space-2-5) var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background-color: var(--bg-input);
  color: var(--text-primary);
  font-size: var(--text-sm);
  resize: vertical;
}

.checkin-textarea:focus {
  border-color: var(--accent);
  box-shadow: var(--shadow-ring);
}

/* --------------------------------------------------------------------------
   Upcoming View
   -------------------------------------------------------------------------- */
.upcoming-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.upcoming-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 3px;
}

.upcoming-overdue-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--warning-border);
  background: linear-gradient(180deg, var(--warning-soft) 0%, var(--bg-surface) 95px);
  box-shadow: var(--shadow-xs);
}

.upcoming-overdue-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.upcoming-overdue-header p {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  margin-top: 2px;
}

.upcoming-overdue-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
}

.upcoming-overdue-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
}

.upcoming-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-4);
  align-items: start;
}

.upcoming-day-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.upcoming-day-card.is-today {
  border-color: var(--accent-border);
  box-shadow: var(--shadow-sm);
}

.upcoming-day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}

.upcoming-day-title-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  font-weight: 700;
  color: var(--text-primary);
}

.upcoming-day-title-btn:hover {
  color: var(--accent-text);
}

.upcoming-day-badge {
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-subtle);
  font-size: var(--text-xs);
  font-weight: 700;
}

.upcoming-day-card.is-today .upcoming-day-badge {
  background-color: var(--accent-soft);
  color: var(--accent-text);
}

.upcoming-day-date {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
}

.upcoming-day-meta,
.upcoming-day-count {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.upcoming-day-tasks {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
}

.upcoming-task-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-subtle);
  border: 1px solid transparent;
}

.upcoming-task-row:hover {
  border-color: var(--border-subtle);
  background-color: var(--bg-surface-hover);
}

.upcoming-task-row.is-completed .upcoming-task-link {
  text-decoration: line-through;
  color: var(--text-muted);
}

.upcoming-task-link {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upcoming-task-link:hover {
  color: var(--accent-text);
}

.upcoming-empty {
  padding: var(--space-3) 0;
  text-align: center;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.upcoming-add-input {
  height: 32px;
  font-size: var(--text-xs);
  background-color: var(--bg-surface-subtle);
}

/* --------------------------------------------------------------------------
   Routines View
   -------------------------------------------------------------------------- */
.routines-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.routines-subtitle {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin-top: 3px;
}

.routines-header-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.routine-form-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  animation: tf-slide-up var(--duration-fast) var(--ease-out);
}

.routine-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.routine-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.routine-form-span2 {
  grid-column: 1 / -1;
}

.routine-form-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.routine-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--space-4);
}

.routine-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}

.routine-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}

.routine-card.is-paused,
.routine-card.is-inactive {
  opacity: 0.68;
}

.routine-card-top,
.routine-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.routine-card-heading {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-width: 0;
}

.routine-title {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
}

.routine-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.routine-subtask-preview {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: var(--space-2-5) var(--space-3);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-subtle);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.routine-subtask-preview li {
  position: relative;
  padding-left: 14px;
}

.routine-subtask-preview li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 7px;
  width: 5px;
  height: 5px;
  border-radius: var(--radius-full);
  background-color: var(--accent);
  opacity: 0.7;
}

.routine-subtask-more {
  color: var(--text-muted);
  font-style: italic;
}

.routine-card-footer {
  margin-top: auto;
  padding-top: var(--space-2-5);
  border-top: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.routine-sync-status {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: 500;
}

.routine-card-actions {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.routine-streak {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background-color: var(--warning-soft);
  color: var(--warning-text);
  font-size: var(--text-2xs);
  font-weight: 700;
}

/* Toggle Switch — supports both <label class="toggle-switch"><input><span class="toggle-slider"></span></label>
   and standalone <input class="toggle-switch" type="checkbox"> */
label.toggle-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
  cursor: pointer;
}

label.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  border-radius: var(--radius-full);
  background-color: var(--border-default);
  transition: background-color var(--duration-fast) var(--ease-out);
}

.toggle-slider::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform var(--duration-fast) var(--ease-out);
}

label.toggle-switch input:checked + .toggle-slider {
  background-color: var(--accent);
}

label.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

label.toggle-switch input:focus-visible + .toggle-slider {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input.toggle-switch[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  border-radius: var(--radius-full);
  background-color: var(--border-default);
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color var(--duration-fast) var(--ease-out);
}

input.toggle-switch[type="checkbox"]::before {
  content: "";
  position: absolute;
  left: 2px;
  top: 2px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-full);
  background-color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
  transition: transform var(--duration-fast) var(--ease-out);
}

input.toggle-switch[type="checkbox"]:checked {
  background-color: var(--accent);
}

input.toggle-switch[type="checkbox"]:checked::before {
  transform: translateX(18px);
}

/* --------------------------------------------------------------------------
   Task Detail Slide-Over Drawer
   -------------------------------------------------------------------------- */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background-color: var(--bg-overlay);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: var(--z-backdrop);
  animation: tf-fade-in var(--duration-fast) var(--ease-out);
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--drawer-width);
  max-width: 100vw;
  background-color: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-xl);
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  visibility: hidden;
  transition:
    transform var(--duration-base) var(--ease-out),
    visibility var(--duration-base) var(--ease-out);
}

.drawer.open {
  transform: translateX(0);
  visibility: visible;
}

.drawer-inner {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.drawer-header-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.drawer-date-tag {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--text-muted);
}

.drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.drawer-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.drawer-presets {
  flex-direction: row;
  flex-wrap: wrap;
  gap: var(--space-1-5);
}

.drawer-subtasks-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.subtask-pct {
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.subtask-bar-track {
  width: 100%;
  height: 5px;
  border-radius: var(--radius-full);
  background-color: var(--bg-surface-subtle);
  overflow: hidden;
}

.subtask-bar-fill {
  height: 100%;
  border-radius: var(--radius-full);
  background-color: var(--accent);
  transition: width var(--duration-base) var(--ease-out);
}

.drawer-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-3-5) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-subtle);
  flex-shrink: 0;
}

.subtask-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
}

.subtask-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-subtle);
  border: 1px solid transparent;
  font-size: var(--text-sm);
}

.subtask-item:hover {
  border-color: var(--border-subtle);
}

.subtask-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex: 1 1 auto;
  min-width: 0;
  cursor: pointer;
}

.subtask-checkbox {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
  flex-shrink: 0;
}

.subtask-item.done .subtask-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.subtask-title {
  flex: 1 1 auto;
  min-width: 0;
  word-break: break-word;
}

.subtask-empty {
  padding: var(--space-2-5);
  font-size: var(--text-xs);
  color: var(--text-muted);
  text-align: center;
  border-radius: var(--radius-sm);
  background-color: var(--bg-surface-subtle);
}

.subtask-add-form {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
}

.subtask-add-form .form-input {
  flex: 1 1 auto;
  height: 32px;
  font-size: var(--text-xs);
}

/* --------------------------------------------------------------------------
   Modals, Settings & Command Palette
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 9vh var(--space-4) var(--space-4);
  background-color: var(--bg-overlay);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  animation: tf-fade-in var(--duration-fast) var(--ease-out);
}

.modal-dialog {
  width: 100%;
  max-width: 560px;
  max-height: 82vh;
  background-color: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: tf-pop var(--duration-fast) var(--ease-out);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
}

.modal-title {
  font-size: var(--text-md);
  font-weight: 700;
}

.modal-close-btn {
  color: var(--text-muted);
}

.settings-dialog {
  max-width: 540px;
}

.shortcuts-dialog {
  max-width: 580px;
}

.modal-body {
  padding: var(--space-5);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-3-5) var(--space-5);
  border-top: 1px solid var(--border-subtle);
  background-color: var(--bg-surface-subtle);
}

/* Settings Modal Internals */
.settings-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.settings-grid-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3);
}

.settings-toggles {
  display: flex;
  flex-direction: column;
  gap: var(--space-2-5);
}

.setting-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background-color: var(--bg-surface-subtle);
  border: 1px solid var(--border-subtle);
  cursor: pointer;
}

.setting-toggle-title {
  display: block;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--text-primary);
}

.setting-toggle-desc {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: 2px;
}

.settings-divider {
  height: 1px;
  background-color: var(--border-subtle);
}

.settings-data-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.settings-section-title {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: var(--tracking-wide);
  color: var(--text-muted);
}

.settings-data-actions,
.settings-danger-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Command Palette */
.command-palette {
  max-width: 600px;
}

.command-header {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border-subtle);
}

.command-search-icon {
  color: var(--text-muted);
  flex-shrink: 0;
}

.command-input {
  width: 100%;
  height: 52px;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-size: var(--text-md);
}

.command-input:focus-visible {
  outline: none;
}

.command-list {
  max-height: 360px;
  overflow-y: auto;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.command-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  text-align: left;
}

.command-item-main {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  min-width: 0;
  flex: 1 1 auto;
}

.command-item-group {
  display: inline-flex;
  align-items: center;
  padding: 2px 7px;
  border-radius: var(--radius-xs);
  background-color: var(--bg-surface-subtle);
  color: var(--text-muted);
  font-size: var(--text-2xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  flex-shrink: 0;
}

.command-item-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-primary);
  font-weight: 500;
}

.command-empty {
  padding: var(--space-6) var(--space-4);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.command-item:hover,
.command-item.active {
  background-color: var(--accent-soft);
  color: var(--accent-text);
}

.command-item.active .command-item-group,
.command-item:hover .command-item-group {
  background-color: var(--accent-soft-hover);
  color: var(--accent-text);
}

.command-item.active .command-item-title,
.command-item:hover .command-item-title {
  color: var(--accent-text);
}

.shortcut-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2-5) var(--space-5);
}

.shortcut-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-1-5) 0;
  border-bottom: 1px solid var(--border-subtle);
  font-size: var(--text-xs);
  color: var(--text-secondary);
}

.shortcut-keys {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Toasts
   -------------------------------------------------------------------------- */
#toast-container,
.toast-container {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2-5);
  max-width: min(420px, calc(100vw - 24px));
  padding: var(--space-2-5) var(--space-3-5);
  border-radius: var(--radius-md);
  background-color: var(--text-primary);
  color: var(--bg-surface);
  box-shadow: var(--shadow-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  animation: tf-slide-up var(--duration-fast) var(--ease-out);
  transition: opacity 200ms ease, transform 200ms ease;
}

[data-theme="dark"] .toast {
  background-color: #1e293b;
  color: #f8fafc;
  border: 1px solid var(--border-default);
}

.toast-success {
  border-left: 3px solid var(--success);
}

.toast-error {
  border-left: 3px solid var(--danger);
}

.toast-info {
  border-left: 3px solid var(--accent);
}

.toast.is-leaving {
  opacity: 0;
  transform: translateY(6px);
}

.toast-message {
  flex: 1 1 auto;
  min-width: 0;
}

.toast-close-btn {
  width: 24px !important;
  height: 24px !important;
  font-size: 16px;
  line-height: 1;
  color: inherit;
  opacity: 0.72;
}

.toast-close-btn:hover {
  opacity: 1;
  background-color: rgba(255, 255, 255, 0.12) !important;
  color: inherit !important;
}

.toast-undo-btn {
  padding: 4px 10px;
  border-radius: var(--radius-sm);
  background-color: rgba(255, 255, 255, 0.14);
  color: #a5b4fc;
  font-size: var(--text-xs);
  font-weight: 600;
  white-space: nowrap;
}

.toast-undo-btn:hover {
  background-color: rgba(255, 255, 255, 0.24);
}

/* --------------------------------------------------------------------------
   Component Responsive Adjustments
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
  .progress-hero {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-4);
    padding: var(--space-4);
  }

  .hero-stats-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .progress-hero-main {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-3);
  }

  .hero-stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .checkin-grid,
  .form-row,
  .drawer-grid-2,
  .routine-form-grid,
  .settings-grid-two,
  .shortcut-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .upcoming-grid,
  .routine-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .quick-add-hint {
    margin-left: 0;
  }

  .task-card {
    flex-wrap: wrap;
    padding: var(--space-3);
  }

  .task-actions {
    width: 100%;
    justify-content: flex-end;
    padding-top: var(--space-1-5);
    border-top: 1px solid var(--border-subtle);
  }

  .modal-backdrop {
    padding: var(--space-4) var(--space-3);
    align-items: center;
  }

  #toast-container,
  .toast-container {
    left: var(--space-3);
    right: var(--space-3);
    bottom: var(--space-3);
    align-items: stretch;
  }

  .toast {
    width: 100%;
    max-width: 100%;
    justify-content: space-between;
  }
}
