/* PenEcho Cloud — auth page (Apple-minimal redesign) */
:root {
  color-scheme: light;
  --bg: #fafafa;
  --card: #ffffff;
  --ink: #18181b;
  --ink-2: #52525b;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --line: #e4e4e7;
  --danger: #dc2626;
  --ok: #18181b;
  --radius-card: 14px;
  --radius-ctl: 10px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  overflow-x: clip;
}
.auth-shell { width: 100%; max-width: 400px; text-align: center; }
.auth-logo { align-items: center; display: inline-flex; min-height: 44px; margin-bottom: 20px; }
.auth-logo img { height: 32px; width: auto; display: block; }

.auth-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-card);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 28px 28px 24px;
  text-align: left;
}

/* Segmented tabs */
.auth-tabs {
  display: flex;
  gap: 4px;
  background: #fafafa;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  margin-bottom: 24px;
}
.auth-tabs button {
  flex: 1;
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink-2);
  padding: 7px 0;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 44px;
}
.auth-tabs button.on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

/* Forms */
form { margin: 0; }
form h1 { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; margin: 0 0 4px; }
form .sub { font-size: 13px; line-height: 1.45; color: var(--ink-2); margin: 0 0 20px; }

.field { margin-bottom: 16px; }
.field label {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 6px;
}
.field label .opt { font-size: 12px; font-weight: 400; color: var(--ink-2); }
.field input[type="email"], .field input[type="password"], .field input[type="text"] {
  width: 100%;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  min-height: 44px;
}
.field input::placeholder { color: #a1a1a6; }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.field input.invalid { border-color: var(--danger); }
.field .error { display: none; font-size: 12px; color: var(--danger); margin-top: 6px; }
.field.show-error .error { display: block; }
.field .hint { display: block; font-size: 12px; color: var(--ink-2); margin-top: 6px; }
.field.show-error .hint { display: none; }

.link-button {
  align-items: center;
  appearance: none;
  border: 0;
  padding: 0;
  background: none;
  font: inherit;
  font-size: 12px;
  font-weight: 400;
  color: var(--accent);
  cursor: pointer;
  display: inline-flex;
  justify-content: center;
  min-height: 44px;
}
.link-button:hover { text-decoration: underline; }

/* Password meter */
.pw-meter { display: flex; gap: 4px; margin-top: 8px; }
.pw-meter i { flex: 1; height: 3px; border-radius: 2px; background: var(--line); transition: background 0.2s ease; }
.pw-meter.s1 i:nth-child(1) { background: var(--danger); }
.pw-meter.s2 i:nth-child(-n+2) { background: #f0930a; }
.pw-meter.s3 i { background: #34c759; }

/* Legal consent */
.legal-consent { margin: 8px 0 16px; font-size: 12px; line-height: 1.55; color: var(--ink-2); }
.legal-consent label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  min-height: 44px;
  padding: 4px 0;
  cursor: pointer;
}
.legal-consent input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
}
.legal-consent a { color: var(--accent); text-decoration: none; }
.legal-consent-copy { display: block; min-width: 0; }
.legal-consent-copy a { display: inline; min-height: 0; }
.legal-consent a:hover { text-decoration: underline; }
.legal-consent input[type="checkbox"]:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.2); outline-offset: 2px; }
.legal-consent-error { display: none; font-size: 12px; color: var(--danger); margin: 4px 0 0 28px; }
.legal-consent.invalid .legal-consent-error { display: block; }

/* Buttons */
.form-foot { margin-top: 20px; }
.button {
  display: block;
  width: 100%;
  min-height: 44px;
  appearance: none;
  border: 0;
  border-radius: var(--radius-ctl);
  font: inherit;
  font-size: 15px;
  font-weight: 500;
  color: #fff;
  background: var(--accent);
  padding: 11px 16px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.button:hover { background: var(--accent-hover); }
.button:disabled { opacity: 0.6; cursor: default; }
.verification-actions { display: flex; flex-direction: column; gap: 12px; }
.verification-actions .link-button { font-size: 13px; min-height: 44px; text-align: center; }

/* Code input */
.code-field { position: relative; }
.code-shell { min-height: 44px; position: relative; }
.code-boxes {
  display: flex;
  gap: 8px;
  pointer-events: none;
  align-items: center;
  justify-content: center;
}
.code-boxes i {
  flex: 1 1 0;
  height: 44px;
  max-width: 44px;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font-size: 17px;
  font-weight: 500;
  color: var(--ink);
  display: flex; align-items: center; justify-content: center;
}
.code-boxes i.filled { border-color: var(--accent); }
.code-boxes i.active { box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15); }
.field input.code-input {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 44px;
  border: 0;
  background: transparent;
  color: transparent;
  caret-color: transparent;
  font-size: 16px;
  letter-spacing: 4px;
  outline: none;
  padding: 0;
}
.field input.code-input::placeholder { color: transparent; }
.field input.code-input:focus { border: 0; box-shadow: none; }
/* The active digit box already provides the code input's focus indicator. */
.public-paper .auth-shell input.code-input:focus-visible { outline: none; }
.code-field.show-error .code-boxes i { border-color: var(--danger); }
.code-field .error { margin-top: 6px; }

/* OAuth */
.form-alt {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 14px;
  font-size: 11px;
  color: var(--ink-2);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.form-alt::before, .form-alt::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.oauth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  appearance: none;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius-ctl);
  padding: 10px 16px;
  margin-bottom: 10px;
  min-height: 44px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.oauth-btn:hover { background: #fafafa; }
.google-mark {
  width: 18px; height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--line);
  color: var(--ink);
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.github-mark { width: 18px; height: 18px; fill: var(--ink); }

/* Messages */
.form-message {
  display: none;
  font-size: 13px;
  line-height: 1.45;
  border-radius: var(--radius-ctl);
  padding: 10px 12px;
  margin-top: 16px;
}
.form-message.ok { display: block; background: #fafafa; color: var(--ink); }
.form-message.err { display: block; background: #fef2f2; color: var(--danger); }

/* Footer note + legal */
.auth-note {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 11px;
  line-height: 1.5;
  color: var(--ink-2);
  margin-top: 18px;
}
.auth-note svg { flex: none; margin-top: 1px; color: var(--ink-2); }
.auth-legal {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 18px;
  font-size: 12px;
}
.auth-legal a { align-items: center; color: var(--ink-2); display: inline-flex; min-height: 44px; text-decoration: none; }
.auth-legal a:hover { color: var(--ink); text-decoration: underline; }

.auth-shell button:focus-visible,
.auth-shell a[href]:focus-visible,
.auth-shell input:not(.code-input):focus-visible {
  border-radius: 8px;
  outline: 3px solid rgba(37, 99, 235, 0.36);
  outline-offset: 2px;
}
