/* Flat, borderless layers like the desktop app. Follows the system light/dark setting. */
:root {
  color-scheme: light dark;
  --bg: #f4f4f6;
  --side: #ececf0;
  --card: #ffffff;
  --row: #f1f1f4;
  --hover: #e9e9ee;
  --raised: #e2e2e8;
  --ink: #121214;
  --muted: #6c6c76;
  --accent: #121214;
  --accent-ink: #ffffff;
  --good: #1f9d57;
  --good-bg: rgba(31, 157, 87, 0.13);
  --warn: #b7791f;
  --warn-bg: rgba(183, 121, 31, 0.15);
  --bad: #d23f3f;
  --bad-bg: rgba(210, 63, 63, 0.12);
  --info: #3b6fd4;
  --info-bg: rgba(59, 111, 212, 0.13);
  --radius: 16px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #080808;
    --side: #0d0d0d;
    --card: #101010;
    --row: #171717;
    --hover: #1e1e1e;
    --raised: #242424;
    --ink: #f2f2f2;
    --muted: #8f8f99;
    --accent: #ffffff;
    --accent-ink: #080808;
    --good: #5ad18a;
    --good-bg: rgba(90, 209, 138, 0.14);
    --warn: #e6b450;
    --warn-bg: rgba(230, 180, 80, 0.14);
    --bad: #f06b6b;
    --bad-bg: rgba(240, 107, 107, 0.14);
    --info: #7aa2f7;
    --info-bg: rgba(122, 162, 247, 0.14);
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

a {
  color: inherit;
}

svg.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  border: 0;
  border-radius: 999px;
  padding: 9px 18px;
  background: var(--raised);
  white-space: nowrap;
  transition:
    background 140ms,
    transform 140ms,
    opacity 140ms;
}

button:hover:not(:disabled) {
  background: var(--hover);
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

button.primary {
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  opacity: 0.86;
  background: var(--accent);
}

button.danger {
  color: var(--bad);
  background: var(--bad-bg);
}

button.ghost {
  background: transparent;
}

button.ghost:hover:not(:disabled) {
  background: var(--hover);
}

button.small {
  padding: 6px 14px;
  font-size: 13px;
}

button.block {
  width: 100%;
}

input,
textarea {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 11px 14px;
  background: var(--row);
  outline: 2px solid transparent;
  transition: outline-color 140ms;
}

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

textarea {
  min-height: 120px;
  resize: vertical;
}

label {
  display: block;
  margin: 14px 0 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

h1,
h2,
h3 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 22px;
}

h2 {
  font-size: 15px;
}

p {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.mono {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 12.5px;
}

.error {
  color: var(--bad);
  min-height: 1.5em;
}

/* ---- sign-in ---- */
.center {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.login {
  width: min(440px, 100%);
  background: var(--card);
  border-radius: 24px;
  padding: 32px 28px 28px;
  display: grid;
  gap: 18px;
}

.login .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.login .brand img {
  width: 44px;
  height: 44px;
  border-radius: 12px;
}

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

.steps i {
  flex: 1;
  height: 4px;
  border-radius: 99px;
  background: var(--raised);
}

.steps i.done {
  background: var(--accent);
}

.code {
  font-size: 30px;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-align: center;
  padding: 18px;
  border-radius: 14px;
  background: var(--row);
  user-select: all;
}

.secret {
  word-break: break-all;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--row);
  user-select: all;
}

.qr {
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 16px;
  background: #ffffff;
  width: fit-content;
  margin: 0 auto;
}

.qr img {
  display: block;
  width: 200px;
  height: 200px;
  image-rendering: pixelated;
}

.stack {
  display: grid;
  gap: 14px;
}

.row-inline {
  display: flex;
  gap: 8px;
  align-items: center;
}

.row-inline > :first-child {
  flex: 1;
  min-width: 0;
}

.code-input {
  text-align: center;
  font-size: 24px;
  letter-spacing: 0.3em;
  padding: 14px;
}

/* ---- app shell ---- */
.app {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

.side {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 14px;
  background: var(--side);
}

.side .brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 18px;
  font-weight: 650;
  font-size: 15px;
}

.side .brand img {
  width: 30px;
  height: 30px;
  border-radius: 9px;
}

.side .brand small {
  display: block;
  font-weight: 400;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.1;
}

.nav {
  display: grid;
  gap: 2px;
}

.nav button {
  justify-content: flex-start;
  padding: 10px 12px;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 500;
}

.nav button:hover:not(:disabled) {
  background: var(--hover);
  color: var(--ink);
}

.nav button[aria-current="page"] {
  background: var(--card);
  color: var(--ink);
}

.nav .count {
  margin-left: auto;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 99px;
  background: var(--warn-bg);
  color: var(--warn);
}

.side .grow {
  flex: 1;
}

.me {
  display: grid;
  gap: 8px;
  padding: 12px;
  border-radius: 14px;
  background: var(--card);
}

.me small {
  color: var(--muted);
  font-size: 12px;
}

.main {
  padding: 28px clamp(16px, 4vw, 44px) 80px;
  max-width: 1120px;
  width: 100%;
}

.page-head {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-head .grow {
  flex: 1;
}

.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 22px;
}

.card + .card {
  margin-top: 14px;
}

.card h2 {
  margin-bottom: 4px;
}

.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  margin-bottom: 14px;
}

.stat {
  background: var(--card);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat b {
  display: block;
  font-size: 28px;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-top: 2px;
}

.filters {
  display: flex;
  gap: 6px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.filters button {
  background: var(--card);
  color: var(--muted);
  padding: 6px 14px;
  font-size: 13px;
}

.filters button[aria-pressed="true"] {
  background: var(--accent);
  color: var(--accent-ink);
}

/* ---- releases ---- */
.list {
  display: grid;
  gap: 12px;
}

.release {
  display: grid;
  gap: 14px;
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px 22px;
}

.release .top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.version {
  font-size: 20px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 99px;
  padding: 3px 11px;
  font-size: 12px;
  font-weight: 550;
  background: var(--raised);
  color: var(--muted);
}

.badge.published {
  background: var(--good-bg);
  color: var(--good);
}

.badge.ready {
  background: var(--warn-bg);
  color: var(--warn);
}

.badge.draft {
  background: var(--info-bg);
  color: var(--info);
}

.badge.yanked {
  background: var(--bad-bg);
  color: var(--bad);
}

.release .when {
  margin-left: auto;
  color: var(--muted);
  font-size: 12.5px;
}

.meter {
  display: grid;
  gap: 6px;
}

.meter .track {
  height: 8px;
  border-radius: 99px;
  background: var(--raised);
  overflow: hidden;
}

.meter .track i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--good);
  transition: width 300ms;
}

.meter .label {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12.5px;
}

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

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  padding: 5px 10px;
  background: var(--row);
  font-size: 12.5px;
}

.chip.gone {
  opacity: 0.5;
  text-decoration: line-through;
}

.notes {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--row);
  white-space: pre-wrap;
}

.notes small {
  color: var(--muted);
}

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

.empty {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 56px 20px;
  text-align: center;
  background: var(--card);
  border-radius: var(--radius);
  color: var(--muted);
}

.empty svg.icon {
  width: 36px;
  height: 36px;
  stroke-width: 1.4;
}

/* ---- charts, tokens, settings ---- */
.bars {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.bar-line {
  display: grid;
  grid-template-columns: 110px 1fr 70px;
  align-items: center;
  gap: 12px;
}

.bar-line .track {
  height: 10px;
  border-radius: 99px;
  background: var(--raised);
  overflow: hidden;
}

.bar-line i {
  display: block;
  height: 100%;
  border-radius: 99px;
  background: var(--accent);
  min-width: 4px;
}

.token-once {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border-radius: 14px;
  background: var(--warn-bg);
}

.item {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 20px;
}

.item .grow {
  flex: 1;
  min-width: 160px;
}

.toggle {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 14px 0;
}

.toggle + .toggle {
  border-top: 1px solid var(--raised);
}

.toggle .text {
  flex: 1;
}

.toggle small {
  display: block;
  color: var(--muted);
}

.switch {
  position: relative;
  flex: none;
  width: 44px;
  height: 26px;
  padding: 0;
  border-radius: 99px;
  background: var(--raised);
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--card);
  transition: transform 160ms;
}

.switch[aria-checked="true"] {
  background: var(--good);
}

.switch[aria-checked="true"]::after {
  transform: translateX(18px);
  background: #fff;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  text-align: left;
  padding: 10px 12px;
  vertical-align: top;
}

th {
  color: var(--muted);
  font-weight: 500;
  font-size: 12px;
}

tbody tr:nth-child(odd) td {
  background: var(--row);
}

td:first-child {
  border-radius: 10px 0 0 10px;
}

td:last-child {
  border-radius: 0 10px 10px 0;
}

/* ---- dialogs and toasts ---- */
dialog {
  border: 0;
  border-radius: 22px;
  background: var(--card);
  color: var(--ink);
  padding: 26px;
  width: min(480px, calc(100vw - 32px));
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(2px);
}

dialog .actions {
  justify-content: flex-end;
  margin-top: 20px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translateX(-50%);
  background: var(--accent);
  color: var(--accent-ink);
  padding: 11px 20px;
  border-radius: 999px;
  max-width: calc(100vw - 32px);
  z-index: 10;
}

.toast.bad {
  background: var(--bad);
  color: #fff;
}

/* ---- small screens: the sidebar becomes a top bar ---- */
@media (max-width: 860px) {
  .app {
    grid-template-columns: 1fr;
  }

  .side {
    position: static;
    height: auto;
    flex-direction: row;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    overflow-x: auto;
  }

  .side .brand {
    padding: 0 8px 0 0;
  }

  .side .brand small,
  .me small,
  .side .grow {
    display: none;
  }

  .nav {
    display: flex;
  }

  .nav button span.label {
    display: none;
  }

  .me {
    padding: 0;
    background: transparent;
  }

  .main {
    padding-top: 18px;
  }

  .bar-line {
    grid-template-columns: 80px 1fr 50px;
  }

  .release .when {
    margin-left: 0;
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  * {
    transition: none !important;
  }
}

/* ---- code slots: one hidden input behind six slots; digits rise in, errors drain red, success merges ---- */
.slots {
  --slot-w: 50px;
  --slot-h: 60px;
  --gap: 8px;
  --r: 14px;
  position: relative;
  display: flex;
  justify-content: center;
  gap: var(--gap);
  margin: 4px 0;
  transition: gap 380ms cubic-bezier(0.3, 0.9, 0.3, 1);
}

.slots input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  padding: 0;
  font-size: 16px; /* keeps phones from zooming in */
  cursor: text;
  z-index: 2;
}

.slot {
  position: relative;
  width: var(--slot-w);
  height: var(--slot-h);
  border-radius: var(--r);
  background: var(--row);
  display: grid;
  place-items: center;
  overflow: hidden;
  box-shadow: inset 0 0 0 2px transparent;
  transition:
    box-shadow 160ms,
    border-radius 380ms,
    background 160ms;
}

.slots.focused .slot.active {
  box-shadow: inset 0 0 0 2px var(--ink);
  background: color-mix(in srgb, var(--ink) 8%, var(--row));
}

.slot .fill {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--accent);
  opacity: 0;
  transform: scale(0.55);
}

.slot .digit {
  position: relative;
  font-size: 26px;
  font-weight: 650;
  color: var(--accent-ink);
  opacity: 0;
  transform: translateY(8px);
}

.slot.landed .fill {
  animation: slot-land 300ms cubic-bezier(0.34, 1.45, 0.64, 1) both;
  animation-delay: var(--d, 0ms);
}

.slot.landed .digit {
  animation: slot-rise 300ms cubic-bezier(0.34, 1.45, 0.64, 1) both;
  animation-delay: var(--d, 0ms);
}

.slot.draining .fill,
.slot.draining .digit {
  animation: slot-drain 280ms ease-in both;
  animation-delay: var(--d, 0ms);
}

.slot .caret {
  display: none;
  width: 2px;
  height: 26px;
  border-radius: 2px;
  background: var(--ink);
  animation: slot-blink 1.05s steps(2, start) infinite;
}

.slots.focused .slot.active:not(.landed) .caret {
  display: block;
}

.slots.error .slot .fill {
  background: var(--bad);
}

.slots.error {
  animation: slot-shake 380ms ease;
}

.slots.error .slot {
  box-shadow: inset 0 0 0 2px var(--bad);
}

/* Success: the slots close up and their fills become one band. */
.slots.success {
  --gap: 0px;
}

.slots.success .slot {
  border-radius: 0;
  box-shadow: none;
  background: transparent;
}

.slots.success .slot:first-of-type {
  border-radius: var(--r) 0 0 var(--r);
}

.slots.success .slot:last-of-type {
  border-radius: 0 var(--r) var(--r) 0;
}

.slots.success .fill {
  background: var(--good);
}

.slots.success .digit {
  color: #fff;
}

.slots.locked input {
  pointer-events: none;
}

@keyframes slot-land {
  from {
    opacity: 0;
    transform: scale(0.55);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes slot-rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slot-drain {
  from {
    opacity: 1;
    transform: none;
  }
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.8);
  }
}

@keyframes slot-blink {
  to {
    visibility: hidden;
  }
}

@keyframes slot-shake {
  20% {
    transform: translateX(-6px);
  }
  45% {
    transform: translateX(5px);
  }
  70% {
    transform: translateX(-3px);
  }
}

@media (max-width: 420px) {
  .slots {
    --slot-w: 44px;
    --slot-h: 54px;
    --gap: 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .slot.landed .fill,
  .slot.landed .digit,
  .slot.draining .fill,
  .slot.draining .digit,
  .slots.error {
    animation-duration: 1ms !important;
    animation-delay: 0ms !important;
  }
}
