:root {
  color-scheme: light;
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-subtle: #eef3f7;
  --text: #18202b;
  --muted: #65758a;
  --line: #d7dee8;
  --accent: #0f766e;
  --accent-strong: #0a5f59;
  --coral: #ee6f61;
  --amber: #d99a2b;
  --ink: #112236;
  --danger: #9f1239;
  --shadow: 0 18px 46px rgba(17, 34, 54, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 12px 28px;
  border-bottom: 1px solid rgba(215, 222, 232, 0.78);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(16px);
}

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

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: var(--ink);
  color: #ffffff;
  font-size: 14px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 15px;
  line-height: 1.2;
}

.brand small {
  color: var(--muted);
  font-size: 12px;
}

.nav-links {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
}

.nav-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.nav-links a:hover {
  background: var(--panel-subtle);
  color: var(--text);
}

.topbar-meta {
  min-width: 220px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  text-align: right;
}

.home-hero {
  position: relative;
  display: grid;
  align-items: center;
  min-height: clamp(520px, calc(100svh - 126px), 760px);
  overflow: hidden;
  isolation: isolate;
}

.hero-media,
.hero-overlay {
  position: absolute;
  inset: 0;
}

.hero-media {
  z-index: -2;
  background-image: url("/assets/home-hero.png");
  background-position: center;
  background-size: cover;
  transform: scale(1.02);
}

.hero-overlay {
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(247, 250, 252, 0.98) 0%, rgba(247, 250, 252, 0.9) 34%, rgba(247, 250, 252, 0.42) 68%, rgba(17, 34, 54, 0.24) 100%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), rgba(245, 247, 251, 0.42));
}

.hero-content {
  width: min(1120px, calc(100% - 40px));
  margin: 0 auto;
  padding: 54px 0 74px;
}

.eyebrow {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.home-hero h1 {
  max-width: 670px;
  margin-bottom: 18px;
  color: #102033;
  font-size: clamp(42px, 6.2vw, 78px);
  line-height: 0.98;
}

.hero-copy {
  max-width: 620px;
  margin-bottom: 26px;
  color: #415064;
  font-size: 18px;
  line-height: 1.55;
}

.hero-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 34px;
}

.primary-action,
.secondary-action,
.open-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border-radius: 8px;
  font-weight: 900;
  text-decoration: none;
}

.primary-action {
  padding: 0 18px;
  background: var(--accent);
  color: #ffffff;
  box-shadow: 0 12px 30px rgba(15, 118, 110, 0.26);
}

.primary-action:hover,
.open-link:hover {
  background: var(--accent-strong);
}

.secondary-action {
  padding: 0 18px;
  border: 1px solid rgba(17, 34, 54, 0.18);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
}

.hero-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 170px));
  gap: 12px;
}

.stat-card,
.category-card,
.recent-card {
  border: 1px solid rgba(215, 222, 232, 0.86);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
}

.stat-card {
  padding: 16px;
  backdrop-filter: blur(12px);
}

.stat-card strong {
  display: block;
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.stat-card span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.home-section,
.catalog-shell {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
}

.intro-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-top: 28px;
  padding: 26px 0;
}

.intro-strip h2,
.section-heading h2,
.catalog-heading h2 {
  margin-bottom: 0;
  color: var(--ink);
  font-size: clamp(24px, 3vw, 36px);
  line-height: 1.12;
}

.pulse-indicator {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  min-height: 38px;
  padding: 0 13px;
  border: 1px solid rgba(15, 118, 110, 0.24);
  border-radius: 999px;
  background: #edf8f5;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
}

.pulse-indicator span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.45);
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  70% {
    box-shadow: 0 0 0 9px rgba(15, 118, 110, 0);
  }
}

.section-heading,
.catalog-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.text-link {
  color: var(--accent-strong);
  font-size: 14px;
  font-weight: 900;
  text-decoration: none;
}

.feature-grid,
.category-grid,
.recent-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
  margin-bottom: 42px;
}

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

.feature-card,
.category-card,
.recent-card {
  display: block;
  min-height: 148px;
  padding: 18px;
  color: inherit;
  text-align: left;
  text-decoration: none;
}

.feature-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(249, 251, 253, 0.94)),
    linear-gradient(135deg, rgba(15, 118, 110, 0.14), rgba(238, 111, 97, 0.12));
}

.feature-icon {
  display: block;
  width: 42px;
  height: 42px;
  margin-bottom: 18px;
  border-radius: 8px;
  background: var(--accent);
  position: relative;
}

.feature-icon::before,
.feature-icon::after {
  position: absolute;
  content: "";
}

.route-icon::before {
  inset: 11px 8px;
  border-top: 3px solid #ffffff;
  border-bottom: 3px solid #ffffff;
  transform: skewY(-18deg);
}

.wallet-icon {
  background: var(--amber);
}

.wallet-icon::before {
  left: 10px;
  right: 8px;
  top: 13px;
  height: 14px;
  border: 3px solid #ffffff;
  border-radius: 4px;
}

.ai-icon {
  background: #2563eb;
}

.ai-icon::before {
  left: 12px;
  top: 12px;
  width: 18px;
  height: 18px;
  border: 3px solid #ffffff;
  border-radius: 50%;
}

.ai-icon::after {
  left: 19px;
  top: 5px;
  width: 4px;
  height: 32px;
  background: #ffffff;
  transform: rotate(45deg);
}

.document-icon {
  background: var(--coral);
}

.document-icon::before {
  left: 12px;
  top: 8px;
  width: 18px;
  height: 25px;
  border: 3px solid #ffffff;
  border-radius: 3px;
}

.share-icon {
  background: #16a34a;
}

.share-icon::before {
  left: 10px;
  top: 11px;
  width: 22px;
  height: 18px;
  border-top: 3px solid #ffffff;
  border-bottom: 3px solid #ffffff;
  transform: skewY(-28deg);
}

.feature-card h3 {
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 17px;
  line-height: 1.2;
}

.feature-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

button.category-card {
  width: 100%;
  border: 1px solid rgba(215, 222, 232, 0.86);
  cursor: pointer;
  font: inherit;
}

.category-card:hover,
.recent-card:hover {
  transform: translateY(-2px);
  transition: transform 160ms ease, box-shadow 160ms ease;
  box-shadow: 0 22px 52px rgba(17, 34, 54, 0.15);
}

.category-topline,
.recent-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.category-card strong,
.recent-card strong {
  display: block;
  margin-bottom: 8px;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.25;
}

.category-card p,
.recent-card p {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.accent-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 40px;
  height: 30px;
  padding: 0 10px;
  border-radius: 999px;
  color: #ffffff;
  font-size: 12px;
  font-weight: 900;
}

.chip-teal {
  background: var(--accent);
}

.chip-coral {
  background: var(--coral);
}

.chip-amber {
  background: var(--amber);
}

.catalog-shell {
  padding-bottom: 34px;
}

.catalog-count {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.layout {
  display: grid;
  grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
  gap: 20px;
  min-height: 78vh;
}

.sidebar,
.viewer {
  min-height: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.sidebar {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.search {
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.search label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.search input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font: inherit;
}

.search input:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(15, 118, 110, 0.14);
}

.filters {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.filter-button {
  flex: 0 0 auto;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.filter-button.active {
  border-color: var(--accent);
  background: var(--accent);
  color: white;
}

.document-list {
  min-height: 0;
  overflow-y: auto;
  padding: 8px;
}

.document-item {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.document-item:hover,
.document-item.active {
  border-color: var(--line);
  background: var(--panel-subtle);
}

.document-item strong {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 1.35;
}

.document-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.badge {
  align-self: start;
  min-width: 44px;
  padding: 4px 7px;
  border-radius: 999px;
  background: #e8f5f2;
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
}

.viewer {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.document-type {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.viewer-header h2 {
  margin-bottom: 0;
  font-size: 20px;
  line-height: 1.25;
}

.open-link {
  flex: 0 0 auto;
  min-height: 36px;
  padding: 0 14px;
  background: var(--accent);
  color: white;
}

.viewer-content {
  flex: 1;
  min-height: 0;
  overflow: auto;
  background: #fbfcfd;
}

.viewer-frame {
  width: 100%;
  height: 100%;
  border: 0;
  background: white;
}

.markdown-body,
.empty-state,
.error-state {
  max-width: 980px;
  margin: 0 auto;
  padding: 32px;
  line-height: 1.65;
}

.markdown-body h1,
.markdown-body h2,
.markdown-body h3 {
  line-height: 1.25;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 20px 0;
  background: white;
}

.markdown-body th,
.markdown-body td {
  padding: 10px;
  border: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.markdown-body th {
  background: var(--panel-subtle);
}

.markdown-body code {
  padding: 2px 5px;
  border-radius: 4px;
  background: #e9edf2;
}

.markdown-body pre {
  overflow-x: auto;
  padding: 16px;
  border-radius: 6px;
  background: #111827;
  color: #f8fafc;
}

.markdown-body pre code {
  padding: 0;
  background: transparent;
}

.empty-state,
.error-state {
  color: var(--muted);
}

.error-state h3 {
  color: var(--danger);
}

@media (max-width: 980px) {
  .topbar {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .nav-links {
    order: 3;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
  }

  .topbar-meta {
    min-width: auto;
  }

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

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

  .sidebar {
    max-height: 50vh;
  }

  .viewer {
    min-height: 70vh;
  }
}

@media (max-width: 680px) {
  .topbar {
    padding: 10px 14px;
  }

  .brand {
    min-width: 0;
  }

  .topbar-meta {
    width: 100%;
    text-align: left;
  }

  .home-hero {
    min-height: clamp(560px, calc(100svh - 120px), 720px);
  }

  .hero-overlay {
    background: linear-gradient(180deg, rgba(247, 250, 252, 0.97) 0%, rgba(247, 250, 252, 0.78) 58%, rgba(247, 250, 252, 0.48) 100%);
  }

  .hero-media {
    background-position: 62% center;
  }

  .hero-content,
  .home-section,
  .catalog-shell {
    width: min(100% - 24px, 1180px);
  }

  .home-hero h1 {
    font-size: 42px;
  }

  .hero-copy {
    font-size: 16px;
  }

  .hero-stats,
  .feature-grid,
  .category-grid,
  .recent-grid {
    grid-template-columns: 1fr;
  }

  .intro-strip,
  .section-heading,
  .catalog-heading {
    align-items: flex-start;
    flex-direction: column;
  }
}
