/* ── Views ─────────────────────────────────────────────────── */
.view {
  display: none;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  width: 100%;
  background: var(--bg);
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px);
}

.view.active { display: flex; }

.view.subview.active { padding-bottom: 0; }

.view-body {
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

#home-body {
  overflow-anchor: none;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

#home-body.is-dragging {
  cursor: grabbing;
}

#home-body button,
#home-body a,
#home-body input,
#home-body textarea,
#home-body select,
#home-body label {
  cursor: pointer;
  user-select: none;
}

.view-body.flush { padding: 0; }

#tx-body {
  touch-action: pan-y;
  overscroll-behavior: contain;
}

.view-body:not(#home-body) {
  cursor: grab;
}

.view-body.is-drag-scrolling {
  cursor: grabbing;
  user-select: none;
}

.view-body:not(#home-body) button,
.view-body:not(#home-body) a,
.view-body:not(#home-body) input,
.view-body:not(#home-body) textarea,
.view-body:not(#home-body) select,
.view-body:not(#home-body) label {
  cursor: pointer;
}

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  min-width: 0;
}

.topbar h1 {
  font-size: 17px;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  letter-spacing: -0.01em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topbar .meta {
  font-size: 13px;
  color: var(--text-3);
  font-weight: 400;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text-2);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

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

.btn-text {
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 500;
  color: var(--accent);
  cursor: pointer;
  padding: 6px 0;
}

/* ── Period selector ───────────────────────────────────────── */
.period-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  border: none;
  border-radius: var(--radius);
  background: var(--surface-2);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  cursor: pointer;
  max-width: 58%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 1;
}

.period-btn svg { flex-shrink: 0; color: var(--text-3); }

/* ── Bottom nav ────────────────────────────────────────────── */
.bottom-nav-wrap {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  overflow: visible;
  pointer-events: none;
  padding-left: env(safe-area-inset-left, 0px);
  padding-right: env(safe-area-inset-right, 0px);
}

.bottom-nav {
  width: 100%;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--border);
  overflow: visible;
  pointer-events: auto;
}

.bottom-nav-wrap.hidden { display: none; }

.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border: none;
  background: none;
  font-family: var(--font);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  cursor: pointer;
  padding: 6px 0;
  min-width: 0;
}

.nav-btn svg { width: 20px; height: 20px; }

.nav-btn.active { color: var(--accent); }

.nav-btn.add {
  position: relative;
  overflow: visible;
}

.nav-add-fab {
  --fab: var(--nav-fab);
  width: var(--fab);
  height: var(--fab);
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(100% - var(--fab) * 0.8);
  transition: background 0.15s, box-shadow 0.15s;
}

.nav-add-fab svg {
  width: 24px;
  height: 24px;
}

.nav-btn.add:active .nav-add-fab {
  background: var(--surface-2);
  box-shadow: var(--shadow-sm);
}

/* ── Section ───────────────────────────────────────────────── */
.section { margin-bottom: 20px; }

.section-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-3);
}

.section-link {
  font-size: 13px;
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  font-family: var(--font);
  font-weight: 500;
}

/* ── Cards & panels ────────────────────────────────────────── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  min-width: 0;
  max-width: 100%;
}

.panel + .panel { margin-top: 8px; }

.panel.flat { border-radius: 0; border-left: none; border-right: none; }
