/* S9C shared member shell; S9F purchase results reuse these presentation tokens only. */
:root {
  color-scheme: light;
  --auth-ink: #19373d;
  --auth-ink-soft: #526b70;
  --auth-teal: #075f69;
  --auth-teal-dark: #034952;
  --auth-teal-soft: #e8f3f0;
  --auth-on-primary: #fff;
  --auth-canvas: #f5f3eb;
  --auth-card: #fffefa;
  --auth-line: #cbdcd8;
  --auth-line-strong: #91b3ae;
  --auth-focus: #b75c18;
  --auth-error: #8c2f35;
  --auth-error-bg: #fff0f0;
  --auth-success: #246342;
  --auth-success-bg: #edf7ef;
  --auth-warning: #785516;
  --auth-warning-bg: #fff7df;
  --auth-info-bg: #eef4f5;
  --auth-radius-card: 1.5rem;
  --auth-radius-control: 0.75rem;
  --auth-shadow: 0 1.5rem 4rem rgba(35, 64, 66, 0.12);
  font-family: "Chiron GoRound TC", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html,
body { min-height: 100%; margin: 0; }

body {
  position: relative;
  isolation: isolate;
  background: linear-gradient(180deg, #e6f0ed 0%, #edf1eb 44%, var(--auth-canvas) 78%, var(--auth-canvas) 100%);
  color: var(--auth-ink);
  text-rendering: optimizeLegibility;
}

button,
input,
select { font: inherit; }

button,
a,
input,
select { -webkit-tap-highlight-color: transparent; }

.auth-root {
  width: min(100%, 52rem);
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(1rem, env(safe-area-inset-top)) max(1rem, env(safe-area-inset-right)) max(1.5rem, env(safe-area-inset-bottom)) max(1rem, env(safe-area-inset-left));
  display: grid;
  align-content: center;
}

/* Native hidden state must outrank shared flex/grid control presentation. */
.auth-root [hidden] {
  display: none !important;
}

.auth-shell {
  min-width: 0;
  overflow: hidden;
  background: rgba(255, 254, 250, 0.98);
  border: 1px solid var(--auth-line);
  border-radius: var(--auth-radius-card);
  box-shadow: var(--auth-shadow);
}

.auth-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-width: 0;
  padding: 0.9rem 1.15rem;
  background: rgba(239, 247, 244, 0.9);
  border-bottom: 1px solid var(--auth-line);
}

.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  color: var(--auth-teal-dark);
  font-size: clamp(0.9rem, 0.85rem + 0.2vw, 1rem);
  font-weight: 800;
  line-height: 1.35;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.auth-language {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  flex: 0 1 auto;
  min-width: 0;
  color: var(--auth-ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
}

.auth-language-label { overflow-wrap: anywhere; }

.auth-language select {
  min-width: 6.8rem;
  max-width: 100%;
  min-height: 2.75rem;
  padding: 0.5rem 2rem 0.5rem 0.7rem;
  background-color: var(--auth-card);
  border: 1px solid var(--auth-line-strong);
  border-radius: 0.65rem;
  color: var(--auth-ink);
  font-weight: 700;
}

.auth-panel {
  width:min(100%, 34rem);
  margin: 0 auto;
  padding: clamp(1.4rem, 4.5vw, 2.85rem);
}

.auth-panel-inner { min-width: 0; }

.auth-page-heading { margin: 0 0 clamp(1.25rem, 3vw, 1.75rem); }

.auth-page-heading h1,
.auth-panel > h1,
.auth-panel-inner > h1 {
  max-width: 22ch;
  margin: 0;
  color: var(--auth-ink);
  font-size: clamp(1.55rem, 1.35rem + 1vw, 2.05rem);
  font-weight: 850;
  letter-spacing: -0.018em;
  line-height: 1.18;
  overflow-wrap: anywhere;
  word-break: normal;
}

.auth-intro {
  max-width: 42ch;
  margin: 0.6rem 0 0;
  color: var(--auth-ink-soft);
  font-size: clamp(0.91rem, 0.88rem + 0.12vw, 0.98rem);
  line-height: 1.65;
  overflow-wrap: anywhere;
  word-break: normal;
}

.auth-form {
  display: grid;
  gap: 1rem;
  min-width: 0;
}

.auth-field {
  display: grid;
  gap: 0.45rem;
  min-width: 0;
  color: var(--auth-ink);
  font-size: 0.9rem;
  font-weight: 750;
  line-height: 1.4;
}

.auth-field > label {
  min-width: 0;
  overflow-wrap: anywhere;
}

.auth-field input {
  width: 100%;
  min-width: 0;
  min-height: 3rem;
  padding: 0.72rem 0.85rem;
  background: #fff;
  border: 1px solid var(--auth-line-strong);
  border-radius: var(--auth-radius-control);
  color: var(--auth-ink);
  line-height: 1.4;
  transition: border-color 140ms ease, box-shadow 140ms ease, background-color 140ms ease;
}

.auth-field input:hover { border-color: var(--auth-teal); }

.auth-field input:focus {
  border-color: var(--auth-teal);
  box-shadow: 0 0 0 3px rgba(7, 95, 105, 0.14);
}

.auth-field input[aria-invalid="true"] { border-color: var(--auth-error); }

.auth-field input:-webkit-autofill,
.auth-field input:-webkit-autofill:hover,
.auth-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--auth-ink);
  box-shadow: 0 0 0 1000px #f1f8f5 inset;
}

.auth-password-wrap {
  position: relative;
  display: block;
  min-width: 0;
}

.auth-password-wrap input { padding-inline-end: 4.7rem; }

.auth-password-toggle {
  position: absolute;
  top: 50%;
  right: 0.35rem;
  min-width: 3.7rem;
  min-height: 2.75rem;
  padding: 0 0.6rem;
  transform: translateY(-50%);
  background: var(--auth-teal-soft);
  border: 0;
  border-radius: 0.55rem;
  color: var(--auth-teal-dark);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 800;
}

.auth-primary,
.auth-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 3rem;
  padding: 0.72rem 1rem;
  border-radius: var(--auth-radius-control);
  cursor: pointer;
  font-size: 0.94rem;
  font-weight: 850;
  line-height: 1.35;
  text-align: center;
  text-decoration: none;
  overflow-wrap: anywhere;
  word-break: normal;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.auth-primary,
.auth-links a.auth-primary {
  background: var(--auth-teal);
  border: 1px solid var(--auth-teal);
  color: var(--auth-on-primary);
}

.auth-secondary {
  background: transparent;
  border: 1px solid var(--auth-line-strong);
  color: var(--auth-teal-dark);
}

.auth-sign-out { width: 100%; margin-top: 1rem; }

.auth-primary[disabled],
.auth-secondary[disabled],
.auth-form[aria-busy="true"] button {
  cursor: wait;
  opacity: 0.58;
}

.auth-form[data-state="submitted"] button {
  cursor: default;
  opacity: 0.72;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.7rem 1rem;
  min-width: 0;
  margin-top: 1.35rem;
  padding-top: 1rem;
  border-top: 1px solid #e1e9e6;
  color: var(--auth-ink-soft);
  font-size: 0.86rem;
  line-height: 1.5;
}

.auth-links--actions { border-top: 0; padding-top: 0; }

.auth-link-prompt {
  min-width: 0;
  overflow-wrap: anywhere;
}

.auth-link {
  min-width: 0;
  color: var(--auth-teal-dark);
  font-weight: 750;
  text-underline-offset: 0.2em;
  overflow-wrap: anywhere;
}

.auth-links .auth-link--quiet { color: var(--auth-ink-soft); }
.auth-link--support { margin-inline-end: auto; }
.auth-link-button { width: 100%; }

.auth-status {
  position: relative;
  min-width: 0;
  margin: 1rem 0 0;
  padding: 0.85rem 0.95rem 0.85rem 2.7rem;
  background: var(--auth-info-bg);
  border: 1px solid #ccdce0;
  border-radius: var(--auth-radius-control);
  color: var(--auth-ink);
  font-size: 0.88rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  word-break: normal;
}

.auth-status::before {
  position: absolute;
  top: 0.93rem;
  left: 1rem;
  display: grid;
  place-items: center;
  width: 1rem;
  height: 1rem;
  border: 1.5px solid currentColor;
  border-radius: 50%;
  content: "i";
  font-family: system-ui, sans-serif;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
}

.auth-status[data-kind="success"] {
  background: var(--auth-success-bg);
  border-color: #bfdcc8;
  color: var(--auth-success);
}

.auth-status[data-kind="success"]::before { content: "\2713"; }

.auth-status[data-kind="warning"] {
  background: var(--auth-warning-bg);
  border-color: #ead79b;
  color: var(--auth-warning);
}

.auth-status[data-kind="warning"]::before { content: "!"; }

.auth-status[data-kind="error"] {
  background: var(--auth-error-bg);
  border-color: #ebc5c7;
  color: var(--auth-error);
}

.auth-status[data-kind="error"]::before { content: "!"; }

.auth-status[data-kind="loading"]::before {
  border-color: rgba(7, 95, 105, 0.24);
  border-top-color: var(--auth-teal);
  content: "";
  animation: auth-spin 850ms linear infinite;
}

.auth-status--compact { margin-top: 0.85rem; }

.auth-account-card {
  min-width: 0;
  padding: 1rem;
  background: #f7faf8;
  border: 1px solid var(--auth-line);
  border-radius: 1rem;
}

.auth-account-label {
  margin: 0 0 0.35rem;
  color: var(--auth-ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.35;
  text-transform: uppercase;
}

.auth-account-email {
  margin: 0;
  color: var(--auth-ink);
  direction: ltr;
  font-size: clamp(0.96rem, 0.9rem + 0.22vw, 1.08rem);
  font-weight: 800;
  line-height: 1.45;
  text-align: start;
  unicode-bidi: plaintext;
  overflow-wrap: anywhere;
  word-break: normal;
}

/* S9F Account bookshelf: read-only entitlement presentation. */
.account-books {
  min-width: 0;
  margin-top: 1rem;
  padding: 1rem;
  background: #fffdf6;
  border: 1px solid #dfd7c5;
  border-radius: 1rem;
}

.account-books__heading {
  display: flex;
  align-items: center;
  min-width: 0;
  margin-bottom: 0.8rem;
}

.account-books__heading h2 {
  margin: 0;
  color: var(--auth-ink);
  font-size: clamp(1.05rem, 1rem + 0.28vw, 1.2rem);
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.account-books__content { display: grid; gap: 0.75rem; min-width: 0; }
.account-books__state { margin: 0; color: var(--auth-ink-soft); font-size: 0.88rem; line-height: 1.55; overflow-wrap: anywhere; }
.account-books__state[data-kind="loading"] { padding-inline-start: 1.5rem; background: radial-gradient(circle at 0.45rem 50%, var(--auth-teal) 0 0.22rem, transparent 0.25rem); }
.account-books__state[data-kind="error"] { color: var(--auth-error); }
.account-books__browse { width: 100%; margin-top: 0.15rem; }

.account-book {
  display: grid;
  grid-template-columns: 5rem minmax(0, 1fr);
  gap: 0.9rem;
  min-width: 0;
  padding-top: 0.8rem;
  border-top: 1px solid #e7e0d2;
}
.account-book:first-child { padding-top: 0; border-top: 0; }
.account-book__cover { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 0.4rem; box-shadow: 0 0.45rem 1rem rgba(25, 55, 61, 0.12); }
.account-book__body { align-self: center; min-width: 0; }
.account-book__eyebrow { margin: 0 0 0.25rem; color: var(--auth-success); font-size: 0.74rem; font-weight: 850; letter-spacing: 0.025em; line-height: 1.4; overflow-wrap: anywhere; }
.account-book h3 { margin: 0; color: var(--auth-ink); font-size: clamp(1.05rem, 0.98rem + 0.36vw, 1.25rem); line-height: 1.3; overflow-wrap: anywhere; }
.account-book__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.55rem 0.8rem; min-width: 0; margin-top: 0.7rem; }
.account-book__actions .auth-primary { flex: 1 1 9rem; }
.account-book__library { flex: 0 1 auto; min-height: 2.75rem; display: inline-flex; align-items: center; }

.auth-state {
  display: grid;
  justify-items: center;
  gap: 0.8rem;
  padding: 1.2rem;
  color: var(--auth-ink-soft);
  text-align: center;
}

.auth-root[data-auth-page="account"] { align-content: start; }

.auth-loading { margin: 0; padding: 0; font-size: 0.9rem; font-weight: 750; line-height: 1.5; }

.auth-spinner {
  width: 1.65rem;
  height: 1.65rem;
  border: 3px solid rgba(7, 95, 105, 0.18);
  border-top-color: var(--auth-teal);
  border-radius: 50%;
  animation: auth-spin 850ms linear infinite;
}

@keyframes auth-spin { to { transform: rotate(360deg); } }

@media (hover: hover) {
  .auth-brand:hover,
  .auth-link:hover { color: var(--auth-teal); }
  .auth-primary:hover { background: var(--auth-teal-dark); border-color: var(--auth-teal-dark); }
  .auth-secondary:hover { background: var(--auth-teal-soft); border-color: var(--auth-teal); }
  .auth-primary:not([disabled]):active,
  .auth-secondary:not([disabled]):active { transform: translateY(1px); }
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 3px solid var(--auth-focus);
  outline-offset: 3px;
}

@media (max-width: 520px) {
  .auth-root { padding-inline: max(0.65rem, env(safe-area-inset-left)); padding-right: max(0.65rem, env(safe-area-inset-right)); }
  .auth-header { align-items: stretch; flex-direction: column; padding: 0.85rem 1rem; }
  .auth-language { width: 100%; justify-content: space-between; }
  .auth-language select { flex: 0 1 9rem; }
  .auth-panel { padding: 1.35rem 1rem 1.55rem; }
  .auth-links { align-items: stretch; flex-direction: column; }
  .auth-link--support { margin-inline-end: 0; }
  .auth-link { min-height: 2.75rem; display: inline-flex; align-items: center; }
}

@media (max-width: 340px) {
  .auth-root { padding-inline: max(0.45rem, env(safe-area-inset-left)); padding-right: max(0.45rem, env(safe-area-inset-right)); }
  .auth-shell { border-radius: 1.1rem; }
  .auth-panel { padding-inline: 0.85rem; }
  .auth-language { align-items: stretch; flex-direction: column; }
  .auth-language select { width: 100%; flex-basis: auto; }
  .auth-password-toggle { min-width: 3.35rem; padding-inline: 0.45rem; }
  .auth-password-wrap input { padding-inline-end: 4.25rem; }
  .account-book { grid-template-columns: 4.25rem minmax(0, 1fr); gap: 0.7rem; }
  .account-book__actions { align-items: stretch; flex-direction: column; }
  .account-book__actions .auth-primary { flex: 0 1 auto; }
  .account-book__actions > * { width: 100%; }
}

@media (min-width: 900px) {
  .auth-shell { border-radius: 1.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; }
}
