.auth-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(360px, 0.72fr);
}

.auth-visual {
  position: relative;
  padding: 52px;
  display: flex;
  align-items: center;
  overflow: hidden;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand-lockup h1,
.boot-screen h1 { margin: 0 0 4px; font-size: 46px; letter-spacing: 0; }
.brand-lockup p,
.boot-screen p { margin: 0; color: var(--muted); font-size: 18px; }

.floating-note {
  position: absolute;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  animation: floaty 4s ease-in-out infinite;
}
.note-a { right: 17%; top: 24%; }
.note-b { left: 17%; bottom: 22%; animation-delay: 500ms; }
.note-c { right: 22%; bottom: 32%; animation-delay: 1s; }

@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.auth-card {
  margin: auto;
  width: min(440px, calc(100% - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 28px;
}

.auth-card h2 { margin: 22px 0 6px; font-size: 28px; }
.login-badge {
  width: max-content;
  border-radius: 999px;
  padding: 7px 12px;
  background: #e5f2ef;
  color: #0f665a;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 5px;
}
.tabs button {
  min-height: 38px;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  font-weight: 800;
}
.tabs button.active { background: #fff; color: var(--ink); box-shadow: 0 4px 14px rgba(34, 58, 54, 0.08); }
.form-stack { display: grid; gap: 16px; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.brand-row {
  display: flex;
  gap: 12px;
  align-items: center;
}
.brand-row strong { display: block; }
.brand-row span { color: var(--muted); font-size: 13px; }

.sidebar nav {
  display: grid;
  gap: 8px;
}
.sidebar nav button {
  min-height: 44px;
  border-radius: 8px;
  padding: 0 14px;
  background: transparent;
  color: #364e4a;
  text-align: left;
  font-weight: 800;
}
.sidebar nav button.active,
.sidebar nav button:hover { background: #e7f3f0; color: #0e665a; }

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 10px;
}
.sidebar-footer p { margin: 0; font-weight: 800; overflow-wrap: anywhere; }

.workspace {
  min-width: 0;
  padding: 24px;
}

.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}
.topbar h1 { margin: 0 0 4px; font-size: 30px; }
.topbar p { margin: 0; color: var(--muted); }
.app-warning { margin-bottom: 16px; }

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}
.span-2 { grid-column: span 2; }

.action-hero,
.metric-card,
.list-panel,
.settings-panel,
.resume-card,
.pending-card,
.wizard-panel,
.preview-shell {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 8px 28px rgba(30, 54, 50, 0.07);
}

.action-hero {
  min-height: 178px;
  padding: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  overflow: hidden;
}
.action-hero h2 { margin: 0 0 8px; font-size: 28px; }
.action-hero p { margin: 0; color: var(--muted); max-width: 620px; }

.metric-card {
  min-height: 130px;
  padding: 22px;
  display: grid;
  align-content: center;
  gap: 8px;
}
.metric-card span { color: var(--muted); font-weight: 800; }
.metric-card strong { font-size: 42px; }

.list-panel,
.settings-panel {
  padding: 22px;
}
.list-panel h2,
.list-panel h3,
.settings-panel h2 { margin: 0 0 16px; }

.book-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 13px 0;
  border-top: 1px solid var(--line);
}
.book-row:first-of-type { border-top: 0; }
.book-row strong { display: block; overflow-wrap: anywhere; }
.book-row p { margin: 3px 0 0; color: var(--muted); overflow-wrap: anywhere; }

.status-pill {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 0 10px;
  background: #edf2f1;
  color: #47615d;
  font-size: 12px;
  font-weight: 900;
  text-transform: capitalize;
}
.status-pill.admin,
.status-pill.submitted,
.status-pill.active,
.status-pill.completed { background: #dff4ec; color: #0f755c; }
.status-pill.draft,
.status-pill.pending,
.status-pill.in_review { background: #fff2cf; color: #7b5d05; }
.status-pill.uploaded { background: #e5ecff; color: #2f55a1; }
.status-pill.inactive,
.status-pill.blocked { background: #f1eeee; color: #7b5757; }

.resume-card {
  padding: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.inline-actions {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.resume-card p { margin: 4px 0 0; color: var(--muted); }

.page-stack { display: grid; gap: 16px; }

.section-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.section-head h2 { margin: 0 0 6px; }
.section-head p { margin: 0; color: var(--muted); }

.category-panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 8px 28px rgba(30, 54, 50, 0.07);
}
.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}
.category-card {
  min-height: 190px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(180deg, #ffffff, #f6fbfa);
  padding: 18px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  transition: transform 160ms ease, box-shadow 160ms ease;
}
.category-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 34px rgba(31, 55, 51, 0.1);
}
.category-card button { grid-column: 1 / -1; justify-self: start; }
.category-card h3 { margin: 0 0 8px; }
.category-card p { margin: 0; color: var(--muted); line-height: 1.55; }
.category-icon {
  width: 54px;
  height: 54px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, #11806f, #2f66d0);
}

.wizard-full {
  max-width: 1180px;
  margin: 0 auto;
  display: grid;
  gap: 18px;
}

.wizard-panel {
  padding: 20px;
  display: grid;
  gap: 16px;
}
.pro-panel {
  min-height: calc(100vh - 132px);
}
.wizard-head {
  display: flex;
  gap: 12px;
  align-items: center;
}
.wizard-head h2 { margin: 0 0 4px; }
.wizard-head p { margin: 0; color: var(--muted); }

.stepper {
  display: grid;
  grid-template-columns: repeat(10, minmax(28px, 1fr));
  gap: 6px;
}
.stepper button {
  aspect-ratio: 1;
  border-radius: 8px;
  background: #edf2f1;
  color: #5d716e;
  font-weight: 900;
}
.stepper button.active { background: #11806f; color: #fff; }
.stepper button.done { background: #d9eee8; color: #0f665a; }
.process-wrap {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbfa;
}
.process-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  font-size: 13px;
  color: #405956;
}
.process-track {
  height: 7px;
  border-radius: 999px;
  background: #dfece9;
  overflow: hidden;
}
.process-fill {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #11806f, #2f66d0);
  transition: width 220ms ease;
}
.save-note {
  width: max-content;
  max-width: 100%;
  border-radius: 999px;
  padding: 6px 11px;
  background: #e5f2ef;
  color: #0f665a;
  font-size: 12px;
  font-weight: 900;
}
.step-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.step-title span { color: var(--brand); font-weight: 800; }

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

.topic-title-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.topic-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}
.topic-tabs button {
  min-width: 74px;
  min-height: 38px;
  border-radius: 8px;
  background: #edf2f1;
  color: #4f6460;
  font-weight: 900;
}
.topic-tabs button.active { background: #172927; color: #fff; }

.editor-wrap {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.editor-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px;
  background: #f3f7f6;
  border-bottom: 1px solid var(--line);
}
.editor-toolbar button,
.editor-toolbar select,
.editor-toolbar input[type="color"] {
  width: auto;
  min-height: 34px;
  border-radius: 7px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 0 10px;
  font-weight: 800;
}
.editor-toolbar input[type="color"] { width: 42px; padding: 4px; }
.rich-editor {
  min-height: 420px;
  max-height: 68vh;
  padding: 16px;
  outline: none;
  line-height: 1.7;
  overflow: auto;
  resize: vertical;
}
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: #90a09d;
}

.upload-box {
  min-height: 260px;
  border: 1px dashed #aac8c2;
  border-radius: 8px;
  background: #f7fbfa;
  padding: 18px;
  display: grid;
  gap: 12px;
  place-items: center;
  text-align: center;
}
.upload-box img {
  max-height: 260px;
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.preview-shell {
  padding: 14px;
  max-height: calc(100vh - 126px);
  overflow: auto;
}
.final-preview-step {
  display: grid;
  gap: 16px;
}
.success-screen {
  min-height: 520px;
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 16px;
  text-align: center;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.94), rgba(245,251,249,.94)),
    radial-gradient(circle at 50% 16%, rgba(17,128,111,.12), transparent 32%);
  border: 1px solid var(--line);
  padding: 28px;
}
.success-check {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #11806f;
  color: white;
  font-size: 36px;
  font-weight: 900;
  animation: popIn 360ms ease both;
}
.success-screen h3 { margin: 0; font-size: 28px; }
.success-screen p { margin: 0; color: var(--muted); }
.book-cover-mini,
.book-cover-thumb {
  width: 126px;
  aspect-ratio: 5 / 8;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: linear-gradient(145deg, #effaf7, #e6edff);
  box-shadow: 0 14px 34px rgba(31, 55, 51, 0.13);
  overflow: hidden;
  color: #12312f;
  font-weight: 900;
  padding: 10px;
}
.book-cover-mini img,
.book-cover-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}
.book-cover-thumb.large { width: 168px; }
.share-link-box.compact {
  width: min(640px, 100%);
  grid-template-columns: minmax(0, 1fr) auto;
}
@keyframes popIn {
  from { opacity: 0; transform: scale(.88); }
  to { opacity: 1; transform: scale(1); }
}
.final-preview {
  max-height: none;
  padding: 10px;
}
.admin-bottom-preview {
  margin-top: 0;
}
.share-link-box {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f5faf9;
}
.ebook-preview {
  background: #e8eceb;
  display: grid;
  gap: 14px;
  padding: 12px;
}
.preview-cover,
.preview-page {
  min-height: 720px;
  background: #fff;
  padding: 58px;
  border-radius: 4px;
  box-shadow: 0 8px 24px rgba(29, 43, 41, 0.08);
}
.preview-cover {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.preview-cover img {
  width: min(280px, 68%);
  margin: 0 auto 28px;
  border-radius: 4px;
}
.preview-cover h1 {
  text-align: center;
  font-size: 44px;
  margin: 0 0 14px;
}
.preview-cover h2 {
  text-align: center;
  color: var(--muted);
  margin: 0 0 30px;
}
.preview-block { margin-top: 28px; }
.preview-block h3 { margin-bottom: 8px; }
.copyright-line { margin-top: 46px; color: #445b57; }
.contents-page ol { line-height: 2; font-size: 18px; }
.chapter-kicker {
  text-align: center;
  color: var(--brand);
  font-weight: 900;
  text-transform: uppercase;
}
.preview-page h2 {
  text-align: center;
  font-size: 34px;
  margin: 8px 0 36px;
}
.chapter-content { font-family: Georgia, "Times New Roman", serif; line-height: 1.72; font-size: 18px; }
.chapter-content p:first-of-type::first-letter {
  float: left;
  font-size: 3.4em;
  line-height: 0.86;
  padding: 0.08em 0.12em 0 0;
  color: #12312f;
  font-weight: 900;
}

.link-page {
  min-height: 100vh;
  padding: 22px;
}
.link-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin: 0 auto 18px;
  max-width: 1180px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 8px 28px rgba(30, 54, 50, 0.07);
}
.link-toolbar h1 { margin: 0 0 4px; }
.link-toolbar p { margin: 0; color: var(--muted); }
.link-preview {
  max-width: 980px;
  max-height: none;
  margin: 0 auto;
}
.selling-admin-box {
  max-width: 980px;
  margin: 0 auto 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffdf5;
}
.selling-admin-box p {
  margin: 8px 0 0;
  color: #4f5d59;
  line-height: 1.6;
}

.admin-list-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 16px;
}
.admin-list-head h2,
.admin-list-head p { margin: 0; }
.admin-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.admin-filters select { width: min(260px, 100%); }
.admin-books-table {
  display: grid;
  gap: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}
.admin-books-row {
  display: grid;
  grid-template-columns: 28px minmax(180px, 1.5fr) minmax(130px, .8fr) minmax(120px, .8fr) minmax(130px, .8fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border-top: 1px solid var(--line);
}
.admin-books-row:first-child { border-top: 0; }
.admin-books-row.table-head {
  background: #f3f7f6;
  color: #415956;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.admin-books-row input[type="checkbox"] {
  width: 18px;
  height: 18px;
  padding: 0;
}
.admin-books-row select { min-width: 126px; padding: 9px 10px; }
.admin-books-row p { margin: 3px 0 0; color: var(--muted); overflow-wrap: anywhere; }
.admin-books-row small { display: block; color: var(--muted); overflow-wrap: anywhere; margin-top: 3px; }
.admin-book-brief,
.admin-link-format {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 18px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #f9fcfb;
}
.admin-link-format {
  max-width: 980px;
  margin: 0 auto 14px;
  background: rgba(255, 255, 255, 0.92);
}
.admin-copy-stack {
  display: grid;
  gap: 12px;
}
.copy-field {
  display: grid;
  gap: 6px;
}
.copy-field > span {
  color: #405956;
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}
.copy-field > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}
.selling-details {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fffdf5;
}
.selling-details summary {
  cursor: pointer;
  font-weight: 900;
}
.selling-copy-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: start;
  margin-top: 12px;
}

.admin-topic-list {
  display: grid;
  gap: 10px;
}
.admin-topic-list details {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
}
.admin-topic-list summary {
  cursor: pointer;
  font-weight: 900;
  margin-bottom: 10px;
}

.pending-card {
  width: min(480px, 100%);
  padding: 30px;
  display: grid;
  justify-items: center;
  gap: 12px;
  text-align: center;
}
.pending-card h1 { margin: 10px 0 0; }
.pending-card p { margin: 0; color: var(--muted); }

@media (max-width: 980px) {
  .auth-page,
  .app-shell,
  .wizard-full { max-width: 100%; }
  .auth-visual {
    min-height: 260px;
    padding: 30px;
  }
  .auth-card { margin: 0 auto 28px; }
  .sidebar {
    position: static;
    height: auto;
  }
  .workspace { padding: 16px; }
  .dashboard-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .preview-shell { max-height: none; }
}

@media (max-width: 680px) {
  .topbar,
  .action-hero,
  .resume-card {
    align-items: stretch;
    flex-direction: column;
  }
  .topic-title-grid { grid-template-columns: 1fr; }
  .category-grid { grid-template-columns: 1fr; }
  .share-link-box { grid-template-columns: 1fr; }
  .link-toolbar { align-items: stretch; flex-direction: column; }
  .book-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .admin-list-head,
  .admin-book-brief,
  .admin-link-format,
  .selling-copy-row {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .admin-list-head { display: grid; }
  .admin-books-row {
    grid-template-columns: 24px 1fr;
  }
  .admin-books-row > *:nth-child(n+3) {
    grid-column: 2;
  }
  .preview-cover,
  .preview-page {
    min-height: 560px;
    padding: 28px;
  }
  .preview-cover h1 { font-size: 32px; }
  .stepper { grid-template-columns: repeat(5, 1fr); }
  .brand-lockup h1,
  .boot-screen h1 { font-size: 34px; }
  .floating-note { display: none; }
}

@media print {
  body { background: #fff; }
  .sidebar,
  .topbar,
  .link-toolbar,
  .wizard-panel,
  .admin-actions,
  .selling-admin-box {
    display: none !important;
  }
  .preview-shell,
  .link-preview {
    box-shadow: none;
    border: 0;
    padding: 0;
    max-height: none;
  }
  .ebook-preview {
    background: #fff;
    padding: 0;
  }
  .preview-cover,
  .preview-page {
    box-shadow: none;
    page-break-after: always;
  }
}
