:root {
  --navy: #082f52;
  --navy-soft: #174365;
  --gold: #b99045;
  --gold-soft: #dcc17f;
  --cream: #fff8ed;
  --surface: #fffdf8;
  --surface-strong: #ffffff;
  --ink: #16324a;
  --muted: #657686;
  --line: rgba(185, 144, 69, 0.24);
  --shadow: 0 14px 34px rgba(8, 47, 82, 0.11);
  --radius-lg: 26px;
  --radius-md: 20px;
  --safe-bottom: env(safe-area-inset-bottom);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--cream);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
svg {
  display: block;
  width: 1.25rem;
  height: 1.25rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.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;
}

.app-frame {
  min-height: 100vh;
  padding-bottom: calc(92px + var(--safe-bottom));
  background:
    radial-gradient(circle at 10% 0%, rgba(220, 193, 127, 0.22), transparent 32%),
    linear-gradient(180deg, #fff8ed 0%, #fff5e7 48%, #f4ead9 100%);
}

.top-app-bar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 70px;
  padding: max(12px, env(safe-area-inset-top)) 18px 12px;
  border-bottom: 1px solid rgba(185, 144, 69, 0.18);
  background: rgba(255, 248, 237, 0.88);
  backdrop-filter: blur(18px);
}

.app-brand {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  gap: 11px;
  text-decoration: none;
}

.app-brand img {
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  border-radius: 14px;
  box-shadow: 0 8px 18px rgba(8, 47, 82, 0.12);
}

.app-brand strong,
.app-brand em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-brand strong {
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
  line-height: 1.1;
}

.app-brand em {
  margin-top: 2px;
  color: var(--gold);
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.icon-button {
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 15px;
  background: var(--navy);
  color: var(--cream);
  font-size: 1.25rem;
  font-weight: 900;
  cursor: pointer;
}

.app-main {
  width: min(760px, 100%);
  margin: 0 auto;
  padding: 16px 16px 4px;
}

.app-view { display: none; }
.app-view.is-active {
  display: grid;
  gap: 18px;
}

.companion-hero,
.welcome-card,
.about-card {
  overflow: hidden;
  position: relative;
  padding: 24px;
  border: 1px solid rgba(185, 144, 69, 0.22);
  border-radius: var(--radius-lg);
  background:
    linear-gradient(135deg, rgba(8, 47, 82, 0.95), rgba(18, 74, 105, 0.93)),
    var(--navy);
  color: var(--cream);
  box-shadow: var(--shadow);
}

.companion-hero {
  display: grid;
  min-height: 360px;
  align-content: end;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  border-color: rgba(8, 47, 82, 0.08);
  background:
    linear-gradient(180deg, rgba(8, 47, 82, 0.08) 0%, rgba(8, 47, 82, 0.2) 42%, rgba(8, 47, 82, 0.84) 100%),
    url("../assets/community-hero-background.jpeg") center / cover no-repeat;
  color: #fffdf8;
  text-align: center;
}

.welcome-card::after,
.about-card::after {
  content: "";
  position: absolute;
  right: -42px;
  top: -52px;
  width: 150px;
  height: 150px;
  border: 1px solid rgba(220, 193, 127, 0.28);
  border-radius: 50%;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--gold-soft);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2, h3 {
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
}

.companion-hero h1,
.welcome-card h1,
.about-card h2 {
  position: relative;
  margin: 0 0 12px;
  color: #fffdf8;
  font-size: clamp(2.05rem, 10vw, 3.4rem);
  line-height: 0.98;
}

.companion-hero h1 {
  max-width: 12ch;
  text-shadow: 0 2px 18px rgba(8, 47, 82, 0.36);
}

.companion-hero .eyebrow {
  position: relative;
  margin: 0;
  color: #f1d99b;
  text-shadow: 0 2px 12px rgba(8, 47, 82, 0.35);
}

.companion-hero p:last-child {
  position: relative;
  max-width: 30rem;
  margin: 0;
  color: rgba(255, 253, 248, 0.9);
  font-size: 1rem;
  line-height: 1.52;
  text-shadow: 0 2px 12px rgba(8, 47, 82, 0.35);
}

.welcome-card p:last-child,
.about-card p {
  position: relative;
  max-width: 34rem;
  margin: 0;
  color: rgba(255, 253, 248, 0.86);
  font-size: 1rem;
  line-height: 1.52;
}

.today-section {
  display: grid;
  gap: 12px;
}

.today-grid {
  display: grid;
  gap: 12px;
}

.today-card {
  position: relative;
  display: grid;
  min-height: 188px;
  overflow: hidden;
  align-items: end;
  border: 1px solid rgba(8, 47, 82, 0.11);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: 0 12px 26px rgba(8, 47, 82, 0.08);
  text-decoration: none;
}

.today-card img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.today-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(8, 47, 82, 0.04) 0%, rgba(8, 47, 82, 0.2) 42%, rgba(8, 47, 82, 0.86) 100%);
}

.today-card span {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 5px;
  padding: 18px;
  justify-items: center;
  text-align: center;
}

.today-card em {
  color: #efd18b;
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.today-card strong {
  color: #fffdf8;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.25rem;
  line-height: 1.1;
}

.today-card small {
  color: rgba(255, 253, 248, 0.86);
  font-size: 0.9rem;
  line-height: 1.38;
}

.home-search,
.search-card {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 58px;
  padding: 0 16px;
  border: 1px solid rgba(8, 47, 82, 0.12);
  border-radius: 19px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 26px rgba(8, 47, 82, 0.08);
}

.home-search .search-icon,
.search-card .search-icon {
  flex: 0 0 auto;
  color: var(--gold);
}

.home-search input,
.search-card input {
  width: 100%;
  min-width: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font-size: 1rem;
  outline: none;
}

.section-heading,
.screen-heading {
  display: grid;
  gap: 4px;
}

.section-heading h2,
.screen-heading h2 {
  margin: 0;
  color: var(--navy);
  line-height: 1.08;
}

.section-heading h2 { font-size: 1.4rem; }
.screen-heading h2 { font-size: clamp(2rem, 9vw, 3rem); }
.screen-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.quick-card {
  display: grid;
  min-height: 190px;
  overflow: hidden;
  align-content: stretch;
  gap: 0;
  padding: 0;
  border: 1px solid rgba(185, 144, 69, 0.22);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.92);
  box-shadow: 0 12px 24px rgba(8, 47, 82, 0.07);
  text-decoration: none;
}

.quick-card img {
  width: 100%;
  height: 106px;
  object-fit: cover;
}

.quick-card > span {
  display: grid;
  gap: 6px;
  padding: 13px 14px 15px;
  justify-items: center;
  text-align: center;
}

.quick-card span,
.card-icon {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 15px;
  background: rgba(185, 144, 69, 0.14);
  color: var(--navy);
  font-weight: 900;
}

.quick-card > span {
  display: grid;
  width: auto;
  height: auto;
  place-items: center;
  border-radius: 0;
  background: transparent;
}

.quick-card svg,
.card-icon svg {
  width: 22px;
  height: 22px;
}

.quick-card strong {
  color: var(--navy);
  font-size: 1rem;
  line-height: 1.2;
}

.quick-card small,
.app-list-card small,
.empty-card span {
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.chip-row {
  display: flex;
  gap: 9px;
  margin: 0 -16px;
  overflow-x: auto;
  padding: 0 16px 4px;
  scrollbar-width: none;
}

.chip-row::-webkit-scrollbar { display: none; }

.chip-row button {
  flex: 0 0 auto;
  min-height: 42px;
  padding: 0 15px;
  border: 1px solid rgba(185, 144, 69, 0.28);
  border-radius: 999px;
  background: rgba(255, 253, 248, 0.86);
  color: var(--navy);
  font-weight: 900;
  cursor: pointer;
}

.chip-row button.is-active {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--cream);
}

.list-stack {
  display: grid;
  gap: 12px;
}

.app-list-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: stretch;
  padding: 12px;
  border: 1px solid rgba(8, 47, 82, 0.11);
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 10px 24px rgba(8, 47, 82, 0.06);
}

.card-main {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  min-width: 0;
  text-decoration: none;
}

.app-list-card em,
.app-list-card strong,
.app-list-card small {
  display: block;
}

.app-list-card em {
  margin: 1px 0 3px;
  color: var(--gold);
  font-size: 0.66rem;
  font-style: normal;
  font-weight: 900;
  letter-spacing: 0.1em;
  line-height: 1.25;
  text-transform: uppercase;
}

.app-list-card strong {
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  line-height: 1.18;
}

.save-button {
  display: inline-grid;
  place-items: center;
  width: 44px;
  min-height: 44px;
  border: 0;
  border-radius: 16px;
  background: rgba(8, 47, 82, 0.06);
  color: var(--navy);
  cursor: pointer;
}

.save-button svg {
  width: 20px;
  height: 20px;
}

.save-button svg.filled {
  fill: currentColor;
}

.save-button.is-saved {
  background: rgba(185, 144, 69, 0.18);
  color: #9a722e;
}

.result-summary {
  min-height: 22px;
  margin: -5px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.empty-card {
  display: grid;
  gap: 6px;
  padding: 20px;
  border: 1px dashed rgba(185, 144, 69, 0.34);
  border-radius: var(--radius-md);
  background: rgba(255, 253, 248, 0.72);
}

.empty-card strong {
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.2rem;
}

.offline-banner {
  display: grid;
  gap: 4px;
  padding: 14px 16px;
  border: 1px solid rgba(185, 144, 69, 0.32);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.95);
  box-shadow: 0 10px 24px rgba(8, 47, 82, 0.06);
}

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

.offline-banner strong {
  color: var(--navy);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.08rem;
}

.offline-banner span {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.4;
}

.about-card {
  display: grid;
  justify-items: start;
  gap: 10px;
}

.about-card img {
  position: relative;
  width: 74px;
  height: 74px;
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.98);
}

.about-links {
  position: relative;
  display: grid;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
}

.about-links a {
  display: flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid rgba(220, 193, 127, 0.32);
  border-radius: 16px;
  background: rgba(255, 253, 248, 0.12);
  color: #fffdf8;
  font-weight: 900;
  text-decoration: none;
}

.bottom-nav {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 12;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  padding: 7px 6px calc(7px + var(--safe-bottom));
  border-top: 1px solid rgba(185, 144, 69, 0.22);
  background: rgba(255, 253, 248, 0.95);
  box-shadow: 0 -12px 26px rgba(8, 47, 82, 0.10);
  backdrop-filter: blur(18px);
}

.bottom-nav button,
.bottom-nav a {
  display: grid;
  min-width: 0;
  min-height: 56px;
  place-items: center;
  gap: 2px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  text-decoration: none;
}

.bottom-nav svg {
  width: 21px;
  height: 21px;
  stroke-width: 1.85;
}

.bottom-nav strong {
  overflow: hidden;
  max-width: 100%;
  font-size: 0.64rem;
  font-weight: 900;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav button.is-active,
.bottom-nav a.is-active {
  background: rgba(8, 47, 82, 0.09);
  color: var(--navy);
}

@media (min-width: 680px) {
  .app-main {
    padding: 24px;
  }

  .quick-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .today-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .companion-hero {
    min-height: 430px;
    padding: 32px;
  }

  .quick-card {
    min-height: 210px;
  }

  .quick-card img {
    height: 122px;
  }

  .bottom-nav {
    right: max(18px, calc((100vw - 760px) / 2));
    bottom: 18px;
    left: max(18px, calc((100vw - 760px) / 2));
    border: 1px solid rgba(185, 144, 69, 0.22);
    border-radius: 26px;
  }
}

@media (max-width: 374px) {
  .app-main {
    padding-right: 12px;
    padding-left: 12px;
  }

  .quick-grid {
    grid-template-columns: 1fr;
  }

  .bottom-nav {
    gap: 1px;
    padding-right: 3px;
    padding-left: 3px;
  }

  .bottom-nav button,
  .bottom-nav a {
    min-height: 54px;
    border-radius: 15px;
  }

  .bottom-nav svg {
    width: 19px;
    height: 19px;
  }

  .bottom-nav strong {
    font-size: 0.58rem;
  }
}
