/* Bookology Writer App */

:root{
  --bkw-teal:#1abc9c;
  --bkw-orange:#ff6b3d;
  --bkw-navy:#2c3e50;
  --bkw-bg:#f6f8fb;
  --bkw-card:#ffffff;
  --bkw-border:rgba(0,0,0,0.08);
  --bkw-shadow:0 10px 28px rgba(16,24,40,0.10);
  --bkw-shadow-soft:0 6px 16px rgba(16,24,40,0.08);
  --bkw-header-h:74px;
}

.bkw-app {
  min-height: 600px;
  background: transparent;
  border-radius: 18px;
  padding: 0;
  box-shadow: none;
  overflow: visible;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

.bkw-loading {
  padding: 30px;
  text-align: center;
  color: #444;
}

.bkw-notice {
  padding: 12px 16px;
  border-radius: 10px;
  margin: 10px 0;
}
.bkw-notice--warn {
  background: #fff7e6;
  border: 1px solid #ffd591;
  color: #614700;
}

/* Layout */
.bkw-shell {
  display: flex;
  flex-direction: column;
  min-height: 600px;
  position: relative;
  padding-top: calc(var(--bkw-header-h) - 12px);
}

.bkw-shell__body {
  display: flex;
  align-items: flex-start;
}

.bkw-app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 18px;
  background: transparent;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  box-sizing: border-box;
  z-index: 1100;
  transition: transform 220ms ease, opacity 220ms ease;
  will-change: transform;
}
.bkw-app-header.is-hidden {
  transform: translateY(calc(-100% - 8px));
  opacity: 0;
  pointer-events: none;
}
body.admin-bar .bkw-app-header { top: 32px; }
@media (max-width: 782px){ body.admin-bar .bkw-app-header { top: 46px; } }

.bkw-app-header__brand {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
}

.bkw-app-header__logo {
  display: block;
  width: auto !important;
  height: auto !important;
  max-height: 50px !important;
  max-width: min(32vw, 520px) !important;
  object-fit: contain;
}
.bkw-app-header__brand{ max-height: 50px; }

.bkw-app-header__wordmark {
  font-size: 32px;
  font-weight: 800;
  color: var(--bkw-navy);
}

.bkw-app-header__right {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

.bkw-header-auth-btn,
.bkw-header-menu__toggle {
  border: none;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.bkw-header-auth-btn {
  background: var(--bkw-orange);
  color: #fff !important;
  box-shadow: var(--bkw-shadow-soft);
  text-decoration: none !important;
}
.bkw-header-auth-btn span{ color:#fff !important; text-decoration:none !important; }
.bkw-header-auth-btn i{ color:#fff !important; font-size:14px; }
.bkw-header-auth-btn:hover { transform: translateY(-1px); }

.bkw-header-menu { position: relative; }
.bkw-header-menu__toggle {
  background: rgba(255,255,255,0.75);
  color: var(--bkw-navy);
  border: 1px solid var(--bkw-border);
  box-shadow: var(--bkw-shadow-soft);
  text-decoration:none !important;
}
.bkw-header-menu__avatar { font-size: 16px; line-height: 1; }
.bkw-header-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 180px;
  background: #fff;
  border: 1px solid var(--bkw-border);
  border-radius: 14px;
  box-shadow: var(--bkw-shadow);
  padding: 8px;
  display: none;
}
.bkw-header-menu.is-open .bkw-header-menu__panel { display: block; }
.bkw-header-menu__panel button {
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--bkw-navy);
  font-weight: 600;
  cursor: pointer;
}
.bkw-header-menu__panel button:hover { background: rgba(26,188,156,0.08); }

.bkw-nav {
  width: 74px;
  background: var(--bkw-navy);
  padding: 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
  border-radius: 16px;
  box-shadow: var(--bkw-shadow-soft);
  position: fixed;
  left: 20px;
  top: calc(var(--bkw-header-h) + 36px);
  z-index: 999;
}

/* Nav groups */
.bkw-nav-primary{
  display:flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}
.bkw-nav-context{ display:none; }

.bkw-nav a {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  text-decoration: none;
  color: #ecf0f1;
  background: rgba(255,255,255,0.08);
  transition: transform 0.15s ease, background 0.15s ease;
}

.bkw-nav a:hover {
  transform: scale(1.06);
  background: rgba(255,255,255,0.15);
}

.bkw-nav a.active {
  background: var(--bkw-teal);
  color: #fff;
}

.bkw-main {
  flex: 1;
  padding: 22px;
  margin-left: 120px;
  background: var(--bkw-card);
  border-radius: 18px;
  border: 1px solid var(--bkw-border);
  box-shadow: var(--bkw-shadow);
  min-height: 600px;
}

.bkw-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.bkw-shell--guest{
  min-height:auto;
}

.bkw-shell--guest .bkw-main{
  margin-left:0;
  padding:0;
  background:transparent;
  border:none;
  box-shadow:none;
  min-height:auto;
}

.bkw-shell--guest .bkw-view{
  padding:0;
}

@media (max-width: 768px) {
  :root{ --bkw-header-h: 58px; }
  .bkw-app-header {
    padding: 8px 10px 6px;
  }
  .bkw-shell {
    padding-top: calc(var(--bkw-header-h) - 12px);
  }
  .bkw-app-header__logo {
    max-height: 35px !important;
    max-width: 168px !important;
  }
  .bkw-app-header__right { gap: 8px; }
  .bkw-header-auth-btn,
  .bkw-header-menu__toggle {
    min-height: 38px;
    padding: 0 14px;
    font-size: 14px;
  }
  .bkw-header-menu__label { display: none; }
  .bkw-shell__body { display:block; }
  .bkw-shell--guest {
    min-height: auto;
  }
  .bkw-shell--guest .bkw-main {
    margin-left: 0;
    padding: 14px 2px 16px;
    padding-bottom: 16px;
    width: 100%;
    box-sizing: border-box;
  }
  .bkw-shell--guest .bkw-view {
    width: 100%;
  }
  .bkw-shell--guest .bkw-prompt-view,
  .bkw-shell--guest .bkw-concept-view {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    box-sizing: border-box;
  }
  .bkw-shell--guest .bkw-prompt-hero,
  .bkw-shell--guest .bkw-concept-card {
    width: 100%;
    padding: 14px 12px 12px;
    border-radius: 18px;
    box-sizing: border-box;
  }
  .bkw-shell--guest .bkw-prompt-title {
    margin-top: 0;
    font-size: clamp(16px, 5.6vw, 22px);
    line-height: 1.06;
    letter-spacing: -0.02em;
  }
  .bkw-shell--guest .bkw-prompt-copy {
    font-size: 13px;
    line-height: 1.35;
    margin-bottom: 10px;
    max-width: 26ch;
  }
  .bkw-shell--guest .bkw-prompt-input {
    min-height: 84px;
    padding: 11px 12px;
    border-radius: 14px;
  }
  .bkw-shell--guest .bkw-prompt-examples {
    gap: 8px;
  }
  .bkw-shell--guest .bkw-chip {
    padding: 9px 11px;
    font-size: 11px;
  }
  .bkw-shell--guest .bkw-prompt-form .bkw-row--between{
    margin-top: 10px !important;
    align-items: stretch !important;
  }
  .bkw-shell--guest .bkw-prompt-cta{
    width: 100%;
    justify-content: center;
  }
  }



/* v1.9.5: Desktop unified chapter toolbar */
.bkw-topbar--chapter .bkw-topbar-leftcluster{
  display:flex;
  align-items:center;
  gap:12px;
}

/* v2.0.5: Prev/Next chapter controls */
.bkw-chapter-nav{ display:flex; align-items:center; gap:4px; }

.bkw-topbar--chapter .bkw-topbar-meta{ display:flex; flex-direction:column; gap:2px; }
.bkw-topbar--chapter .bkw-topbar-meta-title{
  font-weight:700;
  color: var(--bkw-navy);
  line-height:1.1;
}
.bkw-topbar--chapter .bkw-topbar-meta-sub{ font-size:13px; line-height:1.1; }

.bkw-iconbtn{
  width:44px;
  height:44px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  padding:0;
  border-radius:999px;
}

.bkw-iconbtn:disabled{ opacity:.45; }

/* Desktop layout: true centered title with left/right clusters */
@media (min-width: 769px){
  .bkw-topbar--chapter{
    display:grid;
    grid-template-columns: auto 1fr auto;
    align-items:center;
    gap:16px;
  }

  /* Spec: ensure true-center alignment using .bkw-toolbar--chapter as well */
  .bkw-toolbar--chapter{
    display:grid;
    grid-template-columns: auto 1fr auto;
    align-items:center;
    gap:16px;
  }
  .bkw-toolbar--chapter .bkw-toolbar__left{ display:flex; align-items:center; gap:12px; min-width:0; }
  .bkw-toolbar--chapter .bkw-toolbar__center{ justify-self:center; text-align:center; }
  .bkw-toolbar--chapter .bkw-toolbar__right{ justify-self:end; display:flex; align-items:center; gap:10px; }

  .bkw-topbar--chapter .bkw-topbar-title{
    justify-self:center;
    text-align:center;
  }
  .bkw-topbar--chapter .bkw-topbar-actions{
    justify-self:end;
    display:flex;
    align-items:center;
    gap:10px;
  }
  /* Remove ⋯ menu on desktop */
  .bkw-topbar--chapter [data-open-actions]{ display:none !important; }

  /* Draft toolbar becomes part of topbar on desktop */
  .bkw-chapter-view .bkw-draft-toolbar{ display:none !important; }

  /* Show delete icon button on desktop */
  .bkw-topbar--chapter [data-delete-chapter]{ display:inline-flex !important; }
}

/* Mobile: keep compact actions inside Draft panel toolbar; hide big buttons in topbar */
@media (max-width: 768px){
  .bkw-topbar--chapter .bkw-topbar-meta{ display:none; }
  .bkw-topbar--chapter [data-draft-generate],
  .bkw-topbar--chapter [data-draft-save],
  .bkw-topbar--chapter [data-delete-chapter]{ display:none !important; }

  /* New chapter becomes icon-only on mobile */
  .bkw-topbar--chapter [data-new-chapter]{
    width:44px;
    height:44px;
    padding:0;
    border-radius:999px;
    display:inline-flex;
    align-items:center;
    justify-content:center;
  }
  .bkw-topbar--chapter [data-new-chapter] .bkw-btn__label{ display:none; }

  /* Slightly tighter prev/next controls on mobile */
  .bkw-chapter-nav{ gap:2px; }
}

.bkw-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--bkw-navy);
}

.bkw-subtitle {
  font-size: 13px;
  color: #667;
}

.bkw-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* Shown only on mobile for compact toolbars */
.bkw-actions-mobile{ display:none; }

.bkw-btn {
  border: none;
  background: var(--bkw-teal);
  color: #fff;
  border-radius: 999px;
  padding: 10px 14px;
  cursor: pointer;
  font-weight: 600;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.bkw-btn:hover { filter: brightness(0.95); }

.bkw-btn:hover { transform: translateY(-1px); }
.bkw-btn:disabled { opacity: 0.55; cursor: not-allowed; }

.bkw-btn.secondary {
  background: #34495e;
}

.bkw-btn.danger {
  background: #e74c3c;
}

.bkw-btn.bkw-btn-ghost,
.bkw-btn-ghost{
  background: rgba(44,62,80,0.08);
  color: var(--bkw-navy);
  border: 1px solid rgba(44,62,80,0.12);
}
.bkw-btn.bkw-btn-ghost:hover,
.bkw-btn-ghost:hover{ transform: translateY(-1px); }

.bkw-btn.bkw-btn-xs{ padding: 6px 10px; font-size: 12px; }

.bkw-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
}

/* v1.6.7: Book cover grid (My Books) */
.bkw-bookgrid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
@media (max-width: 560px){
  .bkw-bookgrid{ grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 12px; }
}

.bkw-booktile{
  display:block;
  text-decoration:none;
  color: inherit;
  cursor: pointer;
}
.bkw-booktile:focus-visible{
  outline: 2px solid var(--bkw-teal);
  outline-offset: 4px;
  border-radius: 16px;
}

.bkw-bookcover{
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow:hidden;
  border: 1px solid var(--bkw-border);
  background: #eef1f6;
  box-shadow: var(--bkw-shadow-soft);
}
.bkw-bookcover img{ width:100%; height:100%; object-fit: cover; display:block; }
.bkw-bookcover-placeholder{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 44px;
  color: rgba(0,0,0,0.35);
}
@media (max-width: 560px){
  .bkw-bookcover-placeholder{ font-size: 36px; }
}

.bkw-booktitle{
  margin-top: 8px;
  font-weight: 800;
  font-size: 13px;
  text-align: center;
  color: rgba(0,0,0,0.82);
  line-height: 1.25;
}
.bkw-bookmeta{
  margin-top: 2px;
  font-size: 12px;
  text-align: center;
  color: rgba(0,0,0,0.58);
}

/* v1.6.7: Book cover editor (Book → Pack) */
.bkw-cover-editor{
  display:grid;
  grid-template-columns: minmax(300px, 1.05fr) minmax(280px, 1fr);
  gap: 14px;
  align-items:start;
}
@media (max-width: 760px){
  .bkw-cover-editor{ grid-template-columns: 1fr; }
}
.bkw-cover-preview{
  width: 100%;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  overflow:hidden;
  border: 1px solid var(--bkw-border);
  background: #eef1f6;
  box-shadow: var(--bkw-shadow-soft);
}
.bkw-cover-preview img{ width:100%; height:100%; object-fit: cover; display:block; }
.bkw-cover-preview .bkw-bookcover-placeholder{ font-size: 48px; }

/* v1.5.9: Compact thumbnail grids for Characters / Locations / Items */
.bkw-thumbgrid{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 14px;
}
@media (max-width: 560px){
  .bkw-thumbgrid{
    grid-template-columns: repeat(auto-fill, minmax(92px, 1fr));
    gap: 10px;
  }
}

.bkw-thumbtile{
  display:block;
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
  cursor: pointer;
  text-align: center;
  color: inherit;
}
.bkw-thumbtile:focus-visible{
  outline: 2px solid var(--bkw-teal);
  outline-offset: 3px;
  border-radius: 12px;
}

.bkw-thumb{
  width: 108px;
  height: 108px;
  margin: 0 auto;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--bkw-border);
  background: #eef1f6;
  box-shadow: var(--bkw-shadow-soft);
}
@media (max-width: 560px){
  .bkw-thumb{ width: 92px; height: 92px; }
}
.bkw-thumb img{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display:block;
}
.bkw-thumb-placeholder{
  width: 100%;
  height: 100%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 34px;
  color: rgba(0,0,0,0.35);
}
@media (max-width: 560px){
  .bkw-thumb-placeholder{ font-size: 28px; }
}

.bkw-thumbname{
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.2;
  font-weight: 600;
  color: rgba(0,0,0,0.78);
  text-align: center;
  word-break: break-word;
}

.bkw-prompt-section{
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--bkw-border);
  border-radius: 14px;
  background: var(--bkw-card);
  box-shadow: var(--bkw-shadow-soft);
}
.bkw-prompt-actions{
  display:flex;
  gap: 10px;
  margin-top: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* v1.5.9: Centered modal */
html.bkw-modal-open,
body.bkw-modal-open{ overflow: hidden; }

.bkw-modal-overlay{
  position: fixed;
  inset: 0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:
    calc(16px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left));
  background: rgba(0,0,0,0.45);
  z-index: 99999;
}

.bkw-modal{
  width: min(760px, 100%);
  max-height: 90vh;
  overflow: hidden;
  display:flex;
  flex-direction: column;
  background: var(--bkw-card);
  border: 1px solid var(--bkw-border);
  border-radius: 16px;
  box-shadow: var(--bkw-shadow);
}
@media (max-width: 560px){
  .bkw-modal{ max-height: 94vh; border-radius: 14px; }
}

.bkw-modal-header{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--bkw-border);
}
.bkw-modal-title{
  font-size: 14px;
  font-weight: 800;
}
.bkw-modal-x{
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 10px;
  font-size: 22px;
  line-height: 1;
}
.bkw-modal-body{
  padding: 14px;
  overflow: auto;
}
.bkw-modal-footer{
  padding: 12px 14px;
  border-top: 1px solid var(--bkw-border);
  background: #fafbfe;
  display:flex;
  gap: 10px;
  justify-content:flex-end;
  flex-wrap: wrap;
}

.bkw-entity-modal-layout{
  display:grid;
  grid-template-columns: 1fr 240px;
  gap: 14px;
}
@media (max-width: 760px){
  .bkw-entity-modal-layout{ grid-template-columns: 1fr; }
}

.bkw-image-preview{
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 10px;
  overflow:hidden;
  border: 1px solid var(--bkw-border);
  background: #eef1f6;
}
.bkw-image-preview img{
  width:100%;
  height:100%;
  object-fit: cover;
  display:block;
}

.bkw-statusline{
  margin-top: 8px;
  font-size: 12px;
  color: rgba(0,0,0,0.65);
}

.bkw-inline-spinner{
  display:inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,.16);
  border-top-color: rgba(0,0,0,.55);
  animation: bkwspin .9s linear infinite;
  vertical-align: -2px;
  margin-right: 6px;
}

.bkw-card {
  background: #fff;
  border-radius: 14px;
  padding: 14px;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 4px 10px rgba(0,0,0,0.06);
}

.bkw-card h3 {
  margin: 0 0 6px 0;
  font-size: 16px;
  color: #2c3e50;
}

.bkw-card p {
  margin: 0;
  color: #556;
  font-size: 13px;
}

.bkw-form {
  display: grid;
  gap: 10px;
  margin: 12px 0;
}

.bkw-form input[type="text"],
.bkw-form input[type="number"],
.bkw-form textarea {
  width: 100%;
  border: 1px solid #d7dee8;
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fbfcff;
}

.bkw-form input[type="text"]:focus,
.bkw-form input[type="number"]:focus,
.bkw-form textarea:focus,
.bkw-input:focus,
.bkw-textarea:focus,
.bkw-select:focus{
  outline: none;
  border-color: var(--bkw-teal);
  box-shadow: 0 0 0 4px rgba(26,188,156,0.18);
  background: #fff;
}

.bkw-form textarea {
  min-height: 110px;
  resize: vertical;
}

.bkw-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin: 12px 0;
}

.bkw-tab {
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(44,62,80,0.08);
  color: #2c3e50;
  cursor: pointer;
  font-weight: 700;
  font-size: 13px;
}

.bkw-tab.active {
  background: var(--bkw-teal);
  color: #fff;
}

/* Mobile: bottom nav */


/* Desktop contextual nav: show chapter/book context rail, hide primary */
.bkw-nav[data-navmode="primary"] .bkw-nav-primary{ display:flex; }
.bkw-nav[data-navmode="primary"] .bkw-nav-context{ display:none; }

.bkw-nav[data-navmode="book"] .bkw-nav-primary,
.bkw-nav[data-navmode="chapter"] .bkw-nav-primary{ display:none; }

.bkw-nav[data-navmode="book"] .bkw-nav-context,
.bkw-nav[data-navmode="chapter"] .bkw-nav-context{
  display:flex;
  flex-direction: column;
  gap: 10px;
  align-items: center;
}

/* Review mode: hide app nav entirely */
.bkw-nav[data-navmode="review"]{
  display:none !important;
}

/* Public review page layout */
.bkw-review{
  width:100%;
}
.bkw-review-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:14px 16px;
  border-bottom:1px solid rgba(0,0,0,.08);
  background:#fff;
  position:sticky;
  top:0;
  z-index:10;
}
.bkw-review-title{
  font-weight:700;
  font-size:16px;
}
.bkw-review-sub{
  font-size:12px;
  opacity:.7;
  margin-top:2px;
}
.bkw-review-body{
  padding:16px;
}
.bkw-review-draft{
  background:#fff;
  border:1px solid rgba(0,0,0,.1);
  border-radius:12px;
  padding:16px;
  min-height:240px;
  max-width: 860px;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.7;
  white-space: pre-wrap;
  outline:none;
}

/* Make HTML paragraphs look like the main editor too */
.bkw-review-draft p{ margin: 0 0 1em; }
.bkw-review-draft p:last-child{ margin-bottom: 0; }
.bkw-review-sugg{
  border:1px solid rgba(0,0,0,.08);
  background:#fff;
  border-radius:12px;
  padding:12px;
  margin-top:10px;
}
.bkw-review-sugg-sel{
  font-weight:600;
}
.bkw-review-sugg-com{
  margin-top:8px;
}

.bkw-review-help-grid{
  margin-top:16px;
}
.bkw-review-help-card{
  max-width:860px;
  margin:0 auto;
}
.bkw-review-guidance-chips{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:12px;
}
.bkw-review-guidance-chips .bkw-chip.active{
  background:var(--bkw-green);
  color:#fff;
  border-color:transparent;
}
.bkw-review-guidance-output{
  margin-top:12px;
  background:#fff;
  border:1px solid rgba(0,0,0,.08);
  border-radius:12px;
  padding:12px 14px;
}
.bkw-review-guidance-output__title{
  font-weight:700;
  margin-bottom:6px;
}
.bkw-review-guidance-output__list{
  margin:0;
  padding-left:18px;
}
.bkw-review-guidance-output__list li + li{
  margin-top:6px;
}
.bkw-feedback-assist-help{
  margin-top:8px;
  font-size:12px;
  color:var(--bkw-muted);
}
.bkw-feedback-assist-actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
  margin-top:10px;
}
.bkw-review-conversion{
  max-width:860px;
  margin:16px auto 0;
}
.bkw-review-conversion-copy{
  margin-top:8px;
  color:var(--bkw-text);
}

/* Chapter view: pills removed on desktop (nav is canonical) */
@media (min-width: 769px){
  .bkw-chapter-view .bkw-tabs{ display:none !important; }
}

/* Loader (skeleton + shimmer) */
.bkw-loader-wrap{ position: relative; }
.bkw-loader{
  /* Full-screen loading screen so it always looks right on mobile (even without viewport meta) */
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(2px);
}
.bkw-loader[hidden]{ display:none !important; }

.bkw-loader-card{
  width: min(560px, 100%);
  background: #fff;
  border: 1px solid var(--bkw-border);
  border-radius: 16px;
  box-shadow: var(--bkw-shadow);
  padding: 18px 16px;
}

.bkw-loader-head{
  display:flex;
  align-items:center;
  gap: 12px;
  margin-bottom: 14px;
}

.bkw-loader-title{ font-weight: 800; color: var(--bkw-navy); font-size: 16px; line-height: 1.1; }
.bkw-loader-sub{ color: rgba(0,0,0,0.62); font-size: 13px; margin-top: 2px; }

.bkw-loader-spinner{
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,0.14);
  border-top-color: var(--bkw-teal);
  animation: bkwSpin 0.9s linear infinite;
}

@keyframes bkwSpin{
  to{ transform: rotate(360deg); }
}

.bkw-skel{ width: 100%; }
.bkw-skel-line{
  height: 14px;
  border-radius: 10px;
  margin: 10px 0;
  background: linear-gradient(90deg, rgba(0,0,0,0.06) 0%, rgba(0,0,0,0.12) 50%, rgba(0,0,0,0.06) 100%);
  background-size: 220% 100%;
  animation: bkwShimmer 1.2s ease-in-out infinite;
}
.bkw-skel-line.w-50{ width: 50%; }
.bkw-skel-line.w-60{ width: 60%; }
.bkw-skel-line.w-70{ width: 70%; }
.bkw-skel-line.w-80{ width: 80%; }

@keyframes bkwShimmer{
  0%{ background-position: 200% 0; }
  100%{ background-position: -200% 0; }
}

.bkw-loader-error{
  width: 100%;
  text-align: center;
}
.bkw-loader-error-title{
  font-weight: 700;
  margin-bottom: 6px;
}


@media (max-width: 768px){
  .bkw-shell{ flex-direction: column; }
  /* Make the app full-bleed on mobile (no "card" shadowed container) */
  .bkw-app{ border-radius: 0; }
  .bkw-nav{
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 68px;
    border-radius: 0;
    flex-direction: row;
    justify-content: space-around;
    padding: 8px 10px;
    box-shadow: 0 -6px 18px rgba(16,24,40,0.12);
  }
  .bkw-nav-primary,
  .bkw-nav-context{
    display:flex;
    flex:1;
    justify-content: space-around;
    align-items:center;
    gap: 8px;
    flex-direction: row;
    flex-wrap: nowrap;
  }

  /* Override higher-specificity desktop context rule that sets column layout */
  .bkw-nav[data-navmode="book"] .bkw-nav-context,
  .bkw-nav[data-navmode="chapter"] .bkw-nav-context{
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
  }
  /* Contextual nav: show primary on library/wizard/profile; show context in book/chapter */
  .bkw-nav[data-navmode="primary"] .bkw-nav-context{ display:none; }
  .bkw-nav[data-navmode="primary"] .bkw-nav-primary{ display:flex; }
  .bkw-nav[data-navmode="book"] .bkw-nav-primary,
  .bkw-nav[data-navmode="chapter"] .bkw-nav-primary{ display:none; }
  .bkw-nav[data-navmode="book"] .bkw-nav-context,
  .bkw-nav[data-navmode="chapter"] .bkw-nav-context{ display:flex; }

  /* Mobile bottom nav: stack icon over label */
  .bkw-nav a{
    width: auto;
    height: auto;
    flex: 1;
    background: transparent;
    display:flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px 4px;
  }
  .bkw-nav-ico{ font-size: 20px; }
  .bkw-nav-lbl{ display:block; font-size: 11px; opacity: 0.95; }
  .bkw-nav-lbl{ white-space: nowrap; }
  .bkw-nav a{ min-width: 0; }

  .bkw-main{
    margin-left: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    width: 100vw;
    height: calc(100dvh - 68px);
    min-height: 0;
    overflow: hidden;
    padding: 0;
  }
  .bkw-view{
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 10px 12px;
    padding-bottom: calc(86px + env(safe-area-inset-bottom, 0));
    min-height: 0;
  }


  /* Library topbar: only show Trash on mobile (Upload/New move to bottom nav) */
  .bkw-actions [data-go-import],
  .bkw-actions [data-go-wizard]{ display:none !important; }
  .bkw-trash-btn{ padding: 8px 10px; }
  .bkw-trash-btn .bkw-label{ display:none; } /* icon-only on mobile */
  /* Hide pill-tabs on mobile; bottom nav replaces them */
  .bkw-tabs{ display:none !important; }
}

/* iOS/Safari (and some WP admin contexts) may omit a viewport meta tag, causing max-width media queries
   to miss. Use device-width as a fallback so Book tabs collapse into the tools menu on phones. */
@media (max-device-width: 768px){
  .bkw-tabs{ display:none !important; }
  /* Fallback for missing viewport meta: force bottom nav layout */
  .bkw-shell{ flex-direction: column; }
  .bkw-app{ border-radius: 0; }
  .bkw-nav{
    position: fixed;
    top: auto;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    height: 68px;
    border-radius: 0;
    flex-direction: row;
    justify-content: space-around;
    padding: 8px 10px;
    box-shadow: 0 -6px 18px rgba(16,24,40,0.12);
  }
  .bkw-nav-primary,
  .bkw-nav-context{
    display:flex;
    flex:1;
    justify-content: space-around;
    align-items:center;
    gap: 8px;
    flex-direction: row;
    flex-wrap: nowrap;
  }

  /* Override higher-specificity desktop context rule that sets column layout */
  .bkw-nav[data-navmode="book"] .bkw-nav-context,
  .bkw-nav[data-navmode="chapter"] .bkw-nav-context{
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 8px;
  }
  .bkw-nav a{
    width: auto;
    height: auto;
    flex: 1;
    background: transparent;
    display:flex;
    flex-direction: column;
    gap: 3px;
    padding: 6px 4px;
    min-width: 0;
  }
  .bkw-nav-ico{ font-size: 20px; }
  .bkw-nav-lbl{ display:block; font-size: 11px; opacity: 0.95; white-space: nowrap; }

  .bkw-book-topbar{ align-items:center; gap:8px; }
  .bkw-book-topbar .bkw-actions-desktop{ display:none !important; }
  .bkw-book-topbar .bkw-actions-mobile{ display:flex; align-items:center; }
}

/* Mobile: ensure inner "views" can scroll inside flex containers */
@media (max-width: 768px){
  .bkw-shell{ height: 100dvh; min-height: 100dvh; }
  .bkw-screen{ max-width: 100%; }
  /* Common flex children that need min-height:0 for iOS scrolling */
  .bkw-view,
  .bkw-panel,
  .bkw-page,
  .bkw-content,
  .bkw-screen{
    min-height: 0;
  }
}

/* Mobile: Chapter toolbar + full-width editor */
@media (max-width: 768px){
  /* Ensure chapter screen is truly full-bleed */
  .bkw-screen{ max-width: none; margin: 0; }
  .bkw-view{ padding-left: 10px; padding-right: 10px; }

  .bkw-ch-topbar{ align-items:center; gap:8px; }
  .bkw-ch-topbar .bkw-actions-desktop{ display:none !important; }
  .bkw-ch-topbar .bkw-actions-mobile{ display:flex; align-items:center; }

  /* Make draft/editor area use full width */
  .bkw-draft-split{ flex-direction: column; gap: 10px; }
  .bkw-draft-editorwrap{ width: 100%; }
  .bkw-feedback-panel:not(.is-open){ display:none !important; }

  textarea.bkw-draft{
    width: 100% !important;
    max-width: 100% !important;
    min-height: 64vh;
    padding: 12px 12px;
    box-sizing: border-box;
  }
}

/* Mobile: chapter editor sizing */
@media (max-width: 768px){
  #bkw-draft{
    width: 100%;
    min-height: 58vh;
    padding-left: 10px;
    padding-right: 10px;
  }
}

/* === App-shell screens (v1.0.4) === */
.bkw-screen { width: 100%; max-width: 1100px; margin: 0 auto; }
.bkw-header h2 { margin: 0 0 6px 0; color: #2c3e50; }
.bkw-muted { color: #667; font-size: 13px; }
.bkw-label { display:block; font-weight: 700; margin: 10px 0 6px; color:#2c3e50; }
.bkw-input,
.bkw-textarea { width:100%; border:1px solid #d8dde6; border-radius:10px; padding:10px 12px; font-size:14px; background:#fff; }
.bkw-textarea { resize: vertical; }

.bkw-input, .bkw-select {
  width: 100%;
  border: 1px solid #d8dde6;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fff;
}

.bkw-field { margin: 12px 0; }
.bkw-field > label { display:block; font-weight:700; color:#2c3e50; margin-bottom:6px; font-size:13px; }

.bkw-grid-2 { display:grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 768px){
  .bkw-grid-2 { grid-template-columns: 1fr; }
}

.bkw-checkgrid { display:grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 8px; }
@media (max-width: 768px){
  .bkw-checkgrid { grid-template-columns: 1fr; }
}

.bkw-check { display:flex; gap:8px; align-items:center; font-size:13px; color:#233; }
.bkw-row { display:flex; gap:10px; align-items:center; flex-wrap:wrap; margin-top:10px; }
.bkw-row--between { justify-content: space-between; }
.bkw-check { font-size: 13px; color:#2c3e50; display:flex; gap:8px; align-items:center; }
.bkw-pre { background:#0b1020; color:#e7e9ff; padding:12px; border-radius:10px; overflow:auto; font-size:12px; }
.bkw-btn--primary { background:#1abc9c; }

.bkw-editor {
  min-height: 380px;
}

.bkw-editor textarea {
  min-height: 380px;
  font-family: Georgia, serif;
  font-size: 16px;
  line-height: 1.7;
}

/* Mobile: chapter draft textarea should be wider with more usable height */
@media (max-width: 768px){
  .bkw-editor{ min-height: auto; }
  .bkw-editor textarea,
  textarea.bkw-textarea{
    width: 100%;
    min-height: 58vh;
    padding: 12px 12px;
    border-radius: 14px;
  }
}

.bkw-meta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  color: #556;
  font-size: 13px;
  margin-top: 8px;
}

.bkw-divider {
  height: 1px;
  background: rgba(0,0,0,0.08);
  margin: 14px 0;
}

/* Selection toolbar */
.bkw-selection-bar {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(12px + env(safe-area-inset-bottom, 0));
  display: none;
  gap: 8px;
  background: #2c3e50;
  padding: 10px;
  border-radius: 12px;
  z-index: 99999;
  box-shadow: 0 10px 28px rgba(0,0,0,0.25);
}

.bkw-selection-bar button {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 2px solid #1abc9c;
  background: transparent;
  color: #ecf0f1;
  cursor: pointer;
  font-weight: 800;
}

.bkw-selection-bar button:hover {
  background: #1abc9c;
  color: #fff;
}

/* Modal */
.bkw-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100000;
  padding: 12px;
}

.bkw-modal {
  background: #fff;
  width: 100%;
  max-width: 920px;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 14px 40px rgba(0,0,0,0.25);
}

.bkw-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  background: #f3f5f7;
}

.bkw-modal-header h3 {
  margin: 0;
  font-size: 14px;
  color: #2c3e50;
}

.bkw-modal-body {
  padding: 14px;
}

.bkw-modal-body pre {
  white-space: pre-wrap;
  background: #fbfbfb;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 12px;
  padding: 12px;
  max-height: 50vh;
  overflow: auto;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 13px;
}

.bkw-modal-footer {
  padding: 12px 14px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  background: #f3f5f7;
}

/* Awards overlay */
.bkw-award-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 110000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.bkw-award-modal {
  background: #fffef0;
  border: 3px solid gold;
  border-radius: 20px;
  padding: 2rem 1.5rem;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 0 30px gold;
  position: relative;
  animation: bkwAwardPop 0.6s ease-out;
}

@keyframes bkwAwardPop {
  0% { transform: scale(0.85); opacity: 0; }
  80% { transform: scale(1.05); opacity: 1; }
  100% { transform: scale(1); }
}

.bkw-award-modal h2 {
  margin: 0 0 12px 0;
}

.bkw-award-modal button {
  margin-top: 14px;
  padding: 0.75rem 1.1rem;
  border: none;
  border-radius: 12px;
  background: gold;
  color: #000;
  font-weight: 800;
  cursor: pointer;
}

/* Mobile */
@media (max-width: 768px) {
  .bkw-app {
    border-radius: 0;
    box-shadow: none;
    min-height: 100dvh;
    height: 100dvh;
  }

  .bkw-shell { flex-direction: column; min-height: 100vh; }

  /* Lock nav to bottom for maximum editing space */
  .bkw-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 9990;
    width: 100%;
    flex-direction: row;
    justify-content: space-around;
    padding-bottom: env(safe-area-inset-bottom, 0);
    border-radius: 0;
  }

  .bkw-main {
    padding: 12px;
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0));
  }

  /* Mobile scrolling fixes: allow inner view to scroll within 100dvh app */
  .bkw-shell-app{
    height: 100dvh;
    min-height: 100dvh;
  }
  .bkw-main{
    min-height: 0;
  }
  .bkw-view{
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* Modal becomes a bottom sheet on mobile */
@media (max-width: 768px) {
  .bkw-modal-overlay {
    align-items: flex-end;
  }
  .bkw-modal {
    width: 100%;
    height: 78dvh;
    max-width: none;
    border-radius: 16px 16px 0 0;
  }
  .bkw-modal-body {
    overflow: auto;
  }
}

/* Wizard (mobile-first full-screen) */
.bkw-wiz-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10050;
  padding: 16px;
}

.bkw-wiz-card {
  background: #fff;
  width: 100%;
  max-width: 720px;
  height: 100%;
  max-height: 920px;
  border-radius: 16px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.bkw-wiz-header{
  margin-bottom: 12px;
  padding: 12px 14px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(16,24,40,0.08);
}


.bkw-wiz-body {
  padding: 16px;
  overflow: auto;
}

.bkw-wiz-footer {
  padding: 14px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  background: #f5f7fa;
}

.bkw-wiz-sub {
  margin: 6px 0 14px 0;
  color: #556;
}

.bkw-wiz-h3 {
  margin: 0;
  font-size: 14px;
}

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

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

@media (max-width: 768px) {
  .bkw-wiz-overlay { padding: 0; }
  .bkw-wiz-card { max-width: none; max-height: none; border-radius: 0; }
  .bkw-grid-3 { grid-template-columns: 1fr; }
}



/* === v1.0.3 App Shell + Modular UI === */
.bkw-shell-app{
  display:flex;
  flex-direction:column;
  min-height:600px;
}
.bkw-view{
  flex:1;
  overflow:auto;
  padding-bottom:72px; /* space for bottom nav */
}
.bkw-nav-bottom{
  position: sticky;
  bottom: 0;
  display:flex;
  gap:10px;
  padding:10px;
  background:#2c3e50;
  justify-content:space-around;
  align-items:center;
  z-index:50;
}
.bkw-nav-item{
  color:#ecf0f1;
  text-decoration:none;
  font-size:14px;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  padding:8px 10px;
  border-radius:10px;
}
.bkw-nav-item span{ font-size:12px; opacity:0.9; }
.bkw-nav-item.active, .bkw-nav-item:hover{
  background:#1abc9c;
  transform: translateY(-1px);
}

@media (max-width: 768px){
  .bkw-app{ border-radius:0; }
  .bkw-shell-app{ min-height: 100dvh; }
  .bkw-view{ padding-bottom: calc(72px + env(safe-area-inset-bottom, 0)); }
  .bkw-nav-bottom{
    position: fixed;
    left:0; right:0;
    bottom:0;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0));
  }
}

/* Wizard */
.bkw-wizard{
  padding: 18px;
  width: min(760px, 100%);
  margin: 0 auto;
}

.bkw-wiz-header{
  margin-bottom: 12px;
}

.bkw-wiz-progress{
  height: 10px;
  background: rgba(0,0,0,0.06);
  border-radius: 999px;
  overflow: hidden;
}

.bkw-wiz-progress-fill{
  height: 100%;
  width: 0;
  background: var(--bkw-teal);
  border-radius: 999px;
  transition: width .25s ease;
}

.bkw-wiz-steps{
  display:flex;
  gap: 24px;
  align-items: center;
  margin-top: 10px;
  overflow-x: auto;
  padding-bottom: 6px;
}

.bkw-wiz-chip{
  position: relative;
  white-space: nowrap;
  border: 1px solid rgba(52,64,84,0.18);
  background: #f6f7fb;
  color: #344054;
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.bkw-wiz-chip:not(:last-child)::after{
  content:"";
  position:absolute;
  /* connector line between step chips */
  right: -24px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 2px;
  background: rgba(52,64,84,0.28);
  border-radius: 2px;
  pointer-events: none;
}

.bkw-wiz-chip.done{
  border-color: rgba(26,188,156,0.35);
  background: rgba(26,188,156,0.10);
  color: #0f766e;
}

.bkw-wiz-chip.active{
  border-color: rgba(26,188,156,0.85);
  background: rgba(26,188,156,0.95);
  color: #ffffff;
}

.bkw-wiz-chip:disabled{
  opacity: 0.45;
  cursor: default;
}

/* Wizard card + form improvements (scoped) */
.bkw-wizard .bkw-card{
  border-radius: 18px;
  padding: 18px;
  border: 1px solid rgba(0,0,0,0.06);
  box-shadow: 0 10px 28px rgba(16,24,40,0.10);
}

.bkw-wizard .bkw-card h3{
  font-size: 18px;
  margin-bottom: 8px;
}

.bkw-wizard .bkw-note{
  color: rgba(0,0,0,0.62);
}

.bkw-wizard .bkw-form-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.bkw-wizard .bkw-form-row{
  display:flex;
  flex-direction:column;
  gap: 6px;
  margin-top: 10px;
}

.bkw-wizard .bkw-form-row label{
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.2px;
  color: rgba(0,0,0,0.78);
}

.bkw-wizard input[type="text"],
.bkw-wizard input[type="number"],
.bkw-wizard select,
.bkw-wizard textarea{
  width: 100%;
  border: 1px solid rgba(20, 28, 40, 0.14);
  border-radius: 14px;
  padding: 10px 12px;
  font-size: 14px;
  background: #fbfcff;
}

.bkw-wizard textarea{ resize: vertical; }

.bkw-wizard input[disabled]{
  background: rgba(0,0,0,0.03);
  color: rgba(0,0,0,0.55);
}

.bkw-wizard-nav{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  margin-top:14px;
}

.bkw-wizard-nav .bkw-btn{
  padding: 10px 14px;
  border-radius: 12px;
}

@media (max-width: 768px){
  .bkw-wizard{ padding: 14px; }
  .bkw-wizard .bkw-form-grid{ grid-template-columns: 1fr; }
  .bkw-wiz-chip{ padding: 7px 10px; }
}

.bkw-wizard-note{ margin-top:10px; color:#666; font-size:13px; }

/* Toasts */
.bkw-toast{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(90px + env(safe-area-inset-bottom, 0));
  background: #111;
  color:#fff;
  padding:10px 14px;
  border-radius: 999px;
  opacity:0;
  transition: opacity .2s ease, transform .2s ease;
  z-index: 99999;
  font-size: 14px;
}
.bkw-toast.show{ opacity:0.95; transform: translateX(-50%) translateY(-4px); }
.bkw-toast-success{ background:#1b7f5a; }
.bkw-toast-error{ background:#a02828; }

/* Progress overlay (long-running tasks) */
.bkw-progress-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99997;
  display:flex;
  align-items:center;
  justify-content:center;
  padding: 16px;
}
.bkw-progress-card{
  width: min(520px, 100%);
  background:#fff;
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  display:flex;
  flex-direction:column;
  gap: 10px;
}
.bkw-progress-title{ font-weight:700; font-size:16px; }
.bkw-progress-message{ font-size:14px; color:#333; line-height:1.35; }
.bkw-progress-spinner{
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,.12);
  border-top-color: rgba(0,0,0,.55);
  animation: bkwspin .9s linear infinite;
}
@keyframes bkwspin{ to{ transform: rotate(360deg); } }
.bkw-progress-bar{
  height: 10px;
  background: rgba(0,0,0,.08);
  border-radius: 999px;
  overflow:hidden;
}
.bkw-progress-bar-fill{
  height: 100%;
  width: 0%;
  background: #1abc9c;
  transition: width .25s ease;
}
.bkw-progress-percent{ font-size:12px; color:#666; }

/* Bottom sheet */
.bkw-sheet-overlay{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  z-index: 99998;
  display:flex;
  align-items:flex-end;
  justify-content:center;
  padding: 12px;
}
.bkw-sheet{
  width: min(900px, 100%);
  background:#fff;
  border-radius: 16px;
  overflow:hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.bkw-sheet-header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  padding:12px 14px;
  border-bottom:1px solid #eee;
}
.bkw-sheet-title{ font-weight:700; }
.bkw-sheet-close{
  border:none;
  background:transparent;
  font-size: 26px;
  line-height: 1;
  cursor:pointer;
}
.bkw-sheet-body{ padding: 12px 14px; max-height: 70vh; overflow:auto; }
.bkw-sheet-footer{
  display:flex;
  gap:10px;
  justify-content:flex-end;
  padding:12px 14px;
  border-top:1px solid #eee;
}

/* Selection bar */
.bkw-selectionbar{
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(82px + env(safe-area-inset-bottom, 0));
  background:#2c3e50;
  padding:8px;
  border-radius: 12px;
  display:flex;
  gap:8px;
  z-index: 99997;
}
.bkw-iconbtn{
  border: 1px solid #1abc9c;
  background: transparent;
  color: #ecf0f1;
  padding: 10px 12px;
  border-radius: 10px;
  cursor:pointer;
  font-size: 16px;
}
.bkw-iconbtn:hover{ background:#1abc9c; color:#fff; transform: scale(1.05); }

.bkw-selected-preview{
  background:#f5f7fa;
  border:1px solid #e6e9ef;
  padding:10px;
  border-radius:10px;
  white-space:pre-wrap;
  max-height: 160px;
  overflow:auto;
}

/* Characters */
.bkw-character-card{display:flex;align-items:center;gap:12px;}
.bkw-character-card h3{margin:0;flex:1;font-size:16px;}
.bkw-character-card .bkw-btn{margin-left:auto;}
.bkw-character-thumb{width:56px;height:56px;border-radius:12px;overflow:hidden;background:#f3f3f3;display:flex;align-items:center;justify-content:center;flex:0 0 56px;}
.bkw-character-thumb img{width:100%;height:100%;object-fit:cover;display:block;}
.bkw-character-thumb .bkw-portrait-placeholder{font-size:22px;}
.bkw-portrait-placeholder{width:100%;height:100%;display:flex;align-items:center;justify-content:center;color:#666;font-size:28px;}
.bkw-character-portrait-large{width:100%;height:240px;display:flex;align-items:center;justify-content:center;background:#f3f3f3;border-radius:12px;overflow:hidden;margin:10px 0;}
.bkw-character-portrait-large img{width:100%;height:100%;object-fit:contain;}
/* Locations */
.bkw-location-card .bkw-location-image{
  width:100%;
  height:160px;
  display:flex;
  align-items:center;
  justify-content:center;
  background:#f3f3f3;
  border-radius:12px;
  overflow:hidden;
  margin-bottom:10px;
}
.bkw-location-card img{width:100%;height:100%;object-fit:cover;display:block;}

/* Locations selector */
.bkw-location-list{display:flex;flex-wrap:wrap;gap:10px;}
.bkw-location-item{display:flex;align-items:center;gap:8px;border:1px solid #e6e9ef;border-radius:12px;padding:8px 10px;background:#fff;cursor:pointer;}
.bkw-location-item input{margin:0;}
.bkw-location-thumb{width:34px;height:34px;border-radius:8px;object-fit:cover;background:#f3f3f3;display:inline-flex;align-items:center;justify-content:center;}
.bkw-location-thumb--empty{font-size:16px;color:#666;}

/* Cast selector */
.bkw-cast-list{display:flex;flex-wrap:wrap;gap:10px;}
.bkw-cast-item{display:flex;align-items:center;gap:8px;border:1px solid #e6e9ef;border-radius:12px;padding:8px 10px;background:#fff;cursor:pointer;}
.bkw-cast-item input{margin:0;}
.bkw-cast-thumb{width:34px;height:34px;border-radius:8px;object-fit:cover;background:#f3f3f3;display:inline-flex;align-items:center;justify-content:center;}
.bkw-cast-thumb--empty{font-size:16px;color:#666;}


/* Feedback / Review (v1.1.1) */
.bkw-draft-split{
  display:flex;
  gap:12px;
  align-items:flex-start;
}
.bkw-draft-editorwrap{
  position:relative;
  flex: 1 1 auto;
  min-width: 0;
}
.bkw-draft-overlay{
  position:absolute;
  top:0;
  left:0;
  right:0;
  bottom:0;
  padding: 12px;
  overflow:auto;
  pointer-events:none;
  color: transparent;
  white-space: pre-wrap;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}
.bkw-draft{
  position:relative;
  background: transparent;
}
.bkw-highlight{
  pointer-events:auto;
  background: rgba(255, 235, 59, 0.9);
  color: #111;
  border-radius: 3px;
  cursor:pointer;
}
.bkw-highlight--resolved{
  background: rgba(200,200,200,0.6);
}
.bkw-feedback-panel{
  width: 320px;
  flex: 0 0 320px;
  background: #fff;
  border: 1px solid #e6e6e6;
  border-radius: 12px;
  padding: 10px;
}
.bkw-feedback-head{
  display:flex;
  gap:8px;
  margin-bottom:10px;
}
.bkw-feedback-head select{
  flex:1 1 auto;
  padding:8px;
  border-radius:10px;
  border:1px solid #ddd;
}
.bkw-feedback-list{
  display:flex;
  flex-direction:column;
  gap:10px;
  max-height: 60vh;
  overflow:auto;
}
.bkw-feedback-item{
  border:1px solid #eee;
  border-radius:12px;
  padding:10px;
  cursor:pointer;
}
.bkw-feedback-item:hover{ background:#fafafa; }
.bkw-feedback-meta{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-bottom:6px;
  font-size: 12px;
}
.bkw-feedback-status{
  padding:2px 8px;
  border-radius:999px;
  border:1px solid #ddd;
  text-transform:capitalize;
}
.bkw-feedback-status--open{ background:#fff3cd; border-color:#ffe69c; }
.bkw-feedback-status--resolved{ background:#d1e7dd; border-color:#a3cfbb; }
.bkw-feedback-text{ font-size: 13px; margin-bottom:6px; }
.bkw-feedback-quote{ font-size: 12px; opacity:0.75; }

.bkw-quote{
  background:#f7f7f7;
  padding:10px;
  border-radius:12px;
  margin-bottom:10px;
  font-size: 13px;
  white-space: pre-wrap;
}

@media (max-width: 900px){
  .bkw-draft-split{ flex-direction:column; }
  .bkw-feedback-panel{ width: 100%; flex: 0 0 auto; }
  .bkw-feedback-list{ max-height: 40vh; }
}


.bkw-feedback-badge{display:inline-block;margin-left:8px;padding:2px 6px;border-radius:10px;font-size:12px;background:#ffefd5;color:#7a4b00;border:1px solid #f2c97d;}
.bkw-feedback-badge--focus{background:#eefbf8;color:#0f766e;border-color:#b7efe8;}
.bkw-feedback-actions{margin-top:6px;}
.bkw-btn-xs{padding:6px 10px;font-size:12px;}


/* v2.2.2: Draft suggestions panel + highlight overlay */
.bkw-mobile-only{ display:none; }
.bkw-draft-split{
  display:grid;
  grid-template-columns: minmax(0,1fr) 360px;
  gap:16px;
  align-items:start;
}
.bkw-draft-left{ min-width:0; }
.bkw-draft-editorwrap{
  position:relative;
  min-height:420px;
}
.bkw-draft-editor{
  position:relative;
  z-index:2;
  background:transparent;
}
.bkw-draft-overlay{
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
  color:transparent;
  overflow:hidden;
}
.bkw-draft-overlay-inner{
  max-width:860px;
  margin:0 auto;
  padding:18px 18px 22px;
  min-height:420px;
  white-space:pre-wrap;
  line-height:1.7;
  font-size:16px;
  font-family:inherit;
  color:transparent;
}
.bkw-highlight{
  background: rgba(255, 235, 59, 0.62);
  border-radius:4px;
  color:transparent;
  box-shadow: inset 0 0 0 1px rgba(204, 170, 0, 0.18);
}
.bkw-highlight--resolved{
  background: rgba(176, 184, 196, 0.42);
}
.bkw-highlight.is-active,
.bkw-highlight--resolved.is-active{
  box-shadow: inset 0 0 0 2px rgba(26,188,156,0.65);
}
.bkw-feedback-panel{
  width:auto;
  min-width:0;
  flex:initial;
  display:flex;
  flex-direction:column;
  gap:12px;
  padding:12px;
  position:sticky;
  top:16px;
}
.bkw-feedback-panel__header{ display:flex; flex-direction:column; gap:10px; }
.bkw-feedback-title-row{ display:flex; flex-direction:column; gap:2px; }
.bkw-feedback-title{ font-size:18px; font-weight:800; color:#1f2d3d; }
.bkw-feedback-summary{ font-size:12px; }
.bkw-feedback-filters{ display:flex; gap:8px; flex-wrap:wrap; }
.bkw-feedback-filters button{
  border:1px solid #d8e2eb;
  background:#fff;
  color:#334155;
  border-radius:999px;
  padding:6px 10px;
  font-size:12px;
  cursor:pointer;
}
.bkw-feedback-filters button.is-active{
  background:#1abc9c;
  border-color:#1abc9c;
  color:#fff;
}
.bkw-feedback-ai{ display:flex; flex-direction:column; gap:10px; align-items:stretch; }
.bkw-feedback-ai__actions{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; }
.bkw-feedback-ai__controls{ display:grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap:10px; }
.bkw-feedback-control{ display:flex; flex-direction:column; gap:6px; min-width:0; }
.bkw-feedback-control__label{ font-size:12px; font-weight:700; color:#334155; }
.bkw-feedback-control__help{ font-size:11px; color:#64748b; }
.bkw-feedback-ai select{
  width:100%;
  min-width:0;
  padding:8px 10px;
  border:1px solid #d8e2eb;
  border-radius:10px;
  background:#fff;
}
.bkw-feedback-ai .bkw-btn{ flex:0 0 auto; }
.bkw-feedback-coaching{
  margin-bottom:8px;
  padding:10px;
  border-radius:10px;
  background:#f8f7ff;
  border:1px solid #e5e0ff;
  color:#4c1d95;
  font-size:13px;
  line-height:1.5;
}
.bkw-checkrow{
  display:flex;
  gap:10px;
  align-items:flex-start;
  color:#334155;
  font-size:14px;
}
.bkw-checkrow input{ margin-top:3px; }
.bkw-feedback-list{
  display:flex;
  flex-direction:column;
  gap:10px;
  max-height:68vh;
  overflow:auto;
  padding-right:2px;
}
.bkw-feedback-item{
  border:1px solid #e6ebf1;
  border-radius:14px;
  padding:12px;
  background:#fff;
  cursor:pointer;
  transition:box-shadow .15s ease, border-color .15s ease, background-color .15s ease;
}
.bkw-feedback-item:hover{
  border-color:#cfdbe8;
  box-shadow:0 8px 20px rgba(0,0,0,0.06);
}
.bkw-feedback-item.is-active{
  border-color:#1abc9c;
  box-shadow:0 0 0 2px rgba(26,188,156,0.18);
}
.bkw-feedback-item__top{
  display:flex;
  justify-content:space-between;
  gap:12px;
  align-items:flex-start;
  margin-bottom:8px;
}
.bkw-feedback-item__title{
  display:flex;
  gap:8px;
  align-items:center;
  flex-wrap:wrap;
  font-size:13px;
}
.bkw-feedback-type{ font-weight:700; color:#1f2d3d; text-transform:capitalize; }
.bkw-feedback-reviewer{ color:#64748b; font-size:12px; }
.bkw-feedback-status{ font-size:11px; font-weight:700; }
.bkw-feedback-status--applied{ background:#d1e7dd; border-color:#a3cfbb; }
.bkw-feedback-status--dismissed{ background:#eef2f7; border-color:#d6dde6; }
.bkw-feedback-status--needs_reanchor{ background:#fff3cd; border-color:#ffe69c; }
.bkw-feedback-snippet,
.bkw-feedback-comment,
.bkw-feedback-suggested{
  white-space:pre-wrap;
  line-height:1.5;
  font-size:13px;
}
.bkw-feedback-snippet{
  background:#f8fafc;
  border:1px solid #eef2f6;
  border-radius:10px;
  padding:10px;
  color:#334155;
  margin-bottom:8px;
}
.bkw-feedback-comment{ color:#475569; margin-bottom:8px; }
.bkw-feedback-suggested{
  background:#f6fbfa;
  border:1px solid rgba(26,188,156,0.20);
  border-radius:10px;
  padding:10px;
  color:#1f2d3d;
}
.bkw-feedback-note{ margin-top:8px; }
.bkw-feedback-actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin-top:10px;
}
.bkw-feedback-empty{ padding:10px 2px; }

@media (max-width: 768px){
  .bkw-draft-split{ grid-template-columns: 1fr; }
  .bkw-feedback-panel{
    width:100%;
    max-height:none;
    position:static;
  }
  .bkw-feedback-ai__actions{ flex-direction:column; align-items:stretch; }
  .bkw-feedback-ai__controls{ grid-template-columns: 1fr; }
  .bkw-feedback-list{ max-height:50vh; }
  .bkw-mobile-only{ display:inline-flex; margin-top:10px; }
  .bkw-draft-overlay-inner{ padding:14px 14px 18px; min-height:360px; font-size:15px; }
}


/* Importer */
.bkw-table-wrap{ overflow:auto; }
.bkw-table{ width:100%; border-collapse:collapse; font-size:14px; }
.bkw-table th,.bkw-table td{ border:1px solid #e6e6e6; padding:8px; vertical-align:top; }
.bkw-error{ border-left:4px solid #d63638; }
.bkw-note{ color:#555; font-size:13px; margin-top:8px; }
.bkw-btn-ghost{ background:#fff; color:#333; border:1px solid #ddd; }
/* Simple sheet menu (More) */
.bkw-menu{ display:flex; flex-direction:column; gap:10px; }
.bkw-menu-section{ font-size:12px; font-weight:800; color:#2c3e50; opacity:0.75; margin: 6px 2px -2px; text-transform: uppercase; letter-spacing: .04em; }
.bkw-menu-item{
  width:100%;
  padding:12px 14px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,0.10);
  background:#fff;
  font-weight:800;
  text-align:left;
  cursor:pointer;
}
.bkw-menu-item:hover{ background: rgba(44,62,80,0.05); }

.bkw-nav-ico{ font-size: 20px; line-height: 1; }
.bkw-nav-lbl{ display:none; font-size: 11px; line-height: 1; }

.bkw-pre--compact{max-height:140px;}

/* v1.6.1 fix: ensure centered modal overlay is visible (older CSS blocks set display:none) */
.bkw-modal-overlay{
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  background: rgba(0,0,0,0.45) !important;
  padding:
    calc(16px + env(safe-area-inset-top))
    calc(16px + env(safe-area-inset-right))
    calc(16px + env(safe-area-inset-bottom))
    calc(16px + env(safe-area-inset-left)) !important;
  z-index: 100000 !important;
}
.bkw-modal{
  width: min(760px, 100%) !important;
  max-height: 90vh !important;
  display:flex !important;
  flex-direction: column !important;
}
.bkw-modal-body{ overflow:auto !important; }

/* =========================================================
   v1.8.1: Blueprint + Threads UI helpers
   ========================================================= */

.bkw-badge{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  line-height:18px;
  border:1px solid #d0d5dd;
  background:#f9fafb;
  color:#344054;
  white-space:nowrap;
}
.bkw-badge--ok{ background:#ecfdf3; border-color:#abefc6; color:#067647; }
.bkw-badge--warn{ background:#fffaeb; border-color:#fedf89; color:#b54708; }
.bkw-badge--muted{ background:#f2f4f7; border-color:#d0d5dd; color:#475467; }

/* =========================================================
   v2.0.6: Chapter Advanced → Characters tool UI
   ========================================================= */

.bkw-char-review{ display:flex; flex-direction:column; gap:10px; }
.bkw-char-row{
  display:grid;
  grid-template-columns: 24px 1fr 280px;
  gap:12px;
  align-items:start;
  padding:10px;
  border:1px solid var(--bkw-border);
  border-radius:12px;
  background:#fff;
}
.bkw-char-include{ margin-top:4px; }
.bkw-char-main{ min-width:0; }
.bkw-char-name-static{ font-weight:700; color:#101828; font-size:14px; line-height:20px; }
.bkw-char-nameinput{ font-weight:700; }
.bkw-char-notes{ margin-top:4px; }
.bkw-char-actions{ display:flex; gap:8px; align-items:center; justify-content:flex-end; flex-wrap:wrap; }
.bkw-char-select{ max-width: 280px; }

@media (max-width: 768px){
  .bkw-char-row{ grid-template-columns: 24px 1fr; }
  .bkw-char-actions{ justify-content:flex-start; }
}

.bkw-thread-list{ display:flex; flex-direction:column; gap:10px; }
.bkw-thread-row{ display:flex; gap:10px; align-items:flex-start; justify-content:space-between; padding:10px; border:1px solid #eaecf0; border-radius:12px; background:#fff; }
.bkw-thread-main{ flex:1; min-width:0; }
.bkw-thread-meta{ display:flex; gap:6px; align-items:center; flex-wrap:wrap; margin-bottom:6px; }
.bkw-thread-text{ color:#101828; font-size:14px; line-height:20px; }
.bkw-thread-actions{ flex:0 0 auto; }

.bkw-workflow-steps{ display:flex; gap:10px; flex-wrap:wrap; }
.bkw-workflow-step{ display:flex; align-items:center; gap:8px; padding:6px 10px; border:1px solid #eaecf0; border-radius:999px; background:#fff; }
.bkw-workflow-dot{ width:20px; height:20px; border-radius:999px; display:inline-flex; align-items:center; justify-content:center; font-size:12px; border:1px solid #d0d5dd; background:#f2f4f7; color:#475467; }
.bkw-workflow-dot--done{ background:#ecfdf3; border-color:#abefc6; color:#067647; }
.bkw-workflow-state{ font-size:12px; color:#475467; }


/* v1.8.1: Library desktop cleanup */
@media (min-width: 900px){
  .bkw-library-view .bkw-topbar .bkw-actions{ display:none !important; }
}

/* v1.8.1: Book tabs as a smooth toolbar on desktop */
.bkw-book-tabs{
  background: #f6f8fb;
  border: 1px solid rgba(15, 23, 42, 0.10);
  border-radius: 16px;
  padding: 10px 10px;
  margin: 12px 0 14px 0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
  align-items: center;
}

.bkw-book-tabs .bkw-tab{
  background: transparent;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 800;
  font-size: 13px;
  color: #334155;
}

.bkw-book-tabs .bkw-tab:hover{
  background: rgba(26,188,156,0.10);
}

.bkw-book-tabs .bkw-tab.active{
  background: var(--bkw-teal);
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(26,188,156,0.25);
}

/* slightly tighter on small screens */
@media (max-width: 520px){
  .bkw-book-tabs{
    padding: 8px;
    border-radius: 14px;
  }
  .bkw-book-tabs .bkw-tab{
    padding: 9px 12px;
  }
}



/* My Books empty state */
.bkw-empty{
  border: 2px dashed rgba(44,62,80,0.14);
  background: rgba(44,62,80,0.03);
  border-radius: 18px;
  padding: 26px 18px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.bkw-empty-title{
  font-size: 18px;
  font-weight: 800;
  color: var(--bkw-navy);
}
.bkw-empty-sub{
  font-size: 14px;
  color: rgba(44,62,80,0.72);
  max-width: 420px;
}
.bkw-btn-wizard{
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-radius: 10px;
  background: var(--bkw-teal);
  color: #fff !important;
  text-decoration: none !important;
  font-weight: 700;
  white-space: nowrap;
  box-shadow: 0 10px 20px rgba(26,188,156,0.18);
}
.bkw-btn-wizard i{
  font-size: 14px;
  color: #fff !important;
}
@media (max-width: 560px){
  .bkw-empty{ padding: 22px 14px; }
  .bkw-btn-wizard{ width: 100%; justify-content: center; }
}
/* Defensive overrides: themes can apply link styles with higher specificity */
a.bkw-btn-wizard,
a.bkw-btn-wizard:visited,
a.bkw-btn-wizard:hover,
a.bkw-btn-wizard:active,
a.bkw-btn-wizard:focus{
  color:#fff !important;
  text-decoration:none !important;
}
.bkw-btn-wizard:hover{ filter: brightness(0.98); }

/* ===================================================================== */
/* v1.8.5: Chapter Outline Studio                                         */
/* ===================================================================== */

.bkw-outline-studio{
  display:flex;
  flex-direction:column;
  gap:14px;
}

.bkw-attachments-grid{
  display:grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap:12px;
}

@media (max-width: 980px){
  .bkw-attachments-grid{ grid-template-columns: 1fr; }
}

.bkw-attach-group{
  border:1px solid rgba(0,0,0,0.06);
  border-radius:12px;
  padding:10px;
  background: rgba(255,255,255,0.6);
}

.bkw-attach-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}

.bkw-attach-title{
  font-weight:700;
}

.bkw-chip-row{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.bkw-chip{
  display:inline-flex;
  align-items:center;
  gap:8px;
  border:1px solid rgba(0,0,0,0.08);
  background:#fff;
  border-radius:999px;
  padding:6px 10px;
}

.bkw-chip-img{
  width:22px;
  height:22px;
  border-radius:999px;
  background-size:cover;
  background-position:center;
  background-color: rgba(0,0,0,0.04);
  flex:0 0 auto;
}

.bkw-chip-img--empty{ background-image:none !important; }

.bkw-chip-text{ font-size: 13px; }

.bkw-chip-x{
  border:none;
  background:transparent;
  cursor:pointer;
  font-size:16px;
  line-height:1;
  padding:0 2px;
  opacity:0.6;
}
.bkw-chip-x:hover{ opacity:1; }

.bkw-outline-main{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:14px;
}

@media (max-width: 980px){
  .bkw-outline-main{ grid-template-columns: 1fr; }
}

.bkw-outline-chat .bkw-chat-log{
  margin-top:10px;
  border:1px solid rgba(0,0,0,0.06);
  border-radius:12px;
  padding:10px;
  min-height:140px;
  max-height:300px;
  overflow:auto;
  background:#fff;
}

.bkw-chat-msg{
  padding:8px 10px;
  border-radius:12px;
  border:1px solid rgba(0,0,0,0.06);
  margin-bottom:8px;
}

.bkw-chat-msg--user{ background: rgba(0,0,0,0.02); }
.bkw-chat-msg--ai{ background: rgba(26,188,156,0.06); }

.bkw-chat-role{
  font-size:11px;
  text-transform:uppercase;
  letter-spacing:0.04em;
  opacity:0.7;
  margin-bottom:4px;
}

.bkw-chat-content{ white-space:pre-wrap; }

.bkw-chat-compose{
  display:flex;
  gap:10px;
  margin-top:10px;
}

.bkw-chat-compose textarea{ flex:1; }

@media (max-width: 560px){
  .bkw-chat-compose{ flex-direction:column; }
}

.bkw-pending-inner{
  margin-top:12px;
  border:1px solid rgba(0,0,0,0.08);
  border-radius:12px;
  padding:10px;
  background: rgba(255,193,7,0.06);
}

.bkw-pending-title{ font-weight:800; margin-bottom:6px; }
.bkw-pending-note{ white-space:pre-wrap; }
.bkw-pending-patchlist{ margin-top:8px; }
.bkw-patch-op{ font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size:12px; opacity:0.8; }

.bkw-outline-editor .bkw-scenes{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}

.bkw-scene-card{
  border:1px solid rgba(0,0,0,0.06);
  border-radius:12px;
  padding:10px;
  background:#fff;
}

.bkw-scene-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  margin-bottom:8px;
}

.bkw-scene-title{ font-weight:800; }

.bkw-grid-2{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap:10px;
}

@media (max-width: 980px){
  .bkw-grid-2{ grid-template-columns: 1fr; }
}

.bkw-btn-xs{
  padding:6px 10px;
  font-size:12px;
  border-radius:10px;
}

.bkw-badge{
  display:inline-block;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  border:1px solid rgba(0,0,0,0.08);
  margin-right:6px;
  background:#fff;
}

.bkw-badge-success{
  border-color: rgba(26,188,156,0.35);
  background: rgba(26,188,156,0.10);
}

.bkw-pre{
  border:1px solid rgba(0,0,0,0.06);
  background:#fff;
  border-radius:12px;
  padding:10px;
  white-space:pre-wrap;
}

.bkw-picker-list{
  border:1px solid rgba(0,0,0,0.06);
  border-radius:12px;
  padding:8px;
  max-height: 420px;
  overflow:auto;
  background:#fff;
}

.bkw-picker-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px;
  border-radius:10px;
}

.bkw-picker-row:hover{ background: rgba(0,0,0,0.03); }


/* === v1.8.6 Draft Writing Page + Selection Tools === */
.bkw-draft-page{
  background: transparent;
}
.bkw-draft-toolbar{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 14px;
  background: #ffffff;
  box-shadow: 0 8px 24px rgba(0,0,0,0.06);
}
.bkw-draft-toolbar-left{
  display:flex;
  flex-direction:column;
  gap:2px;
}
.bkw-draft-toolbar-right{
  display:flex;
  gap:10px;
  align-items:center;
}
.bkw-draft-hint{ margin-top:10px; }
.bkw-draft-editor-wrap{
  margin-top: 12px;
  background: #ffffff;
  border: 1px solid rgba(0,0,0,0.08);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.06);
}
.bkw-draft-editor{
  padding: 18px 18px 22px;
  min-height: 420px;
  max-width: 860px;
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.7;
  color: #1f2d3d;
  white-space: pre-wrap;
  outline: none;
}
.bkw-draft-editor:focus{
  box-shadow: inset 0 0 0 2px rgba(26,188,156,0.25);
  border-radius: 14px;
}
.bkw-selmenu{
  display:flex;
  gap:8px;
  padding: 8px 10px;
  border-radius: 12px;
  background: rgba(44,62,80,0.98);
  box-shadow: 0 14px 32px rgba(0,0,0,0.25);
  backdrop-filter: blur(6px);
}
.bkw-selbtn{
  border: 0;
  background: rgba(255,255,255,0.08);
  color: #ffffff;
  padding: 6px 10px;
  border-radius: 10px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.bkw-selbtn:hover{ background: rgba(255,255,255,0.16); }
.bkw-selbtn:active{ transform: translateY(1px); }

@media (max-width: 768px){
  .bkw-draft-editor{ padding: 14px 14px 18px; min-height: 360px; font-size: 15px; }
  .bkw-selmenu{ gap:6px; padding: 8px; flex-wrap: wrap; max-width: calc(100vw - 24px); }
}


/* Passage transform modal */
.bkw-passage-grid{ display:grid; grid-template-columns: 1fr 1fr; gap:12px; }
.bkw-passage-grid textarea{ min-height: 160px; }
@media (max-width: 720px){
  .bkw-passage-grid{ grid-template-columns: 1fr; }
}


/* v2.0.8: Thumbnail rendering improvements */
.bkw-cover-preview img{display:block;width:160px;height:240px;object-fit:cover;border-radius:12px;}
.bkw-thumb img{display:block;width:96px;height:96px;object-fit:cover;border-radius:12px;}

/* Rewards Experience (v2.2.4) */
.bkw-rewards-dashboard{ display:grid; gap:16px; }
.bkw-rewards-metrics{ display:grid; grid-template-columns:repeat(3,minmax(0,1fr)); gap:14px; }
.bkw-rewards-phase3-grid{ display:grid; grid-template-columns:1.1fr .9fr; gap:14px; }
.bkw-reward-stat-card,
.bkw-reward-tier-card,
.bkw-reward-nextup-card,
.bkw-reward-collections-card,
.bkw-reward-collection,
.bkw-reward-progress-card,
.bkw-reward-badge,
.bkw-rewards-empty{ background:#fff; border:1px solid rgba(44,62,80,0.08); border-radius:18px; box-shadow:0 10px 28px rgba(16,24,40,0.06); }
.bkw-reward-stat-card{ padding:18px; display:flex; flex-direction:column; gap:8px; min-height:136px; }
.bkw-reward-stat-card__icon{ width:42px; height:42px; display:flex; align-items:center; justify-content:center; border-radius:12px; background:rgba(26,188,156,0.12); font-size:22px; }
.bkw-reward-stat-card__value{ font-size:32px; font-weight:800; color:var(--bkw-navy); line-height:1; }
.bkw-reward-stat-card__label{ color:#627083; font-weight:600; }
.bkw-reward-tier-card,
.bkw-reward-nextup-card,
.bkw-reward-collections-card,
.bkw-reward-collection{ padding:18px; display:flex; flex-direction:column; gap:12px; }
.bkw-reward-tier-card{ background:linear-gradient(180deg, rgba(26,188,156,0.12), rgba(255,255,255,1)); }
.bkw-reward-tier-card__eyebrow,
.bkw-reward-popup__eyebrow{ font-size:12px; font-weight:800; letter-spacing:.04em; text-transform:uppercase; color:#627083; }
.bkw-reward-tier-card__title{ font-size:28px; font-weight:800; color:var(--bkw-navy); line-height:1.05; }
.bkw-reward-tier-card__desc,
.bkw-reward-tier-card__sub,
.bkw-reward-collection__desc,
.bkw-reward-nextup-item__sub,
.bkw-reward-collection__complete{ color:#627083; font-size:14px; line-height:1.45; }
.bkw-reward-tier-card__progress{ font-weight:700; color:#213146; }
.bkw-reward-progress-bar{ position:relative; height:10px; border-radius:999px; background:rgba(44,62,80,0.08); overflow:hidden; }
.bkw-reward-progress-bar > span{ position:absolute; inset:0 auto 0 0; width:0; background:linear-gradient(90deg, var(--bkw-teal), #6adbc5); border-radius:999px; }
.bkw-reward-nextup-list,
.bkw-reward-collections-list,
.bkw-rewards-awards{ display:grid; gap:12px; }
.bkw-reward-nextup-item,
.bkw-reward-collection-row{ display:flex; gap:12px; align-items:flex-start; padding:12px 14px; border:1px solid rgba(44,62,80,0.08); border-radius:16px; background:#fcfcfd; }
.bkw-reward-nextup-item__icon,
.bkw-reward-collection-row__icon,
.bkw-reward-collection__icon{ width:40px; height:40px; border-radius:12px; display:flex; align-items:center; justify-content:center; background:rgba(26,188,156,0.12); font-size:20px; flex:0 0 40px; }
.bkw-reward-nextup-item--streak .bkw-reward-nextup-item__icon,
.bkw-reward-collection-row.is-complete .bkw-reward-collection-row__icon{ background:rgba(255,193,7,0.18); }
.bkw-reward-nextup-item--chapter .bkw-reward-nextup-item__icon{ background:rgba(69,123,157,0.16); }
.bkw-reward-nextup-item--daily .bkw-reward-nextup-item__icon{ background:rgba(109,40,217,0.12); }
.bkw-reward-nextup-item__body,
.bkw-reward-collection-row__body{ display:grid; gap:8px; flex:1; min-width:0; }
.bkw-reward-nextup-item__title,
.bkw-reward-collection__title,
.bkw-reward-collection-row__top{ font-weight:700; color:var(--bkw-navy); }
.bkw-reward-collection-row__top{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.bkw-reward-collection{ gap:14px; }
.bkw-reward-collection.is-complete{ background:linear-gradient(180deg, rgba(26,188,156,0.08), rgba(255,255,255,1)); }
.bkw-reward-collection__head,
.bkw-rewards-awards__head{ display:flex; align-items:center; justify-content:space-between; gap:8px; }
.bkw-reward-collection__titlewrap{ display:flex; gap:12px; align-items:flex-start; }
.bkw-rewards-awards__head h3{ margin:0; color:var(--bkw-navy); }
.bkw-rewards-awards__count,
.bkw-reward-collection__count{ font-size:13px; color:#627083; font-weight:700; }
.bkw-rewards-awards-grid{ display:grid; grid-template-columns:repeat(auto-fit,minmax(220px,1fr)); gap:14px; }
.bkw-rewards-awards-grid--compact{ grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); }
.bkw-reward-badge{ padding:16px; display:flex; gap:14px; align-items:flex-start; min-height:112px; }
.bkw-reward-badge__icon{ width:50px; height:50px; border-radius:14px; background:rgba(26,188,156,0.12); display:flex; align-items:center; justify-content:center; font-size:26px; flex:0 0 50px; }
.bkw-reward-badge__body{ display:flex; flex-direction:column; gap:6px; }
.bkw-reward-badge__title{ font-weight:800; color:var(--bkw-navy); }
.bkw-reward-badge__desc{ color:#627083; font-size:14px; line-height:1.45; }
.bkw-reward-badge--major .bkw-reward-badge__icon,
.bkw-reward-badge--milestone .bkw-reward-badge__icon,
.bkw-reward-popup--major .bkw-reward-popup__icon,
.bkw-reward-popup--milestone .bkw-reward-popup__icon{ background:rgba(255,107,61,0.12); }
.bkw-reward-badge--starter .bkw-reward-badge__icon{ background:rgba(26,188,156,0.12); }
.bkw-reward-badge--streak .bkw-reward-badge__icon,
.bkw-reward-popup--streak .bkw-reward-popup__icon{ background:rgba(255,193,7,0.18); }
.bkw-reward-badge--chapter .bkw-reward-badge__icon,
.bkw-reward-popup--chapter .bkw-reward-popup__icon{ background:rgba(69,123,157,0.16); }
.bkw-reward-badge--daily .bkw-reward-badge__icon,
.bkw-reward-popup--daily .bkw-reward-popup__icon,
.bkw-reward-popup--collection .bkw-reward-popup__icon{ background:rgba(109,40,217,0.12); }
.bkw-reward-badge--locked{ opacity:.62; box-shadow:none; background:#f8fafc; }
.bkw-rewards-empty{ padding:22px; text-align:center; display:flex; flex-direction:column; gap:8px; align-items:center; justify-content:center; min-height:164px; }
.bkw-rewards-empty--compact{ min-height:unset; }
.bkw-rewards-empty__icon{ font-size:32px; }
.bkw-rewards-empty__title{ font-weight:800; color:var(--bkw-navy); }
.bkw-rewards-empty__text{ color:#627083; max-width:320px; line-height:1.45; }
.bkw-reward-popups{ position:fixed; top:calc(20px + env(safe-area-inset-top, 0px)); right:20px; z-index:99998; pointer-events:none; }
.bkw-reward-popup{ width:min(380px, calc(100vw - 24px)); background:#fff; border:1px solid rgba(44,62,80,0.08); border-radius:20px; box-shadow:0 18px 48px rgba(16,24,40,0.18); padding:18px 18px 16px; display:flex; gap:14px; align-items:flex-start; position:relative; transform:translateY(-12px) scale(0.98); opacity:0; transition:opacity .18s ease, transform .18s ease; pointer-events:auto; overflow:hidden; }
.bkw-reward-popup::before{ content:''; position:absolute; inset:0 auto 0 0; width:5px; background:var(--bkw-teal); }
.bkw-reward-popup.show{ opacity:1; transform:translateY(0) scale(1); }
.bkw-reward-popup--major::before,
.bkw-reward-popup--milestone::before{ background:#ff6b3d; }
.bkw-reward-popup--streak::before{ background:#ffc107; }
.bkw-reward-popup--chapter::before{ background:#457b9d; }
.bkw-reward-popup--daily::before,
.bkw-reward-popup--collection::before{ background:#7c3aed; }
.bkw-reward-popup__icon{ width:56px; height:56px; border-radius:16px; background:rgba(26,188,156,0.12); display:flex; align-items:center; justify-content:center; font-size:30px; flex:0 0 56px; }
.bkw-reward-popup__body{ display:flex; flex-direction:column; gap:6px; min-width:0; }
.bkw-reward-popup__title{ font-size:20px; line-height:1.15; font-weight:800; color:var(--bkw-navy); }
.bkw-reward-popup__desc{ font-size:14px; color:#49566a; line-height:1.45; }
.bkw-reward-popup__cta{ align-self:flex-start; margin-top:6px; background:#ff6b3d; }
.bkw-reward-popup__close{ position:absolute; top:8px; right:8px; width:28px; height:28px; border:none; border-radius:999px; background:rgba(44,62,80,0.06); color:#5b6b7d; cursor:pointer; font-size:18px; line-height:1; }
@media (max-width: 900px){
  .bkw-rewards-metrics,
  .bkw-rewards-progress-grid{
    grid-template-columns:1fr;
  }
}
@media (max-width: 768px){
  .bkw-reward-popups{
    right:12px;
    left:12px;
    top:auto;
    bottom:calc(96px + env(safe-area-inset-bottom, 0px));
  }
  .bkw-reward-popup{
    width:100%;
  }
  .bkw-rewards-awards-grid{
    grid-template-columns:1fr;
  }
}
/* Author rewards upgrade (v3.0.3) */
.bkw-rewards-scope-head{ display:flex; align-items:flex-end; justify-content:space-between; gap:12px; }
.bkw-rewards-scope-head--author{ margin-top:10px; padding-top:4px; border-top:1px solid rgba(44,62,80,0.06); }
.bkw-rewards-scope-title{ margin:2px 0 0; font-size:28px; line-height:1.1; color:var(--bkw-navy); }
.bkw-rewards-metrics--author{ grid-template-columns:repeat(4,minmax(0,1fr)); }
.bkw-rewards-two-col{ display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:14px; }
.bkw-rewards-recent-list{ display:grid; gap:10px; }
.bkw-rewards-recent-item{ display:flex; gap:12px; align-items:flex-start; padding:12px 14px; border:1px solid rgba(44,62,80,0.08); border-radius:16px; background:#fcfcfd; }
.bkw-rewards-summary-list{ display:grid; gap:10px; }
.bkw-rewards-summary-item{ display:flex; justify-content:space-between; gap:12px; padding:12px 14px; border:1px solid rgba(44,62,80,0.08); border-radius:16px; background:#fcfcfd; color:#627083; }
.bkw-rewards-summary-item strong{ color:var(--bkw-navy); }
.bkw-reward-tier-card--author{ background:linear-gradient(180deg, rgba(69,123,157,0.12), rgba(255,255,255,1)); }
.bkw-reward-nextup-item--author .bkw-reward-nextup-item__icon,
.bkw-reward-badge--author .bkw-reward-badge__icon,
.bkw-reward-popup--author .bkw-reward-popup__icon{ background:rgba(69,123,157,0.16); }
.bkw-reward-nextup-item--catalog .bkw-reward-nextup-item__icon,
.bkw-reward-badge--catalog .bkw-reward-badge__icon,
.bkw-reward-popup--catalog .bkw-reward-popup__icon{ background:rgba(255,107,61,0.12); }
.bkw-reward-nextup-item--craft .bkw-reward-nextup-item__icon,
.bkw-reward-badge--craft .bkw-reward-badge__icon,
.bkw-reward-popup--craft .bkw-reward-popup__icon{ background:rgba(124,58,237,0.12); }
.bkw-reward-popup--author::before{ background:#457b9d; }
.bkw-reward-popup--catalog::before{ background:#ff6b3d; }
.bkw-reward-popup--craft::before{ background:#7c3aed; }
@media (max-width: 1000px){
  .bkw-rewards-metrics--author,
  .bkw-rewards-two-col{ grid-template-columns:1fr 1fr; }
}
@media (max-width: 900px){
  .bkw-rewards-two-col{ grid-template-columns:1fr; }
}
@media (max-width: 768px){
  .bkw-rewards-metrics--author{ grid-template-columns:1fr; }
  .bkw-rewards-scope-title{ font-size:24px; }
}

/* v3.1.0 Prompt-first onboarding */
.bkw-prompt-view,
.bkw-concept-view{
  width:min(980px, 100%);
  margin:0 auto;
}
.bkw-prompt-hero,
.bkw-concept-card,
.bkw-prompt-launcher{
  padding:22px;
  border-radius:18px;
  background:#fff;
  border:1px solid rgba(0,0,0,0.06);
  box-shadow: var(--bkw-shadow-soft);
}
.bkw-prompt-title{
  margin:8px 0 6px;
  font-size: clamp(28px, 4vw, 42px);
  line-height:1.08;
}
.bkw-prompt-copy{
  margin:0 0 14px;
  color: rgba(0,0,0,0.72);
  font-size:15px;
}
.bkw-kicker{
  font-size:12px;
  text-transform:uppercase;
  letter-spacing:.08em;
  font-weight:800;
  color:#6b4eff;
}
.bkw-prompt-form{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.bkw-prompt-input{
  width:100%;
  min-height:110px;
  padding:14px 16px;
  border-radius:16px;
  border:1px solid var(--bkw-border);
  background:#fff;
  box-shadow: var(--bkw-shadow-soft);
  font:inherit;
  resize:vertical;
}
.bkw-prompt-input:focus{
  outline:none;
  border-color:#7c5cff;
  box-shadow:0 0 0 3px rgba(124,92,255,.14);
}
.bkw-prompt-examples{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}

.bkw-prompt-cta{
  background: var(--bkw-teal) !important;
  color:#fff !important;
}
.bkw-prompt-cta:hover{
  background: var(--bkw-orange) !important;
  filter:none !important;
}
.bkw-chip{
  border:1px solid var(--bkw-border);
  background:#fff;
  color:inherit;
  border-radius:999px;
  padding:8px 12px;
  font-size:12px;
  line-height:1.2;
  cursor:pointer;
  text-align:left;
}
.bkw-chip:hover{
  background:#f7f4ff;
  border-color:#cabdff;
}
.bkw-honeypot{
  position:absolute !important;
  left:-99999px !important;
  width:1px !important;
  height:1px !important;
  opacity:0 !important;
  pointer-events:none !important;
}
.bkw-prompt-launcher{
  margin-bottom:18px;
}
.bkw-prompt-launcher-head{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:12px;
  margin-bottom:10px;
}
.bkw-note-info{
  border-left:4px solid #7c5cff;
  padding-left:10px;
}
@media (max-width: 720px){
  .bkw-prompt-hero,
  .bkw-concept-card,
  .bkw-prompt-launcher{
    padding:16px;
    border-radius:16px;
  }
  .bkw-prompt-title{
    font-size:30px;
  }
  .bkw-prompt-form .bkw-row--between{
    align-items:flex-start !important;
  }
}


.bkw-brand-loader-overlay{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(246,248,251,0.78);
  backdrop-filter: blur(4px);
  z-index:100000;
}
.bkw-brand-loader-card{
  min-width:220px;
  max-width:90vw;
  background:#fff;
  border:1px solid rgba(0,0,0,0.06);
  border-radius:22px;
  padding:24px 26px;
  box-shadow:0 20px 48px rgba(16,24,40,0.14);
  text-align:center;
}
.bkw-brand-loader-mark{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:10px;
  margin-bottom:14px;
}
.bkw-brand-loader-dot{
  width:14px;
  height:14px;
  border-radius:999px;
  display:inline-block;
  animation:bkwBrandLoaderBounce 1s infinite ease-in-out;
}
.bkw-brand-loader-dot--green{ background:var(--bkw-teal); }
.bkw-brand-loader-dot--orange{ background:var(--bkw-orange); animation-delay:.15s; }
.bkw-brand-loader-dot:nth-child(3){ animation-delay:.3s; }
.bkw-brand-loader-title{
  font-size:20px;
  font-weight:800;
  color:var(--bkw-navy);
  margin-bottom:6px;
}
.bkw-brand-loader-message{
  font-size:14px;
  color:#5f6b7a;
}
@keyframes bkwBrandLoaderBounce{
  0%, 80%, 100% { transform:translateY(0); opacity:.55; }
  40% { transform:translateY(-8px); opacity:1; }
}

/* v3.2.0 Draft safety + versioning */
.bkw-chapter-meta__row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
}
.bkw-save-status{
  font-weight:600;
}
.bkw-save-status.is-dirty{ color:#8a6d1d; }
.bkw-save-status.is-saving{ color:#2563eb; }
.bkw-save-status.is-saved{ color:#0f766e; }
.bkw-save-status.is-error{ color:#b42318; }

.bkw-versions{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.bkw-version-row{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  padding:12px 14px;
  border:1px solid rgba(0,0,0,0.08);
  border-radius:12px;
  background:#fff;
}
.bkw-version-main{ min-width:0; }
.bkw-version-title{ font-weight:700; color:#1f2d3d; }
.bkw-version-badge{
  display:inline-block;
  margin-top:6px;
  font-size:11px;
  font-weight:700;
  text-transform:capitalize;
  color:#475569;
  background:#f8fafc;
  border:1px solid #e2e8f0;
  border-radius:999px;
  padding:3px 8px;
}
.bkw-version-preview-card .bkw-pre{
  background:#f8fafc;
  border-radius:12px;
}
@media (max-width: 768px){
  .bkw-version-row{
    flex-direction:column;
  }
}

/* v3.2.2 Export system */
.bkw-export-form{
  display:flex;
  flex-direction:column;
  gap:16px;
}
.bkw-export-grid{
  display:grid;
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:16px;
}
.bkw-export-section{
  border:1px solid rgba(0,0,0,0.08);
  border-radius:14px;
  padding:14px;
  background:#fff;
}
.bkw-export-check{
  display:flex;
  align-items:center;
  gap:10px;
  margin:8px 0;
  color:#1f2d3d;
}
.bkw-export-check input{ margin:0; }
.bkw-export-checklist{
  max-height:240px;
  overflow:auto;
  border:1px solid rgba(0,0,0,0.08);
  border-radius:12px;
  padding:10px 12px;
  background:#f8fafc;
}
.bkw-export-checklist .bkw-export-check:first-child{ margin-top:0; }
.bkw-export-checklist .bkw-export-check:last-child{ margin-bottom:0; }
.bkw-note--success{
  border:1px solid rgba(13,148,136,0.18);
  background:#ecfeff;
  color:#115e59;
}
@media (max-width: 768px){
  .bkw-export-grid{ grid-template-columns:1fr; }
}


.bkw-shell--guest .bkw-app-header { padding-left: 0; padding-right: 0; }
.bkw-shell--guest .bkw-app-header__left { padding-left: 6px; }
.bkw-shell--guest .bkw-app-header__right { padding-right: 6px; }


@media (max-width: 1024px) and (min-width: 769px) {
  .bkw-nav{ top: calc(var(--bkw-header-h) + 44px); }
}

body.admin-bar .bkw-shell{ padding-top: calc(var(--bkw-header-h) + 20px); }
@media (max-width:782px){ body.admin-bar .bkw-shell{ padding-top: calc(var(--bkw-header-h) + 10px); } }

/* Public review assistance / conversion */
.bkw-review-help-card,
.bkw-review-conversion-card{ border-radius:16px; }
.bkw-review-guidance__chip{ cursor:pointer; }
.bkw-review-guidance__output{ line-height:1.55; }
.bkw-review-conversion[hidden]{ display:none !important; }
.bkw-review-conversion-card .bkw-btn{ min-width: 180px; }
.bkw-review .bkw-card-title{ font-weight:700; }
.bkw-review .bkw-review-draft{ line-height:1.7; }
@media (max-width: 768px){
  .bkw-review-help-card,
  .bkw-review-conversion-card{ border-radius:14px; }
}

/* Visual Asset Management (v3.4.4) */
.bkw-asset-gallery{
  display:flex;
  flex-direction:column;
  gap:14px;
}
.bkw-asset-gallery__head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:12px;
  flex-wrap:wrap;
}
.bkw-asset-gallery__title,
.bkw-asset-gallery__subtitle,
.bkw-asset-primary__label{
  font-weight:700;
}
.bkw-asset-primary{
  display:flex;
  flex-direction:column;
  gap:10px;
}
.bkw-asset-primary__media{
  display:block;
  width:100%;
  border:1px solid var(--bkw-border);
  border-radius:16px;
  background:#fff;
  overflow:hidden;
  padding:0;
  cursor:pointer;
}
.bkw-asset-primary__media[disabled]{
  cursor:default;
}
.bkw-asset-primary__media img{
  display:block;
  width:100%;
  height:auto;
  max-height:520px;
  object-fit:contain;
  background:#f8fafc;
}
.bkw-asset-primary__placeholder,
.bkw-asset-preview-modal__placeholder{
  min-height:260px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:48px;
  background:#f8fafc;
  color:#64748b;
}
.bkw-asset-primary__actions,
.bkw-asset-thumbcard__actions{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
}
.bkw-asset-thumbgrid{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(132px, 1fr));
  gap:12px;
  margin-top:10px;
}
.bkw-asset-thumbcard{
  display:flex;
  flex-direction:column;
  gap:8px;
}
.bkw-asset-thumbcard__media{
  display:block;
  width:100%;
  aspect-ratio:1 / 1;
  border:1px solid var(--bkw-border);
  border-radius:14px;
  overflow:hidden;
  background:#fff;
  padding:0;
  cursor:pointer;
}
.bkw-asset-thumbcard__media img{
  display:block;
  width:100%;
  height:100%;
  object-fit:cover;
  background:#f8fafc;
}
.bkw-asset-thumbcard__media .bkw-thumb-placeholder{
  width:100%;
  height:100%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:34px;
  background:#f8fafc;
}
.bkw-asset-preview-modal{
  display:flex;
  flex-direction:column;
  gap:14px;
}
.bkw-asset-preview-modal__imagewrap{
  border:1px solid var(--bkw-border);
  border-radius:16px;
  overflow:hidden;
  background:#f8fafc;
}
.bkw-asset-preview-modal__image{
  display:block;
  width:100%;
  height:auto;
  max-height:72vh;
  object-fit:contain;
  margin:0 auto;
}
.bkw-asset-preview-modal__meta{
  display:grid;
  gap:6px;
  font-size:14px;
}
@media (max-width: 768px){
  .bkw-asset-primary__actions,
  .bkw-asset-thumbcard__actions,
  .bkw-asset-gallery__head{
    flex-direction:column;
    align-items:stretch;
  }
  .bkw-asset-primary__placeholder,
  .bkw-asset-preview-modal__placeholder{
    min-height:200px;
  }
}
.bkw-asset-lightbox-overlay{
  position:fixed;
  inset:0;
  z-index:100000;
  background:rgba(15,23,42,0.68);
  display:flex;
  align-items:center;
  justify-content:center;
  padding:24px;
}
.bkw-asset-lightbox{
  width:min(980px, 100%);
  max-height:min(92vh, 980px);
  display:flex;
  flex-direction:column;
  background:#fff;
  border-radius:18px;
  overflow:hidden;
  box-shadow:0 30px 80px rgba(15,23,42,0.35);
}
.bkw-asset-lightbox__header,
.bkw-asset-lightbox__footer{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:14px 16px;
  border-bottom:1px solid var(--bkw-border);
}
.bkw-asset-lightbox__footer{
  border-top:1px solid var(--bkw-border);
  border-bottom:none;
  justify-content:flex-end;
  flex-wrap:wrap;
}
.bkw-asset-lightbox__title{
  font-weight:700;
}
.bkw-asset-lightbox__close{
  border:none;
  background:transparent;
  font-size:28px;
  line-height:1;
  cursor:pointer;
}
.bkw-asset-lightbox__body{
  padding:16px;
  overflow:auto;
}
@media (max-width: 768px){
  .bkw-asset-lightbox-overlay{ padding:12px; }
  .bkw-asset-lightbox{ max-height:95vh; border-radius:14px; }
  .bkw-asset-lightbox__header,
  .bkw-asset-lightbox__footer{ padding:12px; }
}

/* =========================
   Chapter Audio Mode (v3.5.5)
   ========================= */
.bkw-chapter-workspace-nav {
  margin: 16px 0 12px;
}
.bkw-chapter-workspace-nav-main {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.bkw-chapter-mode-toggle {
  display: inline-flex;
  gap: 6px;
  padding: 6px;
  border-radius: 999px;
  background: rgba(255,255,255,.65);
  border: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 8px 24px rgba(15,23,42,.06);
}
.bkw-mode-pill {
  appearance: none;
  border: 0;
  background: transparent;
  color: #475569;
  border-radius: 999px;
  padding: 9px 16px;
  font-weight: 700;
  cursor: pointer;
}
.bkw-mode-pill.active {
  background: linear-gradient(135deg, #0f172a, #1e293b);
  color: #fff;
}
.bkw-writing-tabbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.bkw-writing-tabbar .bkw-tab {
  appearance: none;
  border: 1px solid rgba(15,23,42,.08);
  background: rgba(255,255,255,.78);
  color: #334155;
  border-radius: 999px;
  padding: 9px 14px;
  font-weight: 600;
  cursor: pointer;
}
.bkw-writing-tabbar .bkw-tab.active {
  background: #fff;
  color: #0f172a;
  box-shadow: 0 10px 24px rgba(15,23,42,.08);
}
.bkw-audio-mode-panel {
  margin-top: 10px;
}
.bkw-audio-studio-shell {
  display: grid;
  gap: 16px;
}
.bkw-audio-hero-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(15,23,42,.98), rgba(30,41,59,.94));
  color: #fff;
  box-shadow: 0 14px 36px rgba(15,23,42,.16);
}
.bkw-audio-hero-card .bkw-card-title,
.bkw-audio-hero-card .bkw-muted {
  color: #fff;
}
.bkw-audio-hero-meta,
.bkw-audio-upgrade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  background: rgba(255,255,255,.14);
  font-weight: 700;
}
.bkw-audio-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.bkw-audio-card {
  position: relative;
  overflow: hidden;
}
.bkw-audio-item-list {
  display: grid;
  gap: 12px;
}
.bkw-audio-item-card {
  border: 1px solid rgba(15,23,42,.08);
  border-radius: 14px;
  padding: 14px;
  background: rgba(248,250,252,.95);
}
.bkw-audio-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.bkw-audio-item-title {
  font-weight: 700;
  color: #0f172a;
}
.bkw-audio-player {
  width: 100%;
}
.bkw-audio-studio-shell.is-locked {
  position: relative;
}
.bkw-audio-grid.is-disabled {
  filter: blur(1px);
  opacity: .55;
  pointer-events: none;
}
.bkw-audio-locked-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.bkw-audio-locked-card {
  max-width: 420px;
  width: 100%;
  border-radius: 20px;
  background: rgba(255,255,255,.96);
  border: 1px solid rgba(15,23,42,.08);
  box-shadow: 0 20px 40px rgba(15,23,42,.16);
  padding: 22px;
  text-align: center;
}
.bkw-audio-upgrade-actions {
  display: grid;
  gap: 10px;
  margin-top: 14px;
}
.bkw-audio-studio-shell.is-locked select:disabled,
.bkw-audio-studio-shell.is-locked textarea:disabled,
.bkw-audio-studio-shell.is-locked button:disabled {
  cursor: not-allowed;
}
.bkw-chapter-audio-active .bkw-loader-wrap {
  margin-top: 0;
}
@media (max-width: 900px) {
  .bkw-audio-grid {
    grid-template-columns: 1fr;
  }
}


.bkw-audio-profile-panel{margin-top:14px;padding:12px;border:1px solid rgba(15,23,42,.08);border-radius:14px;background:#f8fafc}
.bkw-audio-profile-pills{display:flex;flex-wrap:wrap;gap:8px}
.bkw-audio-delivery-guidance{margin-top:10px;font-size:13px;line-height:1.5;color:#334155}

.bkw-audio-player-wrap{display:grid;gap:8px}.bkw-audio-player{width:100%}.bkw-audio-player-actions{display:flex;gap:8px;justify-content:flex-end}.bkw-audio-preview-panel textarea[disabled],.bkw-audio-studio-shell textarea:disabled,.bkw-audio-studio-shell select:disabled{opacity:.7;cursor:not-allowed}.bkw-audio-latest-preview{display:flex;align-items:center;gap:8px}


.bkw-audio-notice{margin-bottom:12px;padding:12px 14px;border-radius:14px;border:1px solid rgba(15,23,42,.08);font-size:13px;line-height:1.5}
.bkw-audio-notice.is-info{background:#eff6ff;border-color:#bfdbfe;color:#1e3a8a}
.bkw-audio-notice.is-success{background:#ecfdf5;border-color:#a7f3d0;color:#166534}
.bkw-audio-notice.is-warning{background:#fff7ed;border-color:#fed7aa;color:#9a3412}
.bkw-audio-notice.is-error{background:#fef2f2;border-color:#fecaca;color:#991b1b}
.bkw-audio-studio-shell.is-loading .bkw-audio-card{min-height:180px}
.bkw-audio-spinner{width:18px;height:18px;border-radius:999px;border:2px solid rgba(255,255,255,.35);border-top-color:#fff;animation:bkwSpin .9s linear infinite}
@keyframes bkwSpin{to{transform:rotate(360deg)}}
.bkw-audio-skeleton{height:12px;border-radius:999px;background:linear-gradient(90deg, rgba(226,232,240,.8), rgba(241,245,249,.95), rgba(226,232,240,.8));background-size:200% 100%;animation:bkwAudioShimmer 1.2s ease-in-out infinite;margin-top:12px}
.bkw-audio-skeleton-lg{height:22px;width:65%}
@keyframes bkwAudioShimmer{0%{background-position:200% 0}100%{background-position:-200% 0}}
.bkw-audio-empty-state{padding:18px;border:1px dashed rgba(15,23,42,.12);border-radius:14px;background:#f8fafc}
.bkw-audio-player-wrap{padding:10px 12px;border:1px solid rgba(15,23,42,.08);border-radius:14px;background:#fff}
.bkw-audio-player-actions{margin-top:4px}
.bkw-btn[data-busy="1"]{position:relative;pointer-events:none}
.bkw-btn[data-busy="1"]::after{content:'';display:inline-block;width:12px;height:12px;margin-left:8px;border-radius:999px;border:2px solid currentColor;border-right-color:transparent;vertical-align:-2px;animation:bkwSpin .9s linear infinite}
