:root {
  --bg-top: #4D3A31;
  --bg-mid: #2A2018;
  --bg-bot: #0D0A08;
  --card: #493A32;
  --text: #FFFFFF;
  --text-dim: #8B847B;
  --text-muted: #6A635A;
  --accent: #FF9478;
  --divider: #3A2E26;
  --input-bg: #2A211C;
  --snackbar: #0F0A07;
  --sheet-bg: #1C1510;
  --sheet-control: #3A2E26;
  --sheet-divider: #4D3A31;
  --hairline: #5C524A;
  --action-bg: #3A2E26;
  --action-fg: #C4B5A9;
  --blocker-bg: #3A2E26;
  --blocker-fg: #C4998A;
  /* D-card design tokens (pencil/01.pen variant D) */
  --d-card: #493A32;
  --d-card-border: rgba(255,255,255,0.06);
  --d-text: #F4ECE4;
  --d-text-dim: rgba(244,236,228,0.55);
  --d-text-very-dim: rgba(244,236,228,0.35);
  --d-accent: #E07A5F;
  --d-note-bg: rgba(255,255,255,0.03);
  --age-1: #D6A76A;
  --age-2: #D68A5F;
  --age-3: #CF6B4D;
  --age-4: #B94C3A;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }

html {
  background: var(--bg-bot);
  min-height: 100dvh;
  min-height: var(--app-height, 100dvh);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', system-ui, sans-serif;
  color: var(--text);
  background: transparent;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
  min-height: 100dvh;
  min-height: var(--app-height, 100dvh);
}

/* Gradient lives on its own fixed element with EXPLICIT height = --app-height
 * (sourced from screen.height when the layout viewport reads short on iOS PWA
 * cold-start). This bypasses background-attachment: fixed, which on iOS would
 * anchor to the short layout viewport and leave the bottom unpainted until
 * WebKit reconciles after first touch. */
.bg-fill {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: var(--app-height, 100dvh);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-bot) 100%);
  z-index: -1;
  pointer-events: none;
}

#app { min-height: 100dvh; min-height: var(--app-height, 100dvh); }

#app.app-root {
  height: var(--app-height, 100dvh);
  overflow: hidden;
  position: relative;
}

/* ---------- pager (Сегодня ↔ Morning ↔ Calendar ↔ Tracks) ---------- */

.pager {
  display: flex;
  width: 400%;
  height: 100%;
  transform: translateX(0);
  transition: transform 280ms cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}
.pager.no-anim { transition: none; }
.pager.dragging { transition: none; }

.page {
  flex: 0 0 25%;
  width: 25%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  position: relative;
  touch-action: pan-y;
}

/* ---------- floating tabbar (Liquid Glass) ---------- */

.tabbar-capsule {
  position: fixed;
  /* Anchor to physical screen bottom via --app-height instead of bottom:4px.
   * `bottom` resolves against the layout viewport, which on iOS PWA cold-start
   * is short — leaving the bar floating above the actual screen bottom until
   * first touch. Top-positioned with --app-height (= screen.height) is stable
   * from first paint. */
  top: calc(var(--app-height, 100dvh) - 86px);
  left: 16px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(42, 32, 24, 0.45);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    inset 0 -1px 0 rgba(0, 0, 0, 0.20),
    0 8px 24px rgba(0, 0, 0, 0.35);
  z-index: 10;
}

.tabbar-tab {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.1px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background 200ms ease, color 200ms ease, padding 200ms ease;
}
.tabbar-tab .icon,
.tabbar-tab svg { width: 22px; height: 22px; }
.tabbar-tab.active {
  background: rgba(255, 148, 120, 0.14);
  color: var(--accent);
  font-weight: 600;
  padding: 8px 18px;
}
.tabbar-tab:active { transform: scale(0.96); }

.tabbar-plus {
  position: fixed;
  /* Same reasoning as .tabbar-capsule: anchor via top + --app-height to escape
   * the cold-start layout-viewport short-read. 60px height + 8px gap = 68px. */
  top: calc(var(--app-height, 100dvh) - 83px);
  right: 16px;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 10;
  opacity: 0;
  transform: scale(0.8);
  pointer-events: none;
  transition: opacity 180ms ease-out, transform 180ms ease-out;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.40),
    inset 0 -1px 0 rgba(0, 0, 0, 0.18),
    0 6px 18px rgba(255, 148, 120, 0.35);
}
.tabbar-plus.visible {
  opacity: 1;
  transform: scale(1);
  pointer-events: auto;
}
.tabbar-plus:active { transform: scale(0.94); }
.tabbar-plus .icon,
.tabbar-plus svg { width: 26px; height: 26px; color: #0D0A08; }

.screen {
  padding: 0 16px 100px 16px;
  max-width: 560px;
  margin: 0 auto;
}

/* Tracks and Today pages have no .top-region, so safe-area-inset compensation
 * goes directly on the .screen. Morning uses .top-region which already handles it. */
.page-tracks > .screen,
.page-today > .screen {
  padding-top: calc(env(safe-area-inset-top, 0) + 24px);
}

/* Calendar page has its own narrower screen container */
.page-calendar > .screen-cal {
  padding: calc(env(safe-area-inset-top, 0) + 24px) 14px 100px 14px;
  max-width: 560px;
  margin: 0 auto;
}

.top-region {
  display: flex;
  flex-direction: column;
  min-height: calc(100% - 100px);
  padding-top: calc(env(safe-area-inset-top, 0) + 24px);
}
.top-region > .active-grid,
.top-region > .active-grouped,
.top-region > .empty {
  margin-top: auto;
}

/* ---------- header ---------- */

.header {
  padding: 12px 4px 20px 4px;
}
.header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.header h1 {
  margin: 0;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.header .sub {
  margin-top: 4px;
  font-size: 15px;
  color: var(--text-dim);
}

/* ---------- grid ---------- */

.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.card {
  aspect-ratio: 1 / 1;
  background: var(--card);
  border-radius: 15px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  min-width: 0;
  transition: transform 120ms ease, opacity 200ms ease;
}
.card:active { transform: scale(0.97); }
.card .icon {
  font-size: 22px;
  line-height: 1;
}
.card .text {
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: auto;
  padding-top: 1px;
}
.card.removing { opacity: 0; transform: scale(0.9); }

.card.stamping,
.stuck-card-d.stamping,
.cal-card.stamping {
  overflow: visible;
  z-index: 2;
  animation: stamp-card-impact 280ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
@keyframes stamp-card-impact {
  0%   { transform: scale(1); }
  22%  { transform: scale(0.97); }
  100% { transform: scale(1); }
}

.stamp-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 12px;
  background: #111111;
  color: #FFFFFF;
  display: grid;
  place-items: center;
  pointer-events: none;
  opacity: 0;
  z-index: 3;
  animation: stamp-badge-drop 280ms cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.stamp-badge svg { width: 26px; height: 26px; }
@keyframes stamp-badge-drop {
  0%   { opacity: 0; transform: translateY(-46px) scale(1.35) rotate(-22deg); box-shadow: 0 2px 6px rgba(0,0,0,0.3); }
  36%  { opacity: 1; transform: translateY(-22px) scale(1.32) rotate(-20deg); box-shadow: 0 10px 22px rgba(0,0,0,0.6); }
  64%  { opacity: 1; transform: translateY(0) scale(1.12) rotate(14deg); box-shadow: 0 10px 22px rgba(0,0,0,0.7); }
  82%  { transform: translateY(0) scale(0.96) rotate(10deg); box-shadow: 0 7px 16px rgba(0,0,0,0.55); }
  100% { opacity: 1; transform: translateY(0) scale(1.0) rotate(var(--final-rot, 12deg)); box-shadow: 0 6px 14px rgba(0,0,0,0.45); }
}

.stamp-shockwave {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 60px;
  height: 60px;
  margin-left: -30px;
  margin-top: -30px;
  border-radius: 50%;
  background: rgba(255, 148, 120, 0.28);
  pointer-events: none;
  opacity: 0;
  z-index: 1;
  animation: stamp-shockwave 280ms cubic-bezier(0.2, 0.6, 0.2, 1) forwards 100ms;
}
@keyframes stamp-shockwave {
  0%   { opacity: 0; transform: scale(0.5); }
  35%  { opacity: 1; transform: scale(1.2); }
  100% { opacity: 0; transform: scale(2.6); }
}

.card .icon-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.card .notes-mark {
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  pointer-events: none;
}
.card .notes-mark svg,
.card .notes-mark .icon { width: 14px; height: 14px; }

.card .track-mark {
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 4px;
  pointer-events: none;
  margin-top: 6px;
}
.card .track-mark svg,
.card .track-mark .icon { width: 10px; height: 10px; flex: 0 0 10px; }
.card .track-mark .name {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.card .deadline {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}
.card .deadline.today,
.card .deadline.overdue { color: var(--accent); }

.check-badge {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  margin-top: -22px;
  border-radius: 10px;
  background: #111111;
  color: #FFFFFF;
  display: grid;
  place-items: center;
  transform: rotate(var(--rot, 0deg));
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.45), 0 1px 0 rgba(255, 255, 255, 0.03) inset;
  pointer-events: none;
}
.check-badge svg {
  width: 26px;
  height: 26px;
}

/* ---------- section dividers ---------- */

.divider {
  display: flex;
  align-items: center;
  margin: 28px 4px 14px 4px;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
}
.divider-label { margin-right: 10px; }
.divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--divider);
}
.divider.has-link::after { content: none; }
.divider.has-link .divider-line {
  flex: 1;
  height: 1px;
  background: var(--divider);
}
.divider.has-link .divider-link {
  margin-left: 10px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 4px 2px;
}
.divider.has-link .divider-link:active { opacity: 0.6; }

.active-grouped {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.active-grouped .divider {
  margin: 0 4px;
  padding: 8px 0 4px 0;
}
.active-grouped .divider.plain {
  padding: 12px 0 4px 0;
}

/* ---------- empty ---------- */

.empty {
  padding: 60px 24px;
  text-align: center;
  color: var(--text-dim);
  font-size: 15px;
}

/* ---------- input-bar ---------- */

.input-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0)) 16px;
  background: linear-gradient(180deg, rgba(13,10,8,0) 0%, rgba(13,10,8,0.9) 40%, rgba(13,10,8,1) 100%);
  z-index: 10;
}
.input-bar .wrap {
  max-width: 560px;
  margin: 0 auto;
  background: var(--accent);
  color: #0D0A08;
  border-radius: 999px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 0;
  width: 100%;
  font: 600 16px -apple-system, system-ui, sans-serif;
  cursor: pointer;
  transition: transform 120ms ease;
}
.input-bar .wrap:active { transform: scale(0.98); }
.input-bar .wrap .icon,
.input-bar .wrap svg { width: 20px; height: 20px; }

/* ---------- bottom sheet ---------- */

.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 100;
  transition: background 200ms ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.sheet-backdrop.open { background: rgba(0, 0, 0, 0.33); }

.sheet {
  width: 100%;
  max-width: 560px;
  background: var(--sheet-bg);
  border-radius: 28px 28px 0 0;
  padding: 12px 24px calc(24px + env(safe-area-inset-bottom, 0)) 24px;
  transform: translateY(100%);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  max-height: 92vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.sheet-backdrop.open .sheet { transform: translateY(0); }

.sheet-handle {
  width: 44px;
  height: 5px;
  background: #A89C90;
  border-radius: 999px;
  margin: 0 auto 2px auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sheet-title {
  color: var(--text);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.sheet-done {
  background: transparent;
  border: 0;
  color: var(--accent);
  font: 600 16px -apple-system, system-ui, sans-serif;
  padding: 4px 4px;
  cursor: pointer;
}
.sheet-done:active { opacity: 0.6; }

.sheet-input-row {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.sheet-iconbox {
  flex: 0 0 52px;
  width: 52px;
  height: 52px;
  border-radius: 14px;
  background: var(--sheet-control);
  border: 0;
  color: var(--text);
  display: grid;
  place-items: center;
  cursor: pointer;
  padding: 0;
  transition: transform 120ms ease;
}
.sheet-iconbox:active { transform: scale(0.94); }
.sheet-iconbox .icon,
.sheet-iconbox svg { width: 24px; height: 24px; }

.sheet-input-wrap {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  border-radius: 14px;
  background: var(--sheet-control);
  padding: 14px 16px;
  display: flex;
  align-items: center;
}
.sheet-text {
  flex: 1;
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--text);
  font: 500 16px/1.35 -apple-system, system-ui, sans-serif;
  padding: 0;
  max-height: 94px;
  overflow-y: auto;
}
.sheet-text::placeholder { color: var(--text-muted); }

.sheet-notes-wrap {
  border-radius: 14px;
  background: var(--sheet-control);
  padding: 14px 16px;
}
.sheet-notes {
  width: 100%;
  min-width: 0;
  display: block;
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
  color: var(--text);
  font: 500 16px/1.35 -apple-system, system-ui, sans-serif;
  padding: 0;
  overflow: hidden;
}
.sheet-notes::placeholder { color: var(--text-muted); }

.sheet-section {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sheet-label {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
}

.sheet-icon-row {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 6px;
}
.sheet-icons-all {
  align-self: flex-start;
  border: 0;
  background: transparent;
  color: var(--accent);
  font: 600 14px -apple-system, system-ui, sans-serif;
  padding: 6px 0;
  cursor: pointer;
  letter-spacing: 0.01em;
}
.sheet-icons-all:active { opacity: 0.6; }
.sheet-icon {
  border: 0;
  background: var(--sheet-control);
  color: var(--text);
  border-radius: 12px;
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 120ms ease, transform 120ms ease;
}
.sheet-icon:active { transform: scale(0.94); }
.sheet-icon.selected {
  background: var(--accent);
  color: #0D0A08;
}
.sheet-icon.prediction {
  background: rgba(255, 148, 120, 0.2);
  color: var(--accent);
}
.sheet-icon .icon,
.sheet-icon svg {
  width: 20px;
  height: 20px;
}
.sheet-icon-row .sheet-icon .icon,
.sheet-icon-row .sheet-icon svg {
  width: 18px;
  height: 18px;
}

.sheet-track-row {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  gap: 6px;
  padding: 2px 0 4px 0;
  scrollbar-width: none;
}
.sheet-track-row::-webkit-scrollbar { display: none; }

.track-chip {
  flex: 0 0 auto;
  border: 0;
  background: var(--sheet-control);
  color: var(--text);
  border-radius: 999px;
  padding: 0 14px;
  font: 500 14px -apple-system, system-ui, sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, transform 120ms ease, color 120ms ease;
}
.track-chip:active { transform: scale(0.96); }
.track-chip .icon,
.track-chip svg { width: 16px; height: 16px; }
.track-chip.selected {
  background: var(--accent);
  color: #0D0A08;
}

.track-chip-none {
  min-width: 44px;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  color: var(--text-dim);
}
.track-chip-none.selected { color: #0D0A08; }

.track-chip-plus {
  padding: 0 12px;
  color: var(--text-dim);
}

.track-chip-input {
  padding: 0;
  background: var(--sheet-control);
}
.track-chip-input input {
  background: transparent;
  border: 0;
  outline: 0;
  color: var(--text);
  font: 500 14px -apple-system, system-ui, sans-serif;
  padding: 0 14px;
  width: 180px;
  height: 36px;
}
.track-chip-input input::placeholder { color: var(--text-muted); }

.sheet-dl-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.sheet-dl-row .label {
  color: var(--text);
  font-size: 15px;
}
.sheet-deadline {
  background: var(--sheet-control);
  border: 0;
  outline: 0;
  color: var(--text);
  font: 500 14px -apple-system, system-ui, sans-serif;
  padding: 8px 14px;
  border-radius: 999px;
  color-scheme: dark;
  min-width: 0;
}

.sheet-divider {
  height: 1px;
  background: var(--sheet-divider);
  border: 0;
  margin: 0;
}

.sheet-finish {
  width: 100%;
  background: var(--accent);
  color: #0D0A08;
  border: 0;
  border-radius: 999px;
  padding: 14px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font: 600 16px -apple-system, system-ui, sans-serif;
  cursor: pointer;
  transition: transform 120ms ease;
  margin-top: 4px;
}
.sheet-finish:active { transform: scale(0.98); }
.sheet-finish .icon,
.sheet-finish svg { width: 20px; height: 20px; }

.sheet-delete {
  align-self: flex-start;
  padding: 8px 0;
  background: transparent;
  border: 0;
  color: #FF7A6B;
  font: 500 15px -apple-system, system-ui, sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sheet-delete:active { opacity: 0.6; }
.sheet-delete svg { width: 18px; height: 18px; }

/* ---------- full icon picker ---------- */

.picker-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0);
  z-index: 200;
  transition: background 200ms ease;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.picker-backdrop.open { background: rgba(0, 0, 0, 0.5); }

.picker-sheet {
  width: 100%;
  max-width: 560px;
  background: var(--sheet-bg);
  border-radius: 28px 28px 0 0;
  padding: 14px 18px calc(24px + env(safe-area-inset-bottom, 0)) 18px;
  transform: translateY(100%);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  height: 80vh;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.picker-backdrop.open .picker-sheet { transform: translateY(0); }

.picker-search {
  width: 100%;
  background: var(--card);
  border: 0;
  outline: 0;
  color: var(--text);
  font: 16px -apple-system, system-ui, sans-serif;
  padding: 12px 14px;
  border-radius: 12px;
  margin-top: 4px;
  margin-bottom: 14px;
}
.picker-search::placeholder { color: var(--text-muted); }
.picker-search::-webkit-search-cancel-button { filter: invert(0.7); }

.picker-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-auto-rows: max-content;
  align-content: start;
  gap: 8px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 20px;
  min-height: 0;
  flex: 1;
}
.picker-grid .sheet-icon { align-self: start; }

.picker-empty {
  grid-column: 1 / -1;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  padding: 24px 12px;
}

/* ---------- history sheet (Весь журнал) ---------- */

.history-sheet {
  padding: 14px 24px calc(24px + env(safe-area-inset-bottom, 0)) 24px;
}
.history-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin: 4px 0 14px;
}
.history-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
}
.history-clear-all {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  padding: 4px 2px;
}
.history-clear-all:active { opacity: 0.6; }
.history-content {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  min-height: 0;
  flex: 1;
  padding-bottom: 8px;
}
.history-group { margin-bottom: 20px; }
.history-group:last-child { margin-bottom: 0; }
.history-day {
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.history-empty {
  color: var(--text-dim);
  text-align: center;
  padding: 40px 0;
  font-size: 13px;
}

/* Lucide icons on cards */
.card .icon-row > .icon,
.card .icon-row > svg {
  width: 22px;
  height: 22px;
}

/* ---------- undo snackbar ---------- */

.snackbar {
  position: fixed;
  left: 50%;
  bottom: calc(96px + env(safe-area-inset-bottom, 0));
  transform: translateX(-50%) translateY(calc(100% + 24px));
  background: var(--snackbar);
  color: var(--text);
  padding: 8px 8px 8px 18px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 9999;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.55);
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  z-index: 50;
  max-width: calc(100vw - 32px);
  font-size: 14px;
}
.snackbar.open { transform: translateX(-50%) translateY(0); }
.snackbar-label { white-space: nowrap; }
.snackbar-action {
  background: var(--accent);
  color: #0D0A08;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  font: 600 14px -apple-system, system-ui, sans-serif;
  cursor: pointer;
}
.snackbar-action:active { transform: scale(0.96); }

/* ---------- tracks screen ---------- */

.track-section {
  padding: 0 4px;
  transition: background 160ms ease;
}
.track-section + .track-section { margin-top: 8px; }
.track-section.drop-target {
  background: rgba(255, 148, 120, 0.06);
  border-radius: 12px;
}

.track-divider {
  display: flex;
  align-items: center;
  padding: 10px 4px 8px 4px;
  color: var(--text-dim);
  font-size: 12px;
  font-weight: 600;
}
.track-divider.inactive { color: #5A4F48; }
.track-divider-label { margin-right: 10px; }
.track-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--divider);
}
.track-divider.inactive::after { background: #2E2620; }

.track-strip {
  --progress: 0%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px;
  height: 38px;
  margin-top: 4px;
  border-radius: 10px;
  cursor: pointer;
  position: relative;
  color: #0D0A08;
  background: linear-gradient(90deg,
    var(--accent) 0%,
    var(--accent) var(--progress),
    #f7bba5 var(--progress),
    #f7bba5 100%);
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.track-strip:active { transform: scale(0.985); }
.track-strip.inactive {
  background: #2A211C;
  color: var(--text-dim);
}
.track-strip.inactive .track-grip .icon,
.track-strip.inactive .track-grip svg { color: #5A4F48; }
.track-strip.inactive .track-icon { color: var(--text-dim); }
.track-strip.drag-origin { opacity: 0.35; }

.track-grip {
  border: 0;
  background: transparent;
  padding: 0;
  display: grid;
  place-items: center;
  width: 18px;
  height: 100%;
  color: rgba(13, 10, 8, 0.53);
  cursor: grab;
  touch-action: none;
}
.track-grip:active { cursor: grabbing; }
.track-grip .icon,
.track-grip svg { width: 16px; height: 22px; }

.track-icon {
  width: 14px;
  height: 14px;
  color: #0D0A08;
}
.track-name {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.track-meta {
  font-size: 11px;
  font-weight: 500;
  color: rgba(13, 10, 8, 0.55);
  white-space: nowrap;
}
.track-strip.inactive .track-meta { color: #5A4F48; }

.track-strip.drag-ghost {
  position: fixed;
  z-index: 500;
  pointer-events: none;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.55);
  transform: scale(1.02);
  will-change: transform;
  margin-top: 0;
}

/* ---------- track sheet — extras ---------- */

.category-toggle {
  display: flex;
  gap: 6px;
  background: var(--sheet-control);
  padding: 4px;
  border-radius: 999px;
}
.category-toggle-btn {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--text-dim);
  font: 600 14px -apple-system, system-ui, sans-serif;
  padding: 10px 0;
  border-radius: 999px;
  cursor: pointer;
  transition: background 160ms ease, color 160ms ease;
}
.category-toggle-btn.selected {
  background: var(--accent);
  color: #0D0A08;
}

.track-tasks-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.track-task-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
.track-task-row.done .track-task-text {
  color: var(--text-dim);
}
.track-task-main {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: 500 14px -apple-system, system-ui, sans-serif;
  min-width: 0;
}
.track-task-action {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  padding: 0;
}
.track-task-action svg,
.track-task-action .icon { width: 16px; height: 16px; }
.track-task-action.detach { color: var(--text-muted); }
.track-task-action.attach { color: var(--accent); }
.track-task-action.attach svg,
.track-task-action.attach .icon { width: 18px; height: 18px; }
.track-task-action:active { opacity: 0.55; }
.track-task-icon {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: var(--sheet-control);
  display: grid;
  place-items: center;
  flex: 0 0 24px;
  color: var(--text);
}
.track-task-icon .icon,
.track-task-icon svg { width: 14px; height: 14px; }
.track-task-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.track-tasks-empty {
  color: var(--text-dim);
  font-size: 14px;
  padding: 8px 0;
}

/* ---------- status banner (IDB reconnect etc) ---------- */

#err-bar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  padding: 10px 14px;
  font: 13px/1.4 -apple-system, sans-serif;
  color: #fff;
  z-index: 9999;
  white-space: pre-wrap;
  max-height: 40vh;
  overflow: auto;
}

/* ---------- Today screen: stuck cards (D-style, pencil/01.pen) ---------- */

.stuck-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 20px;
}

.stuck-card-d {
  display: flex;
  background: var(--d-card);
  border-radius: 18px;
  border: 1px solid var(--d-card-border);
  overflow: hidden;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: transform 120ms ease, opacity 200ms ease;
}
.stuck-card-d:active { transform: scale(0.99); }
.stuck-card-d.removing { opacity: 0; transform: scale(0.96); }

.stuck-stripe {
  width: 4px;
  flex: 0 0 4px;
  background: var(--card-age, var(--age-1));
}

.stuck-age-block {
  width: 60px;
  flex: 0 0 60px;
  padding: 14px 0 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  border-right: 1px solid var(--d-card-border);
}
.stuck-age-num {
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -1px;
  color: var(--card-age, var(--age-1));
  font-feature-settings: 'tnum';
}
.stuck-age-word {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--card-age, var(--age-1));
  opacity: 0.85;
}
.stuck-age-flame {
  width: 12px;
  height: 14px;
  margin-top: 5px;
  color: var(--card-age, var(--age-1));
  opacity: 0.7;
  flex: 0 0 14px;
}

.stuck-main {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.stuck-top-d {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 12px 12px 14px;
}
.stuck-left-d {
  flex: 1 1 auto;
  min-width: 0;
}

.stuck-title-row-d {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.stuck-task-icon-d {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  margin-top: 1px;
  color: var(--d-text);
}
.stuck-title-row-d > .stuck-title-d {
  flex: 1 1 auto;
  min-width: 0;
}
.stuck-title-d {
  font-size: 16px;
  font-weight: 600;
  line-height: 20px;
  letter-spacing: -0.25px;
  color: var(--d-text);
  word-break: break-word;
  overflow-wrap: anywhere;
}

.stuck-trash-d {
  flex: 0 0 auto;
  margin: -4px -4px -4px 0;
  padding: 8px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: var(--d-text-dim);
  border-radius: 6px;
}
.stuck-trash-d:active { opacity: 0.6; }
.stuck-trash-d > .icon,
.stuck-trash-d > svg {
  width: 16px;
  height: 16px;
  color: currentColor;
  flex: 0 0 16px;
}

.stuck-track-pill-d {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 148, 120, 0.12);
  color: var(--accent);
  font-size: 11px;
  font-weight: 500;
  align-self: flex-start;
}
.stuck-track-pill-d > .icon,
.stuck-track-pill-d > svg {
  width: 11px;
  height: 11px;
  color: currentColor;
  flex: 0 0 11px;
}

.stuck-note {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 8px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: var(--d-note-bg);
  font-size: 11.5px;
  font-style: italic;
  font-family: inherit;
  text-align: left;
  color: var(--d-text-dim);
  max-width: 100%;
  min-width: 0;
  cursor: pointer;
}
.stuck-note:active { opacity: 0.7; }
.stuck-note > .icon,
.stuck-note > svg {
  width: 11px;
  height: 11px;
  color: var(--d-text-very-dim);
  flex: 0 0 11px;
}
.stuck-note > span {
  word-break: break-word;
  overflow-wrap: anywhere;
  min-width: 0;
}
.stuck-note-x {
  margin: -4px -4px -4px 2px;
  padding: 4px;
  border: 0;
  background: transparent;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
  border-radius: 6px;
  color: var(--d-text-dim);
}
.stuck-note-x:active { opacity: 0.6; }
.stuck-note-x > .icon,
.stuck-note-x > svg {
  width: 11px;
  height: 11px;
  color: currentColor;
  flex: 0 0 11px;
}

.stuck-edit-bar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--d-card-border);
}
.stuck-edit-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stuck-edit-input-row > .icon,
.stuck-edit-input-row > svg {
  width: 12px;
  height: 12px;
  color: var(--d-text-dim);
  flex: 0 0 12px;
}
.stuck-edit-input-box {
  flex: 1 1 auto;
  background: #0D0A08;
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  min-width: 0;
}
.stuck-edit-input {
  flex: 1 1 auto;
  background: transparent;
  border: 0;
  outline: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  font-style: italic;
  color: var(--d-text);
  caret-color: var(--d-accent);
  min-width: 0;
  padding: 0;
}
.stuck-edit-input::placeholder {
  color: var(--d-text-very-dim);
  font-style: italic;
}
.stuck-edit-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}
.stuck-edit-cancel,
.stuck-edit-save {
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 12px;
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stuck-edit-cancel {
  background: rgba(255,255,255,0.04);
  color: var(--d-text-dim);
  font-weight: 500;
}
.stuck-edit-save {
  background: var(--d-accent);
  color: #2A211C;
  font-weight: 600;
  gap: 5px;
}
.stuck-edit-save > .icon,
.stuck-edit-save > svg {
  width: 12px;
  height: 12px;
  color: #2A211C;
  flex: 0 0 12px;
}
.stuck-edit-cancel:active,
.stuck-edit-save:active { opacity: 0.7; }

.stuck-split-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--d-card-border);
}
.stuck-split-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stuck-split-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.stuck-split-input-box {
  flex: 1 1 auto;
  background: #0D0A08;
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  min-width: 0;
}
.stuck-split-input {
  flex: 1 1 auto;
  background: transparent;
  border: 0;
  outline: 0;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  color: var(--d-text);
  caret-color: var(--d-accent);
  min-width: 0;
  padding: 0;
}
.stuck-split-input::placeholder {
  color: var(--d-text-very-dim);
  font-style: italic;
}
.stuck-split-row-x {
  border: 0;
  background: transparent;
  padding: 4px;
  display: grid;
  place-items: center;
  cursor: pointer;
  border-radius: 6px;
  flex: 0 0 auto;
}
.stuck-split-row-x > .icon,
.stuck-split-row-x > svg {
  width: 12px;
  height: 12px;
  color: var(--d-text-very-dim);
  flex: 0 0 12px;
}
.stuck-split-row-x:active { opacity: 0.6; }
.stuck-split-plus {
  border: 0;
  background: transparent;
  padding: 4px 0 0 0;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  color: var(--d-text-dim);
  align-self: flex-start;
}
.stuck-split-plus > .icon,
.stuck-split-plus > svg {
  width: 12px;
  height: 12px;
  color: currentColor;
  flex: 0 0 12px;
}
.stuck-split-plus:active { opacity: 0.7; }
.stuck-split-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding-top: 4px;
}
.stuck-split-save {
  border: 0;
  border-radius: 999px;
  padding: 6px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  background: var(--d-accent);
  color: #2A211C;
}
.stuck-split-save > .icon,
.stuck-split-save > svg {
  width: 12px;
  height: 12px;
  color: #2A211C;
  flex: 0 0 12px;
}
.stuck-split-save:disabled,
.stuck-split-save.disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.stuck-split-save:not(:disabled):active { opacity: 0.7; }

.stuck-segbar {
  display: flex;
  border-top: 1px solid var(--d-card-border);
}
.stuck-seg {
  flex: 1 1 0;
  min-width: 0;
  height: 44px;
  border: 0;
  background: transparent;
  color: var(--d-text);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: -0.05px;
  font-family: inherit;
  cursor: pointer;
  padding: 0 2px;
}
.stuck-seg:active { opacity: 0.6; }
.stuck-seg > .icon,
.stuck-seg > svg {
  width: 14px;
  height: 14px;
  color: currentColor;
  flex: 0 0 14px;
}
.stuck-seg-label {
  color: currentColor;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.stuck-seg-accent { color: var(--d-accent); }
.stuck-seg-date { position: relative; }
.stuck-seg-date-input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  border: 0;
  margin: 0;
  padding: 0;
  background: transparent;
  color: transparent;
  font-size: 16px;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}
.stuck-seg-divider {
  width: 1px;
  margin: 8px 0;
  background: var(--d-card-border);
  flex: 0 0 1px;
}

.today-section-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  margin: 24px 4px 8px 4px;
  text-transform: uppercase;
}

.fresh-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.fresh-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 10px 4px;
  min-height: 44px;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: opacity 200ms ease, transform 200ms ease;
}
.fresh-row.removing { opacity: 0; transform: scale(0.98); }
.fresh-row > .icon,
.fresh-row > svg { width: 20px; height: 20px; color: var(--text); flex: 0 0 20px; }

.fresh-text {
  flex: 1 1 auto;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fresh-check {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: transparent;
  border: 1.5px solid #5C524A;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 22px;
  transition: background 180ms ease, border-color 180ms ease, transform 180ms ease;
}
.fresh-check > .icon,
.fresh-check > svg {
  width: 12px;
  height: 12px;
  color: transparent;
  transition: color 180ms ease;
}
.fresh-check.filling {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.1);
}
.fresh-check.filling > .icon,
.fresh-check.filling > svg {
  color: #2A211C;
}

/* ---------- Calendar page ---------- */

.cal-quote {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;
  color: var(--text-dim);
  margin-top: 6px;
}

.cal-strip-wrap {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  margin: 14px -14px 0 -14px;
  padding: 0 14px;
  scrollbar-width: none;
  /* Block native gestures so the pager (1-finger horizontal) and our
   * 2-finger horizontal scroll can coexist without pointercancel races.
   * 1-finger vertical scroll is delegated to a JS handler below. */
  touch-action: none;
}
.cal-strip-wrap::-webkit-scrollbar { display: none; }

.cal-strip {
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.cal-col {
  flex: 0 0 112px;
  width: 112px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cal-day-title {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1.8px;
  color: var(--text-dim);
}
.cal-col.is-today .cal-day-title {
  color: var(--accent);
}

.cal-day-sub {
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-top: -2px;
}
.cal-col.is-today .cal-day-sub {
  color: var(--accent);
  opacity: 0.7;
}

.cal-hdiv {
  height: 1px;
  background: var(--divider);
  width: 100%;
}

.cal-vdiv {
  width: 1px;
  align-self: stretch;
  background: var(--divider);
  flex: 0 0 1px;
}

.cal-card {
  background: var(--card);
  border-radius: 15px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  position: relative;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  overflow: hidden;
  width: 112px;
  height: 112px;
  flex: 0 0 112px;
  transition: transform 120ms ease, opacity 200ms ease;
}
.cal-card:active { transform: scale(0.97); }

.cal-card .icon-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.cal-card .icon-row > .icon,
.cal-card .icon-row > svg {
  width: 22px;
  height: 22px;
}
.cal-card .notes-mark {
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  pointer-events: none;
}
.cal-card .notes-mark svg,
.cal-card .notes-mark .icon { width: 14px; height: 14px; }

.cal-card .text {
  font-size: 12px;
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.01em;
  word-break: break-word;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: auto;
  padding-top: 1px;
}

.cal-card .deadline {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-dim);
}
.cal-card .deadline.today { color: var(--accent); }
.cal-card .deadline.overdue { color: #FF6B6B; }

/* ---------- header gear ---------- */

.header-row {
  align-items: center;
}
.header-gear {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: var(--text-dim);
  border-radius: 999px;
}
.header-gear:active { transform: scale(0.94); }
.header-gear .icon,
.header-gear svg { width: 22px; height: 22px; }

/* ---------- settings overlay ---------- */

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: var(--bg-bot) linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 55%, var(--bg-bot) 100%);
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 240ms cubic-bezier(0.2, 0.8, 0.2, 1);
  padding-top: env(safe-area-inset-top, 0);
  touch-action: pan-y;
}
.settings-overlay.open { transform: translateX(0); }
.settings-overlay.dragging { transition: none; }

.settings-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px;
  height: 48px;
  flex: 0 0 auto;
}
.settings-back,
.settings-back-spacer {
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}
.settings-back:active { transform: scale(0.94); }
.settings-back .icon,
.settings-back svg { width: 24px; height: 24px; }
.settings-title {
  font: 600 17px -apple-system, system-ui, sans-serif;
  color: var(--text);
}

.settings-content {
  padding: 24px 16px calc(24px + env(safe-area-inset-bottom, 0)) 16px;
  display: flex;
  flex-direction: column;
  gap: 28px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.settings-section-label {
  font: 600 11px -apple-system, system-ui, sans-serif;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.settings-card {
  background: var(--card);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  padding: 0 16px;
  background: transparent;
  border: 0;
  width: 100%;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  color: var(--text);
  font: 400 16px -apple-system, system-ui, sans-serif;
  text-align: left;
}
.settings-row:active { background: rgba(255,255,255,0.04); }
div.settings-row { cursor: default; }
div.settings-row:active { background: transparent; }
.settings-row-divider {
  height: 1px;
  background: #3A2E26;
  margin: 0 16px;
}
.settings-row-left {
  display: flex;
  align-items: center;
  gap: 14px;
}
.settings-row-left .icon,
.settings-row-left svg { width: 20px; height: 20px; color: var(--text); }
.settings-row-label {
  font-size: 16px;
  color: var(--text);
}
.settings-row-right-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}
.settings-row-right {
  font-size: 15px;
  color: var(--text-dim);
}
.settings-row-chevron {
  color: var(--text-muted);
}
.settings-row-chevron.icon,
.settings-row-chevron svg { width: 18px; height: 18px; }
.settings-hint {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-muted);
  padding: 0 4px;
}

/* ---------- settings sheets (export/import) ---------- */

.settings-sheet-backdrop {
  z-index: 400;
}
.settings-sheet-backdrop .settings-sheet {
  height: auto;
  max-height: 92vh;
  padding: 14px 24px calc(28px + env(safe-area-inset-bottom, 0)) 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.settings-sheet-head {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.settings-sheet-title {
  font: 700 24px -apple-system, system-ui, sans-serif;
  color: var(--text);
}
.settings-sheet-sub {
  font-size: 14px;
  color: var(--text-dim);
  line-height: 1.4;
}

.settings-counts {
  background: var(--sheet-control, #3A2E26);
  border-radius: 14px;
  padding: 0 16px;
  display: flex;
  flex-direction: column;
}
.settings-count-row {
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  color: var(--text);
}
.settings-count-row .settings-count-value {
  color: var(--text-dim);
}
.settings-count-divider {
  height: 1px;
  background: #4D3A31;
}

.settings-file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-dim);
}
.settings-file-row .icon,
.settings-file-row svg { width: 16px; height: 16px; }

.settings-file-chip {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--sheet-control, #3A2E26);
  border-radius: 999px;
  padding: 8px 10px 8px 14px;
  color: var(--text);
  font: 500 14px -apple-system, system-ui, sans-serif;
  max-width: 100%;
}
.settings-file-chip > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 200px;
}
.settings-file-chip .icon,
.settings-file-chip svg { width: 16px; height: 16px; flex: 0 0 auto; }
.settings-file-chip-x {
  width: 24px;
  height: 24px;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-dim);
  -webkit-tap-highlight-color: transparent;
  flex: 0 0 auto;
}
.settings-file-chip-x:active { transform: scale(0.92); }
.settings-file-chip-x .icon,
.settings-file-chip-x svg { width: 16px; height: 16px; }

.settings-warning {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  background: var(--sheet-control, #3A2E26);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.4;
}
.settings-warning .icon,
.settings-warning svg {
  width: 18px;
  height: 18px;
  color: var(--accent);
  flex: 0 0 auto;
  margin-top: 1px;
}

.settings-compare {
  display: flex;
  gap: 12px;
}
.settings-compare-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--sheet-control, #3A2E26);
  border-radius: 14px;
  padding: 14px;
}
.settings-compare-col.accent {
  border: 1px solid rgba(255, 148, 120, 0.4);
}
.settings-compare-label {
  font: 600 11px -apple-system, system-ui, sans-serif;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.settings-compare-col.accent .settings-compare-label {
  color: var(--accent);
}
.settings-compare-row {
  font-size: 15px;
  color: var(--text);
}

.settings-cancel {
  align-self: center;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  font: 500 15px -apple-system, system-ui, sans-serif;
  cursor: pointer;
  padding: 8px 16px;
  -webkit-tap-highlight-color: transparent;
}
.settings-cancel:active { opacity: 0.6; }
