:root {
  --font: "IBM Plex Sans", "Segoe UI", Inter, ui-sans-serif, system-ui, sans-serif;
  --bg: #eef1f5;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.9);
  --panel-soft: rgba(245, 247, 250, 0.68);
  --field: rgba(255, 255, 255, 0.84);
  --line: rgba(15, 23, 42, 0.1);
  --line-strong: rgba(15, 23, 42, 0.18);
  --text: #101828;
  --muted: #5b6472;
  --accent: #101828;
  --accent-soft: rgba(16, 24, 40, 0.06);
  --ok-soft: rgba(8, 145, 178, 0.08);
  --danger: #c2410c;
  --danger-soft: rgba(194, 65, 12, 0.08);
  --shadow: 0 24px 64px rgba(15, 23, 42, 0.14);
  --shadow-soft: 0 12px 28px rgba(15, 23, 42, 0.08);
  --radius: 24px;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #090a0e;
  --panel: rgba(21, 24, 31, 0.88);
  --panel-strong: rgba(25, 28, 36, 0.94);
  --panel-soft: rgba(31, 35, 44, 0.78);
  --field: rgba(12, 15, 21, 0.84);
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.18);
  --text: #f3f5f8;
  --muted: #9aa3b2;
  --accent: #f3f4f6;
  --accent-soft: rgba(255, 255, 255, 0.08);
  --ok-soft: rgba(125, 211, 252, 0.12);
  --danger: #ff8383;
  --danger-soft: rgba(255, 131, 131, 0.12);
  --shadow: 0 32px 60px rgba(0, 0, 0, 0.32);
  --shadow-soft: 0 18px 36px rgba(0, 0, 0, 0.24);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: var(--font);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.54), transparent 34%),
    linear-gradient(180deg, #f4f6f8, var(--bg));
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  position: relative;
  overflow-x: hidden;
}

html[data-theme="dark"] body {
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.06), transparent 28%),
    radial-gradient(circle at top right, rgba(148, 163, 184, 0.08), transparent 24%),
    linear-gradient(160deg, #090a0e 0%, #0d1016 38%, #171b22 100%);
}

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

button,
input,
select {
  font: inherit;
}

button,
.ghostbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-strong);
  color: var(--text);
  padding: 0 14px;
  font-weight: 800;
  text-align: center;
  cursor: pointer;
  transition: border-color .18s ease, background .18s ease, color .18s ease, transform .12s ease;
}

button:hover,
.ghostbtn:hover {
  border-color: var(--line-strong);
  background: var(--accent-soft);
}

button:active,
.ghostbtn:active {
  transform: translateY(1px);
}

input,
select {
  width: 100%;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--field);
  color: var(--text);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

input::placeholder {
  color: var(--muted);
}

input:focus,
select:focus {
  border-color: var(--line-strong);
  box-shadow: 0 0 0 4px rgba(15, 23, 42, 0.06);
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus {
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.08);
}

.auth-float-tools,
.auth-shell {
  position: relative;
  z-index: 1;
}

.auth-float-tools {
  position: fixed;
  top: 18px;
  right: 18px;
  display: flex;
  gap: 10px;
}

.theme-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0;
  border-radius: 14px;
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  box-shadow: var(--shadow-soft);
}

.theme-toggle {
  width: 40px;
}

.auth-mask-icon {
  width: 18px;
  height: 18px;
  display: inline-block;
  background: currentColor;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: contain;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: contain;
}

.auth-mask-icon--moon {
  -webkit-mask-image: url("/icons/moon.svg");
  mask-image: url("/icons/moon.svg");
}

.auth-mask-icon--sun {
  -webkit-mask-image: url("/icons/sun.svg");
  mask-image: url("/icons/sun.svg");
}

.theme-icon-stack {
  position: relative;
  width: 18px;
  height: 18px;
  display: inline-grid;
  place-items: center;
}

.theme-icon-stack .theme-icon {
  position: absolute;
  inset: 0;
  transition: opacity .18s ease, transform .18s ease;
}

.theme-icon-stack .theme-icon--sun {
  opacity: 0;
  transform: scale(.86);
}

.theme-toggle.is-light .theme-icon--sun,
.theme-icon-stack.is-light .theme-icon--sun {
  opacity: 1;
  transform: scale(1);
}

.theme-toggle.is-light .theme-icon--moon,
.theme-icon-stack.is-light .theme-icon--moon {
  opacity: 0;
  transform: scale(.86);
}

.auth-shell {
  min-height: 100dvh;
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0;
  display: grid;
  grid-template-columns: minmax(0, 520px) minmax(280px, 1fr);
  gap: 18px;
  align-items: center;
}

.auth-card,
.side-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel-strong), var(--panel));
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  -webkit-backdrop-filter: blur(22px);
}

.auth-card {
  padding: 18px;
}

.side-card {
  padding: 20px;
}

.auth-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: #111827;
  color: #fff;
  box-shadow: var(--shadow-soft);
}

html[data-theme="dark"] .brand-mark {
  background: linear-gradient(135deg, #f5f7fb 0%, #d6dae1 100%);
  color: #111318;
  box-shadow: 0 14px 30px rgba(255, 255, 255, 0.08);
}

.brand-glyph {
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -.04em;
}

.brand-name {
  font-size: 15px;
  font-weight: 900;
  line-height: 1.1;
}

.brand-tag {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.mode-pill,
.chip-row span {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel-soft);
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.auth-card-body {
  display: grid;
  gap: 14px;
}

.flash-stack {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.flash {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel-soft);
}

.flash.ok {
  background: var(--ok-soft);
}

.flash.error,
.flash.err {
  color: var(--danger);
  background: var(--danger-soft);
}

.form-title {
  display: grid;
  gap: 8px;
}

.auth-kicker,
.side-kicker {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .1em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(26px, 2.6vw, 34px);
  line-height: 1.02;
  letter-spacing: -.03em;
}

.form-title p,
.auth-side-copy p,
.helper,
.auth-side-note span {
  color: var(--muted);
  line-height: 1.52;
}

.form-title p,
.auth-side-copy p {
  font-size: 13px;
}

.auth-form {
  display: grid;
  gap: 12px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.actions > .ghostbtn,
.actions > button,
.actions > .primary {
  width: 100%;
}

.primary {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.primary:hover {
  background: #1f2937;
  color: #fff;
}

html[data-theme="dark"] .primary {
  border-color: #f8fafc;
  background: #f8fafc;
  color: #0f172a;
}

.text-link {
  display: inline-flex;
  justify-self: start;
  color: var(--text);
  font-size: 13px;
  font-weight: 800;
}

.helper {
  margin-top: 6px;
  font-size: 12px;
}

.auth-side {
  min-width: 0;
}

.side-card--walldesk {
  display: grid;
  gap: 14px;
}

.auth-side-copy {
  display: grid;
  gap: 10px;
}

.side-card h2 {
  font-size: clamp(28px, 2.8vw, 38px);
  line-height: 1;
  letter-spacing: -.04em;
}

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

.auth-side-note {
  display: grid;
  gap: 5px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--panel-soft);
}

.auth-side-note strong {
  font-size: 12px;
  line-height: 1.2;
  text-transform: uppercase;
  letter-spacing: .08em;
}

@media (max-width: 900px) {
  .auth-float-tools {
    top: calc(12px + env(safe-area-inset-top, 0px));
    right: 12px;
    gap: 6px;
  }

  .auth-shell {
    width: min(520px, calc(100% - 16px));
    grid-template-columns: 1fr;
    min-height: auto;
    align-items: start;
    gap: 14px;
    padding: calc(46px + env(safe-area-inset-top, 0px)) 0 calc(14px + env(safe-area-inset-bottom, 0px));
  }

  .auth-side {
    display: none;
  }

  .auth-card {
    padding: 14px;
    border-radius: 20px;
  }

  .auth-card-body {
    gap: 10px;
  }

  .auth-form {
    gap: 9px;
  }

  .flash-stack {
    gap: 6px;
    margin-top: 10px;
  }

  .flash {
    padding: 9px 10px;
    border-radius: 14px;
    font-size: 12px;
  }

  .form-title p {
    line-height: 1.42;
  }

  .helper {
    margin-top: 0;
    font-size: 11px;
    line-height: 1.34;
  }
}

@media (max-width: 520px) {
  .auth-shell {
    width: 100%;
    gap: 10px;
    padding-left: 8px;
    padding-right: 8px;
  }

  .auth-card {
    padding: 11px;
    border-radius: 16px;
  }

  .auth-head {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 9px;
  }

  .mode-pill {
    grid-column: 1 / -1;
    justify-self: start;
    min-height: 26px;
    padding: 0 9px;
    font-size: 11px;
  }

  .brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 12px;
  }

  .brand-glyph {
    font-size: 18px;
  }

  .brand-tag {
    display: none;
  }

  .auth-card-body {
    gap: 8px;
  }

  .form-title {
    gap: 4px;
  }

  h1 {
    font-size: clamp(22px, 7vw, 28px);
  }

  .form-title p,
  .auth-side-copy p {
    font-size: 12px;
    line-height: 1.4;
  }

  label {
    gap: 4px;
    font-size: 11px;
  }

  input,
  select,
  button,
  .ghostbtn {
    min-height: 38px;
    padding: 0 12px;
    border-radius: 13px;
  }

  .theme-toggle {
    width: 36px;
    min-height: 36px;
    border-radius: 12px;
  }

  .actions {
    grid-template-columns: 1fr;
    gap: 6px;
  }
}

@media (max-width: 380px) {
  .auth-float-tools {
    top: calc(10px + env(safe-area-inset-top, 0px));
    right: 10px;
  }

  .auth-shell {
    padding-top: calc(42px + env(safe-area-inset-top, 0px));
    padding-left: 6px;
    padding-right: 6px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .auth-card {
    padding: 9px;
  }

  .auth-head {
    gap: 8px;
  }

  .brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 10px;
  }

  .brand-glyph {
    font-size: 16px;
  }

  .brand-name {
    font-size: 14px;
  }

  .mode-pill {
    min-height: 24px;
    font-size: 10px;
  }

  .auth-kicker {
    font-size: 10px;
    letter-spacing: .08em;
  }

  .form-title p {
    font-size: 11px;
  }

  label {
    font-size: 10px;
  }

  .auth-form {
    gap: 8px;
  }

  .actions {
    gap: 5px;
  }
}

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