:root {
  color-scheme: light dark;
  --bg: #f3f6f1;
  --surface: #fbfcf9;
  --surface-strong: #ffffff;
  --surface-muted: #e8eee6;
  --ink: #17352d;
  --ink-soft: #53665f;
  --line: #cbd7ce;
  --brand: #176b50;
  --brand-deep: #114d3b;
  --brand-soft: #dcece4;
  --accent: #e9a82b;
  --danger: #a13d34;
  --shadow: 0 18px 48px rgba(23, 53, 45, 0.12);
  --radius-card: 18px;
  --radius-control: 12px;
  font-family: "Avenir Next", Avenir, "PingFang SC", "Microsoft YaHei", sans-serif;
}
* { box-sizing: border-box; }
html { min-width: 320px; background: var(--bg); }
body { margin: 0; min-width: 320px; min-height: 100dvh; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.6; }
button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
a { color: inherit; }
button:focus-visible, a:focus-visible, input:focus-visible { outline: 3px solid rgba(233, 168, 43, 0.5); outline-offset: 3px; }
[hidden] { display: none !important; }
.skip-link { position: fixed; top: 12px; left: 12px; z-index: 100; padding: 10px 14px; border-radius: var(--radius-control); background: var(--surface-strong); color: var(--ink); transform: translateY(-160%); }
.skip-link:focus { transform: translateY(0); }

.auth-shell { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(430px, 0.96fr); min-height: 100dvh; }
.auth-visual { position: relative; isolation: isolate; display: flex; min-height: 100dvh; overflow: hidden; padding: 44px clamp(36px, 5vw, 84px); background: radial-gradient(circle at 76% 18%, rgba(233, 168, 43, 0.22), transparent 24%), linear-gradient(145deg, #0f4637 0%, #17352d 62%, #102d27 100%); color: #f6faf7; }
.auth-visual::after { content: ""; position: absolute; inset: auto -12% -24% 20%; z-index: -1; height: 54%; border-radius: 50%; background: rgba(255, 255, 255, 0.055); transform: rotate(-8deg); }
.auth-visual > .brand-mark { position: relative; z-index: 2; }
.brand-mark { display: inline-grid; width: 44px; height: 44px; place-items: center; flex: 0 0 auto; border-radius: 14px; background: var(--accent); color: #17352d; font-size: 15px; font-weight: 900; letter-spacing: 0.04em; }
.auth-visual-copy { position: relative; z-index: 2; align-self: center; max-width: 580px; padding-bottom: 8vh; }
.auth-visual-copy .brand-name { margin: 0 0 18px; color: #bdd5cb; font-size: 14px; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; }
.auth-visual-copy h1 { max-width: 10.5em; margin: 0; font-size: clamp(38px, 4.2vw, 68px); line-height: 1.13; letter-spacing: -0.045em; }
.auth-visual-copy p:last-child { max-width: 29em; margin: 24px 0 0; color: #c9dbd3; font-size: 18px; }
.auth-visual > img { position: absolute; right: -9%; bottom: -15%; z-index: 1; width: min(46vw, 620px); height: auto; opacity: 0.9; filter: drop-shadow(0 24px 28px rgba(4, 20, 16, 0.24)); }

.auth-panel { display: grid; min-height: 100dvh; place-items: center; padding: clamp(28px, 5vw, 72px); background: var(--surface); }
.auth-card { width: min(100%, 460px); }
.mobile-brand { display: none; }
.auth-heading > p, .section-label { margin: 0 0 8px; color: var(--brand); font-size: 13px; font-weight: 850; letter-spacing: 0.08em; text-transform: uppercase; }
.auth-heading h2 { margin: 0; font-size: clamp(31px, 4vw, 42px); line-height: 1.2; letter-spacing: -0.03em; }
.auth-heading > span { display: block; margin-top: 10px; color: var(--ink-soft); }
.auth-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; margin: 34px 0 26px; padding: 4px; border-radius: var(--radius-control); background: var(--surface-muted); }
.auth-tab { min-height: 44px; border: 0; border-radius: 9px; background: transparent; color: var(--ink-soft); font-weight: 800; cursor: pointer; }
.auth-tab.is-active { background: var(--surface-strong); color: var(--ink); box-shadow: 0 2px 9px rgba(23, 53, 45, 0.09); }
.auth-form { display: grid; gap: 19px; }
.field { display: grid; gap: 7px; }
.field > span { color: var(--ink); font-size: 14px; font-weight: 800; }
.field input { width: 100%; height: 50px; border: 1px solid var(--line); border-radius: var(--radius-control); background: var(--surface-strong); color: var(--ink); padding: 0 15px; transition: border-color 160ms ease, box-shadow 160ms ease; }
.field input::placeholder { color: #718179; }
.field input:hover { border-color: #9eb0a5; }
.field input:focus { border-color: var(--brand); box-shadow: 0 0 0 4px rgba(23, 107, 80, 0.12); outline: 0; }
.field small { color: var(--ink-soft); font-size: 12px; }
.form-message { min-height: 1.55em; margin: -4px 0 0; color: var(--danger); font-size: 13px; font-weight: 700; }
.form-message.is-info { color: var(--brand); }

.button { display: inline-flex; min-height: 46px; align-items: center; justify-content: center; border: 1px solid transparent; border-radius: var(--radius-control); padding: 10px 18px; font-weight: 850; line-height: 1.2; text-align: center; text-decoration: none; white-space: nowrap; cursor: pointer; transition: transform 140ms ease, background-color 160ms ease, border-color 160ms ease; }
.button:active:not(:disabled) { transform: translateY(1px) scale(0.99); }
.button-primary { background: var(--brand); color: #f7fbf8; }
.button-primary:hover { background: var(--brand-deep); }
.button-secondary { border-color: var(--line); background: var(--surface-strong); color: var(--ink); }
.button-secondary:hover { border-color: var(--brand); }
.button-full { width: 100%; }
.button-compact { min-height: 38px; padding: 8px 13px; }
.button-disabled { border-color: var(--line); background: var(--surface-muted); color: var(--ink-soft); cursor: not-allowed; }
.preview-notice { margin-top: 26px; border-left: 4px solid var(--accent); border-radius: 0 var(--radius-control) var(--radius-control) 0; padding: 13px 15px; background: color-mix(in srgb, var(--accent) 11%, var(--surface)); }
.preview-notice strong { font-size: 14px; }
.preview-notice p { margin: 5px 0 0; color: var(--ink-soft); font-size: 13px; }

.library-view { min-height: 100dvh; }
.site-header { position: sticky; top: 0; z-index: 20; border-bottom: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); }
.header-inner, .library-main, .site-footer { width: min(100% - 40px, 1440px); margin-inline: auto; }
.header-inner { display: flex; min-height: 72px; align-items: center; justify-content: space-between; gap: 24px; }
.site-brand { display: flex; align-items: center; gap: 12px; text-decoration: none; }
.site-brand > span:last-child { display: grid; line-height: 1.15; }
.site-brand strong { font-size: 16px; }
.site-brand small { margin-top: 4px; color: var(--ink-soft); font-size: 11px; }
.header-actions { display: flex; align-items: center; gap: 15px; }
.text-button { border: 0; background: transparent; color: var(--brand); font-weight: 850; text-decoration: none; cursor: pointer; }
.account-name { max-width: 180px; overflow: hidden; color: var(--ink-soft); font-size: 14px; text-overflow: ellipsis; white-space: nowrap; }
.library-main { padding-block: 58px 90px; }
.library-intro { display: flex; align-items: end; justify-content: space-between; gap: 32px; }
.library-intro h1 { margin: 0; font-size: clamp(34px, 4.5vw, 62px); line-height: 1.12; letter-spacing: -0.045em; }
.library-intro > div > p:last-child { max-width: 680px; margin: 15px 0 0; color: var(--ink-soft); font-size: 17px; }
.sync-banner { display: flex; align-items: center; justify-content: space-between; gap: 26px; margin-top: 38px; border-radius: var(--radius-card); padding: 20px 24px; background: var(--brand-deep); color: #edf7f1; }
.sync-banner strong { font-size: 16px; }
.sync-banner p { margin: 3px 0 0; color: #bed4ca; font-size: 13px; }
.sync-banner > span { flex: 0 0 auto; color: #f2c45a; font-size: 13px; font-weight: 850; }

.books-section { margin-top: 68px; }
.section-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 22px; margin-bottom: 22px; }
.section-heading h2 { margin: 0; font-size: 30px; letter-spacing: -0.025em; }
.section-heading p { margin: 0; color: var(--ink-soft); }
.book-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(420px, 0.9fr); gap: 22px; align-items: stretch; }
.book-card { border: 1px solid var(--line); border-radius: var(--radius-card); background: var(--surface-strong); box-shadow: 0 8px 24px rgba(23, 53, 45, 0.055); }
.book-card-featured { display: grid; grid-template-columns: minmax(230px, 0.72fr) minmax(0, 1.28fr); overflow: hidden; }
.book-cover { container-type: inline-size; display: flex; min-height: 460px; flex-direction: column; justify-content: space-between; padding: clamp(20px, 4cqw, 32px); color: #f6faf7; }
.foundations-cover { background: radial-gradient(circle at 90% 8%, rgba(233, 168, 43, 0.74), transparent 22%), linear-gradient(155deg, #1d7b5b 0%, #153f34 72%); }
.book-cover .book-series { font-size: 13px; font-weight: 850; letter-spacing: 0.06em; text-transform: uppercase; }
.book-cover strong { max-width: 100%; font-size: clamp(22px, 8.5cqw, 52px); line-height: 1; letter-spacing: -0.055em; white-space: nowrap; }
.book-cover span:last-child { max-width: 17em; color: #c9ded4; font-size: 13px; }
.book-info { display: flex; min-width: 0; flex-direction: column; padding: 32px; }
.status { display: inline-block; color: var(--ink-soft); font-size: 12px; font-weight: 850; }
.status-ready { color: var(--brand); }
.book-info h3, .compact-book h3 { margin: 8px 0 5px; font-size: 26px; line-height: 1.2; }
.book-info > div > p, .compact-book p { margin: 0; color: var(--ink-soft); font-size: 14px; }
.book-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 28px 0; }
.book-meta div { border-radius: var(--radius-control); padding: 12px; background: var(--surface-muted); }
.book-meta dt { color: var(--ink-soft); font-size: 11px; }
.book-meta dd { margin: 4px 0 0; font-size: 14px; font-weight: 850; }
.book-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: auto; }
.local-preview-note { margin: 12px 0 0; color: var(--ink-soft); font-size: 11px; }
.book-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.compact-book { display: grid; grid-template-columns: auto 1fr; gap: 14px; min-height: 214px; padding: 20px; }
.compact-book .button { grid-column: 1 / -1; align-self: end; }
.compact-book-wide { grid-column: 1 / -1; grid-template-columns: auto 1fr auto; min-height: 166px; }
.compact-book-wide .button { grid-column: auto; align-self: center; }
.level-number { display: grid; width: 52px; height: 66px; place-items: center; border-radius: 14px 14px 5px 5px; background: var(--brand-soft); color: var(--brand-deep); font-size: 26px; font-weight: 900; }
.compact-book:nth-child(2) .level-number, .compact-book:nth-child(5) .level-number { background: color-mix(in srgb, var(--accent) 24%, var(--surface)); }

.site-footer { display: flex; align-items: center; justify-content: space-between; gap: 40px; border-top: 1px solid var(--line); padding-block: 44px; }
.footer-copy strong { font-size: 19px; }
.footer-copy p { margin: 6px 0 0; color: var(--ink-soft); }
.contact-codes { display: flex; gap: 18px; }
.contact-codes figure { margin: 0; text-align: center; }
.contact-codes img { display: block; width: 92px; height: 92px; border-radius: var(--radius-control); object-fit: cover; box-shadow: var(--shadow); }
.contact-codes figcaption { margin-top: 7px; color: var(--ink-soft); font-size: 12px; font-weight: 800; }

.activation-dialog { width: min(92vw, 510px); max-height: min(88dvh, 680px); border: 1px solid var(--line); border-radius: var(--radius-card); padding: 0; background: var(--surface-strong); color: var(--ink); box-shadow: 0 34px 90px rgba(7, 29, 23, 0.28); }
.activation-dialog::backdrop { background: rgba(9, 30, 24, 0.65); backdrop-filter: blur(5px); }
.dialog-close-form { display: flex; justify-content: end; padding: 14px 16px 0; }
.dialog-close { border: 0; background: transparent; color: var(--ink-soft); font-size: 13px; font-weight: 800; cursor: pointer; }
.dialog-content { padding: 5px 34px 34px; }
.dialog-content h2 { margin: 0; font-size: 32px; letter-spacing: -0.03em; }
.dialog-content > p:not(.section-label) { margin: 10px 0 24px; color: var(--ink-soft); }

@media (prefers-color-scheme: dark) {
  :root { --bg: #101814; --surface: #151f1a; --surface-strong: #1b2822; --surface-muted: #223129; --ink: #e7f0eb; --ink-soft: #a8bab1; --line: #34473d; --brand: #63b995; --brand-deep: #28785c; --brand-soft: #234337; --accent: #e4ae49; --danger: #ed9d92; }
  .button-primary { color: #0e241b; }
  .auth-tab.is-active { box-shadow: none; }
  .preview-notice { background: rgba(228, 174, 73, 0.1); }
  .site-header { background: rgba(21, 31, 26, 0.92); }
}
@media (max-width: 1100px) {
  .auth-shell { grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr); }
  .auth-visual-copy h1 { font-size: clamp(38px, 5vw, 54px); }
  .book-layout { grid-template-columns: 1fr; }
  .book-card-featured { grid-template-columns: minmax(250px, 0.75fr) minmax(0, 1.25fr); }
}
@media (max-width: 767px) {
  .auth-shell { display: block; }
  .auth-visual { display: none; }
  .auth-panel { min-height: 100dvh; padding: 28px 20px 44px; place-items: start center; }
  .mobile-brand { display: flex; align-items: center; gap: 11px; margin-bottom: 40px; font-size: 15px; font-weight: 850; }
  .auth-heading h2 { font-size: 34px; }
  .auth-tabs { margin-top: 26px; }
  .header-inner, .library-main, .site-footer { width: min(100% - 28px, 1440px); }
  .header-inner { min-height: 66px; gap: 12px; }
  .site-brand > span:last-child { display: none; }
  .header-actions { gap: 8px; }
  .header-actions .text-button, .account-name { display: none; }
  .library-main { padding-block: 38px 64px; }
  .library-intro { display: grid; align-items: start; gap: 24px; }
  .library-intro .button { width: 100%; }
  .library-intro h1 { font-size: 40px; }
  .sync-banner { display: grid; margin-top: 28px; padding: 18px; }
  .sync-banner > span { white-space: normal; }
  .books-section { margin-top: 48px; }
  .section-heading { display: block; }
  .section-heading p { margin-top: 4px; }
  .book-card-featured { grid-template-columns: 1fr; }
  .book-cover { min-height: 300px; }
  .book-info { padding: 24px; }
  .book-meta { grid-template-columns: 1fr; }
  .book-actions { display: grid; }
  .book-grid { grid-template-columns: 1fr; }
  .compact-book, .compact-book-wide { grid-column: auto; grid-template-columns: auto 1fr; min-height: 190px; }
  .compact-book .button, .compact-book-wide .button { grid-column: 1 / -1; }
  .site-footer { display: grid; padding-block: 36px; }
  .contact-codes { width: 100%; justify-content: space-between; gap: 14px; }
  .contact-codes figure { flex: 1; }
  .contact-codes img { width: min(38vw, 150px); height: min(38vw, 150px); margin-inline: auto; }
  .dialog-content { padding: 2px 22px 26px; }
}
@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; }
}
