/* ── Header ── */

/* Small screens: brand + actions on the first row, the tab bar as an
   edge-to-edge second row. From 768px up the three groups merge into a
   single bar (brand · tabs · actions) — see the media query below. */
.app-header {
  background: var(--header-bg);
  color: var(--header-text);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--border);
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px 16px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  column-gap: 12px;
}

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

.brand-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  color: var(--brand);
}

.brand-icon svg {
  width: 100%;
  height: 100%;
}

.brand-name {
  font-family: var(--font-brand);
  font-size: 1.2rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  overflow: hidden;
  padding: 0;
  border: none;
  cursor: pointer;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ── Sync indicator ── */

.sync-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* Resting arrows: Arpynt green at full strength, so the control is visible
   at rest and the user can learn where it lives. The chrome is
   surface-coloured, so --brand reads directly against it. */
.sync-arrows {
  display: flex;
  align-items: center;
  gap: 1px;
  color: var(--brand);
  position: relative;
}

.sync-arrow {
  display: flex;
  transition: color 120ms ease-out, opacity 120ms ease-out;
}

/* Two 15px arrows sit in roughly the footprint the single 20px cloud had,
   so the header actions row keeps its spacing. */
.sync-arrow .sync-icon {
  width: 15px;
  height: 15px;
}

/* Only the direction actually moving lights up. Colour alone is a weak
   signal at this size, so the lit arrow also gains prominence by dimming
   its partner — otherwise "uploading" can read as *less* emphatic than
   idle. */
.sync-arrow.active {
  color: var(--accent);
  animation: sync-pulse 1.6s ease-in-out infinite;
}

.sync-btn.transferring .sync-arrow:not(.active) {
  opacity: 0.35;
}

/* Parked, not moving: the queue is stuck behind a quota, so a pulse would
   misleadingly suggest progress. */
.sync-btn.quota .sync-arrow.active {
  animation: none;
}

/* Offline: neither direction can make progress, so the pair drops to a
   neutral gray and nothing pulses regardless of what is queued. Colour
   alone is too weak to read in isolation (the user never sees online and
   offline side by side), so a slash crosses the pair as well. */
.sync-btn.offline .sync-arrows {
  color: var(--text-subtle);
}

.sync-btn.offline .sync-arrows::after {
  content: "";
  position: absolute;
  left: -2px;
  right: -2px;
  top: 50%;
  height: 1.5px;
  border-radius: 2px;
  background: currentColor;
  transform: rotate(-22deg);
}

/* Shallower than the old cloud's pulse: the arrow must stay clearly
   brighter than its dimmed partner at every point in the cycle. */
@keyframes sync-pulse {
  0%, 100% { opacity: 0.72; }
  50%      { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .sync-arrow.active {
    animation: none;
  }
}

.sync-badge {
  position: relative;
  display: flex;
  align-items: center;
}

/* Quota-parked: the queue is stuck rather than draining. The dot marks it
   without needing a colour that reads as distinct from --accent (the two
   tokens are the same amber). The QuotaBanner carries the explanation. */
.sync-warn-dot {
  position: absolute;
  bottom: -1px;
  left: -6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--warning);
  box-shadow: 0 0 0 1.5px var(--header-bg);
}

.sync-count {
  position: absolute;
  top: -6px;
  right: -8px;
  background: var(--warning);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  border-radius: 50%;
  min-width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ── Tab bar ── */

/* Second header row on small screens: full-bleed via negative margins so
   the hairline divider spans the viewport regardless of .header-inner
   padding. */
.tab-bar {
  order: 3;
  width: calc(100% + 32px);
  margin: 8px -16px 0;
  display: flex;
  border-top: 1px solid var(--border);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 12px 0;
  min-height: 44px;
  cursor: pointer;
  transition: color 0.15s, box-shadow 0.15s;
}

.tab-btn:hover {
  color: var(--text);
}

.tab-btn.active {
  color: var(--brand);
  box-shadow: inset 0 -2px 0 var(--brand);
}

/* Single merged bar from 768px up: brand · centred tabs · actions. */
@media (min-width: 768px) {
  .header-inner {
    padding: 8px 16px;
    flex-wrap: nowrap;
  }

  .tab-bar {
    order: 0;
    flex: 1;
    width: auto;
    margin: -8px 0;   /* stretch tabs to the full bar height */
    align-self: stretch;
    justify-content: center;
    gap: 4px;
    border-top: none;
  }

  .tab-btn {
    flex: 0 1 auto;
    padding: 0 14px;
    min-height: 0;
  }
}

.tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--brand);
  color: #fff;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  padding: 0 4px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ── Upload button ── */

.upload-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}

.upload-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--brand);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  transition: background 0.15s;
}

.upload-btn:hover {
  background: var(--brand-hover);
}

.upload-btn .at-icon {
  width: 20px;
  height: 20px;
  vertical-align: 0;
}

/* ── Passkey re-enrol banner ──
   App-wide, persistent until the user enrols a new passkey (driven by the
   durable passkey_reenrol_pending flag). Amber/accent, not an error. */

.reenrol-banner {
  background: var(--accent-soft);
  border-bottom: 1px solid var(--accent);
  color: var(--text);
}

.reenrol-banner-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: 0.6rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.reenrol-banner-icon {
  flex: none;
  color: var(--accent-hover);
}

.reenrol-banner-text {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
  flex: 1 1 auto;
}

.reenrol-banner-text strong {
  font-size: 0.9rem;
  font-weight: 600;
}

.reenrol-banner-text span {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.reenrol-banner-cta {
  flex: none;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.reenrol-banner-cta:hover {
  background: var(--accent-hover);
}

/* ── Sync-engine failure banner ──
   Same layout as the re-enrol banner, but this one is an error: the worker
   is dead and nothing persists or syncs until the page is reloaded. */

.sync-failed-banner {
  background: var(--danger-soft);
  border-bottom-color: var(--danger);
}

.sync-failed-banner .reenrol-banner-icon {
  color: var(--danger);
}

.sync-failed-banner .reenrol-banner-cta {
  background: var(--danger);
}

.sync-failed-banner .reenrol-banner-cta:hover {
  background: var(--danger-hover);
}

/* ── Storage-quota banner ──
   Same layout again, warning-tinted: uploads are parked locally until the
   user frees space (or retries after freeing it elsewhere). */

.quota-banner {
  background: var(--warning-soft, var(--accent-soft));
  border-bottom-color: var(--warning);
}

.quota-banner .reenrol-banner-icon {
  color: var(--warning);
}

.quota-banner .reenrol-banner-cta {
  background: var(--warning);
}
