/* ========================================
 * 小説コメントシステム
 * テキスト選択コメント + 画像コメント + パネル
 * ライト/ダーク両テーマ対応
 * ======================================== */

/* --- テキストハイライト --- */
.nc-highlight {
  background: rgba(196, 163, 90, 0.3);
  border-radius: 2px;
  cursor: pointer;
  transition: background 0.2s;
}
.nc-highlight:hover {
  background: rgba(196, 163, 90, 0.5);
}
.nc-highlight.nc-flash {
  animation: nc-flash 1.5s ease;
}
@keyframes nc-flash {
  0%, 100% { background: rgba(196, 163, 90, 0.3); }
  25%, 75% { background: rgba(196, 163, 90, 0.7); }
}

/* --- テキスト選択時の追加ボタン --- */
.nc-add-btn {
  position: fixed;
  z-index: 9996;
  background: #2a2040;
  color: #e0d8c8;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  border: 1px solid rgba(196, 163, 90, 0.3);
  user-select: none;
  -webkit-user-select: none;
  transition: all 0.2s;
  white-space: nowrap;
  font-family: 'Noto Sans JP', sans-serif;
}
.nc-add-btn:hover {
  background: #3a2d55;
  border-color: #c4a35a;
}

/* --- モーダル --- */
.nc-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.nc-modal {
  background: #1a1a2e;
  border: 1px solid rgba(196, 163, 90, 0.2);
  border-radius: 12px;
  padding: 24px;
  max-width: 480px;
  width: 90%;
  color: #d0d0e0;
  box-shadow: 0 16px 48px rgba(0,0,0,0.5);
  font-family: 'Noto Sans JP', sans-serif;
}
.nc-modal h3 {
  font-size: 1rem;
  margin-bottom: 16px;
  color: #c4a35a;
  font-weight: 600;
}
.nc-modal-snippet {
  background: rgba(255,255,255,0.05);
  border-left: 3px solid #c4a35a;
  padding: 10px 14px;
  border-radius: 0 6px 6px 0;
  font-size: 0.85rem;
  color: #a0a0b0;
  margin-bottom: 16px;
  max-height: 120px;
  overflow-y: auto;
  line-height: 1.6;
  word-break: break-word;
}
.nc-modal-img-preview {
  max-width: 200px;
  max-height: 150px;
  border-radius: 6px;
  margin-bottom: 16px;
  border: 1px solid rgba(255,255,255,0.1);
  display: block;
}
.nc-modal textarea {
  width: 100%;
  min-height: 100px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px;
  padding: 12px;
  color: #e0e0e8;
  font-size: 0.9rem;
  font-family: inherit;
  resize: vertical;
  line-height: 1.6;
}
.nc-modal textarea:focus {
  outline: none;
  border-color: #c4a35a;
}
.nc-modal-btns {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 16px;
}

/* --- ボタン共通 --- */
.nc-btn {
  padding: 8px 20px;
  border-radius: 6px;
  font-size: 0.85rem;
  cursor: pointer;
  border: none;
  font-family: 'Noto Sans JP', sans-serif;
  transition: all 0.2s;
}
.nc-btn-primary {
  background: #c4a35a;
  color: #1a1a2e;
  font-weight: 600;
}
.nc-btn-primary:hover { background: #d4b36a; }
.nc-btn-secondary {
  background: transparent;
  color: #888;
  border: 1px solid rgba(255,255,255,0.12);
}
.nc-btn-secondary:hover { border-color: #888; color: #bbb; }
.nc-btn-danger {
  background: transparent;
  color: #e74c3c;
  border: 1px solid rgba(231, 76, 60, 0.3);
}
.nc-btn-danger:hover { background: rgba(231, 76, 60, 0.1); }
.nc-btn-sm {
  padding: 6px 14px;
  font-size: 0.78rem;
}

/* --- ハイライトクリック時のポップアップ --- */
.nc-popup {
  position: fixed;
  z-index: 9996;
  background: #1a1a2e;
  border: 1px solid rgba(196, 163, 90, 0.2);
  border-radius: 10px;
  padding: 14px;
  max-width: 320px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  color: #d0d0e0;
  font-family: 'Noto Sans JP', sans-serif;
}
.nc-popup-comment {
  font-size: 0.85rem;
  line-height: 1.6;
  margin-bottom: 10px;
  word-break: break-word;
}
.nc-popup-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.nc-popup-actions button {
  padding: 4px 12px;
  border-radius: 4px;
  font-size: 0.75rem;
  cursor: pointer;
  border: none;
  font-family: 'Noto Sans JP', sans-serif;
  transition: all 0.2s;
}
.nc-popup-btn-edit {
  background: rgba(196, 163, 90, 0.15);
  color: #c4a35a;
}
.nc-popup-btn-edit:hover { background: rgba(196, 163, 90, 0.3); }
.nc-popup-btn-delete {
  background: rgba(231, 76, 60, 0.1);
  color: #e74c3c;
}
.nc-popup-btn-delete:hover { background: rgba(231, 76, 60, 0.2); }

/* --- 画像コメント --- */
.nc-img-wrapper {
  position: relative;
  display: inline-block;
}
.nc-img-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(26, 26, 46, 0.85);
  color: #c4a35a;
  border: 1px solid rgba(196, 163, 90, 0.3);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
}
.nc-img-wrapper:hover .nc-img-btn,
.nc-img-btn.nc-has-comment {
  opacity: 1;
}
.nc-img-btn:hover {
  background: rgba(26, 26, 46, 0.95);
  border-color: #c4a35a;
  transform: scale(1.1);
}
.nc-img-btn.nc-has-comment {
  background: #c4a35a;
  color: #1a1a2e;
  border-color: #c4a35a;
}

/* --- パネルトグルボタン --- */
.nc-panel-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9990;
  background: #2a2040;
  color: #c4a35a;
  border: 1px solid rgba(196, 163, 90, 0.3);
  border-radius: 50%;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  transition: all 0.3s;
  font-family: sans-serif;
}
.nc-panel-toggle:hover {
  background: #3a2d55;
  transform: scale(1.05);
}
.nc-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #c4a35a;
  color: #1a1a2e;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* --- コメントパネル --- */
.nc-panel {
  position: fixed;
  top: 0;
  right: -400px;
  z-index: 9995;
  width: 380px;
  max-width: 90vw;
  height: 100vh;
  background: #12121e;
  border-left: 1px solid rgba(196, 163, 90, 0.15);
  box-shadow: -8px 0 32px rgba(0,0,0,0.4);
  transition: right 0.3s ease;
  display: flex;
  flex-direction: column;
  color: #d0d0e0;
  font-family: 'Noto Sans JP', sans-serif;
}
.nc-panel.nc-open {
  right: 0;
}
.nc-panel-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.nc-panel-header h3 {
  font-size: 0.95rem;
  color: #c4a35a;
  margin: 0;
  font-weight: 600;
}
.nc-panel-close {
  background: none;
  border: none;
  color: #888;
  font-size: 1.2rem;
  cursor: pointer;
  padding: 4px 8px;
  line-height: 1;
}
.nc-panel-close:hover { color: #ddd; }
.nc-panel-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.nc-panel-empty {
  text-align: center;
  color: #555;
  padding: 40px 20px;
  font-size: 0.85rem;
  line-height: 1.8;
}
.nc-panel-item {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
  transition: border-color 0.2s;
  cursor: pointer;
}
.nc-panel-item:hover {
  border-color: rgba(196, 163, 90, 0.3);
}
.nc-panel-item.nc-orphaned {
  border-color: rgba(231, 76, 60, 0.3);
}
.nc-panel-item-type {
  font-size: 0.7rem;
  color: #888;
  margin-bottom: 6px;
}
.nc-panel-item.nc-orphaned .nc-panel-item-type::after {
  content: ' (位置不明)';
  color: #e74c3c;
}
.nc-panel-item-snippet {
  font-size: 0.8rem;
  color: #a0a0b0;
  margin-bottom: 8px;
  padding: 6px 10px;
  background: rgba(255,255,255,0.03);
  border-left: 2px solid #c4a35a;
  border-radius: 0 4px 4px 0;
  max-height: 60px;
  overflow: hidden;
  line-height: 1.5;
  word-break: break-word;
}
.nc-panel-item-comment {
  font-size: 0.85rem;
  line-height: 1.6;
  color: #d0d0e0;
  word-break: break-word;
}
.nc-panel-item-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}
.nc-panel-item-time {
  font-size: 0.7rem;
  color: #555;
}
.nc-panel-item-delete {
  background: none;
  border: none;
  color: #666;
  font-size: 0.7rem;
  cursor: pointer;
  padding: 2px 6px;
  font-family: 'Noto Sans JP', sans-serif;
}
.nc-panel-item-delete:hover { color: #e74c3c; }
.nc-panel-footer {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* --- レスポンシブ --- */
@media (max-width: 767px) {
  .nc-panel {
    width: 100vw;
    max-width: 100vw;
    right: -100vw;
  }
  .nc-panel.nc-open { right: 0; }
  .nc-panel-toggle {
    bottom: 16px;
    right: 16px;
    width: 42px;
    height: 42px;
    font-size: 1rem;
  }
  .nc-add-btn {
    font-size: 0.75rem;
    padding: 5px 12px;
  }
  .nc-modal {
    width: 95%;
    padding: 20px;
  }
  .nc-popup {
    max-width: 280px;
  }
  .nc-img-btn {
    opacity: 1;
    width: 32px;
    height: 32px;
    font-size: 0.8rem;
  }
}
