:root {
  color-scheme: light;
  --bg: #f3f0ea;
  --surface: #fffaf3;
  --surface-2: #ebe5dc;
  --ink: #211f1e;
  --muted: #706a63;
  --line: #d7cec1;
  --accent: #b3272f;
  --accent-2: #176b69;
  --shadow: 0 18px 50px rgba(48, 39, 31, 0.12);
  --radius: 8px;
  --nav-width: 240px;
  --chapter-panel-width: 280px;
  --inspector-width: 300px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #171818;
  --surface: #202322;
  --surface-2: #292d2b;
  --ink: #f1eee8;
  --muted: #aaa39a;
  --line: #3c403d;
  --accent: #e5555e;
  --accent-2: #6fd0ca;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(179, 39, 47, 0.09), transparent 32%),
    linear-gradient(315deg, rgba(23, 107, 105, 0.1), transparent 30%),
    var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

.hidden {
  display: none !important;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.catalog-shell {
  min-height: 100vh;
  background: #f7f7f8;
}

:root[data-theme="dark"] .catalog-shell {
  background: #151617;
}

.catalog-main {
  min-width: 0;
}

.catalog-topbar {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 70px;
  padding: 0 36px;
  background: #7562df;
}

.topbar-brand {
  display: flex;
  align-items: baseline;
  gap: 14px;
  color: white;
  text-align: center;
}

.topbar-brand strong {
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.55rem;
  line-height: 1;
}

.topbar-brand span {
  color: rgba(255, 255, 255, 0.76);
  font-size: 0.82rem;
  font-weight: 700;
}

.catalog-logo {
  position: absolute;
  right: 36px;
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 2px solid rgba(255, 255, 255, 0.42);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.16);
}

.catalog-logo img {
  width: 34px;
  height: 34px;
}

.catalog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 38px 46px 18px;
  background: var(--surface);
}

.catalog-heading h1 {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.9rem;
  line-height: 1.1;
}

.title-line {
  width: 76px;
  height: 3px;
  margin-top: 8px;
  background: #7562df;
}

.catalog-icons {
  display: flex;
  align-items: center;
  gap: 12px;
}

.primary-button {
  min-height: 36px;
  border: 0;
  border-radius: 5px;
  background: #7562df;
  color: white;
  padding: 0 18px;
  font-weight: 900;
}

.category-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 0 46px 28px;
  background: var(--surface);
}

.category-tab {
  min-width: 94px;
  min-height: 42px;
  border: 0;
  border-radius: 5px;
  background: color-mix(in srgb, var(--surface-2) 55%, var(--surface));
  color: #7562df;
  font-size: 0.74rem;
  font-weight: 800;
}

.category-tab.active {
  background: #7562df;
  color: white;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 284px));
  gap: 18px;
  align-items: start;
  min-height: calc(100vh - 228px);
  padding: 36px 46px;
}

.book-card {
  overflow: hidden;
  border: 8px solid #292b46;
  border-radius: 5px;
  background: #202136;
  box-shadow: 0 8px 18px rgba(32, 33, 54, 0.16);
}

.book-cover {
  display: grid;
  min-height: 330px;
  place-items: center;
  padding: 26px;
  background:
    radial-gradient(circle at 72% 24%, rgba(255, 255, 255, 0.52), transparent 16%),
    linear-gradient(140deg, var(--cover-a), var(--cover-b));
  color: rgba(255, 255, 255, 0.92);
  text-align: center;
}

.book-cover strong {
  max-width: 210px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.35rem;
  line-height: 1.12;
  text-transform: uppercase;
}

.book-meta-line {
  position: relative;
  height: 24px;
  background: #252640;
  color: #a7a8b7;
  font-weight: 800;
  font-size: 0.72rem;
  text-align: center;
  line-height: 24px;
}

.book-card-body {
  padding: 12px 12px 14px;
}

.book-card-body h2 {
  margin: 0 0 12px;
  overflow: hidden;
  color: white;
  font-size: 0.95rem;
  line-height: 1.2;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.card-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.go-book {
  border: 0;
  background: transparent;
  color: #7562df;
  font-weight: 800;
}

.card-mini-actions {
  display: flex;
  gap: 5px;
}

.mini-icon {
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: white;
}

.mini-icon:hover {
  background: rgba(255, 255, 255, 0.1);
}

.studio-shell {
  display: grid;
  grid-template-columns: var(--nav-width) 14px var(--chapter-panel-width) 14px minmax(0, 1fr);
  height: 100vh;
  background: #f6f6f8;
  color: #17204a;
}

.studio-nav,
.chapter-panel {
  min-height: 0;
  overflow: auto;
  background: #191c2d;
  color: white;
}

.studio-nav {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 36px 28px;
}

.nav-home,
.nav-link {
  min-height: 42px;
  border: 0;
  border-radius: 5px;
  padding: 0 18px;
  background: transparent;
  color: white;
  text-align: left;
  font-weight: 800;
}

.nav-home,
.nav-link.active {
  background: #7562df;
}

.nav-link:not(.active) {
  color: #d5d4e5;
}

.nav-spacer {
  flex: 1;
  min-height: 28px;
}

.chapter-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 28px 22px;
  background: #242741;
}

.nav-resizer,
.chapter-resizer {
  position: relative;
  display: grid;
  width: 14px;
  min-width: 14px;
  place-items: center;
  border: 0;
  border-left: 1px solid #1b1e33;
  border-right: 1px solid #ebeaf4;
  background: linear-gradient(90deg, #20233a 0%, #343758 48%, #f3f1ff 100%);
  cursor: col-resize;
}

.nav-resizer::before,
.chapter-resizer::before,
.inspector-resizer::before {
  content: "";
  width: 4px;
  height: 46px;
  border-radius: 999px;
  background: #7562df;
  box-shadow: 0 0 0 3px rgba(117, 98, 223, 0.14);
}

.nav-resizer:hover,
.resizing-nav .nav-resizer,
.chapter-resizer:hover,
.resizing-chapters .chapter-resizer {
  background: #7562df;
}

.add-chapter-button,
.chapter-panel select {
  min-height: 42px;
  border: 0;
  border-radius: 5px;
  padding: 0 14px;
  font-weight: 800;
}

.add-chapter-button {
  background: #7562df;
  color: white;
}

.chapter-panel select {
  background: #1c2034;
  color: white;
}

.chapter-card {
  position: relative;
  display: grid;
  gap: 6px;
  border: 2px solid transparent;
  border-radius: 6px;
  padding: 14px 14px 14px 72px;
  background: #1c2034;
  color: white;
  text-align: left;
}

.chapter-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 54px;
  border-radius: 4px 0 0 4px;
  background: #ff9c4a;
}

.chapter-card.active {
  border-color: #7562df;
}

.chapter-dot {
  position: absolute;
  top: 16px;
  left: 20px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #191c2d;
}

.chapter-card strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chapter-card small {
  color: #d5d4e5;
}

.workspace {
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

.workspace-view {
  min-height: 100%;
}

.writing-stats {
  display: flex;
  align-items: center;
  gap: 28px;
  min-height: 66px;
  padding: 0 24px;
  border-bottom: 1px solid #ebeaf4;
  background: white;
  color: #6870a4;
  font-size: 0.86rem;
}

.top-save-cluster {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
}

.writing-stats div {
  min-width: 52px;
  color: #7562df;
  font-weight: 900;
}

.writing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 14px var(--inspector-width);
  min-height: calc(100vh - 66px);
}

.inspector-resizer {
  display: grid;
  width: 14px;
  min-width: 14px;
  place-items: center;
  border: 0;
  border-left: 1px solid #eceaf8;
  border-right: 1px solid #d9d4f4;
  background: linear-gradient(90deg, #f8f7ff, #e6e1ff);
  cursor: col-resize;
}

.inspector-resizer:hover,
.resizing .inspector-resizer {
  background: #7562df;
}

.resizing,
.resizing-nav,
.resizing-chapters {
  user-select: none;
  cursor: col-resize;
}

.writing-pad {
  min-width: 0;
  background: white;
  padding: 20px 22px;
}

.book-title-input,
.chapter-title-input {
  width: 100%;
  border: 0;
  background: transparent;
  color: #17204a;
}

.book-title-input {
  height: 42px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.9rem;
  font-weight: 900;
}

.chapter-title-input {
  height: 38px;
  font-size: 1.25rem;
  font-weight: 800;
}

.format-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 50px;
  align-items: center;
  margin: 12px 0;
  border: 1px solid #e0dfeb;
  padding: 0 14px;
  color: #52566d;
}

.format-bar button,
.format-bar select {
  min-height: 30px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: white;
  color: #52566d;
  padding: 0 8px;
}

.format-bar button:hover,
.format-bar select:hover {
  border-color: #d8d2ff;
  background: #f7f5ff;
}

.writing-pad #chapterBody,
.rich-editor {
  width: 100%;
  min-height: calc(100vh - 265px);
  border: 0;
  padding: 8px 12px;
  background: white;
  color: #111;
  font-family: Arial, sans-serif;
  font-size: 1rem;
  line-height: 1.55;
  outline: none;
  overflow: auto;
}

.rich-editor h1 {
  font-size: 1.7rem;
}

.rich-editor h2 {
  font-size: 1.35rem;
}

.rich-editor blockquote {
  border-left: 4px solid #7562df;
  margin-left: 0;
  padding-left: 14px;
  color: #4f5680;
}

.chapter-inspector {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: #242741;
  padding: 28px 22px;
  color: #d5d4e5;
}

.inspector-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 0;
  border-radius: 5px;
  background: #7562df;
  color: white;
  font-weight: 800;
}

.inspector-button.muted {
  position: relative;
  overflow: hidden;
  border: 1px solid #3a3f66;
  background: #191c2d;
  color: #f1f0ff;
  box-shadow: 0 2px 8px rgba(5, 7, 20, 0.18);
  text-align: center;
}

.inspector-button.muted:hover {
  border-color: #7562df;
  background: #202136;
  color: white;
  box-shadow: 0 4px 14px rgba(5, 7, 20, 0.28);
}

.inspector-button.muted::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: #7562df;
  opacity: 0;
}

.inspector-button.muted:hover::before,
.inspector-button.muted:focus-visible::before {
  opacity: 1;
}

#toolsPanel,
#peoplePanel,
#placesPanel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

#toolsPanel.hidden,
#peoplePanel.hidden,
#placesPanel.hidden {
  display: none;
}

#toolsPanel .inspector-button.muted {
  width: fit-content;
  max-width: 100%;
  min-height: 36px;
  padding: 0 12px;
}

.chapter-inspector > .inspector-button.muted,
.chapter-inspector > .file-button {
  width: 100%;
  margin-top: 4px;
  padding: 0 14px;
}

.tool-tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid #3a3f66;
  border-radius: 5px;
  overflow: hidden;
  background: #191c2d;
}

.tool-tabs button {
  min-height: 38px;
  border: 0;
  background: transparent;
  color: #d5d4e5;
  font-weight: 800;
}

.tool-tabs .active {
  background: #7562df;
  color: white;
}

.inspector-section h2 {
  margin: 6px 0 12px;
  font-size: 1rem;
  color: #f1f0ff;
}

.inspector-section p {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: #d5d4e5;
}

.inspector-section p strong {
  color: #f1f0ff;
}

.inspector-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inspector-heading-row h2 {
  margin-bottom: 8px;
}

.reference-list {
  display: grid;
  gap: 10px;
  max-height: min(62vh, 640px);
  overflow: auto;
  padding-right: 4px;
}

.reference-card {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid #3a3f66;
  border-radius: 7px;
  background: #191c2d;
  padding: 9px;
}

.reference-card img,
.reference-placeholder {
  width: 62px;
  aspect-ratio: 1;
  border-radius: 6px;
  object-fit: cover;
  background: linear-gradient(145deg, #2d3152, #484f80);
}

.reference-placeholder {
  display: grid;
  place-items: center;
  color: white;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.4rem;
  font-weight: 900;
}

.reference-card span {
  display: block;
  color: #8ee0d4;
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.reference-card strong {
  display: block;
  margin: 3px 0 5px;
  color: #f1f0ff;
  font-size: 0.9rem;
  line-height: 1.2;
}

.reference-card p,
.empty-reference {
  display: block;
  margin: 0;
  color: #d5d4e5;
  font-size: 0.82rem;
  line-height: 1.35;
}

.page-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 48px 46px 18px;
  background: white;
}

.page-heading h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.9rem;
}

.page-copy {
  max-width: 1040px;
  margin: 0;
  padding: 28px 46px;
  color: #33416d;
}

.order-list,
.people-grid,
.plot-board,
.guide-board,
.export-card {
  padding: 24px 46px 48px;
}

.order-row {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 160px 190px;
  gap: 24px;
  align-items: center;
  margin-bottom: 18px;
  border-radius: 6px;
  background: white;
  padding: 18px;
}

.drag-handle {
  display: grid;
  height: 100%;
  place-items: center;
  border-radius: 4px;
  background: #7562df;
  color: white;
}

.muted-copy {
  color: #9da0ae;
}

.order-actions {
  display: grid;
  gap: 8px;
}

.order-actions button {
  min-height: 34px;
  border: 0;
  border-radius: 4px;
  background: #f0efff;
  color: #38305f;
  font-weight: 800;
}

.people-actions {
  display: flex;
  gap: 14px;
  padding: 0 46px 8px;
}

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

.people-grid h2 {
  margin-top: 0;
}

.plot-board {
  display: grid;
  gap: 36px;
  background: #242741;
  color: white;
}

.guide-board {
  display: grid;
  grid-template-columns: minmax(320px, 1.15fr) minmax(320px, 0.85fr);
  gap: 22px;
  align-items: start;
}

.guide-panel {
  border: 1px solid rgba(29, 31, 52, 0.08);
  border-radius: 8px;
  background: white;
  padding: 22px;
  box-shadow: 0 12px 26px rgba(18, 22, 40, 0.06);
}

.guide-main-panel {
  grid-row: span 2;
}

.guide-panel h2 {
  margin: 0 0 16px;
  color: #141936;
  font-size: 1.12rem;
}

.guide-field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.guide-field span,
.guide-step em {
  color: #596395;
  font-size: 0.78rem;
  font-style: normal;
  font-weight: 900;
  text-transform: uppercase;
}

.guide-field textarea,
.guide-step textarea {
  width: 100%;
  min-height: 118px;
  resize: vertical;
  border: 1px solid #e3dece;
  border-radius: 6px;
  background: #fffcf7;
  padding: 12px;
  color: #141936;
  font: inherit;
  line-height: 1.45;
}

.guide-field textarea:focus,
.guide-step textarea:focus {
  outline: 2px solid rgba(117, 98, 223, 0.28);
  border-color: #7562df;
}

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

.guide-path {
  display: grid;
  gap: 14px;
}

.guide-step {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.guide-step strong {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 50%;
  background: #7562df;
  color: white;
  font-size: 1.05rem;
}

.guide-step span {
  display: grid;
  gap: 8px;
}

.guide-step textarea {
  min-height: 92px;
}

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

.plot-lane-title {
  margin: 0 0 14px;
  color: #f1f0ff;
  font-size: 0.95rem;
}

.act-marker {
  border-radius: 4px;
  background: #ff9c4a;
}

.plot-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}

.plot-card {
  width: 280px;
  min-height: 360px;
  border-radius: 5px;
  background: #30334f;
  padding: 14px;
  box-shadow: 0 10px 22px rgba(8, 10, 22, 0.18);
}

.plot-card small {
  display: block;
  margin-bottom: 10px;
  color: #c7c8da;
  font-weight: 800;
}

.plot-card label {
  display: block;
  margin: 9px 0 5px;
  color: #c7c8da;
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.plot-card input,
.plot-card select,
.plot-card textarea {
  width: 100%;
  border: 1px solid #4b5074;
  border-radius: 5px;
  background: #1b1e31;
  color: #f1f0ff;
  padding: 9px 10px;
}

.plot-card textarea {
  min-height: 96px;
  resize: vertical;
  line-height: 1.35;
}

.plot-card input:focus,
.plot-card select:focus,
.plot-card textarea:focus {
  border-color: #7562df;
  box-shadow: 0 0 0 3px rgba(117, 98, 223, 0.22);
}

.plot-card p,
.plot-empty {
  color: #c7c8da;
}

.plot-open-button {
  width: 100%;
  min-height: 36px;
  margin-top: 12px;
  border: 1px solid #7562df;
  border-radius: 5px;
  background: #7562df;
  color: white;
  font-weight: 900;
}

.plot-open-button:hover {
  background: #6352c8;
}

.export-card {
  max-width: 560px;
}

.export-card .soft-button {
  margin-right: 10px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  background: rgba(20, 22, 31, 0.35);
  backdrop-filter: blur(5px);
}

.modal-card {
  position: relative;
  width: min(920px, calc(100vw - 32px));
  border-radius: 6px;
  background: white;
  padding: 36px;
  color: #17204a;
}

.modal-card h1 {
  margin: 4px 0 26px;
  font-family: Georgia, "Times New Roman", serif;
}

.modal-close {
  position: absolute;
  top: 24px;
  right: 24px;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 5px;
  background: #f7f7f8;
  color: #17204a;
  font-weight: 900;
}

.modal-card select {
  width: 100%;
  height: 46px;
  margin: 18px 0 28px;
  border: 0;
  padding: 0 14px;
  background: #f2f1f7;
  color: #17204a;
  font-weight: 700;
}

.reimagine-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 38px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
}

.reimagine-grid textarea {
  min-height: 300px;
  resize: vertical;
  border: 1px solid #dedbea;
  padding: 24px;
  background: #ffffff;
  color: #17204a;
}

.reimagine-grid textarea::placeholder {
  color: #6870a4;
  opacity: 1;
}

.reimagine-run {
  height: 62px;
  border: 0;
  border-radius: 6px;
  background: #7562df;
  color: white;
  font-weight: 900;
}

.focus .studio-nav,
.focus .nav-resizer,
.focus .chapter-panel,
.focus .chapter-resizer,
.focus .chapter-inspector,
.focus .writing-stats {
  display: none;
}

.focus .studio-shell {
  grid-template-columns: minmax(0, 1fr);
}

.focus .writing-layout {
  grid-template-columns: minmax(0, 880px);
  justify-content: center;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(250px, 300px) minmax(420px, 1fr) minmax(280px, 340px);
  gap: 16px;
  height: 100vh;
  padding: 16px;
}

.sidebar,
.right-rail,
.editor-pane {
  min-height: 0;
}

.sidebar,
.right-rail {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: auto;
}

.brand {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 2px 4px;
}

.brand h1 {
  margin: 2px 0 0;
  max-width: 230px;
  font-size: 1.05rem;
  line-height: 1.2;
}

.eyebrow {
  margin: 0;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  box-shadow: var(--shadow);
  padding: 12px;
}

.project-panel label {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  outline: none;
}

input[type="text"]:focus,
textarea:focus {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent-2) 22%, transparent);
}

#bookTitle {
  height: 38px;
  padding: 0 10px;
  font-weight: 700;
}

.project-stats {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.78rem;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title h2 {
  margin: 0;
  font-size: 0.86rem;
}

.icon-button,
.soft-button {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.icon-button {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  font-weight: 900;
}

.soft-button {
  min-height: 34px;
  padding: 0 12px;
  font-size: 0.82rem;
  font-weight: 800;
}

.icon-button:hover,
.soft-button:hover {
  border-color: var(--accent-2);
  transform: translateY(-1px);
}

.book-list,
.chapter-list,
.notes-list,
.location-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.book-item,
.chapter-item,
.note-item,
.location-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 10px;
}

.book-item,
.chapter-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  text-align: left;
  cursor: pointer;
}

.book-item.active,
.chapter-item.active {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
}

.book-item strong,
.chapter-item strong {
  display: block;
  overflow: hidden;
  font-size: 0.88rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.book-item span,
.book-item small,
.chapter-item span,
.chapter-item small {
  color: var(--muted);
  font-size: 0.74rem;
}

.delete-button {
  align-self: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.delete-button:hover {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.editor-pane {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.editor-header,
.editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.editor-footer {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--muted);
  font-size: 0.82rem;
}

.save-cluster {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.save-button {
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  background: #7562df;
  color: white;
  padding: 0 16px;
  font-weight: 900;
}

.save-button:hover {
  background: #6352c8;
}

.cloud-sync {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 15;
  width: min(330px, calc(100vw - 36px));
  border: 1px solid rgba(117, 98, 223, 0.26);
  border-radius: 8px;
  background: color-mix(in srgb, var(--surface) 94%, white);
  box-shadow: var(--shadow);
  color: var(--ink);
  padding: 12px;
}

.cloud-sync-top,
.cloud-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.cloud-sync-top {
  margin-bottom: 10px;
}

.cloud-sync-top strong {
  font-size: 0.86rem;
}

.cloud-sync-top span,
.cloud-account span {
  color: var(--muted);
  font-size: 0.78rem;
}

.cloud-auth-form {
  display: grid;
  gap: 8px;
}

.cloud-auth-form input {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--ink);
  padding: 0 10px;
}

.cloud-actions button {
  min-height: 32px;
  border: 0;
  border-radius: 5px;
  background: #7562df;
  color: white;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 850;
}

.cloud-actions button:last-child {
  background: var(--surface-2);
  color: var(--ink);
}

.cloud-account {
  display: grid;
  gap: 8px;
}

.cloud-sync.cloud-connected {
  display: none;
}

.auth-locked {
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(117, 98, 223, 0.16), transparent 35%),
    linear-gradient(315deg, rgba(179, 39, 47, 0.12), transparent 30%),
    var(--bg);
}

.auth-locked .cloud-sync {
  display: block;
  top: 50%;
  right: auto;
  bottom: auto;
  left: 50%;
  width: min(420px, calc(100vw - 36px));
  transform: translate(-50%, -50%);
  z-index: 40;
  padding: 18px;
}

.auth-locked .cloud-sync-top strong {
  font-size: 1.05rem;
}

.auth-locked .cloud-auth-form input {
  min-height: 42px;
}

.chapter-title-input {
  width: min(55vw, 680px);
  height: 44px;
  border: 0;
  padding: 0;
  background: transparent;
  font-size: clamp(1.45rem, 2.2vw, 2.25rem);
  font-weight: 850;
}

.chapter-title-input:focus {
  box-shadow: none;
}

.editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

#importLibrary {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.file-button {
  display: inline-flex;
  align-items: center;
}

#chapterBody {
  height: 100%;
  resize: none;
  border: 0;
  border-radius: 0;
  padding: 32px clamp(22px, 5vw, 72px);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  line-height: 1.78;
}

#chapterBody:focus {
  box-shadow: none;
}

.countdown-card input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

#daysLeftBadge {
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  color: var(--accent);
  padding: 5px 9px;
  font-size: 0.75rem;
  font-weight: 800;
}

.range-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 0.72rem;
}

.small-textarea {
  min-height: 86px;
  resize: vertical;
  padding: 10px;
  line-height: 1.45;
}

.mini-count {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.chapter-inspector .mini-count {
  color: #a8aac8;
}

.note-item textarea,
.location-item textarea {
  min-height: 70px;
  resize: vertical;
  border: 0;
  padding: 0;
  background: transparent;
  line-height: 1.4;
}

.note-item textarea:focus,
.location-item textarea:focus {
  box-shadow: none;
}

.item-top {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.tag {
  color: var(--accent-2);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.focus .sidebar,
.focus .right-rail,
.focus .editor-actions {
  display: none;
}

.focus .app-shell {
  grid-template-columns: minmax(0, 900px);
  justify-content: center;
}

@media (max-width: 980px) {
  .catalog-shell {
    display: block;
  }

  .catalog-heading,
  .category-tabs,
  .catalog-grid {
    padding-left: 18px;
    padding-right: 18px;
  }

  .catalog-grid {
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  }

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

  .editor-pane {
    min-height: 72vh;
    order: -1;
  }

  .chapter-title-input {
    width: 100%;
  }

  .editor-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-actions {
    justify-content: flex-start;
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
  }

  #chapterBody {
    padding: 22px 16px;
    font-size: 1rem;
  }
}

/* Current Tokyo Novel Studio workspace overrides */
.studio-shell.wide-workspace {
  grid-template-columns: var(--nav-width) 14px minmax(0, 1fr);
}

.writing-pad .book-title-input,
.writing-pad .chapter-title-input {
  display: block;
  width: 100%;
  height: auto;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  background: transparent;
  padding: 0;
  color: #17204a;
}

.writing-pad .book-title-input {
  margin: 0 0 4px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.75rem;
  font-weight: 900;
  line-height: 1.2;
}

.writing-pad .chapter-title-input {
  margin: 0 0 14px;
  font-size: 2rem;
  font-weight: 900;
  line-height: 1.15;
}

.writing-pad .book-title-input:focus,
.writing-pad .chapter-title-input:focus {
  box-shadow: none;
}

.chapter-inspector .small-textarea {
  min-height: 154px;
  border-color: #3a3f66;
  background: #191c2d;
  color: #f1f0ff;
  padding: 12px;
  line-height: 1.4;
}

.chapter-inspector label {
  display: block;
  margin: 12px 0 6px;
  color: #d5d4e5;
  font-weight: 800;
}

.chapter-inspector select,
.chapter-inspector input[type="password"],
.chapter-inspector input[type="range"] {
  width: 100%;
}

.chapter-inspector select,
.chapter-inspector input[type="password"] {
  min-height: 34px;
  border: 1px solid #3a3f66;
  border-radius: 5px;
  background: #191c2d;
  color: #f1f0ff;
  padding: 0 10px;
}

.chapter-inspector input[type="password"]::placeholder {
  color: #8f94b5;
}

.chapter-inspector input[type="range"] {
  accent-color: #7562df;
}

.api-key-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 8px;
}

.mini-action {
  min-height: 34px;
  border: 1px solid #7562df;
  border-radius: 5px;
  background: #7562df;
  color: white;
  font-weight: 800;
}

.voice-status {
  margin: 2px 0 0;
  color: #a8aac8;
  font-size: 0.82rem;
  line-height: 1.35;
}

.page-heading {
  min-height: 126px;
  padding: 38px 54px 22px;
}

.page-heading h1 {
  max-width: none;
}

.page-copy {
  padding: 26px 54px;
  max-width: 1050px;
}

.order-list {
  display: grid;
  gap: 16px;
  padding: 26px 54px 54px;
}

.order-row {
  grid-template-columns: 42px minmax(0, 1fr) 120px 260px;
  gap: 22px;
  width: 100%;
  min-height: 132px;
}

.order-row h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.act-pill {
  justify-self: start;
  border-radius: 999px;
  background: #f0efff;
  color: #38305f;
  padding: 8px 14px;
  font-weight: 900;
}

.order-actions {
  grid-template-columns: repeat(2, 1fr);
}

.order-actions button:last-child {
  grid-column: 1 / -1;
}

.people-grid {
  grid-template-columns: repeat(2, minmax(320px, 1fr));
  align-items: start;
  padding: 24px 54px 54px;
}

.people-grid > section {
  min-width: 0;
  border-radius: 8px;
  background: white;
  padding: 22px;
  box-shadow: 0 8px 22px rgba(32, 33, 54, 0.08);
}

.people-grid .notes-list,
.people-grid .location-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.profile-item {
  min-width: 0;
  border: 1px solid #e6ded0;
  border-radius: 8px;
  background: #fffaf1;
  padding: 12px;
  box-shadow: 0 6px 16px rgba(32, 33, 54, 0.06);
}

.profile-photo {
  display: grid;
  width: 100%;
  aspect-ratio: 16 / 10;
  place-items: center;
  overflow: hidden;
  border-radius: 7px;
  background: linear-gradient(145deg, #242741, #3b4169);
  color: white;
  object-fit: cover;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 2.3rem;
  font-weight: 900;
}

.profile-photo-wrap {
  position: relative;
}

.photo-menu {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 2;
}

.photo-menu summary {
  display: grid;
  min-width: 68px;
  min-height: 32px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 5px;
  background: rgba(20, 24, 45, 0.86);
  color: white;
  font-size: 0.78rem;
  font-weight: 900;
  list-style: none;
  cursor: pointer;
}

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

.photo-menu-panel {
  position: absolute;
  right: 0;
  bottom: 40px;
  display: grid;
  width: 180px;
  gap: 7px;
  border: 1px solid #d8dbea;
  border-radius: 7px;
  background: white;
  padding: 8px;
  box-shadow: 0 12px 26px rgba(23, 32, 74, 0.2);
}

.profile-item label {
  display: block;
  margin: 10px 0 5px;
  color: #536098;
  font-size: 0.78rem;
  font-weight: 900;
}

.profile-name,
.profile-meta,
.profile-description {
  width: 100%;
  border: 1px solid #e6ded0;
  border-radius: 5px;
  background: white;
  color: #17204a;
  padding: 9px 10px;
}

.profile-field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
  margin-top: 2px;
}

.profile-details {
  margin-top: 10px;
}

.profile-details summary {
  display: grid;
  min-height: 36px;
  place-items: center;
  border: 1px solid #d8dbea;
  border-radius: 5px;
  background: white;
  color: #17204a;
  font-size: 0.82rem;
  font-weight: 900;
  list-style: none;
  cursor: pointer;
}

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

.profile-details summary:hover,
.profile-details[open] summary {
  border-color: #7562df;
  color: #7562df;
}

.profile-details-panel {
  margin-top: 10px;
}

.profile-field-grid label {
  margin-bottom: 0;
}

.profile-meta {
  margin-top: 5px;
  padding: 8px 9px;
}

.profile-description {
  min-height: 150px;
  resize: vertical;
  line-height: 1.45;
}

.profile-status {
  margin: 8px 0 0;
  min-height: 0;
}

.profile-status:not(:empty) {
  min-height: 18px;
}

.profile-name:focus,
.profile-meta:focus,
.profile-description:focus {
  border-color: #7562df;
  box-shadow: 0 0 0 3px rgba(117, 98, 223, 0.16);
}

.profile-actions {
  display: none;
}

.photo-button,
.photo-remove,
.photo-generate {
  display: inline-grid;
  min-height: 34px;
  place-items: center;
  border: 1px solid #d8dbea;
  border-radius: 5px;
  background: white;
  color: #17204a;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 900;
  cursor: pointer;
}

.photo-menu-panel .photo-button,
.photo-menu-panel .photo-remove,
.photo-menu-panel .photo-generate {
  width: 100%;
  justify-content: center;
}

.photo-button:hover,
.photo-remove:hover,
.photo-generate:hover {
  border-color: #7562df;
  color: #7562df;
}

.photo-generate {
  background: #7562df;
  border-color: #7562df;
  color: white;
}

.photo-generate:hover {
  background: #6653cf;
  color: white;
}

.photo-generate:disabled {
  cursor: wait;
  opacity: 0.72;
}

.profile-status {
  min-height: 18px;
  margin: 8px 0 0;
  color: #536098;
  font-size: 0.78rem;
  font-weight: 800;
}

.profile-photo-input {
  display: none;
}

.plot-board {
  padding: 32px 54px 64px;
}

#plotView .page-heading {
  min-height: 0;
  padding: 22px 54px 18px;
}

.plot-lane {
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: stretch;
}

.plot-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 18px;
}

.plot-card {
  width: auto;
  min-height: 250px;
}

.plot-card p {
  min-height: 72px;
}

.tool-tabs button {
  cursor: pointer;
}

.modal-card {
  max-height: calc(100vh - 80px);
  overflow: auto;
}

.reimagine-grid textarea {
  min-height: 330px;
  font-size: 0.95rem;
  line-height: 1.5;
}

.modal .reimagine-grid textarea,
.modal .modal-card select {
  color: #17204a !important;
  -webkit-text-fill-color: #17204a;
}

@media (max-width: 1100px) {
  .studio-shell,
  .studio-shell.wide-workspace {
    grid-template-columns: 200px minmax(0, 1fr);
  }

  .chapter-panel {
    display: none;
  }

  .nav-resizer,
  .chapter-resizer {
    display: none;
  }

  .writing-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .inspector-resizer {
    display: none;
  }

  .chapter-inspector {
    min-height: auto;
  }

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

  .guide-board,
  .guide-compact-grid {
    grid-template-columns: 1fr;
  }
}
