:root {
  --ink: #1c2026;
  --muted: #69717d;
  --line: #d9dee7;
  --paper: #f7f4ef;
  --surface: #ffffff;
  --accent: #197d72;
  --accent-dark: #105b54;
  --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,
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;
}

.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 a:hover,
.link-button:hover {
  color: var(--ink);
}

.link-button {
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-weight: 650;
}

.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;
}

.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;
}

.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 {
  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 {
  display: grid;
  gap: 1px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.16);
  border-color: rgba(255, 255, 255, 0.18);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
}

.metric {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 26px;
  background: rgba(255, 255, 255, 0.13);
}

.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 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;
}

.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-form {
  display: flex;
  gap: 10px;
  width: min(560px, 100%);
}

.asin-form input {
  min-width: 0;
  flex: 1 1 180px;
}

.asin-form select {
  min-width: 132px;
}

.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-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;
}

.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;
}

.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.active {
  border-color: #bfe4df;
  background: #f0faf8;
}

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

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

.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 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);
}

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

.doc-page {
  max-width: 820px;
  padding: 56px 0 80px;
}

.doc-page h1 {
  font-size: clamp(1.7rem, 2.4vw, 2.4rem);
  margin-bottom: 22px;
}

.doc-content {
  display: grid;
  gap: 16px;
  background: #fff;
  border: 1px solid rgba(28, 32, 38, 0.08);
  border-radius: 8px;
  padding: 28px;
}

.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;
}

.wide-panel {
  width: 100%;
}

.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: center;
  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: block;
  margin-bottom: 3px;
}

.quality-subtitle {
  display: block;
  margin-bottom: 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;
}

.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;
}

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

.chart-wrap svg {
  width: 100%;
  height: auto;
  overflow: visible;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.chart-axis {
  stroke: #c7ced9;
  stroke-width: 2;
}

.chart-line {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 4;
}

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

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

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

  nav {
    flex-wrap: wrap;
  }

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

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

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

  .asin-form {
    flex-direction: column;
  }

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

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

  .chart-legend {
    flex-direction: column;
  }

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

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

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

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

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