[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; }
.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: 72px minmax(0, 1fr);
  gap: 14px;
  padding: 18px 20px;
  border-bottom: 1px solid #1b2a3e;
}
.chapter-row:last-child { border-bottom: 0; }
.chapter-row.is-child { padding-left: 56px; background: #0b152210; }
.chapter-controls {
  display: grid;
  grid-template-columns: repeat(2, 30px);
  align-content: end;
  gap: 6px;
  padding-bottom: 1px;
}
.chapter-controls form { display: contents; }
.chapter-icon {
  width: 30px;
  height: 30px;
  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-meta-form {
  min-width: 0;
  display: grid;
  grid-template-columns: 110px minmax(210px, 310px) minmax(320px, 1fr) auto;
  gap: 16px;
  align-items: end;
}
.chapter-meta-form label {
  display: block;
  margin: 0 0 7px;
  color: #70b9ef;
  font: 700 10px Space Mono;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.chapter-number-value {
  height: 42px;
  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: 72px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  padding: 11px 13px;
  border: 1px solid #2b435d;
  border-radius: 9px;
  background: #0c1723;
  color: #d7e7f8;
  text-align: left;
  line-height: 1.5;
  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-save { min-width: 106px; height: 42px; }

.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%);
  max-height: calc(100vh - 44px);
  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-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 { 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-modal-text {
  width: 100%;
  min-height: 410px;
  max-height: calc(100vh - 310px);
  resize: vertical;
  padding: 28px 34px;
  border: 1px solid #263952;
  border-radius: 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;
}
.chapter-modal-footer {
  display: flex;
  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 { 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-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;
}

@media (max-width: 1150px) {
  .chapter-meta-form { grid-template-columns: 100px minmax(180px, 260px) 1fr; }
  .chapter-save { grid-column: 1/-1; justify-self: end; }
}
@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-controls { grid-template-columns: repeat(4, 34px); align-content: start; }
  .chapter-icon { width: 34px; height: 34px; }
  .chapter-meta-form { grid-template-columns: 1fr; }
  .chapter-save { grid-column: auto; justify-self: stretch; }
  .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: calc(100vh - 330px); 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;
  }
}
