:root {
  --ink: #1c2026;
  --muted: #69717d;
  --line: #d9dee7;
  --paper: #f7f4ef;
  --surface: #ffffff;
  --accent: #58a6ff;
  --accent-dark: #1f6feb;
  --gold: #d99b35;
  --danger: #b42318;
  --shadow: 0 18px 45px rgba(28, 32, 38, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
input,
textarea,
select {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  min-height: 72px;
  padding: 0 32px;
  background: rgba(247, 244, 239, 0.92);
  border-bottom: 1px solid rgba(28, 32, 38, 0.08);
  backdrop-filter: blur(14px);
}

body:has(.hero) .topbar {
  background: rgba(15, 18, 22, 0.72);
  border-bottom-color: rgba(255, 255, 255, 0.14);
  color: #fff;
}

body:has(.hero) .brand-mark {
  background: #f2a33a;
  color: #17191d;
}

body:has(.hero) nav,
body:has(.hero) .link-button {
  color: rgba(255, 255, 255, 0.76);
}

body:has(.hero) nav a:hover,
body:has(.hero) .link-button:hover {
  color: #fff;
}

body:has(.hero) .share-menu-panel {
  background: rgba(16, 18, 22, 0.97);
  border-color: rgba(255, 255, 255, 0.14);
}

body:has(.hero) .share-menu-item {
  color: #fff;
}

body:has(.hero) .share-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
}

body:has(.hero) .share-menu-copy small,
body:has(.hero) .share-menu-caption {
  color: rgba(255, 255, 255, 0.68);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-weight: 800;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
}

nav {
  display: flex;
  align-items: center;
  gap: 18px;
  color: var(--muted);
  font-weight: 650;
}

nav details {
  position: relative;
}

nav a:hover,
.link-button:hover {
  color: var(--ink);
}

.link-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
}

.share-menu {
  display: inline-flex;
  align-items: center;
}

.share-menu-summary {
  list-style: none;
}

.share-menu-summary::-webkit-details-marker {
  display: none;
}

.share-menu-summary .icon-img {
  width: 18px;
  height: 18px;
}

.share-menu-panel {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  z-index: 20;
  display: grid;
  gap: 6px;
  width: 280px;
  padding: 12px;
  border: 1px solid rgba(28, 32, 38, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 28px 48px rgba(28, 32, 38, 0.16);
}

.share-menu-caption {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 650;
}

.share-menu-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  align-items: start;
  width: 100%;
  min-height: 46px;
  padding: 8px 10px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.share-menu-item:hover {
  border-color: rgba(28, 32, 38, 0.08);
  background: rgba(88, 166, 255, 0.06);
}

.share-menu-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.share-menu-copy strong,
.share-menu-copy small {
  display: block;
}

.share-menu-copy strong {
  font-size: 0.92rem;
}

.share-menu-copy small {
  color: var(--muted);
  font-size: 0.77rem;
  font-weight: 600;
}

.share-menu-item[data-share-facebook] .share-menu-icon {
  background: rgba(24, 119, 242, 0.12);
}

.share-menu-item[data-share-native] .share-menu-icon {
  background: rgba(239, 68, 68, 0.1);
}

.share-menu-item[data-share-mail] .share-menu-icon {
  background: rgba(31, 111, 235, 0.1);
}

.share-menu-item[data-share-copy] .share-menu-icon {
  background: rgba(217, 155, 53, 0.14);
}

.icon-nav {
  display: inline-grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
}

main {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

body:has(.hero) main {
  width: 100%;
}

.hero {
  position: relative;
  isolation: isolate;
  min-height: calc(100vh - 72px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.36fr);
  align-items: center;
  gap: 32px;
  padding: 56px max(32px, calc((100vw - 1180px) / 2)) 96px;
  overflow: hidden;
}

.hero::before {
  content: "";
  position: absolute;
  inset: -18px;
  z-index: -2;
  background: url("/public/images/kdp-hero-bg.png") center right / cover no-repeat;
  filter: blur(6px);
  transform: scale(1.03);
}

.hero::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(90deg, rgba(9, 12, 16, 0.9) 0%, rgba(16, 18, 22, 0.72) 42%, rgba(16, 18, 22, 0.28) 100%),
    radial-gradient(circle at 78% 24%, rgba(242, 163, 58, 0.28), transparent 32%),
    linear-gradient(180deg, rgba(0, 0, 0, 0.08), rgba(0, 0, 0, 0.48));
}

.hero-copy {
  max-width: 760px;
  display: grid;
  gap: 18px;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.4rem, 5vw, 5rem);
  line-height: 0.98;
  letter-spacing: 0;
}

.workspace-head h1,
.doc-page h1,
.auth-panel h1 {
  margin: 0;
  line-height: 1.12;
  letter-spacing: 0;
}

.auth-panel h1 {
  font-size: clamp(1.6rem, 2.4vw, 2.25rem);
}

.hero h1 {
  color: #fff;
  text-shadow: 0 18px 48px rgba(0, 0, 0, 0.38);
}

.lead {
  max-width: 680px;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1.65;
}

.hero .lead {
  max-width: 650px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 1.24rem;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

.hero .eyebrow {
  color: #f2a33a;
}

.actions,
.book-actions,
.plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.hero .actions {
  margin-top: 6px;
}

.hero .actions .button {
  min-width: 220px;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 750;
  white-space: nowrap;
}

.button.icon-only {
  width: 46px;
  min-width: 46px;
  padding: 0;
}

.button.compact.icon-only {
  width: 38px;
  min-width: 38px;
  padding: 0;
}

.icon-img {
  display: block;
  width: 20px;
  height: 20px;
}

.button.secondary .icon-img,
body:has(.hero) .button.ghost .icon-img,
body:has(.hero) .icon-nav .icon-img,
body:has(.hero) .share-menu-summary .icon-img {
  filter: invert(1);
}

.button.primary .icon-img {
  filter: invert(1);
}

.hero .button.primary .icon-img {
  filter: none;
}

.icon-nav .icon-img {
  opacity: 0.76;
}

.icon-nav:hover .icon-img {
  opacity: 1;
}

.button.primary {
  background: var(--accent);
  color: #fff;
}

.hero .button.primary {
  background: #f2a33a;
  color: #16191d;
}

.button.primary:hover {
  background: var(--accent-dark);
}

.hero .button.primary:hover {
  background: #ffc15f;
}

.button.secondary {
  background: var(--ink);
  color: #fff;
}

.hero .button.secondary {
  background: rgba(255, 255, 255, 0.13);
  border-color: rgba(255, 255, 255, 0.26);
  color: #fff;
  backdrop-filter: blur(10px);
}

.button.ghost {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.button.compact {
  min-height: 36px;
  padding: 0 12px;
  font-size: 0.9rem;
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.hero-panel,
.panel {
  background: var(--surface);
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.hero-panel {
  padding: 18px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.2);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
}

.hero-panel-card {
  display: grid;
  gap: 16px;
  padding: 24px;
  border-radius: 8px;
  background: rgba(11, 14, 18, 0.42);
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.hero-panel-label {
  margin: 0;
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.hero-benefits {
  display: grid;
  gap: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.hero-benefits li {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
  color: #fff;
  font-weight: 700;
  line-height: 1.4;
}

.hero-benefit-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-top: 2px;
}

.hero-benefit-icon .icon-img {
  width: 18px;
  height: 18px;
  filter: invert(63%) sepia(93%) saturate(584%) hue-rotate(349deg) brightness(101%) contrast(95%);
}

.metric span,
dt,
.muted {
  color: var(--muted);
}

.metric strong {
  color: var(--gold);
  font-size: 1.65rem;
}

.hero .metric span {
  color: rgba(255, 255, 255, 0.7);
}

.hero .metric strong {
  color: #ffc15f;
}

.band {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0 64px;
}

.feature-grid,
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.feature-grid article,
.empty,
.table-shell {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 8px;
  padding: 24px;
}

.feature-grid article {
  min-height: 100%;
}

.feature-grid h2,
.panel h2,
.doc-content h2 {
  margin: 0 0 10px;
  font-size: 1rem;
}

.feature-grid p,
.doc-content p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.auth-shell {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 72px);
}

.auth-panel,
.panel {
  width: min(520px, 100%);
  padding: 28px;
}

label {
  display: grid;
  gap: 8px;
  margin: 24px 0 16px;
  color: var(--muted);
  font-weight: 700;
}

[hidden],
.is-hidden {
  display: none !important;
}

input,
select,
textarea {
  min-height: 44px;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
}

textarea {
  min-height: 120px;
  padding: 12px;
  resize: vertical;
  line-height: 1.45;
}

.notice {
  background: #e9f6f4;
  border: 1px solid #bfe4df;
  border-radius: 8px;
  color: var(--accent-dark);
  padding: 12px;
}

.workspace-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 0 18px;
}

.admin-head {
  align-items: center;
}

.workspace-head h1 {
  font-size: clamp(1.55rem, 2.2vw, 2.25rem);
  line-height: 1.12;
}

.workspace-head .eyebrow {
  margin-bottom: 6px;
  font-size: 0.64rem;
}

.asin-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
}

.asin-dialog::backdrop {
  background: rgba(28, 32, 38, 0.46);
  backdrop-filter: blur(5px);
}

.asin-dialog-card {
  position: relative;
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 24px;
  border: 1px solid rgba(28, 32, 38, 0.1);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.asin-dialog-card h2 {
  margin: 0;
  padding-right: 40px;
  font-size: 1.1rem;
}

.asin-dialog-card label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.asin-dialog-error {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid rgba(184, 63, 63, 0.18);
  border-radius: 8px;
  background: rgba(184, 63, 63, 0.08);
  color: #9a2f2f;
  font-size: 0.88rem;
  line-height: 1.45;
}

.asin-dialog-card textarea {
  min-height: 120px;
}

.dialog-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.dialog-close:hover {
  color: var(--ink);
}

.marketplace-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: -4px 0 18px;
}

.marketplace-filter {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  font-size: 0.88rem;
  font-weight: 750;
}

.marketplace-filter.active,
.marketplace-filter:hover {
  border-color: rgba(25, 125, 114, 0.42);
  background: #edf7f5;
  color: var(--accent-dark);
}

.book-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(330px, 1fr));
  gap: 18px;
  padding-bottom: 64px;
}

.book-card {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 18px;
  background: #fff;
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 8px;
  padding: 16px;
  min-height: 260px;
}

.cover {
  display: grid;
  place-items: center;
  width: 112px;
  height: 168px;
  overflow: hidden;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.book-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.book-title-row {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 8px;
}

.book-card h2 {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.35;
}

.book-card p {
  margin: 6px 0 14px;
  color: var(--muted);
}

.book-card dl {
  margin-bottom: 16px;
}

.book-actions {
  align-items: center;
  justify-content: flex-end;
  margin-top: auto;
}

.book-actions-spacer {
  flex: 1 1 auto;
}

.book-job-status {
  margin: 10px 0 0;
  padding: 8px 10px;
  border: 1px solid rgba(25, 125, 114, 0.12);
  border-radius: 8px;
  background: rgba(25, 125, 114, 0.06);
  color: var(--accent-dark);
  font-size: 0.82rem;
  line-height: 1.4;
}

.book-job-status[data-busy="true"] {
  border-style: dashed;
}

.book-delete-action {
  position: absolute;
  left: 16px;
  bottom: 16px;
}

.quality-widget {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 24px;
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 750;
}

.quality-source-icon {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  border-radius: 5px;
  background: #edf6fd;
  color: #28658f;
}

.quality-source-icon .icon-img {
  width: 13px;
  height: 13px;
}

.quality-stars {
  display: inline-flex;
  gap: 1px;
  color: #c6ccd6;
  font-size: 0.94rem;
  line-height: 1;
}

.quality-stars .filled {
  color: var(--gold);
}

dl {
  display: grid;
  gap: 7px;
  margin: 0 0 14px;
}

dl div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

dt {
  font-size: 0.84rem;
}

dd {
  margin: 0;
  text-align: right;
  font-weight: 780;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

.book-actions .icon-button {
  width: 38px;
  height: 36px;
}

.icon-button .icon-img {
  width: 17px;
  height: 17px;
}

.icon-button.danger {
  border-color: #e6b8b2;
  background: #fff6f4;
  color: #9f2f25;
}

.icon-button.danger:hover {
  border-color: #d99b93;
  background: #ffefec;
  color: #84251d;
}

.ai-action {
  border-color: #bdd4e8;
  background: #edf6fd;
  color: #28658f;
}

.ai-action:hover {
  border-color: #9fc0dc;
  background: #e1f0fb;
  color: #1f5478;
}

.danger-button {
  background: var(--danger);
  color: #fff;
}

.danger-button:hover {
  background: #8f1d14;
}

.confirm-dialog {
  width: min(440px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
}

.confirm-dialog::backdrop {
  background: rgba(28, 32, 38, 0.46);
  backdrop-filter: blur(5px);
}

.confirm-card {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 24px;
  border: 1px solid rgba(28, 32, 38, 0.1);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}

.confirm-card h2 {
  margin: 0;
  font-size: 1.05rem;
}

.confirm-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
}

.confirm-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.toast-layer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 70;
  display: grid;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid rgba(28, 32, 38, 0.12);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: var(--shadow);
  opacity: 0;
  transform: translateY(12px);
  transition: opacity 180ms ease, transform 180ms ease;
  pointer-events: auto;
}

.toast.visible {
  opacity: 1;
  transform: translateY(0);
}

.toast-message {
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.4;
}

.upgrade-dialog {
  width: min(520px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
}

.upgrade-dialog::backdrop {
  background: rgba(28, 32, 38, 0.56);
  backdrop-filter: blur(6px);
}

.upgrade-card {
  position: relative;
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 28px;
  border: 1px solid rgba(25, 125, 114, 0.18);
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(28, 32, 38, 0.22);
}

.upgrade-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
  font-size: 1.35rem;
  line-height: 1;
}

.upgrade-close:hover {
  color: var(--ink);
}

.upgrade-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: #e9f6f4;
}

.upgrade-card h2 {
  max-width: 420px;
  margin: 0;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
  line-height: 1.12;
  letter-spacing: 0;
}

.upgrade-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.upgrade-price {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid #bfe4df;
  border-radius: 8px;
  background: #f0faf8;
}

.upgrade-price strong {
  color: var(--accent-dark);
  font-size: 2.25rem;
  line-height: 1;
}

.upgrade-price strong span {
  color: var(--muted);
  font-size: 0.98rem;
  font-weight: 800;
}

.upgrade-price small {
  max-width: 180px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.35;
  text-align: right;
}

.upgrade-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.profile-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding-bottom: 64px;
}

.profile-grid .panel {
  width: 100%;
}

.profile-head {
  padding-bottom: 18px;
}

.profile-head h1 {
  font-size: clamp(1.5rem, 2vw, 2rem);
}

.profile-email {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 700;
}

.subscription-panel {
  grid-column: 1 / -1;
}

.account-deletion-panel {
  grid-column: 1 / -1;
  border: 1px solid #f4b4ad;
  background: linear-gradient(180deg, #fff8f7 0%, #fff2f0 100%);
}

.account-deletion-panel h2 {
  color: var(--danger);
}

.account-deletion-panel .notice {
  margin-top: 12px;
}

.account-deletion-list {
  display: grid;
  gap: 8px;
  margin: 14px 0 0;
  padding-left: 18px;
  color: var(--danger);
  font-weight: 700;
}

.account-deletion-form {
  display: grid;
  gap: 16px;
  margin-top: 18px;
}

.account-deletion-confirm {
  margin-top: 0;
  color: var(--ink);
  font-weight: 700;
}

.account-deletion-confirm span {
  line-height: 1.45;
}

.plan-cards {
  display: grid;
  gap: 12px;
  margin-top: 14px;
}

.plan-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, auto);
  align-items: stretch;
  gap: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.plan-card.free-tier {
  border: 4px solid #bfe7b7;
  background: linear-gradient(180deg, #f4fbef 0%, #eff9e8 100%);
  box-shadow: 0 0 0 2px rgba(191, 231, 183, 0.25);
}

.plan-card.active {
  border-color: #bfe4df;
  background: #f0faf8;
}

.plan-card.locked {
  background: #f4f5f7;
}

.plan-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.plan-badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin: 8px 0 10px !important;
  padding: 0 12px;
  border-radius: 999px;
  background: #e7f8df;
  color: #2f6f2c !important;
  font-size: 0.84rem;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.plan-options {
  display: grid;
  justify-items: end;
  gap: 8px;
  min-width: 180px;
}

.plan-option {
  display: grid;
  grid-template-columns: minmax(70px, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.plan-option-static {
  align-items: center;
  grid-template-columns: minmax(70px, 1fr) auto;
}

.plan-option-static .plan-state {
  justify-self: end;
}

.plan-option strong {
  font-size: 0.98rem;
}

.plan-option strong span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.plan-requirement {
  margin-top: 8px !important;
  color: var(--accent-dark) !important;
  font-weight: 800;
}

.plan-state {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  margin-top: 10px !important;
  padding: 0 10px;
  border-radius: 999px;
  background: #e9f6f4;
  color: var(--accent-dark) !important;
  font-size: 0.84rem;
  font-weight: 800;
}

.profile-list {
  margin-top: 20px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  background: #e9f6f4;
  color: var(--accent-dark);
  font-weight: 800;
}

.danger-status {
  background: #fff1ef;
  color: var(--danger);
}

.busy-status {
  background: #fff4e1;
  color: #8a5a00;
}

.admin-plan-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scraper-table-shell code {
  display: inline-block;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.docs-page {
  display: grid;
  gap: 28px;
  padding: 42px 0 80px;
}

body:has(.docs-page) {
  background:
    radial-gradient(circle at top left, rgba(216, 228, 248, 0.92), transparent 34%),
    radial-gradient(circle at 86% 10%, rgba(242, 163, 58, 0.12), transparent 26%),
    linear-gradient(180deg, #f7f4ef 0%, #f8f6f1 100%);
}

.docs-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: 24px;
  align-items: stretch;
}

.docs-hero-copy {
  display: grid;
  gap: 18px;
  padding: 8px 0;
}

.docs-hero h1 {
  margin: 0;
  font-size: clamp(2.3rem, 4.8vw, 4.7rem);
  line-height: 0.96;
  letter-spacing: -0.03em;
  max-width: 12ch;
}

.docs-hero .lead {
  max-width: 66ch;
  margin: 0;
}

.docs-actions .button {
  min-width: 230px;
}

.docs-points {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  color: var(--muted);
  font-weight: 650;
}

.docs-points span {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.docs-point-icon {
  display: inline-flex;
  width: 18px;
  height: 18px;
}

.docs-point-icon .icon-img {
  width: 18px;
  height: 18px;
  filter: invert(63%) sepia(93%) saturate(584%) hue-rotate(349deg) brightness(101%) contrast(95%);
}

.docs-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(28, 32, 38, 0.16), transparent);
}

.docs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
}

.docs-card,
.docs-cta {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 20px;
  box-shadow: 0 16px 40px rgba(28, 32, 38, 0.08);
  backdrop-filter: blur(10px);
}

.docs-card {
  display: grid;
  gap: 16px;
  padding: 24px;
}

.docs-card-wide {
  grid-column: 1 / -1;
}

.docs-card-head {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.docs-card-icon {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(24, 28, 34, 0.95), rgba(24, 28, 34, 0.8));
}

.docs-card-icon .icon-img {
  width: 20px;
  height: 20px;
  filter: invert(1);
}

.docs-kicker {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 0.68rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.docs-card h2,
.docs-cta h2 {
  margin: 0;
  font-size: clamp(1.15rem, 1.55vw, 1.45rem);
  line-height: 1.15;
}

.docs-card p,
.docs-cta p {
  margin: 0;
  color: var(--muted);
  line-height: 1.75;
}

.signal-box {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 2px 0 0;
}

.signal-box div {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.92);
  color: var(--ink);
  font-weight: 650;
}

.signal-box span {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 999px;
  background: rgba(88, 166, 255, 0.12);
  color: var(--accent-dark);
  font-weight: 850;
  flex: 0 0 22px;
}

.docs-cta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 20px;
  align-items: center;
  padding: 28px;
}

.docs-cta-copy {
  display: grid;
  gap: 12px;
}

.docs-cta .docs-kicker {
  margin-bottom: 0;
}

.table-shell {
  overflow-x: auto;
  padding: 0;
  margin-bottom: 64px;
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  padding: 16px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

th {
  color: var(--muted);
  font-size: 0.82rem;
  text-transform: uppercase;
}

.inline-form {
  display: flex;
  gap: 8px;
}

.inline-form select {
  width: 120px;
}

.admin-panel {
  padding-bottom: 22px;
}

.admin-tabs-shell {
  display: grid;
  gap: 16px;
  margin-bottom: 64px;
}

.admin-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.admin-tab {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 750;
}

.admin-tab:hover {
  color: var(--ink);
}

.admin-tab.active,
.admin-tab[aria-selected="true"] {
  border-color: rgba(25, 125, 114, 0.16);
  background: #e9f6f4;
  color: var(--accent-dark);
  box-shadow: inset 0 0 0 1px rgba(25, 125, 114, 0.06);
}

.admin-panels {
  display: grid;
  gap: 18px;
}

.admin-panel[hidden] {
  display: none;
}

.admin-panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 14px;
}

.admin-panel-head h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.admin-panel-head p {
  margin: 0;
  max-width: 76ch;
}

.admin-search-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: end;
  padding: 16px;
  margin-bottom: 18px;
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.admin-search-bar label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 750;
}

.admin-search-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: end;
}

.admin-book-title {
  display: grid;
  gap: 4px;
}

.admin-book-link {
  font-weight: 750;
}

.wide-panel {
  width: 100%;
}

.log-viewer {
  max-height: 68vh;
  overflow: auto;
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 14px;
  background: linear-gradient(180deg, #fbfcfd 0%, #ffffff 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.68);
}

.log-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 16px;
  list-style: none;
}

.log-entry {
  display: grid;
  grid-template-columns: max-content max-content minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 12px;
  background: #fff;
}

.log-time {
  color: var(--muted);
  font-size: 0.84rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.log-level {
  min-height: 24px;
  font-size: 0.78rem;
  text-transform: uppercase;
}

.log-entry.log-warn .log-level {
  background: #fff4e1;
  color: #8a5a00;
}

.log-entry.log-error .log-level {
  background: #fff1ef;
  color: var(--danger);
}

.log-entry.log-info .log-level {
  background: #edf6fd;
  color: #28658f;
}

.log-entry.log-debug .log-level {
  background: #eef1f6;
  color: #4f5866;
}

.log-message {
  min-width: 0;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 1.45;
}

.log-entry.log-warn {
  border-color: rgba(217, 155, 53, 0.25);
  background: #fffaf1;
}

.log-entry.log-error {
  border-color: rgba(180, 35, 24, 0.22);
  background: #fff5f4;
}

.log-entry.log-info {
  border-color: rgba(88, 166, 255, 0.2);
  background: #f6fbff;
}

.log-entry.log-debug {
  background: #f8f9fb;
}

.log-empty {
  padding: 12px 2px;
}

.prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.prompt-card {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.prompt-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.prompt-head h3 {
  margin: 0;
  font-size: 1rem;
}

.danger-notice {
  border-color: #f4b4ad;
  background: #fff1ef;
  color: var(--danger);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.checkbox-row input {
  min-height: auto;
  width: auto;
}

.detail-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 22px;
  padding-bottom: 64px;
}

.detail-cover {
  display: grid;
  place-items: center;
  align-self: start;
  min-height: 330px;
  overflow: hidden;
  border: 1px solid transparent;
  border-radius: 0;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}

.detail-cover img {
  width: 100%;
  height: 100%;
  max-height: 330px;
  object-fit: contain;
}

.detail-main {
  display: grid;
  gap: 18px;
  min-width: 0;
}

.detail-stats,
.chart-panel,
.quality-panel {
  width: 100%;
}

.quality-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 22px;
  padding: 18px 22px;
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 8px;
  background: #fff;
}

.quality-summary h2 {
  margin: 0;
  font-size: 1.25rem;
}

.quality-summary .quality-stars {
  font-size: 1.05rem;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.quality-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.quality-item {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  align-items: start;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.quality-item.locked {
  background: #f4f5f7;
}

.quality-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: #e9f6f4;
}

.quality-item.locked .quality-icon {
  background: #e8ebef;
}

.quality-icon .icon-img {
  width: 18px;
  height: 18px;
}

.quality-item strong {
  display: inline;
  margin: 0;
}

.quality-subtitle {
  display: inline;
  margin-left: 6px;
  color: var(--ink);
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.4;
}

.quality-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
}

.markdown-report {
  display: block;
  margin-top: 10px;
  padding: 12px 14px;
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 10px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfcfd 100%);
  color: var(--muted);
  line-height: 1.45;
}

.markdown-report > * + * {
  margin-top: 4px;
}

.markdown-report h2,
.markdown-report h3,
.markdown-report h4 {
  display: inline;
  margin: 0;
  color: var(--ink);
  font-size: 0.9rem;
  line-height: 1.25;
  letter-spacing: -0.01em;
}

.markdown-report p,
.markdown-report ul,
.markdown-report ol {
  margin: 0;
}

.markdown-report p {
  display: inline;
  color: var(--muted);
}

.markdown-report ul,
.markdown-report ol {
  display: grid;
  gap: 2px;
  padding-left: 20px;
}

.markdown-report li + li {
  margin-top: 0;
}

.markdown-report li {
  margin: 0;
}

.markdown-report li::marker {
  color: var(--accent-dark);
}

.markdown-report code {
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(25, 125, 114, 0.08);
  color: var(--ink);
  font-size: 0.86em;
}

.markdown-report strong {
  color: var(--ink);
}

.markdown-report em {
  color: var(--accent-dark);
  font-style: normal;
}

.markdown-report blockquote {
  margin: 0;
  padding: 0 0 0 12px;
  border-left: 3px solid rgba(25, 125, 114, 0.22);
  color: var(--muted);
}

.markdown-report hr {
  width: 100%;
  height: 1px;
  margin: 2px 0;
  border: 0;
  background: linear-gradient(90deg, transparent, rgba(28, 32, 38, 0.16), transparent);
}

.quality-score {
  display: grid;
  gap: 2px;
  justify-items: end;
  font-weight: 850;
  white-space: nowrap;
}

.quality-score small {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.quality-item-side {
  display: grid;
  justify-items: end;
  align-content: start;
  gap: 8px;
}

.quality-item-action {
  margin: 0;
}

.chart-wrap {
  position: relative;
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.chart-stage {
  position: relative;
}

.chart-wrap svg {
  width: 100%;
  height: auto;
  overflow: visible;
  border: 1px solid rgba(84, 103, 128, 0.16);
  border-radius: 16px;
  background:
    radial-gradient(circle at top right, rgba(88, 166, 255, 0.1), transparent 38%),
    linear-gradient(180deg, #fbfdfc 0%, #f5f8fa 100%);
  box-shadow: 0 10px 28px rgba(25, 35, 46, 0.06);
}

.chart-bg {
  fill: transparent;
}

.chart-grid {
  stroke: rgba(103, 120, 142, 0.12);
  stroke-dasharray: 4 6;
  stroke-width: 1;
}

.chart-axis {
  stroke: rgba(103, 120, 142, 0.42);
  stroke-width: 2;
}

.chart-area {
  fill: url(#bsrArea);
}

.chart-line {
  fill: none;
  stroke: url(#bsrLine);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4.5;
  filter: drop-shadow(0 4px 6px rgba(31, 111, 235, 0.14));
}

.chart-hitbox {
  fill: transparent;
  cursor: crosshair;
  pointer-events: all;
}

.chart-hover-line {
  position: absolute;
  top: 0;
  width: 0;
  border-left: 2px solid rgba(31, 111, 235, 0.95);
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
  pointer-events: none;
  z-index: 2;
}

.chart-tooltip {
  position: absolute;
  top: 12px;
  transform: translateX(-50%);
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(241, 246, 255, 0.96);
  color: #1f6feb;
  border: 1px solid rgba(31, 111, 235, 0.18);
  box-shadow: 0 10px 24px rgba(25, 35, 46, 0.12);
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  white-space: nowrap;
  pointer-events: none;
  z-index: 3;
}

.chart-legend {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-size: 0.86rem;
}

.chart-empty {
  margin-top: 16px;
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
    padding: 16px;
  }

  nav {
    flex-wrap: wrap;
  }

  .share-menu-panel {
    position: static;
    width: min(100%, 340px);
    margin-top: 10px;
  }

  .hero,
  .feature-grid,
  .docs-hero,
  .docs-grid,
  .profile-grid,
  .detail-layout {
    grid-template-columns: 1fr;
  }

  .hero {
    min-height: auto;
    padding: 56px 16px 72px;
  }

  .hero .actions .button {
    width: 100%;
    min-width: 0;
  }

  .docs-actions .button {
    width: 100%;
    min-width: 0;
  }

  .workspace-head {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-search-bar {
    grid-template-columns: 1fr;
  }

  .admin-search-actions {
    justify-content: flex-start;
  }

  .book-card {
    grid-template-columns: 88px minmax(0, 1fr);
  }

  .cover {
    width: 88px;
    height: 132px;
  }

  .chart-legend {
    align-items: flex-start;
    flex-direction: column;
  }

  .plan-card {
    grid-template-columns: 1fr;
  }

  .prompt-grid {
    grid-template-columns: 1fr;
  }

  .log-entry {
    grid-template-columns: 1fr;
  }

  .quality-summary {
    align-items: flex-start;
    flex-direction: column;
  }

  .quality-item {
    grid-template-columns: 34px minmax(0, 1fr);
  }

  .quality-item-side {
    grid-column: 2;
    justify-items: start;
  }

  .quality-score {
    justify-items: start;
  }

  .docs-page {
    padding: 28px 0 64px;
  }

  .docs-hero {
    gap: 18px;
  }

  .docs-hero h1 {
    max-width: none;
  }

  .signal-box {
    grid-template-columns: 1fr;
  }

  .docs-cta {
    grid-template-columns: 1fr;
  }
}
