* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--cream-100);
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 90% 2%, rgba(210, 142, 46, .12), transparent 240px),
    var(--cream-100);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
  color: inherit;
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: .48;
}

a {
  color: inherit;
  text-decoration: none;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.app-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  justify-content: space-between;
  min-height: calc(var(--header-height) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 18px 0;
  background: rgba(250, 246, 239, .9);
  border-bottom: 1px solid rgba(47, 70, 51, .08);
  backdrop-filter: blur(18px);
}

.app-header .brand { justify-self: start; }
.app-header .version-pill { justify-self: end; }
.current-section-title { text-align: center; font-size: 18px; line-height: 1.25; color: var(--forest-900); }
@media (max-width: 560px) {
  .app-header .brand span { display: none; }
  .app-header .version-pill { padding-inline: 6px; font-size: 9px; }
}

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

.brand img {
  border: 1px solid rgba(47, 70, 51, .12);
  border-radius: 11px;
  box-shadow: var(--shadow-sm);
}

.brand span {
  display: grid;
  line-height: 1.05;
}

.brand strong {
  color: var(--forest-800);
  font-size: 17px;
  letter-spacing: .02em;
}

.brand small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.version-pill {
  padding: 5px 9px;
  color: var(--amber-600);
  background: rgba(210, 142, 46, .09);
  border: 1px solid rgba(189, 116, 27, .2);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.app-view {
  width: min(100%, var(--content-width));
  min-height: calc(100vh - var(--header-height));
  margin: 0 auto;
  padding: 20px 16px calc(var(--nav-height) + env(safe-area-inset-bottom) + 26px);
}

.bottom-nav {
  position: fixed;
  z-index: 30;
  right: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  height: calc(var(--nav-height) + env(safe-area-inset-bottom));
  padding: 5px max(10px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(10px, env(safe-area-inset-left));
  background: rgba(252, 250, 246, .96);
  border-top: 1px solid var(--cream-300);
  backdrop-filter: blur(20px);
}

.bottom-nav a[hidden] { display: none; }
body[data-access-mode="archive"] .bottom-nav { grid-template-columns: repeat(3, 1fr); }
body[data-access-mode="archive"] [data-context-action] { display: none; }

.bottom-nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  color: var(--muted);
  border-radius: 12px;
}

.bottom-nav a > span {
  font-size: 21px;
  line-height: 1;
}

.bottom-nav a small {
  overflow: hidden;
  max-width: 100%;
  font-size: 9px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav a.is-active {
  color: var(--forest-800);
  background: var(--forest-100);
}

.loading-state {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 55vh;
  color: var(--muted);
  font-size: 14px;
}

.loading-dot {
  width: 10px;
  height: 10px;
  background: var(--amber-500);
  border-radius: 50%;
  animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
  to { transform: scale(.55); opacity: .45; }
}

@media (min-width: 760px) {
  .app-header {
    padding-right: max(24px, calc((100vw - var(--content-width)) / 2));
    padding-left: max(24px, calc((100vw - var(--content-width)) / 2));
  }

  .bottom-nav {
    right: calc((100vw - var(--content-width)) / 2);
    left: calc((100vw - var(--content-width)) / 2);
    border: 1px solid var(--cream-300);
    border-bottom: none;
    border-radius: 20px 20px 0 0;
    box-shadow: var(--shadow-md);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}
