/* KOL tool app. One stylesheet, custom properties first. Cartographic: deep teal ink, contour texture,
   amber reserved for "rising" signal, coral for industry money. */
:root {
  --ink: #0d2530;
  --ink-2: #163a47;
  --ink-3: #2b5563;
  --sea: #5fb3a8;
  --sea-soft: #d5ece8;
  --amber: #f2a516;
  --amber-soft: #fdf0d2;
  --coral: #e0603f;
  --coral-soft: #fbe3dc;
  --canvas: #e6edf0;
  --surface: #ffffff;
  --line: #c9d6dc;
  --line-soft: #e1e9ec;
  --text: #102029;
  --muted: #5a6d76;
  --focus: #1f7a8c;
  --radius: 6px;
  --shadow: 0 1px 0 rgba(13, 37, 48, .06), 0 6px 18px -10px rgba(13, 37, 48, .28);
  --serif: "Source Serif 4", "Iowan Old Style", Georgia, serif;
  --sans: "Atkinson Hyperlegible", "Segoe UI", Helvetica, sans-serif;
  --contours: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='240' height='120' viewBox='0 0 240 120'%3E%3Cg fill='none' stroke='%235fb3a8' stroke-opacity='.16' stroke-width='1'%3E%3Cpath d='M0 90c40-18 70-34 120-30s80 26 120 14'/%3E%3Cpath d='M0 70c40-16 74-30 120-26s82 22 120 10'/%3E%3Cpath d='M0 50c38-14 76-26 120-22s84 18 120 6'/%3E%3Cpath d='M0 30c38-12 78-22 120-18s86 14 120 2'/%3E%3Cpath d='M0 110c40-20 70-38 120-34s80 30 120 18'/%3E%3C/g%3E%3C/svg%3E");
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.5 var(--sans);
  color: var(--text);
  background: var(--canvas);
  min-height: 100vh;
}
a { color: var(--ink-3); text-underline-offset: 2px; }
a:hover { color: var(--ink); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3 { font-family: var(--serif); color: var(--ink); line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: clamp(1.6rem, 2.4vw, 2.1rem); font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }
p { margin: 0 0 .75rem; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.skip { position: absolute; left: -999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: 1rem; }
.boot { padding: 3rem; color: var(--muted); }

/* ---------------------------------------------------------------- top bar */
#topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 1.5rem;
  padding: .7rem clamp(1rem, 3vw, 2rem);
  background: var(--ink) var(--contours);
  color: #e8f2f1;
}
.brand { display: flex; align-items: center; gap: .6rem; color: #fff; text-decoration: none; font-family: var(--serif); font-weight: 700; font-size: 1.2rem; letter-spacing: .01em; }
.brand:hover { color: #fff; }
.brand-mark { width: 30px; height: 30px; }
#mainnav { display: flex; gap: .25rem; flex: 1; }
#mainnav a { color: #cfe3e0; text-decoration: none; padding: .4rem .7rem; border-radius: var(--radius); font-weight: 700; font-size: .95rem; }
#mainnav a:hover { background: var(--ink-2); color: #fff; }
#mainnav a[aria-current="page"] { background: var(--ink-2); color: #fff; }
#account-slot { display: flex; align-items: center; gap: .75rem; font-size: .9rem; }
#account-slot .who { color: #cfe3e0; max-width: 18ch; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------------------------------------------- buttons, inputs */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 40px; padding: .45rem 1rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--ink);
  font: 700 .95rem/1 var(--sans); cursor: pointer; text-decoration: none;
  transition: background .15s, border-color .15s, transform .1s;
}
.btn:hover { border-color: var(--ink-3); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: var(--ink-2); color: #fff; }
.btn-accent { background: var(--amber); border-color: #d99209; color: var(--ink); }
.btn-ghost { background: transparent; border-color: transparent; color: inherit; }
.btn-small { min-height: 32px; padding: .3rem .65rem; font-size: .85rem; }
#topbar .btn { background: transparent; color: #fff; border-color: var(--ink-3); }
#topbar .btn-accent { background: var(--amber); color: var(--ink); border-color: var(--amber); }

label { display: block; font-weight: 700; font-size: .875rem; margin-bottom: .25rem; color: var(--ink-2); }
input[type="text"], input[type="email"], input[type="search"], select, textarea {
  width: 100%; min-height: 42px; padding: .5rem .7rem;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--text); font: inherit;
}
textarea { min-height: 80px; resize: vertical; }
/* The native chevron sits flush with the right border; draw our own with room on both sides. */
select {
  appearance: none; -webkit-appearance: none; padding-right: 2.4rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%232b5563' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .85rem center; background-size: 12px 8px;
}
select::-ms-expand { display: none; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px rgba(31, 122, 140, .18); }
.form-status { min-height: 1.4em; margin-top: .5rem; font-size: .9rem; color: var(--ink-3); }
.form-status.error { color: var(--coral); }

/* ---------------------------------------------------------------- page frames */
.page { max-width: 1240px; margin: 0 auto; padding: clamp(1rem, 3vw, 2rem); }
.page-narrow { max-width: 560px; }
.panel { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1.25rem; }
.panel + .panel { margin-top: 1rem; }

/* ---------------------------------------------------------------- search layout */
.search-layout { display: grid; grid-template-columns: 260px minmax(0, 1fr); gap: 1.5rem; align-items: start; }
.topics { position: sticky; top: 78px; background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); box-shadow: var(--shadow); padding: .5rem; max-height: calc(100vh - 100px); overflow: auto; }
.topics h2 { font-size: .95rem; padding: .5rem .6rem .25rem; margin: 0; color: var(--muted); font-family: var(--sans); font-weight: 700; }
.topics button { display: block; width: 100%; text-align: left; padding: .45rem .6rem; border: 0; background: none; font: inherit; font-size: .93rem; color: var(--text); cursor: pointer; border-radius: 0 var(--radius) var(--radius) 0; }
.topics button:hover { background: var(--line-soft); }
.topics button[aria-pressed="true"] { background: var(--sea-soft); font-weight: 700; color: var(--ink); }

.search-head { display: grid; gap: .75rem; margin-bottom: 1rem; }
.search-head h1 { margin: 0; }
.filters { display: grid; grid-template-columns: minmax(180px, 2fr) repeat(3, minmax(130px, 1fr)); gap: .6rem; align-items: end; }
.toggles { display: flex; flex-wrap: wrap; gap: .4rem; }
.toggle { display: inline-flex; align-items: center; gap: .35rem; min-height: 34px; padding: .3rem .7rem; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); font-size: .87rem; font-weight: 700; cursor: pointer; color: var(--ink-2); }
.toggle[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); }
.result-meta { display: flex; justify-content: space-between; align-items: center; gap: 1rem; margin: .75rem 0 .5rem; font-size: .9rem; color: var(--muted); }

/* result rows */
.results { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.result {
  display: grid; grid-template-columns: 2.6rem minmax(0, 1fr) 190px auto; gap: .9rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: .8rem 1rem;
  box-shadow: var(--shadow);
  animation: rise .35s ease both;
}
.result:hover { border-color: var(--line); }
.rank { font: 700 1.05rem/1 var(--serif); color: var(--ink-3); text-align: right; font-variant-numeric: tabular-nums; }
.who-name { font-weight: 700; font-size: 1.02rem; color: var(--ink); text-decoration: none; }
.who-name:hover { text-decoration: underline; }
.who-line { font-size: .88rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.facts { display: flex; flex-wrap: wrap; gap: .35rem .9rem; font-size: .83rem; color: var(--ink-3); margin-top: .25rem; }
.facts b { color: var(--ink); font-variant-numeric: tabular-nums; }
.scorebar { display: grid; gap: .25rem; }
.scorebar-track { height: 8px; border-radius: 4px; background: var(--line-soft); overflow: hidden; }
.scorebar-fill { height: 100%; background: linear-gradient(90deg, var(--ink-3), var(--sea)); border-radius: 4px; transform-origin: left; animation: grow .6s ease both; }
.scorebar-label { font-size: .78rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.badge { display: inline-flex; align-items: center; gap: .25rem; padding: .1rem .45rem; border-radius: 3px; font-size: .74rem; font-weight: 700; letter-spacing: .01em; }
.badge-rising { background: var(--amber-soft); color: #8a5a00; box-shadow: inset 0 0 0 1px #f3cf7f; }
.badge-money { background: var(--coral-soft); color: #9a3417; box-shadow: inset 0 0 0 1px #f2b9a7; }
.badge-trial { background: var(--sea-soft); color: #1d5d55; box-shadow: inset 0 0 0 1px #a8d6cf; }
.badges { display: flex; gap: .3rem; flex-wrap: wrap; margin-top: .3rem; }

.locked-band {
  margin-top: .75rem; padding: 1.25rem; border-radius: var(--radius);
  background: var(--ink) var(--contours); color: #e8f2f1;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap;
}
.locked-band h3 { color: #fff; margin: 0 0 .2rem; }
.locked-band p { margin: 0; color: #cfe3e0; }
.pager { display: flex; gap: .5rem; justify-content: center; margin: 1.25rem 0; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }

/* ---------------------------------------------------------------- profile */
.profile-head { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 1rem; align-items: start; padding: 1.5rem; background: var(--ink) var(--contours); color: #e8f2f1; border-radius: var(--radius); box-shadow: var(--shadow); }
.profile-head h1 { color: #fff; margin-bottom: .2rem; }
.profile-head .sub { color: #cfe3e0; }
.profile-head .ids { font-size: .82rem; color: #a9c7c3; margin-top: .4rem; }
.profile-head .ids a { color: #cfe3e0; }
.ranks { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .9rem; }
.rank-chip { display: inline-flex; gap: .35rem; align-items: baseline; padding: .25rem .55rem; border-radius: 3px; background: var(--ink-2); color: #e8f2f1; font-size: .82rem; border: 1px solid var(--ink-3); text-decoration: none; }
.rank-chip b { color: var(--amber); font-variant-numeric: tabular-nums; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: .6rem; margin: 1rem 0; }
.tile { background: var(--surface); border: 1px solid var(--line-soft); border-radius: var(--radius); padding: .8rem 1rem; box-shadow: var(--shadow); }
.tile .v { font: 700 1.55rem/1.1 var(--serif); color: var(--ink); font-variant-numeric: tabular-nums; }
.tile .k { font-size: .8rem; color: var(--muted); }
.profile-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; }
.tabs button { border: 0; background: none; font: 700 .95rem var(--sans); color: var(--muted); padding: .5rem .85rem; cursor: pointer; border-radius: var(--radius); }
.tabs button[aria-selected="true"] { color: var(--ink); background: var(--sea-soft); }
.items { list-style: none; padding: 0; margin: 0; }
.items li { padding: .65rem 0; border-bottom: 1px solid var(--line-soft); }
.items li:last-child { border-bottom: 0; }
.item-title { font-weight: 700; color: var(--ink); text-decoration: none; }
.item-title:hover { text-decoration: underline; }
.item-meta { font-size: .84rem; color: var(--muted); }
.bars { display: flex; align-items: flex-end; gap: 3px; height: 70px; padding-top: .5rem; }
.bars span { flex: 1; background: var(--sea); border-radius: 2px 2px 0 0; min-height: 2px; position: relative; animation: grow-y .5s ease both; transform-origin: bottom; }
.bars span i { position: absolute; inset: auto 0 0 0; background: var(--ink-3); border-radius: 2px 2px 0 0; }
.bars-axis { display: flex; justify-content: space-between; font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.kv { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem .75rem; font-size: .9rem; }
.kv dt { color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; color: var(--ink-3); font-weight: 700; }
.locked-overlay { position: relative; }
.locked-overlay .veil { margin-top: 1rem; padding: 1.5rem; text-align: center; border: 1px dashed var(--line); border-radius: var(--radius); background: repeating-linear-gradient(135deg, var(--surface), var(--surface) 10px, var(--line-soft) 10px, var(--line-soft) 11px); }

/* ---------------------------------------------------------------- lists, account, plans */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.card-link { display: block; text-decoration: none; color: inherit; }
.card-link:hover .panel { border-color: var(--ink-3); }
.plans { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; margin: 1rem 0; }
.plan { border: 2px solid var(--line-soft); }
.plan.best { border-color: var(--amber); }
.plan .price { font: 700 2rem/1 var(--serif); color: var(--ink); margin: .5rem 0; }
.plan ul { padding-left: 1.1rem; margin: .5rem 0 1rem; }
.row-actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.note-input { font-size: .88rem; min-height: 34px; }

dialog { border: 0; border-radius: var(--radius); box-shadow: 0 20px 60px -20px rgba(13, 37, 48, .55); padding: 1.25rem; width: min(420px, 92vw); }
.btn-danger { background: #b23f26; border-color: #b23f26; color: #fff; }
dialog label input { margin-top: .35rem; font-weight: 400; }
dialog::backdrop { background: rgba(13, 37, 48, .45); }
.check-row { display: flex; align-items: center; gap: .5rem; padding: .35rem 0; font-weight: 400; }
#toast { position: fixed; bottom: 1.25rem; left: 50%; transform: translateX(-50%) translateY(150%); background: var(--ink); color: #fff; padding: .6rem 1rem; border-radius: var(--radius); box-shadow: var(--shadow); transition: transform .25s ease; z-index: 20; font-size: .92rem; }
#toast.show { transform: translateX(-50%) translateY(0); }
.prose { max-width: 70ch; }
.prose h2 { margin-top: 1.5rem; }

@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes grow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
@keyframes grow-y { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.results li:nth-child(2) { animation-delay: .03s; } .results li:nth-child(3) { animation-delay: .06s; }
.results li:nth-child(4) { animation-delay: .09s; } .results li:nth-child(5) { animation-delay: .12s; }
.results li:nth-child(n+6) { animation-delay: .15s; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

@media (max-width: 900px) {
  .search-layout, .profile-grid { grid-template-columns: 1fr; }
  .topics { position: static; max-height: none; display: flex; overflow-x: auto; gap: .25rem; padding: .4rem; }
  .topics h2 { display: none; }
  .topics button { white-space: nowrap; width: auto; border-radius: var(--radius); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters > :first-child { grid-column: 1 / -1; }
  .result { grid-template-columns: 2rem minmax(0, 1fr); }
  .result .scorebar, .result .row-actions { grid-column: 2; }
  #topbar { flex-wrap: wrap; gap: .6rem; }
  #mainnav { order: 3; flex-basis: 100%; overflow-x: auto; }
}

/* fixes after the first visual pass */
#view:focus { outline: none; }
.plans .panel + .panel, .cards .panel + .panel { margin-top: 0; }
#toast { visibility: hidden; }
#toast.show { visibility: visible; }
