:root {
  --surface: rgba(28, 28, 32, 0.82);
  --line: rgba(255, 255, 255, 0.09);
  --text: #f4f4f6;
  --muted: #a2a2aa;
  --accent: #18a36f;
  --shadow: 0 36px 88px rgba(0, 0, 0, 0.42);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 50% 16%, rgba(255, 255, 255, 0.05), transparent 20%),
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.03), transparent 30%),
    linear-gradient(180deg, #19191b 0%, #131315 100%);
  color: var(--text);
  font-family: "SF Pro Display", "Segoe UI", "PingFang SC", sans-serif;
}

body,
button,
input,
a {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.page-shell,
.auth-frame {
  width: 100vw;
  min-height: 100vh;
}

.auth-frame {
  display: grid;
  padding: clamp(56px, 10vh, 96px) 24px clamp(40px, 8vh, 72px);
  place-items: center;
}

.auth-panel {
  position: relative;
  z-index: 3;
  display: flex;
  width: min(100%, 1040px);
  align-items: flex-start;
  justify-content: center;
}

.auth-card {
  display: grid;
  width: min(360px, calc(100vw - 48px));
  gap: 12px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), var(--shadow);
  backdrop-filter: blur(18px);
}

.auth-card--setup {
  width: min(380px, calc(100vw - 48px));
}

.view,
.form-grid {
  display: grid;
  gap: 10px;
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
}

.view-title,
.view-message {
  margin: 0;
  text-align: center;
}

.view-title {
  color: var(--text);
  font-size: 18px;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.view-message {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

.error {
  display: none;
  padding: 10px 12px;
  border: 1px solid rgba(255, 92, 92, 0.18);
  border-radius: 14px;
  color: #ffdede;
  background: rgba(255, 92, 92, 0.12);
  font-size: 12px;
  line-height: 1.5;
}

.error.is-visible {
  display: block;
}

.server-error {
  order: -1;
}

.field-label {
  color: #d0d0d5;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

input {
  width: 100%;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  outline: 0;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-size: 14px;
  line-height: 1.2;
}

input::placeholder {
  color: rgba(244, 244, 246, 0.5);
}

input:focus {
  border-color: rgba(24, 163, 111, 0.54);
  box-shadow: 0 0 0 4px rgba(24, 163, 111, 0.12);
}

.field-shell {
  display: flex;
  gap: 8px;
  align-items: stretch;
}

.field-shell input {
  min-width: 0;
}

.field-inline-action {
  flex-shrink: 0;
  min-height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(24, 163, 111, 0.26);
  border-radius: 12px;
  color: #daf8ed;
  background: rgba(24, 163, 111, 0.14);
  font-size: 13px;
  line-height: 1;
  white-space: nowrap;
}

.field-inline-action:disabled {
  cursor: not-allowed;
  border-color: rgba(255, 255, 255, 0.1);
  color: rgba(244, 244, 246, 0.48);
  background: rgba(255, 255, 255, 0.08);
}

.button-stack {
  display: grid;
  gap: 8px;
}

.primary-button,
.ghost-button {
  min-height: 38px;
  padding: 0 14px;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 700;
}

.primary-button {
  border: 0;
  color: #fff;
  background: linear-gradient(180deg, #1aba7d 0%, #149968 100%);
  box-shadow: 0 14px 34px rgba(24, 163, 111, 0.26);
}

.ghost-button {
  display: grid;
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #d7d7db;
  background: rgba(255, 255, 255, 0.08);
  place-items: center;
}

.text-link {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.4;
  text-align: center;
}

.text-link button {
  padding: 0;
  border: 0;
  color: #dff8ec;
  background: transparent;
  font-weight: 700;
}

.status-mark {
  width: 34px;
  height: 34px;
  margin: 2px auto 4px;
  border: 2px solid rgba(255, 255, 255, 0.16);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: auth-spin 0.9s linear infinite;
}

.status-mark--static {
  display: grid;
  border: 1px solid rgba(24, 163, 111, 0.28);
  color: #dff8ec;
  background: rgba(24, 163, 111, 0.14);
  animation: none;
  place-items: center;
  font-size: 17px;
  font-weight: 800;
}

.status-mark--warning {
  border-color: rgba(255, 196, 92, 0.28);
  color: #ffe6b3;
  background: rgba(255, 196, 92, 0.12);
}

.status-mark--danger {
  border-color: rgba(255, 92, 92, 0.25);
  color: #ffdede;
  background: rgba(255, 92, 92, 0.12);
}

@keyframes auth-spin {
  to { transform: rotate(360deg); }
}

.qr-shell {
  display: grid;
  gap: 12px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
}

.qr-image {
  display: block;
  width: 176px;
  height: 176px;
  margin: 0 auto;
  padding: 12px;
  border-radius: 20px;
  background: #fff;
  object-fit: contain;
}

.qr-image:not([src]),
.qr-image[src=""] {
  visibility: hidden;
}

.secret-box {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.22);
}

.secret-code {
  color: #dff8ec;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  line-height: 1.55;
  word-break: break-all;
}

[hidden] {
  display: none !important;
}

@media (max-width: 640px) {
  .auth-frame {
    padding: 44px 16px 36px;
  }

  .auth-card {
    width: min(360px, calc(100vw - 32px));
    padding: 18px;
  }

  .field-shell {
    display: grid;
  }
}
