/* ===================================================================
   Tracking Buddy — components.css
   All shared UI components
   =================================================================== */

/* ============== HEADER ============== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(to bottom, var(--bg-primary) 60%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.app-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 600;
  font-size: 1.3rem;
  color: var(--text-primary);
}

.app-title-mascot {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  overflow: hidden;
  flex-shrink: 0;
}

.app-title-mascot img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* ============== DASHBOARD SWITCHER ============== */
.dashboard-switcher {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  padding: 6px 8px 6px 14px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--border);
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s;
  max-width: 200px;
}

.dashboard-switcher:hover, .dashboard-switcher:active {
  border-color: var(--accent);
  transform: translateY(-1px);
}

.dashboard-switcher-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dashboard-switcher-chevron {
  width: 24px;
  height: 24px;
  background: var(--accent-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-weight: 700;
  font-size: 0.75rem;
  flex-shrink: 0;
}

/* ============== BUTTONS ============== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.95rem;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  user-select: none;
  min-height: 44px;
}

.btn:active { transform: scale(0.96); }

.btn-primary {
  background: var(--accent);
  color: var(--text-inverse);
  box-shadow: 0 4px 0 var(--accent-hover);
}
.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:active { box-shadow: 0 2px 0 var(--accent-hover); transform: translateY(2px) scale(0.98); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-primary);
  border: 2px solid var(--border-strong);
}
.btn-secondary:hover { background: var(--surface-alt); }

.btn-danger {
  background: var(--danger);
  color: var(--text-inverse);
  box-shadow: 0 4px 0 #B83A30;
}
.btn-danger:active { box-shadow: 0 2px 0 #B83A30; transform: translateY(2px) scale(0.98); }

.btn-ghost {
  color: var(--text-secondary);
  padding: 10px 14px;
}
.btn-ghost:hover { background: var(--surface-alt); }

.btn-icon {
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  font-size: 1.2rem;
  flex-shrink: 0;
}
.btn-icon:hover { background: var(--surface-alt); border-color: var(--accent); }

.btn-full { width: 100%; }

/* ============== DASHBOARD GRID ============== */
.dashboard {
  flex: 1;
  padding: 4px 16px 120px;
  position: relative;
}

.dashboard-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
  min-height: 60vh;
  animation: slideUp 0.5s ease-out;
}

.dashboard-empty-mascot {
  width: 140px;
  height: 140px;
  margin-bottom: 20px;
  background: var(--accent-soft);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 70px;
  overflow: hidden;
  animation: pulse 3s ease-in-out infinite;
}
.dashboard-empty-mascot img { width: 100%; height: 100%; object-fit: cover; }

.dashboard-empty h2 { margin-bottom: 8px; }
.dashboard-empty p { margin-bottom: 24px; max-width: 280px; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--grid-gap);
  margin-top: 8px;
}

@media (min-width: 480px) {
  .tile-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (min-width: 720px) {
  .tile-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (min-width: 1024px) {
  .tile-grid { grid-template-columns: repeat(5, 1fr); }
}
@media (min-width: 1280px) {
  .tile-grid { grid-template-columns: repeat(6, 1fr); }
}

/* ============== TILE ============== */
.tile {
  position: relative;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-soft);
  border: 2px solid transparent;
  display: flex;
  flex-direction: column;
  min-height: var(--tile-min-size);
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.2s, border-color 0.2s;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  animation: popIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.tile:active { transform: scale(0.97); }
.tile:hover { box-shadow: var(--shadow); }

/* Shape variants */
.tile.shape-wide { grid-column: span 2; }
.tile.shape-tall { grid-row: span 2; }
.tile.shape-large { grid-column: span 2; grid-row: span 2; }

/* Tile size: small reduces internal padding & font */
.tile.size-sm { padding: 10px; }
.tile.size-sm .tile-icon { font-size: 28px; width: 40px; height: 40px; }
.tile.size-sm .tile-metric-value { font-size: 1rem; }

/* Tile face content */
.tile-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.tile-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  flex-shrink: 0;
  overflow: hidden;
  position: relative;
}

.tile-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.tile-icon-emoji {
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.08));
}

.tile-name {
  font-weight: 700;
  font-size: 0.9rem;
  line-height: 1.2;
  color: var(--text-primary);
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  flex: 1;
}

.tile-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 2px;
}

.tile-metric {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.tile-metric-value {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.tile-metric-value.live {
  color: var(--accent);
}

.tile-metric-label {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 600;
}

.tile.shape-large .tile-metric-value,
.tile.shape-wide .tile-metric-value { font-size: 1.5rem; }
.tile.shape-tall .tile-body { gap: 8px; }

/* Quick log button */
.tile-quick-log {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 600;
  box-shadow: 0 3px 0 var(--accent-hover), 0 4px 12px rgba(0,0,0,0.12);
  transition: transform 0.12s, box-shadow 0.15s;
  z-index: 2;
}

.tile-quick-log:active {
  transform: translateY(2px) scale(0.95);
  box-shadow: 0 1px 0 var(--accent-hover), 0 2px 6px rgba(0,0,0,0.12);
}

.tile-quick-log.quit-mode { background: var(--success); box-shadow: 0 3px 0 #3FA037, 0 4px 12px rgba(0,0,0,0.12); }

/* Floating +1 animation */
.tile-floating-feedback {
  position: absolute;
  bottom: 50px;
  right: 26px;
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--success);
  pointer-events: none;
  animation: floatUp 1.2s ease-out forwards;
  text-shadow: 0 1px 2px rgba(255,255,255,0.8);
  z-index: 3;
}

/* Tile type indicators */
.tile-type-badge {
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.tile.paused .tile-icon { opacity: 0.5; }
.tile.paused::after {
  content: 'PAUSED';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-15deg);
  font-family: 'Fredoka', sans-serif;
  font-weight: 700;
  font-size: 1rem;
  color: var(--warning);
  background: var(--surface);
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  border: 2px solid var(--warning);
  pointer-events: none;
}

/* System tile (Tracking Buddy meta-tile) */
.tile.system {
  background: linear-gradient(135deg, var(--accent-soft), var(--secondary-soft));
  border: 2px solid var(--accent);
}

/* Edit mode */
.dashboard.edit-mode .tile {
  animation: wiggle 0.4s ease-in-out infinite;
  animation-delay: calc(var(--tile-i, 0) * 0.05s);
}

.dashboard.edit-mode .tile-quick-log {
  display: none;
}

.tile-edit-handle {
  display: none;
}

.dashboard.edit-mode .tile-edit-handle {
  display: flex;
  position: absolute;
  top: -8px;
  left: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--danger);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  align-items: center;
  justify-content: center;
  z-index: 4;
  box-shadow: 0 2px 6px rgba(0,0,0,0.2);
  animation: popIn 0.3s ease-out;
}

.tile.dragging {
  opacity: 0.4;
  animation: none !important;
  z-index: 100;
}

.tile.drop-target {
  outline: 3px dashed var(--accent);
  outline-offset: 2px;
}

/* Add tile button (floating) */
.fab-add {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-inverse);
  font-size: 1.8rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 5px 0 var(--accent-hover), 0 8px 20px rgba(0,0,0,0.18);
  transition: transform 0.15s, box-shadow 0.2s;
  z-index: 40;
}

.fab-add:active {
  transform: translateY(3px) scale(0.97);
  box-shadow: 0 2px 0 var(--accent-hover), 0 4px 10px rgba(0,0,0,0.18);
}

.fab-add.edit-mode-active {
  background: var(--success);
  box-shadow: 0 5px 0 #3FA037, 0 8px 20px rgba(0,0,0,0.18);
}

/* ============== MODAL ============== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--bg-overlay);
  z-index: 100;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: fadeIn 0.25s ease-out;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-elevated);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: slideUp 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
  box-shadow: 0 -10px 40px rgba(0,0,0,0.2);
}

@media (min-width: 720px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { border-radius: var(--radius-xl); max-height: 86vh; }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 { font-size: 1.2rem; }

.modal-close {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-alt);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  color: var(--text-secondary);
  font-weight: 600;
  transition: background 0.2s;
}
.modal-close:hover { background: var(--border); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  display: flex;
  gap: 10px;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.modal-footer .btn { flex: 1; }

/* Drag handle for mobile sheet feel */
.modal-grip {
  width: 40px;
  height: 4px;
  background: var(--border-strong);
  border-radius: 4px;
  margin: 8px auto 0;
  flex-shrink: 0;
}

@media (min-width: 720px) {
  .modal-grip { display: none; }
}

/* ============== FORM FIELDS ============== */
.field {
  margin-bottom: 16px;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

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

/* Segmented control / pill choices */
.pill-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 2px solid var(--border);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.pill:hover { border-color: var(--accent); }

.pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--text-inverse);
}

/* Type cards (quit/build/observe/neutral) */
.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.type-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
}

.type-card:hover, .type-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}

.type-card-emoji { font-size: 1.8rem; margin-bottom: 4px; }
.type-card-title { font-weight: 700; font-size: 0.9rem; }
.type-card-desc { font-size: 0.75rem; color: var(--text-secondary); margin-top: 2px; }

/* Icon picker grid */
.icon-search {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  padding-bottom: 12px;
  z-index: 2;
}

.icon-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}

@media (min-width: 480px) {
  .icon-grid { grid-template-columns: repeat(6, 1fr); }
}

.icon-option {
  aspect-ratio: 1;
  background: var(--surface-alt);
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.8rem;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
  position: relative;
}

.icon-option:hover { border-color: var(--accent); transform: scale(1.05); }
.icon-option.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: scale(1.05);
}

.icon-option img { width: 70%; height: 70%; object-fit: cover; border-radius: 8px; }

.icon-upload-btn {
  aspect-ratio: 1;
  background: var(--surface-alt);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  color: var(--text-secondary);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  padding: 4px;
  gap: 2px;
}

.icon-upload-btn:hover { border-color: var(--accent); color: var(--accent); }
.icon-upload-icon { font-size: 1.4rem; }

/* Metric toggles */
.metric-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.metric-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.15s;
  border: 2px solid transparent;
}

.metric-toggle:hover { background: var(--accent-soft); }
.metric-toggle.active { background: var(--accent-soft); border-color: var(--accent); }

.metric-toggle-label {
  font-weight: 600;
  font-size: 0.9rem;
}

.metric-toggle-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.metric-toggle-info { flex: 1; min-width: 0; padding-right: 12px; }

.face-star {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: all 0.15s;
}

.metric-toggle.on-face .face-star {
  background: var(--warning);
  border-color: var(--warning);
  color: white;
}

/* Preset grid */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.preset-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 12px;
  cursor: pointer;
  text-align: center;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.preset-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.preset-icon {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  overflow: hidden;
}
.preset-icon img { width: 100%; height: 100%; object-fit: cover; }

.preset-name { font-weight: 700; font-size: 0.85rem; line-height: 1.2; }
.preset-type { font-size: 0.7rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Detail modal metric display */
.detail-hero {
  background: linear-gradient(135deg, var(--accent-soft), var(--secondary-soft));
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
  margin-bottom: 20px;
}

.detail-hero-icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 42px;
  margin: 0 auto 12px;
  overflow: hidden;
}

.detail-hero-icon img { width: 100%; height: 100%; object-fit: cover; }

.detail-hero-name {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
}

.detail-hero-type {
  font-size: 0.75rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 700;
  margin-top: 4px;
}

.detail-metrics {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.detail-metric {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 12px;
}

.detail-metric-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-weight: 700;
  margin-bottom: 4px;
}

.detail-metric-value {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.4rem;
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.detail-actions .btn { flex: 1; min-width: 110px; font-size: 0.85rem; padding: 10px 12px; }

.detail-section { margin-bottom: 20px; }
.detail-section-title {
  font-weight: 700;
  font-size: 0.95rem;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 8px;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px;
  background: var(--surface);
  border-radius: 10px;
  font-size: 0.85rem;
}

.history-item-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  text-transform: uppercase;
}

.history-item-tag.log { background: var(--success-soft); color: var(--success); }
.history-item-tag.lapse { background: var(--danger-soft); color: var(--danger); }

.history-delete {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}
.history-delete:hover { color: var(--danger); background: var(--danger-soft); }

.history-empty {
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.85rem;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: 100%;
  max-width: 360px;
  padding: 0 16px;
}

.toast {
  background: var(--text-primary);
  color: var(--text-inverse);
  padding: 12px 18px;
  border-radius: var(--radius-pill);
  font-weight: 600;
  font-size: 0.9rem;
  box-shadow: 0 6px 20px rgba(0,0,0,0.25);
  animation: popIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
}

.toast.success { background: var(--success); }
.toast.danger { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text-primary); }

/* Confetti container */
.confetti-piece {
  position: fixed;
  top: -10px;
  width: 10px;
  height: 14px;
  z-index: 999;
  pointer-events: none;
  animation: confetti 2.5s ease-in forwards;
}

/* Settings list */
.settings-list { display: flex; flex-direction: column; gap: 4px; }
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  gap: 12px;
}

.settings-item-info { flex: 1; min-width: 0; }
.settings-item-label { font-weight: 700; font-size: 0.95rem; }
.settings-item-desc { font-size: 0.78rem; color: var(--text-muted); margin-top: 2px; }

/* Theme picker */
.theme-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.theme-card {
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  border: 3px solid transparent;
  position: relative;
  text-align: left;
  transition: transform 0.15s;
}

.theme-card:active { transform: scale(0.97); }
.theme-card.active { border-color: var(--accent); }
.theme-card.active::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

.theme-card-name { font-weight: 700; font-size: 0.95rem; margin-bottom: 4px; }
.theme-card-desc { font-size: 0.75rem; opacity: 0.8; }
.theme-card-swatches { display: flex; gap: 4px; margin-top: 8px; }
.theme-swatch { width: 18px; height: 18px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.5); }

/* Dashboard picker / settings-style list */
.dashboard-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}

.dashboard-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 2px solid transparent;
}

.dashboard-list-item.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.dashboard-list-item-name { font-weight: 700; flex: 1; }
.dashboard-list-item-count { font-size: 0.78rem; color: var(--text-muted); }
.dashboard-list-actions { display: flex; gap: 4px; }

.icon-btn-sm {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.icon-btn-sm:hover { color: var(--accent); background: var(--accent-soft); }

/* Wizard / onboarding */
.wizard-step { animation: slideUp 0.3s ease-out; }
.wizard-progress {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  justify-content: center;
}
.wizard-dot {
  width: 28px;
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  transition: background 0.3s;
}
.wizard-dot.active { background: var(--accent); }
.wizard-dot.complete { background: var(--success); }

.wizard-mascot {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  font-size: 50px;
  overflow: hidden;
}
.wizard-mascot img { width: 100%; height: 100%; object-fit: cover; }

.wizard-title { text-align: center; margin-bottom: 8px; }
.wizard-subtitle { text-align: center; color: var(--text-secondary); margin-bottom: 24px; }

/* Version display in settings */
.version-tag {
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-top: 16px;
  padding: 8px;
  font-weight: 600;
}

/* Edit mode hint banner */
.edit-banner {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent);
  color: white;
  padding: 8px 16px;
  border-radius: var(--radius-pill);
  font-weight: 700;
  font-size: 0.85rem;
  z-index: 45;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  animation: popIn 0.3s ease-out;
}

/* ===================================================================
   v0.002 additions: 2-col tile body, earn type, attempts, audit, drag
   =================================================================== */

/* Two-column tile body for wide/large with many metrics */
.tile-body.tile-body-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.tile-body.tile-body-2col .tile-metric {
  min-width: 0;
}
.tile-body.tile-body-2col .tile-metric-value {
  font-size: 1.15rem;
  line-height: 1.15;
}
.tile-body.tile-body-2col .tile-metric-label {
  font-size: 0.62rem;
}

/* Earn tile type */
.tile.type-earn {
  border-color: #FFB627;
}
.tile-quick-log.earn-mode {
  background: #FFB627;
  box-shadow: 0 3px 0 #D89400, 0 4px 12px rgba(0,0,0,0.12);
  font-size: 1.6rem;
  font-weight: 800;
}

/* Attempts history */
.attempts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}
.attempt-item {
  display: flex;
  gap: 12px;
  align-items: center;
  background: var(--surface-alt, #FAFAF5);
  padding: 10px 12px;
  border-radius: var(--radius-md, 10px);
  border: 1px solid var(--border, #E8E5D8);
}
.attempt-num {
  font-weight: 800;
  color: var(--text-muted);
  font-size: 0.85rem;
  min-width: 28px;
}
.attempt-info { flex: 1; min-width: 0; }
.attempt-dur {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.attempt-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.attempt-current { color: var(--success, #4CB944); font-weight: 700; }
.attempt-lapse { color: var(--danger, #E5484D); }
.attempt-manual { color: var(--text-muted); }

/* Audit log */
.detail-collapsible {
  margin-top: 16px;
  border-top: 1px solid var(--border, #E8E5D8);
  padding-top: 16px;
}
.detail-collapsible > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.detail-collapsible > summary::-webkit-details-marker { display: none; }
.detail-collapsible > summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 0.15s;
  font-size: 0.8em;
}
.detail-collapsible[open] > summary::before {
  transform: rotate(90deg);
}
.audit-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
  font-size: 0.85rem;
}
.audit-item {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  background: var(--surface-alt, #FAFAF5);
  border-radius: var(--radius-sm, 6px);
  align-items: baseline;
}
.audit-time {
  color: var(--text-muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  min-width: 80px;
}
.audit-note {
  color: var(--text);
  flex: 1;
}

/* Drag placeholder */
.tile-placeholder {
  border-radius: var(--radius-lg, 16px);
  background: transparent;
  outline: 3px dashed var(--accent, #5BA856);
  outline-offset: -3px;
  opacity: 0.55;
}
.tile.dragging {
  opacity: 0.95;
  box-shadow: 0 12px 32px rgba(0,0,0,0.22), 0 0 0 2px var(--accent, #5BA856);
}

/* Edit mode wiggle so users know they can drag */
.dashboard.edit-mode .tile:not(.system):not(.dragging) {
  animation: tile-wiggle 0.4s ease-in-out infinite alternate;
  animation-delay: calc(var(--tile-i, 0) * 0.05s);
}
@keyframes tile-wiggle {
  from { transform: rotate(-0.6deg); }
  to   { transform: rotate(0.6deg); }
}

/* Ghost button used for "or enter bundle pricing" disclosure */
.btn-ghost {
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  text-decoration: underline;
}
.btn-ghost:hover { opacity: 0.8; }

/* ===================================================================
   v0.003 additions: rearrange button, mascot placements, timeline
   =================================================================== */

/* Active state for rearrange button when in edit mode */
#rearrange-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 168, 86, 0.25);
}

/* Larger, clearer edit banner with instructions */
.edit-banner {
  display: flex;
  align-items: center;
  gap: 10px;
}
.edit-banner-mascot {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: white;
  flex-shrink: 0;
}
.edit-banner-mascot img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Mascot used as a flag badge on goal-hit tiles */
.tile-goal-flag {
  position: absolute;
  top: 8px;
  right: 38px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--success, #4CB944);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.tile-goal-flag img {
  width: 18px;
  height: 18px;
  object-fit: contain;
}

/* Sleeping mascot indicator on inactive tiles */
.tile-sleep-indicator {
  position: absolute;
  top: 8px;
  right: 38px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(255,255,255,0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 3;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  opacity: 0.85;
}
.tile-sleep-indicator img {
  width: 22px;
  height: 22px;
  object-fit: cover;
  border-radius: 50%;
}

/* Detail view hero mascot for paused tiles */
.detail-paused-mascot {
  display: inline-block;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-left: 10px;
  vertical-align: middle;
  overflow: hidden;
  background: var(--surface-alt, #FAFAF5);
}
.detail-paused-mascot img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Mascot decorator for the attempts history section header */
.section-title-with-mascot {
  display: flex;
  align-items: center;
  gap: 10px;
}
.section-title-mascot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-alt, #FAFAF5);
  flex-shrink: 0;
}
.section-title-mascot img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Mascot inside slip-confirm dialog */
.slip-comfort-mascot {
  display: block;
  width: 64px;
  height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface-alt, #FAFAF5);
}
.slip-comfort-mascot img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Help tooltip mascot — used in onboarding hints and form help */
.help-mascot-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85em;
  color: var(--text-muted);
  margin-top: 6px;
}
.help-mascot-inline .help-mascot-img {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}
.help-mascot-inline .help-mascot-img img {
  width: 100%; height: 100%; object-fit: cover;
}

/* Confetti celebration mascot — appears with toast on big milestones */
.celebrate-toast-mascot {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%) scale(0);
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: white;
  overflow: hidden;
  z-index: 80;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  animation: celebrate-pop 1.8s ease-out forwards;
}
.celebrate-toast-mascot img {
  width: 100%; height: 100%; object-fit: cover;
}
@keyframes celebrate-pop {
  0% { transform: translateX(-50%) scale(0) rotate(-20deg); }
  20% { transform: translateX(-50%) scale(1.15) rotate(10deg); }
  35% { transform: translateX(-50%) scale(1) rotate(0deg); }
  85% { transform: translateX(-50%) scale(1) rotate(0deg); opacity: 1; }
  100% { transform: translateX(-50%) scale(0.5) rotate(0deg); opacity: 0; }
}

/* ===== Attempts timeline (mini bar chart) ===== */
.attempts-timeline {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-alt, #FAFAF5);
  border-radius: var(--radius-md, 10px);
  min-height: 80px;
}
.timeline-bar {
  flex: 1;
  min-width: 8px;
  background: var(--accent, #5BA856);
  border-radius: 4px 4px 0 0;
  position: relative;
  transition: opacity 0.2s;
  min-height: 4px;
}
.timeline-bar:hover { opacity: 0.7; }
.timeline-bar.lapse { background: var(--danger, #E5484D); }
.timeline-bar.manual { background: var(--warning, #FFB627); }
.timeline-bar.current {
  background: var(--accent, #5BA856);
  box-shadow: 0 0 0 2px rgba(91, 168, 86, 0.3);
}
.timeline-bar-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text, #2A2D2A);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  white-space: nowrap;
  margin-bottom: 4px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s;
}
.timeline-bar:hover .timeline-bar-tooltip {
  opacity: 1;
}
.timeline-legend {
  display: flex;
  gap: 14px;
  margin-top: 8px;
  font-size: 0.72rem;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.timeline-legend-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
}

/* Date picker styling for cost-change "from a specific date" */
.cost-date-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
  padding: 12px;
  background: var(--surface-alt, #FAFAF5);
  border-radius: var(--radius-md, 10px);
}
.cost-date-picker input[type="date"] {
  font-size: 1rem;
  padding: 10px;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border, #E8E5D8);
  background: white;
  font-family: inherit;
}

/* ===================================================================
   v0.004 additions: permanent Tally, timer button, schema editor,
   schema-rich activity rendering, log details prompt
   =================================================================== */

/* Permanent Tally avatar above the action button (bottom-right corner) */
.tile-tally {
  position: absolute;
  bottom: 64px;            /* sits above the 44px quick-log button + spacing */
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--surface, white);
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  z-index: 2;
  pointer-events: none;     /* never blocks taps on the button below */
  transition: transform 0.2s;
}
.tile-tally img {
  width: 100%; height: 100%; object-fit: cover;
}
.tile-tally[data-variant="celebrate"],
.tile-tally[data-variant="flag"] {
  animation: tally-bob 1.6s ease-in-out infinite;
}
.tile-tally[data-variant="sleep"] {
  opacity: 0.85;
}
@keyframes tally-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-3px); }
}
/* On wide tiles the tally still sits above the action button — same position works */
.tile.shape-wide .tile-tally,
.tile.shape-large .tile-tally {
  bottom: 64px;
  right: 14px;
}

/* Timer button — replaces quick-log when hasTimer is on */
.tile-quick-log.timer-mode {
  background: var(--accent, #5BA856);
  box-shadow: 0 3px 0 #3F8A3D, 0 4px 12px rgba(0,0,0,0.12);
  font-size: 1.4rem;
}
.tile-quick-log.timer-mode.running {
  width: auto;
  min-width: 44px;
  padding: 0 12px;
  height: 44px;
  border-radius: 22px;
  background: var(--danger, #E5484D);
  box-shadow: 0 3px 0 #B33135, 0 4px 12px rgba(0,0,0,0.18);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  animation: timer-pulse 1.6s ease-in-out infinite;
}
.tile-quick-log.timer-mode.running .timer-icon {
  font-size: 1rem;
}
.tile-quick-log.timer-mode.running .timer-elapsed {
  font-size: 0.85rem;
  white-space: nowrap;
}
@keyframes timer-pulse {
  0%, 100% { box-shadow: 0 3px 0 #B33135, 0 4px 12px rgba(229,72,77,0.45); }
  50%      { box-shadow: 0 3px 0 #B33135, 0 4px 20px rgba(229,72,77,0.7); }
}

/* Schema field editor rows */
.schema-field-row {
  display: grid;
  grid-template-columns: 1fr 100px auto auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  padding: 8px;
  background: var(--surface-alt, #FAFAF5);
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border, #E8E5D8);
}
.schema-field-row .schema-label-input,
.schema-field-row .schema-type-input {
  font-size: 0.9rem;
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid var(--border, #E8E5D8);
  background: white;
  font-family: inherit;
}
.schema-field-row .schema-required {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}
.schema-field-row .schema-required-input {
  margin: 0;
}
.schema-field-row .schema-remove-btn {
  background: transparent;
  border: none;
  font-size: 1.3rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
}
.schema-field-row .schema-remove-btn:hover {
  color: var(--danger, #E5484D);
}
@media (max-width: 480px) {
  .schema-field-row {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }
  .schema-field-row .schema-label-input { grid-column: 1 / -1; }
  .schema-field-row .schema-type-input { grid-column: 1; }
  .schema-field-row .schema-required { grid-column: 1 / 2; }
  .schema-field-row .schema-remove-btn { grid-column: 2; grid-row: 2; align-self: center; }
}

/* Duration display in the log-details prompt */
.log-duration-display {
  font-size: 1.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--accent, #5BA856);
  padding: 12px 14px;
  background: var(--surface-alt, #FAFAF5);
  border-radius: var(--radius-md, 10px);
  text-align: center;
}

/* Schema extras in recent activity rows */
.history-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
}
.history-item-time { color: var(--text-muted); font-size: 0.85rem; }
.history-item-extras {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  padding-left: 4px;
}
.log-extra {
  font-size: 0.75rem;
  background: var(--surface-alt, #FAFAF5);
  padding: 3px 8px;
  border-radius: 10px;
  border: 1px solid var(--border, #E8E5D8);
  color: var(--text, #2A2D2A);
}
.log-extra.log-note-extra {
  font-style: italic;
  color: var(--text-muted);
}
