/* ── App Shell & Layout ─────────────────────────────────────────── */

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;          /* the app scrolls its own panels, never the page */
  overscroll-behavior: none; /* disables pull-to-refresh & rubber-banding */
  position: fixed;           /* extra insurance against iOS body scrolling */
  background: #0f172a;
}

#newviewContainer {
  display: flex;
  width: 100%;
  height: 100vh;             /* fallback for browsers without dvh */
  height: 100dvh;            /* the *visible* viewport; never use min-height: 100vh here */
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  overflow: hidden;
  background: #0f172a;
  color: #f8fafc;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#newviewContainer.wide   { flex-direction: row; }
#newviewContainer.narrow { flex-direction: column; }

/* Data View: fills whatever the controls don't take */
.data-view {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
  overflow-x: hidden; /* tossed cards fly sideways */
  overflow-y: auto;
  overscroll-behavior: contain;
}

.data-view.hidden { display: none; }

/* Always at least as tall as the view, so the spacer below only adds scroll
   room and never pushes the footer up */
.data-view-inner {
  flex-shrink: 0;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.sheet-spacer {
  flex-shrink: 0;
  height: var(--sheet-space, 0px);
}

.wide .data-view { border-right: 1px solid #334155; }

.narrow .data-view { padding: 1.25rem 1rem; }

/* Controls: shared */
#controls-view {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  background: #0f172a;
}

/* Wide: fixed-width side column */
.controls-side {
  flex: 0 0 clamp(340px, 32vw, 460px);
  width: clamp(340px, 32vw, 460px);
  height: 100%;
  padding: 1.25rem;
  gap: 1rem;
  justify-content: center;
  overflow: auto;
}

/* Narrow + create/edit inspector: takes over the screen */
.controls-full {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1rem;
  padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* Narrow + list mode: a dock sized to its content (the quick-create bar).
   The bottom inset is *added* to the padding so system nav bars never cover it. */
.controls-dock {
  flex: 0 0 auto;
  position: relative;
  z-index: 10;
  padding: 0.65rem 0.85rem;
  padding-bottom: calc(0.65rem + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid #334155;
}

/* Out of flow, anchored to the dock's top edge; clips the sheet so it
   slides out from behind the dock rather than over it. */
.controls-sheet-clip {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  overflow: hidden;
  pointer-events: none;
}

.controls-sheet {
  pointer-events: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 60dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  box-sizing: border-box;
  padding: 0.65rem 0.85rem;
  background: #0f172a;
  border-top: 1px solid #334155;
  border-radius: 0.85rem 0.85rem 0 0;
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.45);
}

/* Vertical Tab List Container */
.tab-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  width: 100%;
  box-sizing: border-box;
}

/* Individual Stacked Tab Item */
.tab-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  text-align: left;
  font-family: inherit;
  box-sizing: border-box;
  padding: 0.85rem 1.15rem;
  /* opaque (not translucent) so cards sliding behind others don't show through */
  background-color: #1c2639;
  background-image: linear-gradient(to right, var(--fill-color, #38bdf8) var(--progress, 0%), transparent var(--progress, 0%));
  border: 1px solid rgba(51, 65, 85, 0.8);
  border-left: 4px solid #475569;
  border-radius: 0.6rem;
  color: #e2e8f0;
  font-size: 0.925rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

/* Hover State */
.tab-item:hover {
  background-color: #2e3a4d;
  border-color: rgba(100, 116, 139, 0.9);
  border-left-color: #38bdf8;
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.15);
}

/* Focus State */
.tab-item:focus-visible {
  border-color: #38bdf8;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35);
}

/* Selected State */
.tab-item.selected {
  background-color: #1c3579;
  background-image: linear-gradient(to right, var(--fill-color, #3b82f6) var(--progress, 0%), transparent var(--progress, 0%));
  border-color: #3b82f6;
  border-left: 4px solid #3b82f6;
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 14px rgba(59, 130, 246, 0.3);
}

.tab-item.selected:hover {
  border-left-color: #60a5fa;
  background-color: #1e3986;
}

/* Browse views (All, Upcoming, Daily): due cards stand forward, upcoming ones
   (not yet appeared, or already handled today) recede */
.tab-item.browse {
  color: #f8fafc;
  border-left-color: #94a3b8;
}

/* keep hover and selection winning over the browse edge colour */
.tab-item.browse:hover {
  border-left-color: #38bdf8;
}

.tab-item.browse.selected {
  border-left-color: #3b82f6;
}

.tab-item.upcoming {
  background-color: #141c2c;
  border-color: rgba(51, 65, 85, 0.5);
  border-left-color: #2a3647;
  color: #8a97ab;
  font-weight: 400;
  box-shadow: none;
}

.tab-item.upcoming.selected {
  background-color: #1c3579;
  border-left-color: #3b82f6;
  color: #ffffff;
}

.tab-repeats {
  color: #60a5fa;
}

/* Daily view: every card says whether it repeats (↻) or happens once */
.tab-repeat-icon {
  color: #60a5fa;
  font-size: 0.95rem;
  line-height: 1;
}

.tab-once {
  padding: 0.05rem 0.45rem;
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 999px;
  color: #cbd5e1;
  font-size: 0.68rem;
  letter-spacing: 0.02em;
}

.tab-item.upcoming .tab-once {
  border-color: rgba(148, 163, 184, 0.3);
  color: #8a97ab;
}

/* When an upcoming tab is due; lights up briefly when rescheduled */
.tab-when {
  padding: 0.1rem 0.4rem;
  border-radius: 0.35rem;
  color: #cbd5e1;
  font-variant-numeric: tabular-nums;
}

/* Browse-view actions for a selected tab */
.browse-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.browse-actions.wide {
  flex-direction: column;
  gap: 0.6rem;
}

.browse-action-btn {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.1rem;
  min-height: 2.5rem;
  padding: 0.45rem 0.75rem;
  border-radius: 0.5rem;
  border: 1px solid #334155;
  background: #1e293b;
  color: #e2e8f0;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.browse-action-btn:hover {
  background: #334155;
}

.browse-action-btn:focus-visible {
  outline: 2px solid #38bdf8;
  outline-offset: 2px;
}

.browse-action-btn.confirming {
  border-color: #f59e0b;
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
}

.browse-action-sub {
  font-size: 0.7rem;
  color: #94a3b8;
}

/* The Daily view: a day's timeline of when daily tabs appear.
   Each row is [time | rail with a dot | card]; the rail runs through all rows. */
.timeline {
  display: flex;
  flex-direction: column;
}

.timeline-row {
  position: relative;
  display: grid;
  grid-template-columns: 4.75rem 1.25rem minmax(0, 1fr);
  align-items: center;
  padding: 0.3rem 0;
}

.timeline-time {
  font-size: 0.75rem;
  color: #94a3b8;
  text-align: right;
  padding-right: 0.5rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.timeline-rail {
  position: relative;
  align-self: stretch;
  display: flex;
  align-items: center;
  justify-content: center;
}

.timeline-rail::before {
  content: "";
  position: absolute;
  top: -0.3rem;
  bottom: -0.3rem;
  left: 50%;
  width: 2px;
  transform: translateX(-50%);
  background: #334155;
}

.timeline-row:first-child .timeline-rail::before { top: 50%; }
.timeline-row:last-child .timeline-rail::before { bottom: 50%; }

.timeline-dot {
  position: relative;
  width: 0.55rem;
  height: 0.55rem;
  border-radius: 50%;
  background: #475569;
  box-shadow: 0 0 0 3px #111a2c;
}

/* The current time: a thin accent line across the card column */
.timeline-now .timeline-time,
.timeline-now-line span {
  color: #38bdf8;
}

.timeline-now .timeline-dot {
  background: #38bdf8;
  width: 0.45rem;
  height: 0.45rem;
}

.timeline-now-line {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.timeline-now-line::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(56, 189, 248, 0.6), rgba(56, 189, 248, 0));
}

/* Time input beside the text in the create bar (Daily view) */
.quick-create-time {
  flex: 0 0 auto;
  width: 6.75rem;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  padding: 0.55rem 0.5rem;
  color: #f8fafc;
  font-family: inherit;
  font-size: 0.8rem;
  color-scheme: dark;
}

.quick-create-time:focus {
  outline: none;
  border-color: #3b82f6;
}

/* Quick edits for a daily tab, in the sheet */
.daily-edit {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 0.75rem;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid #334155;
  border-radius: 0.75rem;
}

.daily-edit-field .inspector-label {
  margin-bottom: 0.3rem;
}

.daily-edit-time {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.daily-edit-time .inspector-input {
  width: auto;
  flex: 0 0 8rem;
  color-scheme: dark;
}

.daily-edit-time .option-pill {
  flex: 0 0 auto;
}

.daily-edit-hint {
  font-size: 0.75rem;
  color: #94a3b8;
}

.browse-action-btn.stop-daily {
  color: #cbd5e1;
  border-style: dashed;
}

/* Tab Text Content */
.tab-text {
  flex: 1;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin-right: 0.75rem;
}

/* Tab Timestamp / Meta */
.tab-meta {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  font-weight: 400;
  white-space: nowrap;
}

/* The Deck: everything out of sight, always present under the hand. Drawn as
   a small stack of face-down cards whose thickness shows how many there are.
   Deliberately calm: curiosity, not alarm. */
.deck {
  position: relative;
  z-index: 2; /* cards sliding back in tuck underneath */
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.25rem 0.75rem;
  min-height: 2.9rem;
  box-sizing: border-box;
  padding: 0.75rem 1rem;
  margin-top: 0.5rem;
  margin-bottom: 0.6rem; /* room for the cards peeking out below */
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 0.6rem;
  color: #cbd5e1;
  font-size: 0.825rem;
  font-weight: 500;
  user-select: none;
}

/* No cards out of sight: just an empty tray */
.deck.deck-empty {
  background: transparent;
  border: 1px dashed rgba(71, 85, 105, 0.6);
}

/* The cards underneath, as layered shadows: each pair is a card's fill plus a
   1px outline, offset down and inset a little further than the one above.
   Outer shadows never paint inside the box, so the top card stays clean. */
.deck.deck-1 {
  box-shadow:
    0 5px 0 -3px #16233a,
    0 5px 0 -2px rgba(56, 189, 248, 0.22);
}

.deck.deck-2 {
  box-shadow:
    0 5px 0 -3px #16233a,
    0 5px 0 -2px rgba(56, 189, 248, 0.22),
    0 10px 0 -7px #132033,
    0 10px 0 -6px rgba(56, 189, 248, 0.14);
}

.deck-count {
  color: #bae6fd;
}

.deck-hint {
  font-size: 0.75rem;
  color: #94a3b8;
}

/* Brief glow when a card slides back into the deck */
.deck-glow {
  position: absolute;
  inset: -1px;
  border-radius: inherit;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.7), 0 0 16px rgba(56, 189, 248, 0.45);
  pointer-events: none;
}


/* Quick Create Bar */
.quick-create-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid #334155;
  border-radius: 0.75rem;
  padding: 0.75rem;
}

/* Delay Menu Container */
.delay-menu-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid #334155;
  border-left: 3px solid #475569;
  border-radius: 0.75rem;
  padding: 0.75rem;
  transition: border-color 0.2s ease;
}

.delay-menu-container.active {
  border-left-color: #f59e0b;
}

.delay-menu-header-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: #94a3b8;
  transition: color 0.2s ease;
}

.delay-menu-container.active .delay-menu-header-title {
  color: #f59e0b;
}

.quick-create-input-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.quick-create-input {
  flex: 1;
  min-width: 0;
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.5rem;
  padding: 0.6rem 0.85rem;
  color: #f8fafc;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.quick-create-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.25);
}

.quick-create-btn {
  flex-shrink: 0;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.6rem 0.9rem;
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.1s ease, filter 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.quick-create-btn:hover:not(:disabled) {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.quick-create-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.options-toggle-btn {
  flex-shrink: 0;
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  border-radius: 0.5rem;
  padding: 0.6rem 0.75rem;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.options-toggle-btn:hover {
  background: #334155;
  color: #f8fafc;
  border-color: #475569;
}

/* Inspector Panel / Sub-menu Forms */
.inspector-panel {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid #334155;
  border-radius: 0.75rem;
  padding: 1rem;
  height: 100%;
  box-sizing: border-box;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.inspector-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid #1e293b;
}

.inspector-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.inspector-section {
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid #1e293b;
  border-left: 3px solid #334155;
  border-radius: 0.6rem;
  padding: 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.inspector-section.modified {
  border-color: rgba(56, 189, 248, 0.4);
  border-left: 3px solid #38bdf8;
  background: rgba(56, 189, 248, 0.06);
}

.inspector-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  font-weight: 600;
  color: #cbd5e1;
}

.inspector-section.modified .inspector-section-header {
  color: #f8fafc;
}

.modified-badge {
  font-size: 0.675rem;
  font-weight: 600;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.35);
  padding: 0.1rem 0.4rem;
  border-radius: 9999px;
  line-height: 1.2;
  user-select: none;
}

.inspector-label {
  font-size: 0.8rem;
  color: #94a3b8;
  font-weight: 500;
  margin-bottom: 0.25rem;
  display: block;
}

/* Option Pill Buttons */
.option-pills-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.option-pill {
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  border-radius: 0.4rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.775rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  flex: 1 1 auto;
  text-align: center;
}

.option-pill:hover {
  background: #334155;
  color: #f8fafc;
}

.option-pill.active {
  background: rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
  color: #60a5fa;
  font-weight: 600;
}

.option-pill:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  border-color: #1e293b;
  color: #64748b;
  background: #0f172a;
}

/* Custom Input Controls inside Inspector */
.inspector-input {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.4rem;
  padding: 0.45rem 0.65rem;
  color: #f8fafc;
  font-size: 0.825rem;
  width: 100%;
  box-sizing: border-box;
}

.inspector-input:focus {
  border-color: #38bdf8;
  outline: none;
}

/* Action Buttons inside Inspector */
.inspector-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: auto;
  padding-top: 0.5rem;
  padding-bottom: 0.5rem;
  flex-shrink: 0;
}

.btn-primary {
  flex: 1;
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  border: none;
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  font-weight: 600;
  font-size: 0.875rem;
  cursor: pointer;
  transition: filter 0.2s ease;
}

.btn-primary:hover:not(:disabled) {
  filter: brightness(1.1);
}

.btn-primary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-secondary {
  flex: 1;
  background: #1e293b;
  border: 1px solid #334155;
  color: #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.65rem 1rem;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: background 0.2s ease;
}

.btn-secondary:hover {
  background: #334155;
}

/* Data View Footer & Corner Buttons */
.data-view-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 0.75rem;
  margin-top: auto;
  border-top: 1px solid #334155;
}

.corner-btn {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(30, 41, 59, 0.6);
  border: 1px solid #334155;
  color: #94a3b8;
  border-radius: 0.5rem;
  padding: 0.45rem 0.75rem;
  font-size: 0.8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}

.corner-btn:hover {
  background: #334155;
  border-color: #475569;
  color: #f8fafc;
}

.corner-btn-label {
  font-size: 0.8rem;
}

/* "Last backed up ..." in Settings */
.backup-status {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.8rem;
  color: #94a3b8;
}

.backup-status.due {
  color: #fcd34d;
}

/* Modal Backdrop & Overlay */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: rgba(15, 23, 42, 0.85);
  padding: 1rem;
  box-sizing: border-box;
  animation: modalBackdropFadeIn 0.15s ease-out forwards;
  will-change: opacity;
}

@keyframes modalBackdropFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-wrapper {
  max-width: 560px;
  width: 90vw;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  animation: modalSlideIn 0.18s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  will-change: transform, opacity;
  transform: translateZ(0);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Modal Card / Dialog Window */
.modal-card {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 0.85rem;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.6), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 85vh;
  box-sizing: border-box;
  overflow: hidden;
  contain: content;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid #1e293b;
  background: rgba(30, 41, 59, 0.5);
}

.modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-close-btn {
  background: transparent;
  border: none;
  color: #94a3b8;
  font-size: 1.1rem;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  border-radius: 0.375rem;
  transition: all 0.15s ease;
  line-height: 1;
}

.modal-close-btn:hover {
  background: #334155;
  color: #f8fafc;
}

.modal-body {
  padding: 1.25rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  box-sizing: border-box;
  -webkit-overflow-scrolling: touch;
}

.modal-section {
  display: flex;
  flex-direction: column;
  background: rgba(30, 41, 59, 0.4);
  border: 1px solid #1e293b;
  border-radius: 0.6rem;
  padding: 0.85rem 1rem;
}

.help-accordion-section {
  padding: 0;
  overflow: hidden;
  border-color: #27354a;
  transition: border-color 0.2s ease, background 0.2s ease;
}

.help-accordion-section.is-open {
  border-color: #3b82f6;
  background: rgba(30, 41, 59, 0.6);
}

.help-accordion-header {
  margin: 0;
  font-size: 1rem;
  font-weight: normal;
}

.help-accordion-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  background: transparent;
  border: none;
  color: #f8fafc;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 0.6rem;
  transition: background 0.15s ease, color 0.15s ease;
}

.help-accordion-trigger:hover {
  background: rgba(51, 65, 85, 0.35);
  color: #ffffff;
}

.help-accordion-trigger:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: -2px;
}

.help-accordion-icon {
  font-size: 0.75rem;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease;
  user-select: none;
}

.help-accordion-trigger:hover .help-accordion-icon {
  color: #e2e8f0;
}

.help-accordion-trigger[aria-expanded="true"] .help-accordion-icon {
  transform: rotate(90deg);
  color: #60a5fa;
}

.help-accordion-body {
  padding: 0 1rem 0.95rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.modal-section-title {
  font-size: 0.875rem;
  font-weight: 600;
  color: #f8fafc;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.modal-section-desc {
  margin: 0;
  font-size: 0.8rem;
  color: #94a3b8;
  line-height: 1.45;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid #1e293b;
  background: rgba(30, 41, 59, 0.3);
}

.help-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.825rem;
  color: #cbd5e1;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  line-height: 1.45;
}

.help-list li strong {
  color: #f8fafc;
}

/* Source Switcher Pill Control */
.source-switcher-container {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.source-pill-dropdown {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* On screens narrower than 850px, position the extra pills out of document flow */
@media (max-width: 850px) {
  .source-pill-dropdown {
    position: absolute;
    top: calc(100% + 0.4rem);
    right: 0;
    z-index: 50;
    flex-direction: column;
    align-items: stretch;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 0.4rem;
    border-radius: 0.75rem;
    border: 1px solid #334155;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    min-width: 140px;
  }
}

.source-pill-btn {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.3);
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  white-space: nowrap;
  outline: none;
}

.source-pill-btn:hover {
  background: rgba(59, 130, 246, 0.25);
  border-color: rgba(59, 130, 246, 0.5);
  color: #93c5fd;
}

.source-pill-btn.inactive {
  background: rgba(148, 163, 184, 0.1);
  color: #94a3b8;
  border-color: rgba(148, 163, 184, 0.25);
}

.source-pill-btn.inactive:hover {
  background: rgba(148, 163, 184, 0.2);
  color: #f1f5f9;
  border-color: rgba(148, 163, 184, 0.45);
}

.source-pill-btn:focus-visible {
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.4);
}

.source-pill-btn:disabled,
.source-pill-btn.inactive:disabled {
  opacity: 0.38;
  cursor: not-allowed;
  pointer-events: none;
}


