:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f1f3f6;
  --text: #16181d;
  --muted: #5d6472;
  --border: #e3e6eb;
  --border-strong: #cfd4dc;
  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef0ff;
  --on-accent: #ffffff;
  --danger: #c2322b;
  --danger-hover: #a8261f;
  --danger-soft: #fdeceb;
  --success: #17804a;
  --success-soft: #e7f6ee;
  --focus: 0 0 0 3px rgba(79, 70, 229, 0.35);
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --surface: #171a21;
    --surface-2: #1e222b;
    --text: #e8eaef;
    --muted: #9aa2b1;
    --border: #272c36;
    --border-strong: #363c48;
    --accent: #7c75ff;
    --accent-hover: #918bff;
    --accent-soft: #23234a;
    --on-accent: #0f1115;
    --danger: #f06a61;
    --danger-hover: #ff8078;
    --danger-soft: #3a1c1b;
    --success: #4cc488;
    --success-soft: #16301f;
    --focus: 0 0 0 3px rgba(124, 117, 255, 0.45);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

h1,
h2 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

h1 {
  font-size: 1.6rem;
  font-weight: 650;
}

h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

p {
  margin: 0.5rem 0 0;
}

a {
  color: var(--accent);
}

code {
  font-family: var(--mono);
  font-size: 0.9em;
}

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

.small {
  font-size: 0.85rem;
}

/* ---- top bar ------------------------------------------------------------------------------ */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.65rem clamp(1rem, 4vw, 2rem);
  background: color-mix(in srgb, var(--surface) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--text);
  font-weight: 650;
  text-decoration: none;
  min-width: 0;
}

.brand > span:first-of-type {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logo {
  flex: none;
  display: block;
}

.badge {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.75rem;
  font-weight: 600;
}

.account {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.account form {
  margin: 0;
}

.avatar {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--surface-2);
}

.avatar-fallback {
  display: inline-grid;
  place-items: center;
  color: var(--accent);
  background: var(--accent-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.account-email {
  color: var(--muted);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 26ch;
}

@media (max-width: 640px) {
  .account-email,
  .badge {
    display: none;
  }
}

/* ---- layout ------------------------------------------------------------------------------- */

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem) 4rem;
}

.container.narrow {
  max-width: 520px;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.page-head > div {
  min-width: 0;
}

.page-head p {
  max-width: 60ch;
}

.page-head .btn {
  flex: none;
}

@media (max-width: 640px) {
  .page-head {
    flex-direction: column;
    gap: 1rem;
  }
}

.back {
  display: inline-block;
  margin-bottom: 1rem;
  color: var(--muted);
  font-size: 0.9rem;
  text-decoration: none;
}

.back:hover {
  color: var(--text);
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(1.1rem, 3vw, 1.5rem);
  margin-bottom: 1.25rem;
  scroll-margin-top: 5rem;
}

.card > h2 + p,
.card > h2 + .facts {
  margin-top: 0.75rem;
}

.card-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

.card.center {
  text-align: center;
}

.card.center .btn {
  margin-top: 1.25rem;
}

.card-danger {
  border-color: color-mix(in srgb, var(--danger) 30%, var(--border));
}

.card form:not(.form) {
  margin-top: 1rem;
}

/* ---- endpoint list ------------------------------------------------------------------------ */

.endpoint-list {
  list-style: none;
  margin: 1rem calc(-1 * clamp(1.1rem, 3vw, 1.5rem)) calc(-1 * clamp(1.1rem, 3vw, 1.5rem));
  padding: 0;
  border-top: 1px solid var(--border);
}

.endpoint-list li + li {
  border-top: 1px solid var(--border);
}

.endpoint-row {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.9rem clamp(1.1rem, 3vw, 1.5rem);
  color: inherit;
  text-decoration: none;
  transition: background 0.12s;
}

.endpoint-list li:last-child .endpoint-row {
  border-radius: 0 0 var(--radius) var(--radius);
}

.endpoint-row:hover {
  background: var(--surface-2);
}

.endpoint-row:focus-visible {
  outline: none;
  box-shadow: inset var(--focus);
}

.endpoint-main {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

.endpoint-name {
  font-weight: 600;
}

.endpoint-url {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.85rem;
  overflow-wrap: anywhere;
}

.endpoint-main .endpoint-url {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.endpoint-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.15rem;
  flex: none;
}

.chevron {
  color: var(--muted);
  font-size: 1.4rem;
  line-height: 1;
}

@media (max-width: 640px) {
  .endpoint-row {
    flex-wrap: wrap;
  }
  .endpoint-main {
    flex-basis: calc(100% - 2rem);
  }
  .endpoint-meta {
    order: 3;
    flex-direction: row;
    align-items: center;
    gap: 0.75rem;
  }
}

.key-hint {
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  white-space: nowrap;
}

.empty {
  padding: 1.5rem 0 0.5rem;
  text-align: center;
}

/* ---- facts -------------------------------------------------------------------------------- */

.facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 2.5rem;
  margin: 0;
}

.facts dt {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.facts dd {
  margin: 0.2rem 0 0;
}

/* ---- key reveal --------------------------------------------------------------------------- */

.key-reveal {
  border-color: var(--accent);
  background: linear-gradient(0deg, var(--surface), var(--surface)) padding-box,
    linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 40%, #22d3ee)) border-box;
  border: 2px solid transparent;
}

.key-box {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 0.6rem 0.6rem 0.6rem 0.9rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.key-box code {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 0.92rem;
  user-select: all;
}

.secret-note {
  margin-top: 1rem;
  padding: 0.6rem 0.85rem;
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  background: var(--accent-soft);
  font-size: 0.92rem;
}

/* ---- where the key lives ------------------------------------------------------------------ */

.card h3 {
  margin: 1.5rem 0 0;
  font-size: 0.95rem;
  font-weight: 600;
}

.flow {
  display: flex;
  gap: 2rem;
  margin: 1rem 0 0;
  padding: 0;
  list-style: none;
}

.flow-step {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow-wrap: anywhere;
}

.flow-step + .flow-step::before {
  content: "→";
  position: absolute;
  left: -1.45rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  font-size: 1.1rem;
  line-height: 1;
}

.flow-key {
  border-color: var(--accent);
  background: var(--accent-soft);
}

@media (max-width: 640px) {
  .flow {
    flex-direction: column;
    gap: 1.6rem;
  }
  .flow-step + .flow-step::before {
    content: "↓";
    left: 50%;
    top: -1.35rem;
    transform: translateX(-50%);
  }
}

/* ---- forms -------------------------------------------------------------------------------- */

.form {
  margin-top: 1rem;
}

.field + .field {
  margin-top: 1rem;
}

.field label {
  display: block;
  margin-bottom: 0.35rem;
  font-weight: 550;
  font-size: 0.92rem;
}

.field input {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.field input[type="url"] {
  font-family: var(--mono);
  font-size: 0.9rem;
}

.field input::placeholder {
  color: color-mix(in srgb, var(--muted) 70%, transparent);
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: var(--focus);
}

.field .hint {
  margin-top: 0.35rem;
  color: var(--muted);
  font-size: 0.85rem;
}

.field .error {
  margin-top: 0.35rem;
  color: var(--danger);
  font-size: 0.85rem;
  font-weight: 500;
}

.field.has-error input {
  border-color: var(--danger);
}

.actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  padding: 0.6rem 1rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.92rem;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s, color 0.12s;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus);
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-secondary:hover {
  background: var(--surface-2);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
}

.btn-ghost:hover {
  background: var(--surface-2);
  color: var(--text);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

/* ---- alerts ------------------------------------------------------------------------------- */

.alert {
  margin: 0 0 1.25rem;
  padding: 0.7rem 0.9rem;
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
}

.alert-error {
  background: var(--danger-soft);
  color: var(--danger);
}

.alert-success {
  background: var(--success-soft);
  color: var(--success);
}

/* ---- sign-in ------------------------------------------------------------------------------ */

.auth {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 1.5rem 1rem;
  background: radial-gradient(60rem 30rem at 50% -10%, var(--accent-soft), transparent 70%), var(--bg);
}

.auth-card {
  width: 100%;
  max-width: 400px;
  padding: 2.25rem 2rem 1.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px -12px rgba(16, 24, 40, 0.18);
  text-align: center;
}

.auth-card .logo {
  margin: 0 auto 1.1rem;
}

.auth-card h1 {
  font-size: 1.4rem;
}

.auth-card .badge {
  display: inline-block;
  margin-top: 0.6rem;
}

.auth-card .alert {
  margin: 1.25rem 0 0;
  text-align: left;
}

.btn-google {
  width: 100%;
  margin-top: 1.5rem;
  padding: 0.7rem 1rem;
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}

.btn-google:hover {
  background: var(--surface-2);
}

.fineprint {
  margin-top: 1.25rem;
  color: var(--muted);
  font-size: 0.8rem;
}

/* ---- copy feedback ------------------------------------------------------------------------ */

.copied {
  background: var(--success) !important;
  color: #fff !important;
}
