:root {
  color-scheme: dark;
  --bg: #070714;
  --text: #f5f5ff;
  --muted: rgba(245, 245, 255, 0.62);
  --glass: rgba(255, 255, 255, 0.08);
  --glass-strong: rgba(255, 255, 255, 0.14);
  --stroke: rgba(255, 255, 255, 0.22);
  --accent: #6ea8ff;
  --accent-2: #b388ff;
  --danger: #ff6b8a;
  --radius: 22px;
  --radius-sm: 14px;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.92em;
  background: rgba(255, 255, 255, 0.08);
  padding: 0.12em 0.4em;
  border-radius: 6px;
}

.bg-orbs {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite alternate;
}

.orb-a {
  width: min(70vw, 520px);
  height: min(70vw, 520px);
  background: radial-gradient(circle, #4f7cff 0%, transparent 70%);
  top: -10%;
  left: -10%;
}

.orb-b {
  width: min(60vw, 440px);
  height: min(60vw, 440px);
  background: radial-gradient(circle, #9b5cff 0%, transparent 70%);
  bottom: 5%;
  right: -8%;
  animation-delay: -6s;
}

.orb-c {
  width: min(50vw, 360px);
  height: min(50vw, 360px);
  background: radial-gradient(circle, #38bdf8 0%, transparent 70%);
  top: 40%;
  left: 35%;
  animation-delay: -12s;
  opacity: 0.35;
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(30px, -24px, 0) scale(1.08); }
}

.shell {
  position: relative;
  z-index: 1;
  width: min(100%, 720px);
  margin: 0 auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(32px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.glass {
  background: linear-gradient(135deg, var(--glass-strong), var(--glass));
  border: 1px solid var(--stroke);
  backdrop-filter: blur(28px) saturate(160%);
  -webkit-backdrop-filter: blur(28px) saturate(160%);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero {
  padding: 28px 24px 24px;
  text-align: center;
}

.hero-icon {
  width: 52px;
  height: 52px;
  margin: 0 auto 12px;
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.18);
}

.hero h1 {
  margin: 0 0 8px;
  font-size: clamp(1.45rem, 4vw, 1.85rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.form-card {
  padding: 22px 18px 24px;
}

.form-section + .form-section {
  margin-top: 22px;
  padding-top: 22px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.form-section h2 {
  margin: 0 0 14px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  font-weight: 600;
}

.section-note {
  margin: -6px 0 14px;
  font-size: 0.86rem;
  color: var(--muted);
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-grid {
  display: grid;
  gap: 0;
}

.label-row {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 7px;
}

.label {
  font-size: 0.92rem;
  font-weight: 600;
}

.req {
  color: var(--danger);
  font-weight: 700;
}

.hint {
  display: block;
  margin-top: 6px;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.4;
}

.hint.block { margin-top: 2px; }

input[type="text"],
input[type="url"],
input[type="password"],
select {
  width: 100%;
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(0, 0, 0, 0.22);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font: inherit;
  font-size: 16px;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

input:focus,
select:focus {
  outline: none;
  border-color: rgba(110, 168, 255, 0.65);
  box-shadow: 0 0 0 4px rgba(110, 168, 255, 0.18);
  background: rgba(0, 0, 0, 0.32);
}

input.invalid {
  border-color: rgba(255, 107, 138, 0.75);
  box-shadow: 0 0 0 4px rgba(255, 107, 138, 0.15);
}

select {
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 18px) calc(50% - 3px), calc(100% - 12px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 36px;
}

.field-check {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  cursor: pointer;
  user-select: none;
}

.field-check input { display: none; }

.check-ui {
  width: 22px;
  height: 22px;
  margin-top: 2px;
  flex-shrink: 0;
  border-radius: 7px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.2);
  position: relative;
}

.field-check input:checked + .check-ui {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: transparent;
}

.field-check input:checked + .check-ui::after {
  content: "";
  position: absolute;
  left: 7px;
  top: 3px;
  width: 5px;
  height: 10px;
  border: 2px solid #fff;
  border-top: 0;
  border-left: 0;
  transform: rotate(45deg);
}

.hidden { display: none !important; }

.btn-primary {
  width: 100%;
  margin-top: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font: inherit;
  font-size: 1rem;
  font-weight: 650;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, #5b8cff 0%, #8b5cf6 55%, #38bdf8 100%);
  box-shadow: 0 12px 32px rgba(91, 140, 255, 0.35);
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
}

.btn-primary:active { transform: scale(0.98); }

.btn-primary:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-ghost {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
  backdrop-filter: blur(12px);
}

.btn-ghost.copied {
  border-color: rgba(110, 168, 255, 0.5);
  color: var(--accent);
}

.result-card {
  padding: 18px;
}

.result-card.hidden { display: none; }

.result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.result-head h2 {
  margin: 0;
  font-size: 1rem;
}

.result-url {
  margin: 0;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-family: ui-monospace, "SF Mono", Menlo, Monaco, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 240px;
  overflow: auto;
}

.result-hint { margin-bottom: 0; }

.footer {
  text-align: center;
  color: rgba(245, 245, 255, 0.35);
  font-size: 0.78rem;
  padding: 8px 0 4px;
}

/* ——— Login ——— */

.login-body .shell {
  min-height: calc(100dvh - 40px);
  justify-content: center;
}

.login-shell {
  width: min(100%, 420px);
}

.login-card {
  padding: 32px 24px 28px;
  text-align: center;
}

.login-card .hero-icon {
  margin-bottom: 16px;
}

.login-card h1 {
  margin: 0 0 8px;
  font-size: clamp(1.35rem, 4vw, 1.65rem);
  font-weight: 700;
  letter-spacing: -0.02em;
}

.login-sub {
  margin-bottom: 24px;
}

.login-form {
  text-align: left;
  width: 100%;
  max-width: 280px;
  margin: 0 auto;
}

.login-form .field {
  margin-bottom: 14px;
}

.login-form input[type="text"],
.login-form input[type="password"] {
  padding: 11px 13px;
  font-size: 15px;
}

.login-form .btn-primary {
  width: 100%;
  margin-top: 4px;
  padding: 12px 16px;
  font-size: 0.95rem;
}

.login-error {
  margin: 0 0 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(255, 107, 138, 0.12);
  border: 1px solid rgba(255, 107, 138, 0.35);
  color: #ffb3c3;
  font-size: 0.86rem;
}

.login-error.hidden {
  display: none;
}

.hero-with-actions .hero-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.hero-with-actions .hero-icon {
  margin: 0;
}

.btn-logout {
  flex-shrink: 0;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
}

@media (min-width: 640px) {
  .shell { padding-top: 40px; }
  .form-card { padding: 28px 26px 30px; }
  .field-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }
  .field-grid .field { margin-bottom: 0; }
  .result-url { font-size: 0.78rem; }
}

@media (prefers-reduced-motion: reduce) {
  .orb { animation: none; }
  .btn-primary { transition: none; }
}
