/* The frame around every page: header, nav, page headings, banners. */

body.auth-locked { overflow: hidden; }
body.auth-locked .app-header,
body.auth-locked .app-nav,
body.auth-locked #view { visibility: hidden; }

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 1rem;
  padding: 1rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  background: linear-gradient(135deg, #0f172a, #334155);
  color: white;
  box-shadow: var(--shadow);
}
.brand { min-width: 0; }
.eyebrow { margin: 0; color: #cbd5e1; }
.status-panel { display: flex; flex-direction: column; gap: .35rem; align-items: flex-end; }
.status-pill-row { display: flex; align-items: center; justify-content: flex-end; gap: .4rem; flex-wrap: wrap; }
.pill {
  border: 1px solid rgba(255, 255, 255, .3);
  border-radius: 999px;
  padding: .35rem .7rem;
  background: rgba(255, 255, 255, .08);
  font-size: .85rem;
}
.pill-offline { background: #fef3c7; border-color: #f59e0b; color: #78350f; font-weight: 700; }
/* What has not synced: the open day's, or this device's (a link to Setup). */
.sync-slot { display: contents; }
.sync-pill { color: inherit; text-decoration: none; font: inherit; font-size: .85rem; min-height: 0; cursor: default; }
a.sync-pill, button.sync-pill { cursor: pointer; }
.sync-pill.tone-ok { border-color: rgba(134, 239, 172, .55); }
.sync-pill.tone-pending { background: #e0e7ff; border-color: #a5b4fc; color: #1e1b4b; font-weight: 700; }
.sync-pill.tone-warn { background: #fef3c7; border-color: #f59e0b; color: #78350f; font-weight: 700; }
.sync-pill.tone-error { background: #fee2e2; border-color: #f87171; color: #7f1d1d; font-weight: 700; }
/* Field view has no header; the nav takes the top. */
body.no-header .app-header { display: none; }
body.no-header .app-nav { margin-top: max(.5rem, env(safe-area-inset-top)); }
/* The sync pill in the nav (Field view), on white. */
.app-nav .sync-pill { white-space: nowrap; border-color: var(--border); background: #f8fafc; color: var(--text); min-height: 44px; display: inline-flex; align-items: center; }
.app-nav .sync-pill.tone-ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; font-weight: 700; }
/* A page that wants the room (the day) keeps only the pills. */
body.compact-header .app-header { padding-top: max(.45rem, env(safe-area-inset-top)); padding-bottom: .45rem; justify-content: flex-end; }
body.compact-header .brand { display: none; }
body.compact-header .status-panel { flex-direction: row; align-items: center; }
.pill-site { background: var(--switch); border-color: #a5b4fc; font-weight: 700; }
.auth-user-pill { max-width: 11rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status-panel .muted { color: #cbd5e1; }

/* The nav sits under the header and stays in reach while a long page scrolls. */
.app-nav {
  position: sticky;
  top: 0;
  z-index: 8;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .55rem;
  max-width: 2200px;
  margin: 1rem auto 0;
  width: calc(100% - 2rem);
  padding: .6rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 1rem;
  box-shadow: var(--shadow);
}
.tab-row {
  display: flex;
  flex-wrap: nowrap;
  gap: .55rem;
  align-items: center;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.tab-btn {
  border-radius: .8rem;
  padding: .75rem .95rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  background: #f1f5f9;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .06);
}
.tab-btn.active { background: var(--header); box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .08); }
.icon-btn {
  flex: none;
  width: 48px;
  min-width: 48px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: .8rem;
  background: #e2e8f0;
  color: var(--text);
}
.icon-btn .icon { width: 1.55rem; height: 1.55rem; }
.setup-button.active { background: var(--header); box-shadow: inset 0 0 0 1px rgba(15, 23, 42, .12); }
/* A page's own symbol buttons, beside the cog (the locks, a day's previous
   and next). */
.nav-end, .nav-page-actions, .page-nav-actions, .nav-page-start, .day-toolbar { display: flex; align-items: center; gap: .4rem; }
.nav-page-start:empty, .nav-page-centre:empty { display: none; }
.nav-page-centre { flex: 1 1 auto; min-width: 0; display: flex; justify-content: center; }
.nav-end { gap: .55rem; }
a.icon-btn { text-decoration: none; }
/* A page's own symbol buttons beside its compact buttons. */
.icon-btn.compact-icon { width: 44px; min-width: 44px; min-height: 36px; border-radius: .65rem; }
.icon-btn.compact-icon .icon { width: 1.35rem; height: 1.35rem; }
.icon-btn.switch-icon { background: var(--switch); color: white; }
/* Refresh spins while it reads. */
.refresh-btn.is-busy:disabled { opacity: 1; }
.refresh-btn.is-busy .icon { animation: refresh-spin .9s linear infinite; }
@keyframes refresh-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .refresh-btn.is-busy .icon { animation: none; opacity: .5; }
}

/* A plan opened has a tab of its own after the others until its × closes it,
   set off from them by a rule. */
.plan-tabs { display: contents; }
.plan-tabs:not(:empty)::before { content: ""; align-self: stretch; width: 1px; margin: .3rem .1rem; background: var(--border); }
.tab-btn.plan-tab { padding: 0; }
.plan-tab-link {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  max-width: 12rem;
  padding: .75rem .3rem .75rem .95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: inherit;
  text-decoration: none;
}
.plan-tab-close {
  width: 32px;
  min-width: 32px;
  min-height: 32px;
  margin-right: .4rem;
  padding: 0;
  border-radius: .6rem;
  background: transparent;
  color: var(--label);
}
.plan-tab-close:hover { background: rgba(15, 23, 42, .1); color: var(--text); }
.plan-tab-close .icon { width: 1.1rem; height: 1.1rem; }
.icon-btn.is-disabled { opacity: .4; pointer-events: none; }
.icon-btn.lock-button.unlocked { background: #fee2e2; color: #b91c1c; box-shadow: inset 0 0 0 1px rgba(185, 28, 28, .3); }

.page-heading {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 1rem;
  margin-bottom: .85rem;
}
.placeholder p { max-width: 42rem; }
.placeholder .button-like { margin-top: 1rem; }
.empty-state { margin: 0; }

.plan-list { display: flex; flex-direction: column; gap: .5rem; margin-top: .5rem; }
.plan-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: .25rem .75rem;
  padding: .75rem .9rem;
  border: 1px solid var(--border);
  border-radius: .75rem;
  background: #f8fafc;
  color: inherit;
  text-decoration: none;
}
/* Apart: a selector list holding :focus-visible is dropped whole before Safari 15.4. */
.plan-row:hover { border-color: #94a3b8; background: #eef2f7; }
.plan-row:focus-visible { border-color: #94a3b8; background: #eef2f7; }
.plan-row .small-note { margin: 0; }

.update-banner {
  position: fixed;
  left: 50%;
  bottom: max(1rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 9000;
  display: flex;
  align-items: center;
  gap: 1rem;
  width: max-content;
  max-width: calc(100vw - 2rem);
  padding: .6rem .6rem .6rem 1rem;
  border-radius: 1rem;
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .25);
}
.update-banner button { background: var(--header); color: var(--text); min-height: 40px; }

@media (max-width: 760px) {
  .app-header { flex-direction: column; gap: .5rem; }
  .status-panel { align-items: flex-start; }
  .status-pill-row { justify-content: flex-start; }
  .app-nav { width: calc(100% - 1rem); margin-top: .5rem; align-items: flex-start; }
  .container { padding: .5rem; }
  /* Wrapped rather than scrolled: a tab off the edge is a tab nobody finds. */
  .tab-row { flex-wrap: wrap; overflow-x: visible; }
  .plan-tabs:not(:empty)::before { display: none; }
  /* A page's buttons and the cog take a row of their own. */
  .app-nav { flex-wrap: wrap; }
  .nav-end { margin-left: auto; }
  .nav-page-centre { order: 3; flex-basis: 100%; }
  .tab-btn { padding: .6rem .75rem; }
}
