/* Persistent application shell: loading state, masthead, workspace, and page mounts. */

#loadingOverlay {
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, var(--blue) 100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  gap: 16px;
  transition: opacity 0.4s ease;
}

#loadingOverlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.loader-logo {
  font-family: 'Playfair Display', serif;
  font-size: 1.4rem;
  color: #fff;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.loader-sub {
  font-size: 0.82rem;
  color: var(--accent-light);
  max-width: 360px;
  padding: 0 20px;
  line-height: 1.5;
  text-align: center;
}

.loader-retry { margin-top: 4px; }
.loader-retry[hidden] { display: none; }
.loader-sign-out[hidden] { display: none; }

#loadingOverlay.load-error .loader-spinner { display: none; }

.loader-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255,255,255,0.2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin-bottom: 8px;
}

@keyframes spin { to { transform: rotate(360deg); } }

header {
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 60%, var(--blue) 100%);
  padding: 36px 48px 32px;
  position: relative;
  overflow: hidden;
}

header::before {
  content: '';
  position: absolute;
  top: -80px;
  right: -80px;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: rgba(200,169,110,0.08);
}

header::after {
  content: '';
  position: absolute;
  bottom: -60px;
  left: 30%;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(30,77,140,0.3);
}

.header-inner {
  position: relative;
  z-index: 1;
  max-width: 1300px;
  margin: 0 auto;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.header-text { width: 100%; }
.header-app-mark { display: none; }

.header-text h1 {
  font-family: 'Playfair Display', serif;
  font-size: 2rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
}

.header-text p {
  color: var(--accent-light);
  font-size: 0.9rem;
  font-weight: 400;
  letter-spacing: 0.3px;
}

.header-bottom-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
}

.header-plan-selector {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}
.header-plan-selector[hidden] { display: none; }
.header-plan-selector label {
  color: var(--accent-light);
}
.header-plan-selector select {
  min-width: 150px;
  max-width: 240px;
  min-height: 34px;
  padding: 5px 30px 5px 10px;
  border-color: rgba(255,255,255,0.28);
  background-color: rgba(255,255,255,0.12);
  color: #fff;
}
.header-plan-selector select:focus {
  border-color: var(--accent-light);
  background-color: rgba(255,255,255,0.18);
}
.header-plan-selector select option {
  background: var(--color-surface);
  color: var(--color-action);
}

.header-actions-right {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-edit-actions,
.header-utility-actions { display: contents; }

.btn.header-account {
  display: none;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: rgba(255,255,255,0.8);
}

.header-account:not(:disabled):hover,
.header-account.active {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.3);
  color: #fff;
}

@media (min-width: 1025px) {
  .header-actions-right { display: none; }
  .btn.header-account-wide { display: inline-flex; }
  /* A long name must not push the header's other actions out. */
  .header-account .btn-label {
    max-width: 16ch;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.disclaimer {
  background: rgba(200,169,110,0.15);
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  margin-top: 16px;
  border-radius: 4px;
  font-size: var(--font-size-supporting);
  color: var(--accent-light);
  line-height: 1.5;
}

.disclaimer-pill {
  background: rgba(200,169,110,0.15);
  border: 1px solid rgba(200,169,110,0.3);
  color: var(--accent-light);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: var(--font-size-supporting);
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background 0.15s;
}
.disclaimer-pill:hover { background: rgba(200,169,110,0.25); }

.disclaimer-full {
  display: block;
  background: rgba(200,169,110,0.15);
  border-left: 3px solid var(--accent);
  padding: 10px 16px;
  margin-top: 10px;
  border-radius: 4px;
  font-size: var(--font-size-supporting);
  color: var(--accent-light);
  line-height: 1.5;
  max-width: 600px;
}
.disclaimer-full[hidden] { display: none; }

.main {
  max-width: 1300px;
  margin: 0 auto;
  padding: 32px 24px;
}

.app-shell {
  /* Flex lets the navigation rail animate its own width reliably. */
  display: flex;
  gap: 18px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.scroll-cue-frame {
  position: relative;
  min-height: 0;
}
.scroll-cue-frame::before,
.scroll-cue-frame::after {
  content: '';
  position: absolute;
  z-index: 2;
  right: 0;
  left: 0;
  height: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}
.scroll-cue-frame::before {
  top: 0;
  background: linear-gradient(to bottom, var(--scroll-cue-color) 0%, transparent 100%);
}
.scroll-cue-frame::after {
  bottom: 0;
  background: linear-gradient(to top, var(--scroll-cue-color) 0%, transparent 100%);
}
.scroll-cue-frame.can-scroll-up::before,
.scroll-cue-frame.can-scroll-down::after {
  opacity: 1;
}

.planner-workspace-frame {
  --scroll-cue-color: var(--color-page);
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.planner-workspace {
  height: 100%;
  overflow-y: auto;
  padding-right: 2px;
  scrollbar-gutter: stable;
  scrollbar-width: thin;
}

/* Whose plan a shared session (#290 B3b) is looking at, above every page. */
.shared-access-banner {
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
}

.shared-access-banner[hidden] {
  display: none;
}

.shared-access-banner p {
  margin: 0;
}

.content-page {
  display: none;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}
.content-page.active { display: flex; }

.page-heading {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 2px 0 0;
}
.page-kicker { margin: 0 0 var(--space-1); }
.page-heading h2 {
  margin: 0;
}

@media (prefers-reduced-motion: reduce) {
  .scroll-cue-frame::before,
  .scroll-cue-frame::after {
    transition: none;
  }
}

/* The fixed rail needs wide-screen workspace room. Portrait tablets keep the
   document-scrolling drawer shell but may retain multi-column page content. */
@media (min-width: 1025px) {
  html { overflow-y: scroll; }
  body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
  }
  .main {
    flex: 1;
    min-height: 0;
    min-width: 0;
    width: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    padding: 24px;
  }
}

/* Standard laptop screens have desktop width but materially less vertical
   room. Compact the shell before making the navigation itself scroll. */
@media (min-width: 1025px) and (max-height: 1000px) {
  header { padding: 18px 48px 14px; }
  .main { padding: 12px 24px; }
}

@media (min-width: 1025px) and (max-height: 800px) {
  header {
    padding-top: 12px;
    padding-bottom: 10px;
  }
  .main {
    padding-top: 6px;
    padding-bottom: 6px;
  }
}

@media (max-width: 1024px) {
  body {
    display: block;
    min-height: 100vh;
    overflow: auto;
  }
  header {
    position: sticky;
    top: 0;
    z-index: 200;
    padding: 20px 16px 16px;
  }
  .header-text h1 {
    font-size: 1.4rem;
    margin-bottom: 4px;
    letter-spacing: -0.3px;
  }
  .header-inner { gap: 8px; }
  .header-bottom-row { flex-wrap: wrap; }
  .disclaimer-pill {
    flex: 1 1 0;
    min-width: 0;
    justify-content: center;
    text-align: center;
  }
  .header-actions-right { flex: 0 0 auto; }
  .header-plan-selector {
    order: 3;
    flex: 1 0 100%;
    margin: 2px 0 0;
  }
  .header-plan-selector select {
    flex: 1;
    max-width: none;
    min-height: 44px;
  }
  .disclaimer {
    font-size: var(--font-size-supporting);
    padding: 8px 12px;
    margin-top: 10px;
    line-height: 1.45;
  }
  .disclaimer-pill { padding: 5px 12px; margin-top: 0; }
  .disclaimer-full { padding: 8px 12px; max-width: 100%; }

  .main {
    display: block;
    flex: 1;
    min-height: 0;
    overflow-y: visible;
    padding: 0 14px 96px;
  }
  .app-shell {
    display: block;
    overflow: visible;
  }
  .planner-workspace-frame {
    min-height: auto;
    overflow: visible;
  }
  .planner-workspace {
    height: auto;
    overflow: visible;
    padding: 10px 0 0;
  }
  .scroll-cue-frame::before,
  .scroll-cue-frame::after {
    display: none;
  }
  .content-page { gap: var(--space-4); }
  .page-heading { padding: 4px 0 0; }
}

@media (max-width: 767px) {
  header { padding: 5px 12px 8px; }
  .header-text {
    display: grid;
    grid-template-columns: 24px minmax(0, 1fr);
    align-items: center;
    column-gap: 8px;
    row-gap: 5px;
  }
  .header-text h1 {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .header-app-mark {
    display: block;
    grid-column: 1;
    grid-row: 1;
    width: 24px;
    height: 24px;
    color: var(--accent);
    fill: currentColor;
  }
  .header-bottom-row { display: contents; }
  .header-actions-right {
    grid-column: 1 / -1;
    grid-row: 2;
    width: 100%;
    justify-content: space-between;
  }
  .header-edit-actions,
  .header-utility-actions {
    display: flex;
    align-items: center;
    gap: 7px;
  }
  .disclaimer-pill {
    grid-column: 2;
    grid-row: 1;
    width: max-content;
    max-width: 100%;
    min-height: 20px;
    padding: 0;
    border: 0;
    background: transparent;
    justify-content: flex-start;
    text-align: left;
    white-space: nowrap;
    font-size: 0.8125rem;
    line-height: 20px;
  }
  .header-plan-selector {
    grid-column: 1 / -1;
    grid-row: 3;
    min-width: 0;
    margin: 0;
  }
  .header-plan-selector label { display: none; }
  .header-plan-selector select { width: 100%; }
  .disclaimer-full {
    grid-column: 1 / -1;
    grid-row: 4;
    margin-top: 0;
  }
}
