/* PAN GIF 제작기 계열 버튼 톤 */
.btn,
.icon-btn,
.chip {
  border-color: #e4e6ee;
  background: #f0f2f6;
  color: #485266;
  box-shadow: none;
}

.btn:hover,
.icon-btn:hover,
.chip:hover {
  border-color: #d9d5ff;
  background: #ece9ff;
  color: #5148cf;
}

.btn.primary,
.pan-edit-toggle.is-editing {
  border-color: #635bff;
  background: #635bff;
  color: #fff;
}

.btn.primary:hover,
.pan-edit-toggle.is-editing:hover {
  border-color: #5148cf;
  background: #5148cf;
  color: #fff;
}

.chip.active {
  border-color: #d9d5ff;
  background: #ece9ff;
  color: #5148cf;
}

.pan-edit-controls {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}

.pan-collapse-all {
  background: #f0f2f6;
}

/* 편집 버튼을 누르기 전에는 보기 기능만 노출 */
body:not(.edit-mode) #addLinkBtn,
body:not(.edit-mode) #bulkAddBtn,
body:not(.edit-mode) #addCategoryBtn,
body:not(.edit-mode) #backupBtn,
body:not(.edit-mode) #importBtn,
body:not(.edit-mode) #duplicatesBtn,
body:not(.edit-mode) #installBtn,
body:not(.edit-mode) .toolbar-divider,
body:not(.edit-mode) .category-actions,
body:not(.edit-mode) .group-actions,
body:not(.edit-mode) .link-actions,
body:not(.edit-mode) .add-inline,
body:not(.edit-mode) .drag-handle,
body:not(.edit-mode) .mobile-nav [data-mobile-action="add"] {
  display: none !important;
}

body:not(.edit-mode) .link-row,
body:not(.edit-mode) .category-card {
  cursor: default;
}

body.edit-mode .link-row {
  cursor: pointer;
}

body.edit-mode .link-row:hover {
  background: #f0efff;
  outline: 1px solid #ddd9ff;
}

body.edit-mode .link-actions,
body.edit-mode .group-actions {
  opacity: 1;
}

body.edit-mode .status-dot {
  background: #635bff;
  box-shadow: 0 0 0 4px rgba(99, 91, 255, .12);
}

.pan-group-collapse {
  flex: 0 0 auto;
  margin-left: auto;
  color: #6c7485;
}

.group-head .pan-group-collapse + .group-actions {
  margin-left: 2px;
}

.group.pan-group-collapsed .link-list {
  display: none;
}

.group.pan-group-collapsed {
  padding-bottom: 2px;
}

.group.pan-group-collapsed .group-head {
  margin-bottom: 0;
}

.pan-cut-pending {
  opacity: .45;
  outline: 1px dashed #635bff !important;
}

.pan-context-menu {
  position: fixed;
  z-index: 200;
  width: 184px;
  padding: 6px;
  border: 1px solid #e3e5ed;
  border-radius: 12px;
  background: rgba(255,255,255,.98);
  box-shadow: 0 18px 50px rgba(27,31,48,.2);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

body[data-mode="dark"] .pan-context-menu {
  border-color: #383d4d;
  background: rgba(34,37,49,.98);
}

.pan-context-menu button {
  width: 100%;
  min-height: 35px;
  display: grid;
  grid-template-columns: 22px 1fr;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border: 0;
  border-radius: 8px;
  color: var(--text);
  background: transparent;
  text-align: left;
  font-size: 12px;
  font-weight: 750;
}

.pan-context-menu button:hover:not(:disabled) {
  background: #ece9ff;
  color: #5148cf;
}

.pan-context-menu button:disabled {
  opacity: .35;
  cursor: not-allowed;
}

.pan-context-menu button.danger {
  color: #cb4b56;
}

.pan-context-menu button.danger:hover {
  background: #fff0f1;
  color: #b73845;
}

.pan-context-menu button span {
  display: grid;
  place-items: center;
  color: #8179dc;
  font-size: 14px;
}

.pan-context-separator {
  height: 1px;
  margin: 5px 4px;
  background: var(--line);
}

/* 편집 중 각 북마크를 개별/다중 선택 */
body.edit-mode .link-row {
  grid-template-columns: 18px var(--bookmark-icon-size) minmax(0, 1fr) auto !important;
}

.pan-link-select {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.pan-selected-link {
  background: color-mix(in srgb, var(--accent) 11%, var(--panel)) !important;
  outline: 1px solid color-mix(in srgb, var(--accent) 48%, var(--line)) !important;
}

.pan-bulk-edit-bar {
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 170;
  display: none;
  align-items: center;
  gap: 14px;
  min-width: min(520px, calc(100vw - 28px));
  padding: 9px 10px 9px 14px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  border-radius: 14px;
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface-strong));
  box-shadow: 0 18px 46px rgba(25, 29, 45, .18);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.pan-bulk-edit-bar.show {
  display: flex;
}

.pan-bulk-edit-bar > strong {
  flex: 1 1 auto;
  font-size: 12px;
  white-space: nowrap;
}

.pan-bulk-actions {
  display: flex;
  gap: 6px;
}

.pan-bulk-actions .btn.danger {
  color: #fff !important;
  background: #d95656 !important;
  border-color: #d95656 !important;
}

/* 중복 주소 선택 관리 */
.pan-duplicate-group {
  overflow: hidden;
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--line));
  border-radius: 13px;
  background: color-mix(in srgb, var(--accent) 3%, var(--surface-strong));
}

.pan-duplicate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 11px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface-strong));
}

.pan-duplicate-head > div {
  min-width: 0;
}

.pan-duplicate-head strong,
.pan-duplicate-head small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pan-duplicate-head strong {
  color: var(--text);
  font-size: 11px;
}

.pan-duplicate-head small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.pan-duplicate-items {
  display: grid;
}

.pan-duplicate-items label {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  padding: 9px 11px;
  cursor: pointer;
}

.pan-duplicate-items label + label {
  border-top: 1px solid var(--line);
}

.pan-duplicate-items input {
  width: 15px;
  height: 15px;
  margin: 0;
  accent-color: var(--accent);
}

.pan-duplicate-items strong,
.pan-duplicate-items small {
  display: block;
}

.pan-duplicate-items strong {
  color: var(--text);
  font-size: 11px;
}

.pan-duplicate-items small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 9px;
}

.pan-duplicate-actions {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface-strong));
}

.pan-duplicate-actions > span {
  flex: 1 1 auto;
  color: var(--text);
  font-size: 11px;
  font-weight: 800;
}

body[data-custom-text-color="true"] .pan-bulk-edit-bar,
body[data-custom-text-color="true"] .pan-bulk-edit-bar .btn,
body[data-custom-text-color="true"] .pan-duplicate-head strong,
body[data-custom-text-color="true"] .pan-duplicate-items strong,
body[data-custom-text-color="true"] .pan-duplicate-actions > span {
  color: var(--text) !important;
}

@media (max-width: 760px) {
  .pan-edit-controls {
    order: -1;
  }

  .pan-edit-controls .btn {
    min-height: 32px;
    padding: 0 10px;
    font-size: 11px;
  }

  body.edit-mode .mobile-nav {
    grid-template-columns: repeat(5, 1fr);
  }

  body:not(.edit-mode) .mobile-nav {
    grid-template-columns: repeat(4, 1fr);
  }

  .pan-context-menu {
    width: min(210px, calc(100vw - 18px));
  }

  .pan-bulk-edit-bar {
    bottom: 82px;
    min-width: calc(100vw - 20px);
    gap: 8px;
  }

  .pan-bulk-actions .btn {
    min-height: 32px;
    padding: 0 8px;
    font-size: 10px;
  }

  .pan-duplicate-head,
  .pan-duplicate-actions {
    align-items: stretch;
    flex-direction: column;
  }
}
