body textarea {
  resize: none !important;
  field-sizing: fixed !important;
  min-height: 96px;
  max-height: 240px !important;
  max-width: 100%;
  overflow-y: auto !important;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}
.field-character-count { display: block; margin-top: 4px; color: var(--muted, #536b5d); font-size: 12px; text-align: end; font-variant-numeric: tabular-nums; }
.form-validation-message { grid-column: 1 / -1; flex-basis: 100%; margin: 10px 0 0; padding: 10px 14px; border: 1px solid var(--coral); border-radius: 12px; color: var(--ink); background: color-mix(in srgb, var(--coral) 9%, var(--card)); overflow-wrap: anywhere; }
.form-validation-message[hidden] { display: none !important; }
.field-validation-error { display:block; margin:5px 0; color:var(--ink); font-size:13px; line-height:1.45; overflow-wrap:anywhere; }
.field-validation-error::before { content:'!'; display:inline-grid; place-items:center; width:17px; height:17px; margin-inline-end:6px; border:1px solid var(--coral); border-radius:50%; font-weight:800; }
.field-validation-error[hidden] { display:none !important; }
.auth-form > .field-validation-error { grid-column: 1 / -1; min-width: 0; margin-top: -4px; }
#auth-consents .field-validation-error { margin: 2px 0 8px 28px; }
body input[aria-invalid="true"], body textarea[aria-invalid="true"], body select[aria-invalid="true"] { border-color:var(--coral); }

/* Same themed focus ring as text inputs; keep keyboard focus clearly visible. */
body textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 14%, transparent);
}
@media (forced-colors: active) {
  body textarea:focus { outline: 2px solid Highlight; outline-offset: 2px; box-shadow: none; }
}

/* Compact account entry: fields stay readable, not scaled down to fit. */
body.webapp-page #auth-view[data-auth-mode="register"] {
  grid-template-columns: minmax(0, 1fr) !important;
  gap: 24px !important;
  padding: 28px !important;
}
#auth-view[data-auth-mode="register"] > :is(.auth-copy, .auth-card) {
  width: 100%; max-width: 600px; min-width: 0; justify-self: center;
}
#auth-view[data-auth-mode="register"] .auth-copy .lead { margin: 16px 0 0; line-height: 1.6; }
#auth-view .auth-card { container-type: inline-size; min-width: 0; }
#auth-view[data-auth-mode="register"] .auth-card { padding: 24px; }
#auth-view[data-auth-mode="register"] .auth-tabs { margin-bottom: 18px; }
#auth-view[data-auth-mode="register"] .auth-form { gap: 14px 16px; align-items: start; }
#auth-view .auth-field { min-width: 0; align-content: start; }
#auth-view .auth-field > span:first-child { line-height: 1.4; }
#auth-view[data-auth-mode="register"] .auth-field { gap: 6px; font-size: 14px; }
#auth-view[data-auth-mode="register"] .auth-field > input,
#auth-view[data-auth-mode="register"] .password-field { min-height: 48px; border-radius: 14px; }
#auth-view[data-auth-mode="register"] .password-field input { min-height: 46px; }
#auth-view[data-auth-mode="register"] .auth-form > :not(.auth-field) { grid-column: 1 / -1; }
.auth-helper-actions[hidden], .auth-consents[hidden] { display: none !important; }
.auth-consents { display: grid; gap: 6px; margin: 2px 0; min-width: 0; }
body .auth-consents label.welcome-checkbox { gap: 10px; padding: 4px 0; min-height: 30px; font-size: 14px; font-weight: 600; line-height: 1.5; }
.auth-consents .welcome-checkbox > span { min-width: 0; overflow-wrap: anywhere; }
.auth-consents a { color: var(--accent-ink); text-decoration: underline; text-underline-offset: 3px; text-decoration-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.auth-consents a:hover { text-decoration-color: currentColor; }
.auth-consents a:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.auth-consents > small { padding-left: 32px; color: var(--muted); font-size: 12px; line-height: 1.5; }
body .auth-consents .welcome-checkbox input[type="checkbox"] {
  appearance: none; display: grid; place-items: center; width: 22px; height: 22px; min-height: 22px; flex: 0 0 22px;
  margin: 0; padding: 0; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); cursor: pointer;
}
body .auth-consents input[type="checkbox"]:checked { background: var(--accent-ink); border-color: var(--accent-ink); }
body .auth-consents input[type="checkbox"]:checked::after { content: ''; width: 6px; height: 11px; border: solid white; border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); }
body .auth-consents input[type="checkbox"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
body .auth-consents input[type="checkbox"][aria-invalid="true"] { border-color: var(--coral); }
.auth-consents .field-validation-error { margin: 0 0 4px 32px; }
#auth-view[data-auth-mode="register"] .provider-button { min-width: 0; min-height: 52px; gap: 8px; padding: 8px 12px; font-size: 14px; line-height: 1.4; border-radius: 14px; }
#auth-view[data-auth-mode="register"] .provider-button > span:last-child { min-width: 0; overflow-wrap: anywhere; }
#auth-view[data-auth-mode="register"] .provider-mark { flex-shrink: 0; }
@container (min-width: 430px) {
  #auth-view[data-auth-mode="register"] .auth-form { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #auth-view[data-auth-mode="register"] .auth-provider-actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1280px) {
  body.webapp-page #auth-view[data-auth-mode="register"] { grid-template-columns: minmax(0, .85fr) minmax(460px, 1.15fr) !important; gap: 28px !important; padding: 32px !important; }
}
@media (max-width: 640px) {
  body.webapp-page #auth-view[data-auth-mode="register"] { gap: 18px !important; padding: 20px 10px !important; }
  #auth-view[data-auth-mode="register"] .auth-card { padding: 16px; }
  #auth-view[data-auth-mode="register"] .auth-copy .lead { font-size: 16px; }
  #auth-view[data-auth-mode="register"] .auth-field input { font-size: 16px; }
}
@media (forced-colors: active) {
  body .auth-consents input[type="checkbox"] { border-color: CanvasText; }
  body .auth-consents input[type="checkbox"]:checked { background: Highlight; }
  body .auth-consents input[type="checkbox"]:checked::after { border-color: HighlightText; }
}

/* Account benefits: a balanced, readable companion to either form. */
#auth-view .auth-copy { align-self: center; }
#auth-view .auth-copy .lead { margin: 16px 0 0; font-size: 17px; line-height: 1.65; }
#auth-view .auth-benefits { display: grid; gap: 12px; margin: 26px 0 0; padding: 0; list-style: none; }
#auth-view .auth-benefit {
  display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 14px; align-items: start;
  padding: 18px; border: 1px solid var(--line); border-radius: 18px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  box-shadow: 0 5px 18px color-mix(in srgb, var(--accent) 5%, transparent);
}
#auth-view .auth-benefit-icon { display: grid; place-items: center; width: 44px; height: 44px; border-radius: 13px; color: var(--accent-ink); background: var(--accent-soft); }
#auth-view .auth-benefit-icon svg { width: 24px; height: 24px; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#auth-view .auth-benefit h2 { margin: 0 0 5px; font-size: 16px; line-height: 1.4; letter-spacing: -.015em; }
#auth-view .auth-benefit p { margin: 0; color: var(--muted); font-size: 14px; line-height: 1.55; }
@media (max-width: 1279px) {
  /* Keep the form close to the top on smaller screens; details follow it. */
  body.webapp-page #auth-view { grid-template-columns: minmax(0, 1fr) !important; gap: 18px !important; }
  #auth-view .auth-copy { display: contents; }
  #auth-view :is(#auth-heading, #auth-intro, .auth-card, .auth-benefits) { width: 100%; max-width: 600px !important; min-width: 0; justify-self: center; }
  #auth-view #auth-heading { grid-row: 1; margin: 0; }
  #auth-view #auth-intro { grid-row: 2; margin: 0; }
  #auth-view .auth-card { grid-row: 3; }
  #auth-view .auth-benefits { grid-row: 4; margin: 0; gap: 10px; }
  #auth-view .auth-benefit { padding: 14px; gap: 12px; }
}
@media (max-width: 640px) {
  #auth-view .auth-benefit { grid-template-columns: 36px minmax(0, 1fr); padding: 12px; }
  #auth-view .auth-benefit-icon { width: 36px; height: 36px; border-radius: 11px; }
  #auth-view .auth-benefit-icon svg { width: 22px; height: 22px; }
  #auth-view .auth-benefit h2 { font-size: 15px; }
  #auth-view .auth-benefit p { font-size: 13px; }
}
