/* Nest Rank — mobile-first styles. No <style> tags anywhere (CSP). */

:root {
  --bg: #0c1210;
  --panel: #141c18;
  --card: #182019;
  --ink: #eef4ee;
  --muted: #9db0a3;
  --line: #263129;
  --accent: #4ade80;
  --accent-dim: #14532d;
  --warn: #fbbf24;
  --danger: #f87171;
  --radius: 14px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", Inter, system-ui, sans-serif;
  font-size: 16px; line-height: 1.45;
}

#app { min-height: 100dvh; }

.page { padding: 14px 14px 92px; max-width: 640px; margin: 0 auto; }

.pagetitle { font-size: 26px; margin: 6px 0 12px; letter-spacing: -0.02em; }
.pagetitle .hint { font-size: 14px; color: var(--muted); font-weight: 400; }

h2 { font-size: 17px; margin: 18px 0 8px; }
h2 .hint { font-size: 12px; color: var(--muted); font-weight: 400; }
.hint { color: var(--muted); font-size: 13px; }
.notes { white-space: pre-wrap; }

.linkbtn {
  background: none; border: none; color: var(--accent);
  font-size: 14px; font-weight: 600; cursor: pointer; padding: 6px;
}

/* project chips */
.chips {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 10px;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; text-decoration: none; color: var(--ink);
  background: var(--panel); border: 1px solid var(--line);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600;
}
.chip .count { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
.chip.active { background: var(--accent-dim); border-color: var(--accent); }
.chip.ghost { color: var(--muted); border-style: dashed; }

/* cards */
.cards { display: grid; gap: 12px; }
.card {
  position: relative; display: block; text-decoration: none; color: inherit;
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.card:active { transform: scale(0.99); }
.rank {
  position: absolute; top: 8px; left: 8px; z-index: 2;
  background: rgba(0,0,0,0.65); color: #fff; font-weight: 800; font-size: 13px;
  border-radius: 999px; padding: 3px 10px;
}
.cardphoto { height: 150px; background-size: cover; background-position: center; }
.cardphoto.empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 44px; background: #1b241e;
}
.cardbody { padding: 12px 14px; }
.cardtop { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.cardaddr { font-weight: 700; font-size: 16px; }
.cardsub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.cardfacts { font-size: 13px; margin-top: 6px; }
.cardfoot { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; }
.whos { display: flex; gap: 10px; }
.who { display: inline-flex; align-items: center; gap: 5px; font-size: 13px; font-weight: 700; }
.avatar {
  width: 22px; height: 22px; border-radius: 50%; background: #334155;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 800; color: #fff;
}
.avatar.me { background: var(--accent-dim); }
.need { color: var(--warn); font-size: 13px; font-weight: 600; }
.done { color: var(--accent); font-size: 13px; font-weight: 600; }
.ping { color: var(--warn); font-size: 13px; font-weight: 600; margin-bottom: 6px; }
.progress { height: 6px; background: #223028; border-radius: 999px; margin-top: 10px; overflow: hidden; }
.pfill { height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s; }

/* pills + score bars */
.pill {
  font-weight: 800; font-size: 15px; border-radius: 10px; padding: 4px 10px;
  background: #223028; color: var(--muted); white-space: nowrap;
}
.pill.great { background: #14532d; color: #bbf7d0; }
.pill.good { background: #1c3a24; color: #d9f99d; }
.pill.meh { background: #3a2f1c; color: #fde68a; }
.pill.poor { background: #3a1c1c; color: #fecaca; }
.pill.none { font-size: 12px; font-weight: 600; }

.scorebar { flex: 1; height: 10px; background: #223028; border-radius: 999px; overflow: hidden; }
.scorebar .fill { height: 100%; border-radius: 999px; transition: width 0.35s ease; }
.scorebar .fill.great { background: #4ade80; }
.scorebar .fill.good { background: #a3e635; }
.scorebar .fill.meh { background: #fbbf24; }
.scorebar .fill.poor { background: #f87171; }
.scorebar .fill.none { background: transparent; }
.scorerow { display: flex; align-items: center; gap: 10px; margin: 8px 0; }
.scorerow > span:first-child { width: 84px; font-size: 14px; color: var(--muted); }
.scorerow.total { border-top: 1px solid var(--line); padding-top: 10px; }
.scorerow.total > span:first-child { color: var(--ink); font-weight: 700; }

/* detail */
.backlink { color: var(--muted); text-decoration: none; font-size: 14px; }
.hero { height: 220px; border-radius: var(--radius); background-size: cover; background-position: center; margin: 10px 0; }
.hero.empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background: #1b241e;
}
.hero.empty .heroemoji { font-size: 52px; }
.dtitle { font-size: 24px; margin: 4px 0 2px; letter-spacing: -0.02em; }
.dsub { color: var(--muted); font-size: 14px; }
.dprice { font-size: 26px; font-weight: 800; margin: 8px 0; }
.dfacts { font-size: 14px; font-weight: 400; color: var(--muted); }
.factgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.fact { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; }
.fk { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.fv { font-weight: 700; font-size: 15px; }

/* star ratings */
.dimrow { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.dimhead { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.dimicon { font-size: 20px; }
.dimname { font-weight: 600; flex: 1; }
/* weight pills (replaces the old dot row) */
.wpill {
  display: inline-block;
  min-width: 26px;
  height: 26px;
  line-height: 26px;
  padding: 0 7px;
  text-align: center;
  border-radius: 9px;
  font-size: 14px;
  font-weight: 800;
  vertical-align: middle;
}
.wpill.w5 { background: #fbbf24; color: #2f2100; }
.wpill.w4 { background: rgba(251, 191, 36, 0.6); color: #2f2100; }
.wpill.w3 { background: rgba(251, 191, 36, 0.32); color: #f3e6c4; }
.wpill.w2 { background: rgba(251, 191, 36, 0.16); color: #9db0a3; }
.wpill.w1 { background: #222c25; color: #9db0a3; border: 1px solid var(--line); }
.stars { display: flex; gap: 4px; }
.star {
  background: none; border: none; cursor: pointer;
  font-size: 40px; line-height: 1; padding: 6px 2px; color: #3a4a3e;
  transition: transform 0.12s ease;
  min-width: 52px; min-height: 52px; /* big touch target */
}
.star.on { color: #fbbf24; text-shadow: 0 0 14px rgba(251, 191, 36, 0.45); }
.star:active { transform: scale(1.25); }
.star.pop { animation: pop 0.18s ease; }
@keyframes pop { 50% { transform: scale(1.35); } }

/* partner ratings */
.prow { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin-bottom: 8px; }
.prow .pname { font-weight: 600; margin: 0 8px; }
.pdim { margin-top: 6px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.mini { font-size: 12px; color: var(--muted); white-space: nowrap; }

/* buttons + forms */
.btn {
  display: inline-block; text-decoration: none; text-align: center;
  background: #223028; color: var(--ink); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 18px; font-size: 15px; font-weight: 700;
  cursor: pointer; min-height: 48px;
}
.btn.primary { background: var(--accent-dim); border-color: var(--accent); color: #eafff0; }
.btn.danger { color: var(--danger); border-color: #5a2626; }
.btn.ghost { background: transparent; }
.btn.small { padding: 8px 14px; min-height: 0; font-size: 13px; }
.btn.big { width: 100%; margin-top: 12px; }
.btn:disabled { opacity: 0.6; }
.btnrow { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.panel h2 { margin-top: 0; }

label { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 10px; }
input, textarea {
  width: 100%; margin-top: 4px; background: var(--bg); color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 12px;
  font-size: 16px; font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }
textarea { resize: vertical; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; }
.urlrow { display: flex; gap: 8px; }
.urlrow input { flex: 1; }
.urlrow .btn { white-space: nowrap; }

.fetchok { background: #12351f; border: 1px solid var(--accent-dim); border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 14px; }
.fetchwarn { background: #3a2f1c; border: 1px solid #6b5426; border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 14px; }
.thumb { height: 90px; border-radius: 8px; background-size: cover; background-position: center; margin-top: 8px; }

/* tune page */
.tunerow { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.tunerow:last-child { border-bottom: none; }
.ticon { max-width: 52px; flex: 0 0 52px; text-align: center; font-size: 18px; }
.tname { flex: 1; min-width: 0; }
.wslider { flex: 1.4; min-width: 0; }
.wslider input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 38px;
  background: transparent;
  margin: 0;
  --fill: 50%;
}
.wslider input[type="range"]::-webkit-slider-runnable-track {
  height: 14px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--warn) var(--fill), #2b352d var(--fill));
}
.wslider input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 32px;
  height: 32px;
  margin-top: -9px;
  border-radius: 50%;
  background: #f4f7f4;
  border: 4px solid var(--warn);
  box-shadow: 0 2px 10px rgba(0,0,0,.5);
}
.wslider input[type="range"]::-moz-range-track { height: 14px; border-radius: 999px; background: #2b352d; }
.wslider input[type="range"]::-moz-range-progress { height: 14px; border-radius: 999px; background: var(--warn); }
.wslider input[type="range"]::-moz-range-thumb { width: 24px; height: 24px; border-radius: 50%; background: #f4f7f4; border: 4px solid var(--warn); }
.wlabel { font-size: 12px; color: var(--ink); font-weight: 700; }
.iconbtn { background: none; border: none; font-size: 18px; cursor: pointer; padding: 10px; }

/* projects page */
.projrow { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.projrow:last-child { border-bottom: none; }
.projname { flex: 1; font-weight: 700; color: var(--ink); text-decoration: none; font-size: 16px; }
.pcount { color: var(--muted); font-size: 13px; }
.defbadge { font-size: 11px; font-weight: 700; color: var(--accent); background: var(--accent-dim); border-radius: 999px; padding: 2px 8px; }

/* empty states, actions, toast */
.empty-state { text-align: center; padding: 48px 20px; }
.bigemoji { font-size: 52px; margin-bottom: 8px; }
.empty-state h2 { margin: 8px 0; }
.empty-state p { color: var(--muted); }
.actions { display: grid; gap: 10px; margin-top: 20px; }

#toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(20px);
  background: #eef4ee; color: #0c1210; font-weight: 600; font-size: 14px;
  padding: 12px 18px; border-radius: 999px; opacity: 0; pointer-events: none;
  transition: opacity 0.2s, transform 0.2s; z-index: 50; max-width: 90vw; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* bottom tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; background: rgba(12, 18, 16, 0.96);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
  backdrop-filter: blur(8px);
}
.tab {
  position: relative; flex: 1; display: flex; flex-direction: column; align-items: center;
  text-decoration: none; color: var(--muted); padding: 10px 0 8px; font-size: 11px; font-weight: 600;
  min-height: 60px; justify-content: center;
}
.tabicon { font-size: 22px; }
.tab.active { color: var(--accent); }
.tabbadge {
  position: absolute; top: 6px; right: calc(50% - 22px);
  background: var(--warn); color: #201503; font-size: 11px; font-weight: 800;
  border-radius: 999px; min-width: 20px; height: 20px;
  display: flex; align-items: center; justify-content: center; padding: 0 5px;
}

@media (min-width: 700px) {
  .page { padding-bottom: 40px; }
  .tabbar { display: none; }
  .factgrid { grid-template-columns: repeat(4, 1fr); }
}

/* home header with matrix button */
.homehead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.homehead .pagetitle { margin: 6px 0 12px; }

/* quiet secondary links under the one primary CTA */
.morelinks { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 12px; }
.textbtn {
  background: none; border: none; color: var(--muted); font-size: 14px; font-weight: 600;
  padding: 10px 6px; cursor: pointer; text-decoration: none; font-family: inherit;
}
.textbtn.danger { color: var(--danger); }
.morelinks .dot { color: var(--line); }

/* suggested dimension chips */
.sugchips { display: flex; flex-wrap: wrap; gap: 8px; }
.sugchip {
  display: inline-flex; align-items: center; gap: 6px;
  background: var(--bg); border: 1px dashed var(--line); color: var(--ink);
  border-radius: 999px; padding: 10px 14px; font-size: 14px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.sugchip:active { transform: scale(0.96); background: var(--accent-dim); }
.sugicon { font-size: 16px; }
.sugadd { color: var(--accent); font-weight: 800; font-size: 16px; }

/* segmented rater toggle */
.seg { display: flex; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.segbtn {
  background: none; border: none; color: var(--muted); font-size: 13px; font-weight: 700;
  border-radius: 999px; padding: 8px 14px; cursor: pointer; font-family: inherit; white-space: nowrap;
}
.segbtn.active { background: var(--accent-dim); color: #eafff0; }

/* matrix view */
.mwrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); }
table.matrix { border-collapse: collapse; width: 100%; min-width: 560px; font-size: 13px; }
.matrix th, .matrix td { padding: 10px 12px; text-align: center; border-bottom: 1px solid var(--line); white-space: nowrap; }
.matrix th a, .matrix td.cell a { color: inherit; text-decoration: none; display: block; }
.matrix .sticky {
  position: sticky; left: 0; z-index: 2; background: var(--panel);
  text-align: left; min-width: 170px; max-width: 220px; white-space: normal;
}
.matrix thead th { background: var(--card); font-size: 12px; }
.matrix thead th.sticky { background: var(--card); }
.matrix tfoot td { border-bottom: none; border-top: 2px solid var(--line); font-weight: 700; background: var(--card); }
.matrix tfoot td.sticky { background: var(--card); }
.mrank { font-weight: 800; color: var(--accent); }
.matrix .cell { min-width: 72px; padding: 0; }
.matrix .cell a { padding: 10px 6px; }
.cnum {
  display: inline-block;
  min-width: 40px;
  height: 40px;
  line-height: 40px;
  border-radius: 13px;
  font-size: 21px;
  font-weight: 800;
}
.cnum.s5 { background: #16a34a; color: #04180c; }
.cnum.s4 { background: #4ade80; color: #04180c; }
.cnum.s3 { background: #fbbf24; color: #2f2100; }
.cnum.s2 { background: #fb923c; color: #2f1500; }
.cnum.s1 { background: #f87171; color: #2f0808; }
.cell.s0 .cnone { color: #4a5a4e; font-size: 20px; }
.mlegend { display: flex; align-items: center; gap: 6px; margin: 0 0 10px; }
.cnum.sm { min-width: 28px; height: 28px; line-height: 28px; border-radius: 9px; font-size: 15px; }
.matrix .dimicon { font-size: 16px; }

/* wayback snapshot note */
.snapnote { color: var(--muted); font-size: 12px; font-weight: 400; }

/* super fat link drop target */
.dropzone {
  border: 3px dashed #3a4a3e;
  border-radius: 22px;
  background: linear-gradient(180deg, #15211a 0%, #0f1512 100%);
  padding: 22px 16px 18px;
  margin: 2px 0 18px;
  text-align: center;
  transition: border-color 0.2s;
}
.dropzone:focus-within { border-color: var(--accent); }
.dz-emoji { font-size: 36px; line-height: 1; }
#dz_url {
  text-align: center;
  font-size: 17px;
  margin: 12px 0;
  padding: 18px 14px;
  border-radius: 14px;
  border-width: 2px;
}
#dz_status { margin-top: 10px; }
#dz_status .fetchwarn { text-align: left; }

/* drag-reorder for criteria rows */
.tunerow { touch-action: pan-y; }
.draghandle {
  cursor: grab;
  touch-action: none;
  padding: 14px 10px 14px 2px;
  color: var(--muted);
  font-size: 18px;
  letter-spacing: 1px;
  user-select: none;
  -webkit-user-select: none;
  flex: none;
}
.tunerow.dragging {
  position: relative;
  z-index: 10;
  background: #1b2721;
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,.5);
  opacity: .98;
}
.tunerow.dragging .draghandle { cursor: grabbing; color: var(--accent); }

/* custom-dimension icon picker */
.iconpick {
  font-size: 26px;
  line-height: 1;
  background: #1a2620;
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 10px 14px;
  flex: none;
}
.iconpick:active { border-color: var(--accent); }
#emojisheet { position: fixed; inset: 0; z-index: 100; display: flex; align-items: flex-end; }
.esheet-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.6); }
.esheet {
  position: relative;
  width: 100%;
  max-height: 72vh;
  background: #121a16;
  border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--line);
  padding: 10px 12px 28px;
  display: flex;
  flex-direction: column;
}
.esheet-head { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px 10px; }
.esheet-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.echoice { font-size: 30px; line-height: 1; padding: 11px 0; background: none; border: none; border-radius: 10px; }
.echoice:active { background: #223129; }

/* partner notify nudge + invite */
.notifybar {
  background: #17251d;
  border: 2px solid var(--accent);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 14px;
}
.nb-text { margin-bottom: 10px; font-size: 15px; }
.nb-actions { display: flex; gap: 8px; align-items: center; }
.nb-actions .btn { flex: 1; }
.headbtns { display: flex; gap: 8px; align-items: center; }
