:root {
  --blue: #f1cd9e;
  --blue-dark: #ffc87f;
  --accent: #e8a020;
  --aside-bg: #eef2f7;
  --main-bg: #f9fafb;
  --border: #cdd8e3;
  --text: #ffe1ba;
  --text-muted: #6b7c93;
  --radius: 8px;
  --radius-card: 16px;
  --red: #e74c3c;
  --green: #2ecc71;
  --shadow: 0 10px 40px rgba(44, 95, 138, 0.08);
  --trans: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ─── Toaster ─── */
#toaster {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 14px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  color: #fff;
  min-width: 260px;
  max-width: 340px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  animation:
    slideIn 0.3s ease,
    fadeOut 0.4s ease 2.6s forwards;
}
.toast.success {
  background: var(--green);
}
.toast.error {
  background: var(--red);
}
.toast.info {
  background: var(--blue);
}
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(40px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
@keyframes fadeOut {
  to {
    opacity: 0;
    transform: translateX(40px);
  }
}

/* ─── Main layout ─── */
main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  position: relative;
  overflow: hidden;
}

/* ─── Floating book decorations ─── */
.book-deco {
  position: absolute;
  pointer-events: none;
  user-select: none;
  animation: floatBook 6s ease-in-out infinite;
}
.book-deco svg {
  display: block;
}

.bd-1 {
  left: 4%;
  top: 10%;
  animation-delay: 0s;
  opacity: 0.55;
}
.bd-2 {
  left: 8%;
  bottom: 12%;
  animation-delay: 1.2s;
  opacity: 0.45;
}
.bd-3 {
  right: 5%;
  top: 8%;
  animation-delay: 0.6s;
  opacity: 0.5;
}
.bd-4 {
  right: 7%;
  bottom: 10%;
  animation-delay: 1.8s;
  opacity: 0.45;
}
.bd-5 {
  left: 22%;
  top: 5%;
  animation-delay: 0.9s;
  opacity: 0.3;
}
.bd-6 {
  right: 22%;
  bottom: 5%;
  animation-delay: 2.1s;
  opacity: 0.3;
}

@keyframes floatBook {
  0%,
  100% {
    transform: translateY(0) rotate(var(--rot, 0deg));
  }
  50% {
    transform: translateY(-14px) rotate(var(--rot, 0deg));
  }
}
.bd-1 {
  --rot: -8deg;
}
.bd-2 {
  --rot: 6deg;
}
.bd-3 {
  --rot: 10deg;
}
.bd-4 {
  --rot: -5deg;
}
.bd-5 {
  --rot: -12deg;
}
.bd-6 {
  --rot: 7deg;
}

/* scattered tiny sparkles */
.sparkle {
  position: absolute;
  pointer-events: none;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: 0;
  animation: twinkle 4s ease-in-out infinite;
}
@keyframes twinkle {
  0%,
  100% {
    opacity: 0;
    transform: scale(0.5);
  }
  50% {
    opacity: 0.6;
    transform: scale(1.2);
  }
}

/* ─── Card ─── */
.auth-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 460px;
  overflow: hidden;
  position: relative;
  z-index: 1;
}
.auth-card::before {
  content: "";
  display: block;
  height: 5px;
  background: linear-gradient(90deg, var(--blue), var(--accent));
}
.auth-inner {
  padding: 40px 44px 44px;
}

/* ─── Panel switching ─── */
.panel {
  display: none;
  animation: panelIn 0.35s ease;
}
.panel.active {
  display: block;
}
@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ─── Typography ─── */
.auth-title {
  font-family: "Playfair Display", serif;
  font-size: 26px;
  color: var(--blue-dark);
  margin-bottom: 6px;
}
.auth-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
  line-height: 1.5;
}

/* ─── Form elements ─── */
.form-group {
  margin-bottom: 18px;
  position: relative;
}
label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--blue-dark);
  margin-bottom: 7px;
}

/* ── Expanding input ── */
input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  padding: 11px 42px 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--main-bg);
  font-size: 15px;
  font-family: "DM Sans", sans-serif;
  color: var(--text);
  outline: none;
  /* transition for expanding effect */
  transition:
    border-color 0.3s ease,
    background 0.3s ease,
    box-shadow 0.3s ease,
    padding 0.25s ease,
    transform 0.25s ease;
  transform-origin: left center;
}
input:focus {
  border-color: var(--blue);
  background: #ffffff;
  box-shadow:
    0 0 0 4px rgba(44, 95, 138, 0.13),
    0 2px 12px rgba(44, 95, 138, 0.1);
  padding-top: 14px;
  padding-bottom: 14px;
  transform: scaleX(1.012);
}
input.error {
  border-color: var(--red);
  background: #fdf2f2;
}

.field-icon {
  position: absolute;
  right: 14px;
  top: 38px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 17px;
  user-select: none;
  transition: var(--trans);
}
.field-icon:hover {
  color: var(--blue);
}
.field-error {
  font-size: 12px;
  color: var(--red);
  margin-top: 5px;
  display: none;
}
.field-error.show {
  display: block;
}

/* password strength */
#strength-bar-wrap {
  margin-top: 8px;
  display: none;
}
#strength-bar-wrap.show {
  display: block;
}
.strength-track {
  height: 4px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}
.strength-fill {
  height: 100%;
  border-radius: 4px;
  width: 0;
  transition:
    width 0.4s ease,
    background 0.4s ease;
}
.strength-text {
  font-size: 11px;
  margin-top: 4px;
  font-weight: 500;
}

/* row */
.row-between {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.checkbox-label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.checkbox-label input {
  width: auto;
  accent-color: var(--blue);
  cursor: pointer;
}
.link-btn {
  background: none;
  border: none;
  color: var(--blue);
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  font-family: "DM Sans", sans-serif;
}
.link-btn:hover {
  color: var(--blue-dark);
  text-decoration: underline;
}

/* submit button */
.btn-primary {
  width: 100%;
  padding: 14px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: "DM Sans", sans-serif;
  cursor: pointer;
  transition: var(--trans);
  letter-spacing: 0.3px;
  position: relative;
  overflow: hidden;
}
.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(30, 63, 92, 0.35);
}
.btn-primary:active {
  transform: translateY(0);
}
.btn-primary:disabled {
  opacity: 0.7;
  cursor: not-allowed;
  transform: none;
}
.btn-spinner {
  display: none;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  margin: 0 auto;
}
.btn-primary.loading .btn-text {
  display: none;
}
.btn-primary.loading .btn-spinner {
  display: block;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* divider */
.divider {
  text-align: center;
  margin: 22px 0;
  position: relative;
}
.divider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.divider span {
  background: #ffffff;
  position: relative;
  padding: 0 12px;
  font-size: 12px;
  color: var(--text-muted);
}

.switch-text {
  text-align: center;
  font-size: 14px;
  color: var(--text-muted);
  margin-top: 24px;
}
.switch-text button {
  color: var(--accent);
  font-weight: 600;
}
.switch-text button:hover {
  color: #d69018;
}

/* forgot */
.back-row {
  margin-bottom: 20px;
}
.back-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: "DM Sans", sans-serif;
  transition: var(--trans);
}
.back-btn:hover {
  color: var(--blue);
}

/* success */
.success-box {
  text-align: center;
  padding: 20px 0;
}
.success-icon {
  font-size: 52px;
  margin-bottom: 16px;
}
.success-box h3 {
  font-family: "Playfair Display", serif;
  font-size: 22px;
  color: var(--blue-dark);
  margin-bottom: 10px;
}
.success-box p {
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.7;
}

/* logged-in */
#logged-in-card {
  display: none;
  text-align: center;
  padding: 20px 0;
}
.user-avatar-big {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  font-weight: 700;
  color: #fff;
  margin: 0 auto 16px;
}
#logged-in-card h3 {
  font-family: "Playfair Display", serif;
  font-size: 22px;
  color: var(--blue-dark);
  margin-bottom: 8px;
}
#logged-in-card p {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}
.btn-secondary {
  width: 100%;
  padding: 13px;
  background: transparent;
  border: 1.5px solid var(--blue);
  color: var(--blue);
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 600;
  font-family: "DM Sans", sans-serif;
  cursor: pointer;
  transition: var(--trans);
  margin-top: 12px;
}
.btn-secondary:hover {
  background: var(--blue);
  color: #fff;
}

/* lock */
.lock-warning {
  display: none;
  background: #fdf2f2;
  border: 1px solid var(--red);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--red);
  margin-bottom: 16px;
  align-items: flex-start;
  gap: 8px;
}
.lock-warning.show {
  display: flex;
}

/* ─── Footer ─── */
footer {
  background: var(--blue-dark);
  color: var(--aside-bg);
  text-align: center;
  padding: 18px;
  font-size: 13px;
}
footer span {
  color: var(--accent);
  font-weight: 600;
}

/* ─── Responsive ─── */
@media (max-width: 520px) {
  .auth-inner {
    padding: 28px 24px 36px;
  }
  nav {
    padding: 0 16px;
  }
  .nav-links {
    display: none;
  }
  .bd-1,
  .bd-2,
  .bd-3,
  .bd-4,
  .bd-5,
  .bd-6 {
    display: none;
  }
}