/* Apple-inspired design: system fonts, restrained spacing, segmented controls,
   frosted cards, and hairline dividers. Warm white in light mode, black in dark mode. */

:root {
  color-scheme: light dark;

  --font-ui: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei UI",
    "Microsoft YaHei", sans-serif;

  /* Light mode */
  --bg: #f5f5f7;
  --glow: rgb(0 113 227 / 7%);
  --glow-2: rgb(120 120 128 / 6%);
  --surface: rgb(255 255 255 / 72%);
  --surface-solid: #fff;
  --thumb: #fff;
  --field: #fff;
  --card-inner: rgb(255 255 255 / 60%);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #86868b;
  --hairline: rgb(0 0 0 / 8%);
  --hairline-2: rgb(0 0 0 / 14%);
  --fill: rgb(118 118 128 / 10%);
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --blue-press: #0063c8;
  --green: #1d8a3c;
  --orange: #b25000;
  --red: #d70015;
  --shadow: 0 1px 2px rgb(0 0 0 / 4%), 0 10px 30px rgb(0 0 0 / 6%),
    0 48px 80px -48px rgb(0 0 0 / 24%);
  --radius-card: 28px;
  --radius-ctl: 14px;
  --ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000;
    --glow: rgb(10 132 255 / 12%);
    --glow-2: rgb(255 255 255 / 3%);
    --surface: rgb(28 28 30 / 74%);
    --surface-solid: #1c1c1e;
    --thumb: #636366;
    --field: rgb(255 255 255 / 6%);
    --card-inner: rgb(255 255 255 / 6%);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #8e8e93;
    --hairline: rgb(255 255 255 / 10%);
    --hairline-2: rgb(255 255 255 / 18%);
    --fill: rgb(118 118 128 / 24%);
    --blue: #0a84ff;
    --blue-hover: #2f95ff;
    --blue-press: #0a7ae0;
    --green: #30d158;
    --orange: #ff9f0a;
    --red: #ff453a;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%), 0 24px 64px rgb(0 0 0 / 55%);
  }
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

::selection { background: color-mix(in srgb, var(--blue) 22%, transparent); }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 48px 24px;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  letter-spacing: 0.01em;
  background-color: var(--bg);
  background-image:
    radial-gradient(900px 520px at 50% -14%, var(--glow), transparent 70%),
    radial-gradient(720px 460px at 82% 112%, var(--glow-2), transparent 70%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-tap-highlight-color: transparent;
}

.shell {
  width: min(440px, 100%);
  display: grid;
  gap: 20px;
  animation: rise 0.6s var(--ease) both;
}

/* Card: frosted glass, layered shadows, and a top highlight */
.card {
  position: relative;
  padding: 44px 40px 34px;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  background: var(--surface);
  box-shadow: var(--shadow), inset 0 1px 0 var(--card-inner);
  backdrop-filter: saturate(180%) blur(30px);
  -webkit-backdrop-filter: saturate(180%) blur(30px);
}

@supports not ((backdrop-filter: blur(4px)) or (-webkit-backdrop-filter: blur(4px))) {
  .card { background: var(--surface-solid); }
}

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

h1 {
  margin: 0 0 10px;
  font-size: 36px;
  font-weight: 600;
  line-height: 1.12;
  letter-spacing: -0.02em;
}

/* Tabs: iOS-style segmented control */
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
  margin-bottom: 28px;
  padding: 3px;
  border-radius: 13px;
  background: var(--fill);
}

.tabs [role="tab"] {
  height: 34px;
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-2);
  background: none;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  transition: color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.tabs [role="tab"]:hover { color: var(--text); }

.tabs [role="tab"][aria-selected="true"] {
  color: var(--text);
  background: var(--thumb);
  box-shadow: 0 1px 3px rgb(0 0 0 / 12%), 0 0 0 0.5px rgb(0 0 0 / 6%);
}

.tabs [role="tab"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--blue) 40%, transparent),
    0 1px 3px rgb(0 0 0 / 12%);
}

/* Forms */
.panel[hidden] { display: none; }

.panel { animation: fade 0.25s ease both; }

form { display: grid; gap: 18px; }

.field { display: grid; gap: 8px; }

label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: var(--field);
  border: 1px solid var(--hairline-2);
  border-radius: var(--radius-ctl);
  transition: border-color 0.18s ease, box-shadow 0.18s ease,
    background-color 0.18s ease;
}

input::placeholder { color: var(--text-3); }

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

input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent);
}

/* Keep Safari autofill colors consistent with the current theme. */
input:-webkit-autofill,
input:-webkit-autofill:hover,
input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  box-shadow: inset 0 0 0 1000px var(--field),
    0 0 0 4px color-mix(in srgb, var(--blue) 18%, transparent);
}

.field-hint {
  padding-inline: 2px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}

/* Password visibility */
.input-wrap { position: relative; display: block; }
.input-wrap input { padding-right: 46px; }
.input-wrap input::-ms-reveal { display: none; }

.input-wrap .toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  color: var(--text-2);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background-color 0.18s ease, color 0.18s ease;
}

.input-wrap input:placeholder-shown + .toggle { display: none; }

.input-wrap .toggle:hover {
  color: var(--text);
  background: var(--fill);
}

.input-wrap .toggle:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 1px;
}

.input-wrap .toggle:disabled { opacity: 0.42; cursor: default; }

/* Eye shows while masked; eye-off shows while the password is visible. */
.toggle .icon {
  display: block;
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.toggle .icon-eye-off,
.toggle[aria-pressed='true'] .icon-eye { display: none; }
.toggle[aria-pressed='true'] .icon-eye-off { display: block; }

/* Primary button */
.primary {
  height: 50px;
  margin-top: 6px;
  padding: 0 18px;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: #fff;
  background: var(--blue);
  border: 0;
  border-radius: var(--radius-ctl);
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.12s ease,
    opacity 0.18s ease;
}

.primary:hover:not(:disabled) { background: var(--blue-hover); }
.primary:active:not(:disabled) { background: var(--blue-press); transform: scale(0.99); }
.primary:disabled { opacity: 0.42; cursor: default; }
.primary:focus-visible { outline: 2px solid var(--blue); outline-offset: 3px; }

/* Password strength meter */
.strength {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding-inline: 2px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--text-2);
}

.strength[hidden] { display: none; }

.strength-bar {
  height: 4px;
  width: 0;
  border-radius: 999px;
  background: var(--hairline-2);
  transition: width 0.28s var(--ease), background-color 0.28s ease;
}

.strength[data-level="weak"] .strength-bar { background: var(--red); }
.strength[data-level="medium"] .strength-bar { background: var(--orange); }
.strength[data-level="strong"] .strength-bar { background: var(--green); }

.strength[data-level="weak"] .strength-text { color: var(--red); }
.strength[data-level="strong"] .strength-text { color: var(--green); }

/* Messages and footer */
.message {
  margin: 0;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-2);
  overflow-wrap: anywhere;
}

.message:not(:empty) { margin-top: 12px; }

.message.error {
  color: color-mix(in srgb, var(--red) 82%, var(--text));
}

.message.success:not(:empty) {
  padding: 10px 12px;
  color: var(--text);
  background: color-mix(in srgb, var(--green) 8%, transparent);
  border-inline-start: 2px solid var(--green);
  border-radius: 8px;
}

.fineprint {
  margin: 14px 0 0;
  padding-top: 16px;
  border-top: 1px solid var(--hairline);
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
}

.link {
  margin: 0;
  padding: 0;
  font: inherit;
  font-size: 13px;
  color: var(--blue);
  background: none;
  border: 0;
  cursor: pointer;
}

.link:hover { text-decoration: underline; }
.link:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Profile: grouped inset list */
.profile {
  display: grid;
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
  margin: 0 0 24px;
  padding: 0;
  background: color-mix(in srgb, var(--fill) 55%, transparent);
  border: 1px solid var(--hairline);
  border-radius: 16px;
  overflow: hidden;
}

.profile dt,
.profile dd {
  margin: 0;
  padding: 14px clamp(12px, 3vw, 18px);
  font-size: 14px;
  line-height: 1.5;
}

.profile dt { color: var(--text-2); font-size: 13px; }

.profile dd {
  color: var(--text);
  text-align: right;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

.profile dt:not(:nth-child(-n + 2)),
.profile dd:not(:nth-child(-n + 2)) {
  border-top: 1px solid var(--hairline);
}

/* Sign out: use system red for the destructive action */
.ghost {
  width: 100%;
  height: 48px;
  margin: 0;
  font: inherit;
  font-size: 16px;
  font-weight: 500;
  color: var(--red);
  background: color-mix(in srgb, var(--red) 7%, transparent);
  border: 0;
  border-radius: var(--radius-ctl);
  cursor: pointer;
  transition: background-color 0.18s ease, transform 0.12s ease,
    opacity 0.18s ease;
}

.ghost:hover { background: color-mix(in srgb, var(--red) 12%, transparent); }
.ghost:active { transform: scale(0.99); }
.ghost:disabled { opacity: 0.45; cursor: default; }
.ghost:focus-visible { outline: 2px solid var(--red); outline-offset: 3px; }

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

@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

@media (max-width: 480px) {
  body { padding: 20px 16px; align-items: start; }
  .shell { gap: 16px; }
  .card { padding: 32px 24px 26px; border-radius: 24px; }
  h1 { font-size: 30px; }
  .card-head { margin-bottom: 24px; }
  .tabs { margin-bottom: 24px; }
}

/* Account screens share their backdrop and card proportions. */
.account-page {
  --bg: #f6f5f2;
  --surface: rgb(255 255 255 / 88%);
  --glow: rgb(148 170 196 / 13%);
  --shadow: 0 2px 8px rgb(37 40 48 / 3%), 0 18px 44px -16px rgb(37 40 48 / 14%);
  background-image: radial-gradient(ellipse at 50% 0%, var(--glow), transparent 65%);
}

.account-page .card {
  padding-block: clamp(30px, 7vw, 42px) clamp(26px, 6vw, 34px);
}

.account-page .card-head { margin-bottom: 24px; }
.account-page h1 { margin-bottom: 0; line-height: 1.2; }

.account-page button:focus-visible {
  outline-offset: 3px;
}

.signet-page .tabs [role="tab"]:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 0;
  box-shadow: none;
}

.signet-page .tabs {
  margin-bottom: 24px;
  background: color-mix(in srgb, var(--fill) 75%, transparent);
}

.signet-page .tabs [aria-selected="true"]:not(:focus-visible) {
  box-shadow: 0 1px 3px rgb(0 0 0 / 8%);
}

.signet-page .field { gap: 6px; }
.signet-page input { --hairline-2: var(--hairline); }

.signet-page .primary { font-weight: 600; }
.signet-page .primary:not(:disabled) {
  box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--blue) 45%, transparent);
}

.signet-page .fineprint {
  margin-top: 20px;
  padding-top: 18px;
}

.signet-page .fineprint .link {
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 0.2em;
}

.signet-page .fineprint .link:hover,
.signet-page .fineprint .link:focus-visible { color: var(--blue); }

@media (max-width: 480px) {
  .account-page { padding: clamp(24px, 7vw, 32px) 16px; }
  .account-page .card { padding-inline: clamp(18px, 6vw, 28px); }
}

@media (prefers-color-scheme: dark) {
  .account-page {
    --bg: #121316;
    --surface: rgb(29 31 36 / 92%);
    --glow: rgb(135 158 199 / 11%);
    --shadow: 0 2px 8px rgb(0 0 0 / 12%), 0 18px 44px -16px rgb(0 0 0 / 42%);
  }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .shell,
  .panel { animation: none; }
  * { transition-duration: 0.01ms !important; }
}
