:root {
  --paper: #e7ebf0;
  --ink: #12161c;
  --ink-soft: #3a4450;
  --mute: #6b7582;
  --line: rgba(18, 22, 28, 0.14);
  --line-strong: rgba(18, 22, 28, 0.28);
  --signal-deep: #0a4f3d;
  --ember: #c45c26;
  --steel: #2f4f7a;
  --display: "Literata", Georgia, "Times New Roman", serif;
  --body: "Atkinson Hyperlegible", "Helvetica Neue", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 520px at 12% -8%, rgba(47, 79, 122, 0.14), transparent 60%),
    radial-gradient(900px 480px at 100% 8%, rgba(15, 110, 86, 0.1), transparent 55%),
    linear-gradient(180deg, #eef2f6 0%, var(--paper) 42%, #dde3ea 100%);
  font-family: var(--body);
  -webkit-font-smoothing: antialiased;
}

body.modal-open { overflow: hidden; }

a { color: inherit; text-decoration: none; }
button, input { font: inherit; color: inherit; }

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

/* Top bar */
.top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 28px 0 22px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: baseline;
  font-family: var(--display);
  font-size: clamp(1.08rem, 1.92vw, 1.36rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
}

.brand span {
  color: var(--mute);
  font-weight: 500;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.top-nav a:hover { color: var(--ink); }

/* Hero */
.hero {
  padding: clamp(52px, 9vw, 104px) 0 clamp(40px, 6vw, 64px);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: clamp(28px, 6vw, 72px);
  align-items: end;
  border-bottom: 1px solid var(--line);
}

.hero-copy h1 {
  margin: 0 0 18px;
  max-width: 9ch;
  font-family: var(--display);
  font-size: clamp(2.72rem, 7.2vw, 5.12rem);
  font-weight: 800;
  letter-spacing: -0.055em;
  line-height: 0.9;
}

.hero-copy p {
  margin: 0;
  max-width: 34ch;
  color: var(--ink-soft);
  font-size: clamp(1.05rem, 1.6vw, 1.2rem);
  line-height: 1.5;
  text-align: left;
}

.find {
  padding: 22px 22px 20px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line-strong);
}

.find label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}

.find input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  font-family: var(--display);
  font-size: clamp(1.08rem, 1.92vw, 1.36rem);
  font-weight: 700;
  letter-spacing: -0.03em;
}

.find input::placeholder { color: rgba(18, 22, 28, 0.28); }

.find-hint {
  margin-top: 14px;
  color: var(--mute);
  font-size: 0.85rem;
  line-height: 1.4;
  text-align: left;
}

.find-hint a {
  color: var(--signal-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.find-empty {
  margin: 12px 0 0;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

body.is-filtering .section-more {
  display: none;
}

/* Chapters */
.chapters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  border-bottom: 1px solid var(--line);
}

.chapter-link {
  padding: 22px 18px 24px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  transition: background 0.2s ease;
}

.chapter-link:hover { background: rgba(255, 255, 255, 0.45); }

.chapter-link .n {
  display: block;
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--mute);
}

.chapter-link .t {
  display: block;
  font-family: var(--display);
  font-size: 1.16rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

/* Sections */
.section {
  padding: clamp(48px, 7vw, 88px) 0 8px;
}

.section-head {
  margin-bottom: 28px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--ink);
}

.section-head h2 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(1.76rem, 4vw, 2.72rem);
  font-weight: 800;
  letter-spacing: -0.045em;
  line-height: 0.95;
}

.section[data-tone="ai"] .section-head,
.page-hero[data-tone="ai"] { border-color: #5b4a9a; }
.section[data-tone="ai"] h2,
.page-hero[data-tone="ai"] h1 { color: #5b4a9a; }

.section[data-tone="developer-tools"] .section-head,
.page-hero[data-tone="developer-tools"] { border-color: var(--steel); }
.section[data-tone="developer-tools"] h2,
.page-hero[data-tone="developer-tools"] h1 { color: var(--steel); }

.section[data-tone="productivity"] .section-head,
.page-hero[data-tone="productivity"] { border-color: var(--signal-deep); }
.section[data-tone="productivity"] h2,
.page-hero[data-tone="productivity"] h1 { color: var(--signal-deep); }

.section[data-tone="consumer"] .section-head,
.page-hero[data-tone="consumer"] { border-color: #8a3d55; }
.section[data-tone="consumer"] h2,
.page-hero[data-tone="consumer"] h1 { color: #8a3d55; }

.section[data-tone="fintech"] .section-head,
.page-hero[data-tone="fintech"] { border-color: var(--ember); }
.section[data-tone="fintech"] h2,
.page-hero[data-tone="fintech"] h1 { color: var(--ember); }

.section[data-tone="health"] .section-head,
.page-hero[data-tone="health"] { border-color: #1f7a5c; }
.section[data-tone="health"] h2,
.page-hero[data-tone="health"] h1 { color: #1f7a5c; }

.section[data-tone="education"] .section-head,
.page-hero[data-tone="education"] { border-color: #2a6f97; }
.section[data-tone="education"] h2,
.page-hero[data-tone="education"] h1 { color: #2a6f97; }

.section[data-tone="marketing"] .section-head,
.page-hero[data-tone="marketing"] { border-color: #a14a2a; }
.section[data-tone="marketing"] h2,
.page-hero[data-tone="marketing"] h1 { color: #a14a2a; }

.section[data-tone="design"] .section-head,
.page-hero[data-tone="design"] { border-color: #6b3d75; }
.section[data-tone="design"] h2,
.page-hero[data-tone="design"] h1 { color: #6b3d75; }

.section[data-tone="ecommerce"] .section-head,
.page-hero[data-tone="ecommerce"] { border-color: #3d5a40; }
.section[data-tone="ecommerce"] h2,
.page-hero[data-tone="ecommerce"] h1 { color: #3d5a40; }

.list-page { padding-top: 8px; }

/* Rows */
.list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.row {
  display: grid;
  grid-template-columns: minmax(14rem, 17rem) minmax(0, 1fr) minmax(7rem, 10rem);
  gap: 20px 24px;
  align-items: baseline;
  padding: 18px 4px;
  border-bottom: 1px solid var(--line);
  transition: background 0.18s ease, padding-left 0.18s ease;
}

.row:hover {
  background: rgba(255, 255, 255, 0.42);
  padding-left: 10px;
}

.row-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: 1.02rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.row-mark {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  border-radius: 4px;
  object-fit: contain;
}

.row:hover .row-name {
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

.row-blurb {
  margin: 0;
  color: var(--ink-soft);
  font-size: 0.98rem;
  line-height: 1.45;
  text-align: left;
}

.row-meta {
  overflow: hidden;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  text-transform: none;
  color: var(--mute);
  white-space: nowrap;
  text-align: right;
  text-overflow: ellipsis;
}

.section-more {
  display: inline-flex;
  margin-top: 22px;
  margin-bottom: 12px;
  font-weight: 600;
  color: var(--ink);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-thickness: 2px;
}

.section-more:hover { opacity: 0.72; }

/* Close strip */
.close {
  margin: clamp(48px, 8vw, 96px) 0 0;
  padding: clamp(36px, 6vw, 56px) 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 0.8fr);
  gap: 28px;
  align-items: center;
}

.close h2 {
  margin: 0 0 10px;
  font-family: var(--display);
  font-size: clamp(1.44rem, 2.8vw, 1.92rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1.05;
}

.close p {
  margin: 0;
  max-width: 40ch;
  color: var(--ink-soft);
  line-height: 1.5;
  text-align: left;
}

.close-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0 20px;
  border: 1px solid var(--ink);
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}

.btn-solid {
  background: var(--ink);
  color: #f4f6f8;
}

.btn-solid:hover { background: #000; }
.btn-ghost:hover { background: rgba(18, 22, 28, 0.06); }

footer {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 28px 0 48px;
  color: var(--mute);
  font-size: 0.9rem;
}

footer a:hover { color: var(--ink); }

/* Category / company pages */
.crumb {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 22px 0 0;
  color: var(--mute);
  font-size: 0.88rem;
  font-weight: 500;
}

.crumb a:hover { color: var(--ink); }
.crumb .sep { opacity: 0.45; }

.page-hero {
  padding: clamp(28px, 5vw, 48px) 0 28px;
  border-bottom: 2px solid var(--ink);
}

.page-hero h1 {
  margin: 0;
  font-family: var(--display);
  font-size: clamp(2.08rem, 5.6vw, 3.68rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.92;
}

.page-count {
  margin: 12px 0 0;
  color: var(--mute);
  font-size: 0.92rem;
  font-weight: 500;
}

.back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 28px;
  padding: 10px 14px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.55);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.back:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: var(--ink);
}

/* Standalone company page: centered, narrower column */
body.page-company .shell {
  width: min(640px, calc(100% - 40px));
}

body.page-company .crumb {
  justify-content: center;
  padding-top: 36px;
}

body.page-company .top {
  justify-content: center;
  flex-wrap: wrap;
}

.company {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: clamp(36px, 7vw, 72px) 0 48px;
  border-bottom: 1px solid var(--line);
}

.company-mark {
  width: 40px;
  height: 40px;
  margin: 0 0 20px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.7);
  object-fit: contain;
}

.company h1 {
  margin: 0 0 16px;
  font-family: var(--display);
  font-size: clamp(2.24rem, 5.6vw, 3.4rem);
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 0.95;
}

.company .deck {
  margin: 0 0 22px;
  max-width: 38ch;
  color: var(--ink-soft);
  font-size: 1.18rem;
  line-height: 1.45;
}

.company .body {
  margin: 0 0 32px;
  max-width: 48ch;
  color: var(--ink-soft);
  font-size: 1.02rem;
  line-height: 1.65;
}

.company-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 28px 40px;
  margin: 0 0 32px;
  padding: 0;
}

.company-meta div {
  min-width: 6rem;
}

.company-meta dt {
  margin: 0 0 4px;
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mute);
}

.company-meta dd {
  margin: 0;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.company-meta a {
  color: var(--signal-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

.company-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.related {
  padding: clamp(36px, 6vw, 56px) 0 8px;
}

.related h2 {
  margin: 0 0 18px;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.03em;
}

/* Company modal — class toggle, no [hidden]/display fight */
.company-modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
  place-items: center;
  padding: 24px;
}

.company-modal.is-open {
  display: grid;
}

.company-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(18, 22, 28, 0.48);
}

.company-modal-panel {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(880px, 100%);
  max-height: min(860px, calc(100vh - 48px));
  background: #eef2f6;
  border: 1px solid var(--line-strong);
  box-shadow: 0 24px 64px rgba(18, 22, 28, 0.22);
}

.company-modal-bar {
  flex: 0 0 auto;
  display: flex;
  justify-content: flex-end;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.company-modal-close {
  border: 0;
  background: transparent;
  color: var(--ink-soft);
  font-size: 0.92rem;
  font-weight: 600;
  cursor: pointer;
}

.company-modal-close:hover { color: var(--ink); }

.company-modal-scroll {
  flex: 1 1 auto;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 8px 28px 36px;
}

.company-modal-content .company {
  border-bottom: 0;
  padding-top: 20px;
  padding-bottom: 8px;
}

.company-modal-content .company-actions .btn-ghost {
  display: none;
}

.company-modal-loading {
  margin: 48px 0;
  color: var(--ink-soft);
  text-align: left;
}

.company-modal-loading a {
  color: var(--signal-deep);
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Motion */
@media (prefers-reduced-motion: no-preference) {
  .hero-copy h1,
  .hero-copy p,
  .find {
    animation: rise 0.7s ease both;
  }

  .hero-copy p { animation-delay: 0.08s; }
  .find { animation-delay: 0.14s; }

  .chapter-link { animation: rise 0.55s ease both; }
  .chapter-link:nth-child(2) { animation-delay: 0.06s; }
  .chapter-link:nth-child(3) { animation-delay: 0.12s; }

  @keyframes rise {
    from { opacity: 0; transform: translateY(14px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

@media (max-width: 860px) {
  .hero,
  .close {
    grid-template-columns: 1fr;
  }

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

  .chapter-link { border-right: 0; }

  .row {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .row-meta {
    white-space: normal;
    text-align: left;
  }

  .close-actions { justify-content: flex-start; }
  .top-nav .hide-sm { display: none; }

  .company-modal { padding: 0; }

  .company-modal-panel {
    width: 100%;
    max-height: 100%;
    height: 100%;
    border: 0;
  }

  .company-modal-scroll { padding: 8px 20px 40px; }
}
