* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
html {
  overscroll-behavior: none;
}
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', sans-serif;
  background: #f5f5f5;
  color: #333;
  overscroll-behavior: none;
}

.screen {
  display: none;
}

.screen.active {
  display: block;
}

/* 検索画面 - 左右分割レイアウト */
.search-screen-split {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.search-left-panel {
  width: 40%;
  min-width: 350px;
  background: #f5f5f5;
  border-right: 1px solid #ddd;
  overflow: hidden;
}

.manual-frame {
  width: 100%;
  height: 100%;
  border: none;
}

.search-right-panel {
  width: 60%;
  min-width: 500px;
  overflow-y: auto;
  background: #f5f5f5;
}

/* 検索画面 */
.search-container {
  max-width: 600px;
  margin: 80px auto;
  padding: 40px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

h1 {
  font-size: 24px;
  margin-bottom: 30px;
  color: #0066cc;
  text-align: center;
}

.search-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-weight: 600;
  font-size: 14px;
  color: #555;
}

.form-group input {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: #0066cc;
}

.selected-info {
  padding: 10px;
  background: #f0f8ff;
  border: 1px solid #b3d9ff;
  border-radius: 4px;
  font-size: 13px;
  color: #333;
  min-height: 20px;
}

.btn-primary {
  padding: 12px 24px;
  background: #0066cc;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 10px;
}

.btn-primary:hover {
  background: #0052a3;
}

.btn-primary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-secondary {
  padding: 12px 24px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 10px;
}

.btn-secondary:hover {
  background: #5a6268;
}

.btn-secondary:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.button-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.btn-secondary-small {
  padding: 10px 16px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-secondary-small:hover {
  background: #5a6268;
}

.btn-secondary-small:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-small {
  padding: 6px 12px;
  background: #0066cc;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-small:hover {
  background: #0052a3;
}

.btn-danger {
  background: #dc3545;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-similar {
  width: 100%;
  padding: 10px;
  background: #28a745;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-bottom: 12px;
}

.btn-similar:hover {
  background: #218838;
}

.btn-similar:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.similar-results {
  margin-bottom: 20px;
}

.similar-group {
  margin-bottom: 20px;
  padding: 12px;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #dee2e6;
}

.similar-group-title {
  font-size: 13px;
  font-weight: 600;
  color: #495057;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #dee2e6;
}

.similar-item {
  display: flex;
  gap: 10px;
  padding: 8px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  margin-bottom: 8px;
  transition: box-shadow 0.2s;
}

.similar-item:hover {
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.similar-item-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  flex-shrink: 0;
  cursor: pointer;
}

.similar-item-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.similar-item-score {
  font-size: 12px;
  font-weight: 600;
  color: #28a745;
}

.similar-item-url {
  font-size: 11px;
  color: #0066cc;
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.similar-item-url:hover {
  text-decoration: underline;
}

.similar-item-date {
  font-size: 11px;
  color: #6c757d;
}

.similar-loading {
  text-align: center;
  padding: 20px;
  color: #6c757d;
}

.status-message {
  text-align: center;
  padding: 10px;
  border-radius: 4px;
  font-size: 14px;
  min-height: 20px;
}

.status-message.loading {
  background: #fff3cd;
  color: #856404;
}

.status-message.success {
  background: #d4edda;
  color: #155724;
}

.status-message.error {
  background: #f8d7da;
  color: #721c24;
}

.status-message.info {
  background: #d1ecf1;
  color: #0c5460;
}

/* メイン画面 */
#main-screen {
  height: 100vh;
  overflow: hidden;
}

#main-screen.active {
  display: flex;
}

.sidebar {
  width: 60px;
  background: #0066cc;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 0;
  gap: 20px;
  flex-shrink: 0;
}

.sidebar-btn {
  width: 40px;
  height: 40px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  position: relative;
  color: white;
}

.sidebar-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.sidebar-btn svg {
  pointer-events: none;
}

.sidebar-tooltip {
  position: absolute;
  left: 60px;
  background: #333;
  color: white;
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 1000;
}

.sidebar-tooltip::before {
  content: '';
  position: absolute;
  left: -6px;
  top: 50%;
  transform: translateY(-50%);
  border: 6px solid transparent;
  border-right-color: #333;
}

.sidebar-btn:hover .sidebar-tooltip {
  opacity: 1;
}

.sidebar-btn.active {
  background: rgba(255, 255, 255, 0.3);
}

.links-panel {
  position: fixed;
  left: 60px;
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.18);
  z-index: 10000;
  padding: 6px 0;
  min-width: 260px;
  overflow: hidden;
}

.links-panel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  text-decoration: none;
  color: #333;
  font-size: 13px;
  transition: background 0.15s;
}

.links-panel-item:hover {
  background: #f0f7ff;
  color: #0066cc;
}

.links-panel-favicon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.main-layout {
  display: grid;
  grid-template-columns: 350px 1fr 532px minmax(200px, 300px);
  height: 100vh;
  gap: 1px;
  background: #ddd;
  flex: 1;
}

.column {
  background: white;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  overflow: hidden;
}

.column h3 {
  font-size: 16px;
  margin: 0;
  padding: 0;
  background: white;
  z-index: 10;
  flex: 0 0 auto;
  display: flex;
}

.column-list h3 {
  padding: 0;
  border: none;
}

.column:not(.column-list) h3 {
  padding: 16px 16px 8px 16px;
  border-bottom: 2px solid #0066cc;
  align-items: center;
  gap: 8px;
}

.column-references h3 {
  justify-content: space-between;
  padding: 12px 6px 8px 16px; /* 上パディングを少し減らす */
  border-bottom: 2px solid #0066cc;
  margin: 0; /* デフォルトマージンを削除 */
}

.ref-header-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.ref-action-btn {
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}

.ref-action-btn svg {
  stroke: #666;
  fill: none;
  transition: all 0.2s;
}

.ref-action-btn:hover svg {
  stroke: #333;
}

.ref-action-btn.active svg {
  stroke: #0066cc;
  fill: none;
}

/* メモタブ横の＋ボタン（notes-tabs-container内で使用） */
.btn-toggle-add {
  width: 20px;
  height: 20px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 50%;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.btn-back {
  padding: 6px 12px;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}

.btn-back:hover {
  background: #5a6268;
}

.column h4 {
  font-size: 14px;
  margin: 16px 0 8px 0;
  color: #555;
}

/* 案件リスト */
.column-list {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 図面カラム */
.column-images {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* 案件情報カラム */
.column-info {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

/* 参考文献カラム */
.column-references {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 6px 8px 16px; /* 案件一覧と同じ左右パディング */
  gap: 8px;
  border-bottom: 2px solid #0066cc;
}

.list-header h3 {
  margin: 0;
  flex: 1;
}

.list-header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.sort-toggle-btn,
.search-toggle-btn,
.filter-toggle-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  position: relative;
  justify-content: center;
  transition: all 0.2s;
}

.sort-toggle-btn svg,
.search-toggle-btn svg,
.filter-toggle-btn svg {
  stroke: #666;
  fill: none;
  transition: all 0.2s;
}

.sort-toggle-btn:hover svg,
.search-toggle-btn:hover svg,
.filter-toggle-btn:hover svg {
  stroke: #333;
}

.sort-toggle-btn.active svg,
.search-toggle-btn.active svg,
.filter-toggle-btn.active svg {
  stroke: #0066cc;
  fill: #0066cc;
}

.sort-panel {
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.sort-panel.open {
  display: flex;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.sort-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sort-section h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.sort-radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* 順序（昇順・降順）のトグルボタンスタイル */
.sort-section:first-child .sort-radio-group {
  flex-direction: row;
  gap: 0;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

.sort-section:first-child .sort-radio-item {
  flex: 1;
  margin: 0;
  padding: 8px 12px;
  text-align: center;
  border-right: 1px solid #ddd;
  background: white;
  transition: all 0.2s;
}

.sort-section:first-child .sort-radio-item:last-child {
  border-right: none;
}

.sort-section:first-child .sort-radio-item:has(input:checked) {
  background: #0066cc;
  color: white;
}

.sort-section:first-child .sort-radio-item:hover {
  background: #f0f0f0;
}

.sort-section:first-child .sort-radio-item:has(input:checked):hover {
  background: #0052a3;
}

/* ソート項目の選択スタイル */
.sort-radio-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: 4px;
  background: white;
  border: 1px solid #ddd;
  transition: all 0.2s;
  user-select: none;
}

.sort-radio-item:hover {
  background: #f0f0f0;
}

.sort-radio-item:has(input:checked) {
  background: #e6f2ff;
  border-color: #0066cc;
  color: #0066cc;
  font-weight: 600;
}

.sort-radio-item input[type="radio"] {
  display: none;
}

.sort-radio-item span {
  user-select: none;
}

.sort-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #ddd;
}

.search-panel {
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.search-panel.open {
  display: flex;
  animation: slideDown 0.3s ease-out;
}

.search-keyword-input {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  width: 100%;
  transition: border-color 0.2s;
}

.search-keyword-input:focus {
  outline: none;
  border-color: #0066cc;
}

.search-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #ddd;
}

.filter-panel {
  padding: 12px 16px;
  background: #f8f9fa;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

.filter-panel.open {
  display: flex;
  animation: slideDown 0.3s ease-out;
}

.filter-section {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}

.filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  flex-shrink: 0;
}

.filter-section h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.filter-section-actions {
  display: flex;
  gap: 8px;
}

.filter-action-btn {
  background: none;
  border: none;
  padding: 2px 6px;
  font-size: 11px;
  color: #0066cc;
  cursor: pointer;
  text-decoration: underline;
  transition: color 0.2s;
}

.filter-action-btn:hover {
  color: #0052a3;
}

.filter-checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px;
  max-height: 150px;
  overflow-y: auto;
}

.filter-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  cursor: pointer;
  padding: 2px;
}

.filter-checkbox-item input[type="checkbox"] {
  cursor: pointer;
  flex-shrink: 0;
}

.filter-checkbox-item label {
  cursor: pointer;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.filter-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #ddd;
}

.btn-primary-small {
  padding: 6px 12px;
  background: #0066cc;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-primary-small:hover {
  background: #0052a3;
}

.design-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 6px 16px 16px; /* 右側のパディングを10px減らす（スクロールバー幅分） */
  flex: 1;
  overflow-y: scroll; /* 常にスクロールバー表示 */
}

.design-item {
  min-height: 120px;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
  overflow: hidden;
}

.design-item:hover {
  background: #f8f9fa;
  border-color: #0066cc;
}

.design-item.active {
  background: #e3f2fd;
  border-color: #0066cc;
  border-width: 2px;
}

.design-item-content {
  display: flex;
  height: 100%;
  padding: 12px;
  gap: 12px;
}

.design-item-left {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.design-item-right {
  width: 100px;
  height: 96px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.design-item-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  position: relative;
}

.design-item-number {
  font-weight: 600;
  font-size: 14px;
  color: #0066cc;
  flex: 0 0 auto;
}

.design-item-header .judgment-label {
  margin-left: auto;
  margin-top: 0;
  flex: 0 0 auto;
}

.design-item-link {
  color: #0066cc;
  text-decoration: none;
  display: flex;
  align-items: center;
  padding: 2px;
  border-radius: 3px;
  transition: background 0.2s;
  flex: 0 0 auto;
}

.design-item-link:hover {
  background: rgba(0, 102, 204, 0.1);
}

.design-item-link svg {
  display: block;
}

.design-item-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
  background: #f5f5f5;
}

.design-item-no-image {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 4px;
  font-size: 11px;
  color: #999;
}

.design-item-loading {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 4px;
  gap: 8px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e0e0e0;
  border-top-color: #0066cc;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-text {
  font-size: 10px;
  color: #999;
  text-align: center;
}

.design-item-info {
  font-size: 12px;
  color: #666;
  line-height: 1.3;
  flex: 1;
  overflow: hidden;
  padding-left: 0.5em;
}

.design-item-info > div {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.judgment-label {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 11px;
  font-weight: 600;
  margin-top: 4px;
  white-space: nowrap;
}

.judgment-label.registered {
  background-color: #d1ecf1;
  color: #0c5460;
}

.judgment-label.rejected {
  background-color: #f8d7da;
  color: #721c24;
}

/* 画像パネル */
.column-images {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.images-panel {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 8px;
  padding: 16px 6px 16px 16px; /* 右側のパディングを10px減らす（スクロールバー幅分） */
  align-items: start;
  grid-auto-rows: min-content;
  flex: 1;
  overflow-y: scroll; /* 常にスクロールバー表示 */
}

.design-separator {
  grid-column: 1 / -1;
  font-weight: 600;
  font-size: 14px;
  color: #0066cc;
  padding: 12px 0 8px 0;
  margin-top: 8px;
  border-top: 2px solid #e0e0e0;
}

.design-separator:first-child {
  margin-top: 0;
  border-top: none;
}

.image-item {
  background: #f5f5f5;
  border-radius: 4px;
  padding: 4px;
  border: 1px solid #e0e0e0;
  position: relative;
  aspect-ratio: 1 / 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: auto;
}

.image-item img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.image-item img:hover {
  transform: scale(1.05);
}

.image-item .composite-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.image-item .composite-canvas:hover {
  transform: scale(1.05);
}

.image-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: #999;
  background: rgba(255, 255, 255, 0.9);
  padding: 8px 16px;
  border-radius: 4px;
  pointer-events: none;
}

.image-error-403 {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 12px;
  color: #dc3545;
  background: rgba(255, 255, 255, 0.95);
  padding: 8px 16px;
  border-radius: 4px;
  font-weight: 600;
  pointer-events: none;
  border: 1px solid #dc3545;
}

/* 案件情報パネル */
.info-panel {
  flex: 0 0 auto;
  font-size: 14px;
  line-height: 1.8;
  padding: 16px;
}

.info-table {
  width: 100%;
  border-collapse: collapse;
}

.info-table th {
  font-weight: 600;
  color: #555;
  text-align: left;
  padding: 4px 4px;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
  width: 60px;
}

.info-table td {
  padding: 4px 4px;
  border-bottom: 1px solid #f0f0f0;
}

.info-panel .info-value {
  color: #333;
  word-break: break-word;
}

/* .column-references > div のパディングは削除（個別設定） */

#design-toggle-section {
  flex: 0 0 auto;
  padding: 8px 16px;
  display: grid;
  gap: 8px;
}

.design-toggle-btn {
  padding: 8px 12px;
  background: #e9ecef;
  color: #495057;
  border: 1px solid #ced4da;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.design-toggle-btn:hover {
  background: #dee2e6;
}

.design-toggle-btn.active {
  background: #0066cc;
  color: white;
  border-color: #0052a3;
}

#judgment-section {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  padding: 8px 16px ;
  padding-bottom: 8px;
}

#judgment-section h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: #555;
}

.judgment-labels {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.judgment-label-item {
  padding: 3px 6px;
  background: #f0f0f0;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  user-select: none;
  transition: all 0.2s;
}

.judgment-label-item:hover {
  background: #e0e0e0;
  border-color: #bbb;
}

.judgment-label-item.selected-registered {
  background: #cce5ff;
  border-color: #66b3ff;
  color: #0066cc;
  font-weight: 600;
}

.judgment-label-item.selected-rejected {
  background: #ffe6e6;
  border-color: #ffb3b3;
  color: #cc0000;
  font-weight: 600;
}

#notes-section {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  min-height: 0;
  overflow: hidden;
}

/* タブコンテナの親要素 */
.notes-tabs-container {
  position: relative;
  flex: 0 0 auto;
  margin-bottom: 8px;
}

/* タブコンテナ */
.notes-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 2px solid #ddd;
  padding-right: 30px;
}

.notes-tabs::-webkit-scrollbar {
  height: 6px;
}

.notes-tabs::-webkit-scrollbar-thumb {
  background: #ccc;
  border-radius: 3px;
}

.notes-tabs .placeholder {
  padding: 8px;
  color: #999;
  font-size: 13px;
}

/* 個別タブ */
.note-tab {
  flex: 1 1 0;
  min-width: 80px;
  max-width: 200px;
  padding: 8px 12px;
  background: #f5f5f5;
  border: 1px solid #ddd;
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 13px;
  position: relative;
  height: 36px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

/* タブ横の＋ボタン */
.notes-tabs-container .btn-toggle-add {
  position: absolute;
  right: 4px;
  bottom: 10px;
  z-index: 10;
}

.note-tab:hover {
  background: #e8e8e8;
}

.note-tab.active {
  background: white;
  font-weight: 600;
  border-color: #0066cc;
}

/* タブタイトル編集用input */
.note-tab-input {
  width: 100%;
  border: 1px solid #0066cc;
  border-radius: 2px;
  padding: 2px 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
  background: white;
}

/* Quillエディタ */
#notes-editor {
  height: calc(100% - 85px);
  display: flex;
  flex-direction: column;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  overflow: hidden;
}

#notes-editor .ql-toolbar.ql-snow {
  border: none !important;
  background: white;
  padding: 8px;
  flex: 0 0 auto;
}

#notes-editor .ql-container {
  flex: 1;
  border: none;
  font-size: 14px;
  font-family: inherit;
  overflow: hidden; /* コンテナのスクロールを無効化 */
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

#notes-editor .ql-editor {
  padding: 12px 5px 12px 15px; /* 右側のパディングを10px減らす */
  box-sizing: border-box;
  overflow-y: scroll !important; /* エディタ自体をスクロール可能に */
  flex: 1;
  min-height: 0;
}

#notes-editor .ql-editor.ql-blank::before {
  color: #999;
  font-style: normal;
  left: 15px;
}

/* 参考文献パネル */
.column-references {
  display: flex;
  flex-direction: column;
}

.add-reference {
  display: none;
  flex-direction: column;
  gap: 8px;
  padding: 0 6px 16px 16px; /* 案件一覧と同じパディング */
  background: white;
  flex: 0 0 auto;
}

.references-list {
  flex: 1;
  overflow-y: scroll; /* 常にスクロールバー表示 */
  padding: 16px 6px 16px 16px; /* 案件一覧と同じパディング */
  min-height: 0;
}

/* インライン編集フォーム */
.reference-item-edit {
  padding: 12px;
  background: #fff;
  border-radius: 4px;
  border: 2px solid #0066cc;
  margin-bottom: 8px;
}

.reference-item-edit:first-child {
  margin-top: 8px;
}

.reference-edit-field {
  margin-bottom: 8px;
}

.reference-edit-field:last-of-type {
  margin-bottom: 12px;
}

.reference-edit-field label {
  display: block;
  font-size: 11px;
  color: #666;
  margin-bottom: 4px;
  font-weight: 600;
}

.reference-edit-field input[type="text"],
.reference-edit-field input[type="url"],
.reference-edit-field input[type="date"] {
  width: 100%;
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}

.reference-edit-field input:focus {
  outline: none;
  border-color: #0066cc;
}

.reference-edit-image-area {
  margin-top: 8px;
}

.reference-edit-image-upload {
  padding: 8px;
  border: 2px dashed #ddd;
  border-radius: 4px;
  text-align: center;
  cursor: pointer;
  font-size: 12px;
  color: #666;
  transition: all 0.2s;
}

.reference-edit-image-upload:hover {
  border-color: #0066cc;
  color: #0066cc;
}

.reference-edit-image-upload.drag-over {
  border-color: #0066cc;
  background: #f0f8ff;
}

.reference-edit-image-preview {
  max-width: 100%;
  max-height: 150px;
  border-radius: 4px;
  margin-top: 8px;
  display: block;
}

.reference-edit-image-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.reference-edit-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.add-reference input,
.add-reference textarea {
  width: 100%;
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
}

.add-reference input:focus,
.add-reference textarea:focus {
  outline: none;
  border-color: #0066cc;
}

.add-reference-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.image-upload-area {
  border: 2px dashed #ddd;
  border-radius: 4px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s;
  background: white;
}

.image-upload-area:hover {
  border-color: #0066cc;
}

.image-upload-area.drag-over {
  border-color: #0066cc;
  background: #f0f8ff;
}

.image-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
  margin-top: 8px;
}

.reference-item {
  padding: 12px;
  background: #f8f9fa;
  border-radius: 4px;
  border: 1px solid #e0e0e0;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  margin-bottom: 8px;
  cursor: pointer;
  transition: background 0.2s;
}

.reference-item:first-child {
  margin-top: 0; /* 最初のアイテムの上マージンを削除 */
}

.reference-item:hover {
  background: #e9ecef;
}

.reference-item.sortable-ghost {
  opacity: 0.4;
  background: #d0d0d0;
}

.reference-item.sortable-drag {
  opacity: 1;
  background: white;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.reference-item-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
}

.reference-star {
  cursor: pointer;
  flex-shrink: 0;
  margin-left: 8px;
  transition: all 0.2s;
}

.reference-star svg {
  stroke: #666;
  fill: none;
  transition: all 0.2s;
}

.reference-star.starred svg {
  stroke: #0066cc;
  fill: #0066cc;
}

.reference-star:hover svg {
  stroke: #0066cc;
}

.reference-title {
  font-weight: 600;
  font-size: 13px;
  color: #333;
  word-break: break-word;
  flex: 1;
}

.reference-title-link {
  font-weight: 600;
  font-size: 13px;
  color: #0066cc;
  text-decoration: none;
  word-break: break-word;
  flex: 1;
}

.reference-title-link:hover {
  text-decoration: underline;
}

.reference-date {
  font-size: 11px;
  color: #666;
  margin-bottom: 4px;
}

.reference-image-container {
  margin-top: 8px;
  display: flex;
  justify-content: flex-start;
}

.reference-image {
  max-width: 100%;
  max-height: 150px;
  border-radius: 4px;
  cursor: pointer;
}

.reference-image:hover {
  opacity: 0.8;
}

.reference-delete {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 3px;
  padding: 4px 8px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.2s;
}

.reference-delete:hover {
  background: #c82333;
}

.placeholder {
  text-align: center;
  color: #999;
  padding: 40px 20px;
  font-size: 14px;
}

/* 画像モーダル */
.image-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.8);
  cursor: pointer;
}

.image-modal-toolbar {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: white;
  border-radius: 8px;
  padding: 12px 20px;
  display: flex;
  gap: 20px;
  align-items: center;
  z-index: 10001;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toolbar-group label {
  font-size: 13px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
}

.toolbar-slider {
  width: 100px;
  cursor: pointer;
}

.toolbar-group span {
  font-size: 12px;
  color: #666;
  min-width: 30px;
}

.color-picker-wrapper {
  position: relative;
}

.current-color {
  width: 30px;
  height: 30px;
  border: 2px solid #333;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.current-color:hover {
  transform: scale(1.1);
}

.color-palette {
  position: absolute;
  top: 40px;
  left: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 8px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 10002;
}

.color-option {
  width: 30px;
  height: 30px;
  border: 2px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.2s;
}

.color-option:hover {
  transform: scale(1.15);
  border-color: #333;
}

.toolbar-buttons {
  gap: 8px;
  margin-left: 12px;
}

.toolbar-btn {
  padding: 6px 12px;
  background: #f0f0f0;
  color: #333;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  min-width: 100px;
  text-align: center;
}

.toolbar-btn:hover {
  background: #e0e0e0;
}

.toolbar-btn-primary {
  background: #0066cc;
  color: white;
  border-color: #0052a3;
}

.toolbar-btn-primary:hover {
  background: #0052a3;
}

.image-modal-content {
  position: relative;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.canvas-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  width: 90vw;
  height: calc(90vh - 100px);
}

.modal-background-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.canvas-container .canvas-wrapper {
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
}

#modal-canvas {
  border-radius: 4px;
  cursor: crosshair;
  transform-origin: top left;
}

#modal-canvas.hidden {
  opacity: 0;
  pointer-events: none;
}


/* スクロールバーのスタイル - 半透明 */
.column::-webkit-scrollbar,
.design-list::-webkit-scrollbar,
.images-panel::-webkit-scrollbar,
.ql-editor::-webkit-scrollbar,
.references-list::-webkit-scrollbar {
  width: 10px;
}

.column::-webkit-scrollbar-track,
.design-list::-webkit-scrollbar-track,
.images-panel::-webkit-scrollbar-track,
.ql-editor::-webkit-scrollbar-track,
.references-list::-webkit-scrollbar-track {
  background: transparent;
}

.column::-webkit-scrollbar-thumb,
.design-list::-webkit-scrollbar-thumb,
.images-panel::-webkit-scrollbar-thumb,
.ql-editor::-webkit-scrollbar-thumb,
.references-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: padding-box;
}

.column::-webkit-scrollbar-thumb:hover,
.design-list::-webkit-scrollbar-thumb:hover,
.images-panel::-webkit-scrollbar-thumb:hover,
.ql-editor::-webkit-scrollbar-thumb:hover,
.references-list::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.4);
  background-clip: padding-box;
}

/* Firefox用のスクロールバースタイル */
.design-list,
.images-panel,
.references-list,
#notes-editor .ql-container {
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.2) transparent;
}

/* 右クリックメニュー */
.context-menu {
  position: fixed;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  z-index: 10000;
  min-width: 140px;
  overflow: hidden;
}

.context-menu-item {
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s;
  color: #333;
  border-bottom: 1px solid #f0f0f0;
}

.context-menu-item:last-child {
  border-bottom: none;
}

.context-menu-item:hover {
  background: #f0f0f0;
}

.context-menu-item:active {
  background: #e0e0e0;
}

#context-delete {
  color: #dc3545;
}

#context-delete:hover {
  background: #fff5f5;
}

/* モーダル */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
}

.modal-content {
  position: relative;
  background: white;
  border-radius: 8px;
  padding: 24px;
  min-width: 400px;
  max-width: 500px;
  z-index: 10000;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.modal-content h3 {
  margin-bottom: 20px;
  font-size: 18px;
  color: #333;
}

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-input {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
}

.modal-input:focus {
  outline: none;
  border-color: #0066cc;
}

.ref-edit-image-area {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-start;
}

.ref-edit-image-preview {
  max-width: 100%;
  max-height: 200px;
  border-radius: 4px;
  border: 1px solid #ddd;
}

.form-row label {
  font-size: 14px;
  font-weight: 600;
  color: #555;
}

.rename-before {
  padding: 10px;
  background: #f8f9fa;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
}

.rename-input {
  padding: 10px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.2s;
}

.rename-input:focus {
  outline: none;
  border-color: #0066cc;
}

.delete-confirm-text {
  padding: 16px;
  background: #fff3cd;
  border: 1px solid #ffc107;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
  text-align: center;
}

.modal-buttons {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  margin-top: 8px;
}

.btn-danger {
  padding: 10px 20px;
  background: #dc3545;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-danger:active {
  background: #bd2130;
}

/* Quillエディタのツールバー枠線を削除 */
.ql-toolbar.ql-snow {
  border: none !important;
}

/* 参考文献再利用パネル */
.reuse-ref-panel {
  background: #f8f9fa;
  border-bottom: 1px solid #ddd;
  display: none;
  flex-direction: column;
  flex-shrink: 0;
  max-height: 320px;
}

.reuse-ref-panel.open {
  display: flex;
  animation: slideDown 0.3s ease-out;
}

.reuse-ref-list {
  overflow-y: auto;
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.reuse-ref-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: 4px;
  cursor: pointer;
}

.reuse-ref-item:hover {
  background: #e8f0fb;
}

.reuse-ref-item input[type="checkbox"] {
  flex-shrink: 0;
  cursor: pointer;
}

.reuse-ref-item-thumb {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
  border-radius: 3px;
  background: #eee;
}

.reuse-ref-item-thumb-placeholder {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: #eee;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  color: #999;
}

.reuse-ref-item-name {
  font-size: 12px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reuse-ref-footer {
  padding: 8px;
  border-top: 1px solid #ddd;
  display: flex;
  justify-content: flex-end;
}

/* ボタン共通ツールチップ */
.btn-tooltip-text {
  position: absolute;
  top: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 5px 9px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 10003;
}

.btn-tooltip-text::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-bottom-color: #333;
}

.sort-toggle-btn:hover .btn-tooltip-text,
.search-toggle-btn:hover .btn-tooltip-text,
.filter-toggle-btn:hover .btn-tooltip-text,
.ref-action-btn:hover .btn-tooltip-text,
.btn-toggle-add:hover .btn-tooltip-text {
  opacity: 1;
}

