/* 관계표 전용 UI */

.rel-editor-controls {
  background: #ffffff;
  border: 1px solid #a8d2f5;
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 12px;
}
.rel-editor-controls label {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.rel-editor-controls input,.rel-editor-controls select,.rel-inspector input,.rel-inspector select {
  border: 1px solid #a8d2f5;
  border-radius: 8px;
  padding: 8px;
  max-width: 100%;
}
.rel-controls-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
  align-items: center;
}
.rel-tip {
  font-size: 13px;
  color: #6983a6;
  line-height: 1.7;
}
.rel-inspector {
  background: #ffffff;
  border: 1px solid #a8d2f5;
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
}
.rel-inspector label {
  display: flex;
  gap: 5px;
  align-items: center;
  flex-wrap: wrap;
  font-size: 13px;
}
.rel-inspector input[type=range] {
  width: 100px;
}
.rel-inspector input[type=color] {
  width: 46px;
  padding: 2px;
  height: 36px;
}
.rel-inspector button,.rel-controls-row button,.rel-zoom button {
  border: 1px solid #a8d2f5;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px 12px;
  cursor: pointer;
}
.rel-zoom {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
}
.rel-scroll {
  width: 100%;
  overflow: auto;
  max-height: 76vh;
  min-height: 380px;
  border: 1px solid #a8d2f5;
  border-radius: 12px;
  background: #ffffff;
  touch-action: pan-x pan-y;
}
.rel-canvas {
  position: relative;
  width: 1500px;
  height: 900px;
  transform-origin: top left;
  background-color: #ffffff;
  background-image: linear-gradient(#d2edff 1px,transparent 1px),linear-gradient(90deg,#d2edff 1px,transparent 1px);
  background-size: 40px 40px;
}
.rel-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
}
.rel-line-click {
  pointer-events: stroke;
  cursor: pointer;
}
.rel-node {
  position: absolute;
  cursor: grab;
  text-align: center;
  user-select: none;
  touch-action: none;
}
.rel-node:active {
  cursor: grabbing;
}
.rel-node.selected {
  border-radius: 9px;
  outline: 2px solid #243c5d;
  outline-offset: 3px;
}
.rel-node-photo {
  border: 3px solid #a8d2f5;
  overflow: hidden;
  background: #d2edff;
  position: relative;
}
.rel-node-photo span {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  font-size: 12px;
  color: #6983a6;
}
.rel-node-name {
  background: #d2edff;
  font-weight: bold;
  overflow-wrap: anywhere;
}
.rel-node-link {
  color: inherit;
  text-decoration: none;
  display: block;
  cursor: pointer;
}
.rel-node-link:hover .rel-node-name {
  text-decoration: underline;
}
.rel-line-label {
  font-size: 15px;
  font-weight: bold;
  paint-order: stroke;
  stroke: #ffffff;
  stroke-width: 2.5px;
  stroke-linejoin: round;
  pointer-events: none;
}
.rel-inspector .rel-remove {
  color: #a82d36;
  border-color: #a82d36;
}
@media (max-width:700px) {
  .rel-editor-controls {
    padding: 10px;
  }
  .rel-inspector {
    gap: 7px;
  }
  .rel-scroll {
    min-height: 330px;
  }
}

/* 관계표 편집기: 캔버스 + 도구 모음 + 오른쪽 패널 */

.rel-namebar {
  margin: 12px 0;
}
.rel-namebar label {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.rel-namebar input {
  border: 1px solid #a8d2f5;
  border-radius: 9px;
  padding: 10px;
  min-width: 250px;
}
.rel-workspace {
  display: grid;
  grid-template-columns: minmax(0,1fr) 290px;
  gap: 14px;
  align-items: start;
}
.rel-work-main {
  min-width: 0;
  background: #f1faff;
  border-radius: 12px;
  padding: 12px;
}
.rel-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.rel-toolbar button,.rel-sidepanel button {
  border: 1px solid #a8d2f5;
  background: white;
  border-radius: 8px;
  padding: 9px;
  cursor: pointer;
}
.rel-toolbar button.active,.rel-tabs button.active {
  background: #d2edff;
  border-color: #71afe8;
  font-weight: 700;
}
.rel-color-choice {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
}
.rel-color-choice input {
  width: 32px;
  height: 32px;
  border: 0;
  padding: 0;
}
.rel-toolbar .rel-zoom {
  margin: 0 0 0 auto;
}
.rel-work-main .rel-scroll {
  max-height: 75vh;
}
.rel-sidepanel {
  border: 1px solid #a8d2f5;
  border-radius: 12px;
  padding: 12px;
  background: #ffffff;
  min-height: 400px;
}
.rel-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
}
.rel-tabs button {
  font-size: 12px;
  flex: 1;
  padding: 8px 3px;
}
.rel-sidepanel label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
}
.rel-sidepanel select {
  width: 100%;
  padding: 9px;
  border: 1px solid #a8d2f5;
  border-radius: 8px;
}
.rel-sidepanel #relAddCharacter,.rel-sidepanel #relAddCategory {
  display: block;
  width: 100%;
  margin: 10px 0;
  background: #d2edff;
}
.rel-category-row {
  display: flex;
  gap: 6px;
  align-items: center;
  margin: 8px 0;
}
.rel-category-row input[type=color] {
  width: 38px;
  height: 34px;
  flex-shrink: 0;
}
.rel-category-row input[data-cat-name] {
  min-width: 0;
  flex: 1;
  border: 1px solid #a8d2f5;
  border-radius: 7px;
  padding: 8px;
}
.rel-category-row button {
  padding: 7px 10px;
}
.rel-sidepanel #relNodeList {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-top: 12px;
  max-height: 50vh;
  overflow: auto;
}
.rel-sidepanel #relNodeList button {
  text-align: left;
}
.rel-sidepanel .rel-inspector {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  margin: 0 0 10px;
  padding: 8px;
}
.rel-sidepanel .rel-inspector label {
  align-items: stretch;
}
.rel-sidepanel .rel-inspector input[type=range] {
  width: 100%;
}
.rel-sidepanel #relAddLink {
  width: 100%;
}
.rel-free-text {
  position: absolute;
  z-index: 1;
  white-space: pre-wrap;
  font-size: 20px;
  font-weight: bold;
  pointer-events: auto;
  cursor: pointer;
}
.rel-work-main .rel-canvas {
  background-image: none;
}
@media (max-width:850px) {
  .rel-workspace {
    grid-template-columns: 1fr;
  }
  .rel-sidepanel {
    min-height: 0;
  }
  .rel-work-main {
    padding: 6px;
  }
  .rel-toolbar .rel-zoom {
    margin-left: 0;
  }
}

/* Tighten the gap between body-section divider and its content. */

.profile-modified-date a {
  color: inherit;
  text-decoration: none;
}
.profile-modified-date a:hover {
  text-decoration: underline;
}

/* Reduce the visible gap beneath the section divider, including rich-text paragraph margins. */

.body-section[open] > .body-section-heading {
  margin-bottom: 0 !important;
}
.body-section > .body-content > :first-child {
  margin-top: 0 !important;
}
.body-section > .body-content > p:first-child {
  margin-block-start: 0 !important;
}

/* Restore a modest breathing room under section dividers. */

.body-section > .body-content {
  margin-top: 0 !important;
  padding-top: 9px !important;
}

/* PNG export only: offscreen white document block, no navigation or site background. */

.wiki-png-export {
  position: fixed;
  left: -100000px;
  top: 0;
  z-index: -1;
  background: #ffffff;
  color: #243c5d;
  padding: 22px;
  box-sizing: border-box;
  overflow: visible;
}
.wiki-png-export .profile-layout {
  width: 100%;
}
.wiki-png-export .profile-modified-date {
  margin-top: 16px;
}
.wiki-png-export .rel-canvas {
  position: relative;
  transform: none !important;
}
.export-detail-png {
  white-space: nowrap;
}

/* PNG export: static spoiler labels avoid native details rendering artifacts. */

/* Detail-only presentation: use the document profile color on section outlines. */

/* Right-align the last-updated timestamp inside each list card. */

.character-card .list-modified {
  align-self: flex-end;
  text-align: right;
  width: 100%;
}

/* Keep the original neutral divider, independently of profile color. */

/* Match section borders to the profile card, including the divider. */

#detailView .body-section, #comboDetailView .body-section {
  border-color: var(--section-border-color, var(--line));
  border: 1.5px solid var(--section-border-color, var(--line));
}
#detailView .body-section[open] > .body-section-heading,
#comboDetailView .body-section[open] > .body-section-heading {
  border-bottom: 1px solid var(--section-border-color, var(--line));
}

/* All document creation/editing headings share the same white editor card. */

#editorView > .editor > h2,
#comboEditorView > .editor > h2 {
  font-size: 24px;
  line-height: 1.35;
  margin: 0 0 24px;
  font-weight: 700;
  color: var(--text);
}

/* PNG: remove only the outer document outline; preserve inner profile and section borders. */

.wiki-png-export > article {
  border: 0 !important;
  box-shadow: none !important;
  border-radius: 0 !important;
}
.wiki-png-export .body-section {
  border-width: 1.5px;
  border-style: solid;
  border-color: var(--section-border-color, var(--line));
}
.wiki-png-export .body-section[open] > .body-section-heading {
  border-bottom: 1px solid var(--section-border-color, var(--line));
}

/* Keep rich text and spoiler line metrics consistent in detail and PNG exports.
   Newlines are explicit <br> elements from renderRich(), not browser-specific
   whitespace layout around native details/summary. */

.body-content, .profile-table td,
.wiki-png-export .body-content, .wiki-png-export .profile-table td {
  white-space: pre-wrap;
}
.inline-spoiler, .wiki-png-export .png-spoiler-label {
  line-height: inherit;
  vertical-align: baseline;
}

/* Rich text already renders newlines as explicit <br> elements.
   Avoid pre-wrap processing the same newline twice, in both the live
   document and the html2canvas clone. */

#detailView .body-content, #comboDetailView .body-content,
#detailView .profile-table td, #comboDetailView .profile-table td,
.wiki-png-export .body-content, .wiki-png-export .profile-table td {
  white-space: normal !important;
}

/* Keep spoiler labels inline, with identical line boxes in both views. */

#detailView .inline-spoiler, #comboDetailView .inline-spoiler,
.wiki-png-export .png-spoiler-label {
  display: inline !important;
  vertical-align: baseline !important;
  white-space: normal !important;
}

/* Spoilers use inline spans, so live text and PNG have the same line flow. */

.inline-spoiler {
  display: inline !important;
  white-space: normal !important;
}
.inline-spoiler .spoiler-trigger, .wiki-png-export .png-spoiler-label {
  display: inline !important;
  font-size: .92em !important;
  line-height: inherit !important;
  font-family: inherit !important;
  color: #777777 !important;
  text-decoration: underline;
  text-underline-offset: 2px;
  white-space: nowrap !important;
  vertical-align: baseline !important;
}
.inline-spoiler .spoiler-trigger {
  cursor: pointer;
}
.inline-spoiler .spoiler-revealed[hidden] {
  display: none !important;
}

/* Spoilers form a single line boundary, even if the author typed Enter. */

#detailView .inline-spoiler, #comboDetailView .inline-spoiler,
.wiki-png-export .inline-spoiler {
  display: block !important;
  white-space: normal !important;
  margin: 0 !important;
  padding: 0 !important;
}
.inline-spoiler .spoiler-revealed:not([hidden]) {
  display: block !important;
  margin-top: 3px;
  white-space: normal !important;
}

/* Editing-only badges: generated content never enters the stored JSON. */

#editorView .rich-content .editor-spoiler::before,
#comboEditorView .rich-content .editor-spoiler::before {
  content: "[스포일러] ";
  color: #243c5d;
  font-size: .85em;
  pointer-events: none;
  user-select: none;
}
#editorView .rich-content .editor-character-link::before,
#comboEditorView .rich-content .editor-character-link::before {
  content: "[링크] ";
  color: #243c5d;
  font-size: .85em;
  pointer-events: none;
  user-select: none;
}

/* PNG: closed spoilers occupy the same full line as live detail spoilers. */

.wiki-png-export .png-spoiler-label {
  color: #777777;
  font-size: .92em;
  font-family: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  display: block !important;
  margin: 0 !important;
  padding: 0 !important;
  line-height: inherit !important;
  white-space: nowrap !important;
  text-align: left !important;
}

/* Match the document editor section divider between metadata and categories. */

#relationshipEditorView .rel-category-section {
  border-top: 1px solid var(--line);
  margin-top: 36px;
  padding-top: 30px;
  padding-bottom: 22px;
}
#relationshipEditorView .rel-category-section .editor-section-title h3 {
  margin: 0 0 4px;
  font-size: 17px;
}
#relationshipEditorView .rel-category-section .editor-section-title span {
  color: var(--muted);
  font-size: 12px;
}
