/* ============================================================
   ATG — theme tokens
   Light is the default; dark overrides only what changes.
   ============================================================ */
:root {
  --brand:         #f36f21;
  --brand-strong:  #e05c0f;
  --brand-soft:    rgba(243, 111, 33, 0.12);
  --brand-ring:    rgba(243, 111, 33, 0.28);

  --bg:            #ffffff;
  --bg-glow-a:     rgba(243, 111, 33, 0.16);
  --bg-glow-b:     rgba(243, 111, 33, 0.07);

  --surface:       #ffffff;
  --surface-alt:   #fbfbfc;
  --border:        #e8e8ec;
  --border-strong: #d6d6dd;

  --text:          #16161a;
  --text-muted:    #6b6b76;
  --text-faint:    #9a9aa5;

  --danger:        #d7263d;
  --success:       #148f5b;

  --shadow: 0 1px 2px rgba(16, 16, 20, 0.04),
            0 12px 32px rgba(16, 16, 20, 0.07);
  --radius: 16px;
}

[data-theme="dark"] {
  --brand:         #ff8642;
  --brand-strong:  #ff9a61;
  --brand-soft:    rgba(255, 134, 66, 0.16);
  --brand-ring:    rgba(255, 134, 66, 0.32);

  --bg:            #0e0e11;
  --bg-glow-a:     rgba(243, 111, 33, 0.20);
  --bg-glow-b:     rgba(243, 111, 33, 0.06);

  --surface:       #17171c;
  --surface-alt:   #1d1d23;
  --border:        #2a2a32;
  --border-strong: #3a3a45;

  --text:          #f3f3f6;
  --text-muted:    #a2a2ae;
  --text-faint:    #74747f;

  --danger:        #ff6b7d;
  --success:       #4ad295;

  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4),
            0 16px 40px rgba(0, 0, 0, 0.45);
}

/* ---------- base ---------- */
* { box-sizing: border-box; }

/* Beats any component rule that sets display (.modal-root, .search, .btn …),
   so [hidden] always means hidden. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI",
               Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  transition: background-color .25s ease, color .25s ease;
}

/* soft brand glow behind everything */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(60rem 40rem at 78% -10%, var(--bg-glow-a), transparent 60%),
    radial-gradient(50rem 34rem at 8% 108%, var(--bg-glow-b), transparent 62%);
  transition: background .25s ease;
}

.icon {
  width: 18px; height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: block;
}

/* ---------- theme toggle ---------- */
.theme-toggle {
  position: fixed;
  top: clamp(14px, 3vw, 26px);
  right: clamp(14px, 3vw, 26px);
  width: 42px; height: 42px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: color .2s ease, border-color .2s ease, transform .15s ease,
              background-color .25s ease;
}
.theme-toggle:hover { color: var(--brand); border-color: var(--brand-ring); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle .icon { position: absolute; transition: opacity .2s ease, transform .3s ease; }
.icon-moon { opacity: 0; transform: rotate(-45deg) scale(.7); }
[data-theme="dark"] .icon-sun  { opacity: 0; transform: rotate(45deg) scale(.7); }
[data-theme="dark"] .icon-moon { opacity: 1; transform: none; }

/* ---------- layout ---------- */
.shell {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: clamp(20px, 6vw, 48px) 20px;
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: clamp(26px, 6vw, 38px);
  animation: rise .45s cubic-bezier(.2, .7, .3, 1) both;
  transition: background-color .25s ease, border-color .25s ease;
}

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

/* ---------- header ---------- */
.card-head { margin-bottom: 28px; }

.mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 40px;
  padding: 0 14px;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: .13em;
  box-shadow: 0 6px 18px var(--brand-ring);
}

h1 {
  margin: 0 0 6px;
  font-size: clamp(21px, 4.5vw, 25px);
  font-weight: 650;
  letter-spacing: -.02em;
}

.sub {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ---------- fields ---------- */
.field { margin-bottom: 16px; }

label {
  display: block;
  margin-bottom: 7px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  height: 46px;
  padding: 0 14px;
  font: inherit;
  font-size: 15px;
  color: var(--text);
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 11px;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, background-color .25s ease;
}
input::placeholder { color: var(--text-faint); }
input:hover { border-color: var(--border-strong); }
input:focus {
  border-color: var(--brand);
  background: var(--surface);
  box-shadow: 0 0 0 3.5px var(--brand-ring);
}
input.invalid { border-color: var(--danger); }

.password-wrap { position: relative; }
.password-wrap input { padding-right: 46px; }

.peek {
  position: absolute;
  top: 50%; right: 6px;
  transform: translateY(-50%);
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border: 0; border-radius: 8px;
  background: transparent;
  color: var(--text-faint);
  cursor: pointer;
  transition: color .18s ease, background-color .18s ease;
}
.peek:hover { color: var(--brand); background: var(--brand-soft); }
.peek .icon-eye-off { display: none; }
.peek.revealed .icon-eye { display: none; }
.peek.revealed .icon-eye-off { display: block; }

/* ---------- row ---------- */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 4px 0 20px;
  font-size: 13px;
}

.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-weight: 400;
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.check input {
  width: 16px; height: 16px;
  margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}


/* ---------- message ---------- */
.message {
  margin: 0 0 14px;
  min-height: 0;
  font-size: 13px;
  line-height: 1.45;
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity .2s ease, transform .2s ease;
}
.message.show { opacity: 1; transform: none; }
.message.error   { color: var(--danger); }
.message.success { color: var(--success); }

/* ---------- button ---------- */
.btn {
  position: relative;
  width: 100%;
  height: 48px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--brand-ring);
  transition: transform .14s ease, box-shadow .2s ease, filter .2s ease;
}
.btn:hover { filter: brightness(1.05); box-shadow: 0 8px 24px var(--brand-ring); }
.btn:active { transform: translateY(1px); }
.btn:disabled { cursor: default; filter: saturate(.75) brightness(.98); }

.btn-label, .spinner { grid-area: 1 / 1; }

.spinner {
  width: 18px; height: 18px;
  border: 2px solid rgba(255, 255, 255, .45);
  border-top-color: #fff;
  border-radius: 50%;
  opacity: 0;
  animation: spin .7s linear infinite;
}
.btn.loading .btn-label { opacity: 0; }
.btn.loading .spinner { opacity: 1; }
@keyframes spin { to { transform: rotate(360deg); } }


/* ---------- focus visibility ---------- */
:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

/* ---------- small screens ---------- */
@media (max-width: 480px) {
  .card {
    border: 0;
    box-shadow: none;
    background: transparent;
    padding: 8px 4px 24px;
  }
  .shell {
    align-items: start;
    padding: calc(56px + env(safe-area-inset-top, 0px)) 20px
             calc(24px + env(safe-area-inset-bottom, 0px));
  }
  /* 16px keeps iOS from zooming in when a field takes focus */
  input[type="text"], input[type="password"] { font-size: 16px; height: 50px; }
  .btn { height: 50px; }
  .theme-toggle { top: calc(14px + env(safe-area-inset-top, 0px)); }
}

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