:root {
  --bg: #f5f3ee;
  --panel: #ffffff;
  --panel2: #f1eee7;
  --line: #e6e2d8;
  --line2: #d5d0c2;
  --fg: #232019;
  --muted: #6b675c;
  --faint: #8a8578;
  --err: #c92a2a;
  --accent: #0e756b;
  --accent2: #0b5c58;
  --accent-fg: #ffffff;
  --shadow-lg: 0 2px 6px rgba(35, 32, 25, .05), 0 18px 50px rgba(35, 32, 25, .13);
  --sans: "Segoe UI Variable Text", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Segoe UI Variable Display", ui-sans-serif, system-ui, "Segoe UI", Roboto, sans-serif;
  --mono: "Cascadia Mono", ui-monospace, "Segoe UI Mono", SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
  font-family: var(--sans);
  color: var(--fg);
  background: var(--bg);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10100d;
    --panel: #191a15;
    --panel2: #21221c;
    --line: #2c2d26;
    --line2: #3a3b33;
    --fg: #eceade;
    --muted: #a9a698;
    --faint: #8d8a7c;
    --err: #f07a6e;
    --accent: #37b3a2;
    --accent2: #21867a;
    --accent-fg: #06211e;
    --shadow-lg: 0 2px 8px rgba(0, 0, 0, .4), 0 18px 50px rgba(0, 0, 0, .55);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #10100d;
  --panel: #191a15;
  --panel2: #21221c;
  --line: #2c2d26;
  --line2: #3a3b33;
  --fg: #eceade;
  --muted: #a9a698;
  --faint: #8d8a7c;
  --err: #f07a6e;
  --accent: #37b3a2;
  --accent2: #21867a;
  --accent-fg: #06211e;
  --shadow-lg: 0 2px 8px rgba(0, 0, 0, .4), 0 18px 50px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
  min-width: 0;
}

[hidden] { display: none !important; }

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  color: var(--fg);
  background: var(--bg);
  font: 14px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input { font: inherit; }

.auth-page {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding:
    max(24px, env(safe-area-inset-top))
    max(24px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(24px, env(safe-area-inset-left));
}

.auth-card {
  width: min(400px, 100%);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow-lg);
  animation: rise .35s cubic-bezier(.2, .7, .3, 1) both;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.auth-head {
  padding: 30px 26px 5px;
  text-align: center;
}

.brand-mark {
  width: 52px;
  height: 52px;
  display: grid;
  place-items: center;
  margin: 0 auto 12px;
  border-radius: 8px;
  color: var(--accent-fg);
  background: var(--accent);
  box-shadow: 0 4px 14px color-mix(in srgb, var(--accent) 30%, transparent);
}

.brand-mark svg {
  width: 25px;
  height: 25px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.auth-head h1 {
  margin: 0;
  font: 700 19px/1.3 var(--display);
  letter-spacing: 0;
}

.auth-head p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 22px 26px 28px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  color: var(--muted);
  font-size: 12.5px;
}

.form-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line2);
  border-radius: 7px;
  color: var(--fg);
  background: var(--panel2);
  transition: border-color .15s, box-shadow .15s;
}

.password-field {
  position: relative;
}

.password-field input { padding-right: 48px; }

.password-toggle {
  position: absolute;
  top: 50%;
  right: 4px;
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 7px;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.password-toggle:hover {
  color: var(--fg);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.password-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.form-field input:hover { border-color: var(--faint); }
.form-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
}

#totpInput {
  font-family: var(--mono);
  font-size: 17px;
  text-align: center;
  letter-spacing: 0;
}

.login-form > button {
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid var(--accent);
  border-radius: 7px;
  color: var(--accent-fg);
  background: var(--accent);
  font-weight: 650;
  cursor: pointer;
  box-shadow: 0 2px 10px color-mix(in srgb, var(--accent) 25%, transparent);
  transition: filter .15s, transform .1s;
}

.login-form > button:hover { filter: brightness(1.07); }
.login-form > button:active { transform: translateY(1px); }
.login-form > button:disabled {
  cursor: default;
  opacity: .6;
  transform: none;
}

.form-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--err) 32%, transparent);
  border-radius: 7px;
  color: var(--err);
  background: color-mix(in srgb, var(--err) 10%, transparent);
  font-size: 13px;
}

.form-error:empty { display: none; }

@media (min-width: 761px) and (min-height: 501px) {
  body { font-size: 15px; }
  .auth-head h1 { font-size: 20px; }
  .auth-head p { font-size: 14px; }
  .form-field label { font-size: 13.5px; }
  .form-error { font-size: 14px; }
}

button:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

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

@media (max-width: 520px), (max-height: 500px) and (max-width: 950px) {
  .auth-page {
    padding: 0;
    background: var(--panel);
  }

  .auth-card {
    min-height: 100dvh;
    display: grid;
    align-content: center;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .auth-head {
    padding: max(30px, env(safe-area-inset-top)) 22px 4px;
  }

  .login-form {
    gap: 16px;
    padding: 22px 22px max(28px, env(safe-area-inset-bottom));
  }

  .form-field input {
    min-height: 48px;
    padding-top: 11px;
    padding-bottom: 11px;
    font-size: 16px;
  }

  .password-field input { padding-right: 50px; }

  .password-toggle {
    right: 3px;
    width: 42px;
    height: 42px;
  }

  .login-form > button { min-height: 48px; }
}

@media (max-height: 650px) and (max-width: 520px) {
  .auth-card { align-content: start; }
  .brand-mark {
    width: 44px;
    height: 44px;
    margin-bottom: 9px;
  }
}
