/* Direction A — the ledger.
 *
 * Two rules run through this file. Codes are set in a monospaced face with
 * tabular figures, because a six-digit number you are copying by eye must not
 * reflow as it changes. And the countdown never goes green to red: blue is the
 * resting state, red is only the last five seconds, and the digits go hollow
 * at the same moment so the colour is never carrying the signal alone.
 */

:root {
  color-scheme: light dark;

  --ground:      #E9EDF2;
  --surface:     #FFFFFF;
  --panel:       #F4F7FB;
  --ink:         #0C131C;
  --muted:       #57667C;
  --faint:       #8394A9;
  --line:        #E3E9F1;
  --edge:        #CBD4E0;
  --accent:      #0A66C2;
  --accent-soft: #E7F0FB;
  --danger:      #B32318;
  --on-accent:   #FFFFFF;

  --shadow: 0 1px 2px rgba(16, 23, 32, .06), 0 12px 32px -12px rgba(16, 23, 32, .22);

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground:      #0B0F15;
    --surface:     #10171F;
    --panel:       #161E28;
    --ink:         #E8EFF7;
    --muted:       #93A2B6;
    --faint:       #6C7C92;
    --line:        #232D3A;
    --edge:        #2C3846;
    --accent:      #58A6FF;
    --accent-soft: #1B2C42;
    --danger:      #FF8A80;
    --on-accent:   #06121F;

    --shadow: 0 1px 2px rgba(0, 0, 0, .5), 0 16px 40px -14px rgba(0, 0, 0, .7);
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

[hidden] { display: none !important; }

button { font: inherit; cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* ------------------------------------------------------------------ chrome */

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  height: 54px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: -.01em;
}
.wordmark svg { display: block; flex: none; }

.filter {
  flex: 1;
  max-width: 300px;
  height: 30px;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.filter::placeholder { color: var(--faint); }

.spacer { margin-left: auto; }

.avatar {
  flex: none;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.signout { display: flex; }

/* ------------------------------------------------------------------ buttons */

.btn {
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 600;
  background: var(--accent);
  color: var(--on-accent);
  white-space: nowrap;
}
.btn:disabled { opacity: .55; cursor: default; }

.btn-quiet {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.btn-wide { width: 100%; }

/* -------------------------------------------------------------- the clock */

.clockbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.clockbar .track {
  flex: 1;
  height: 4px;
  border-radius: 2px;
  background: var(--edge);
  overflow: hidden;
}

.clockbar .fill {
  height: 100%;
  border-radius: 2px;
  background: var(--accent);
  transition: width .95s linear;
}
.clockbar .fill.ending { background: var(--danger); }

@media (prefers-reduced-motion: reduce) {
  .clockbar .fill { transition: none; }
}

.secs {
  min-width: 26px;
  text-align: right;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.secs.ending { color: var(--danger); font-weight: 700; }

/* ------------------------------------------------------------------- rows */

main { background: var(--surface); }

.row {
  display: grid;
  grid-template-columns: 26px minmax(0, 1fr) minmax(0, 1.1fr) auto auto auto;
  align-items: center;
  gap: 14px;
  height: 48px;
  padding: 0 18px;
  border-bottom: 1px solid var(--line);
}
.row:hover { background: var(--panel); }

.glyph {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  border-radius: 5px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

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

.label {
  color: var(--muted);
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.code {
  /* Wide enough for an eight-digit code so the column is the same width in
     every row — otherwise one Steam account knocks all the labels out of
     line. */
  min-width: 118px;
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: .02em;
  text-align: right;
}
/* The last five seconds: red, and hollow, so either signal alone is enough. */
.code.ending {
  color: var(--danger);
  font-weight: 400;
  -webkit-text-stroke: .6px currentColor;
}
.code.broken {
  color: var(--danger);
  font-family: var(--sans);
  font-size: 13px;
}

.own-secs {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--faint);
  min-width: 24px;
  text-align: right;
}

.actions { display: flex; gap: 6px; }

.copy, .remove {
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 600;
  background: transparent;
  color: var(--accent);
  opacity: 0;
  transition: opacity .12s;
}
.remove { color: var(--muted); }
.remove[data-armed="yes"] { color: var(--danger); border-color: var(--danger); opacity: 1; }
.row:hover .copy,
.row:hover .remove,
.copy:focus-visible,
.remove:focus-visible { opacity: 1; }

@media (prefers-reduced-motion: reduce) {
  .copy, .remove { transition: none; }
}

.empty {
  padding: 34px 18px;
  text-align: center;
  color: var(--muted);
}

/* ------------------------------------------------------------------ cards */

.stage {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.card {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 22px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.card h1 {
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.01em;
}

.field { display: flex; flex-direction: column; gap: 4px; }

.field > span {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  color: var(--muted);
}

.field input {
  padding: 8px 10px;
  border: 1px solid var(--edge);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
}
.field input[type="password"] { font-family: var(--mono); letter-spacing: .06em; }

.fine {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}
.fine a { color: var(--accent); }

.fine.split {
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

/* Errors are red because they are genuinely negative, and they say what to do
   next rather than apologising. */
.problem {
  margin: 0;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--accent-soft);
  border-left: 3px solid var(--danger);
  color: var(--ink);
  font-size: 12.5px;
  line-height: 1.5;
}

/* ------------------------------------------------------------------ dialog */

.scrim {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(12, 19, 28, .45);
  backdrop-filter: blur(2px);
}

.scrim .card { max-width: 420px; }

.or {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11px;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--faint);
}
.or::before, .or::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.dialog-actions { display: flex; gap: 8px; justify-content: flex-end; }

.two-up { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

@media (max-width: 520px) {
  .row { grid-template-columns: 26px minmax(0, 1fr) auto auto; }
  .row .label { display: none; }
  .two-up { grid-template-columns: 1fr; }
}
