/* BioStack Mobile App Shell */
:root {
  --tab-h: 64px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (max-width: 767px) {
  body.app-shell { padding-bottom: calc(var(--tab-h) + var(--safe-b) + 8px); }
  .desktop-nav-links { display: none !important; }
  .mobile-bottom-nav {
    display: flex !important;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: calc(var(--tab-h) + var(--safe-b));
    padding-bottom: var(--safe-b);
    background: rgba(255,255,255,0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-top: 1px solid rgba(226,232,240,0.9);
    z-index: 100;
    justify-content: space-around;
    align-items: center;
  }
  .mobile-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 4px;
    font-size: 10px;
    font-weight: 600;
    color: #64748b;
    text-decoration: none;
    transition: color 0.2s;
  }
  .mobile-bottom-nav a.active { color: #1d4ed8; }
  .mobile-bottom-nav a svg { width: 22px; height: 22px; }
  .top-nav-compact .nav-extra { display: none; }
  main.app-main { padding-top: 1rem; padding-bottom: 1rem; }
}

@media (min-width: 768px) {
  .mobile-bottom-nav { display: none !important; }
}

/* iOS install hint */
.ios-install-hint {
  position: fixed;
  bottom: calc(var(--tab-h) + var(--safe-b) + 12px);
  left: 12px;
  right: 12px;
  z-index: 95;
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 13px;
  line-height: 1.45;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}
@media (min-width: 768px) {
  .ios-install-hint { bottom: 16px; max-width: 360px; left: auto; right: 16px; }
}
.ios-install-hint strong { color: #fff; }

/* Timeline stack */
.timeline-slot { position: relative; padding-left: 2rem; }
.timeline-slot::before {
  content: '';
  position: absolute;
  left: 11px; top: 2rem; bottom: -1rem;
  width: 2px;
  background: linear-gradient(to bottom, #3b82f6, #10b981);
  opacity: 0.25;
}
.timeline-slot:last-child::before { display: none; }
.timeline-dot {
  position: absolute;
  left: 0; top: 1.25rem;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: white;
  border: 3px solid #3b82f6;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  z-index: 1;
}
.intake-card.taken { opacity: 0.75; }
.intake-card.taken .take-btn { background: #d1fae5; color: #047857; }

/* Knowledge base modal */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(15,23,42,0.6);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: none;
  align-items: flex-end;
  justify-content: center;
  padding: 0;
}
.modal-backdrop.open { display: flex; }
@media (min-width: 768px) {
  .modal-backdrop { align-items: center; padding: 1rem; }
}
.modal-sheet {
  background: white;
  width: 100%;
  max-width: 560px;
  max-height: 92vh;
  overflow-y: auto;
  border-radius: 1.25rem 1.25rem 0 0;
  animation: slideUp 0.3s ease;
}
@media (min-width: 768px) {
  .modal-sheet { border-radius: 1.25rem; max-height: 85vh; }
}
@keyframes slideUp {
  from { transform: translateY(100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.video-placeholder {
  aspect-ratio: 9/16;
  max-height: 320px;
  background: linear-gradient(135deg, #1e293b 0%, #312e81 50%, #0f766e 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  position: relative;
  overflow: hidden;
}
.video-placeholder::after {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(255,255,255,0.03) 2px, rgba(255,255,255,0.03) 4px);
}
.filter-chip {
  white-space: nowrap;
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #e2e8f0;
  background: white;
  color: #64748b;
  cursor: pointer;
  transition: all 0.2s;
}
.filter-chip.active {
  background: #1d4ed8;
  color: white;
  border-color: #1d4ed8;
}
.streak-badge {
  background: linear-gradient(135deg, #f59e0b, #ef4444);
  color: white;
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 9999px;
}

.camera-btn {
  background: linear-gradient(135deg, #1d4ed8, #10b981);
  color: white;
  border: none;
  border-radius: 1rem;
  padding: 1rem;
  width: 100%;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

/* Dashboard day calendar (07:00–22:00) */
.day-calendar {
  display: flex;
  gap: 12px;
  min-height: 540px;
}
.day-calendar-labels {
  flex: 0 0 44px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  font-size: 10px;
  font-weight: 600;
  font-family: ui-monospace, monospace;
  color: #94a3b8;
  padding: 4px 0;
}
.day-calendar-track {
  position: relative;
  flex: 1;
  min-height: 540px;
  background: linear-gradient(to bottom, #f8fafc 0%, #f1f5f9 100%);
  border-radius: 1rem;
  border: 1px solid #e2e8f0;
  overflow: visible;
}
.day-calendar-track::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    to bottom,
    transparent,
    transparent calc(100% / 15 - 1px),
    rgba(148, 163, 184, 0.15) calc(100% / 15 - 1px),
    rgba(148, 163, 184, 0.15) calc(100% / 15)
  );
  pointer-events: none;
  border-radius: 1rem;
}
.day-calendar-item {
  position: absolute;
  left: 8px;
  right: 8px;
  transform: translateY(-50%);
  background: white;
  border: 1px solid #e2e8f0;
  border-left: 3px solid #3b82f6;
  border-radius: 12px;
  padding: 10px 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  cursor: grab;
  touch-action: none;
  user-select: none;
  z-index: 2;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.day-calendar-item:active,
.day-calendar-item.is-dragging {
  cursor: grabbing;
  box-shadow: 0 8px 24px rgba(59, 130, 246, 0.25);
  border-color: #3b82f6;
  z-index: 10;
}
.day-calendar-item.is-taken {
  border-left-color: #10b981;
  opacity: 0.85;
}
.day-calendar-item-time {
  font-size: 11px;
  font-weight: 700;
  font-family: ui-monospace, monospace;
  color: #1d4ed8;
  margin-bottom: 2px;
}
.day-calendar-item.is-taken .day-calendar-item-time { color: #059669; }
.day-calendar-item-name {
  font-size: 13px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
}
.day-calendar-item-dose {
  font-size: 11px;
  color: #64748b;
  margin-top: 2px;
}
.day-calendar-item-check {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 20px;
  height: 20px;
  background: #d1fae5;
  color: #047857;
  border-radius: 50%;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}
.day-calendar-item.is-saving { opacity: 0.6; pointer-events: none; }
