:root {
  --ink: #152238;
  --ink-soft: #3d4a5c;
  --ink-muted: #6b7789;
  --surface: #ffffff;
  --surface-mist: #f4f6f9;
  --accent: #3a6f8c;
  --accent-hover: #2f5d76;
  --accent-soft: #e8f1f6;
  --line: #d9e1ea;
  --danger: #a84848;
  --danger-soft: #f8ecec;
  --success: #2f6b55;
  --success-soft: #e8f3ee;
  --brand-deep: #152238;
  --brand-mid: #1e334d;
  --glow: rgba(120, 168, 196, 0.28);
  --glow-warm: rgba(232, 210, 180, 0.18);
  --radius: 14px;
  --font-display: "Fraunces", "Noto Serif SC", "Source Han Serif SC", "Songti SC", Georgia, serif;
  --font-body: "Manrope", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--surface-mist);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Auth split layout ---------- */

.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr);
  min-height: 100vh;
}

.brand-panel {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: clamp(36px, 5vw, 64px);
  color: #f5f8fc;
  background:
    radial-gradient(ellipse 70% 55% at 18% 22%, var(--glow), transparent 58%),
    radial-gradient(ellipse 55% 45% at 88% 78%, var(--glow-warm), transparent 55%),
    linear-gradient(160deg, var(--brand-deep) 0%, var(--brand-mid) 52%, #243a56 100%);
}

.brand-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 40% 40%, #000 20%, transparent 75%);
  pointer-events: none;
  animation: grid-drift 18s linear infinite;
}

.brand-panel::after {
  content: "";
  position: absolute;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  right: -80px;
  top: 18%;
  background: radial-gradient(circle, rgba(154, 196, 216, 0.22), transparent 68%);
  animation: glow-float 10s ease-in-out infinite;
  pointer-events: none;
}

@keyframes grid-drift {
  from {
    transform: translateY(0);
  }
  to {
    transform: translateY(48px);
  }
}

@keyframes glow-float {
  0%,
  100% {
    transform: translate(0, 0);
    opacity: 0.85;
  }
  50% {
    transform: translate(-24px, 18px);
    opacity: 1;
  }
}

.brand-top,
.brand-main,
.brand-foot {
  position: relative;
  z-index: 1;
}

.brand-wordmark {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 500;
  letter-spacing: 0.18em;
  opacity: 0.88;
}

.brand-main {
  max-width: 420px;
  animation: rise-in 0.65s ease both;
}

.brand-main h1 {
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 4.5vw, 3.35rem);
  font-weight: 550;
  line-height: 1.18;
  letter-spacing: 0.04em;
  margin-bottom: 20px;
}

.brand-main .brand-line {
  width: 48px;
  height: 2px;
  background: rgba(255, 255, 255, 0.45);
  margin-bottom: 22px;
}

.brand-main p {
  font-size: 1.05rem;
  line-height: 1.7;
  color: rgba(245, 248, 252, 0.78);
  max-width: 34ch;
}

.brand-foot {
  font-size: 0.85rem;
  letter-spacing: 0.06em;
  color: rgba(245, 248, 252, 0.48);
}

.form-panel {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(28px, 5vw, 56px);
  background:
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(58, 111, 140, 0.06), transparent 55%),
    var(--surface-mist);
}

.form-panel-inner {
  width: min(100%, 400px);
  animation: rise-in 0.55s ease 0.08s both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.form-panel-inner h2 {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 550;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  color: var(--ink);
}

.form-panel-inner .subtitle {
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.55;
  margin-bottom: 28px;
}

.field {
  margin-bottom: 18px;
}

.field label {
  display: block;
  font-size: 0.84rem;
  font-weight: 650;
  letter-spacing: 0.02em;
  color: var(--ink-soft);
  margin-bottom: 8px;
}

.field input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--line);
  border-radius: var(--radius);
  font-size: 1.02rem;
  font-family: inherit;
  color: var(--ink);
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.field input:hover {
  border-color: #c0cbd8;
}

.field input:focus {
  outline: none;
  border-color: var(--accent);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(58, 111, 140, 0.16);
}

.field input::placeholder {
  color: #9aa8b8;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 52px;
  margin-top: 10px;
  border: none;
  border-radius: var(--radius);
  font-size: 1.02rem;
  font-weight: 650;
  font-family: inherit;
  letter-spacing: 0.03em;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease, opacity 0.2s ease, border-color 0.2s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.985);
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
}

.btn:disabled {
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

.btn-outline {
  width: auto;
  min-width: 140px;
  padding: 0 22px;
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}

.btn-outline:hover:not(:disabled) {
  background: var(--accent-soft);
}

.auth-links {
  margin-top: 24px;
  text-align: center;
  font-size: 0.9rem;
  color: var(--ink-muted);
  line-height: 1.9;
}

.auth-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 650;
}

.auth-links a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

.message {
  display: none;
  margin-bottom: 18px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 0.9rem;
  line-height: 1.45;
}

.message.show {
  display: block;
  animation: fade-in 0.25s ease;
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.message.error {
  background: var(--danger-soft);
  color: var(--danger);
}

.message.success {
  background: var(--success-soft);
  color: var(--success);
}

/* ---------- Responsive ---------- */

@media (max-width: 900px) {
  .auth-layout {
    grid-template-columns: 1fr;
  }

  .brand-panel {
    min-height: auto;
    padding: 28px 24px 32px;
    gap: 28px;
  }

  .brand-main h1 {
    font-size: clamp(1.85rem, 7vw, 2.3rem);
  }

  .brand-main p {
    font-size: 0.95rem;
    max-width: none;
  }

  .brand-foot {
    display: none;
  }

  .form-panel {
    padding: 32px 24px 48px;
    align-items: flex-start;
  }

  .brand-panel::after {
    width: 200px;
    height: 200px;
    top: auto;
    bottom: -40px;
  }
}

@media (max-width: 480px) {
  .form-panel-inner h2 {
    font-size: 1.5rem;
  }

  .gate-cards {
    grid-template-columns: 1fr;
  }
}

/* ---------- Login gate ---------- */

.gate-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1.25rem;
  background:
    radial-gradient(ellipse 70% 50% at 15% 10%, rgba(58, 111, 140, 0.14), transparent 55%),
    radial-gradient(ellipse 55% 45% at 90% 90%, rgba(232, 210, 180, 0.2), transparent 50%),
    linear-gradient(165deg, #f4f7fa 0%, #e8eef4 100%);
}

.gate-inner {
  width: min(100%, 760px);
  text-align: center;
}

.gate-kicker {
  font-family: var(--font-display);
  letter-spacing: 0.16em;
  color: var(--accent);
  font-size: 0.9rem;
  margin-bottom: 0.6rem;
}

.gate-inner h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 5vw, 2.75rem);
  margin-bottom: 0.75rem;
}

.gate-lead {
  color: var(--ink-muted);
  font-size: 1.05rem;
  line-height: 1.6;
  margin-bottom: 2rem;
}

.gate-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.gate-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 0.45rem;
  padding: 1.4rem 1.35rem;
  border-radius: 18px;
  border: 1.5px solid var(--line);
  background: #fff;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 12px 28px rgba(21, 34, 56, 0.06);
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.gate-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent);
}

.gate-card-tag {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--accent);
}

.gate-card strong {
  font-size: 1.35rem;
}

.gate-card span:last-child {
  color: var(--ink-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.gate-card-elder {
  background: linear-gradient(180deg, #fff 0%, #f3f8fb 100%);
}

.gate-foot {
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.gate-foot a {
  color: var(--accent);
  font-weight: 650;
  text-decoration: none;
}

.gate-foot a:hover {
  text-decoration: underline;
}

/* ---------- Portal switch ---------- */

.portal-switch {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  margin-bottom: 1.25rem;
  border-radius: 999px;
  background: var(--surface-mist);
  border: 1px solid var(--line);
}

.portal-switch a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 88px;
  height: 36px;
  padding: 0 1rem;
  border-radius: 999px;
  color: var(--ink-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 650;
}

.portal-switch a.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(21, 34, 56, 0.08);
}

/* ---------- Elder login ---------- */

.elder-login-body {
  min-height: 100vh;
  background:
    radial-gradient(ellipse 70% 50% at 20% 0%, rgba(58, 111, 140, 0.12), transparent 55%),
    linear-gradient(180deg, #f7fafc 0%, #eef3f7 100%);
}

.elder-login {
  width: min(100%, 520px);
  margin: 0 auto;
  padding: 2.5rem 1.25rem 3rem;
}

.elder-login-header {
  text-align: center;
  margin-bottom: 1.75rem;
}

.elder-login-header .brand {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 1.1rem;
  margin-bottom: 0.5rem;
}

.elder-login-header h1 {
  font-family: var(--font-display);
  font-size: clamp(1.9rem, 6vw, 2.4rem);
  margin-bottom: 0.4rem;
}

.elder-login-header p {
  font-size: 1.15rem;
  color: var(--ink-soft);
}

.elder-login .field label {
  font-size: 1.05rem;
}

.elder-login .field input {
  height: 64px;
  font-size: 1.25rem;
  border-radius: 16px;
}

.btn-elder {
  width: 100%;
  height: 68px;
  margin-top: 0.75rem;
  border: none;
  border-radius: 18px;
  background: #152238;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-elder:hover:not(:disabled) {
  background: #1e334d;
}

.btn-elder:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}

.elder-login-links {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  text-align: center;
  font-size: 1.05rem;
}

.elder-login-links a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 650;
}

