/* OpenRouter key monitor
   -------------------------------------------------------------------------
   Two type roles: system sans carries prose, monospace carries every number.
   Money in a proportional face misaligns and reads as marketing; in mono it
   reads as an instrument, which is what this page is.

   The palette is cool blue-slate rather than neutral grey so the surfaces have
   a temperature of their own, and the three status colours stay reserved for
   the one thing that is actually a signal: how close the key is to its limit.

   No webfonts by design — the Content-Security-Policy restricts every subresource
   to this origin, so nothing here can phone home while a key is on screen.
*/

:root {
  color-scheme: light dark;

  --ground:    #EEF1F6;
  --surface:   #FFFFFF;
  --sunken:    #F4F6FA;
  --line:      #DDE3ED;
  --ink:       #131A26;
  --ink-muted: #5D6980;
  --ink-faint: #8B95A8;

  --accent:    #3A6FD8;
  --ok:        #1F9E76;
  --warn:      #B87A12;
  --critical:  #CE4149;

  --radius: 14px;
  --radius-sm: 9px;
  --pad: 26px;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:    #0F131B;
    --surface:   #171D28;
    --sunken:    #1D2431;
    --line:      #2A3341;
    --ink:       #E7ECF4;
    --ink-muted: #97A2B6;
    --ink-faint: #6B7689;

    --accent:    #6C9BF5;
    --ok:        #3ECF9B;
    --warn:      #E3A83C;
    --critical:  #F0666E;
  }
}

* { box-sizing: border-box; }

/* Author display rules (.tiles is a grid, .identity a flex row) outrank the UA
   stylesheet's [hidden] rule, so state toggling needs this to bite. */
[hidden] { display: none !important; }

body {
  margin: 0;
  padding: 40px 20px 64px;
  min-height: 100vh;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.sr-only {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.shell {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
}

/* ---- masthead ---- */

.masthead { margin-bottom: 26px; }

.masthead__title {
  margin: 0;
  font-size: 21px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.masthead__title span {
  color: var(--ink-muted);
  font-weight: 400;
}

.masthead__sub {
  margin: 5px 0 0;
  color: var(--ink-muted);
  font-size: 14.5px;
}

/* ---- panels ---- */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: var(--pad);
}

.panel--flush { padding: 0; overflow: hidden; }

/* ---- entry form ---- */

.field-label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.field {
  display: flex;
  align-items: stretch;
  background: var(--sunken);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  transition: border-color 120ms ease;
}

.field:focus-within { border-color: var(--accent); }

.field input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 0;
  background: none;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 14px;
  letter-spacing: 0.01em;
}

.field input:focus { outline: none; }
.field input::placeholder { color: var(--ink-faint); }

.field__reveal {
  padding: 0 14px;
  border: 0;
  border-left: 1px solid var(--line);
  background: none;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 12px;
  cursor: pointer;
}

.field__reveal:hover { color: var(--ink); }

.btn {
  width: 100%;
  margin-top: 14px;
  padding: 12px 18px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  font-family: inherit;
  font-size: 15px;
  font-weight: 550;
  cursor: pointer;
  transition: filter 120ms ease;
}

.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: default; }

:where(button, input, a):focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.assurance {
  margin: 18px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  color: var(--ink-faint);
  font-size: 12.5px;
  line-height: 1.55;
}

.alert {
  margin: 14px 0 0;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--critical) 12%, transparent);
  color: var(--critical);
  font-size: 13.5px;
}

/* ---- results ---- */

.identity {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 15px var(--pad);
  border-bottom: 1px solid var(--line);
  background: var(--sunken);
}

.identity__label {
  font-size: 14px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.identity__key {
  margin-left: auto;
  flex-shrink: 0;
  color: var(--ink-faint);
  font-family: var(--mono);
  font-size: 11.5px;
}

.badge {
  flex-shrink: 0;
  padding: 2px 7px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--ok) 15%, transparent);
  color: var(--ok);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.eyebrow {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-faint);
}

/* The bottom padding lives on the hero rather than on what follows it, because
   what follows changes: a gauge, a tile grid, or nothing at all. */
.hero { padding: 26px var(--pad) 24px; }

.hero__figure {
  margin: 7px 0 0;
  font-family: var(--mono);
  font-size: clamp(32px, 9vw, 42px);
  font-weight: 600;
  letter-spacing: -0.035em;
  font-variant-numeric: tabular-nums;
  line-height: 1.05;
}

.hero__note {
  margin: 9px 0 0;
  color: var(--ink-muted);
  font-size: 13px;
}

/* The signature: a discrete tick gauge. Segments, not a smooth bar — spending
   against a credit limit is a measurement, and measurements have graduations. */

.gauge { padding: 0 var(--pad) 4px; }

.gauge__ticks {
  display: flex;
  gap: 2px;
  height: 26px;
}

.gauge__tick {
  flex: 1;
  border-radius: 1px;
  background: var(--line);
  transform-origin: bottom;
  transition: background-color 200ms ease;
}

.gauge__tick--on { background: var(--gauge-color, var(--accent)); }

.gauge__caption {
  margin: 10px 0 0;
  color: var(--ink-muted);
  font-family: var(--mono);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}

.gauge__caption b {
  color: var(--gauge-color, var(--ink));
  font-weight: 600;
}

/* ---- tiles ---- */

.tiles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin: 20px 0 0;
  border-top: 1px solid var(--line);
  background: var(--line);
}

.tile {
  padding: 16px var(--pad);
  background: var(--surface);
}

.tile--wide { grid-column: 1 / -1; }

.tile__figure {
  margin: 6px 0 0;
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 550;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.tile__figure--sm { font-size: 14px; font-weight: 500; }

.result-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 13px var(--pad);
  border-top: 1px solid var(--line);
  background: var(--sunken);
  color: var(--ink-faint);
  font-size: 12px;
}

.result-foot__actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.link-btn {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
}

.link-btn:hover:not(:disabled) { text-decoration: underline; }
.link-btn:disabled { opacity: 0.5; cursor: default; }

/* Secondary of the two footer actions: refreshing is the common one, starting
   over is the exit. */
.link-btn--quiet { color: var(--ink-muted); font-weight: 500; }

/* A failed refresh reports here rather than in the entry form, so the figures
   already on screen survive it. */
.alert--inline { margin: 16px var(--pad); font-size: 13px; }

/* ---- loading skeleton ---- */

.skel {
  background: var(--line);
  border-radius: 6px;
  animation: pulse 1.4s ease-in-out infinite;
}

.skel--strip  { height: 49px; border-radius: 0; }
.skel--hero   { height: 44px; margin: 26px var(--pad) 0; width: 62%; }
.skel--gauge  { height: 26px; margin: 22px var(--pad) 0; }
.skel-row     { display: flex; gap: 1px; margin-top: 26px; border-top: 1px solid var(--line); }
.skel--tile   { flex: 1; height: 54px; border-radius: 0; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0.45; }
}

/* One orchestrated reveal rather than scattered effects: the panel settles,
   then the gauge fills left to right. */

.reveal { animation: rise 260ms cubic-bezier(0.2, 0.7, 0.3, 1) both; }

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

.gauge__tick--animate { animation: tick-in 260ms ease both; }

@keyframes tick-in {
  from { transform: scaleY(0.25); opacity: 0; }
  to   { transform: none; opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

@media (max-width: 420px) {
  :root { --pad: 18px; }
  body { padding-top: 28px; }
  .identity { flex-wrap: wrap; }
  .identity__key { margin-left: 0; width: 100%; }
}
