:root {
  --bg: #f6f7fb;
  --panel: #ffffff;
  --text: #222;
  --muted: #666;
  --line: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success-bg: #ecfdf5;
  --success-text: #065f46;
  --error-bg: #fef2f2;
  --error-text: #991b1b;
  --warning-bg: #fffbeb;
  --warning-text: #92400e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", sans-serif;
  background: var(--bg);
  color: var(--text);
}

.container {
  width: min(1200px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  background: #111827;
  color: #fff;
  border-bottom: 1px solid #0f172a;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
}

.brand {
  color: #fff;
  text-decoration: none;
  font-size: 20px;
  font-weight: 700;
}

.nav {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.nav a {
  color: #dbeafe;
  text-decoration: none;
  padding: 6px 10px;
  border-radius: 8px;
}

.nav a:hover {
  background: rgba(255, 255, 255, 0.08);
}

main.container {
  padding-top: 16px;
  padding-bottom: 16px;
}

.footer {
  padding: 16px 0 28px;
  color: var(--muted);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 16px;
}

.panel.soft {
  background: #fcfcff;
}

.flash-wrap {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
}

.flash {
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.flash.success {
  background: var(--success-bg);
  color: var(--success-text);
  border: 1px solid #a7f3d0;
}

.flash.error {
  background: var(--error-bg);
  color: var(--error-text);
  border: 1px solid #fecaca;
}

.flash.warning {
  background: var(--warning-bg);
  color: var(--warning-text);
  border: 1px solid #fde68a;
}

h1,
h2,
h3 {
  margin: 0 0 10px;
}

label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 14px;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="file"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
}

textarea {
  resize: vertical;
  min-height: 90px;
}

.help {
  color: var(--muted);
  font-size: 12px;
}

.form-stack>*+* {
  margin-top: 10px;
}

.grid {
  display: grid;
  gap: 12px;
}

.grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.grid-4 {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

@media (max-width: 900px) {
  .grid-4 {
    grid-template-columns: 1fr 1fr;
  }

  .grid-3 {
    grid-template-columns: 1fr 1fr;
  }

  .layout-two {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {

  .grid-4,
  .grid-3,
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

.btns {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}

.align-end {
  align-items: end;
  justify-content: flex-end;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  padding: 9px 12px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 14px;
}

.btn:hover {
  background: #f9fafb;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-danger {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-sm {
  padding: 6px 10px;
  font-size: 13px;
}

.search-form .mt-8 {
  margin-top: 8px;
}

.mt-8 {
  margin-top: 8px;
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}

.checkbox-row input[type="checkbox"] {
  width: auto;
}

.inline-label {
  margin: 0;
  font-weight: 500;
}

.layout-two {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 16px;
}

.sidebar .panel:last-child {
  margin-bottom: 0;
}

.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #1f2937;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
}

.tag:hover {
  background: #e5e7eb;
}

.tag-count {
  color: var(--muted);
  font-size: 11px;
}

.year-list {
  margin: 0;
  padding-left: 18px;
}

.year-list li {
  margin-bottom: 6px;
}

.list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ref-list {
  display: grid;
  gap: 12px;
}

.ref-card {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  background: #fff;
}

.ref-card-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.ref-title-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
}

.ref-title {
  color: #111827;
  text-decoration: none;
  font-weight: 700;
}

.ref-title:hover {
  color: var(--primary);
}

.favorite {
  color: #f59e0b;
  font-weight: 700;
}

.meta-line {
  margin-top: 6px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.badge {
  background: #eef2ff;
  color: #3730a3;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.status {
  background: #f1f5f9;
  color: #334155;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 12px;
}

.authors {
  margin-top: 6px;
  color: #1f2937;
  font-size: 14px;
}

.submeta {
  margin-top: 6px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 12px;
}

.submeta-attachment {
  flex-basis: 100%;
}

.notes-preview {
  margin: 8px 0 0;
  color: #374151;
  font-size: 13px;
  line-height: 1.45;
}

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.detail-title {
  margin: 0;
  font-size: 22px;
}

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

.kv-table th,
.kv-table td {
  border-bottom: 1px solid var(--line);
  padding: 8px 6px;
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

.kv-table th {
  width: 140px;
  color: var(--muted);
  font-weight: 600;
}

.kv-table code {
  background: #f3f4f6;
  border-radius: 6px;
  padding: 2px 6px;
}

.prewrap {
  white-space: pre-wrap;
  line-height: 1.55;
}

.muted {
  color: var(--muted);
}

.attachment-box {
  margin-top: 8px;
  padding: 10px;
  border: 1px dashed var(--line);
  border-radius: 10px;
}

.or-divider {
  text-align: center;
  color: var(--muted);
  margin: 4px 0;
}

/* Flash message wrapper (있으면 생략 가능) */
.flash-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 12px;
}

/* 기존 flash 스타일을 유지하면서 닫기 버튼 레이아웃 추가 */
.flash {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;

  /* 아래는 기존 스타일이 있으면 유지/조정 */
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  word-break: break-word;
}

/* 메시지 영역 */
.flash-text {
  flex: 1;
  min-width: 0;
  white-space: pre-wrap;
}

/* 닫기 버튼 */
.flash-close {
  margin-left: auto;
  flex: 0 0 auto;

  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;

  font-size: 20px;
  line-height: 1;
  font-weight: 600;

  opacity: 0.7;
  padding: 0 2px;
}

.flash-close:hover {
  opacity: 1;
}

.flash-close:focus {
  outline: 2px solid rgba(0, 0, 0, 0.2);
  outline-offset: 2px;
  border-radius: 4px;
}

.flash.info {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1e3a8a;
}

/*local-plus*/

.grid.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grid.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.grid.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 980px) {

  .grid.grid-2,
  .grid.grid-3,
  .grid.grid-4 {
    grid-template-columns: 1fr;
  }
}

.checkbox-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 8px;
  background: rgba(0, 0, 0, .01);
}

.rowline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
  border-bottom: 1px dashed rgba(0, 0, 0, .08);
}

.rowline:last-child {
  border-bottom: none;
}

.mt-8 {
  margin-top: 8px;
}

/* researchflow helper styles */
.mono-block {
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0, 0, 0, .03);
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 8px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
}

/* ===== 2단계 메뉴 정리 ===== */
.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.nav a {
  text-decoration: none;
  color: inherit;
  padding: 7px 10px;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, .08);
}

.nav a.active {
  font-weight: 700;
  background: rgba(0, 0, 0, .04);
  border-color: rgba(0, 0, 0, .18);
}

.nav-primary a {
  font-weight: 600;
}

.nav-secondary {
  padding-top: 2px;
  border-top: 1px dashed rgba(0, 0, 0, .08);
}

/* ===== 읽기 보드 Priority 배지 (GitHub 느낌) ===== */
.priority-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 20px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  border: 1px solid transparent;
  vertical-align: middle;
}

/* 1=높음, 2=중간, 3=낮음 */
.priority-badge.p1 {
  background: rgba(248, 81, 73, 0.12);
  color: #b42318;
  border-color: rgba(248, 81, 73, 0.28);
}

.priority-badge.p2 {
  background: rgba(251, 188, 5, 0.16);
  color: #9a6700;
  border-color: rgba(251, 188, 5, 0.30);
}

.priority-badge.p3 {
  background: rgba(46, 160, 67, 0.12);
  color: #1a7f37;
  border-color: rgba(46, 160, 67, 0.26);
}

/* 기존 4,5 유지 시 fallback */
.priority-badge.p4,
.priority-badge.p5 {
  background: rgba(99, 110, 123, 0.10);
  color: #57606a;
  border-color: rgba(99, 110, 123, 0.22);
}

/* ===== Topbar stacked layout ===== */
.topbar-stacked {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.topbar-headline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* ===== 메뉴 클러스터 (대메뉴+소메뉴를 하나로 묶음) ===== */
.menu-cluster {
  position: relative;
  border-radius: 18px;
  padding: 10px;
  border: 1px solid rgba(0, 0, 0, 0.10);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 255, 255, 0.92));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.85) inset,
    0 8px 20px rgba(0, 0, 0, 0.04);
}

/* 오프셋 느낌의 내부 라인 */
.menu-cluster::before {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 12px;
  border: 1px dashed rgba(0, 0, 0, 0.08);
  pointer-events: none;
}

/* 활성 대메뉴별 클러스터 강조색 */
.menu-cluster-library {
  border-color: rgba(46, 160, 67, 0.25);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 0 0 3px rgba(46, 160, 67, 0.06),
    0 8px 20px rgba(0, 0, 0, 0.04);
}

.menu-cluster-library::before {
  border-color: rgba(46, 160, 67, 0.18);
}

.menu-cluster-workflow {
  border-color: rgba(59, 130, 246, 0.25);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 0 0 3px rgba(59, 130, 246, 0.06),
    0 8px 20px rgba(0, 0, 0, 0.04);
}

.menu-cluster-workflow::before {
  border-color: rgba(59, 130, 246, 0.18);
}

.menu-cluster-tools {
  border-color: rgba(168, 85, 247, 0.25);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 0 0 3px rgba(168, 85, 247, 0.06),
    0 8px 20px rgba(0, 0, 0, 0.04);
}

.menu-cluster-tools::before {
  border-color: rgba(168, 85, 247, 0.18);
}

/* ===== 공통 nav ===== */
.nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
  /* ::before 위로 */
}

.nav a {
  text-decoration: none;
  color: inherit;
  padding: 8px 12px;
  border-radius: 11px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  background: rgba(255, 255, 255, 0.72);
  transition: background-color .12s ease, border-color .12s ease, box-shadow .12s ease, transform .08s ease;
}

.nav a:hover {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.14);
}

/* ===== 1차 메뉴 (큰 주제) ===== */
.nav-primary {
  margin-bottom: 8px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.nav-primary a {
  font-weight: 700;
  letter-spacing: -0.01em;
  padding: 9px 14px;
}

/* 선택 차이를 강하게 */
.nav-primary a.active,
.nav-primary a[aria-current="page"] {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(180deg, #1f2937, #111827);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 6px 14px rgba(17, 24, 39, 0.22);
}

/* 활성 그룹별 1차 메뉴 active 색상 톤 */
.menu-cluster-library .nav-primary a.active,
.menu-cluster-library .nav-primary a[aria-current="page"] {
  background: linear-gradient(180deg, #238636, #1a7f37);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.14) inset,
    0 6px 14px rgba(26, 127, 55, 0.24);
}

.menu-cluster-workflow .nav-primary a.active,
.menu-cluster-workflow .nav-primary a[aria-current="page"] {
  background: linear-gradient(180deg, #2563eb, #1d4ed8);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.14) inset,
    0 6px 14px rgba(29, 78, 216, 0.22);
}

.menu-cluster-tools .nav-primary a.active,
.menu-cluster-tools .nav-primary a[aria-current="page"] {
  background: linear-gradient(180deg, #7c3aed, #6d28d9);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.14) inset,
    0 6px 14px rgba(109, 40, 217, 0.20);
}

/* ===== 2차 메뉴 (작은 주제) ===== */
.nav-secondary {
  gap: 7px;
}

.nav-secondary a {
  font-size: 13px;
  font-weight: 600;
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(255, 255, 255, 0.8);
}

/* 선택된 소메뉴도 확실히 보이게 */
.nav-secondary a.active,
.nav-secondary a[aria-current="page"] {
  border-color: rgba(0, 0, 0, 0.18);
  background: rgba(0, 0, 0, 0.07);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.7) inset,
    0 2px 8px rgba(0, 0, 0, 0.06);
  transform: translateY(-1px);
}

/* 그룹별 소메뉴 active tint */
.menu-cluster-library .nav-secondary a.active,
.menu-cluster-library .nav-secondary a[aria-current="page"] {
  background: rgba(46, 160, 67, 0.12);
  border-color: rgba(46, 160, 67, 0.28);
  color: #1a7f37;
}

.menu-cluster-workflow .nav-secondary a.active,
.menu-cluster-workflow .nav-secondary a[aria-current="page"] {
  background: rgba(59, 130, 246, 0.12);
  border-color: rgba(59, 130, 246, 0.28);
  color: #1d4ed8;
}

.menu-cluster-tools .nav-secondary a.active,
.menu-cluster-tools .nav-secondary a[aria-current="page"] {
  background: rgba(168, 85, 247, 0.12);
  border-color: rgba(168, 85, 247, 0.28);
  color: #6d28d9;
}

/* 모바일 대응 */
@media (max-width: 720px) {
  .menu-cluster {
    padding: 8px;
    border-radius: 14px;
  }

  .menu-cluster::before {
    inset: 5px;
    border-radius: 10px;
  }

  .nav-primary {
    margin-bottom: 6px;
    padding-bottom: 6px;
  }

  .nav-primary a {
    padding: 8px 11px;
  }

  .nav-secondary a {
    font-size: 12px;
    padding: 6px 10px;
  }
}

/* ===== 메뉴 가시성 개선 (비선택 탭이 너무 안 보이는 문제 완화) ===== */

/* 클러스터 자체도 약간 더 선명하게 */
.menu-cluster {
  border-color: rgba(0, 0, 0, 0.14);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(248, 250, 252, 0.96));
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 10px 24px rgba(0, 0, 0, 0.05);
}

.menu-cluster::before {
  border-color: rgba(0, 0, 0, 0.12);
}

/* 공통 비선택 탭: 더 잘 보이게 */
.nav a {
  color: #374151;
  /* 기존보다 진하게 */
  border-color: rgba(0, 0, 0, 0.14);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.85) inset;
}

/* hover 시 반응도 조금 더 명확하게 */
.nav a:hover {
  color: #111827;
  background: rgba(255, 255, 255, 0.98);
  border-color: rgba(0, 0, 0, 0.22);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 3px 10px rgba(0, 0, 0, 0.05);
}

/* 1차 메뉴 비선택 상태를 더 또렷하게 */
.nav-primary a {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 250, 252, 0.92));
  border-color: rgba(0, 0, 0, 0.15);
  color: #1f2937;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.9) inset,
    0 1px 2px rgba(0, 0, 0, 0.03);
}

/* 1차 메뉴 active는 유지하되 너무 과한 대비는 살짝 완화 */
.nav-primary a.active,
.nav-primary a[aria-current="page"] {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.12) inset,
    0 4px 10px rgba(17, 24, 39, 0.18);
}

/* 그룹별 active도 그림자 강도만 살짝 낮춤 */
.menu-cluster-library .nav-primary a.active,
.menu-cluster-library .nav-primary a[aria-current="page"] {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.14) inset,
    0 4px 10px rgba(26, 127, 55, 0.20);
}

.menu-cluster-workflow .nav-primary a.active,
.menu-cluster-workflow .nav-primary a[aria-current="page"] {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.14) inset,
    0 4px 10px rgba(29, 78, 216, 0.18);
}

.menu-cluster-tools .nav-primary a.active,
.menu-cluster-tools .nav-primary a[aria-current="page"] {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.14) inset,
    0 4px 10px rgba(109, 40, 217, 0.17);
}

/* 2차 메뉴 비선택 pill도 더 잘 보이게 */
.nav-secondary a {
  color: #4b5563;
  background: rgba(255, 255, 255, 0.94);
  border-color: rgba(0, 0, 0, 0.12);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.9) inset;
}

/* 2차 메뉴 hover 강화 */
.nav-secondary a:hover {
  color: #111827;
  background: rgba(255, 255, 255, 0.99);
  border-color: rgba(0, 0, 0, 0.20);
}

/* 선택된 소메뉴는 여전히 눈에 띄게 유지 */
.nav-secondary a.active,
.nav-secondary a[aria-current="page"] {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.75) inset,
    0 2px 8px rgba(0, 0, 0, 0.07);
}

/* 키보드 탐색 접근성 (선택과 별개로 포커스도 잘 보이게) */
.nav a:focus-visible {
  outline: none;
  box-shadow:
    0 0 0 2px rgba(255, 255, 255, 0.95),
    0 0 0 4px rgba(59, 130, 246, 0.35);
}

/* ===== Reading Workflow (GitHub-like labels & progress) ===== */
.gh-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.gh-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, .12);
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
  background: #fff;
}

/* Priority (GitHub issue labels 느낌) */
.gh-label-priority.p1 {
  background: rgba(248, 81, 73, 0.12);
  color: #b42318;
  border-color: rgba(248, 81, 73, 0.28);
}

.gh-label-priority.p2 {
  background: rgba(251, 188, 5, 0.16);
  color: #9a6700;
  border-color: rgba(251, 188, 5, 0.30);
}

.gh-label-priority.p3 {
  background: rgba(46, 160, 67, 0.12);
  color: #1a7f37;
  border-color: rgba(46, 160, 67, 0.26);
}

.gh-label-priority.p4,
.gh-label-priority.p5 {
  background: rgba(99, 110, 123, 0.10);
  color: #57606a;
  border-color: rgba(99, 110, 123, 0.22);
}

/* Stage labels */
.gh-label-stage.stage-to_read {
  background: rgba(99, 110, 123, .10);
  color: #57606a;
  border-color: rgba(99, 110, 123, .22);
}

.gh-label-stage.stage-reading {
  background: rgba(59, 130, 246, .12);
  color: #1d4ed8;
  border-color: rgba(59, 130, 246, .28);
}

.gh-label-stage.stage-reviewed {
  background: rgba(46, 160, 67, .12);
  color: #1a7f37;
  border-color: rgba(46, 160, 67, .26);
}

.gh-label-stage.stage-blocked {
  background: rgba(168, 85, 247, .12);
  color: #6d28d9;
  border-color: rgba(168, 85, 247, .26);
}

/* 3-step progress */
.progress-steps {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  vertical-align: middle;
}

.progress-steps .dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  border: 1px solid rgba(0, 0, 0, .12);
  background: rgba(0, 0, 0, .07);
}

.progress-steps .bar {
  width: 16px;
  height: 3px;
  border-radius: 99px;
  background: rgba(0, 0, 0, .08);
}

.progress-steps.is-1 .dot.d1,
.progress-steps.is-2 .dot.d1,
.progress-steps.is-3 .dot.d1 {
  background: rgba(99, 110, 123, .55);
  border-color: rgba(99, 110, 123, .25);
}

.progress-steps.is-2 .dot.d2,
.progress-steps.is-3 .dot.d2 {
  background: rgba(59, 130, 246, .65);
  border-color: rgba(59, 130, 246, .28);
}

.progress-steps.is-3 .dot.d3 {
  background: rgba(46, 160, 67, .75);
  border-color: rgba(46, 160, 67, .28);
}

.progress-steps.is-2 .bar.b1,
.progress-steps.is-3 .bar.b1 {
  background: rgba(59, 130, 246, .32);
}

.progress-steps.is-3 .bar.b2 {
  background: rgba(46, 160, 67, .32);
}

.workflow-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 6px;
}

/* ===== Kanban DnD ===== */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

@media (max-width: 980px) {
  .kanban-board {
    grid-template-columns: 1fr;
  }
}

.kanban-col {
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 14px;
  background: rgba(255, 255, 255, .75);
  display: flex;
  flex-direction: column;
  min-height: 420px;
}

.kanban-col-header {
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0, 0, 0, .06);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.kanban-col-body {
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 360px;
  transition: background-color .12s ease, box-shadow .12s ease;
  border-radius: 0 0 14px 14px;
}

.kanban-col-body.drag-over {
  background: rgba(59, 130, 246, .06);
  box-shadow: inset 0 0 0 2px rgba(59, 130, 246, .18);
}

.kanban-card {
  border: 1px solid rgba(0, 0, 0, .08);
  border-radius: 12px;
  background: #fff;
  padding: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .03);
}

.kanban-card[draggable="true"] {
  cursor: grab;
}

.kanban-card.dragging {
  opacity: .55;
  cursor: grabbing;
}

.kanban-card-title {
  font-weight: 700;
  line-height: 1.35;
}

.kanban-card-title a {
  color: inherit;
  text-decoration: none;
}

.kanban-card-title a:hover {
  text-decoration: underline;
}

.kanban-card-sub {
  margin-top: 4px;
  color: #6b7280;
  font-size: 12px;
}

.kanban-card-actions {
  margin-top: 8px;
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}

.drag-hint {
  color: #6b7280;
  font-size: 12px;
}

.drag-handle {
  user-select: none;
  color: #6b7280;
  font-size: 14px;
  margin-right: 4px;
}

.drop-empty {
  padding: 12px;
  border: 1px dashed rgba(0, 0, 0, .12);
  border-radius: 10px;
  color: #6b7280;
  text-align: center;
  font-size: 13px;
  background: rgba(0, 0, 0, .015);
}

.small-count-badge {
  min-width: 22px;
  height: 22px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 7px;
  font-size: 12px;
  font-weight: 700;
  background: rgba(0, 0, 0, .05);
  border: 1px solid rgba(0, 0, 0, .08);
}

/* ===== Group tree (library sidebar / groups preview) ===== */
.group-tree {
  list-style: none;
  margin: 0;
  padding: 0;
}

.group-tree .group-tree {
  margin-left: 18px;
  padding-left: 10px;
  border-left: 1px dashed var(--line);
}

.group-tree li {
  margin: 6px 0;
}

.group-tree-row {
  border-radius: 10px;
}

.group-tree-link {
  display: grid;
  grid-template-columns: 14px 10px 1fr auto;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
  padding: 6px 8px;
  border-radius: 10px;
  border: 1px solid transparent;
}

.group-tree-link:hover {
  background: #f8fafc;
  border-color: #e5e7eb;
}

.group-tree-row.active .group-tree-link {
  background: #eef2ff;
  border-color: #c7d2fe;
  color: #312e81;
  font-weight: 600;
}

.twisty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 12px;
  width: 14px;
}

.twisty-empty {
  font-size: 10px;
}

.group-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cbd5e1;
  border: 1px solid rgba(0, 0, 0, .08);
}

.group-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.group-count {
  font-size: 12px;
  color: var(--muted);
  padding: 0 6px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
}

.mb-8 {
  margin-bottom: 8px;
}

/* index list header 내 export 버튼 줄바꿈 정리 */
.list-header .btns {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* =========================================================
   Theme patch (force apply)
   - MUST be placed at the very end of style.css
   ========================================================= */

/* 기본 전환감 */
html,
body,
.panel,
.panel.soft,
.rowline,
input,
select,
textarea,
.btn,
table,
th,
td,
thead th,
pre,
code,
textarea[readonly],
.flash,
.alert,
.topbar,
.footer,
.nav a,
.nav-primary a,
.nav-secondary a,
.menu-cluster {
  transition: background-color 220ms ease, color 220ms ease, border-color 220ms ease, box-shadow 220ms ease;
}

/* ---------- 라이트 기본값 ---------- */
html[data-theme="light"] body,
html[data-theme="light"] {
  background: #f5f7fb;
  color: #0f172a;
}

/* ---------- 다크 강제 적용 ---------- */
html[data-theme="dark"],
html[data-theme="dark"] body {
  background: #0b1220 !important;
  color: #e5e7eb !important;
  color-scheme: dark;
}

/* 다크 모드용 CSS 변수 재정의 (var 기반 UI 전반 보정) */
html[data-theme="dark"] {
  --bg: #0b1220;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --line: #243041;
}


/* 상단/하단 */
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .footer {
  background: #0f172a !important;
  color: #e5e7eb !important;
  border-color: #243041 !important;
}

/* 패널/카드 */
html[data-theme="dark"] .panel {
  background: #111827 !important;
  color: #e5e7eb !important;
  border: 1px solid #243041 !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="dark"] .panel.soft {
  background: #0f172a !important;
  border-color: #243041 !important;
}

/* 텍스트류 */
html[data-theme="dark"] .muted,
html[data-theme="dark"] .flash-text,
html[data-theme="dark"] small,
html[data-theme="dark"] label {
  color: #94a3b8 !important;
}

html[data-theme="dark"] h1,
html[data-theme="dark"] h2,
html[data-theme="dark"] h3,
html[data-theme="dark"] h4,
html[data-theme="dark"] strong {
  color: #e5e7eb !important;
}

/* 입력 */
html[data-theme="dark"] input,
html[data-theme="dark"] select,
html[data-theme="dark"] textarea {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border: 1px solid #334155 !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
  color: #94a3b8 !important;
}

html[data-theme="dark"] input:focus,
html[data-theme="dark"] select:focus,
html[data-theme="dark"] textarea:focus {
  border-color: #818cf8 !important;
  box-shadow: 0 0 0 3px rgba(129, 140, 248, 0.16) !important;
}

/* 버튼 */
html[data-theme="dark"] .btn {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border: 1px solid #334155 !important;
}

html[data-theme="dark"] .btn:hover {
  background: #223047 !important;
  border-color: #475569 !important;
}

html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn.btn-primary {
  background: #818cf8 !important;
  color: #0b1020 !important;
  border-color: transparent !important;
}

/* 네비 탭/메뉴 */
html[data-theme="dark"] .nav a,
html[data-theme="dark"] .nav-primary a,
html[data-theme="dark"] .nav-secondary a {
  color: #cbd5e1 !important;
  border-color: #243041 !important;
  background: transparent;
}

html[data-theme="dark"] .nav a:hover,
html[data-theme="dark"] .nav-primary a:hover,
html[data-theme="dark"] .nav-secondary a:hover {
  background: #1a2332 !important;
}

html[data-theme="dark"] .nav a.active,
html[data-theme="dark"] .nav-primary a.active,
html[data-theme="dark"] .nav-secondary a.active {
  background: rgba(129, 140, 248, 0.16) !important;
  color: #e5e7eb !important;
  border-color: #4f5fb8 !important;
}

/* 테이블 */
html[data-theme="dark"] table {
  background: #111827 !important;
  color: #e5e7eb !important;
}

html[data-theme="dark"] th,
html[data-theme="dark"] td {
  border-color: #243041 !important;
}

html[data-theme="dark"] thead th {
  background: #0f172a !important;
}

/* 링크 */
html[data-theme="dark"] a:not(.btn) {
  color: #a5b4fc !important;
}

/* flash */
html[data-theme="dark"] .flash,
html[data-theme="dark"] .alert {
  background: #111827 !important;
  color: #e5e7eb !important;
  border: 1px solid #243041 !important;
}

/* 라인/구분요소 */
html[data-theme="dark"] .rowline {
  border-color: #243041 !important;
}

html[data-theme="dark"] hr {
  border-color: #243041 !important;
}

/* ---------------------------------------------------------
   테마 버튼 상태 (사용자 요청: 다크일 때 버튼도 다크 톤으로)
   --------------------------------------------------------- */
.theme-toggle-wrap {
  margin-left: auto;
  display: flex;
  align-items: center;
}

.theme-toggle-btn {
  min-width: 108px;
  justify-content: center;
  padding-left: 10px;
  padding-right: 10px;
  position: relative;
  overflow: hidden;
}

.theme-toggle-inner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  line-height: 1;
}

.theme-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2em;
  transform-origin: center;
}

.theme-toggle-text {
  display: inline-block;
  min-width: 36px;
  text-align: center;
}

/* 기본(라이트) 버튼 상태 */
html[data-theme="light"] .theme-toggle-btn,
html[data-theme="light"] #themeModeBtn {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

/* 다크 모드일 때 버튼도 다크 색 */
html[data-theme="dark"] .theme-toggle-btn,
html[data-theme="dark"] #themeModeBtn {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border-color: #334155 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25) !important;
}

html[data-theme="dark"] .theme-toggle-btn:hover,
html[data-theme="dark"] #themeModeBtn:hover {
  background: #223047 !important;
  border-color: #475569 !important;
}

/* 모드별 강조(버튼 하나지만 상태가 보이도록) */
#themeModeBtn[data-mode="light"] .theme-toggle-icon {
  filter: saturate(1.15);
}

#themeModeBtn[data-mode="dark"] .theme-toggle-icon {
  filter: saturate(1.05);
}

#themeModeBtn[data-mode="auto"] .theme-toggle-icon {
  opacity: 0.95;
}

/* 버튼 내용 전환 애니메이션 */
.theme-switch-anim .theme-toggle-icon {
  animation: themeIconPop 280ms ease;
}

.theme-switch-anim .theme-toggle-text {
  animation: themeTextSlide 280ms ease;
}

@keyframes themeIconPop {
  0% {
    transform: translateY(1px) scale(0.86) rotate(-12deg);
    opacity: 0.35;
  }

  55% {
    transform: translateY(0) scale(1.08) rotate(6deg);
    opacity: 1;
  }

  100% {
    transform: translateY(0) scale(1) rotate(0deg);
    opacity: 1;
  }
}

@keyframes themeTextSlide {
  0% {
    transform: translateY(4px);
    opacity: 0;
  }

  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* 모션 최소화 설정 대응 */
@media (prefers-reduced-motion: reduce) {

  .theme-switch-anim .theme-toggle-icon,
  .theme-switch-anim .theme-toggle-text {
    animation: none !important;
  }

  html,
  body,
  .panel,
  .panel.soft,
  .rowline,
  input,
  select,
  textarea,
  .btn,
  table,
  th,
  td,
  thead th,
  pre,
  code,
  textarea[readonly],
  .flash,
  .alert,
  .topbar,
  .footer,
  .nav a,
  .nav-primary a,
  .nav-secondary a,
  .menu-cluster {
    transition: none !important;
  }
}

/* =========================================================
   Dark mode policy update
   - Topbar: menu cluster only dark
   - Buttons: keep original/light styling
   ========================================================= */

/* 1) 상단바 바탕은 기본(라이트) 유지 */
html[data-theme="dark"] .topbar {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
}

html[data-theme="dark"] .topbar .brand {
  color: #0f172a !important;
}

/* 2) 상단바 내부에서 '메뉴 클러스터'만 다크 톤 */
html[data-theme="dark"] .topbar .menu-cluster {
  background: #111827 !important;
  color: #e5e7eb !important;
  border: 1px solid #243041 !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18) !important;
}

/* 메뉴 클러스터 안의 1차/2차 메뉴 링크 */
html[data-theme="dark"] .topbar .menu-cluster .nav a,
html[data-theme="dark"] .topbar .menu-cluster .nav-primary a,
html[data-theme="dark"] .topbar .menu-cluster .nav-secondary a {
  color: #cbd5e1 !important;
  background: transparent !important;
  border-color: #243041 !important;
}

html[data-theme="dark"] .topbar .menu-cluster .nav a:hover,
html[data-theme="dark"] .topbar .menu-cluster .nav-primary a:hover,
html[data-theme="dark"] .topbar .menu-cluster .nav-secondary a:hover {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] .topbar .menu-cluster .nav a.active,
html[data-theme="dark"] .topbar .menu-cluster .nav-primary a.active,
html[data-theme="dark"] .topbar .menu-cluster .nav-secondary a.active {
  background: rgba(129, 140, 248, 0.16) !important;
  color: #e5e7eb !important;
  border-color: #4f5fb8 !important;
}

/* 3) 버튼류는 다크에서도 '그대로(라이트 스타일)' 유지
   - 상단 버튼 + 일반 버튼 + 중요 버튼(수정/삭제/저장 포함) */
html[data-theme="dark"] .btn,
html[data-theme="dark"] button.btn,
html[data-theme="dark"] a.btn {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .btn:hover,
html[data-theme="dark"] button.btn:hover,
html[data-theme="dark"] a.btn:hover {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

/* Primary 버튼은 원래 강조색 유지 */
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn.btn-primary {
  background: #4f46e5 !important;
  color: #ffffff !important;
  border-color: transparent !important;
}

html[data-theme="dark"] .btn-primary:hover,
html[data-theme="dark"] .btn.btn-primary:hover {
  filter: brightness(1.03);
  border-color: transparent !important;
}

/* 테마 버튼도 라이트 스타일 유지 (상단바 버튼 유지 정책 명시) */
html[data-theme="dark"] #themeModeBtn,
html[data-theme="dark"] .topbar #themeModeBtn {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="dark"] #themeModeBtn:hover,
html[data-theme="dark"] .topbar #themeModeBtn:hover {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

/* =========================================================
   Dark mode policy update
   - Topbar: menu cluster only dark
   - Buttons: keep original/light styling
   ========================================================= */

/* 1) 상단바 바탕은 기본(라이트) 유지 */
html[data-theme="dark"] .topbar {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #e2e8f0 !important;
}

html[data-theme="dark"] .topbar .brand {
  color: #0f172a !important;
}

/* 2) 상단바 내부에서 '메뉴 클러스터'만 다크 톤 */
html[data-theme="dark"] .topbar .menu-cluster {
  background: #111827 !important;
  color: #e5e7eb !important;
  border: 1px solid #243041 !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.18) !important;
}

/* 메뉴 클러스터 안의 1차/2차 메뉴 링크 */
html[data-theme="dark"] .topbar .menu-cluster .nav a,
html[data-theme="dark"] .topbar .menu-cluster .nav-primary a,
html[data-theme="dark"] .topbar .menu-cluster .nav-secondary a {
  color: #cbd5e1 !important;
  background: transparent !important;
  border-color: #243041 !important;
}

html[data-theme="dark"] .topbar .menu-cluster .nav a:hover,
html[data-theme="dark"] .topbar .menu-cluster .nav-primary a:hover,
html[data-theme="dark"] .topbar .menu-cluster .nav-secondary a:hover {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border-color: #334155 !important;
}

html[data-theme="dark"] .topbar .menu-cluster .nav a.active,
html[data-theme="dark"] .topbar .menu-cluster .nav-primary a.active,
html[data-theme="dark"] .topbar .menu-cluster .nav-secondary a.active {
  background: rgba(129, 140, 248, 0.16) !important;
  color: #e5e7eb !important;
  border-color: #4f5fb8 !important;
}

/* 3) 버튼류는 다크에서도 '그대로(라이트 스타일)' 유지
   - 상단 버튼 + 일반 버튼 + 중요 버튼(수정/삭제/저장 포함) */
html[data-theme="dark"] .btn,
html[data-theme="dark"] button.btn,
html[data-theme="dark"] a.btn {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .btn:hover,
html[data-theme="dark"] button.btn:hover,
html[data-theme="dark"] a.btn:hover {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

/* Primary 버튼은 원래 강조색 유지 */
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn.btn-primary {
  background: #4f46e5 !important;
  color: #ffffff !important;
  border-color: transparent !important;
}

html[data-theme="dark"] .btn-primary:hover,
html[data-theme="dark"] .btn.btn-primary:hover {
  filter: brightness(1.03);
  border-color: transparent !important;
}

/* 테마 버튼도 라이트 스타일 유지 (상단바 버튼 유지 정책 명시) */
html[data-theme="dark"] #themeModeBtn,
html[data-theme="dark"] .topbar #themeModeBtn {
  background: #ffffff !important;
  color: #0f172a !important;
  border-color: #cbd5e1 !important;
}

html[data-theme="dark"] #themeModeBtn:hover,
html[data-theme="dark"] .topbar #themeModeBtn:hover {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

/* =========================================================
   Theme button exception in topbar
   - Keep topbar buttons/tabs light, BUT theme button changes
   ========================================================= */

/* 다크 모드일 때 테마 버튼만 다크 스타일 */
html[data-theme="dark"] .topbar #themeModeBtn,
html[data-theme="dark"] .topbar button#themeModeBtn.btn {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border: 1px solid #334155 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.22) !important;
}

html[data-theme="dark"] .topbar #themeModeBtn:hover,
html[data-theme="dark"] .topbar button#themeModeBtn.btn:hover {
  background: #223047 !important;
  color: #e5e7eb !important;
  border-color: #475569 !important;
}

/* 라이트 모드일 때는 기존 밝은 버튼 느낌 유지 (명시) */
html[data-theme="light"] .topbar #themeModeBtn,
html[data-theme="light"] .topbar button#themeModeBtn.btn {
  background: #ffffff !important;
  color: #0f172a !important;
  border: 1px solid #cbd5e1 !important;
  box-shadow: none !important;
}

html[data-theme="light"] .topbar #themeModeBtn:hover,
html[data-theme="light"] .topbar button#themeModeBtn.btn:hover {
  background: #f8fafc !important;
  color: #0f172a !important;
  border-color: #94a3b8 !important;
}

/* 상태별(자동/라이트/다크) 아이콘 느낌 약간 차이 */
html[data-theme="dark"] #themeModeBtn[data-mode="dark"] .theme-toggle-icon {
  filter: drop-shadow(0 0 4px rgba(148, 163, 184, 0.25));
}

html[data-theme="dark"] #themeModeBtn[data-mode="light"] .theme-toggle-icon {
  filter: drop-shadow(0 0 5px rgba(250, 204, 21, 0.22));
}

html[data-theme="dark"] #themeModeBtn[data-mode="auto"] .theme-toggle-icon {
  opacity: 0.95;
}

/* =========================================================
   Topbar outer card dark fix (keep layout same as light mode)
   - fixes white area outside menu cluster in dark mode
   ========================================================= */

/* 상단바 전체 배경 */
html[data-theme="dark"] .topbar {
  background: #0b1220 !important;
  color: #e5e7eb !important;
  border-bottom: none !important;
}

/* 실제 상단바 카드(바깥 박스) - 라이트 모드 구조 그대로, 색만 다크 */
html[data-theme="dark"] .topbar .container.topbar-inner.topbar-stacked,
html[data-theme="dark"] .topbar .topbar-inner.topbar-stacked,
html[data-theme="dark"] .topbar .topbar-inner {
  background: #111827 !important;
  color: #e5e7eb !important;
  border: 1px solid #243041 !important;
  border-radius: 14px !important;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.28) !important;
}

/* 상단바 카드 내부의 영역들은 불필요한 흰 배경 제거 */
html[data-theme="dark"] .topbar .topbar-headline,
html[data-theme="dark"] .topbar .theme-toggle-wrap,
html[data-theme="dark"] .topbar .menu-cluster-wrap {
  background: transparent !important;
}

/* 메뉴 클러스터(대/소메뉴 묶음) 자체도 다크 톤 */
html[data-theme="dark"] .topbar .menu-cluster,
html[data-theme="dark"] .topbar .menu-cluster.menu-cluster-library,
html[data-theme="dark"] .topbar .menu-cluster.menu-cluster-tools,
html[data-theme="dark"] .topbar .menu-cluster.menu-cluster-workflow {
  background: #0f172a !important;
  color: #e5e7eb !important;
  border: 1px solid #243041 !important;
  border-radius: 12px !important;
  box-shadow: none !important;
}

/* 혹시 active group에 따라 밝은 배경을 주는 규칙이 있으면 덮어쓰기 */
html[data-theme="dark"] .topbar .menu-cluster[data-group],
html[data-theme="dark"] .topbar .menu-cluster[data-group="library"],
html[data-theme="dark"] .topbar .menu-cluster[data-group="tools"],
html[data-theme="dark"] .topbar .menu-cluster[data-group="workflow"] {
  background: #0f172a !important;
  border-color: #243041 !important;
}

/* 메뉴 클러스터 내부 nav 래퍼 배경도 투명 처리 (흰 줄/흰 박스 방지) */
html[data-theme="dark"] .topbar .menu-cluster .nav,
html[data-theme="dark"] .topbar .menu-cluster .nav-primary,
html[data-theme="dark"] .topbar .menu-cluster .nav-secondary {
  background: transparent !important;
}

/* 브랜드 텍스트 */
html[data-theme="dark"] .topbar .brand {
  color: #e5e7eb !important;
}

/* =========================================================
   Dark mode final policy
   1) Hide topbar outer box (same as page bg)
   2) Active menu tabs keep light-mode green
   3) Colored buttons (success/danger/primary) keep same colors in light & dark
   4) Plain buttons remain dark in dark mode
   ========================================================= */

/* ---------- 공통 색(라이트/다크 동일로 유지할 색상) ---------- */
:root {
  /* 라이트 모드에서 쓰던 초록 느낌(필요시 숫자만 조절) */
  --keep-green-bg: #22c55e;
  --keep-green-bg-hover: #16a34a;
  --keep-green-text: #ffffff;
  --keep-green-border: transparent;

  /* 삭제/위험 버튼 */
  --keep-red-bg: #ef4444;
  --keep-red-bg-hover: #dc2626;
  --keep-red-text: #ffffff;
  --keep-red-border: transparent;
}

/* =========================================================
   1) 다크 모드 상단바 바깥 추가 박스(outer box) 숨기기
   ========================================================= */
html[data-theme="dark"] .topbar {
  background: #0b1220 !important;
  /* 페이지 다크 배경과 동일 */
  border-bottom: none !important;
}

/* 상단바 outer box를 배경색과 동일하게 + 테두리/그림자 제거 */
html[data-theme="dark"] .topbar .container.topbar-inner.topbar-stacked,
html[data-theme="dark"] .topbar .topbar-inner.topbar-stacked,
html[data-theme="dark"] .topbar .topbar-inner {
  background: #0b1220 !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

/* 혹시 가상요소 박스가 있으면 제거 */
html[data-theme="dark"] .topbar::before,
html[data-theme="dark"] .topbar::after,
html[data-theme="dark"] .topbar .topbar-inner::before,
html[data-theme="dark"] .topbar .topbar-inner::after {
  background: transparent !important;
  border-color: transparent !important;
  box-shadow: none !important;
}

/* 메뉴 클러스터(대/소메뉴 묶음)는 다크 박스로 유지 */
html[data-theme="dark"] .topbar .menu-cluster,
html[data-theme="dark"] .topbar .menu-cluster[data-group],
html[data-theme="dark"] .topbar .menu-cluster[data-group="library"],
html[data-theme="dark"] .topbar .menu-cluster[data-group="workflow"],
html[data-theme="dark"] .topbar .menu-cluster[data-group="tools"] {
  background: #111827 !important;
  border: 1px solid #243041 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .topbar .brand {
  color: #e5e7eb !important;
}

/* =========================================================
   2) 다크 모드 일반 메뉴 버튼/탭, 선택된 메뉴(활성 탭) = 다크 스타일
   ========================================================= */
html[data-theme="dark"] .topbar .nav a,
html[data-theme="dark"] .topbar .nav-primary a,
html[data-theme="dark"] .topbar .nav-secondary a {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border: 1px solid #334155 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .topbar .nav a:hover,
html[data-theme="dark"] .topbar .nav-primary a:hover,
html[data-theme="dark"] .topbar .nav-secondary a:hover {
  background: #223047 !important;
  color: #e5e7eb !important;
  border-color: #475569 !important;
}

html[data-theme="dark"] .topbar .nav a.active,
html[data-theme="dark"] .topbar .nav-primary a.active,
html[data-theme="dark"] .topbar .nav-secondary a.active,
html[data-theme="dark"] .topbar .nav a[aria-current="page"],
html[data-theme="dark"] .topbar .nav-primary a[aria-current="page"],
html[data-theme="dark"] .topbar .nav-secondary a[aria-current="page"] {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border: 1px solid #334155 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .topbar .nav a.active:hover,
html[data-theme="dark"] .topbar .nav-primary a.active:hover,
html[data-theme="dark"] .topbar .nav-secondary a.active:hover,
html[data-theme="dark"] .topbar .nav a[aria-current="page"]:hover,
html[data-theme="dark"] .topbar .nav-primary a[aria-current="page"]:hover,
html[data-theme="dark"] .topbar .nav-secondary a[aria-current="page"]:hover {
  background: #223047 !important;
  color: #e5e7eb !important;
  border-color: #475569 !important;
}

/* =========================================================
   4) 다크 모드 일반 버튼 = 다크 스타일 (비선택, 기본 버튼)
   - 단, 테마 버튼은 예외(기존 네 규칙 유지)
   ========================================================= */
html[data-theme="dark"] .btn:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.btn-admin):not(#themeModeBtn),
html[data-theme="dark"] a.btn:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.btn-admin):not(#themeModeBtn),
html[data-theme="dark"] button.btn:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.btn-admin):not(#themeModeBtn) {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border: 1px solid #334155 !important;
  box-shadow: none !important;
}

html[data-theme="dark"] .btn:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.btn-admin):not(#themeModeBtn):hover,
html[data-theme="dark"] a.btn:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.btn-admin):not(#themeModeBtn):hover,
html[data-theme="dark"] button.btn:not(.btn-primary):not(.btn-success):not(.btn-danger):not(.btn-admin):not(#themeModeBtn):hover {
  background: #223047 !important;
  color: #e5e7eb !important;
  border-color: #475569 !important;
}

/* =========================================================
   5) 색이 있는 버튼(초록/빨강/기본 강조색)은 라이트/다크 동일 유지
   - 삭제 버튼 / 저장 / 확인 / 주요 액션 포함
   ========================================================= */

/* Primary를 초록 계열로 쓰고 있다면 동일 유지 */
html[data-theme="dark"] .btn-primary,
html[data-theme="dark"] .btn.btn-primary,
html[data-theme="dark"] a.btn-primary,
html[data-theme="dark"] button.btn-primary {
  background: var(--keep-green-bg) !important;
  color: var(--keep-green-text) !important;
  border-color: var(--keep-green-border) !important;
}

html[data-theme="dark"] .btn-primary:hover,
html[data-theme="dark"] .btn.btn-primary:hover,
html[data-theme="dark"] a.btn-primary:hover,
html[data-theme="dark"] button.btn-primary:hover {
  background: var(--keep-green-bg-hover) !important;
  color: var(--keep-green-text) !important;
  border-color: var(--keep-green-border) !important;
}

/* Success(초록) 버튼 명시 클래스가 있다면 동일 유지 */
html[data-theme="dark"] .btn-success,
html[data-theme="dark"] .btn.btn-success,
html[data-theme="dark"] a.btn-success,
html[data-theme="dark"] button.btn-success {
  background: var(--keep-green-bg) !important;
  color: var(--keep-green-text) !important;
  border-color: var(--keep-green-border) !important;
}

html[data-theme="dark"] .btn-success:hover,
html[data-theme="dark"] .btn.btn-success:hover,
html[data-theme="dark"] a.btn-success:hover,
html[data-theme="dark"] button.btn-success:hover {
  background: var(--keep-green-bg-hover) !important;
  color: var(--keep-green-text) !important;
  border-color: var(--keep-green-border) !important;
}

/* Danger(삭제) 버튼 동일 유지 */
html[data-theme="dark"] .btn-danger,
html[data-theme="dark"] .btn.btn-danger,
html[data-theme="dark"] a.btn-danger,
html[data-theme="dark"] button.btn-danger {
  background: var(--keep-red-bg) !important;
  color: var(--keep-red-text) !important;
  border-color: var(--keep-red-border) !important;
}

html[data-theme="dark"] .btn-danger:hover,
html[data-theme="dark"] .btn.btn-danger:hover,
html[data-theme="dark"] a.btn-danger:hover,
html[data-theme="dark"] button.btn-danger:hover {
  background: var(--keep-red-bg-hover) !important;
  color: var(--keep-red-text) !important;
  border-color: var(--keep-red-border) !important;
}

/* 테마 버튼은 네가 앞에서 만든 "모드별 변화" 규칙을 유지 (여기선 건드리지 않음) */

/* =========================================================
   Sync topbar outer shell with page background on theme switch
   - prevents brief white flash of outer box
   ========================================================= */

/* 바깥 박스(outer shell) 대상 선택자 */
html .topbar,
html .topbar .container.topbar-inner.topbar-stacked,
html .topbar .topbar-inner.topbar-stacked,
html .topbar .topbar-inner,
html .topbar::before,
html .topbar::after,
html .topbar .topbar-inner::before,
html .topbar .topbar-inner::after {
  /* 배경색 전환 타이밍을 동일하게 맞춤 */
  transition: background-color 220ms ease, color 220ms ease !important;
}

/* outer shell은 항상 "숨김" 상태 유지 (테두리/그림자 없음) */
html .topbar .container.topbar-inner.topbar-stacked,
html .topbar .topbar-inner.topbar-stacked,
html .topbar .topbar-inner {
  border-color: transparent !important;
  box-shadow: none !important;
}

/* 가상요소도 흔적 제거 */
html .topbar::before,
html .topbar::after,
html .topbar .topbar-inner::before,
html .topbar .topbar-inner::after {
  border-color: transparent !important;
  box-shadow: none !important;
}

/* 논문 목록: 제목은 줄바꿈, 버튼은 오른쪽 고정 */
.list-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

/* 제목 영역(왼쪽)은 줄어들 수 있어야 함 */
.list-header .title-col {
  flex: 1 1 auto;
  min-width: 0;
  /* 긴 텍스트가 버튼 영역 침범하지 않게 */
}

/* 버튼 영역(오른쪽)은 줄어들지 않게 */
.list-header .btns {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  /* 버튼은 한 줄 유지 */
  align-items: center;
}

/* 제목 링크가 줄 전체를 덮지 않게(텍스트 영역만 클릭) */
.ref-title {
  display: inline-block;
  /* 핵심 */
  max-width: 100%;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

/* ============================
   논문 목록: 긴 제목 + 버튼 안정화
   ============================ */

/* 버튼이 아래로 떨어지지 않게 */
.list-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  /* ✅ 중요: 한 줄 유지 */
}

/* 제목 칼럼은 남는 공간을 쓰되, 줄바꿈으로 해결 */
.list-header .title-col {
  flex: 1 1 auto;
  min-width: 0;
  /* ✅ 중요: 제목이 버튼을 밀지 않게 */
  max-width: min(62ch, 100%);
  /* ✅ “더 일찍” 줄바꿈 (원하면 숫자 조절) */
}

/* 버튼 칼럼은 항상 한 줄 */
.list-header .btns {
  flex: 0 0 auto;
  /* ✅ 버튼 영역 고정 */
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  /* ✅ 버튼 줄바꿈 금지 */
  white-space: nowrap;
  align-items: center;
}

/* ✅ 핵심: 링크는 inline로 두기(빈 공간 클릭 최소화) */
.ref-title {
  display: inline;
  /* block/inline-block 금지 */
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

/* 버튼 텍스트가 길어서 버튼 자체가 줄바꿈되는 경우 방지 */
.list-header .btns .btn {
  white-space: nowrap;
}

/* (선택) 화면이 아주 좁을 때는 버튼이 너무 답답하면 아래를 켜도 됨 */

@media (max-width: 720px) {
  .list-header {
    flex-direction: column;
  }

  .list-header .btns {
    justify-content: flex-end;
  }
}

/* 논문 카드 상단: 제목은 여러 줄, 버튼은 오른쪽 고정 */
.ref-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: nowrap;
  /* 버튼 아래로 떨어지지 않게 */
}

/* 제목 영역(왼쪽)은 줄바꿈으로 해결 + 버튼을 밀지 않게 */
.ref-title-row {
  flex: 1 1 auto;
  min-width: 0;
  /* 핵심: 긴 제목이 버튼 영역 침범/밀어내지 않게 */
  max-width: min(62ch, 100%);
  /* “더 일찍” 줄바꿈 (원하면 52~70ch 조절) */
}

/* 버튼 영역은 한 줄 유지 */
.ref-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 6px;
  flex-wrap: nowrap;
  white-space: nowrap;
  align-items: center;
}

/* 제목 링크는 줄바꿈 허용(여러 줄) */
.ref-title {
  display: inline;
  /* 빈 공간 클릭 최소화 */
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  line-height: 1.35;
}

/* 버튼 내부 글자 줄바꿈 방지 */
.ref-actions .btn {
  white-space: nowrap;
}

/* 논문 목록의 그룹 표시 */
.group-line {
  margin-top: 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.group-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line, #cbd5e1);
  background: var(--surface-soft, #f8fafc);
  color: var(--text, #0f172a);
  text-decoration: none;
  font-size: 12px;
  line-height: 1.2;
}

.group-pill:hover {
  filter: brightness(1.02);
}

.group-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.10);
}

/* 기본은 숨김(처음 N개만 보여주기) */
.group-pill-hidden {
  display: none;
}

/* 더보기 버튼(작게) */
.group-more.btn.btn-sm {
  padding: 2px 8px;
  font-size: 12px;
  line-height: 1.2;
}

/* -------------------------
   Auth UI (topbar)
------------------------- */
.topbar-auth {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .08);
  /* topbar 위에서 항상 읽히도록(라이트/다크 공통) */
  color: #f8fafc;
}

/* topbar는 라이트 모드에서도 어두운 배경이므로, chip 스타일을 항상 밝게 유지 */
.topbar .user-chip {
  color: #f8fafc !important;
  border-color: rgba(255, 255, 255, .18) !important;
  background: rgba(255, 255, 255, .10) !important;
}

/* 다크 모드에서 CSS 변수도 함께 보정 (var(--text) 등을 사용하는 요소 호환) */
html[data-theme="dark"] {
  --bg: #0b1220;
  --panel: #111827;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --line: #243041;
}



/* ---------- 다크 모드 추가 보정: 리스트 카드/태그/그룹 카운트 ---------- */
html[data-theme="dark"] .ref-card {
  background: var(--panel) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .ref-title {
  color: var(--text) !important;
}

html[data-theme="dark"] .authors {
  color: #cbd5e1 !important;
}

html[data-theme="dark"] .tag {
  background: rgba(148, 163, 184, .12) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
}

html[data-theme="dark"] .tag:hover {
  background: rgba(148, 163, 184, .18) !important;
}

html[data-theme="dark"] .tag-count {
  color: var(--muted) !important;
}

html[data-theme="dark"] .group-tree-link:hover {
  background: rgba(148, 163, 184, .10) !important;
  border-color: var(--line) !important;
}

html[data-theme="dark"] .group-tree-row.active .group-tree-link {
  background: rgba(99, 102, 241, .18) !important;
  border-color: rgba(99, 102, 241, .35) !important;
  color: #e0e7ff !important;
}

html[data-theme="dark"] .group-dot {
  /* keep dot borders visible in dark mode, but DO NOT override inline background colors */
  border-color: rgba(148, 163, 184, .25) !important;
}

html[data-theme="dark"] .group-dot:not([style]) {
  /* fallback dot color only when no per-group color is provided */
  background: rgba(148, 163, 184, .35) !important;
}

html[data-theme="dark"] .group-count {
  background: rgba(148, 163, 184, .12) !important;
  border-color: var(--line) !important;
  color: #e5e7eb !important;
}

/* 칸반/카드도 다크에서 흰색으로 뜨지 않게 */
html[data-theme="dark"] .kanban-card {
  background: var(--panel) !important;
  border-color: var(--line) !important;
  color: var(--text) !important;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .35) !important;
}

html[data-theme="dark"] .badge {
  background: rgba(99, 102, 241, .18) !important;
  border-color: rgba(99, 102, 241, .35) !important;
  color: #e0e7ff !important;
}

html[data-theme="dark"] .status {
  background: rgba(148, 163, 184, .14) !important;
  color: #e5e7eb !important;
}



/* ===== Dark mode: fix white chips (category badge, generic gh-label) and kanban column panels ===== */
html[data-theme="dark"] .badge {
  background: rgba(148, 163, 184, 0.12) !important;
  color: #cbd5e1 !important;
  border-color: rgba(148, 163, 184, 0.26) !important;
}

html[data-theme="dark"] .group-pill {
  background: rgba(148, 163, 184, 0.12) !important;
  color: #cbd5e1 !important;
  border-color: rgba(148, 163, 184, 0.26) !important;
}

/* Generic gh-label (non-stage, non-priority) should not be white in dark mode */
html[data-theme="dark"] .gh-label:not(.gh-label-stage):not(.gh-label-priority) {
  background: rgba(148, 163, 184, 0.12) !important;
  color: var(--text) !important;
  border-color: rgba(148, 163, 184, 0.24) !important;
}

/* Kanban columns were too bright in dark mode */
html[data-theme="dark"] .kanban-col {
  background: #0f172a !important;
  border-color: var(--line) !important;
}

html[data-theme="dark"] .kanban-col-header {
  border-bottom-color: var(--line) !important;
  color: var(--text) !important;
}


/* ============================================================
   PaperDesk UI layer (2026 refresh)
   이 아래 블록은 새로 추가된 컴포넌트 + 전체 톤 정리입니다.
   기존 규칙을 지우지 않고 마지막에 얹어 덮어쓰는 방식이라
   이전 화면들의 동작/모양은 그대로 유지됩니다.
   ============================================================ */

:root {
  --pd-ease: cubic-bezier(.16, 1, .3, 1);
  --pd-r-lg: 16px;
  --pd-r-md: 12px;
  --pd-r-sm: 9px;
  --pd-shadow-1: 0 1px 2px rgba(15, 23, 42, .04), 0 2px 10px rgba(15, 23, 42, .05);
  --pd-shadow-2: 0 6px 22px rgba(15, 23, 42, .09);
  --pd-soft: #f8fafc;
  --pd-soft-2: #f1f5f9;
}

html[data-theme="dark"] {
  --pd-shadow-1: 0 1px 2px rgba(0, 0, 0, .3), 0 2px 10px rgba(0, 0, 0, .28);
  --pd-shadow-2: 0 6px 22px rgba(0, 0, 0, .42);
  --pd-soft: #0f172a;
  --pd-soft-2: #131c2e;
}

/* ── 스크롤 / 포커스 기본기 ───────────────────────────── */
html {
  scroll-behavior: smooth;
}

:where(a, button, input, select, textarea, [tabindex]):focus-visible {
  outline: 2px solid color-mix(in srgb, var(--primary) 70%, transparent);
  outline-offset: 2px;
  border-radius: var(--pd-r-sm);
}

/* ── 버튼 미세 인터랙션 ───────────────────────────────── */
.btn {
  transition: background-color .16s ease, border-color .16s ease,
    color .16s ease, box-shadow .16s ease, transform .12s var(--pd-ease);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--pd-shadow-1);
}

.btn:active {
  transform: translateY(0) scale(.98);
  box-shadow: none;
}

.btn:disabled {
  opacity: .55;
  pointer-events: none;
  transform: none;
}

/* ── 패널 / 카드 ──────────────────────────────────────── */
.panel {
  box-shadow: var(--pd-shadow-1);
}

.ref-card {
  transition: border-color .18s ease, box-shadow .2s ease, transform .18s var(--pd-ease);
}

.ref-card:hover {
  border-color: color-mix(in srgb, var(--primary) 34%, var(--line));
  box-shadow: var(--pd-shadow-1);
  transform: translateY(-1px);
}

.ref-card.dp-active {
  transform: none;
}

/* ── 입력 포커스 ──────────────────────────────────────── */
input[type="text"],
input[type="url"],
input[type="number"],
input[type="date"],
input[type="password"],
input[type="email"],
select,
textarea {
  transition: border-color .16s ease, box-shadow .16s ease, background-color .2s ease;
}

input[type="text"]:focus,
input[type="url"]:focus,
input[type="number"]:focus,
input[type="date"]:focus,
input[type="password"]:focus,
input[type="email"]:focus,
select:focus,
textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

/* ── flash 등장 ───────────────────────────────────────── */
.flash {
  animation: pdSlideDown .28s var(--pd-ease);
}

@keyframes pdSlideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}


/* ════════════════════════════════════════════════════════
   1. 세그먼트 선택 트랙 (드래그 또는 클릭)
   ════════════════════════════════════════════════════════ */
.seg {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 4px;
  background: var(--pd-soft);
  border: 1px solid var(--line);
  border-radius: var(--pd-r-md);
  user-select: none;
  touch-action: none;
  cursor: grab;
}

.seg:active,
.seg.is-dragging {
  cursor: grabbing;
}

.seg.is-dragging .seg-thumb {
  transition: transform .12s linear, width .12s linear;
}

.seg-thumb {
  position: absolute;
  left: 0;
  top: 4px;
  bottom: 4px;
  width: 0;
  border-radius: var(--pd-r-sm);
  background: var(--panel);
  box-shadow: 0 1px 3px rgba(15, 23, 42, .16), 0 0 0 1px rgba(15, 23, 42, .05);
  transition: transform .34s var(--pd-ease), width .34s var(--pd-ease), box-shadow .25s ease;
  pointer-events: none;
}

html[data-theme="dark"] .seg-thumb {
  background: #1e293b;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .5), 0 0 0 1px rgba(148, 163, 184, .18);
}

.seg-opt {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 8px 6px;
  border: none;
  background: none;
  border-radius: var(--pd-r-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.25;
  pointer-events: none;
  /* 포인터는 트랙 전체가 받는다 */
  transition: color .2s ease, transform .22s var(--pd-ease);
}

.seg-opt.is-active {
  color: var(--text);
  transform: translateY(-1px);
}

.seg-emoji {
  font-size: 15px;
  line-height: 1;
}

.seg-text {
  white-space: nowrap;
}

.seg-sub {
  font-size: 10px;
  font-weight: 500;
  opacity: .72;
  white-space: nowrap;
}

/* 우선순위 단계별 색 */
.seg-priority .seg-opt.is-active.p1 { color: #b42318; }
.seg-priority .seg-opt.is-active.p2 { color: #9a6700; }
.seg-priority .seg-opt.is-active.p3 { color: #1a7f37; }
.seg-priority .seg-opt.is-active.p4,
.seg-priority .seg-opt.is-active.p5 { color: #57606a; }

html[data-theme="dark"] .seg-priority .seg-opt.is-active.p1 { color: #fca5a5; }
html[data-theme="dark"] .seg-priority .seg-opt.is-active.p2 { color: #fcd34d; }
html[data-theme="dark"] .seg-priority .seg-opt.is-active.p3 { color: #86efac; }
html[data-theme="dark"] .seg-priority .seg-opt.is-active.p4,
html[data-theme="dark"] .seg-priority .seg-opt.is-active.p5 { color: #cbd5e1; }

.seg[data-seg="stage"][data-value="reading"] .seg-thumb {
  box-shadow: 0 1px 3px rgba(29, 78, 216, .28), 0 0 0 1.5px rgba(59, 130, 246, .4);
}

.seg[data-seg="stage"][data-value="reviewed"] .seg-thumb {
  box-shadow: 0 1px 3px rgba(26, 127, 55, .26), 0 0 0 1.5px rgba(46, 160, 67, .4);
}

.seg-priority[data-value="1"] .seg-thumb {
  box-shadow: 0 1px 3px rgba(180, 35, 24, .24), 0 0 0 1.5px rgba(248, 81, 73, .42);
}

.seg-priority[data-value="2"] .seg-thumb {
  box-shadow: 0 1px 3px rgba(154, 103, 0, .22), 0 0 0 1.5px rgba(251, 188, 5, .44);
}


/* ════════════════════════════════════════════════════════
   2. 달력 (계획 주차 / 마감일)
   ════════════════════════════════════════════════════════ */
.cal-field {
  position: relative;
}

.cal-trigger {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 9px 11px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--pd-r-md);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  transition: border-color .16s ease, box-shadow .16s ease, background-color .16s ease;
}

.cal-trigger:hover {
  border-color: color-mix(in srgb, var(--primary) 45%, var(--line));
}

.cal-trigger[aria-expanded="true"] {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

.cal-icon {
  font-size: 15px;
  line-height: 1;
  flex-shrink: 0;
}

.cal-value {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.cal-main {
  font-size: 13.5px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-sub {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cal-caret {
  color: var(--muted);
  font-size: 10px;
  transition: transform .22s var(--pd-ease);
}

.cal-trigger[aria-expanded="true"] .cal-caret {
  transform: rotate(180deg);
}

.cal-field.is-empty .cal-main {
  color: var(--muted);
  font-weight: 500;
}

.cal-field.is-current .cal-main::after {
  content: "이번 주";
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 9.5px;
  font-weight: 700;
  vertical-align: middle;
  background: color-mix(in srgb, var(--primary) 15%, transparent);
  color: var(--primary);
}

.cal-pop {
  position: absolute;
  z-index: 120;
  top: calc(100% + 6px);
  left: 0;
  width: 296px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--pd-r-md);
  box-shadow: var(--pd-shadow-2);
  animation: pdPopIn .18s var(--pd-ease);
}

.cal-pop.is-right {
  left: auto;
  right: 0;
}

.cal-pop.is-up {
  top: auto;
  bottom: calc(100% + 6px);
}

.cal-pop[hidden] {
  display: none;
}

@keyframes pdPopIn {
  from {
    opacity: 0;
    transform: translateY(-5px) scale(.98);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.cal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 13.5px;
}

.cal-nav {
  width: 26px;
  height: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease, transform .12s ease;
}

.cal-nav:hover {
  background: var(--pd-soft);
  color: var(--text);
}

.cal-nav:active {
  transform: scale(.92);
}

.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
}

.cal-field[data-cal="week"] .cal-grid {
  grid-template-columns: 30px repeat(7, 1fr);
}

.cal-weekdays {
  font-size: 10.5px;
  color: var(--muted);
  text-align: center;
  padding-bottom: 4px;
  font-weight: 700;
}

.cal-weekdays span {
  padding: 2px 0;
}

.cal-wk {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.cal-row {
  border-radius: 8px;
  transition: background-color .15s ease;
}

.cal-row-pick {
  cursor: pointer;
}

.cal-row-pick:hover {
  background: color-mix(in srgb, var(--primary) 9%, transparent);
}

.cal-row.is-selected {
  background: color-mix(in srgb, var(--primary) 16%, transparent);
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--primary) 45%, transparent);
}

.cal-day {
  aspect-ratio: 1 / 1;
  min-height: 30px;
  border: none;
  background: none;
  border-radius: 8px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
  transition: background-color .14s ease, color .14s ease, transform .12s ease;
}

.cal-row-pick .cal-day {
  pointer-events: none;
}

.cal-day:hover {
  background: color-mix(in srgb, var(--primary) 14%, transparent);
}

.cal-day:active {
  transform: scale(.9);
}

.cal-day.is-out {
  color: color-mix(in srgb, var(--muted) 60%, transparent);
}

.cal-day.is-today {
  font-weight: 800;
  color: var(--primary);
}

.cal-day.is-selected {
  background: var(--primary) !important;
  color: #fff !important;
  font-weight: 700;
}

.cal-foot {
  display: flex;
  gap: 6px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid var(--line);
  flex-wrap: wrap;
}

.cal-foot .btn {
  flex: 1 1 auto;
  padding: 5px 8px;
  font-size: 12px;
}


/* ════════════════════════════════════════════════════════
   3. 워크플로우 페이지
   ════════════════════════════════════════════════════════ */
.wf {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wf-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--pd-r-lg);
  box-shadow: var(--pd-shadow-1);
}

.wf-head-main {
  min-width: 0;
  flex: 1 1 320px;
}

.wf-head-id {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .04em;
  margin-bottom: 3px;
}

.wf-head-title {
  margin: 0 0 6px;
  font-size: 18px;
  line-height: 1.4;
  word-break: break-word;
}

.wf-head-sub {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.55;
}

.wf-head-tags {
  margin: 5px 0 0;
  font-size: 11.5px;
  color: var(--muted);
}

.wf-head-meta {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.wf-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--pd-r-lg);
  padding: 16px 18px 18px;
  box-shadow: var(--pd-shadow-1);
  /* fill-mode 를 backwards 로 둔다 — both 로 두면 애니메이션 효과가 끝난 뒤에도
     계속 적용되어 카드마다 stacking context 가 생기고, 달력 팝오버가
     아래쪽 카드에 가려진다. */
  animation: pdCardIn .34s var(--pd-ease) backwards;
}

.wf-card:nth-of-type(2) { animation-delay: .04s; }
.wf-card:nth-of-type(3) { animation-delay: .08s; }
.wf-card:nth-of-type(4) { animation-delay: .12s; }

/* 팝오버가 열린 카드는 항상 형제 카드 위에 그린다 */
.wf-card.has-popover {
  position: relative;
  z-index: 200;
}

@keyframes pdCardIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: none;
  }
}

.wf-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  padding-bottom: 11px;
  border-bottom: 1px solid var(--line);
}

.wf-card-head>div:first-child {
  display: flex;
  align-items: center;
  gap: 9px;
}

.wf-card-head h3 {
  margin: 0;
  font-size: 15px;
}

.wf-step {
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  background: color-mix(in srgb, var(--primary) 13%, transparent);
  color: var(--primary);
  font-size: 11.5px;
  font-weight: 800;
  flex-shrink: 0;
}

.wf-card-hint {
  margin: 0;
  font-size: 11.5px;
  color: var(--muted);
}

.wf-badge {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  color: var(--muted);
  transition: background-color .25s ease, color .25s ease;
}

.wf-badge.is-done {
  background: rgba(46, 160, 67, .14);
  color: #1a7f37;
}

html[data-theme="dark"] .wf-badge.is-done {
  color: #86efac;
}

.wf-field {
  min-width: 0;
}

.wf-field+.wf-field {
  margin-top: 12px;
}

.wf-label {
  display: block;
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}

.wf-label-hint,
.wf-req {
  font-weight: 500;
  font-size: 11px;
  color: var(--muted);
  margin-left: 5px;
}

.wf-req {
  color: var(--primary);
  font-weight: 700;
}

.wf-plan {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wf-plan .wf-field+.wf-field {
  margin-top: 0;
}

.wf-field-wide {
  grid-column: 1 / -1;
}

.wf-minutes {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.wf-minutes input {
  width: 96px;
  flex: 0 0 auto;
}

.wf-chips {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.wf-chip {
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color .16s ease, border-color .16s ease, color .16s ease, transform .16s ease;
}

.wf-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  transform: translateY(-1px);
}

.wf-chip.is-active {
  background: color-mix(in srgb, var(--primary) 13%, transparent);
  border-color: var(--primary);
  color: var(--primary);
}

.wf-readonly {
  padding: 9px 11px;
  border: 1px dashed var(--line);
  border-radius: var(--pd-r-md);
  font-size: 12.5px;
  color: var(--muted);
  background: var(--pd-soft);
}

.wf-grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.wf-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.wf-grid-2 .wf-field+.wf-field,
.wf-grid-4 .wf-field+.wf-field {
  margin-top: 0;
}

.wf-more {
  margin-top: 14px;
}

.wf-more>summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--muted);
  padding: 8px 11px;
  border: 1px dashed var(--line);
  border-radius: var(--pd-r-md);
  list-style: none;
  transition: color .16s ease, border-color .16s ease, background-color .16s ease;
}

.wf-more>summary::-webkit-details-marker {
  display: none;
}

.wf-more>summary::before {
  content: "＋ ";
}

.wf-more[open]>summary::before {
  content: "－ ";
}

.wf-more>summary:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.wf-more[open]>summary {
  margin-bottom: 12px;
}

.wf-more .wf-grid-2 {
  animation: pdCardIn .26s var(--pd-ease) both;
}

.wf-form textarea {
  min-height: 0;
  line-height: 1.6;
}

/* 저장 바 */
.wf-savebar {
  position: sticky;
  bottom: 10px;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 10px 14px;
  /* 뒤 내용이 비쳐 보이면 지저분해지므로 불투명하게 둔다 */
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--pd-r-lg);
  box-shadow: var(--pd-shadow-2);
  transition: border-color .24s ease;
}

.wf-savebar.is-dirty {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--line));
}

.wf-savebar-state {
  font-size: 12px;
  color: var(--muted);
  transition: color .2s ease;
}

.wf-savebar.is-dirty .wf-savebar-state {
  color: var(--primary);
  font-weight: 700;
}

.wf-savebar.is-dirty .wf-savebar-state::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  margin-right: 6px;
  vertical-align: middle;
  animation: pdPulse 1.6s ease-in-out infinite;
}

@keyframes pdPulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: .3;
  }
}


/* ════════════════════════════════════════════════════════
   4. 미리보기 카드
   ════════════════════════════════════════════════════════ */
.wf-preview-card {
  background: linear-gradient(180deg, var(--panel), var(--pd-soft));
}

.wf-preview-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.wf-preview-live {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--primary);
  padding: 3px 9px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 12%, transparent);
}

.wf-preview-live::before {
  content: "";
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  animation: pdPulse 2s ease-in-out infinite;
}

.btn.is-copied {
  border-color: #86efac !important;
  color: #15803d !important;
}

.wf-preview {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.pv-head {
  padding-bottom: 12px;
  border-bottom: 2px solid var(--line);
}

.pv-title {
  font-size: 16px;
  font-weight: 800;
  line-height: 1.45;
  word-break: break-word;
}

.pv-sub {
  margin-top: 4px;
  font-size: 12px;
  color: var(--muted);
}

.pv-oneline {
  margin-top: 8px;
  padding: 7px 10px;
  background: var(--pd-soft-2);
  border-radius: var(--pd-r-sm);
  font-size: 12px;
  color: var(--muted);
  word-break: break-word;
}

.pv-progress {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 11.5px;
  color: var(--muted);
}

.pv-progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  overflow: hidden;
}

.pv-progress-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), color-mix(in srgb, var(--primary) 55%, #22c55e));
  transition: width .5s var(--pd-ease);
}

.pv-section-title {
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
}

.pv-list {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 0;
  margin: 0;
}

.pv-list dt {
  padding: 9px 12px 9px 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.pv-list dd {
  margin: 0;
  padding: 9px 0;
  font-size: 13px;
  line-height: 1.7;
  border-top: 1px solid var(--line);
  word-break: break-word;
}

.pv-list dt:first-of-type,
.pv-list dd:first-of-type {
  border-top: none;
}

.pv-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.pv-tag {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 12.5px;
  max-width: 100%;
  word-break: break-word;
}

.pv-tag b {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--primary);
}

.pv-note {
  margin: 9px 0 0;
  padding: 9px 12px;
  border-left: 3px solid var(--primary);
  background: var(--pd-soft-2);
  border-radius: 0 var(--pd-r-sm) var(--pd-r-sm) 0;
  font-size: 12.5px;
  line-height: 1.7;
}

.pv-empty {
  margin: 0;
  font-size: 12.5px;
  color: var(--muted);
  font-style: italic;
}

.wf-preview-fallback {
  padding: 12px 0;
}


/* ════════════════════════════════════════════════════════
   5. PDF 패널 빈 상태
   ════════════════════════════════════════════════════════ */
.pdf-empty-state {
  padding: 52px 20px;
  text-align: center;
}

.pdf-empty-icon {
  font-size: 40px;
  margin-bottom: 12px;
  opacity: .75;
}

.pdf-empty-title {
  margin: 0 0 6px;
  font-size: 14.5px;
  font-weight: 700;
}

.pdf-empty-desc {
  margin: 0 0 16px;
  font-size: 12.5px;
  color: var(--muted);
}


/* ════════════════════════════════════════════════════════
   6. 칸반 / 대시보드
   ════════════════════════════════════════════════════════ */
.kanban-col {
  border-radius: var(--pd-r-lg);
}

.kanban-card {
  border-radius: var(--pd-r-md);
  transition: box-shadow .18s ease, transform .18s var(--pd-ease), border-color .18s ease;
}

.kanban-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--pd-shadow-1);
  border-color: color-mix(in srgb, var(--primary) 32%, var(--line));
}

.kanban-card.dragging {
  transform: rotate(1.4deg) scale(.98);
}

.kanban-col-body.drag-over {
  box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--primary) 40%, transparent);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
}

.stat-tile {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--pd-r-md);
  background: var(--pd-soft);
  transition: transform .2s var(--pd-ease), box-shadow .2s ease;
}

.stat-tile:hover {
  transform: translateY(-2px);
  box-shadow: var(--pd-shadow-1);
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .03em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.stat-value small {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  margin-left: 3px;
}

.stat-bar {
  margin-top: 9px;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  overflow: hidden;
}

.stat-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #22c55e);
  transition: width .6s var(--pd-ease);
}

.wf-empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.8;
  border: 1px dashed var(--line);
  border-radius: var(--pd-r-md);
  background: var(--pd-soft);
}

.row-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--pd-r-md);
  background: var(--panel);
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s var(--pd-ease);
}

.row-card:hover {
  border-color: color-mix(in srgb, var(--primary) 30%, var(--line));
  box-shadow: var(--pd-shadow-1);
  transform: translateY(-1px);
}

.row-card + .row-card {
  margin-top: 9px;
}

.row-card-main {
  min-width: 0;
  flex: 1 1 260px;
}

.row-card-title {
  font-weight: 700;
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.row-card-title a {
  color: inherit;
  text-decoration: none;
}

.row-card-title a:hover {
  color: var(--primary);
  text-decoration: underline;
}


/* ════════════════════════════════════════════════════════
   7. 반응형
   ════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .wf-grid-4 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {

  .wf-plan,
  .wf-grid-2,
  .wf-grid-4 {
    grid-template-columns: 1fr;
  }

  .pv-list {
    grid-template-columns: 1fr;
  }

  .pv-list dt {
    padding-bottom: 0;
  }

  .pv-list dd {
    padding-top: 3px;
    border-top: none;
  }

  .seg-opt {
    font-size: 12px;
    padding: 8px 3px;
  }

  .seg-sub {
    display: none;
  }

  .cal-pop {
    width: min(296px, calc(100vw - 40px));
  }

  .wf-card {
    padding: 14px;
  }
}

/* 슬라이드 패널 안(좁은 폭)에서의 워크플로우 */
.detail-panel-body .wf-plan,
.detail-panel-body .wf-grid-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.detail-panel-body .wf-grid-2 {
  grid-template-columns: 1fr;
}

.detail-panel-body .wf-head-title {
  font-size: 16px;
}

.detail-panel-body .seg-sub {
  display: none;
}

.detail-panel-body .pv-list {
  grid-template-columns: 108px minmax(0, 1fr);
}

.detail-panel-body .wf-savebar {
  bottom: 0;
}


/* ════════════════════════════════════════════════════════
   8. 모션 최소화
   ════════════════════════════════════════════════════════ */
@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  .wf-card,
  .cal-pop,
  .flash,
  .wf-more .wf-grid-2 {
    animation: none !important;
  }

  .btn:hover,
  .ref-card:hover,
  .kanban-card:hover,
  .stat-tile:hover,
  .wf-chip:hover,
  .row-card:hover {
    transform: none;
  }

  .seg-thumb,
  .pv-progress-bar i,
  .stat-bar i,
  .cal-caret {
    transition: none !important;
  }

  .wf-savebar.is-dirty .wf-savebar-state::before,
  .wf-preview-live::before {
    animation: none;
  }
}



/* ============================================================
   PaperDesk 관리자 화면
   ============================================================ */

/* ── 상단 관리자 버튼 ─────────────────────────────────── */
.btn-admin {
  font-weight: 700;
}

html .topbar .btn-admin,
html[data-theme="dark"] .topbar .btn-admin {
  background: linear-gradient(180deg, #f59e0b, #d97706) !important;
  color: #fff !important;
  border-color: transparent !important;
  box-shadow: 0 2px 8px rgba(217, 119, 6, .32) !important;
}

html .topbar .btn-admin:hover,
html[data-theme="dark"] .topbar .btn-admin:hover {
  background: linear-gradient(180deg, #d97706, #b45309) !important;
  color: #fff !important;
  border-color: transparent !important;
}

html .topbar .btn-admin.is-active,
html[data-theme="dark"] .topbar .btn-admin.is-active {
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .85),
    0 0 0 4px rgba(217, 119, 6, .45) !important;
}

/* 관리자 메뉴 클러스터 톤 */
.menu-cluster-admin {
  border-color: rgba(217, 119, 6, .28);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, .9) inset,
    0 0 0 3px rgba(217, 119, 6, .07),
    0 8px 20px rgba(0, 0, 0, .04);
}

.menu-cluster-admin::before {
  border-color: rgba(217, 119, 6, .2);
}

.menu-cluster-admin .nav-secondary a.active,
.menu-cluster-admin .nav-secondary a[aria-current="page"] {
  background: rgba(217, 119, 6, .13);
  border-color: rgba(217, 119, 6, .3);
  color: #b45309;
}

html[data-theme="dark"] .topbar .menu-cluster-admin .nav-secondary a.active,
html[data-theme="dark"] .topbar .menu-cluster-admin .nav-secondary a[aria-current="page"] {
  background: rgba(245, 158, 11, .18) !important;
  border-color: rgba(245, 158, 11, .4) !important;
  color: #fcd34d !important;
}

/* ── 표 ───────────────────────────────────────────────── */
.adm-scroll {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: var(--pd-r-md);
}

.adm-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}

.adm-table th,
.adm-table td {
  padding: 9px 12px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.adm-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--pd-soft);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: .05em;
  color: var(--muted);
}

.adm-table tbody tr {
  transition: background-color .14s ease;
}

.adm-table tbody tr:hover {
  background: color-mix(in srgb, var(--primary) 5%, transparent);
}

.adm-table tbody tr:last-child td {
  border-bottom: none;
}

.adm-table tbody tr.is-dim {
  opacity: .55;
}

.adm-table form {
  display: inline;
}

.adm-num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.adm-mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: var(--muted);
}

.adm-detail {
  white-space: normal !important;
  max-width: 340px;
  line-height: 1.55;
}

/* ── 라벨 / 배지 ──────────────────────────────────────── */
.adm-who {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.adm-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  color: var(--muted);
  border: 1px solid transparent;
}

.adm-tag-admin {
  background: rgba(217, 119, 6, .15);
  color: #b45309;
  border-color: rgba(217, 119, 6, .3);
}

.adm-tag-on {
  background: rgba(34, 197, 94, .16);
  color: #15803d;
  border-color: rgba(34, 197, 94, .32);
}

.adm-tag-on::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  animation: pdPulse 2s ease-in-out infinite;
}

.adm-tag-off {
  background: color-mix(in srgb, var(--muted) 12%, transparent);
}

.adm-tag-warn {
  background: rgba(239, 68, 68, .13);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, .28);
}

html[data-theme="dark"] .adm-tag-admin { color: #fcd34d; }
html[data-theme="dark"] .adm-tag-on { color: #86efac; }
html[data-theme="dark"] .adm-tag-warn { color: #fca5a5; }

.adm-sub {
  margin-top: 3px;
  font-size: 11.5px;
  color: var(--muted);
  white-space: normal;
}

.adm-hint {
  margin-top: 6px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
}

.adm-inline-link {
  margin-left: 6px;
  font-size: 11.5px;
}

/* ── 사용량 막대 ──────────────────────────────────────── */
.adm-usage {
  display: flex;
  align-items: center;
  gap: 9px;
}

.adm-bar {
  flex: 1;
  min-width: 60px;
  height: 7px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--muted) 18%, transparent);
  overflow: hidden;
}

.adm-bar i {
  display: block;
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), #22c55e);
  transition: width .6s var(--pd-ease);
}

.adm-bar i.is-warn {
  background: linear-gradient(90deg, #f59e0b, #d97706);
}

.adm-bar i.is-danger {
  background: linear-gradient(90deg, #ef4444, #b91c1c);
}

.adm-usage-num {
  flex: 0 0 auto;
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  min-width: 62px;
  text-align: right;
}

/* ── 키/값 목록 ───────────────────────────────────────── */
.adm-kv {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 0;
  margin: 0;
  font-size: 13px;
}

.adm-kv dt {
  padding: 9px 12px 9px 0;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--muted);
  border-top: 1px solid var(--line);
}

.adm-kv dd {
  margin: 0;
  padding: 9px 0;
  border-top: 1px solid var(--line);
  word-break: break-word;
  line-height: 1.6;
}

.adm-kv dt:first-of-type,
.adm-kv dd:first-of-type {
  border-top: none;
}

/* ── 사용자 카드 ──────────────────────────────────────── */
.adm-user-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.adm-user-head > div:first-child {
  min-width: 0;
  flex: 1 1 300px;
}

.adm-user-usage {
  flex: 0 0 auto;
  min-width: 190px;
}

.adm-metrics {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--muted);
}

.adm-metrics > span {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--pd-soft);
}

.adm-metrics b {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.adm-note {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid #d97706;
  background: rgba(217, 119, 6, .08);
  border-radius: 0 var(--pd-r-sm) var(--pd-r-sm) 0;
  font-size: 12.5px;
  line-height: 1.65;
}

.adm-manage {
  margin-top: 14px;
}

.adm-manage-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 12px;
}

.adm-box {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--pd-r-md);
  background: var(--pd-soft);
}

.adm-box h4 {
  margin: 0 0 10px;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: .02em;
}

.adm-box-danger {
  border-color: rgba(239, 68, 68, .32);
  background: rgba(239, 68, 68, .05);
}

.adm-box-danger h4 {
  color: #b91c1c;
}

html[data-theme="dark"] .adm-box-danger h4 {
  color: #fca5a5;
}

.adm-inline-form {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ── 로그 ─────────────────────────────────────────────── */
.adm-log {
  margin: 10px 0 0;
  padding: 12px 14px;
  max-height: 420px;
  overflow: auto;
  background: var(--pd-soft-2);
  border: 1px solid var(--line);
  border-radius: var(--pd-r-md);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 11.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--text);
}

@media (max-width: 760px) {
  .adm-kv {
    grid-template-columns: 1fr;
  }

  .adm-kv dt {
    padding-bottom: 0;
  }

  .adm-kv dd {
    padding-top: 3px;
    border-top: none;
  }

  .adm-user-usage {
    min-width: 100%;
  }
}

/* ── 누락된 input 타입 보정 ──────────────────────────────
   기존 전역 규칙이 text/url/number/file 만 대상으로 해서
   password / email / date 입력이 브라우저 기본 모양으로 남아 있었다. */
input[type="password"],
input[type="email"],
input[type="date"],
input[type="search"],
input[type="tel"],
input[type="time"],
input[type="month"],
input[type="week"],
input[type="datetime-local"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: var(--panel);
  color: var(--text);
  box-sizing: border-box;
  transition: border-color .16s ease, box-shadow .16s ease, background-color .2s ease;
}

input[type="password"]:focus,
input[type="email"]:focus,
input[type="date"]:focus,
input[type="search"]:focus,
input[type="tel"]:focus,
input[type="time"]:focus,
input[type="month"]:focus,
input[type="week"]:focus,
input[type="datetime-local"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 16%, transparent);
}

html[data-theme="dark"] input[type="password"],
html[data-theme="dark"] input[type="email"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="search"],
html[data-theme="dark"] input[type="tel"] {
  background: #1a2332 !important;
  color: #e5e7eb !important;
  border: 1px solid #334155 !important;
}
