:root {
  --bg: #faf8f5;
  --panel: #ffffff;
  --field: #f6f4f1;
  --field-border: #e7ded2;
  --ink: #1a1a2e;
  --muted: #9b9bab;
  --soft: #6b6b7b;
  --gold: #b8976a;
  --gold-weak: rgba(184, 151, 106, 0.12);
  --button: #1f1e34;
  --button-hover: #2d2d45;
  --danger: #d94848;
  font-family: -apple-system, BlinkMacSystemFont, "Inter", "Noto Sans SC", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
}

body {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.auth-shell {
  position: relative;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(36px, env(safe-area-inset-top)) 24px calc(28px + env(safe-area-inset-bottom));
}

.close-button {
  position: fixed;
  top: 16px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(255, 255, 255, 0.84);
  color: var(--soft);
  font-size: 26px;
  line-height: 1;
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 42px;
  text-align: center;
}

.brand-logo {
  width: 102px;
  height: 102px;
  object-fit: cover;
  margin-bottom: 28px;
  background: var(--panel);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.brand-block h1 {
  margin: 0;
  color: var(--ink);
  font-size: 26px;
  line-height: 1.24;
  font-weight: 700;
  letter-spacing: 0;
}

.brand-block p {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.4;
}

.auth-card {
  width: min(100%, 480px);
  background: var(--panel);
  border: 1px solid #ece7e1;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06), 0 6px 22px rgba(28, 24, 18, 0.04);
}

.auth-form {
  padding: 25px;
}

.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  border: 1px solid var(--field-border);
  margin-bottom: 24px;
  height: 52px;
}

.tab-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-right: 1px solid var(--field-border);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  font-weight: 600;
  transition: background 160ms ease, color 160ms ease;
}

.tab-button:last-child {
  border-right: 0;
}

.tab-button.is-active {
  background: var(--gold-weak);
  color: var(--gold);
}

.tab-button svg,
.input-row svg,
.icon-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.panel {
  display: none;
}

.panel.is-active {
  display: block;
}

.input-row {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 60px;
  margin-bottom: 16px;
  background: var(--field);
  color: var(--muted);
}

.input-row:focus-within {
  outline: 2px solid rgba(184, 151, 106, 0.2);
  outline-offset: 0;
}

.input-row > svg {
  position: absolute;
  left: 16px;
  flex: none;
}

.input-row input {
  width: 100%;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--ink);
  font-size: 18px;
  line-height: 1.2;
  padding: 0 16px 0 52px;
}

.input-row.no-icon input {
  padding-left: 20px;
}

.input-row input::placeholder {
  color: #9fa1b5;
  opacity: 1;
}

.password-row input {
  padding-right: 52px;
}

.icon-button {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  color: #9fa1b5;
}

.code-line {
  display: grid;
  grid-template-columns: 1fr 120px;
  gap: 10px;
  margin-bottom: 16px;
}

.code-line .input-row {
  margin-bottom: 0;
}

.code-line .input-row input {
  text-align: center;
  letter-spacing: 0;
}

.code-button {
  min-width: 0;
  height: 60px;
  border: 1px solid var(--field-border);
  background: #fbf8f4;
  color: var(--gold);
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 160ms ease, opacity 160ms ease;
}

.code-button:hover {
  background: #f4eee6;
}

.code-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.inline-actions {
  display: flex;
  justify-content: flex-end;
  min-height: 28px;
  margin: -8px 0 20px;
}

.text-link {
  border: 0;
  background: transparent;
  color: var(--gold);
  padding: 0;
  font-size: 15px;
  text-decoration: none;
}

.text-link:hover {
  color: #a0825a;
}

.text-link.strong {
  font-weight: 600;
}

.form-message {
  min-height: 20px;
  margin: 0 0 10px;
  color: var(--danger);
  font-size: 14px;
  line-height: 20px;
}

.form-message.is-success {
  color: #2f8f5b;
}

.primary-button {
  width: 100%;
  height: 60px;
  border: 0;
  background: var(--button);
  color: #fff;
  font-size: 18px;
  font-weight: 700;
  box-shadow: 0 8px 15px rgba(31, 30, 52, 0.22);
  transition: transform 120ms ease, background 160ms ease;
}

.primary-button:hover {
  background: var(--button-hover);
}

.primary-button:active {
  transform: translateY(1px);
}

.auth-switch {
  width: min(100%, 480px);
  margin-top: 30px;
  text-align: center;
}

.auth-switch p {
  margin: 0;
  color: var(--muted);
  font-size: 17px;
}

.site-footer {
  margin-top: auto;
  padding-top: 46px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.9;
}

.site-footer p {
  margin: 0;
}

.site-footer a {
  color: var(--muted);
  text-decoration: none;
}

.site-footer a:hover {
  color: var(--gold);
}

[hidden] {
  display: none !important;
}

@media (min-width: 700px) {
  .auth-shell {
    justify-content: center;
  }

  .auth-shell.is-register {
    justify-content: flex-start;
    padding-top: 36px;
  }

  .auth-shell.is-login {
    padding-top: 36px;
  }
}

@media (max-width: 560px) {
  .auth-shell {
    padding-left: 18px;
    padding-right: 18px;
  }

  .brand-block {
    margin-bottom: 30px;
  }

  .brand-logo {
    width: 86px;
    height: 86px;
    margin-bottom: 20px;
  }

  .brand-block h1 {
    font-size: 22px;
  }

  .brand-block p {
    font-size: 15px;
  }

  .auth-form {
    padding: 18px;
  }

  .mode-tabs {
    height: 50px;
    margin-bottom: 20px;
  }

  .tab-button {
    font-size: 13px;
    gap: 6px;
  }

  .input-row,
  .code-button,
  .primary-button {
    height: 56px;
  }

  .input-row input {
    font-size: 16px;
  }

  .code-line {
    grid-template-columns: 1fr 108px;
    gap: 8px;
  }

  .code-button {
    font-size: 14px;
  }

  .auth-switch p {
    font-size: 16px;
  }

  .site-footer {
    padding-top: 34px;
  }
}
