/* =========================================
   CSS Variables
   ========================================= */
:root {
  /* Background layers */
  --bg:        #F2EFE9;
  --surface:   #FDFCF8;
  --surface-2: #F7F4EE;

  /* Accent */
  --accent:       #0D9488;
  --accent-light: #CCFBF1;
  --accent-text:  #0F766E;

  /* Text */
  --text:       #2C2825;
  --text-muted: #8A837A;
  --text-dim:   #B5AFA8;

  /* Borders */
  --border:     #E5E0D8;
  --border-2:   #D9D3CA;

  /* Status */
  --success:  #22C55E;
  --warning:  #F59E0B;
  --danger:   #F87171;

  /* Habit colors */
  --hc-teal:    #0D9488;
  --hc-green:   #34d399;
  --hc-lime:    #84cc16;
  --hc-amber:   #f59e0b;
  --hc-orange:  #fb923c;
  --hc-red:     #f87171;
  --hc-pink:    #ec4899;
  --hc-purple:  #e879f9;
  --hc-indigo:  #818cf8;
  --hc-sky:     #38bdf8;
  --hc-slate:   #64748b;

  /* Category tag colors */
  --cat-health:  #34d399;
  --cat-learn:   #818cf8;
  --cat-work:    #38bdf8;
  --cat-finance: #f59e0b;
  --cat-mind:    #e879f9;
  --cat-social:  #fb923c;

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;

  /* Radius */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-full: 9999px;

  /* Shadow */
  --shadow-sm: 0 1px 3px rgba(44,40,37,.08);
  --shadow-md: 0 4px 12px rgba(44,40,37,.10);
  --shadow-lg: 0 8px 24px rgba(44,40,37,.12);

  /* Typography */
  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-zh: 'Noto Sans TC', var(--font);
}

/* =========================================
   Reset & Base
   ========================================= */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: var(--font-zh);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
  outline: none;
}

/* =========================================
   App Shell
   ========================================= */
#app {
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* =========================================
   Top Nav
   ========================================= */
.top-nav {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.nav-icon-btn {
  width: 34px;
  height: 34px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
  transition: background .15s;
}

.nav-icon-btn:hover { background: var(--surface-2); }

/* =========================================
   Tab Bar
   ========================================= */
.tab-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
  flex-shrink: 0;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab-btn {
  flex: 1;
  padding: var(--sp-3) var(--sp-2);
  font-size: .78rem;
  font-weight: 500;
  color: var(--text-muted);
  text-align: center;
  border-bottom: 2px solid transparent;
  white-space: nowrap;
  transition: color .15s, border-color .15s;
  min-width: 0;
}

.tab-btn.active {
  color: var(--accent-text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}

/* =========================================
   Tab Content
   ========================================= */
.tab-content { display: none; flex: 1; overflow-y: auto; }
.tab-content.active { display: block; }

/* =========================================
   Sections & Cards
   ========================================= */
.section {
  padding: var(--sp-4);
}

.section + .section {
  padding-top: 0;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--sp-4);
  box-shadow: var(--shadow-sm);
}

.card + .card { margin-top: var(--sp-3); }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.card-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text);
}

.card-muted {
  font-size: .78rem;
  color: var(--text-muted);
}

/* =========================================
   Section Header
   ========================================= */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-3);
}

.section-title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .04em;
}

/* =========================================
   Habit Item (Today + Manage tabs)
   ========================================= */
.habit-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--sp-3);
}

.habit-item-bar {
  height: 4px;
}

.habit-item-body {
  padding: var(--sp-3) var(--sp-4);
}

.habit-item-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.habit-name {
  flex: 1;
  font-size: .95rem;
  font-weight: 500;
}

.habit-progress-text {
  font-size: .78rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Category tag */
.cat-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-full);
  font-size: .7rem;
  font-weight: 600;
}

.cat-tag[data-cat="health"]  { background: #dcfce7; color: #15803d; }
.cat-tag[data-cat="learn"]   { background: #e0e7ff; color: #4338ca; }
.cat-tag[data-cat="work"]    { background: #e0f2fe; color: #0369a1; }
.cat-tag[data-cat="finance"] { background: #fef3c7; color: #b45309; }
.cat-tag[data-cat="mind"]    { background: #fae8ff; color: #a21caf; }
.cat-tag[data-cat="social"]  { background: #ffedd5; color: #c2410c; }

/* Status badge */
.checkin-badge {
  font-size: .72rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: var(--r-full);
  white-space: nowrap;
  flex-shrink: 0;
}

.badge-done    { background: rgba(251,146,60,.15); color: #C2410C; }
.badge-partial { background: rgba(245,158,11,.12); color: #D97706; }
.badge-todo    { background: rgba(0,0,0,.06);      color: var(--text-muted); }

/* Text check-in button */
.checkin-text-btn {
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-md);
  padding: 9px 20px;
  font-size: .88rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .15s;
}

.checkin-text-btn:hover { background: var(--accent-text); }

/* Check-in button */
.checkin-btn {
  width: 54px;
  height: 54px;
  border-radius: var(--r-full);
  border: 2px solid var(--border-2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  color: var(--text-dim);
  transition: all .15s;
  flex-shrink: 0;
}

.checkin-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-light);
}

.checkin-btn.done {
  background: #FB923C;
  border-color: #FB923C;
  color: #fff;
  font-size: 1.3rem;
  font-weight: 700;
}

/* Check-in log */
.checkin-log {
  border-top: 1px solid var(--border);
  background: var(--surface-2);
}

.checkin-log-toggle {
  width: 100%;
  padding: var(--sp-2) var(--sp-4);
  font-size: .75rem;
  color: var(--text-muted);
  text-align: left;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.checkin-log-toggle:hover { color: var(--text); }

.log-items { padding: var(--sp-2) var(--sp-4) var(--sp-3); }

.log-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-1) 0;
  font-size: .78rem;
}

.log-time { color: var(--text-muted); min-width: 44px; }
.log-note { flex: 1; color: var(--text); }

.log-undo {
  font-size: .7rem;
  color: var(--danger);
  padding: 2px 6px;
  border-radius: var(--r-sm);
}

.log-undo:hover { background: #fee2e2; }

.log-again {
  margin-top: var(--sp-2);
  width: 100%;
  padding: var(--sp-2);
  border-radius: var(--r-md);
  background: var(--accent-light);
  color: var(--accent-text);
  font-size: .8rem;
  font-weight: 600;
  text-align: center;
}

.log-again:hover { background: #99f6e4; }

/* =========================================
   Check-in Modal
   ========================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,40,37,.45);
  z-index: 300;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

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

.modal-sheet {
  background: var(--surface);
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  padding: var(--sp-6) var(--sp-5) var(--sp-8);
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
}

.modal-overlay.open .modal-sheet {
  transform: translateY(0);
}

.modal-handle {
  width: 36px;
  height: 4px;
  background: var(--border-2);
  border-radius: 2px;
  margin: 0 auto var(--sp-5);
}

.modal-title {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--sp-4);
}

.modal-habit-color {
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  display: inline-block;
  margin-right: var(--sp-1);
}

.modal-label {
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: var(--sp-2);
}

.modal-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-3);
  font-size: .9rem;
  color: var(--text);
  resize: none;
}

.modal-input:focus { border-color: var(--accent); }

.modal-actions {
  display: flex;
  gap: var(--sp-3);
  margin-top: var(--sp-5);
}

.btn {
  flex: 1;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  font-size: .9rem;
  font-weight: 600;
  text-align: center;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-text); }

.btn-ghost {
  background: var(--surface-2);
  color: var(--text-muted);
}

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

/* =========================================
   Progress Ring (today tab summary)
   ========================================= */
.today-summary {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-4);
}

.ring-wrap {
  position: relative;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
}

.ring-wrap svg { transform: rotate(-90deg); }

.ring-track { fill: none; stroke: var(--border-2); stroke-width: 5; }
.ring-fill  { fill: none; stroke: var(--accent); stroke-width: 5; stroke-linecap: round; transition: stroke-dashoffset .4s; }

.ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
  color: var(--accent-text);
  line-height: 1.2;
}

.ring-text span { font-size: .6rem; font-weight: 500; color: var(--text-muted); }

.today-meta {
  flex: 1;
}

.today-greeting {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: var(--sp-1);
}

.today-sub {
  font-size: .8rem;
  color: var(--text-muted);
}

/* Streak badge */
.streak-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: #FFF7ED;
  color: #C2410C;
  font-size: .75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: var(--r-full);
  margin-top: var(--sp-2);
}

/* =========================================
   Stats Tab
   ========================================= */
.stats-filters {
  display: flex;
  gap: var(--sp-3);
  padding: var(--sp-4) var(--sp-4) 0;
}

.stats-select {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-2) var(--sp-3);
  font-size: .82rem;
  color: var(--text);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238A837A' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

.stats-select:focus { border-color: var(--accent); }

/* Achievement bars */
.ach-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) 0;
}

.ach-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--r-full);
  flex-shrink: 0;
}

.ach-name {
  font-size: .8rem;
  font-weight: 500;
  width: 80px;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ach-bar-wrap {
  flex: 1;
  height: 8px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
}

.ach-bar-fill {
  height: 100%;
  border-radius: var(--r-full);
  transition: width .4s;
}

.ach-label {
  font-size: .72rem;
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  min-width: 64px;
}

/* Heatmap */
.heatmap-grid {
  display: grid;
  grid-template-columns: repeat(13, 1fr);
  gap: 3px;
}

.heatmap-cell {
  aspect-ratio: 1;
  border-radius: 2px;
  background: var(--surface-2);
}

.heatmap-cell[data-level="1"] { background: #ccfbf1; }
.heatmap-cell[data-level="2"] { background: #5eead4; }
.heatmap-cell[data-level="3"] { background: #0d9488; }

.heatmap-months {
  display: flex;
  justify-content: space-between;
  margin-top: var(--sp-2);
}

.heatmap-month {
  font-size: .65rem;
  color: var(--text-dim);
}

/* Radar chart container */
.radar-wrap {
  display: flex;
  justify-content: center;
  padding: var(--sp-4) 0;
}

/* =========================================
   Line Chart (mini)
   ========================================= */
.line-chart-wrap {
  padding: var(--sp-2) 0;
  position: relative;
}

.line-chart-wrap canvas {
  width: 100%;
  height: 100px;
}

/* =========================================
   AI Coach Tab
   ========================================= */
.ai-chat {
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  padding: var(--sp-4);
}

.ai-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0 var(--r-lg) var(--r-lg) var(--r-lg);
  padding: var(--sp-3) var(--sp-4);
  font-size: .85rem;
  line-height: 1.6;
  max-width: 90%;
  position: relative;
}

.ai-bubble-meta {
  font-size: .7rem;
  color: var(--text-dim);
  margin-bottom: var(--sp-1);
}

.user-bubble {
  background: var(--accent-light);
  border-color: transparent;
  border-radius: var(--r-lg) 0 var(--r-lg) var(--r-lg);
  align-self: flex-end;
  color: var(--accent-text);
}

.ai-input-area {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  gap: var(--sp-2);
}

.ai-input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: var(--sp-2) var(--sp-4);
  font-size: .85rem;
  resize: none;
  max-height: 120px;
}

.ai-input:focus { border-color: var(--accent); }

.ai-send-btn {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  align-self: flex-end;
}

.ai-send-btn:hover { background: var(--accent-text); }

.ai-report-btn {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3) var(--sp-4);
  font-size: .82rem;
  color: var(--accent-text);
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin: var(--sp-4) var(--sp-4) 0;
}

.ai-report-btn:hover { background: var(--accent-light); border-color: var(--accent); }

/* =========================================
   Habit Manage Tab
   ========================================= */
.manage-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4);
}

.manage-title {
  font-size: 1.05rem;
  font-weight: 700;
}

.manage-add-btn {
  width: 32px;
  height: 32px;
  background: var(--accent);
  color: #fff;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 300;
  line-height: 1;
}

.manage-add-btn:hover { background: var(--accent-text); }

/* Manage habit card */
.manage-habit-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin-bottom: var(--sp-3);
}

.manage-habit-bar {
  height: 4px;
}

.manage-habit-body {
  padding: var(--sp-3) var(--sp-4);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.manage-habit-info { flex: 1; }

.manage-habit-name {
  font-size: .92rem;
  font-weight: 600;
  margin-bottom: 3px;
}

.manage-habit-meta {
  font-size: .75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.manage-habit-actions {
  display: flex;
  gap: var(--sp-1);
}

.manage-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: .85rem;
}

.manage-icon-btn:hover { background: var(--surface-2); color: var(--text); }

.manage-icon-btn.danger:hover { background: #fee2e2; color: var(--danger); }

/* Archived section */
.archived-section {
  margin-top: var(--sp-4);
  padding: 0 var(--sp-4);
}

.archived-toggle {
  width: 100%;
  text-align: left;
  font-size: .8rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: var(--sp-2) 0;
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

/* =========================================
   Add / Edit Habit Panel (slide-in from right)
   ========================================= */
.panel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,40,37,.4);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

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

.add-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100vw);
  background: var(--surface);
  z-index: 201;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.panel-overlay.open .add-panel {
  transform: translateX(0);
}

.add-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.add-panel-title {
  font-size: 1rem;
  font-weight: 700;
}

.panel-close-btn {
  width: 30px;
  height: 30px;
  border-radius: var(--r-full);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 1.1rem;
}

.panel-close-btn:hover { background: var(--surface-2); }

.add-panel-body {
  padding: var(--sp-5);
  flex: 1;
}

.form-group {
  margin-bottom: var(--sp-5);
}

.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.form-input {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-size: .9rem;
  color: var(--text);
}

.form-input:focus { border-color: var(--accent); }

.form-select {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-size: .9rem;
  color: var(--text);
  appearance: none;
  cursor: pointer;
}

.form-select:focus { border-color: var(--accent); }

/* Frequency picker */
.freq-row {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.freq-num-input {
  width: 60px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--sp-3);
  font-size: .9rem;
  font-weight: 700;
  text-align: center;
  color: var(--accent-text);
}

.freq-num-input:focus { border-color: var(--accent); }

.freq-unit {
  font-size: .82rem;
  color: var(--text-muted);
}

/* Color swatches */
.color-swatches {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.color-swatch {
  width: 28px;
  height: 28px;
  border-radius: var(--r-full);
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform .1s, border-color .1s;
}

.color-swatch:hover { transform: scale(1.15); }

.color-swatch.selected {
  border-color: var(--text);
  transform: scale(1.1);
}

.add-panel-footer {
  padding: var(--sp-4) var(--sp-5);
  border-top: 1px solid var(--border);
  display: flex;
  gap: var(--sp-3);
}

/* =========================================
   Settings Panel (⚙️)
   ========================================= */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(44,40,37,.4);
  z-index: 400;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}

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

.settings-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(360px, 100vw);
  background: var(--surface);
  z-index: 401;
  transform: translateX(100%);
  transition: transform .25s cubic-bezier(.32,.72,0,1);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.settings-overlay.open .settings-panel {
  transform: translateX(0);
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.settings-header-title {
  font-size: 1rem;
  font-weight: 700;
}

.settings-body {
  padding: var(--sp-5);
  flex: 1;
}

.settings-section-title {
  font-size: .75rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: var(--sp-3);
  margin-top: var(--sp-5);
}

.settings-section-title:first-child { margin-top: 0; }

/* JSON backup */
.backup-actions {
  display: flex;
  gap: var(--sp-3);
}

.backup-btn {
  flex: 1;
  padding: var(--sp-3);
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  font-size: .82rem;
  font-weight: 600;
  color: var(--text-muted);
  background: var(--surface-2);
  text-align: center;
}

.backup-btn:hover { border-color: var(--accent); color: var(--accent-text); }

/* =========================================
   Empty / Onboarding State
   ========================================= */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-8) var(--sp-6);
  text-align: center;
  gap: var(--sp-4);
}

.empty-icon {
  font-size: 3rem;
  opacity: .4;
}

.empty-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

.empty-desc {
  font-size: .85rem;
  color: var(--text-muted);
  line-height: 1.6;
  max-width: 260px;
}

.empty-cta {
  background: var(--accent);
  color: #fff;
  padding: var(--sp-3) var(--sp-6);
  border-radius: var(--r-full);
  font-size: .9rem;
  font-weight: 600;
}

.empty-cta:hover { background: var(--accent-text); }

/* =========================================
   Utilities
   ========================================= */
/* Drag and drop */
[draggable="true"] { cursor: grab; }
[draggable="true"]:active { cursor: grabbing; }

.dragging {
  opacity: .45;
  box-shadow: var(--shadow-lg);
}

.drag-over {
  border-color: var(--accent) !important;
  background: var(--accent-light) !important;
}

.hidden { display: none !important; }

.text-accent { color: var(--accent-text); }
.text-muted  { color: var(--text-muted); }
.font-bold   { font-weight: 700; }
.font-semibold { font-weight: 600; }

.mt-2 { margin-top: var(--sp-2); }
.mt-3 { margin-top: var(--sp-3); }
.mt-4 { margin-top: var(--sp-4); }
