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

body {
  color-scheme: dark;
  --canvas: #08090c;
  --surface: #111318;
  --surface-subtle: #171a20;
  --surface-strong: #21252d;
  --ink: #f5f5f2;
  --ink-secondary: #b3b6bd;
  --ink-tertiary: #7e838d;
  --ink-inverse: #111315;
  --line: #292d35;
  --line-strong: #454b56;
  --signal: #62e29b;
  --signal-strong: #36be78;
  --signal-soft: #122c20;
  --stage: #e7ad50;
  --stage-soft: #302412;
  --danger: #f16d71;
  --danger-soft: #33191d;
  background: var(--canvas);
}

.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.auth-topbar {
  min-height: 64px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
  background: #090a0d;
}

.back-link {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-secondary);
  background: var(--surface);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.auth-main {
  width: min(960px, calc(100% - 32px));
  margin: 36px auto;
  display: grid;
  place-items: center;
}

.auth-frame {
  width: 100%;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(300px, 0.88fr) minmax(0, 1.12fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: 0 20px 60px rgb(0 0 0 / 34%);
}

.auth-intro {
  min-width: 0;
  position: relative;
  isolation: isolate;
  padding: 40px 34px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 60px;
  overflow: hidden;
  color: white;
  background: var(--ink);
}

.auth-intro::before,
.auth-intro::after {
  content: "";
  position: absolute;
  z-index: -2;
  inset: 0;
}

.auth-intro::before {
  background: url("/public/assets/images/studio-hero.jpg") 63% center / cover;
}

.auth-intro::after {
  z-index: -1;
  background: rgb(8 9 12 / 74%);
}

.auth-intro small {
  color: var(--signal);
  font-weight: 700;
}

.auth-intro h1 {
  margin: 12px 0 14px;
  font-family: var(--font-display);
  font-size: var(--text-8);
  line-height: var(--leading-8);
  overflow-wrap: anywhere;
}

.auth-intro p {
  margin: 0;
  color: oklch(86% 0.006 95);
  line-height: 1.75;
}

.rights-note {
  padding: 14px;
  border-left: 3px solid var(--signal);
  color: oklch(91% 0.02 145);
  background: oklch(13% 0.02 145 / 0.74);
  font-size: 12px;
  line-height: 1.65;
}

.auth-form-wrap {
  min-width: 0;
  padding: 40px 44px;
}

.auth-form-wrap h2 {
  margin: 0 0 8px;
  font-size: var(--text-7);
  line-height: var(--leading-7);
}

.form-subtitle {
  margin: 0 0 26px;
  color: var(--ink-secondary);
}

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

.auth-form .field label {
  display: block;
  margin-bottom: 7px;
}

.field-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.field-heading label {
  margin-bottom: 0 !important;
}

.field-heading a {
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
}

.field-heading a:hover {
  color: var(--ink);
}

.auth-form input[type="tel"],
.auth-form input[type="text"],
.auth-form input[type="password"] {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 10px 11px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  outline: none;
  color: var(--ink);
  background: var(--surface);
}

.verification-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 118px;
  gap: 10px;
}

.code-btn {
  min-height: 44px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink);
  background: var(--surface-subtle);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.code-btn:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: var(--surface-strong);
}

.code-btn:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

.service-state {
  min-height: 38px;
  margin: 0 0 18px;
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  color: var(--ink-secondary);
  background: var(--surface-subtle);
  font-size: 12px;
}

.service-state-ready {
  border-color: color-mix(in oklch, var(--signal), var(--line) 60%);
  color: oklch(35% 0.09 145);
  background: var(--signal-soft);
}

.service-state-unavailable {
  border-color: color-mix(in oklch, var(--stage), var(--line) 60%);
  color: oklch(40% 0.08 75);
  background: var(--stage-soft);
}

.form-notice {
  min-height: 20px;
  margin: 0;
  color: oklch(40% 0.1 145);
  font-size: 13px;
}

.form-notice:empty,
.form-error:empty {
  display: none;
}

.auth-form input:focus {
  border-color: var(--signal-strong);
  box-shadow: 0 0 0 3px color-mix(in oklch, var(--signal), transparent 78%);
}

.consent-list {
  display: grid;
  gap: 10px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-subtle);
}

.consent-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  min-height: var(--touch-target);
  margin: 0;
  color: var(--ink-secondary);
  font-size: 12px;
  font-weight: 500;
  line-height: 1.55;
}

.consent-row input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--signal-strong);
}

.consent-row a {
  color: var(--ink);
  font-weight: 700;
}

.submit-btn {
  min-height: 44px;
  border: 1px solid var(--signal);
  border-radius: var(--radius-md);
  color: oklch(16% 0.025 145);
  background: var(--signal);
  font-weight: 700;
  cursor: pointer;
}

.submit-btn:hover {
  color: white;
  background: var(--signal-strong);
  border-color: var(--signal-strong);
}

.submit-btn:disabled {
  cursor: wait;
  opacity: 0.58;
}

.switch-auth {
  margin: 2px 0 0;
  color: var(--ink-secondary);
  text-align: center;
  font-size: 13px;
}

.switch-auth a {
  color: var(--ink);
  font-weight: 700;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
}

.auth-footer {
  padding: 20px 24px 26px;
  display: flex;
  justify-content: center;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--ink-tertiary);
  font-size: 12px;
}

.auth-footer a {
  text-decoration: none;
}

@media (max-width: 720px) {
  .auth-topbar {
    padding: 0 14px;
  }

  .auth-main {
    width: min(100% - 24px, 520px);
    margin: 18px auto 28px;
  }

  .auth-frame {
    grid-template-columns: 1fr;
  }

  .auth-intro {
    padding: 24px 22px;
    gap: 20px;
  }

  .auth-intro h1 {
    font-size: 27px;
  }

  .auth-form-wrap {
    padding: 28px 22px 30px;
  }
}

@media (max-width: 380px) {
  .back-link {
    padding: 6px 9px;
  }

  .auth-main {
    width: calc(100% - 20px);
  }

  .auth-intro,
  .auth-form-wrap {
    padding-right: 17px;
    padding-left: 17px;
  }

  .verification-row {
    grid-template-columns: minmax(0, 1fr) 108px;
    gap: 8px;
  }
}

/* Auth pages: dense two-column desktop, form-first H5 flow. */
@media (min-width: 1280px) {
  .auth-main {
    width: min(1040px, calc(100% - 64px));
  }

  .auth-intro,
  .auth-form-wrap {
    padding-top: 46px;
    padding-bottom: 46px;
  }
}

@media (max-width: 720px) {
  .auth-body {
    padding-right: var(--safe-right);
    padding-left: var(--safe-left);
  }

  .auth-topbar {
    min-height: calc(60px + var(--safe-top));
    padding: var(--safe-top) var(--mobile-gutter) 0;
  }

  .auth-main {
    width: min(100% - 32px, 520px);
    margin: 16px auto 22px;
    place-items: start center;
  }

  .auth-frame {
    overflow: visible;
    border-radius: 10px;
    box-shadow: 0 12px 36px rgb(0 0 0 / 28%);
  }

  .auth-form-wrap {
    order: 1;
    padding: 26px 22px 24px;
  }

  .auth-form-wrap h2 {
    font-size: 24px;
    line-height: 30px;
  }

  .form-subtitle {
    margin-bottom: 22px;
    font-size: 13px;
  }

  .auth-intro {
    min-height: 0;
    order: 2;
    padding: 0;
    background: var(--surface-subtle);
  }

  .auth-intro::before,
  .auth-intro::after,
  .auth-intro > div:first-child {
    display: none;
  }

  .rights-note {
    padding: 14px 16px;
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 0 0 9px 9px;
    color: var(--ink-secondary);
    background: var(--surface-subtle);
    font-size: 12px;
  }

  .auth-form {
    gap: 15px;
  }

  .auth-form input[type="tel"],
  .auth-form input[type="text"],
  .auth-form input[type="password"],
  .code-btn,
  .submit-btn {
    min-height: 48px;
  }

  .submit-btn {
    margin-top: 2px;
  }

  .auth-footer {
    padding: 16px 18px calc(22px + var(--safe-bottom));
  }
}

@media (max-width: 430px) {
  .auth-main {
    width: calc(100% - 24px);
    margin-top: 12px;
  }

  .auth-form-wrap {
    padding: 23px 18px 22px;
  }

  .verification-row {
    grid-template-columns: minmax(0, 1fr) 116px;
    gap: 8px;
  }

  .code-btn {
    padding-right: 8px;
    padding-left: 8px;
    white-space: nowrap;
  }

  .consent-row {
    align-items: start;
    line-height: 1.6;
  }
}

@media (max-width: 374px) {
  .verification-row {
    grid-template-columns: minmax(0, 1fr) 104px;
  }

  .auth-form-wrap {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 720px) and (max-height: 700px) {
  .auth-topbar {
    min-height: calc(54px + var(--safe-top));
  }

  .auth-main {
    margin-top: 8px;
  }

  .auth-form-wrap {
    padding-top: 20px;
  }

  .auth-footer {
    padding-top: 10px;
  }
}
