[hidden] { display: none !important; }
body.modal-open { overflow: hidden; }

.report-settings,
.add-chapter-panel { margin-bottom: 18px; }
.report-settings summary,
.add-chapter-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 17px 20px;
  cursor: pointer;
  list-style: none;
}
.report-settings summary::-webkit-details-marker,
.add-chapter-panel summary::-webkit-details-marker { display: none; }
.report-settings summary span:first-child,
.add-chapter-panel summary span:first-child { display: flex; flex-direction: column; gap: 3px; }
.report-settings summary strong,
.add-chapter-panel summary strong { font-size: 15px; }
.report-settings summary small,
.add-chapter-panel summary small { color: var(--muted); font-size: 12px; }
.summary-action { color: #68a9fa; font-size: 12px; font-weight: 800; }
.report-settings[open] summary,
.add-chapter-panel[open] summary { border-bottom: 1px solid #1b2a3e; }

.chapters-panel { margin-bottom: 18px; overflow: hidden; scroll-margin-top: 84px; }
.chapters-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 20px;
  border-bottom: 1px solid #1b2a3e;
}
.chapters-heading h2 { margin: 0; font-size: 17px; }
.chapters-heading p { margin: 6px 0 0; color: var(--muted); font-size: 12px; }
.chapters-empty { min-height: 180px; display: grid; place-items: center; }
.chapter-list { display: flex; flex-direction: column; }

.chapter-row {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
  gap: 24px;
  padding: 18px 20px 20px;
  border-bottom: 1px solid #1b2a3e;
  scroll-margin-top: 84px;
}
.chapter-row:last-child { border-bottom: 0; }
.chapter-row.is-child { background: #0b152210; }
.chapter-rail {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 14px;
  padding-right: 20px;
  border-right: 1px solid #1b2a3e;
}
.chapter-controls {
  display: grid;
  grid-template-columns: repeat(4, 40px);
  justify-content: space-between;
  align-content: start;
  gap: 10px;
}
.chapter-controls form { display: contents; }
.chapter-icon {
  width: 40px;
  height: 40px;
  padding: 0;
  border: 1px solid #31506e;
  border-radius: 7px;
  background: #102131;
  color: #9ed4ff;
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
}
.chapter-icon:hover { border-color: #4c9ef3; color: #ffffff; }
.chapter-icon.danger { color: #ff7f8b; border-color: #613843; }
.chapter-icon.chapter-indent {
  grid-column: 3 / 5;
  width: 100%;
  color: #8be0b0;
  border-color: #357154;
  font-size: 9px;
  font-weight: 800;
}
.chapter-icon.chapter-indent:hover { border-color: #4dba7d; }
.chapter-icon.chapter-outdent {
  grid-column: 3 / 5;
  width: 100%;
  color: #ffd27a;
  border-color: #79602f;
  font-size: 9px;
  font-weight: 800;
}
.chapter-icon.chapter-outdent:hover { border-color: #d39b35; }
.chapter-meta-form {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
}
.chapter-name { min-width: 0; }
.chapter-name .field {
  width: 100%;
  height: 42px;
  min-height: 42px;
  line-height: 1.2;
}
.chapter-meta-form label {
  display: block;
  margin: 0 0 7px;
  color: #70b9ef;
  font: 700 10px Space Mono;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.chapter-field-heading {
  min-height: 18px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.chapter-save-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: #6f8ca4;
  font-size: 11px;
  font-weight: 700;
  white-space: nowrap;
  transition: color .18s ease;
}
.chapter-save-status.is-saving { color: #70b9ef; }
.chapter-save-status.is-saved { color: #5fc68b; }
.chapter-save-status.is-error { color: #ff7f8b; }
.chapter-number label {
  display: block;
  margin: 0 0 7px;
  color: #70b9ef;
  font: 700 10px Space Mono;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.chapter-number-value {
  height: 56px;
  display: grid;
  place-items: center;
  border: 1px solid #2b435d;
  border-radius: 9px;
  background: #102131;
  color: #70bfff;
  font-weight: 800;
}
.chapter-text { min-width: 0; }
.chapter-text-preview {
  width: 100%;
  height: 106px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  padding: 13px 14px;
  border: 1px solid #2b435d;
  border-radius: 9px;
  background: #0c1723;
  color: #d7e7f8;
  text-align: left;
  line-height: 1.55;
  cursor: text;
}
.chapter-text-preview:hover { border-color: #38a5ef; box-shadow: 0 0 0 3px #2d9ce719; }
.chapter-text-preview.is-empty { color: var(--muted); font-style: italic; }

.chapter-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 22px;
  background: #020711d9;
  backdrop-filter: blur(7px);
}
.chapter-modal-dialog {
  width: min(1120px, 100%);
  height: min(820px, calc(100vh - 44px));
  max-height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #1d2d43;
  border-radius: var(--radius);
  background: linear-gradient(145deg, #101b2a, #0d1521);
  color: var(--text);
  box-shadow: 0 30px 90px #000a;
}
.chapter-modal-dialog > form {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
}
.chapter-modal-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 62px;
  padding: 10px 16px;
  border-bottom: 1px solid #24394d;
}
.chapter-modal-header > div { display: flex; flex-direction: column; gap: 2px; }
.chapter-modal-header strong { font-size: 15px; }
.chapter-modal-header small { color: #718da6; font-size: 11px; }
.chapter-modal-close {
  margin-left: auto;
  border: 0;
  background: transparent;
  color: #cbe0f2;
  font-size: 27px;
  cursor: pointer;
}
.chapter-modal-body {
  min-height: 0;
  display: flex;
  flex: 1;
  flex-direction: column;
  padding: 30px 38px 20px;
}
.chapter-modal-body h2 { margin: 0; font-size: 25px; line-height: 1.3; }
.chapter-modal-body > p { margin: 8px 0 22px; color: #83a3bd; font-size: 13px; }
.chapter-format-toolbar {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 8px 10px;
  border: 1px solid #263952;
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  background: #101d2c;
}
.chapter-format-toolbar button {
  width: 34px;
  height: 32px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #35506c;
  border-radius: 6px;
  background: #14263a;
  color: #dce9fa;
  font: 700 15px/1 Manrope, sans-serif;
  cursor: pointer;
}
.chapter-format-toolbar button:hover,
.chapter-format-toolbar button.is-active { border-color: #428ff1; background: #183b60; color: #fff; }
.chapter-format-toolbar > span { margin-left: 5px; color: #7796af; font-size: 11px; }
.chapter-modal-text {
  width: 100%;
  min-height: 180px;
  flex: 1;
  resize: vertical;
  padding: 28px 34px;
  border: 1px solid #263952;
  overflow: auto;
  white-space: pre-wrap;
  tab-size: 4;
  border-radius: 0 0 9px 9px;
  outline: 0;
  background: #0d1725;
  color: #dce9fa;
  font: 500 15px/1.55 Manrope, sans-serif;
}
.chapter-modal-text:focus { border-color: #428ff1; box-shadow: 0 0 0 3px #2c82ec18; }
.chapter-modal-meta {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  margin-top: 10px;
  color: #6e91aa;
  font-size: 11px;
}
#chapterModalSaveStatus.is-saving { color: #70b9ef; }
#chapterModalSaveStatus.is-saved { color: #55d79a; }
#chapterModalSaveStatus.is-error { color: #ff7f8b; }
.chapter-modal-footer {
  display: flex;
  flex: 0 0 auto;
  justify-content: flex-end;
  gap: 12px;
  padding: 18px 38px;
  border-top: 1px solid #24394d;
}
.chapter-modal-footer .btn { min-width: 130px; }

html[data-theme="light"] .report-settings[open] summary,
html[data-theme="light"] .add-chapter-panel[open] summary,
html[data-theme="light"] .chapters-heading,
html[data-theme="light"] .chapter-row,
html[data-theme="light"] .chapter-rail { border-color: #d8e2ed; }
html[data-theme="light"] .chapter-row.is-child { background: #f5f9fd; }
html[data-theme="light"] .chapter-icon { background: #f4f9ff; color: #23699f; border-color: #b7ccdf; }
html[data-theme="light"] .chapter-icon:hover { color: #084f8e; border-color: #3788cf; }
html[data-theme="light"] .chapter-icon.danger { color: #b93745; background: #fff7f8; border-color: #e1b6bc; }
html[data-theme="light"] .chapter-meta-form label { color: #286b9d; }
html[data-theme="light"] .chapter-number label { color: #286b9d; }
html[data-theme="light"] .chapter-save-status { color: #66788c; }
html[data-theme="light"] .chapter-save-status.is-saving { color: #286b9d; }
html[data-theme="light"] .chapter-save-status.is-saved { color: #238453; }
html[data-theme="light"] .chapter-save-status.is-error { color: #b93745; }
html[data-theme="light"] .chapter-number-value {
  color: #075bb2;
  background: #f4f9ff;
  border-color: #b7ccdf;
}
html[data-theme="light"] .chapter-text-preview {
  background: #ffffff;
  color: #25364a;
  border-color: #c4d3e1;
}
html[data-theme="light"] .chapter-text-preview.is-empty { color: #66788c; }
html[data-theme="light"] .chapter-modal-dialog {
  background: linear-gradient(145deg, #ffffff, #f9fbfd);
  color: var(--text);
  border-color: #d6e0eb;
  box-shadow: 0 28px 80px #253b5540;
}
html[data-theme="light"] .chapter-modal-header,
html[data-theme="light"] .chapter-modal-footer { border-color: #d8e2ed; }
html[data-theme="light"] .chapter-modal-header small,
html[data-theme="light"] .chapter-modal-body > p,
html[data-theme="light"] .chapter-modal-meta { color: var(--muted); }
html[data-theme="light"] .chapter-modal-close { color: #42566d; }
html[data-theme="light"] .chapter-modal-text {
  background: #ffffff;
  color: #172235;
  border-color: #c7d4e2;
}
html[data-theme="light"] .chapter-format-toolbar { background: #f3f7fb; border-color: #c7d4e2; }
html[data-theme="light"] .chapter-format-toolbar button { background: #fff; color: #24384d; border-color: #b9cadd; }
html[data-theme="light"] .chapter-format-toolbar button:hover,
html[data-theme="light"] .chapter-format-toolbar button.is-active { background: #e8f3ff; color: #075bb2; border-color: #428ff1; }
html[data-theme="light"] .chapter-format-toolbar > span { color: #66788c; }
html[data-theme="light"] #chapterModalSaveStatus.is-saving { color: #286b9d; }
html[data-theme="light"] #chapterModalSaveStatus.is-saved { color: #238453; }
html[data-theme="light"] #chapterModalSaveStatus.is-error { color: #b93745; }

@media (max-width: 1150px) {
  .chapter-row { grid-template-columns: 230px minmax(0, 1fr); gap: 18px; }
  .chapter-rail { padding-right: 16px; }
}
@media (max-width: 800px) {
  .chapters-heading { align-items: flex-start; flex-direction: column; }
  .chapter-row,
  .chapter-row.is-child { grid-template-columns: 1fr; padding: 16px; }
  .chapter-rail {
    width: min(100%, 250px);
    gap: 12px;
    padding: 0 0 14px;
    border-right: 0;
    border-bottom: 1px solid #1b2a3e;
  }
  .chapter-meta-form { grid-template-columns: 1fr; }
  .chapter-field-heading { align-items: center; }
  .chapter-modal { padding: 0; }
  .chapter-modal-dialog { width: 100%; max-height: 100vh; height: 100vh; border-radius: 0; }
  .chapter-modal-body { padding: 22px 18px 14px; }
  .chapter-modal-body h2 { font-size: 20px; }
  .chapter-modal-text { min-height: 120px; padding: 18px; }
  .chapter-modal-footer { padding: 14px 18px; }
}
.report-chatgpt-tip {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid color-mix(in srgb, var(--blue) 28%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--blue) 6%, var(--surface));
}

.report-chatgpt-icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: var(--blue);
  background: color-mix(in srgb, var(--blue) 12%, var(--surface2));
  font-size: 17px;
}

.report-chatgpt-tip strong {
  display: block;
  font-size: 12px;
}

.report-chatgpt-tip p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.55;
}

@media (max-width: 800px) {
  .report-chatgpt-tip {
    grid-template-columns: 38px 1fr;
  }
  .report-chatgpt-tip .btn {
    grid-column: 1 / -1;
  }
}
