/* ==========================================================================
   NAVIGATION & MOBILE SHELL: DOCKED TAB BAR & DYNAMIC ISLAND
   ========================================================================== */

/* Top Masthead */
/* Top Masthead */
.masthead {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface-glass);
  backdrop-filter: blur(var(--glass-blur));
  -webkit-backdrop-filter: blur(var(--glass-blur));
  border-bottom: 1px solid var(--border-subtle);
  transition: all var(--transition-normal);
  padding: 0;
  width: 100%;
}

.masthead-inner {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: linear-gradient(135deg, #f4dca0 0%, var(--gold-primary) 60%, var(--gold-deep) 100%);
  color: #ffffff;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 15px;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  user-select: none;
  transition: transform var(--transition-spring);
}
.brand-badge:active { transform: scale(0.92); }

html[data-theme="oled"] .brand-badge {
  background: linear-gradient(135deg, #fff2a8 0%, #ffd700 55%, #b39200 100%);
  color: #000000;
  box-shadow: 0 0 14px rgba(255, 215, 0, 0.4);
}

.brand-info {
  display: flex;
  flex-direction: column;
}

.brand-title {
  font-family: var(--font-display);
  font-style: italic;
  font-weight: 600;
  font-size: var(--fs-md);
  color: var(--ink-primary);
  line-height: 1.1;
}

.brand-sub {
  font-size: var(--fs-2xs);
  color: var(--ink-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
}

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

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: var(--r-full);
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  font-size: var(--fs-2xs);
  font-weight: 600;
  color: var(--ink-secondary);
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--good);
  box-shadow: 0 0 8px var(--good);
  animation: pulse-ring 2.5s infinite;
}

@keyframes pulse-ring {
  0% { transform: scale(0.9); opacity: 0.7; }
  50% { transform: scale(1.25); opacity: 1; }
  100% { transform: scale(0.9); opacity: 0.7; }
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  color: var(--ink-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
}
.icon-btn:active { transform: scale(0.92); }

/* Theme toggle 2-mode icon behavior */
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: block; }
html[data-theme="oled"] .theme-toggle .icon-sun { display: block; }
html[data-theme="oled"] .theme-toggle .icon-moon { display: none; }

/* Sticky Dynamic Island Micro-Bar */
.dynamic-island {
  position: fixed;
  top: 10px;
  left: 50%;
  transform: translateX(-50%) translateY(-70px);
  z-index: 150;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 14px;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(28px);
  -webkit-backdrop-filter: blur(28px);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: all var(--transition-spring);
}
.dynamic-island.visible {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.island-rate {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: var(--fs-base);
  color: var(--gold-primary);
}
.island-sub {
  font-size: var(--fs-xs);
  color: var(--ink-secondary);
}

/* Floating Bottom Navigation Dock */
.bottom-dock {
  position: fixed;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: var(--surface-glass-strong);
  backdrop-filter: blur(30px) saturate(1.4);
  -webkit-backdrop-filter: blur(30px) saturate(1.4);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-full);
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 32px);
  width: auto;
}

.tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: var(--r-full);
  background: transparent;
  border: none;
  color: var(--ink-secondary);
  font-family: var(--font-sans);
  font-size: var(--fs-xs);
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
}
.tab-btn svg { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.75; }

.tab-btn.active {
  background: var(--gold-tint);
  color: var(--gold-primary);
  border: 1px solid var(--glass-border);
  box-shadow: 0 0 12px var(--gold-glow);
}
.tab-btn.active svg { opacity: 1; }

.tab-btn:active {
  transform: scale(0.95);
}

/* Views Container */
.views-viewport {
  width: 100%;
  max-width: 680px;
  margin: 0 auto;
  padding: 12px 16px;
}

.view-page {
  display: none;
  animation: fadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.view-page.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Mobile-Specific Bottom Bar & Safe-Area Alignment (< 640px) */
@media (max-width: 640px) {
  .masthead-inner {
    padding: max(10px, env(safe-area-inset-top, 0px)) 12px 10px;
    flex-wrap: nowrap;
    gap: 8px;
  }
  .brand-group {
    gap: 6px;
    min-width: 0;
    flex-shrink: 1;
    overflow: hidden;
  }
  .brand-badge {
    width: 28px;
    height: 28px;
    font-size: 13px;
    flex-shrink: 0;
  }
  .brand-info {
    min-width: 0;
    overflow: hidden;
  }
  .brand-title {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .brand-sub {
    font-size: 9px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .masthead-actions {
    gap: 6px;
    flex-shrink: 0;
  }
  .status-indicator {
    padding: 3px 7px;
    font-size: 9.5px;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .icon-btn {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
  }
  .icon-btn svg {
    width: 13px;
    height: 13px;
  }
  .views-viewport {
    padding: 10px 12px 14px;
  }
  .dynamic-island {
    top: max(8px, env(safe-area-inset-top, 0px));
    max-width: calc(100vw - 24px);
    padding: 5px 12px;
    gap: 8px;
  }
  .bottom-dock {
    bottom: 0;
    left: 0;
    right: 0;
    transform: none;
    width: 100%;
    max-width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom, 0px));
    justify-content: space-around;
    gap: 2px;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
  }
  .tab-btn {
    flex: 1;
    flex-direction: column;
    gap: 3px;
    padding: 6px 2px;
    font-size: 10px;
    min-width: 0;
    border-radius: var(--r-sm);
  }
  .tab-btn span {
    font-size: clamp(9px, 2.5vw, 11px);
    white-space: nowrap;
    text-overflow: ellipsis;
  }
  .tab-btn svg {
    width: 18px;
    height: 18px;
  }
}

/* Modal Bottom Sheet */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 300;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}
.sheet-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-sheet {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%) translateY(100%);
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  z-index: 310;
  background: var(--surface-raised);
  border: 1px solid var(--border-strong);
  border-bottom: none;
  border-radius: var(--r-xl) var(--r-xl) 0 0;
  box-shadow: var(--shadow-lg);
  padding: 16px 20px 32px;
  overflow-y: auto;
  transition: transform var(--transition-spring);
}
.modal-sheet.active {
  transform: translateX(-50%) translateY(0);
}

.sheet-handle {
  width: 42px;
  height: 4px;
  border-radius: var(--r-full);
  background: var(--ink-faint);
  margin: 0 auto 14px;
  opacity: 0.6;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.sheet-title {
  font-family: var(--font-display);
  font-size: var(--fs-lg);
  font-weight: 700;
  color: var(--ink-primary);
}
.sheet-close-btn {
  background: var(--surface-sunken);
  border: 1px solid var(--border-subtle);
  color: var(--ink-secondary);
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
