/* ═══════════════════════════════════════════════════
   STRIKS — Design System & Stylesheet
   ═══════════════════════════════════════════════════ */

/* ── Reset ──────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── Design Tokens ───────────────────────────────── */
:root {
  /* Surfaces */
  --bg:               #0d1117;
  --surface:          #161b22;
  --surface-hover:    #1c2128;
  --surface-elevated: #21262d;

  /* Borders */
  --border:           #30363d;
  --border-subtle:    #21262d;

  /* Text */
  --text:             #e6edf3;
  --text-secondary:   #8b949e;
  --text-muted:       #6e7681;

  /* Semantic */
  --accent:           #58a6ff;
  --danger:           #f85149;
  --success:          #3fb950;
  --warning:          #d29922;
  --tabbar-bg:        rgba(13, 17, 23, 0.85);

  /* Contribution grid */
  --cell-size:        13px;
  --cell-gap:         3px;
  --cell-radius:      3px;
  --grid-empty:       #161b22;

  /* Layout */
  --tab-height:       64px;
  --safe-bottom:      env(safe-area-inset-bottom, 0px);
  --safe-top:         env(safe-area-inset-top, 0px);

  /* Motion */
  --ease:             cubic-bezier(0.4, 0, 0.2, 1);
  --spring:           cubic-bezier(0.34, 1.56, 0.64, 1);
  --duration-fast:    0.15s;
  --duration:         0.25s;
  --duration-slow:    0.35s;
}

:root[data-theme='light'] {
  --bg:               #f6f8fa;
  --surface:          #ffffff;
  --surface-hover:    #eef2f7;
  --surface-elevated: #f1f5f9;
  --border:           #d0d7de;
  --border-subtle:    #e5e7eb;
  --text:             #0f172a;
  --text-secondary:   #475569;
  --text-muted:       #64748b;
  --grid-empty:       #e8edf3;
  --tabbar-bg:        rgba(246, 248, 250, 0.9);
}

:root[data-theme='dark'] {
  --bg:               #0d1117;
  --surface:          #161b22;
  --surface-hover:    #1c2128;
  --surface-elevated: #21262d;
  --border:           #30363d;
  --border-subtle:    #21262d;
  --text:             #e6edf3;
  --text-secondary:   #8b949e;
  --text-muted:       #6e7681;
  --grid-empty:       #161b22;
  --tabbar-bg:        rgba(13, 17, 23, 0.85);
}

/* ── Base ────────────────────────────────────────── */
html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
}

button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ── App Shell ───────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* ── Views ───────────────────────────────────────── */
#main {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.views-wrapper {
  flex: 1;
  position: relative;
  overflow: hidden;
  min-height: 0;
}

.sync-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: calc(10px + var(--safe-top)) 16px 10px;
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(180deg, rgba(88, 166, 255, 0.12), rgba(88, 166, 255, 0.03));
  flex-shrink: 0;
}

.sync-banner-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sync-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  user-select: none;
}

.sync-toggle input {
  appearance: none;
  -webkit-appearance: none;
  inline-size: 38px;
  block-size: 22px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-elevated);
  position: relative;
  transition:
    background var(--duration-fast) var(--ease),
    border-color var(--duration-fast) var(--ease),
    box-shadow var(--duration-fast) var(--ease);
}

.sync-toggle input::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  inline-size: 16px;
  block-size: 16px;
  border-radius: 50%;
  background: var(--text-secondary);
  transition:
    transform var(--duration-fast) var(--ease),
    background var(--duration-fast) var(--ease);
}

.sync-toggle input:checked {
  background: color-mix(in srgb, var(--accent) 28%, var(--surface-elevated));
  border-color: var(--accent);
}

.sync-toggle input:checked::before {
  transform: translateX(16px);
  background: var(--accent);
}

.sync-toggle input:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent);
}

.sync-toggle-text {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.sync-status {
  font-size: 12px;
  color: var(--text-secondary);
  text-align: right;
}

.sync-status.error {
  color: var(--danger);
}

.sign-out-btn {
  padding: 4px 10px;
  font-size: 12px;
}

.sign-out-btn[hidden] {
  display: none;
}

.theme-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
}

.theme-btn {
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  transition: background var(--duration-fast) var(--ease), color var(--duration-fast) var(--ease), border-color var(--duration-fast) var(--ease);
}

.theme-btn:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.theme-btn.active {
  background: var(--surface-elevated);
  border-color: var(--border);
  color: var(--text);
}

.theme-icon {
  line-height: 1;
}

.theme-text {
  font-weight: 600;
}

.view {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  overflow-x: hidden;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition:
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--ease);
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}
.view::-webkit-scrollbar { display: none; }
.view.active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ── View Header ─────────────────────────────────── */
.view-header {
  padding: 16px 16px 14px;
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--border-subtle);
  padding-top: 16px;
}

.header-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.view-title {
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.2;
  color: var(--text);
}

.view-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  font-weight: 400;
}

.progress-badge {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
  min-width: 52px;
  text-align: center;
  transition: color var(--duration), border-color var(--duration);
}

.progress-badge.complete {
  color: var(--success);
  border-color: var(--success);
}

.progress-bar-wrap {
  height: 3px;
  background: var(--surface-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  width: 0%;
  transition:
    width 0.5s var(--spring),
    background var(--duration) var(--ease);
}

/* ── View Content ────────────────────────────────── */
.view-content {
  padding: 14px 14px calc(var(--tab-height) + var(--safe-bottom) + 24px);
}

/* ─────────────────────────────────────────────────
   TAB BAR
   ───────────────────────────────────────────────── */
#tab-bar {
  display: flex;
  background: var(--tabbar-bg);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-top: 1px solid var(--border);
  height: calc(var(--tab-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: none;
  border: none;
  padding: 6px 4px 8px;
  color: var(--text-muted);
  transition: color var(--duration-fast) var(--ease);
  position: relative;
}

.tab-btn::before {
  content: '';
  position: absolute;
  top: 0; left: 50%;
  transform: translateX(-50%) scaleX(0);
  width: 32px;
  height: 2px;
  background: var(--accent);
  border-radius: 0 0 2px 2px;
  transition: transform var(--duration) var(--spring);
}

.tab-btn.active {
  color: var(--text);
}
.tab-btn.active::before {
  transform: translateX(-50%) scaleX(1);
}

.tab-btn:active { opacity: 0.7; }

.tab-icon {
  font-size: 20px;
  line-height: 1;
  transition: transform var(--duration) var(--spring);
}
.tab-btn.active .tab-icon {
  transform: scale(1.15) translateY(-1px);
}

.tab-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
}

/* ─────────────────────────────────────────────────
   TODAY — Cards
   ───────────────────────────────────────────────── */
.today-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 12px;
  overflow: hidden;
  position: relative;
  transition: border-color var(--duration) var(--ease);
  contain: layout style;
}

/* Colored left accent bar */
.today-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  background: var(--routine-color, var(--accent));
  border-radius: 4px 0 0 4px;
  transition: background var(--duration);
}

.today-card.done {
  border-color: var(--routine-color, var(--accent));
}

/* Subtle tint overlay for done state */
.today-card.done::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--routine-color, var(--accent));
  opacity: 0.05;
  pointer-events: none;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px 20px;
  gap: 10px;
}

.card-title-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.card-emoji {
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
}

.card-name {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-badge {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-elevated);
  padding: 3px 9px;
  border-radius: 10px;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background var(--duration), color var(--duration);
}

.card-badge.done {
  background: transparent;
  color: var(--routine-color, var(--success));
  border: 1px solid var(--routine-color, var(--success));
}

.card-body {
  padding: 2px 16px 16px 20px;
}

/* ── Toggle Button (once) ────────────────────────── */
.toggle-btn {
  width: 100%;
  padding: 13px 16px;
  border-radius: 12px;
  border: 2px dashed var(--border);
  background: transparent;
  color: var(--text-secondary);
  font-size: 15px;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition:
    background var(--duration) var(--ease),
    border-color var(--duration) var(--ease),
    color var(--duration) var(--ease),
    transform var(--duration-fast) var(--ease);
}

.toggle-btn:hover { border-color: var(--text-muted); color: var(--text); }
.toggle-btn:active { transform: scale(0.97); }

.toggle-btn.done {
  border-style: solid;
  border-color: var(--btn-color, var(--success));
  background: color-mix(in srgb, var(--btn-color, var(--success)) 12%, transparent);
  color: var(--btn-color, var(--success));
}

.toggle-check { font-size: 18px; line-height: 1; }

/* ── Count Control ───────────────────────────────── */
.count-control {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.count-adj-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    background var(--duration-fast),
    border-color var(--duration-fast),
    transform var(--duration-fast) var(--spring);
}

.count-adj-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}
.count-adj-btn:active:not(:disabled) { transform: scale(0.88); }
.count-adj-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.count-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
}

.count-ring {
  position: relative;
  width: 68px;
  height: 68px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}

.ring-bg {
  fill: none;
  stroke: var(--surface-elevated);
  stroke-width: 4;
}

.ring-fill {
  fill: none;
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 113;
  stroke-dashoffset: 113;
  transition: stroke-dashoffset 0.5s var(--spring);
}

.count-value {
  font-size: 24px;
  font-weight: 700;
  position: relative;
  z-index: 1;
  letter-spacing: -0.03em;
}

.count-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* ── Choice Grid ─────────────────────────────────── */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(68px, 1fr));
  gap: 8px;
}

.choice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 11px 6px 10px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-elevated);
  transition:
    background var(--duration-fast),
    border-color var(--duration-fast),
    transform var(--duration-fast) var(--spring);
}

.choice-btn:hover { border-color: var(--text-muted); }
.choice-btn:active { transform: scale(0.93); }

.choice-btn.selected {
  border-color: var(--choice-color, var(--accent));
  background: color-mix(in srgb, var(--choice-color, var(--accent)) 18%, var(--surface-elevated));
}

.choice-emoji { font-size: 26px; line-height: 1; }

.choice-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.2;
}

.choice-btn.selected .choice-label {
  color: var(--choice-color, var(--accent));
  font-weight: 600;
}

/* ── Card Comments (Today) ───────────────────────── */
.card-comment-wrap {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border-subtle);
}

.card-comment {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 12px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  cursor: pointer;
  transition: background var(--duration-fast), border-color var(--duration-fast);
}
.card-comment:hover {
  background: var(--surface-hover);
  border-color: var(--text-muted);
}
.card-comment-icon {
  font-size: 13px;
  line-height: 1.4;
  flex-shrink: 0;
}
.card-comment-text {
  font-size: 12.5px;
  color: var(--text);
  line-height: 1.4;
  word-break: break-word;
  font-style: italic;
}

.card-add-note-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  padding: 4px 6px;
  border-radius: 6px;
  cursor: pointer;
  transition: color var(--duration-fast), background var(--duration-fast);
}
.card-add-note-btn:hover {
  color: var(--text-secondary);
  background: var(--surface-elevated);
}

/* ─────────────────────────────────────────────────
   DASHBOARD — Grids
   ───────────────────────────────────────────────── */
.dashboard-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 16px;
  margin-bottom: 12px;
  overflow: hidden;
}

.dash-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 12px;
}

.dash-card-title {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 600;
  min-width: 0;
}
.dash-card-title span:last-child {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

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

.stat-chip {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}

/* ── Contribution Grid ───────────────────────────── */
.grid-outer {
  display: flex;
  gap: 4px;
  align-items: flex-start;
}

.grid-day-labels {
  display: flex;
  flex-direction: column;
  gap: var(--cell-gap);
  flex-shrink: 0;
  padding-top: calc(14px + var(--cell-gap)); /* align with cells (skip month row) */
}

.day-lbl {
  height: var(--cell-size);
  width: 14px;
  font-size: 8px;
  color: transparent;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  line-height: 1;
  font-weight: 500;
  letter-spacing: 0;
}
.day-lbl.show { color: var(--text-muted); }

.grid-scroll {
  overflow-x: auto;
  scrollbar-width: none;
  flex: 1;
}
.grid-scroll::-webkit-scrollbar { display: none; }

.grid-month-row {
  display: flex;
  gap: var(--cell-gap);
  height: 14px;
  margin-bottom: var(--cell-gap);
}

.month-lbl {
  width: var(--cell-size);
  font-size: 8.5px;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: visible;
  line-height: 14px;
}

.grid-cols {
  display: flex;
  gap: var(--cell-gap);
}

.grid-col {
  display: flex;
  flex-direction: column;
  gap: var(--cell-gap);
}

.grid-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  border-radius: var(--cell-radius);
  background: var(--grid-empty);
  border: 1px solid rgba(255, 255, 255, 0.04);
  cursor: default;
  transition: transform var(--duration-fast) var(--ease), box-shadow var(--duration-fast) var(--ease);
  flex-shrink: 0;
  position: relative;
}

:root[data-theme='light'] .grid-cell {
  border: 1px solid rgba(0, 0, 0, 0.06);
}

.grid-cell:hover {
  transform: scale(1.5);
  z-index: 5;
}

.grid-cell.is-clickable {
  cursor: pointer;
}

.grid-cell.is-clickable:hover {
  box-shadow: 0 0 0 1.5px var(--accent);
}

.grid-cell.has-comment::after {
  content: '';
  position: absolute;
  top: 1px;
  right: 1px;
  width: 3.5px;
  height: 3.5px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

:root[data-theme='light'] .grid-cell.has-comment::after {
  background: #0969da;
  box-shadow: none;
}

.grid-cell.is-future {
  background: var(--bg);
  border-color: rgba(255, 255, 255, 0.02);
  opacity: 0.4;
}

.grid-cell.is-today {
  outline: 1.5px solid var(--text-secondary);
  outline-offset: 1px;
}

/* ── Grid Legend ─────────────────────────────────── */
.grid-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--text-muted);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.legend-dot.empty {
  background: var(--grid-empty);
  border: 1px solid var(--border);
}

/* ─────────────────────────────────────────────────
   MANAGE — Routine List
   ───────────────────────────────────────────────── */
.manage-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manage-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 12px 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  transition: border-color var(--duration-fast);
}
.manage-item:hover { border-color: var(--text-muted); }

.manage-item-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.manage-emoji { font-size: 22px; width: 32px; text-align: center; flex-shrink: 0; }

.manage-name { font-size: 15px; font-weight: 600; }
.manage-meta { font-size: 12px; color: var(--text-secondary); margin-top: 2px; }

.manage-actions { display: flex; gap: 2px; flex-shrink: 0; }

.icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  border: none;
  background: transparent;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: background var(--duration-fast), transform var(--duration-fast) var(--spring);
}
.icon-btn:hover { background: var(--surface-elevated); }
.icon-btn:active { transform: scale(0.88); }

/* ── FAB ─────────────────────────────────────────── */
.fab {
  position: fixed;
  bottom: calc(var(--tab-height) + var(--safe-bottom) + 16px);
  right: 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 0 20px;
  height: 50px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  box-shadow: 0 4px 20px rgba(88, 166, 255, 0.35);
  transition:
    opacity var(--duration) var(--ease),
    transform var(--duration) var(--spring),
    box-shadow var(--duration) var(--ease);
  z-index: 50;
}

/* Only visible when manage tab is active */
#view-manage:not(.active) .fab {
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
}

.fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(88, 166, 255, 0.45);
}
.fab:active { transform: scale(0.95); }

.fab-icon { font-size: 22px; font-weight: 300; line-height: 1; }

/* ─────────────────────────────────────────────────
   EMPTY STATES
   ───────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 52px 24px 80px;
  gap: 10px;
}

.empty-icon {
  font-size: 52px;
  margin-bottom: 6px;
  line-height: 1;
  filter: drop-shadow(0 4px 12px rgba(0,0,0,0.4));
}

.empty-title { font-size: 18px; font-weight: 700; letter-spacing: -0.02em; }
.empty-desc  { font-size: 14px; color: var(--text-secondary); max-width: 260px; line-height: 1.65; }

/* ─────────────────────────────────────────────────
   BUTTONS
   ───────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 20px;
  border-radius: 11px;
  font-size: 14px;
  font-weight: 600;
  border: none;
  transition:
    background var(--duration-fast),
    opacity var(--duration-fast),
    transform var(--duration-fast) var(--spring);
  letter-spacing: -0.01em;
}
.btn:active { transform: scale(0.96); }

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

.btn-ghost    { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--surface-elevated); color: var(--text); }

.btn-danger   { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #ff6b6b; }

/* ── Universal hidden attribute safeguard ────────── */
[hidden] {
  display: none !important;
}

/* ─────────────────────────────────────────────────
   MODALS
   ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  z-index: 200;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--duration) var(--ease), visibility var(--duration) var(--ease);
}
.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}
.modal-overlay.open .modal { transform: translateY(0); }

.modal {
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 24px 24px 0 0;
  width: 100%;
  max-width: 600px;
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  transform: translateY(100%);
  transition: transform var(--duration-slow) var(--spring);
  overflow: hidden;
  padding-bottom: var(--safe-bottom);
}

.modal-drag-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 10px auto 2px;
  flex-shrink: 0;
}

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

.modal-title { font-size: 17px; font-weight: 700; letter-spacing: -0.02em; }

.modal-close-btn {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: none;
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--duration-fast);
}
.modal-close-btn:hover { background: var(--border); color: var(--text); }

.modal-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: none;
}
.modal-body::-webkit-scrollbar { display: none; }

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

/* Confirm modal — centered dialog */
.confirm-overlay {
  align-items: center;
  padding: 16px;
}
.confirm-overlay .modal {
  border-radius: 20px;
  max-width: 360px;
  max-height: none;
  transform: scale(0.9) translateY(0);
}
.confirm-overlay.open .modal {
  transform: scale(1);
}

.confirm-message {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
}

/* ─────────────────────────────────────────────────
   FORM ELEMENTS
   ───────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 18px;
}

.form-row {
  display: flex;
  gap: 12px;
}
.form-row .form-group { margin-bottom: 18px; }

.form-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  transition: border-color var(--duration-fast);
  outline: none;
}
.form-input:focus { border-color: var(--accent); }
.form-input::placeholder { color: var(--text-muted); }

.form-textarea {
  min-height: 84px;
  resize: vertical;
  line-height: 1.45;
  font-family: inherit;
}

.day-log-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 11px;
  padding: 10px 36px 10px 12px;
  color: var(--text);
  font-size: 14px;
  width: 100%;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath fill='%236e7681' d='M5 7L0 2h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  outline: none;
  transition: border-color var(--duration-fast);
}
.form-select:focus { border-color: var(--accent); }
.form-select option { background: var(--surface-elevated); }

.emoji-input { font-size: 20px; text-align: center; letter-spacing: 0; }

.color-input {
  padding: 4px 6px;
  height: 44px;
  cursor: pointer;
  border-radius: 11px;
}

/* ── Choice Rows in Form ─────────────────────────── */
.choice-rows { display: flex; flex-direction: column; gap: 8px; }

.choice-row {
  display: flex;
  gap: 8px;
  align-items: center;
}
.choice-row .emoji-input { flex: 0 0 50px; padding: 8px 4px; font-size: 18px; }
.choice-row .choice-lbl  { flex: 1; }
.choice-row .choice-col  {
  flex: 0 0 40px;
  height: 40px;
  border-radius: 10px;
  border: 1px solid var(--border);
  padding: 2px;
  background: var(--surface);
  cursor: pointer;
}
.choice-row .remove-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--danger);
  font-size: 14px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background var(--duration-fast);
}
.choice-row .remove-btn:hover { background: color-mix(in srgb, var(--danger) 15%, transparent); }

.form-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 9px;
}

/* ─────────────────────────────────────────────────
   UTILITIES & RESPONSIVE
   ───────────────────────────────────────────────── */
.hidden { display: none !important; }

@media (min-width: 420px) {
  :root {
    --cell-size: 14px;
    --cell-gap:  3px;
  }
  .view-title { font-size: 19px; }
  .choice-grid { grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); }
}

@media (max-width: 340px) {
  :root { --cell-size: 11px; }
}

/* Smooth scrolling for grid */
.grid-scroll { scroll-behavior: smooth; }

/* Pulse animation for completion */
@keyframes celebrate {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.06); }
  70%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}
.celebrate { animation: celebrate 0.5s var(--spring) forwards; }
