:root {
  --ink: #1a2f36;
  --ink-soft: #3d5560;
  --paper: #f3f7f6;
  --panel: rgba(255, 252, 248, 0.92);
  --line: rgba(26, 47, 54, 0.12);
  --teal: #0f766e;
  --teal-deep: #0b5f59;
  --sand: #d8c3a5;
  --danger: #b42318;
  --ok: #0f7a4c;
  --warn: #9a6700;
  --shadow: 0 24px 60px rgba(18, 48, 54, 0.18);
  --radius: 22px;
  --font-display: "Fraunces", "Noto Serif SC", serif;
  --font-body: "Noto Sans SC", "PingFang SC", sans-serif;
}

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

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

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.6;
}

.bg-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 55% at 12% 18%, rgba(15, 118, 110, 0.28), transparent 55%),
    radial-gradient(ellipse 70% 50% at 88% 12%, rgba(216, 195, 165, 0.45), transparent 50%),
    linear-gradient(160deg, #e8f2f0 0%, #f7f1e8 48%, #dfeceb 100%);
}

.bg-layer::after {
  content: "";
  position: absolute;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%230f766e' fill-opacity='0.035'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
  opacity: 0.9;
  pointer-events: none;
}

.auth-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  gap: 2rem;
  padding: 3rem clamp(1.25rem, 4vw, 4rem);
  align-items: center;
  max-width: 1180px;
  margin: 0 auto;
}

.brand-panel {
  padding: 1rem 0.5rem 1rem 0;
  max-width: 34rem;
  animation: rise 0.7s ease both;
}

.brand-mark {
  margin: 0 0 1.25rem;
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--teal-deep);
}

.brand-mark.compact {
  margin: 0;
  font-size: 1.35rem;
}

.brand-title {
  margin: 0 0 1rem;
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 4.2vw, 3.25rem);
  font-weight: 700;
  line-height: 1.15;
  color: var(--ink);
}

.brand-desc {
  margin: 0;
  font-size: 1.05rem;
  color: var(--ink-soft);
  max-width: 30rem;
}

.form-panel {
  display: flex;
  justify-content: flex-end;
  animation: rise 0.7s ease 0.12s both;
}

.form-card {
  width: min(100%, 420px);
  padding: 2rem 1.75rem 1.5rem;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.form-card-wide {
  width: min(100%, 460px);
}

.role-switch {
  margin: 0 0 1.1rem;
  padding: 0;
  border: 0;
  display: grid;
  gap: 0.65rem;
}

.role-switch legend {
  margin: 0 0 0.45rem;
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--ink);
}

.role-option {
  display: block;
  cursor: pointer;
}

.role-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.role-card {
  display: grid;
  gap: 0.15rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  border: 1.5px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
  min-height: 44px;
}

.role-card strong {
  font-size: 1.02rem;
}

.role-card small {
  color: var(--ink-soft);
  font-size: 0.84rem;
  line-height: 1.4;
}

.role-option input:checked + .role-card {
  border-color: var(--teal);
  background: rgba(15, 118, 110, 0.08);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.role-option input:focus-visible + .role-card {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

.form-section {
  margin: 0 0 1rem;
  padding-top: 0.25rem;
}

.form-section-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--teal-deep);
}

.elder-bind-panel {
  padding: 0.9rem;
  border-radius: 14px;
  border: 1px dashed rgba(15, 118, 110, 0.35);
  background: rgba(15, 118, 110, 0.05);
}

.bind-hint {
  display: block;
  margin: -0.35rem 0 0.85rem;
}

.elder-bind-panel[hidden] {
  display: none !important;
}

.form-header h2 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 700;
}

.form-header p {
  margin: 0 0 1.5rem;
  color: var(--ink-soft);
  font-size: 0.9rem;
  line-height: 1.65;
}

.field-hint {
  margin: 0;
  font-size: 0.78rem;
  color: var(--ink-soft);
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: 1rem;
}

.field {
  display: grid;
  gap: 0.4rem;
}

.field > span {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--ink-soft);
}

.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 0.95rem;
  font: inherit;
  color: var(--ink);
  background: #fff;
  outline: none;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.field input:focus {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.field input[readonly] {
  background: #f0f5f4;
  color: var(--ink-soft);
}

.password-wrap {
  position: relative;
  display: grid;
}

.password-wrap input {
  padding-right: 4.2rem;
}

.toggle-password {
  position: absolute;
  right: 0.45rem;
  top: 50%;
  transform: translateY(-50%);
  border: 0;
  background: transparent;
  color: var(--teal);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.35rem 0.55rem;
}

.btn-primary,
.btn-ghost {
  font: inherit;
  cursor: pointer;
  border-radius: 999px;
  transition: transform 0.15s ease, background 0.2s ease, border-color 0.2s ease;
}

.btn-primary {
  margin-top: 0.35rem;
  border: 0;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 100%);
  color: #fff;
  padding: 0.9rem 1.2rem;
  font-weight: 600;
  letter-spacing: 0.02em;
}

.btn-primary:hover {
  transform: translateY(-1px);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink);
  padding: 0.45rem 0.95rem;
  font-size: 0.9rem;
}

.btn-ghost:hover {
  border-color: rgba(15, 118, 110, 0.35);
  background: #fff;
}

.form-links {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
}

.form-links a {
  color: var(--teal-deep);
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 500;
}

.form-links a:hover {
  text-decoration: underline;
}

.field-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.82rem;
}

.toast-stack {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 50;
  display: grid;
  gap: 0.6rem;
  width: min(360px, calc(100vw - 2rem));
}

.toast {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  background: #fff;
  border: 1px solid var(--line);
  box-shadow: 0 10px 30px rgba(18, 48, 54, 0.12);
  font-size: 0.92rem;
  animation: slide-in 0.35s ease both;
}

.toast-error {
  border-color: rgba(180, 35, 24, 0.25);
  color: var(--danger);
}

.toast-success {
  border-color: rgba(15, 122, 76, 0.25);
  color: var(--ok);
}

.toast-warning {
  border-color: rgba(154, 103, 0, 0.25);
  color: var(--warn);
}

.home-body .topbar {
  position: sticky;
  top: 0;
  backdrop-filter: blur(12px);
  background: rgba(243, 247, 246, 0.82);
  border-bottom: 1px solid var(--line);
}

.topbar-inner {
  max-width: 980px;
  margin: 0 auto;
  padding: 0.9rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-chip {
  font-size: 0.92rem;
  color: var(--ink-soft);
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slide-in {
  from {
    opacity: 0;
    transform: translateX(12px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@media (max-width: 860px) {
  .auth-shell {
    grid-template-columns: 1fr;
    padding-top: 2rem;
    align-items: start;
  }

  .brand-panel {
    padding: 0;
    max-width: none;
  }

  .form-panel {
    justify-content: stretch;
  }

  .form-card {
    width: 100%;
  }
}

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