:root {
  --ink: #0B1F1B;
  --ink-2: #14332A;
  --ink-3: #2E4A3E;
  --emerald: #0E9E7A;
  --emerald-dk: #0B6B47;
  --mint: #6FD3B6;
  --mint-pale: #EDF8F3;
  --line: #DFEDE6;
  --surface: #FFFFFF;
  --page: #F6FBF9;
  --muted: #52635E;
  --muted-2: #7C8F88;
  --danger: #B42318;

  --s1: 8px; --s2: 16px; --s3: 24px; --s4: 32px; --s5: 48px;
  --t-sm: 14px; --t-base: 16px; --t-lg: 20px; --t-xl: 25px; --t-2xl: 31px;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(11, 31, 27, 0.06), 0 8px 24px rgba(11, 31, 27, 0.08);
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #E8F5F0;
    --ink-2: #CDE7DE;
    --ink-3: #B5D3CA;
    --surface: #0F2A24;
    --page: #0B1F1B;
    --line: #1F3F36;
    --mint-pale: #14332A;
    --muted: #A9C2BA;
    --muted-2: #7FA096;
  }
}

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

html, body { height: 100%; }

body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: var(--t-base);
  line-height: 1.5;
  color: var(--ink);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

.shell {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--s3);
  padding: calc(var(--s4) + env(safe-area-inset-top)) var(--s2) calc(var(--s3) + env(safe-area-inset-bottom));
}

.card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: var(--s4) var(--s3);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--s1);
  margin-bottom: var(--s3);
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: #0B1F1B;
  color: var(--mint);
  font-size: var(--t-sm);
  font-weight: 700;
  letter-spacing: 0.04em;
}

.brand-name {
  font-weight: 600;
  color: var(--ink-2);
}

.title {
  margin: 0;
  font-size: var(--t-2xl);
  line-height: 1.2;
  font-weight: 700;
  color: var(--ink);
}

.subtitle {
  margin: var(--s1) 0 var(--s3);
  color: var(--muted);
  font-size: var(--t-sm);
}

.form {
  display: grid;
  gap: var(--s2);
}

.field {
  display: grid;
  gap: var(--s1);
}

.label-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--s1);
}

label {
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--ink-3);
}

input[type="text"],
input[type="password"] {
  width: 100%;
  min-height: 48px;
  padding: 12px var(--s2);
  font: inherit;
  font-size: 16px; /* prevents iOS zoom on focus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 10px;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
}

input::placeholder { color: var(--muted-2); }

input:hover { border-color: var(--mint); }

input:focus-visible {
  outline: none;
  border-color: var(--emerald);
  box-shadow: 0 0 0 3px rgba(14, 158, 122, 0.25);
}

.input-wrap {
  position: relative;
}

.input-wrap input { padding-right: 80px; }

.toggle {
  position: absolute;
  top: 50%;
  right: var(--s1);
  transform: translateY(-50%);
  min-height: 36px;
  min-width: 44px;
  padding: 0 var(--s1);
  font: inherit;
  font-size: var(--t-sm);
  font-weight: 600;
  color: var(--emerald-dk);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 180ms var(--ease), transform 150ms var(--ease);
}

.toggle:hover { background: var(--mint-pale); }
.toggle:active { transform: translateY(-50%) scale(0.98); }
.toggle:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

.link {
  font-size: var(--t-sm);
  color: var(--emerald-dk);
  text-decoration: none;
  border-radius: 4px;
  transition: color 180ms var(--ease);
}

.link:hover { color: var(--ink); text-decoration: underline; }
.link:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

.remember {
  display: flex;
  align-items: center;
  gap: var(--s1);
  font-weight: 400;
  color: var(--muted);
  cursor: pointer;
  min-height: 44px;
}

.remember input {
  width: 20px;
  height: 20px;
  margin: 0;
  accent-color: var(--emerald);
  cursor: pointer;
}

.remember input:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

.submit {
  width: 100%;
  min-height: 48px;
  margin-top: var(--s1);
  font: inherit;
  font-size: var(--t-base);
  font-weight: 700;
  color: #FFFFFF;
  background: var(--emerald);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(11, 107, 71, 0.2), 0 6px 16px rgba(14, 158, 122, 0.22);
  transition: background 180ms var(--ease), transform 150ms var(--ease), box-shadow 180ms var(--ease);
}

.submit:hover { background: var(--emerald-dk); }
.submit:active { transform: scale(0.98); }
.submit:focus-visible { outline: 3px solid rgba(14, 158, 122, 0.35); outline-offset: 2px; }
.submit:disabled {
  background: var(--muted-2);
  box-shadow: none;
  cursor: not-allowed;
  transform: none;
}

.notice {
  margin: 0;
  padding: var(--s1) var(--s2);
  font-size: var(--t-sm);
  color: var(--ink-3);
  background: var(--mint-pale);
  border: 1px solid var(--line);
  border-radius: 10px;
}

.notice[hidden] { display: none; }

.foot {
  font-size: var(--t-sm);
  color: var(--muted-2);
  text-align: center;
}

.foot a {
  color: var(--emerald-dk);
  text-decoration: none;
}

.foot a:focus-visible { outline: 2px solid var(--emerald); outline-offset: 2px; }

@media (min-width: 600px) {
  .card { padding: var(--s5) var(--s4); }
}

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