:root {
  --red: #e30613;
  --red-dark: #b80510;
  --bg1: #f7f8fb;
  --bg2: #ffffff;
  --text: #111827;
  --muted: #667085;
  --card: rgba(255,255,255,.78);
  --border: rgba(17,24,39,.1);
  --shadow: 0 24px 80px rgba(16,24,40,.14);
}

[data-theme="dark"] {
  --bg1: #070a12;
  --bg2: #151927;
  --text: #f8fafc;
  --muted: #a7b0c0;
  --card: rgba(15, 23, 42, .74);
  --border: rgba(255,255,255,.12);
  --shadow: 0 24px 90px rgba(0,0,0,.42);
}

* { box-sizing: border-box; }

html, body {
  min-height: 100%;
  margin: 0;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  color: var(--text);
}

body {
  background:
    radial-gradient(circle at 15% 10%, rgba(227, 6, 19, .22), transparent 28%),
    radial-gradient(circle at 85% 15%, rgba(10, 12, 22, .18), transparent 28%),
    linear-gradient(135deg, var(--bg1), var(--bg2));
  overflow-x: hidden;
}

.page {
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.card {
  position: relative;
  width: min(100%, 430px);
  padding: 30px;
  border: 1px solid var(--border);
  border-radius: 30px;
  background: var(--card);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
  animation: cardIn .75s ease both;
  overflow: hidden;
}

.card::before {
  content: "";
  position: absolute;
  inset: -2px;
  background: linear-gradient(135deg, rgba(227,6,19,.32), transparent 35%, rgba(255,255,255,.18));
  pointer-events: none;
  z-index: -1;
}

.theme-toggle {
  position: absolute;
  top: 18px;
  right: 18px;
}

.theme-toggle button,
footer button,
.dialog-head button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle button {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.25);
  font-size: 18px;
}

.brand {
  display: flex;
  justify-content: center;
  margin: 14px 0 26px;
}

.brand img {
  max-width: 168px;
  max-height: 80px;
  object-fit: contain;
}

.fallback-logo {
  display: none;
  align-items: center;
  gap: 8px;
  font-size: 22px;
}

.fallback-logo span {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  background: var(--red);
  display: inline-block;
}

.hero { text-align: center; }

.eyebrow {
  color: var(--red);
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  font-size: 12px;
  margin: 0 0 8px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 7vw, 38px);
  line-height: 1.05;
  letter-spacing: -.04em;
}

.subtitle {
  margin: 12px auto 26px;
  color: var(--muted);
  line-height: 1.5;
  max-width: 310px;
}

.form label {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
}

.password-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(255,255,255,.55);
}

[data-theme="dark"] .password-wrap {
  background: rgba(15,23,42,.65);
}

.password-wrap input {
  flex: 1;
  min-width: 0;
  height: 48px;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 16px;
  padding: 0 10px;
}

.password-wrap button {
  height: 42px;
  padding: 0 14px;
  border-radius: 13px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.55);
  color: var(--text);
  cursor: pointer;
}

.check {
  display: flex !important;
  gap: 10px;
  align-items: flex-start;
  margin: 16px 0 12px;
  color: var(--muted);
  font-weight: 500 !important;
  line-height: 1.4;
}

.check input {
  width: 18px;
  height: 18px;
  accent-color: var(--red);
  margin-top: 1px;
}

.error {
  min-height: 20px;
  color: var(--red);
  font-weight: 700;
  font-size: 14px;
  margin: 8px 0;
}

.connect-btn {
  width: 100%;
  height: 54px;
  border: 0;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--red), var(--red-dark));
  color: white;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-decoration: none;
  box-shadow: 0 14px 32px rgba(227,6,19,.3);
  transition: transform .18s ease, box-shadow .18s ease;
}

.connect-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(227,6,19,.36);
}

.connect-btn svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.manual {
  margin-top: 16px;
  padding: 14px;
  border-radius: 16px;
  border: 1px solid rgba(227,6,19,.25);
  background: rgba(227,6,19,.08);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.manual strong {
  display: block;
  color: var(--text);
  margin-bottom: 6px;
}

.manual code {
  color: var(--text);
  font-weight: 700;
}

.hidden { display: none; }

footer {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
  margin-top: 22px;
}

footer button {
  padding: 0;
  font-size: 13px;
  text-decoration: underline;
}

dialog {
  width: min(calc(100% - 32px), 430px);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 22px;
  background: var(--bg2);
  color: var(--text);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0,0,0,.45);
  backdrop-filter: blur(5px);
}

.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.dialog-head h3 { margin: 0; }
.dialog-head button { font-size: 30px; }

@keyframes cardIn {
  from { opacity: 0; transform: translateY(18px) scale(.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (max-width: 420px) {
  .page { padding: 14px; }
  .card { padding: 24px 18px; border-radius: 24px; }
}
