:root {
  --nygardene-ink: #17211b;
  --nygardene-muted: #6e776f;
  --nygardene-surface: #fffefb;
  --nygardene-line: #dedfd7;
  --nygardene-moss: #58765b;
  --nygardene-moss-dark: #36533b;
  --primary: #36533b;
  --primary-foreground: #ffffff;
  --ring: #58765b;
}

/* Authelia follows the device theme. The Nygårdene shell is deliberately
   light, so define every semantic color here to avoid white-on-white text
   when a phone uses dark mode. */
:root[data-theme],
body[data-theme] {
  --background: #f6f4ee;
  --foreground: #17211b;
  --card: #fffefb;
  --card-foreground: #17211b;
  --popover: #fffefb;
  --popover-foreground: #17211b;
  --primary: #36533b;
  --primary-foreground: #ffffff;
  --secondary: #dce8de;
  --secondary-foreground: #17211b;
  --muted: #edf0ea;
  --muted-foreground: #526057;
  --accent: #e4ece5;
  --accent-foreground: #17211b;
  --border: #b8c2b9;
  --input: #87958a;
  --ring: #36533b;
  color-scheme: light;
}

body {
  color: var(--nygardene-ink);
  background:
    radial-gradient(circle at 15% 0%, rgba(230, 237, 229, .95) 0, transparent 38%),
    radial-gradient(circle at 95% 75%, rgba(248, 229, 223, .7) 0, transparent 34%),
    #f6f4ee;
}

#language-button { display: none; }

.nygardene-service-brand {
  position: fixed;
  z-index: 2100;
  top: 22px;
  left: 28px;
  display: inline-flex;
  align-items: center;
  gap: 11px;
  max-width: min(440px, calc(100vw - 150px));
  border-radius: 14px;
  color: var(--nygardene-ink);
  text-decoration: none;
}

.nygardene-service-brand > span:first-child {
  display: grid;
  width: 43px;
  height: 43px;
  flex: 0 0 43px;
  place-items: center;
  border: 1px solid rgba(47, 95, 74, .3);
  border-radius: 13px;
  color: #2f5f4a;
  background: linear-gradient(145deg, #fbfcf9, #d7e3da);
  box-shadow: inset 0 1px 0 #fff, 0 6px 16px rgba(47, 95, 74, .1);
  font: 22px/1 Georgia, "Times New Roman", serif;
}

.nygardene-service-brand > span:last-child { min-width: 0; line-height: 1.15; }
.nygardene-service-brand strong {
  display: block;
  overflow: hidden;
  font: 600 21px/1.05 Georgia, "Times New Roman", serif;
  letter-spacing: -.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nygardene-service-brand small {
  display: block;
  overflow: hidden;
  margin-top: 4px;
  color: var(--nygardene-muted);
  font: 600 11px/1.2 Inter, ui-sans-serif, system-ui, sans-serif;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#first-factor-stage > div,
#reset-password-step1-stage > div,
#reset-password-step2-stage > div {
  width: min(calc(100% - 32px), 500px);
  padding: 34px 40px;
  border: 1px solid rgba(88, 118, 91, .2);
  border-radius: 26px;
  background: rgba(255, 254, 251, .96);
  box-shadow: 0 22px 60px rgba(42, 48, 43, .1);
}

#UserSvg { display: none; }
#first-factor-stage h5,
#reset-password-step1-stage h5,
#reset-password-step2-stage h5 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(30px, 6vw, 40px);
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -.035em;
}

#first-factor-stage h5[data-destination-note]::after,
#reset-password-step1-stage h5[data-destination-note]::after,
#reset-password-step2-stage h5[data-destination-note]::after {
  content: attr(data-destination-note);
  display: block;
  margin: 10px 0 18px;
  color: var(--nygardene-muted);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: normal;
  line-height: 1.5;
}

#first-factor-stage input:not([type="checkbox"]),
#reset-password-step1-stage input:not([type="checkbox"]),
#reset-password-step2-stage input:not([type="checkbox"]) {
  border: 1.5px solid #9ca79e;
  border-radius: 12px;
  background: #fff;
  box-shadow: inset 0 0 0 1px rgba(23, 33, 27, .025);
}

#remember-checkbox {
  width: 18px;
  height: 18px;
  accent-color: var(--nygardene-moss-dark);
  outline: 1.5px solid #657269;
  outline-offset: -1px;
}

#remember-checkbox:focus-visible { outline: 3px solid var(--nygardene-moss); outline-offset: 2px; }

#first-factor-stage button[data-variant="default"],
#reset-password-step1-stage button[data-variant="default"],
#reset-password-step2-stage button[data-variant="default"] {
  min-height: 44px;
  border-radius: 11px;
  text-transform: none;
  font-weight: 750;
}

#first-factor-stage a[href="https://www.authelia.com"],
#reset-password-step1-stage a[href="https://www.authelia.com"],
#reset-password-step2-stage a[href="https://www.authelia.com"] {
  opacity: .55;
}

#first-factor-stage .nygardene-auth-links {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-top: 4px;
}

#first-factor-stage .nygardene-auth-links .nygardene-register-link,
#first-factor-stage .nygardene-auth-links #reset-password-button {
  display: inline-flex;
  width: auto;
  min-width: 0;
  min-height: 40px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  margin: 0;
  padding: 6px 0;
  border: 0;
  color: var(--nygardene-moss-dark);
  background: transparent;
  box-shadow: none;
  font: 500 14px/1.35 Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  text-decoration: none;
  text-transform: none;
}

#first-factor-stage .nygardene-auth-links .nygardene-register-link:hover,
#first-factor-stage .nygardene-auth-links #reset-password-button:hover,
#first-factor-stage .nygardene-auth-links .nygardene-register-link:focus-visible,
#first-factor-stage .nygardene-auth-links #reset-password-button:focus-visible {
  color: var(--nygardene-ink);
  outline: 2px solid var(--nygardene-moss);
  outline-offset: 2px;
}

.nygardene-register-link {
  color: var(--nygardene-moss-dark);
  text-decoration: none;
}

body[data-auth-stage^="reset"] .nygardene-register-link { display: none; }

body[data-auth-stage="settings"] .nygardene-service-brand { display: none; }

body[data-auth-stage="settings"] :is(main, [role="dialog"]) a[href] {
  color: #294c32;
  font-weight: 650;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 3px;
}

body[data-auth-stage="settings"] :is(main, [role="dialog"]) a[href]:hover {
  color: #17211b;
  text-decoration-thickness: 2px;
}

body[data-auth-stage="settings"] :is(a[href], button, input):focus-visible {
  outline: 3px solid #58765b;
  outline-offset: 3px;
}

body[data-auth-stage="settings"] :is(#one-time-password-add, #webauthn-credential-add) {
  min-height: 44px;
  border: 1.5px solid #36533b;
  color: #294c32;
  background: #fffefb;
  font-weight: 750;
}

body[data-auth-stage="settings"] :is(#one-time-password-add, #webauthn-credential-add):hover {
  color: #ffffff;
  background: #36533b;
}

body[data-auth-stage="settings"] input:not([type="radio"]):not([type="checkbox"]) {
  border-color: #87958a;
  color: #17211b;
  background: #ffffff;
}

.nygardene-reset-saving {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(246, 244, 238, .9);
  backdrop-filter: blur(8px);
}

.nygardene-reset-requested {
  position: fixed;
  z-index: 1900;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 84px 20px 20px;
  background: rgba(246, 244, 238, .94);
  backdrop-filter: blur(8px);
}

.nygardene-reset-requested > div {
  width: min(100%, 470px);
  padding: 34px;
  border: 1px solid rgba(88, 118, 91, .30);
  border-radius: 24px;
  background: var(--nygardene-surface);
  box-shadow: 0 22px 60px rgba(42, 48, 43, .14);
  text-align: center;
}

.nygardene-reset-requested i {
  display: grid;
  width: 42px;
  height: 42px;
  margin: 0 auto 18px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--nygardene-moss-dark);
  font-size: 22px;
  font-style: normal;
  font-weight: 800;
}

.nygardene-reset-requested strong {
  display: block;
  font: 500 31px/1.1 Georgia, "Times New Roman", serif;
}

.nygardene-reset-requested span,
.nygardene-reset-requested small {
  display: block;
  margin-top: 12px;
  color: var(--nygardene-muted);
  font-size: 14px;
  line-height: 1.55;
}

.nygardene-reset-requested small { margin-top: 6px; font-size: 12px; }
.nygardene-reset-destination { display: block; margin-top: 14px; color: var(--nygardene-moss-dark); font-size: 13px; }
.nygardene-reset-requested nav { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 22px; }
.nygardene-reset-requested nav a { display: inline-flex; min-height: 44px; align-items: center; justify-content: center; border: 1px solid var(--nygardene-moss-dark); border-radius: 11px; color: #fff; background: var(--nygardene-moss-dark); font-size: 13px; font-weight: 750; text-decoration: none; }
.nygardene-reset-requested nav a + a { color: var(--nygardene-moss-dark); background: #fff; }

.nygardene-reset-saving > div {
  width: min(100%, 430px);
  padding: 34px;
  border: 1px solid rgba(88, 118, 91, .22);
  border-radius: 24px;
  background: var(--nygardene-surface);
  box-shadow: 0 22px 60px rgba(42, 48, 43, .14);
  text-align: center;
}

.nygardene-reset-saving i {
  display: block;
  width: 34px;
  height: 34px;
  margin: 0 auto 18px;
  border: 4px solid #d7e3da;
  border-top-color: var(--nygardene-moss-dark);
  border-radius: 50%;
  animation: nygardene-spin .75s linear infinite;
}
.nygardene-reset-saving strong {
  display: block;
  font: 500 29px/1.1 Georgia, "Times New Roman", serif;
}
.nygardene-reset-saving span {
  display: block;
  margin-top: 10px;
  color: var(--nygardene-muted);
  font-size: 14px;
  line-height: 1.5;
}

@keyframes nygardene-spin { to { transform: rotate(360deg); } }

@media (max-width: 520px) {
  .nygardene-service-brand {
    top: 17px;
    left: 18px;
    max-width: calc(100vw - 36px);
  }
  .nygardene-service-brand > span:first-child { width: 38px; height: 38px; flex-basis: 38px; }
  .nygardene-service-brand strong { font-size: 18px; }
  .nygardene-service-brand small { font-size: 10px; }
  #first-factor-stage,
  #reset-password-step1-stage,
  #reset-password-step2-stage { padding-top: 82px; }
  #first-factor-stage > div,
  #reset-password-step1-stage > div,
  #reset-password-step2-stage > div {
    width: min(calc(100% - 20px), 500px);
    padding: 26px 20px;
    border-radius: 22px;
  }
  .nygardene-reset-requested { padding: 74px 10px 10px; }
  .nygardene-reset-requested > div { padding: 28px 20px; border-radius: 22px; }
  .nygardene-reset-requested nav { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .nygardene-reset-saving i { animation-duration: 1.5s; }
}
