:root {
  color-scheme: light;
  --ink: #1b1a19;
  --muted: #686560;
  --hint: #918d86;
  --surface: #ffffff;
  --canvas: #faf9f7;
  --surface-subtle: #f6f5f3;
  --line: #e4e0da;
  --brand: #9c2831;
  --brand-hover: #81212a;
  --brand-soft: #faf3f4;
  --brand-border: #e7c9cd;
  --danger: #b42332;
  --danger-soft: #f8e7e9;
  --success: #237b66;
  --success-soft: #e7f3ef;
  --radius-control: 7px;
  --shadow: 0 8px 24px rgba(27,26,25,.06);
  font-family: "Noto Sans SC", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-width: 20rem;
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  background: var(--canvas);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button { cursor: pointer; }

.auth-shell {
  width: calc(100% - 48px);
  max-width: 800px;
  min-height: 420px;
  margin: 40px 24px;
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.auth-intro {
  padding: 48px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-right: 1px solid var(--line);
  background: var(--surface-subtle);
  color: var(--ink);
}
.brand { width: 40px; height: 40px; display: block; margin-bottom: 20px; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-control); background: #fff; }
.brand-mark, .brand-mark svg { width: 100%; height: 100%; display: block; }
.intro-copy { margin: 0; padding: 0; }
.intro-copy h1 { margin: 0 0 6px; color: var(--ink); font-size: 20px; font-weight: 600; line-height: 1.35; letter-spacing: .5px; }
.intro-copy p { margin: 0 0 24px; color: var(--muted); font-size: 13px; line-height: 1.65; }
.eyebrow { display: none; }
.scope-note { margin: 0; padding: 0; border: 0; background: transparent; color: var(--hint); font-size: 13px; font-weight: 400; }
.scope-note strong { font-weight: 400; }
.scope-note ul { display: none; }

.auth-panel {
  width: 100%;
  padding: 48px 36px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.auth-panel-head { margin-bottom: 22px; }
.panel-kicker { margin: 0 0 4px; color: var(--brand); font-size: 12px; font-weight: 600; }
.auth-panel h2 { margin: 0; color: var(--ink); font-size: 18px; font-weight: 600; line-height: 1.4; }
.auth-panel-head p:last-child { margin: 4px 0 0; color: var(--muted); font-size: 14px; line-height: 1.65; }

.auth-form { display: grid; gap: 14px; }
.auth-form > label, .channel-panel > label, .verify-row label { display: grid; gap: 4px; color: var(--ink); font-size: 14px; font-weight: 500; }
.channel-panel { display: grid; gap: 14px; }
.channel-panel[hidden] { display: none; }
input {
  width: 100%;
  min-height: 40px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  outline: none;
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  transition: border-color .18s ease, box-shadow .18s ease;
}
input:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(156,40,49,.12); }
small { color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.5; }

.primary-button, .secondary-button {
  min-height: 40px;
  padding: 8px 14px;
  border-radius: var(--radius-control);
  font-size: 14px;
  font-weight: 500;
  transition: background .18s ease, border-color .18s ease;
}
.primary-button { border: 1px solid var(--brand); background: var(--brand); color: #fff; }
.primary-button:hover { background: var(--brand-hover); }
.secondary-button { border: 1px solid var(--line); background: #fff; color: var(--ink); }
.secondary-button:hover { border-color: var(--brand-border); background: var(--brand-soft); color: var(--brand); }
.primary-button:focus-visible, .secondary-button:focus-visible, .text-button:focus-visible { outline: 3px solid rgba(156,40,49,.2); outline-offset: 2px; }
button:disabled { cursor: wait; opacity: .55; }

.auth-tabs, .sub-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 3px; border-radius: 9px; background: var(--surface-subtle); }
.auth-tabs button, .sub-tabs button { min-height: 34px; padding: 0 13px; border: 0; border-radius: 6px; background: transparent; color: var(--muted); font-size: 12px; }
.auth-tabs button[aria-selected="true"], .sub-tabs button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(27,26,25,.08); font-weight: 600; }

.verify-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 8px; }
.verify-row.compact { grid-template-columns: minmax(0, 1fr) auto; }
.verification-state { margin: -7px 0 0; color: var(--muted); font-size: 12px; }
.verification-state.is-ok { color: var(--success); font-weight: 500; }
.align-right { justify-self: end; }
.text-button { padding: 0; border: 0; background: transparent; color: var(--brand); font-size: 13px; font-weight: 500; text-decoration: none; }
.text-button:hover { text-decoration: underline; }
.form-switch { margin: 0; color: var(--muted); font-size: 12px; text-align: center; }
.form-help { margin: 0; color: var(--muted); font-size: 13px; }

.invite-preview, .session-notice, .auth-message { padding: 10px 12px; border-radius: var(--radius-control); font-size: 12px; }
.invite-preview { margin: 0 0 14px; border: 1px solid var(--brand-border); background: var(--brand-soft); color: #721b23; }
.invite-preview p { margin: 3px 0 0; }
.invite-preview.is-error, .auth-message { border-left: 3px solid var(--danger); background: var(--danger-soft); color: var(--danger); }
.session-notice { display: grid; gap: 8px; border: 1px solid var(--line); background: var(--surface-subtle); color: var(--ink); }
.session-notice p { margin: 0; color: var(--muted); font-size: 13px; }
.auth-message { margin: 0 0 14px; }
.auth-message.is-success { border-color: var(--success); background: var(--success-soft); color: var(--success); }

fieldset { display: grid; gap: 8px; margin: 0; padding: 0; border: 0; }
legend { margin-bottom: 4px; font-size: 13px; font-weight: 500; }
#identity-fields { grid-template-columns: repeat(2, minmax(0, 1fr)); }
#identity-fields legend { grid-column: 1 / -1; }
.choice, .agreement { display: flex; align-items: flex-start; gap: 8px; padding: 9px 10px; border: 1px solid var(--line); border-radius: var(--radius-control); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--brand-border); background: var(--brand-soft); }
.choice input, .agreement input { flex: 0 0 auto; width: 15px; min-height: 15px; margin-top: 2px; accent-color: var(--brand); }
.choice span { display: grid; min-width: 0; gap: 1px; text-align: left; }
.choice b { font-size: 13px; }
.choice small { white-space: nowrap; text-align: left; font-size: 11px; letter-spacing: -.1px; }
.auth-form > label.agreement { display: flex; align-items: flex-start; gap: 8px; padding: 0; border: 0; color: var(--muted); font-size: 12px; font-weight: 400; line-height: 1.5; }
.agreement span { min-width: 0; }
.auth-footnote { margin: 16px 0 0; color: var(--hint); font-size: 11px; text-align: center; }

@media (max-width: 640px) {
  body { place-items: start center; }
  .auth-shell { width: calc(100% - 32px); max-width: 420px; margin: 24px 16px; grid-template-columns: 1fr; }
  .auth-intro { padding: 28px 24px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin-bottom: 14px; }
  .intro-copy h1 { font-size: 18px; }
  .intro-copy p { margin-bottom: 8px; }
  .auth-panel { padding: 28px 24px; }
}

@media (max-width: 430px) {
  .verify-row { grid-template-columns: 1fr 1fr; }
  .verify-row label { grid-column: 1 / -1; }
  .secondary-button { width: 100%; }
  #identity-fields { grid-template-columns: 1fr; }
}

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