/* Local LLM Finder — Apple-style visual language.
   Light by default (the apple.com signature), real San Francisco via
   -apple-system, generous whitespace, soft grey panels, one Apple-blue accent,
   pill shapes, tabular figures. A proper dark mode mirrors Apple's. */

:root {
  --bg: #ffffff;
  --panel: #f5f5f7;
  --field: #ffffff;
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #6e6e73;
  --line: rgba(0, 0, 0, 0.10);
  --hair: #d2d2d7;
  --accent: #0071e3;
  --accent-soft: rgba(0, 113, 227, 0.12);
  --ring: rgba(0, 113, 227, 0.28);
  --over: #ff3b30;
  --track: rgba(0, 0, 0, 0.09);
  --chip: rgba(0, 0, 0, 0.05);

  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
  --maxw: 980px;
}

[data-theme="dark"] {
  --bg: #000000;
  --panel: #1d1d1f;
  --field: #000000;
  --text: #f5f5f7;
  --text-2: #a1a1a6;
  --text-3: #86868b;
  --line: rgba(255, 255, 255, 0.12);
  --hair: #424245;
  --accent: #2997ff;
  --accent-soft: rgba(41, 151, 255, 0.16);
  --ring: rgba(41, 151, 255, 0.32);
  --over: #ff453a;
  --track: rgba(255, 255, 255, 0.14);
  --chip: rgba(255, 255, 255, 0.10);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.47;
  letter-spacing: -0.01em;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.9em; }

/* header */
.site {
  display: flex; align-items: center; justify-content: space-between;
  max-width: var(--maxw); margin: 0 auto; padding: 17px 22px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 19px; letter-spacing: -0.02em; }
.brand .mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); display: inline-block; }
.site nav { display: flex; align-items: center; gap: 22px; }
.site nav a { color: var(--text-2); font-size: 15px; }
.site nav a:hover { color: var(--text); text-decoration: none; }
#theme {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--hair); background: transparent; color: var(--text-2);
  cursor: pointer; font-size: 14px; display: grid; place-items: center; line-height: 1;
}
#theme:hover { color: var(--text); }

main { max-width: var(--maxw); margin: 0 auto; padding: 0 22px 44px; }

/* hero */
.intro { text-align: center; padding: 66px 0 42px; max-width: 680px; margin: 0 auto; }
.intro h1 {
  font-size: clamp(40px, 6vw, 56px); font-weight: 600; line-height: 1.06;
  letter-spacing: -0.026em; margin: 0 0 16px;
}
.intro .sub { font-size: 21px; line-height: 1.38; color: var(--text-2); margin: 0 auto; max-width: 34ch; letter-spacing: -0.012em; }

/* auto-detect note */
.detect { text-align: center; font-size: 15px; color: var(--text-2); margin: 4px auto 16px; max-width: 62ch; }
.detect b { color: var(--text); font-weight: 600; }
.detect .mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; }
.detect .dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 8px; vertical-align: middle; }

/* controls: one calm panel */
.controls {
  display: grid; grid-template-columns: 1.7fr 1fr 1fr; gap: 6px;
  background: var(--panel); border-radius: 18px; padding: 10px; margin-top: 6px;
}
.field { padding: 13px 15px; }
.field label { display: block; font-size: 13px; color: var(--text-2); margin-bottom: 8px; }
.controls select, .controls input {
  width: 100%; background: var(--field); color: var(--text);
  border: 1px solid var(--hair); border-radius: 12px;
  font-family: var(--sans); font-size: 16px; padding: 11px 13px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.controls select {
  padding-right: 34px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%236e6e73' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 13px center; background-size: 12px;
}
.controls select:focus, .controls input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.inline { display: flex; gap: 8px; }
.inline input { flex: 0 0 44%; }

/* recommended pick */
.headline { margin: 30px 0 44px; }
.hl { background: var(--panel); border-radius: 22px; padding: 38px 32px 34px; text-align: center; }
.hl-eyebrow {
  display: inline-block; font-size: 13px; font-weight: 600; letter-spacing: 0.01em;
  color: var(--accent); background: var(--accent-soft);
  border-radius: 980px; padding: 5px 13px; margin-bottom: 18px;
}
.hl.empty .hl-eyebrow { color: var(--text-2); background: var(--chip); }
.hl-model { font-size: clamp(30px, 4.6vw, 46px); font-weight: 600; letter-spacing: -0.028em; line-height: 1.04; margin: 0; }
.hl-meta { font-size: 17px; color: var(--text-2); margin-top: 14px; font-variant-numeric: tabular-nums; }
.hl-blurb { margin: 16px auto 0; color: var(--text-2); max-width: 52ch; }

.badge { display: inline-block; font-size: 13px; font-weight: 500; padding: 2px 10px; border-radius: 980px; margin-right: 8px; vertical-align: 1px; }
.badge.ok { color: var(--accent); background: var(--accent-soft); }
.badge.tight, .badge.offload, .badge.no { color: var(--text-2); background: var(--chip); }

/* section heading */
.results-head { display: flex; align-items: baseline; justify-content: space-between; margin: 10px 4px 14px; }
.sect { font-size: 24px; font-weight: 600; letter-spacing: -0.015em; color: var(--text); }
.count { font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; }

/* model list as an airy Apple-style grouped list */
#results { background: var(--panel); border-radius: 18px; padding: 2px 10px; }
table.grid { width: 100%; border-collapse: collapse; }
table.grid thead th {
  text-align: left; font-size: 13px; font-weight: 500; color: var(--text-3);
  padding: 15px 12px 11px; border-bottom: 1px solid var(--line);
}
table.grid td { padding: 16px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.grid tbody tr:last-child td { border-bottom: none; }

.m-name .name { font-weight: 500; font-size: 17px; }
.row.no .m-name .name { color: var(--text-3); }
.chips { display: inline-flex; gap: 6px; margin-left: 11px; vertical-align: middle; }
.chip { font-size: 12px; color: var(--text-2); background: var(--chip); border-radius: 980px; padding: 2px 9px; }
.m-quant { font-size: 15px; color: var(--text-2); font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.no .m-quant { color: var(--text-3); }

.m-mem { width: 250px; white-space: nowrap; }
.meter { display: inline-block; width: 108px; height: 6px; background: var(--track); border-radius: 3px; vertical-align: middle; overflow: hidden; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 3px; }
.row.tight .meter > i { opacity: 0.5; }
.meter.over > i { background: var(--over); }
.memnum { font-size: 14px; color: var(--text-2); margin-left: 11px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.needs { font-size: 14px; color: var(--text-3); font-variant-numeric: tabular-nums; }

.m-status { white-space: nowrap; }
.st { font-size: 15px; color: var(--text); position: relative; padding-left: 16px; }
.st::before { content: ""; position: absolute; left: 0; top: 50%; transform: translateY(-50%); width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); }
.st.ok::before { background: var(--accent); }
.st.tight::before { background: var(--accent); opacity: 0.5; }
.st.offload::before { background: var(--text-3); }
.st.no { color: var(--text-3); }
.st.no::before { background: transparent; border: 1px solid var(--text-3); }
.cloud { display: inline-block; margin-left: 14px; color: var(--accent); font-size: 14px; }

/* how it works */
.how { margin-top: 60px; }
.how .sect { display: block; margin-bottom: 14px; }
.how p { color: var(--text-2); max-width: 70ch; }
.how ul { color: var(--text-2); padding-left: 20px; max-width: 70ch; }
.how li { margin: 6px 0; }
.how b { color: var(--text); font-weight: 600; }
.how .fine { color: var(--text-3); font-size: 15px; }

/* footer */
footer {
  max-width: var(--maxw); margin: 0 auto; padding: 26px 22px 48px;
  display: flex; justify-content: space-between; gap: 16px;
  border-top: 1px solid var(--line); font-size: 12px; color: var(--text-3);
}

@media (max-width: 734px) {
  .intro { padding: 46px 0 30px; }
  .controls { grid-template-columns: 1fr 1fr; }
  .hl { padding: 30px 22px 26px; }
  .m-name .chips { display: none; }
  footer { flex-direction: column; gap: 6px; }
  #library { grid-template-columns: 1fr; }
  .lib-filters { align-items: flex-start; }

  /* finder table reflows to stacked two-line rows so the Verdict never runs off-screen */
  table.grid thead { display: none; }
  table.grid tbody tr { display: grid; grid-template-columns: 1fr auto; column-gap: 12px; row-gap: 3px; align-items: baseline; padding: 13px 2px; border-bottom: 1px solid var(--line); }
  table.grid tbody tr:last-child { border-bottom: none; }
  table.grid tbody td { display: block; border: none; padding: 0; }
  .m-name { grid-column: 1; grid-row: 1; }
  .m-status { grid-column: 2; grid-row: 1; justify-self: end; }
  .m-quant { grid-column: 1; grid-row: 2; }
  .m-mem { grid-column: 2; grid-row: 2; justify-self: end; width: auto; }
  .m-mem .meter { display: none; }
  .m-mem .memnum { margin-left: 0; }
}

/* segmented Finder / Library control */
.seg { display: flex; width: fit-content; margin: 6px auto 24px; gap: 3px; background: var(--panel); border-radius: 980px; padding: 4px; }
.seg-btn { border: none; background: transparent; color: var(--text-2); font: inherit; font-size: 15px; font-weight: 500; padding: 7px 22px; border-radius: 980px; cursor: pointer; }
.seg-btn.is-active { background: var(--field); color: var(--text); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12); }
[data-theme="dark"] .seg-btn.is-active { background: #48484a; box-shadow: none; }

/* finder model name links into the library */
.m-name a.name { color: var(--text); text-decoration: none; }
.m-name a.name:hover { color: var(--accent); }
.row.no .m-name a.name { color: var(--text-3); }

/* library filters */
.lib-filters { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin: 0 2px 20px; }
.lib-uses { display: flex; gap: 8px; flex-wrap: wrap; }
.use { border: none; background: var(--chip); color: var(--text-2); font: inherit; font-size: 14px; padding: 6px 14px; border-radius: 980px; cursor: pointer; }
.use:hover { color: var(--text); }
.use.is-active, .use.is-active:hover { background: var(--accent); color: #fff; }
.lib-fits { display: inline-flex; align-items: center; gap: 9px; font-size: 14px; color: var(--text-2); cursor: pointer; user-select: none; }
.lib-fits input { -webkit-appearance: none; appearance: none; width: 38px; height: 22px; background: var(--track); border-radius: 980px; position: relative; cursor: pointer; transition: background .15s; flex: 0 0 auto; margin: 0; }
.lib-fits input::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25); }
.lib-fits input:checked { background: var(--accent); }
.lib-fits input:checked::after { transform: translateX(16px); }

/* library cards */
#library { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.lib-card { background: var(--panel); border-radius: 18px; padding: 22px 22px 18px; }
.lc-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.lc-name { font-size: 20px; font-weight: 600; letter-spacing: -0.02em; margin: 0; }
.lc-fam { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.lib-card .chips { margin: 11px 0 0; display: flex; flex-wrap: wrap; gap: 6px; }
.lc-blurb { color: var(--text-2); font-size: 15px; margin: 12px 0 0; }
.lc-meta { color: var(--text-3); font-size: 13px; margin: 10px 0 14px; }
.qtable { border-top: 1px solid var(--line); }
.qrow { display: grid; grid-template-columns: 1fr auto 18px; align-items: center; gap: 12px; padding: 8px 2px; border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums; }
.qrow:last-child { border-bottom: none; }
.qhead { color: var(--text-3); font-size: 12px; }
.qn { font-size: 14px; }
.qm { font-size: 14px; color: var(--text-2); text-align: right; }
.qdot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; }
.qdot.ok { background: var(--accent); }
.qdot.tight { background: var(--accent); opacity: .5; }
.qdot.no { background: transparent; border: 1px solid var(--text-3); }
.lib-empty { color: var(--text-2); text-align: center; padding: 36px; }
.flash { animation: flash 1.5s ease; }
@keyframes flash { 0% { box-shadow: 0 0 0 3px var(--accent); } 100% { box-shadow: 0 0 0 0 rgba(0, 0, 0, 0); } }

/* mobile: single-column library (must come after the base 2-col rule to win) */
@media (max-width: 734px) {
  #library { grid-template-columns: 1fr; }
  .lib-filters { align-items: flex-start; }
}

/* compact sort / filter selects */
.rh-right { display: flex; align-items: center; gap: 14px; }
.mini-select {
  -webkit-appearance: none; appearance: none;
  background: var(--field); color: var(--text);
  border: 1px solid var(--hair); border-radius: 980px;
  font: inherit; font-size: 14px; padding: 6px 30px 6px 14px;
  cursor: pointer; outline: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'><path d='M2 4l4 4 4-4' stroke='%236e6e73' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  background-repeat: no-repeat; background-position: right 12px center; background-size: 11px;
}
.mini-select:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.lib-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* inline jargon tooltips */
.term { position: relative; border-bottom: 1px dotted var(--hair); cursor: help; outline: none; }
.term:hover::after, .term:focus::after {
  content: attr(data-tip);
  position: absolute; left: 50%; bottom: calc(100% + 9px); transform: translateX(-50%);
  width: max-content; max-width: 230px; white-space: normal; text-align: left;
  background: var(--text); color: var(--bg);
  font-size: 12px; line-height: 1.4; font-weight: 400; letter-spacing: 0;
  padding: 8px 11px; border-radius: 9px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
  z-index: 30; pointer-events: none;
}
.term:hover::before, .term:focus::before {
  content: ""; position: absolute; left: 50%; bottom: calc(100% + 4px); transform: translateX(-50%);
  border: 5px solid transparent; border-top-color: var(--text); z-index: 30; pointer-events: none;
}

/* one-time library hint */
.lib-hint {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--accent-soft); border-radius: 12px; padding: 11px 14px;
  margin-bottom: 16px; font-size: 14px; color: var(--text);
}
.lib-hint button { border: none; background: transparent; color: var(--accent); font: inherit; font-size: 14px; font-weight: 600; cursor: pointer; padding: 0; }

/* buy me a coffee */
.coffee { text-align: center; margin: 60px auto 0; max-width: 58ch; }
.coffee p { color: var(--text-2); font-size: 15px; line-height: 1.5; margin: 0; }
.coffee a { font-weight: 500; }

/* generation speed estimate */
.tps { display: inline-block; margin-left: 10px; font-size: 13px; color: var(--text-3); font-variant-numeric: tabular-nums; }
.slow { color: var(--over); font-weight: 600; }
.lc-caveat { margin: 2px 0 12px; font-size: 13px; color: var(--text-3); line-height: 1.4; }

@media (max-width: 734px) {
  .lib-controls { width: 100%; }
  .lib-controls .mini-select { flex: 1 1 auto; }
}

/* finder "show all" toggle */
.show-all { text-align: center; padding: 16px 0 4px; }
.show-all button {
  border: 1px solid var(--hair); background: var(--field); color: var(--text);
  font: inherit; font-size: 14px; font-weight: 500; padding: 9px 22px; border-radius: 980px; cursor: pointer;
}
.show-all button:hover { border-color: var(--accent); color: var(--accent); }

/* library search */
.lib-search { margin: 0 2px 14px; }
.lib-search input {
  width: 100%; background: var(--field); color: var(--text);
  border: 1px solid var(--hair); border-radius: 12px;
  font: inherit; font-size: 16px; padding: 12px 16px; outline: none;
  -webkit-appearance: none; appearance: none;
}
.lib-search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px var(--ring); }
.lib-search input::placeholder { color: var(--text-3); }

/* get-it row on library cards: copyable install command + model card link */
.lc-get { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line); }
.copy-cmd {
  flex: 1 1 160px; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--field); border: 1px solid var(--hair); border-radius: 10px;
  padding: 8px 10px 8px 12px; cursor: pointer; text-align: left; font: inherit;
}
.copy-cmd code { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.copy-cmd .copy-ic { flex: none; font-size: 12px; font-weight: 500; color: var(--text-2); }
.copy-cmd:hover { border-color: var(--accent); }
.copy-cmd:hover .copy-ic, .copy-cmd.copied .copy-ic { color: var(--accent); }
.copy-cmd.copied { border-color: var(--accent); }
.hf-link { flex: none; font-size: 14px; color: var(--accent); white-space: nowrap; }
