/* =========================================================================
   Price Lens — "precision instrument" dark theme
   Fraunces (display) · IBM Plex Sans (UI) · IBM Plex Mono (figures)
   ========================================================================= */

:root {
  --bg:          #0b0a09;
  --bg-2:        #100e0c;
  --surface:     rgba(255, 252, 245, 0.028);
  --surface-2:   rgba(255, 252, 245, 0.05);
  --border:      rgba(255, 246, 230, 0.09);
  --border-str:  rgba(255, 246, 230, 0.16);

  --text:        #ece6da;
  --dim:         #a39c8f;
  --faint:       #6f685d;

  --gold:        #f0c75e;
  --gold-bright: #ffdc86;
  --gold-deep:   #c89a3a;

  --anthropic:   #e08a63;
  --openai:      #2bcf8d;
  --google:      #6aa6f7;
  --qwen:        #b197ff;

  --good:        #7fd6a0;
  --hot:         #f08a6e;

  --r:           14px;
  --r-sm:        9px;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --serif: "Fraunces", Georgia, serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

/* ---- atmosphere ---------------------------------------------------------- */
.glow {
  position: fixed;
  z-index: 0;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  opacity: 0.55;
}
.glow-a {
  width: 60vw; height: 60vw;
  top: -28vw; left: -16vw;
  background: radial-gradient(circle, rgba(240,199,94,0.20), transparent 62%);
}
.glow-b {
  width: 52vw; height: 52vw;
  bottom: -26vw; right: -14vw;
  background: radial-gradient(circle, rgba(177,151,255,0.14), transparent 62%);
}
.grain {
  position: fixed; inset: 0; z-index: 1;
  pointer-events: none; opacity: 0.04; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

main { position: relative; z-index: 2; max-width: 1180px; margin: 0 auto; padding: 0 26px 90px; }

/* ---- topbar -------------------------------------------------------------- */
.topbar {
  position: relative; z-index: 3;
  max-width: 1180px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  gap: 18px; padding: 22px 26px 16px;
}
.brand { display: flex; align-items: baseline; gap: 11px; }
.brand-mark {
  font-size: 19px; color: var(--gold);
  transform: translateY(2px);
  text-shadow: 0 0 18px rgba(240,199,94,0.5);
}
.brand-name {
  font-family: var(--serif);
  font-weight: 600; font-size: 23px; letter-spacing: -0.01em;
}
.brand-sub {
  font-size: 11.5px; color: var(--faint);
  letter-spacing: 0.14em; text-transform: uppercase;
}
.topbar-right { display: flex; align-items: center; gap: 12px; }

.status {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  background: var(--surface); border: 1px solid var(--border);
  padding: 7px 12px; border-radius: 999px;
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint); box-shadow: 0 0 0 0 transparent;
}
.status.live .status-dot   { background: var(--good); box-shadow: 0 0 10px 1px rgba(127,214,160,0.7); animation: pulse 2.4s infinite; }
.status.snap .status-dot   { background: var(--gold); box-shadow: 0 0 10px 1px rgba(240,199,94,0.6); }
.status.err  .status-dot   { background: var(--hot); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.35; } }

.btn-refresh {
  font-family: var(--mono); font-size: 12.5px; color: var(--text);
  background: var(--surface-2); border: 1px solid var(--border-str);
  padding: 8px 14px; border-radius: 999px; cursor: pointer;
  display: flex; align-items: center; gap: 7px;
  transition: background .18s, border-color .18s, transform .18s;
}
.btn-refresh:hover { background: rgba(240,199,94,0.12); border-color: var(--gold-deep); }
.btn-refresh:active { transform: scale(0.96); }
.refresh-ico { display: inline-block; }
.btn-refresh.spin .refresh-ico { animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- hero ---------------------------------------------------------------- */
.hero { padding: 30px 0 26px; max-width: 760px; }
.hero-title {
  font-family: var(--serif);
  font-weight: 400; font-size: clamp(38px, 6vw, 62px);
  line-height: 1.02; letter-spacing: -0.025em; margin: 0 0 18px;
}
.hero-title em {
  font-style: italic; font-weight: 500;
  color: var(--gold-bright);
  background: linear-gradient(180deg, var(--gold-bright), var(--gold-deep));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.hero-lede { color: var(--dim); font-size: 16px; line-height: 1.62; max-width: 640px; margin: 0; }

/* ---- reveal animation ---------------------------------------------------- */
.hero, .usage, .podium, .controls, .table-wrap, .foot { animation: rise .7s cubic-bezier(.2,.7,.2,1) both; }
.usage      { animation-delay: .06s; }
.podium     { animation-delay: .12s; }
.controls   { animation-delay: .18s; }
.table-wrap { animation-delay: .24s; }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: none; } }

/* ---- usage panel --------------------------------------------------------- */
.usage {
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); border-radius: var(--r);
  padding: 20px 22px 18px; margin-bottom: 26px;
  position: relative; overflow: hidden;
}
.usage::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(240,199,94,0.5), transparent);
}
.usage-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; }
.usage-head h2 {
  font-family: var(--serif); font-weight: 500; font-size: 19px; margin: 0; letter-spacing: -0.01em;
}
.btn-reset {
  font-family: var(--mono); font-size: 11.5px; color: var(--dim);
  background: transparent; border: 1px solid var(--border); border-radius: 999px;
  padding: 6px 12px; cursor: pointer; transition: color .18s, border-color .18s;
}
.btn-reset:hover { color: var(--gold-bright); border-color: var(--gold-deep); }

.usage-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.field {
  display: flex; flex-direction: column; gap: 6px;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 11px 13px 10px; transition: border-color .18s, box-shadow .18s;
}
.field:focus-within { border-color: var(--accent, var(--gold-deep)); box-shadow: 0 0 0 3px rgba(240,199,94,0.08); }
.field[data-kind="input"]       { --accent: var(--google); }
.field[data-kind="output"]      { --accent: var(--anthropic); }
.field[data-kind="cache_read"]  { --accent: var(--openai); }
.field[data-kind="cache_write"] { --accent: var(--qwen); }
.field-label {
  font-size: 12px; color: var(--text); font-weight: 600;
  display: flex; align-items: center; gap: 6px;
}
.field-label small { color: var(--faint); font-weight: 400; font-size: 10.5px; }
.field-label::before {
  content: ""; width: 7px; height: 7px; border-radius: 2px; background: var(--accent); flex: none;
}
.field input {
  font-family: var(--mono); font-size: 17px; font-weight: 500; color: var(--text);
  background: transparent; border: none; outline: none; width: 100%;
  letter-spacing: -0.01em; font-variant-numeric: tabular-nums;
}
.field-unit { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.usage-note { font-family: var(--mono); font-size: 11.5px; color: var(--faint); margin: 14px 0 0; }
.usage-note b { color: var(--gold); font-weight: 500; }

/* monthly-basis / period scaler */
.period {
  display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px;
  margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--border);
  font-family: var(--mono); font-size: 12px; color: var(--dim);
}
.period-lbl { color: var(--text); font-weight: 600; }
.period-seg { display: inline-flex; align-items: center; gap: 6px; }
.period-in {
  width: 54px; text-align: center;
  font-family: var(--mono); font-size: 13px; color: var(--text); font-variant-numeric: tabular-nums;
  background: var(--bg-2); border: 1px solid var(--border); border-radius: 7px;
  padding: 5px 6px; outline: none; transition: border-color .16s, box-shadow .16s;
}
.period-in:focus { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(240,199,94,0.08); }
.period-unit, .period-arrow { color: var(--faint); }
.period-mult {
  font-weight: 600; color: var(--faint);
  border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px;
  transition: color .16s, background .16s, border-color .16s;
}
.period-mult.on { color: var(--bg); background: var(--gold); border-color: var(--gold); }
.period-hint { color: var(--faint); font-size: 11px; flex: 1 1 200px; min-width: 0; }

/* cache hit-rate slider */
.hitrate { margin-top: 16px; }
.hitrate-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 9px; }
.hitrate-lbl { font-size: 12px; color: var(--text); font-weight: 600; }
.hitrate-val {
  font-family: var(--mono); font-size: 13px; font-weight: 600; color: var(--gold-bright);
  min-width: 42px;
}
.hitrate-presets { display: flex; gap: 6px; flex-wrap: wrap; margin-left: auto; }
.hr-preset {
  font-family: var(--mono); font-size: 10.5px; color: var(--dim);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 4px 9px; cursor: pointer; transition: color .15s, border-color .15s, background .15s;
}
.hr-preset:hover { color: var(--gold-bright); border-color: var(--gold-deep); }
.hr-preset.on { color: var(--bg); background: var(--gold); border-color: var(--gold); }

input[type="range"]#hitSlider {
  -webkit-appearance: none; appearance: none; width: 100%; height: 6px; margin: 4px 0;
  background: linear-gradient(90deg, var(--gold) var(--fill, 75%), var(--bg-2) var(--fill, 75%));
  border: 1px solid var(--border); border-radius: 999px; outline: none; cursor: pointer;
}
#hitSlider::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 18px; height: 18px; border-radius: 50%;
  background: var(--gold-bright); border: 2px solid var(--bg);
  box-shadow: 0 0 10px rgba(240,199,94,0.6); cursor: grab;
}
#hitSlider::-webkit-slider-thumb:active { cursor: grabbing; transform: scale(1.1); }
#hitSlider::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; background: var(--gold-bright);
  border: 2px solid var(--bg); box-shadow: 0 0 10px rgba(240,199,94,0.6); cursor: grab;
}
.hitrate-hint { font-family: var(--mono); font-size: 11px; color: var(--faint); margin: 9px 0 0; line-height: 1.55; }
.hitrate-hint b { color: var(--dim); font-weight: 500; }

.usage-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* paste-from-Hermes box */
.paste-box { margin-top: 14px; }
.paste-box[hidden] { display: none; }
.paste-box textarea {
  width: 100%; min-height: 96px; resize: vertical;
  font-family: var(--mono); font-size: 12px; line-height: 1.5; color: var(--text);
  background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-sm);
  padding: 12px 13px; outline: none; transition: border-color .18s, box-shadow .18s;
}
.paste-box textarea:focus { border-color: var(--gold-deep); box-shadow: 0 0 0 3px rgba(240,199,94,0.08); }
.paste-box textarea::placeholder { color: var(--faint); }
.paste-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.paste-msg { font-family: var(--mono); font-size: 11.5px; color: var(--good); }
.paste-msg.err { color: var(--hot); }
.btn-load {
  font-family: var(--mono); font-size: 12px; color: var(--bg); font-weight: 600;
  background: var(--gold); border: none; border-radius: 999px; padding: 8px 16px; cursor: pointer;
  white-space: nowrap; transition: background .16s, transform .16s;
}
.btn-load:hover { background: var(--gold-bright); }
.btn-load:active { transform: scale(0.96); }

/* ---- podium / featured --------------------------------------------------- */
.podium { margin-bottom: 34px; }
.podium-cap {
  font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--faint); margin: 0 0 12px;
}
.podium-cap::first-letter { color: var(--gold); }
.pod-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.pod-id { display: block; font-family: var(--mono); font-size: 9.5px; color: var(--faint); margin-top: 6px; font-weight: 400; word-break: break-all; }
.pod-missing { opacity: 0.5; }
.pod-missing .pod-cost { color: var(--faint); font-size: 18px; }
.pod {
  position: relative; border-radius: var(--r); padding: 18px 18px 16px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  border: 1px solid var(--border); overflow: hidden;
  transition: transform .2s, border-color .2s;
}
.pod:hover { transform: translateY(-3px); }
.pod-1 { border-color: rgba(240,199,94,0.42); }
.pod-1::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: radial-gradient(120% 80% at 50% -10%, rgba(240,199,94,0.16), transparent 60%);
}
.pod-rank {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--faint); display: flex; align-items: center; gap: 7px; margin-bottom: 12px;
}
.pod-medal { font-size: 15px; }
.pod-1 .pod-medal { filter: drop-shadow(0 0 8px rgba(240,199,94,0.6)); }
.pod-prov {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--dim); margin-bottom: 4px;
}
.pod-name {
  font-family: var(--serif); font-size: 17px; font-weight: 500; line-height: 1.18;
  margin: 0 0 12px; letter-spacing: -0.01em; min-height: 2.3em;
}
.pod-cost {
  font-family: var(--mono); font-weight: 600; font-size: 30px; letter-spacing: -0.02em;
  color: var(--gold-bright); font-variant-numeric: tabular-nums;
}
.pod-1 .pod-cost { text-shadow: 0 0 24px rgba(240,199,94,0.35); }
.pod-cost small { font-size: 13px; color: var(--faint); font-weight: 400; margin-left: 4px; }

/* ---- controls ------------------------------------------------------------ */
.controls {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 12px 0 14px; margin-bottom: 0;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.chips { display: flex; gap: 7px; flex-wrap: wrap; }
.chip {
  font-family: var(--mono); font-size: 12px; color: var(--dim);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 7px 13px; cursor: pointer; display: flex; align-items: center; gap: 7px;
  transition: color .16s, border-color .16s, background .16s;
}
.chip:hover { color: var(--text); }
.chip .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--c, var(--faint)); }
.chip .cnt { color: var(--faint); font-size: 11px; }
.chip.active { color: var(--bg); background: var(--text); border-color: var(--text); }
.chip.active .cnt { color: rgba(11,10,9,0.55); }
.chip.active .dot { box-shadow: 0 0 0 2px rgba(11,10,9,0.25); }

.controls-right { display: flex; align-items: center; gap: 12px; }
.search { position: relative; display: flex; align-items: center; }
.search-ico { position: absolute; left: 12px; color: var(--faint); font-size: 14px; pointer-events: none; }
.search input {
  font-family: var(--mono); font-size: 12.5px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 14px 8px 30px; width: 190px; outline: none; transition: border-color .16s, width .2s;
}
.search input:focus { border-color: var(--gold-deep); width: 230px; }
.sortwrap { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--faint); font-family: var(--mono); }
.sortwrap select {
  font-family: var(--mono); font-size: 12px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 999px;
  padding: 8px 12px; outline: none; cursor: pointer;
}
.sortwrap select option { background: var(--bg-2); }

/* ---- table --------------------------------------------------------------- */
.table-wrap { border: 1px solid var(--border); border-radius: var(--r); overflow: hidden; background: var(--surface); }
table.grid { width: 100%; border-collapse: collapse; }
table.grid thead th {
  text-align: left; font-size: 11px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--faint); padding: 13px 16px; background: var(--bg-2);
  border-bottom: 1px solid var(--border-str); white-space: nowrap;
}
table.grid thead th small { font-weight: 400; text-transform: none; letter-spacing: 0; color: rgba(111,104,93,0.8); }
th.num, td.num { text-align: right; font-variant-numeric: tabular-nums; }
th.col-cost { color: var(--gold); }

tbody tr.row {
  border-bottom: 1px solid var(--border); cursor: pointer;
  transition: background .14s;
}
tbody tr.row:last-child { border-bottom: none; }
tbody tr.row:hover { background: var(--surface-2); }
tbody td { padding: 13px 16px; vertical-align: middle; }

.m-name { display: flex; align-items: center; gap: 11px; }
.m-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--c); flex: none; box-shadow: 0 0 8px -1px var(--c); }
.m-title { font-weight: 600; font-size: 14px; letter-spacing: -0.005em; }
.m-id { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin-top: 1px; }
.tag {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--faint); border: 1px solid var(--border); border-radius: 5px; padding: 1px 5px; margin-left: 7px;
}

td.col-ctx { font-family: var(--mono); font-size: 12.5px; color: var(--dim); }
td.num { font-family: var(--mono); font-size: 13px; color: var(--text); }
td.num.faint { color: var(--faint); }

td.col-cost { position: relative; }
.cost-val {
  font-family: var(--mono); font-size: 14.5px; font-weight: 600; color: var(--gold-bright);
  position: relative; z-index: 1; font-variant-numeric: tabular-nums;
}
.cost-bar {
  position: absolute; right: 16px; bottom: 7px; height: 3px; border-radius: 2px;
  background: linear-gradient(90deg, var(--gold-deep), var(--gold-bright)); opacity: 0.55;
  z-index: 0; transition: width .35s ease;
}
td.col-cost.flash .cost-val { animation: flash .6s ease; }
@keyframes flash { 0% { color: #fff; text-shadow: 0 0 14px rgba(255,220,134,0.9); } 100% { } }

/* expanded breakdown row */
tr.detail td { padding: 0 16px; background: var(--bg-2); }
.detail-inner {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px;
  padding: 14px 0 16px; max-height: 0; overflow: hidden; opacity: 0;
  transition: max-height .3s ease, opacity .25s, padding .3s;
}
tr.detail.open .detail-inner { max-height: 200px; opacity: 1; }
.bd {
  border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; background: var(--surface);
}
.bd-k { font-size: 10.5px; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 4px; }
.bd-v { font-family: var(--mono); font-size: 14px; font-weight: 500; }
.bd-sub { font-family: var(--mono); font-size: 10px; color: var(--faint); margin-top: 2px; }
.bd.total .bd-v { color: var(--gold-bright); }

.empty { text-align: center; color: var(--faint); font-family: var(--mono); font-size: 13px; padding: 40px; }

/* ---- footer -------------------------------------------------------------- */
.foot { margin-top: 30px; color: var(--faint); font-size: 12.5px; line-height: 1.6; max-width: 760px; }
.foot a { color: var(--dim); text-decoration: underline; text-underline-offset: 2px; }
.foot a:hover { color: var(--gold-bright); }
.foot-meta { font-family: var(--mono); font-size: 11px; margin-top: 8px; color: rgba(111,104,93,0.7); }

/* ---- responsive ---------------------------------------------------------- */
@media (max-width: 860px) {
  .usage-grid { grid-template-columns: repeat(2, 1fr); }
  .pod-row { grid-template-columns: 1fr; }
  .controls { flex-direction: column; align-items: stretch; }
  .controls-right { justify-content: space-between; }
  table.grid thead th:nth-child(2),
  tbody td.col-ctx { display: none; }
  .search input { width: 100%; }
  .search { flex: 1; }
}
@media (max-width: 620px) {
  main { padding: 0 13px 70px; }
  .topbar { padding: 16px 13px 12px; flex-wrap: wrap; row-gap: 10px; }
  .hero { padding: 22px 0 20px; }
  .hero-title { font-size: 32px; }
  .hero-lede { font-size: 14.5px; }
  .controls { position: static; }   /* don't eat vertical space on phones */

  /* Mobile table = Model · Input $/M · Your monthly cost.
     Context, Output and Cache columns are dropped so the cost figure is NEVER clipped. */
  table.grid thead th:nth-child(4), tbody td.out-col,
  table.grid thead th:nth-child(5), tbody td.cache-col { display: none; }
  .m-id { display: none; }
  .tag { display: none; }                       /* names stay short on tiny screens */
  table.grid thead th { white-space: normal; }  /* let "Your monthly cost" wrap */
  tbody td, table.grid thead th { padding: 11px 10px; }
  .m-name { gap: 8px; }
  .m-title { font-size: 13px; line-height: 1.25; overflow-wrap: anywhere; }
  td.num, .cost-val { font-size: 13px; }
  th.num small { display: none; }
  .cost-bar { right: 10px; }
  .field input { font-size: 16px; }             /* >=16px stops iOS zoom-on-focus */
  .pod-name { min-height: 0; }
}

@media (max-width: 430px) {
  .usage-grid { grid-template-columns: 1fr; }
  .brand-sub { display: none; }
}
