/* ═══════════════════════════════════════════
   TOKENS
═══════════════════════════════════════════ */
:root {
  --bg:#0d0d0f; --surface:#1a1a1f; --surface2:#22222a; --border:#34343f;
  --accent:#f0cc45; --accent2:#ff6b6b; --accent3:#5bc8ff;
  --text:#f5f4fa; --text2:#b0abbe; --r:14px;
  --nav:64px; --tab:60px;
} 
body.light {
  --bg:#e8e9f0; --surface:#ffffff; --surface2:#f1f2f8; --border:#d1d2db;
  --accent:#b38f00; --accent2:#d94f4f; --accent3:#0077cc;
  --text:#111118; --text2:#333340;
}

/* ═══════════════════════════════════════════
   RESET & BASE
═══════════════════════════════════════════ */
*{margin:0;padding:0;box-sizing:border-box;-webkit-tap-highlight-color:transparent;}
body{background:var(--bg);color:var(--text);font-family:'DM Sans',sans-serif;transition:background .3s,color .3s;}
body::before{content:'';position:fixed;inset:0;background-image:url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");pointer-events:none;z-index:0;opacity:.5;}
a{text-decoration:none;color:inherit;}
button{font-family:'DM Sans',sans-serif;cursor:pointer;}
input,select,textarea{font-family:'DM Sans',sans-serif;}

/* ════════════════ VIEW WRAPPERS ════════════════ */
#dv{display:block;min-height:100vh;position:relative;z-index:1;}
#mv{display:none;height:100dvh;flex-direction:column;overflow:hidden;position:relative;z-index:1;}
body.mobile #dv{display:none;}
body.mobile #mv{display:flex;}
body.mobile{overflow:hidden;height:100dvh;}

/* ════════════════ SHARED COMPONENTS ════════════════ */
.overlay{
  position:fixed;
  inset:0;
  background:rgba(0,0,0,.7);
  backdrop-filter:blur(8px);
  z-index:500;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:1rem;
  opacity:0;
  pointer-events:none;
  transition:opacity .2s;
}
body.light .overlay{background:rgba(0,0,0,.4);}
.overlay.open{opacity:1;pointer-events:all;}

.modal{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:20px;
  padding:2rem;
  width:100%;
  max-width:500px;
  transform:scale(.95);
  transition:transform .2s;
  max-height:90vh;
  overflow-y:auto;
  box-shadow:0 20px 50px rgba(0,0,0,0.3);
  position:relative;
  z-index:1;
}
body.light .modal{box-shadow:0 15px 40px rgba(0,0,0,0.12);border-color:#dcdce6;}
.overlay.open .modal{transform:scale(1);}

body.modal-open{
  overflow:hidden;
}

/* ════════════════ SETTINGS PANEL (shared overlay) ════════════════ */
#settingsPanel{
  position:fixed;
  inset:0;
  z-index:600;
  background:rgba(0,0,0,.75);
  backdrop-filter:blur(8px);
  opacity:0;
  pointer-events:none;
  transition:opacity .25s;
  display:flex;
  align-items:flex-start;
  justify-content:center;
  padding:2.5rem 1.5rem;
}
#settingsPanel.open{opacity:1;pointer-events:all;}

/* 설정에서 여는 모든 서브 모달은 settingsPanel 위 */
#categoryManageOverlay,
#helpOverlay,
#inquiryOverlay,
#addCatOverlay,
#categoryPinOverlay{
  z-index:700;
}

#categoryManageOverlay .modal,
#helpOverlay .modal,
#inquiryOverlay .modal,
#addCatOverlay .modal,
#categoryPinOverlay .modal{
  position:relative;
  z-index:1;
}

/* 잠금 오버레이는 가장 위 */
#lockOverlay{
  z-index:800;
}
#lockOverlay .modal{
  max-width:400px;
}
.modal-hd{font-family:'Playfair Display',serif;font-size:1.4rem;margin-bottom:1.4rem;display:flex;align-items:center;justify-content:space-between;}
.modal-ft{display:flex;gap:.75rem;justify-content:flex-end;margin-top:1.4rem;padding-top:1.4rem;border-top:1px solid var(--border);}

.field{margin-bottom:1rem;}
.field label{display:block;font-size:.75rem;font-weight:600;color:var(--text2);margin-bottom:.35rem;text-transform:uppercase;letter-spacing:1px;}
.field input,.field select,.field textarea{width:100%;background:var(--surface2);border:1px solid var(--border);border-radius:12px;padding:.65rem .9rem;color:var(--text);font-size:.9rem;outline:none;transition:all .2s;-webkit-appearance:none;appearance:none;}
.field input:focus,.field select:focus,.field textarea:focus{border-color:var(--accent);box-shadow:0 0 0 3px rgba(179,143,0,0.1);}
body.light .field input,body.light .field select,body.light .field textarea{background:#fff;}

.btn{background:var(--accent);color:#000;border:none;border-radius:10px;padding:.65rem 1.25rem;font-weight:600;font-size:.9rem;cursor:pointer;transition:all .15s;display:inline-flex;align-items:center;gap:.4rem;box-shadow:0 4px 12px rgba(179,143,0,0.2);}
body.light .btn{color:#fff;}
.btn:hover{transform:translateY(-1px);box-shadow:0 6px 20px rgba(179,143,0,0.3);}
.btn-ghost{background:transparent;color:var(--text2);border:1px solid var(--border);box-shadow:none;}
body.light .btn-ghost{color:var(--text2);background:#fff;}
.btn-ghost:hover{border-color:var(--text);color:var(--text);box-shadow:none;transform:none;}
.btn-danger{background:var(--accent2);color:#fff;box-shadow:0 4px 12px rgba(217,79,79,0.2);}
.btn-danger:hover{box-shadow:0 6px 20px rgba(217,79,79,0.3);}
.icon-btn{background:none;border:none;color:var(--text2);width:30px;height:30px;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:.9rem;transition:all .15s;}
.icon-btn:hover{background:var(--surface2);color:var(--text);}

.s-row{display:flex;align-items:center;justify-content:space-between;padding:.7rem 0;border-bottom:1px solid var(--border);font-size:.9rem;}
.s-row:last-child{border-bottom:none;}
.s-label{display:flex;align-items:center;gap:.6rem;}
.s-section{font-size:.7rem;font-weight:500;letter-spacing:2px;text-transform:uppercase;color:var(--text2);margin:1rem 0 .4rem;}
.s-btn{display:flex;align-items:center;gap:.6rem;padding:.6rem .8rem;border-radius:12px;background:var(--surface2);border:none;color:var(--text);font-size:.88rem;width:100%;margin-bottom:.3rem;transition:all .15s;}
.s-btn:hover,.s-btn:active{background:var(--border);}
.s-btn.danger{color:var(--accent2);}
.s-grid{display:grid;grid-template-columns:1fr 1fr;gap:.5rem;margin-bottom:.3rem;}
.s-btn-v{flex-direction:column;gap:.3rem;text-align:center;padding:.8rem .5rem;}
.s-btn-v span:first-child{font-size:1.2rem;}

.toggle{width:44px;height:26px;background:var(--border);border-radius:999px;position:relative;cursor:pointer;transition:background .2s;flex-shrink:0;border:none;}
.toggle.on{background:var(--accent);}
body.light .toggle.on{background:#c9a800;}
.toggle::after{content:'';position:absolute;width:20px;height:20px;background:white;border-radius:50%;top:3px;left:3px;transition:transform .2s;box-shadow:0 1px 4px rgba(0,0,0,.3);}
.toggle.on::after{transform:translateX(18px);}

.lock-wrap{position:relative;}
.lock-wrap input{padding-right:2.5rem;}
.lock-eye{position:absolute;right:.75rem;top:50%;transform:translateY(-50%);background:none;border:none;cursor:pointer;color:var(--text2);font-size:1rem;}
.lock-err{color:var(--accent2);font-size:.8rem;margin-top:.3rem;display:none;}
.lock-err.show{display:block;}

.img-prev{width:100%;height:110px;border-radius:12px;border:2px dashed var(--border);display:flex;align-items:center;justify-content:center;cursor:pointer;color:var(--text2);font-size:.85rem;position:relative;overflow:hidden;transition:border-color .2s;}
.img-prev:hover{border-color:var(--accent);}
.img-prev img{position:absolute;inset:0;width:100%;height:100%;object-fit:cover;}

.tag-chip{background:var(--surface2);border:1px solid var(--border);color:var(--text2);border-radius:999px;padding:3px 12px;font-size:.78rem;cursor:pointer;transition:all .15s;white-space:nowrap;flex-shrink:0;}
.tag-chip:hover{border-color:var(--accent3);color:var(--accent3);}
.tag-chip.on{background:var(--accent3);border-color:var(--accent3);color:#000;font-weight:500;}
body.light .tag-chip.on{background:#0088cc;border-color:#0088cc;color:#fff;}

.exp-badge{display:inline-flex;align-items:center;background:var(--accent2);color:#fff;font-size:.7rem;font-weight:600;padding:2px 8px;border-radius:999px;}

.empty-state{text-align:center;padding:4rem 2rem;color:var(--text2);}
.empty-state .ei{font-size:3rem;margin-bottom:.75rem;}
.empty-state h3{font-family:'Playfair Display',serif;font-size:1.3rem;color:var(--text);margin-bottom:.4rem;}

.ctag{background:rgba(91,200,255,.1);border:1px solid rgba(91,200,255,.25);color:var(--accent3);border-radius:999px;padding:1px 8px;font-size:.72rem;cursor:pointer;}
body.light .ctag{background:rgba(0,136,204,.1);border-color:rgba(0,136,204,.3);color:#0077bb;}

.sh{scrollbar-width:none;}
.sh::-webkit-scrollbar{display:none;}

.toast{position:fixed;bottom:5rem;left:50%;transform:translateX(-50%) translateY(20px);background:var(--surface);border:1px solid var(--border);border-radius:999px;padding:.5rem 1.2rem;font-size:.85rem;z-index:999;opacity:0;transition:all .3s;pointer-events:none;white-space:nowrap;}
.toast.show{opacity:1;transform:translateX(-50%) translateY(0);}

.share-view{display:none;min-height:100vh;padding:3rem 1.5rem;background:radial-gradient(1200px 800px at 20% -10%, rgba(91,200,255,.08), transparent 60%), radial-gradient(900px 600px at 100% 0, rgba(255,107,107,.08), transparent 55%);position:relative;z-index:1;}
.share-view.on{display:block;}
.share-card{max-width:680px;margin:0 auto;background:var(--surface);border:1px solid var(--border);border-radius:20px;padding:2rem;box-shadow:0 20px 60px rgba(0,0,0,.35);}
.share-badge{display:inline-flex;align-items:center;gap:.4rem;background:var(--surface2);border:1px solid var(--border);color:var(--text2);border-radius:999px;padding:.35rem .85rem;font-size:.78rem;margin-bottom:1rem;}
.share-title{font-family:'Playfair Display',serif;font-size:2rem;margin-bottom:.4rem;}
.share-url{font-size:.85rem;color:var(--text2);word-break:break-all;margin-bottom:1rem;}
.share-meta{display:flex;flex-wrap:wrap;gap:.4rem;margin:.8rem 0 1.2rem;}
.share-meta .ctag{font-size:.74rem;}
.share-actions{display:flex;flex-wrap:wrap;gap:.6rem;margin-top:1.4rem;}
.share-img{width:100%;height:200px;border-radius:16px;overflow:hidden;border:1px solid var(--border);background:var(--surface2);display:flex;align-items:center;justify-content:center;margin-bottom:1rem;}
.share-img img{width:100%;height:100%;object-fit:cover;}
.share-exp{margin-top:.5rem;font-size:.85rem;color:var(--text2);}
.share-exp.expired{color:var(--accent2);}

.share-row{display:flex;gap:.6rem;align-items:center;}
.share-row input,.share-row select{flex:1;}
.share-tip{font-size:.78rem;color:var(--text2);margin-top:.4rem;}
.share-list{display:grid;grid-template-columns:repeat(auto-fill,minmax(220px,1fr));gap:.8rem;margin-top:1rem;}
.share-item{border:1px solid var(--border);border-radius:14px;padding:.8rem;background:var(--surface2);display:flex;gap:.7rem;align-items:flex-start;}
.share-item img{width:36px;height:36px;object-fit:contain;border-radius:8px;background:var(--surface);}
.share-item .t{font-weight:600;font-size:.92rem;color:var(--text);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.share-item .u{font-size:.75rem;color:var(--text2);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.share-item .c{font-size:.7rem;color:var(--accent3);text-transform:uppercase;letter-spacing:.5px;}
.share-edit{margin-top:1rem;border-top:1px solid var(--border);padding-top:1rem;}

.picker-mode{display:block;width:100%;}
.picker-wrap{padding:0;}
.picker-hd{font-family:'Playfair Display',serif;font-size:1.8rem;font-weight:700;margin-bottom:.35rem;}
.picker-sub{font-size:.9rem;color:var(--text2);margin-bottom:1.75rem;}
.picker-grid{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(135px, 150px));
  gap:.75rem;
  justify-content:start;
}
.pcard{
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:16px;
  overflow:hidden;
  cursor:pointer;
  transition:all .2s;
  display:flex;
  flex-direction:column;
  width:100%;
  min-width:0;
}
.pcard:hover{border-color:var(--accent);transform:translateY(-3px);box-shadow:0 10px 30px rgba(0,0,0,.25);}
body.light .pcard:hover{box-shadow:0 6px 20px rgba(0,0,0,.1);}
.pcard-thumb{
  height:92px;
  background:var(--surface2);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:2.2rem;
  border-bottom:1px solid var(--border);
}
.pcard-body{
  padding:.75rem .85rem;
}
.pcard-name{
  font-weight:600;
  font-size:.9rem;
  margin-bottom:.25rem;
  color:var(--text);
}
.pcard-count{
  font-size:.74rem;
  color:var(--text2);
}
.pcard.is-locked .pcard-thumb{position:relative;}
.pcard.is-locked .pcard-thumb::after{content:'🔒';position:absolute;bottom:.3rem;right:.5rem;font-size:1rem;}

.m-picker-wrap{padding:.75rem .75rem .5rem;}
.m-picker-grid{display:grid;gap:.7rem;}
.m-pcard{display:flex;align-items:center;gap:.8rem;background:var(--surface);border:1px solid var(--border);border-radius:14px;padding:.85rem;}
.m-picon{font-size:1.6rem;width:42px;display:flex;align-items:center;justify-content:center;}
.m-pname{font-weight:600;}
.m-pcount{font-size:.78rem;color:var(--text2);}

/* Batch Bar */
.batch-bar { position:fixed; bottom:-80px; left:50%; transform:translateX(-50%); background:var(--surface); border:1px solid var(--accent); border-radius:16px; padding:.75rem 1.25rem; display:flex; align-items:center; gap:1.5rem; box-shadow:0 10px 40px rgba(0,0,0,.5); z-index:900; transition:bottom .3s cubic-bezier(.4,0,.2,1); }
.batch-bar.show { bottom:2rem; }
#mv .batch-bar.show { bottom: calc(var(--tab) + 1rem); width: calc(100% - 2rem); padding:.75rem; gap: .75rem; justify-content:space-between;}
.batch-count { font-weight:700; color:var(--accent); white-space:nowrap;}
.chk-box { width:20px; height:20px; accent-color:var(--accent); cursor:pointer; }
/* Dead link state */
.dead-link { opacity: 0.5; }
.dead-badge { background:var(--accent2); color:white; font-size:.65rem; padding:2px 6px; border-radius:999px; margin-left:.4rem; font-weight:bold; }

/* ════════════════ DESKTOP LAYOUT ════════════════ */
#dv header{position:sticky;top:0;z-index:100;background:rgba(13,13,15,.88);backdrop-filter:blur(20px);border-bottom:1px solid var(--border);padding:0 2rem;display:flex;align-items:center;justify-content:space-between;height:var(--nav);transition:background .3s;}
body.light #dv header{background:rgba(240,239,244,.95);border-bottom-color:#c8c6d0;}
#dv .logo{font-family:'Playfair Display',serif;font-size:1.5rem;font-weight:900;cursor:pointer;}
#dv .logo span{color:var(--accent);}
#dv .hdr-actions{display:flex;gap:.75rem;align-items:center;}
#dv .search-wrap{position:relative;flex:1;max-width:360px;margin:0 2rem;}
#dv .search-wrap input{width:100%;background:var(--surface2);border:1px solid var(--border);border-radius:999px;padding:.5rem 2.4rem .5rem 1rem;color:var(--text);font-size:.9rem;outline:none;transition:border-color .2s;}
#dv .search-wrap input:focus{border-color:var(--accent);}
#dv .search-ic{position:absolute;right:.85rem;top:50%;transform:translateY(-50%);width:14px;height:14px;pointer-events:none;color:var(--text2);}
#dv .view-toggle{display:flex;background:var(--surface2);border-radius:8px;padding:3px;gap:2px;}
#dv .vbtn{background:none;border:none;color:var(--text2);padding:5px 8px;border-radius:6px;font-size:.9rem;transition:all .15s;}
#dv .vbtn.on{background:var(--surface);color:var(--text);}
#dv .layout{display:grid;grid-template-columns:240px 1fr;min-height:calc(100vh - var(--nav));}
/* ════════════════ SIDEBAR ELEMENTS REDESIGN ════════════════ */
#dv aside{
  border-right:1px solid var(--border);
  padding:1rem;
  position:sticky;
  top:var(--nav);
  height:calc(100vh - var(--nav));
  background:var(--bg);
  z-index:10;
  display:flex;
  flex-direction:column;
  gap:1rem;
  overflow:hidden;
}

body.light #dv aside{
  background:#f0f1f7;
  border-right-color:#d8d9e3;
}

#dv .sidebar-top{
  flex:0 0 auto;
}

#dv .sidebar-middle{
  flex:1 1 auto;
  min-height:0;
  overflow-y:auto;
  padding-right:4px;
}

#dv .sidebar-bottom{
  flex:0 0 auto;
  padding-top:.25rem;
  border-top:1px solid var(--border);
  background:var(--bg);
}

body.light #dv .sidebar-bottom{
  background:#f0f1f7;
}

/* ===== Sidebar Premium Cleanup ===== */

/* ===== Sidebar vertical rhythm fix ===== */

/* 제목 간격 */
#dv .sb-title{
  font-size:.72rem !important;
  font-weight:800 !important;
  letter-spacing:1.8px !important;
  text-transform:uppercase !important;
  color:var(--text2) !important;
  background:rgba(255,255,255,0.03) !important;
  display:flex !important;
  align-items:center !important;
  gap:8px !important;
  border:1px solid var(--border) !important;
  padding:.5rem .85rem !important;
  margin:12px 0 8px !important;
  border-radius:14px !important;
}

/* 첫 번째 제목 위 여백 제거 */
#dv aside .sb-title:first-child{
  margin-top:0 !important;
}

/* 사이드바 리스트 구조 */
#dv #d-catList{
  display:flex !important;
  flex-direction:column !important;
  gap:8px !important;
  align-items:stretch !important;
}

#dv #d-catList .cat-item{
  width:100% !important;
  margin-bottom:8px !important;
}

body.light #dv .sb-title{
  background:rgba(255,255,255,0.7) !important;
  border-color:#d8dce8 !important;
  color:#4b5565 !important;
}

#dv .sb-title::before{
  content:'' !important;
  width:4px !important;
  height:14px !important;
  background:linear-gradient(180deg, var(--accent3), var(--accent)) !important;
  border-radius:999px !important;
}

/* 카테고리 카드 */
#d-catTop .cat-item,
#d-catList .cat-item{
  display:flex !important;
  flex-direction:row !important;
  align-items:center !important;
  gap:6px !important;
  min-height:56px;
  padding:0 12px;
  border-radius:18px;
  overflow:hidden;
}

#d-catTop,
#d-catList{
  overflow:hidden !important;
}

#d-catTop .cat-item > * ,
#d-catList .cat-item > *{
  vertical-align:middle !important;
}

/* 제목 바로 아래 카드 */
#dv .sb-title + .cat-item{
  margin-top:2px !important;
}

/* 두 섹션 사이 여백 */
#dv .cat-item + .sb-title{
  margin-top:18px !important;
}

body.light #dv .cat-item{
  background:rgba(255,255,255,0.72) !important;
  border-color:#dde1ec !important;
}

/* hover */
#dv .cat-item:hover{
  background:var(--surface2) !important;
  color:var(--text) !important;
  transform:translateY(-1px) !important;
  border-color:var(--border) !important;
  box-shadow:0 6px 16px rgba(0,0,0,.12) !important;
}

body.light #dv .cat-item:hover{
  background:#fff !important;
  border-color:rgba(0,119,204,.18) !important;
  box-shadow:0 6px 16px rgba(0,0,0,.06) !important;
}

/* 활성 */
#dv .cat-item.on{
  background:linear-gradient(135deg, var(--surface2) 0%, var(--surface) 100%) !important;
  color:var(--text) !important;
  font-weight:700 !important;
  border-color:var(--accent) !important;
  box-shadow:0 8px 20px rgba(0,0,0,.2) !important;
}

body.light #dv .cat-item.on{
  background:linear-gradient(135deg, #ffffff 0%, #f7f8fc 100%) !important;
  border-color:var(--accent) !important;
  color:#111 !important;
  box-shadow:0 8px 18px rgba(0,0,0,.07) !important;
}

/* 잠금 아이콘 */
#d-catTop .cat-lock,
#d-catList .cat-lock{
  width:10px;
  min-width:10px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:10px;
  line-height:1;
  flex:0 0 10px;
  opacity:.95;
}

/* 아이콘 */
#d-catTop .cat-icon,
#d-catList .cat-icon{
  width:22px;
  min-width:22px;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:1.05rem;
  line-height:1;
  flex:0 0 22px;
}

/* 이름 */
#d-catTop .cat-name,
#d-catList .cat-name{
  min-width:0;
  flex:1 1 auto;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-size:1rem;
  line-height:1.2;
  color:var(--text);
}

#d-catTop .cat-item.locked .cat-name,
#d-catList .cat-item.locked .cat-name{
  opacity:1 !important;
}

/* Spacer */
#d-catTop .cat-spacer,
#d-catList .cat-spacer{
  flex:0 0 2px;
  min-width:2px;
}

/* 별 버튼 */
#d-catTop .cat-star-btn,
#d-catList .cat-star-btn{
  width:20px;
  min-width:20px;
  height:20px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0;
  font-size:.82rem;
  line-height:1;
  border:none;
  background:transparent;
  flex:0 0 20px;
}

#dv .cat-item:hover .cat-star-btn{
  opacity:.9 !important;
}

#d-catTop .cat-star-btn:hover,
#d-catList .cat-star-btn:hover{
  background:rgba(240,204,69,.12) !important;
  color:var(--accent) !important;
  opacity:1 !important;
  transform:scale(1.08) !important;
}

/* 카운트 pill */
#d-catTop .cat-count,
#d-catList .cat-count{
  min-width:28px;
  height:28px;
  padding:0 6px;
  display:flex;
  align-items:center;
  justify-content:center;
  border-radius:999px;
  flex:0 0 28px;
  font-size:.88rem;
  font-weight:700;
  line-height:1;
  color:var(--text) !important;
  background:rgba(255,255,255,.04) !important;
  border:1px solid var(--border) !important;
}

#d-catTop .cat-item.locked .cat-count,
#d-catList .cat-item.locked .cat-count{
  opacity:.95 !important;
}

#d-catTop .cat-item.locked .cat-count,
#d-catList .cat-item.locked .cat-count{
  opacity:.32;
  filter:grayscale(.15) saturate(.7);
}

body.light #dv .cat-count{
  background:#f5f7fb !important;
  border-color:#d6dbe7 !important;
  color:#1c2230 !important;
}

#dv .cat-item.on .cat-count{
  background:var(--accent) !important;
  color:#000 !important;
  border-color:rgba(0,0,0,.08) !important;
}

body.light #dv .cat-item.on .cat-count{
  color:#fff !important;
}

/* + 카테고리 추가 / 뒤로가기 버튼 */
#dv .add-cat{
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  gap:.5rem !important;
  padding:.95rem 1rem !important;
  border-radius:18px !important;
  font-size:.9rem !important;
  font-weight:700 !important;
  color:var(--text2) !important;
  margin-top:.9rem !important;
  border:2px dashed var(--border) !important;
  background:rgba(255,255,255,0.015) !important;
  width:100% !important;
  transition:all .18s ease !important;
  min-height:74px !important;
}

#dv .add-cat:hover{
  border-color:var(--accent) !important;
  color:var(--accent) !important;
  background:rgba(240,204,69,.05) !important;
  transform:translateY(-1px) !important;
}

body.light #dv .add-cat{
  background:rgba(255,255,255,.6) !important;
  border-color:#d5dbe7 !important;
}

/* 섹션 간격 */
#dv .sb-section{
  margin-top:1.2rem !important;
  padding-top:1.2rem !important;
  border-top:1px solid var(--border) !important;
}

/* 휴지통 버튼 전용 스타일 */
#dv #d-trashBtnWrap .cat-item{
  display:flex !important;
  flex-direction:row !important;
  align-items:center !important;
  gap:6px !important;
  min-height:56px !important;
  padding:0 12px !important;
  border-radius:18px !important;
  border:1px solid rgba(255,107,107,.18) !important;
  background:rgba(255,107,107,.05) !important;
  color:var(--accent2) !important;
}

#dv #d-trashBtnWrap .cat-icon{
  width:22px !important;
  min-width:22px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  font-size:1.05rem !important;
  line-height:1 !important;
  flex:0 0 22px !important;
}

#dv #d-trashBtnWrap .cat-name{
  min-width:0 !important;
  flex:1 1 auto !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
  font-size:1rem !important;
  line-height:1.2 !important;
  color:var(--accent2) !important;
  font-weight:700 !important;
}

#dv #d-trashBtnWrap .cat-item {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
}

#dv #d-trashBtnWrap .cat-icon {
  order: 1 !important;
  width: 22px !important;
  min-width: 22px !important;
  flex: 0 0 22px !important;
}

#dv #d-trashBtnWrap .cat-name {
  order: 2 !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

#dv #d-trashBtnWrap .cat-count {
  order: 3 !important;
  margin-left: auto !important;
  min-width: 28px !important;
  width: 28px !important;
  height: 28px !important;
  flex: 0 0 28px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  border-radius: 999px !important;
  font-size: .88rem !important;
  font-weight: 700 !important;
  line-height: 1 !important;
}

#dv #d-trashBtnWrap .cat-item:hover{
  border-color:rgba(255,107,107,.35) !important;
  background:rgba(255,107,107,.08) !important;
  box-shadow:0 6px 16px rgba(255,107,107,.08) !important;
}


/* ===== 만료 임박 디자인 정리 ===== */
#dv #d-expiryList{
  display:flex !important;
  flex-direction:column !important;
  gap:8px !important;
}

#dv .exp-item{
  padding:12px 14px !important;
  border-radius:16px !important;
  border:1px solid var(--border) !important;
  background:rgba(255,107,107,.06) !important;
  cursor:pointer !important;
  transition:all .18s ease !important;
  display:flex !important;
  flex-direction:column !important;
  gap:4px !important;
  margin:0 !important;
  box-shadow:none !important;
}

#dv .exp-item:hover{
  border-color:var(--accent2) !important;
  transform:translateY(-1px) !important;
  box-shadow:0 6px 14px rgba(255,107,107,.08) !important;
}

#dv .exp-item .et{
  font-size:.9rem !important;
  font-weight:700 !important;
  color:var(--text) !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

#dv .exp-item .ed{
  font-size:.78rem !important;
  font-weight:700 !important;
  color:var(--accent2) !important;
  margin-top:0 !important;
}


#dv main{padding:2rem;}
#dv .main-hdr{display:flex;align-items:center;justify-content:space-between;margin-bottom:1.25rem;flex-wrap:wrap;gap:.75rem;}
#dv .sec-title{font-family:'Playfair Display',serif;font-size:2rem;font-weight:700;display:flex;align-items:center;gap:1rem;}
#dv .sort-sel { background:var(--surface2); border:1px solid var(--border); color:var(--text); padding:.4rem .8rem; border-radius:8px; font-size:.85rem; outline:none; }
#dv .tag-bar{display:flex;flex-wrap:wrap;gap:.4rem;margin-bottom:1.25rem;}

/* ===== Desktop card design and view modes ===== */

#d-cards{
  align-items:start;
}

#d-cards .link-card{
  display:flex !important;
  flex-direction:column !important;
  min-width:0 !important;
  background:linear-gradient(180deg, rgba(28,30,40,.96), rgba(20,22,31,.96)) !important;
  border:1px solid rgba(255,255,255,.08) !important;
  border-radius:24px !important;
  overflow:hidden !important;
  box-shadow:0 8px 22px rgba(0,0,0,.16) !important;
  transition:transform .16s ease, box-shadow .16s ease, border-color .16s ease !important;
  cursor:pointer !important;
  width:100% !important;
  position:relative !important;
}

#d-cards .link-card:hover{
  transform:translateY(-2px) !important;
  box-shadow:0 14px 28px rgba(0,0,0,.22) !important;
  border-color:rgba(255,255,255,0.12) !important;
}

#d-cards .card-img{
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  width:100% !important;
  aspect-ratio: 1 / 0.72 !important;
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)) !important;
  border-bottom:1px solid rgba(255,255,255,.06) !important;
  overflow:hidden !important;
  text-decoration:none !important;
}

#d-cards .card-img img{
  width:46% !important;
  height:46% !important;
  object-fit:contain !important;
  display:block !important;
  border-radius:18px !important;
  background:rgba(255,255,255,.02) !important;
}

#d-cards .card-body{
  padding:14px 14px 13px !important;
  display:flex !important;
  flex-direction:column !important;
  gap:8px !important;
  min-width:0 !important;
}

#d-cards .card-topline{
  display:flex !important;
  align-items:center !important;
  justify-content:space-between !important;
  gap:10px !important;
  min-width:0 !important;
}

#d-cards .card-cat{
  font-size:.84rem !important;
  font-weight:700 !important;
  color:var(--accent) !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

#d-cards .card-acts-mini{
  display:flex !important;
  align-items:center !important;
  gap:8px !important;
  flex:0 0 auto !important;
}

#d-cards .card-acts-mini .icon-btn{
  width:18px !important;
  min-width:18px !important;
  height:18px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  padding:0 !important;
  border:none !important;
  background:transparent !important;
  font-size:.95rem !important;
  line-height:1 !important;
  color:var(--text2) !important;
  transition:all .15s !important;
}

#d-cards .card-acts-mini .icon-btn:hover{
  color:var(--text) !important;
  background:rgba(255,255,255,0.05) !important;
}

#d-cards .card-title{
  font-size:1.02rem !important;
  font-weight:800 !important;
  line-height:1.26 !important;
  color:var(--text) !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

#d-cards .card-url{
  font-size:.82rem !important;
  line-height:1.3 !important;
  color:var(--text2) !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

#d-cards .dead-badge{
  font-size:.8rem !important;
  margin-left:4px !important;
}

/* =========================
   VIEW MODES - fixed sizing
   ========================= */

/* =========================
   VIEW MODES - FINAL
   1. grid
   2. horizontal
   3. gallery
   ========================= */

/* 1) GRID VIEW - 1번 사진처럼 */
#d-cards.links-grid{
  display:grid !important;
  grid-template-columns:repeat(auto-fill, minmax(210px, 230px)) !important;
  gap:16px !important;
  justify-content:start !important;
  align-items:start !important;
}

#d-cards.links-grid .link-card{
  display:flex !important;
  flex-direction:column !important;
  min-height:276px !important;
  border-radius:18px !important;
  overflow:hidden !important;
}

#d-cards.links-grid .card-img{
  width:100% !important;
  aspect-ratio:1 / 0.78 !important;
  border-bottom:1px solid rgba(0,0,0,.06) !important;
  border-right:none !important;
}

#d-cards.links-grid .card-img img{
  width:44% !important;
  height:44% !important;
  border-radius:14px !important;
}

#d-cards.links-grid .card-body{
  display:flex !important;
  flex-direction:column !important;
  gap:6px !important;
  padding:10px 10px 10px !important;
  min-width:0 !important;
}

#d-cards.links-grid .card-topline{
  display:flex !important;
  align-items:center !important;
  justify-content:space-between !important;
  gap:8px !important;
}

#d-cards.links-grid .card-cat{
  font-size:.68rem !important;
  font-weight:700 !important;
  color:var(--accent) !important;
}

#d-cards.links-grid .card-title{
  font-size:.92rem !important;
  font-weight:800 !important;
  line-height:1.2 !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

#d-cards.links-grid .card-url{
  font-size:.74rem !important;
  line-height:1.2 !important;
  color:var(--text2) !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

#d-cards.links-grid .card-acts-mini{
  display:flex !important;
  align-items:center !important;
  gap:7px !important;
}

#d-cards.links-grid .card-acts-mini .icon-btn{
  width:16px !important;
  min-width:16px !important;
  height:16px !important;
  font-size:.82rem !important;
  background:transparent !important;
  border:none !important;
  border-radius:6px !important;
  padding:0 !important;
}

/* 4) GALLERY VIEW - 4번 사진처럼 */
#d-cards.links-gallery{
  display:grid !important;
  grid-template-columns:repeat(auto-fill, minmax(112px, 128px)) !important;
  gap:12px !important;
  justify-content:start !important;
  align-items:start !important;
}

#d-cards.links-gallery .link-card{
  display:flex !important;
  flex-direction:column !important;
  width:100% !important;
  min-height:114px !important;
  border-radius:14px !important;
  overflow:hidden !important;
  box-shadow:none !important;
}

#d-cards.links-gallery .card-img{
  width:100% !important;
  aspect-ratio:1 / 1 !important;
  border:none !important;
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)) !important;
}

#d-cards.links-gallery .card-img img{
  width:44% !important;
  height:44% !important;
  border-radius:12px !important;
}

#d-cards.links-gallery .card-body{
  display:none !important;
}

/* 데스크톱 좁아질 때 안전장치 */
@media (max-width: 1200px){
  #d-cards.links-grid{
    grid-template-columns:repeat(auto-fill, minmax(190px, 220px)) !important;
  }

  #d-cards.links-gallery{
    grid-template-columns:repeat(auto-fill, minmax(100px, 118px)) !important;
  }
}

/* 5) HORIZONTAL VIEW - 가로 카드 스트립 */
#d-cards.links-horizontal{
  display:flex !important;
  gap:14px !important;
  overflow-x:auto !important;
  overflow-y:hidden !important;
  align-items:stretch !important;
  justify-content:flex-start !important;
  padding:4px 2px 10px !important;
  scroll-snap-type:x proximity;
}

#d-cards.links-horizontal .link-card{
  flex:0 0 320px !important;
  width:320px !important;
  min-width:320px !important;
  max-width:320px !important;
  min-height:124px !important;
  height:124px !important;
  display:grid !important;
  grid-template-columns:96px minmax(0,1fr) !important;
  grid-template-areas:"thumb body" !important;
  border-radius:24px !important;
  overflow:hidden !important;
  box-shadow:0 10px 26px rgba(0,0,0,.18) !important;
  scroll-snap-align:start;
}

#d-cards.links-horizontal .link-card:hover{
  transform:translateY(-2px) !important;
  box-shadow:0 16px 34px rgba(0,0,0,.22) !important;
}

#d-cards.links-horizontal .card-img{
  grid-area:thumb !important;
  width:96px !important;
  min-width:96px !important;
  height:124px !important;
  min-height:124px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  border-right:1px solid rgba(255,255,255,.06) !important;
  border-bottom:none !important;
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)) !important;
}

#d-cards.links-horizontal .card-img img{
  width:54px !important;
  height:54px !important;
  object-fit:contain !important;
  border-radius:16px !important;
  display:block !important;
}

#d-cards.links-horizontal .card-body{
  grid-area:body !important;
  width:100% !important;
  display:grid !important;
  grid-template-rows:auto 1fr auto !important;
  gap:6px !important;
  padding:12px 14px !important;
  min-width:0 !important;
  align-content:center !important;
}

#d-cards.links-horizontal .card-topline{
  display:flex !important;
  align-items:center !important;
  justify-content:space-between !important;
  gap:10px !important;
  min-width:0 !important;
}

#d-cards.links-horizontal .card-cat{
  font-size:.72rem !important;
  font-weight:800 !important;
  color:var(--accent) !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
  min-width:0 !important;
}

#d-cards.links-horizontal .card-acts-mini{
  display:flex !important;
  align-items:center !important;
  justify-content:flex-end !important;
  gap:7px !important;
  flex-wrap:nowrap !important;
  white-space:nowrap !important;
  flex:0 0 auto !important;
}

#d-cards.links-horizontal .card-acts-mini .icon-btn{
  width:16px !important;
  min-width:16px !important;
  height:16px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  font-size:.82rem !important;
  padding:0 !important;
  background:transparent !important;
  border:none !important;
  border-radius:6px !important;
}

#d-cards.links-horizontal .card-title{
  align-self:center !important;
  font-size:1rem !important;
  font-weight:800 !important;
  line-height:1.2 !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
  min-width:0 !important;
}

#d-cards.links-horizontal .card-url{
  font-size:.78rem !important;
  line-height:1.2 !important;
  color:var(--text2) !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
  min-width:0 !important;
}

#d-cards.links-horizontal .trash-meta{
  margin-top:4px !important;
  font-size:.72rem !important;
}

#d-cards.links-horizontal::-webkit-scrollbar{
  height:10px;
}

#d-cards.links-horizontal::-webkit-scrollbar-thumb{
  background:rgba(255,255,255,.12);
  border-radius:999px;
}

#d-cards.links-horizontal::-webkit-scrollbar-track{
  background:transparent;
}

@keyframes fadeIn{from{opacity:0;transform:translateY(10px);}to{opacity:1;transform:translateY(0);}}
@media(max-width:700px){#dv .layout{grid-template-columns:1fr;}#dv aside{display:none;}#dv .search-wrap{max-width:200px;margin:0 1rem;}}


/* ════════════════ SETTINGS PANEL (shared overlay) ════════════════ */
#settingsPanel{position:fixed;inset:0;z-index:600;background:rgba(0,0,0,.75);backdrop-filter:blur(8px);opacity:0;pointer-events:none;transition:opacity .25s;display:flex;align-items:flex-start;justify-content:center;padding:2.5rem 1.5rem;}
#settingsPanel.open{opacity:1;pointer-events:all;}

#categoryManageOverlay { z-index: 700; }
#deletedCategoryManageOverlay { z-index: 750; }
#lockOverlay { z-index: 800; }
#lockOverlay .modal { max-width: 400px; }
#settingsBox{background:var(--surface);width:100%;max-width:480px;border-radius:24px;border:1px solid var(--border);padding:1.5rem;transform:scale(0.9) translateY(0);transition:transform .3s cubic-bezier(.4,0,.2,1), opacity .3s;box-shadow:0 20px 40px rgba(0,0,0,.3);overflow:hidden;}
#settingsPanel.open #settingsBox{transform:scale(1);opacity:1;}
#settingsBox .s-handle{display:none;}
#settingsBox .s-title-row{display:flex;align-items:center;justify-content:space-between;margin-bottom:1.2rem;}
#settingsBox .s-title{font-family:'Playfair Display',serif;font-size:1.3rem;font-weight:700;margin:0;}
.ver-btns{display:grid;grid-template-columns:1fr 1fr;gap:.6rem;margin-bottom:.5rem;}
.ver-btn{padding:.7rem;border-radius:12px;border:2px solid var(--border);background:var(--surface2);color:var(--text2);font-size:.85rem;font-weight:500;text-align:center;transition:all .2s;display:flex;flex-direction:column;align-items:center;gap:.3rem;}
.ver-btn .vb-icon{font-size:1.3rem;}
.ver-btn.active{border-color:var(--accent);background:rgba(240,204,69,.1);color:var(--text);}
body.light .ver-btn.active{background:rgba(201,168,0,.1);}
.ver-btn:hover{border-color:var(--accent);color:var(--text);}
/* ════════════════ FILTER PANEL ════════════════ */
.filter-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  display: none;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1.5rem;
  animation: slideDown .3s ease-out;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}
.filter-panel.open { display: grid; }
.filter-group-title { font-size: .7rem; font-weight: 800; color: var(--accent3); text-transform: uppercase; letter-spacing: 1px; margin-bottom: .75rem; }
.filter-opt { display: flex; align-items: center; gap: .5rem; font-size: .85rem; color: var(--text2); cursor: pointer; margin-bottom: .4rem; transition: color .2s; }
.filter-opt:hover { color: var(--text); }
.filter-opt input { accent-color: var(--accent); cursor: pointer; }

/* ════════════════ PREVIEW TOOLTIP ════════════════ */
#d-preview {
  position: fixed;
  z-index: 1000;
  width: 320px;
  background: var(--surface);
  border: 1px solid var(--accent);
  border-radius: 16px;
  padding: 1.25rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  box-shadow: 0 15px 45px rgba(0,0,0,0.4);
  display: none;
}
body.mobile #d-preview { display: none !important; }
#d-preview.on { opacity: 1; display: block; transform: translateY(0); }
.pv-url { font-size: .75rem; color: var(--accent3); word-break: break-all; margin-bottom: .75rem; display: block; }
.pv-note { font-size: .88rem; color: var(--text); line-height: 1.5; margin-bottom: .8rem; background: var(--surface2); padding: .75rem; border-radius: 10px; border-left: 3px solid var(--accent); }
.pv-tags { display: flex; flex-wrap: wrap; gap: .4rem; }
.pv-expiry { margin-top: .8rem; padding-top: .8rem; border-top: 1px solid var(--border); font-size: .75rem; color: var(--accent2); font-weight: 600; }

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

/* ════════════════ INSIGHT STYLES ════════════════ */
.stat-grid { display:grid; grid-template-columns:repeat(auto-fit, minmax(140px, 1fr)); gap:1rem; margin-bottom:1.5rem; }
.stat-card { background:var(--surface2); padding:1.25rem; border-radius:16px; border:1px solid var(--border); text-align:center; }
.stat-val { font-size:1.8rem; font-weight:900; color:var(--accent); display:block; margin-bottom:4px; }
.stat-lbl { font-size:.75rem; color:var(--text2); text-transform:uppercase; letter-spacing:1px; }
.insight-tags { display:flex; flex-wrap:wrap; gap:.5rem; }

/* ════════════════ MODAL ACCESSIBILITY FIXES ════════════════ */
.overlay select, .overlay option {
  color: var(--text) !important;
  background: var(--surface2) !important;
  border: 1px solid var(--border) !important;
}
body.light .overlay select, body.light .overlay option {
  color: #111 !important;
  background: #fff !important;
}
.modal select {
  cursor: pointer;
  -webkit-appearance: listbox !important;
  appearance: auto !important;
}

.cat-context-menu{
  position: fixed;
  z-index: 9999;
  min-width: 168px;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.08);
  background: rgba(18,18,24,0.88);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  box-shadow:
    0 10px 30px rgba(0,0,0,0.35),
    0 2px 10px rgba(0,0,0,0.22),
    inset 0 1px 0 rgba(255,255,255,0.06);
}

.cat-context-menu .ctx-item{
  width: 100%;
  height: 34px;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  line-height: 1;
  text-align: left;
  cursor: pointer;
  transition: background .14s ease, color .14s ease, transform .08s ease;
}

.cat-context-menu .ctx-item:hover{
  background: rgba(255,255,255,0.08);
}

.cat-context-menu .ctx-item:active{
  transform: scale(0.985);
  background: rgba(255,255,255,0.11);
}

.cat-context-menu .ctx-item.danger{
  color: #ff6b6b;
}

.cat-context-menu .ctx-item.danger:hover{
  background: rgba(255,107,107,0.12);
}

.cat-context-menu .ctx-sep{
  height: 1px;
  margin: 5px 4px;
  background: rgba(255,255,255,0.08);
}

.cat-lock{
  width:16px;
  min-width:16px;
  display:flex;
  align-items:center;
  justify-content:center;
  margin-right:6px;
  font-size:12px;
  opacity:.9;
}

.cat-item.locked .cat-name{
  opacity:.95;
}

.cat-item.locked .cat-count{
  opacity:.9;
}

/* ════════════════ MOBILE FINAL POLISH ════════════════ */

/* 상단 카테고리 / 태그 줄 */
#mv .cat-scroll{
  display:flex !important;
  gap:.4rem !important;
  overflow-x:auto !important;
  padding:.5rem .75rem 0 !important;
  flex:0 0 auto !important;
}

#mv .tag-scroll{
  display:flex !important;
  gap:.4rem !important;
  overflow-x:auto !important;
  padding:.42rem .75rem 0 !important;
  flex:0 0 auto !important;
}

#mv .cat-chip{
  display:inline-flex !important;
  align-items:center !important;
  gap:.28rem !important;
  height:30px !important;
  padding:0 .72rem !important;
  border-radius:999px !important;
  background:var(--surface2) !important;
  border:1px solid var(--border) !important;
  color:var(--text2) !important;
  font-size:.78rem !important;
  font-weight:700 !important;
  white-space:nowrap !important;
  flex:0 0 auto !important;
}

#mv .cat-chip.on{
  background:rgba(91,200,255,.14) !important;
  border-color:rgba(91,200,255,.34) !important;
  color:var(--accent3) !important;
}

#mv .tag-chip{
  height:28px !important;
  padding:0 .68rem !important;
  display:inline-flex !important;
  align-items:center !important;
  border-radius:999px !important;
  font-size:.76rem !important;
  white-space:nowrap !important;
}

/* 모바일 카드 공통 */
#mv .content{
  padding:.55rem 0 calc(var(--tab) + 1rem) !important;
}

#mv .cards-wrap{
  width:100% !important;
  min-width:0 !important;
}

#m-cards .m-card{
  background:linear-gradient(180deg, rgba(28,30,40,.96), rgba(20,22,31,.96)) !important;
  border:1px solid rgba(255,255,255,.08) !important;
  overflow:hidden !important;
  box-shadow:0 8px 18px rgba(0,0,0,.15) !important;
  min-width:0 !important;
}

#m-cards .m-thumb{
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  background:linear-gradient(180deg, rgba(255,255,255,.03), rgba(255,255,255,.01)) !important;
  overflow:hidden !important;
  text-decoration:none !important;
}

#m-cards .m-thumb img{
  object-fit:contain !important;
  display:block !important;
  background:rgba(255,255,255,.02) !important;
}

#m-cards .m-body{
  min-width:0 !important;
}

#m-cards .m-row-top{
  display:flex !important;
  align-items:center !important;
  justify-content:space-between !important;
  gap:8px !important;
}

#m-cards .m-cat{
  color:var(--accent) !important;
  font-weight:700 !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

#m-cards .m-actions{
  display:flex !important;
  align-items:center !important;
  flex:0 0 auto !important;
}

#m-cards .m-actions .icon-btn{
  border:none !important;
  background:transparent !important;
  color:var(--text2) !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  padding:0 !important;
}

#m-cards .m-title{
  color:var(--text) !important;
  font-weight:800 !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

#m-cards .m-url{
  color:var(--text2) !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
}

/* ===== GRID: 지금보다 살짝 작고 균형 있게 ===== */
#m-cards.m-grid{
  display:grid !important;
  grid-template-columns:repeat(2, minmax(0, 1fr)) !important;
  gap:10px !important;
  padding:0 10px 12px !important;
}

#m-cards.m-grid .m-card{
  display:flex !important;
  flex-direction:column !important;
  border-radius:18px !important;
}

#m-cards.m-grid .m-thumb{
  width:100% !important;
  aspect-ratio:1 / 0.72 !important;
  border-bottom:1px solid rgba(255,255,255,.06) !important;
}

#m-cards.m-grid .m-thumb img{
  width:44% !important;
  height:44% !important;
  border-radius:14px !important;
}

#m-cards.m-grid .m-body{
  padding:10px 10px 10px !important;
  display:flex !important;
  flex-direction:column !important;
  gap:6px !important;
}

#m-cards.m-grid .m-cat{
  font-size:.72rem !important;
}

#m-cards.m-grid .m-actions{
  gap:6px !important;
}

#m-cards.m-grid .m-actions .icon-btn{
  width:16px !important;
  min-width:16px !important;
  height:16px !important;
  font-size:.82rem !important;
}

#m-cards.m-grid .m-title{
  font-size:.92rem !important;
  line-height:1.2 !important;
}

#m-cards.m-grid .m-url{
  font-size:.76rem !important;
  line-height:1.25 !important;
}

/* ===== LIST: 4번 느낌으로 정리 ===== */
#m-cards.m-list{
  display:flex !important;
  flex-direction:column !important;
  gap:10px !important;
  padding:0 10px 12px !important;
}

#m-cards.m-list .m-card{
  display:grid !important;
  grid-template-columns:84px minmax(0, 1fr) !important;
  align-items:stretch !important;
  border-radius:18px !important;
}

#m-cards.m-list .m-thumb{
  min-height:84px !important;
  border-right:1px solid rgba(255,255,255,.06) !important;
}

#m-cards.m-list .m-thumb img{
  width:58% !important;
  height:58% !important;
  border-radius:12px !important;
}

#m-cards.m-list .m-body{
  padding:10px 11px !important;
  display:flex !important;
  flex-direction:column !important;
  justify-content:center !important;
  gap:5px !important;
}

#m-cards.m-list .m-cat{
  font-size:.72rem !important;
}

#m-cards.m-list .m-actions{
  gap:6px !important;
}

#m-cards.m-list .m-actions .icon-btn{
  width:16px !important;
  min-width:16px !important;
  height:16px !important;
  font-size:.82rem !important;
}

#m-cards.m-list .m-title{
  font-size:.9rem !important;
  line-height:1.2 !important;
}

#m-cards.m-list .m-url{
  font-size:.76rem !important;
  line-height:1.25 !important;
}

/* ===== MOBILE LAYOUT RESTORE ===== */

body.mobile{
  overflow:hidden !important;
  height:100dvh !important;
}

body.mobile #mv{
  display:flex !important;
  flex-direction:column !important;
  height:100dvh !important;
  min-height:100dvh !important;
  overflow:hidden !important;
  background:var(--bg) !important;
}

#mv .top-nav{
  display:flex !important;
  align-items:center !important;
  gap:.45rem !important;
  padding:.75rem .75rem .5rem !important;
  border-bottom:1px solid var(--border) !important;
  background:rgba(13,13,15,.9) !important;
  backdrop-filter:blur(16px) !important;
  flex:0 0 auto !important;
}

body.light #mv .top-nav{
  background:rgba(240,239,244,.94) !important;
}

#mv .logo{
  font-family:'Playfair Display',serif !important;
  font-size:1.15rem !important;
  font-weight:900 !important;
  line-height:1 !important;
  flex:0 0 auto !important;
}

#mv .logo span{
  color:var(--accent) !important;
}

#mv .nav-btn{
  width:34px !important;
  min-width:34px !important;
  height:34px !important;
  border:none !important;
  border-radius:10px !important;
  background:var(--surface2) !important;
  color:var(--text) !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  font-size:.95rem !important;
  flex:0 0 auto !important;
}

#mv .search-wrap{
  position:relative !important;
  flex:1 1 auto !important;
  min-width:0 !important;
}

#mv .search-wrap input{
  width:100% !important;
  height:36px !important;
  background:var(--surface2) !important;
  border:1px solid var(--border) !important;
  border-radius:999px !important;
  padding:0 2.2rem 0 .9rem !important;
  color:var(--text) !important;
  font-size:.9rem !important;
  outline:none !important;
}

#mv .search-ic{
  position:absolute !important;
  right:.8rem !important;
  top:50% !important;
  transform:translateY(-50%) !important;
  width:14px !important;
  height:14px !important;
  color:var(--text2) !important;
  pointer-events:none !important;
}

#mv .fab{
  position:fixed !important;
  right:1rem !important;
  bottom:calc(var(--tab) + 1rem) !important;
  width:48px !important;
  height:48px !important;
  border:none !important;
  border-radius:50% !important;
  background:var(--accent) !important;
  color:#000 !important;
  font-size:1.35rem !important;
  font-weight:700 !important;
  box-shadow:0 10px 24px rgba(0,0,0,.3) !important;
  z-index:40 !important;
}

#mv .tab-bar{
  position:fixed !important;
  left:0 !important;
  right:0 !important;
  bottom:0 !important;
  height:var(--tab) !important;
  display:grid !important;
  grid-template-columns:repeat(3,1fr) !important;
  border-top:1px solid var(--border) !important;
  background:rgba(13,13,15,.95) !important;
  backdrop-filter:blur(16px) !important;
  z-index:35 !important;
}

body.light #mv .tab-bar{
  background:rgba(240,239,244,.96) !important;
}

#mv .tab-item{
  border:none !important;
  background:none !important;
  color:var(--text2) !important;
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  justify-content:center !important;
  gap:2px !important;
  font-size:.74rem !important;
}

#mv .tab-item.on{
  color:var(--accent) !important;
  font-weight:700 !important;
}

#mv .tab-item .ti{
  font-size:1rem !important;
}

/* ===== MOBILE CARD SIZE TUNE ===== */

/* 그리드: 데스크톱 느낌처럼 더 작고 단단하게 */
body.mobile #m-cards.m-grid{
  display:grid !important;
  grid-template-columns:repeat(2, minmax(0, 1fr)) !important;
  gap:8px !important;
  padding:0 8px 10px !important;
}

body.mobile #m-cards.m-grid .m-card{
  border-radius:16px !important;
}

body.mobile #m-cards.m-grid .m-thumb{
  aspect-ratio:1 / 0.62 !important;
}

body.mobile #m-cards.m-grid .m-thumb img{
  width:38% !important;
  height:38% !important;
  border-radius:12px !important;
}

body.mobile #m-cards.m-grid .m-body{
  padding:8px 9px 8px !important;
  gap:5px !important;
}

body.mobile #m-cards.m-grid .m-cat{
  font-size:.68rem !important;
}

body.mobile #m-cards.m-grid .m-title{
  font-size:.84rem !important;
  line-height:1.15 !important;
}

body.mobile #m-cards.m-grid .m-url{
  font-size:.72rem !important;
  line-height:1.15 !important;
}

body.mobile #m-cards.m-grid .m-actions{
  gap:5px !important;
}

body.mobile #m-cards.m-grid .m-actions .icon-btn{
  width:14px !important;
  min-width:14px !important;
  height:14px !important;
  font-size:.74rem !important;
}

/* 리스트도 같이 조금 더 타이트하게 */
body.mobile #m-cards.m-list{
  gap:8px !important;
  padding:0 8px 10px !important;
}

body.mobile #m-cards.m-list .m-card{
  grid-template-columns:76px minmax(0, 1fr) !important;
  border-radius:16px !important;
}

body.mobile #m-cards.m-list .m-thumb{
  min-height:76px !important;
}

body.mobile #m-cards.m-list .m-thumb img{
  width:54% !important;
  height:54% !important;
  border-radius:10px !important;
}

body.mobile #m-cards.m-list .m-body{
  padding:8px 9px !important;
  gap:4px !important;
}

body.mobile #m-cards.m-list .m-cat{
  font-size:.68rem !important;
}

body.mobile #m-cards.m-list .m-title{
  font-size:.84rem !important;
  line-height:1.15 !important;
}

body.mobile #m-cards.m-list .m-url{
  font-size:.72rem !important;
  line-height:1.15 !important;
}

body.mobile #m-cards.m-list .m-actions{
  gap:5px !important;
}

body.mobile #m-cards.m-list .m-actions .icon-btn{
  width:14px !important;
  min-width:14px !important;
  height:14px !important;
  font-size:.74rem !important;
}

/* ===== MOBILE MODE WIDTH CAP ===== */

body.mobile #mv .content{
  display:flex !important;
  justify-content:center !important;
}

body.mobile #mv .cards-wrap{
  width:100% !important;
  max-width:760px !important;
  margin:0 auto !important;
}

/* 모바일 그리드 카드가 넓은 화면에서 과하게 커지지 않게 */
body.mobile #m-cards.m-grid{
  display:grid !important;
  grid-template-columns:repeat(2, minmax(0, 320px)) !important;
  justify-content:center !important;
  gap:10px !important;
  padding:0 10px 12px !important;
}

/* 리스트도 너무 길어지지 않게 */
body.mobile #m-cards.m-list{
  display:flex !important;
  flex-direction:column !important;
  align-items:center !important;
  gap:10px !important;
  padding:0 10px 12px !important;
}

body.mobile #m-cards.m-list .m-card{
  width:100% !important;
  max-width:640px !important;
}

/* 카드 자체 높이도 조금 더 줄이기 */
body.mobile #m-cards.m-grid .m-thumb{
  aspect-ratio:1 / 0.58 !important;
}

body.mobile #m-cards.m-grid .m-thumb img{
  width:34% !important;
  height:34% !important;
}

/* 섹션 간격 */
#dv .sb-section{
  margin-top:1.2rem !important;
  padding-top:1.2rem !important;
  border-top:1px solid var(--border) !important;
}

/* 휴지통 버튼 전용 스타일 */
#dv #d-trashBtnWrap .cat-item{
  display:flex !important;
  flex-direction:row !important;
  align-items:center !important;
  gap:6px !important;
  min-height:56px !important;
  padding:0 12px !important;
  border-radius:18px !important;
  border:1px solid rgba(255,107,107,.18) !important;
  background:rgba(255,107,107,.05) !important;
  color:var(--accent2) !important;
}

#dv #d-trashBtnWrap .cat-icon{
  width:22px !important;
  min-width:22px !important;
  display:flex !important;
  align-items:center !important;
  justify-content:center !important;
  font-size:1.05rem !important;
  line-height:1 !important;
  flex:0 0 22px !important;
}

#dv #d-trashBtnWrap .cat-name{
  min-width:0 !important;
  flex:1 1 auto !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
  font-size:1rem !important;
  line-height:1.2 !important;
  color:var(--accent2) !important;
  font-weight:700 !important;
}

#dv #d-trashBtnWrap .cat-item {
  display: flex !important;
  align-items: center !important;
  gap: 10px !important;
}

#dv #d-trashBtnWrap .cat-icon {
  order: 1 !important;
  width: 22px !important;
  min-width: 22px !important;
  flex: 0 0 22px !important;
}

#dv #d-trashBtnWrap .cat-name {
  order: 2 !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

#dv #d-trashBtnWrap .cat-count {
  order: 3 !important;
  margin-left: auto !important;
  min-width: 28px !important;
  width: 28px !important;
  height: 28px !important;
  flex: 0 0 28px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  border-radius: 999px !important;
  font-size: .88rem !important;
  font-weight: 700 !important;
  line-height: 1 !important;
}

#dv #d-trashBtnWrap .cat-item:hover{
  border-color:rgba(255,107,107,.35) !important;
  background:rgba(255,107,107,.08) !important;
  box-shadow:0 6px 16px rgba(255,107,107,.08) !important;
}

.trash-toolbar{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:1rem;
  margin-bottom:1.25rem;
  padding:1rem;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:24px;
}

.trash-notice{
  display:flex;
  align-items:center;
  gap:14px;
  padding:14px 16px;
  border-radius:18px;
  background:rgba(255,107,107,0.08);
  border:1px solid rgba(255,107,107,0.2);
  flex:1 1 320px;
  min-width:0;
}

.trash-notice-icon{
  font-size:1.4rem;
  flex:0 0 auto;
}

.trash-notice-text{
  font-size:.88rem;
  line-height:1.5;
  color:var(--text);
}

.trash-notice-text b{
  color:var(--accent2);
}

/* ===== Trash Category Card ===== */
.trash-category-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 1rem 1rem .9rem;
  box-shadow: 0 10px 30px rgba(0,0,0,.08);
  display: flex;
  flex-direction: column;
  gap: .8rem;
  min-height: 180px;
}

.trash-category-head {
  display: flex;
  align-items: flex-start;
  gap: .9rem;
}

.trash-category-icon {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  background: var(--surface2);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.9rem;
  flex-shrink: 0;
}

.trash-category-info {
  min-width: 0;
  flex: 1;
}

.trash-category-type {
  font-size: .78rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: .25rem;
}

.trash-category-name {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.35;
  word-break: break-word;
}

.trash-category-sub {
  font-size: .82rem;
  color: var(--text2);
  margin-top: .25rem;
}

.trash-category-actions {
  display: flex;
  gap: .4rem;
  flex-shrink: 0;
}

.trash-category-meta .trash-meta {
  margin-top: 0;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: .7rem .8rem;
}

.trash-category-meta .trash-meta div {
  font-size: .82rem;
  line-height: 1.5;
}

.trash-category-card.mobile {
  min-height: auto;
}

.trash-category-actions.mobile {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
}

.trash-category-actions.mobile .icon-btn {
  width: auto;
  height: auto;
  padding: .45rem .7rem;
  border-radius: 12px;
}

/* ===== Light mode readability ===== */
body.light {
  --bg: #f5f6fa;
  --surface: #ffffff;
  --surface2: #f3f5f9;
  --border: #d9dee8;
  --text: #1f2430;
  --text2: #5f6b7a;
}

body.light .link-card,
body.light .m-card,
body.light .pcard,
body.light .m-pcard,
body.light .trash-category-card {
  background:
    linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%);
  border: 1px solid #d9dee8;
  box-shadow: 0 8px 24px rgba(31, 36, 48, 0.08);
}

body.light .card-title,
body.light .m-title,
body.light .pcard-name,
body.light .m-pname,
body.light .trash-category-name {
  color: #1f2430 !important;
}

body.light .card-url,
body.light .m-url,
body.light .pcard-count,
body.light .m-pcount,
body.light .trash-category-sub,
body.light .trash-meta,
body.light .trash-meta div {
  color: #5f6b7a !important;
}

body.light .card-cat,
body.light .m-cat,
body.light .trash-category-type {
  color: #a67c00 !important;
}

body.light .icon-btn {
  background: #f3f5f9;
  border: 1px solid #d9dee8;
  color: #3a4556;
}

body.light .tag-chip {
  background: #eef3f8;
  border: 1px solid #d9dee8;
  color: #4b5563;
}

body.light .tag-chip.on {
  background: #dff0ff;
  border-color: #9fd0ff;
  color: #0b63b6;
}

body.light .trash-toolbar,
body.light .trash-notice {
  background: #fff7f5;
  border-color: #f1c7c0;
}

body.light .sb-title,
body.light .sec-title {
  color: #1f2430;
} 

/* ===== Light mode hard override ===== */
body.light #d-cards .link-card,
body.light #m-cards .m-card,
body.light .pcard,
body.light .m-pcard,
body.light .trash-category-card {
  background: linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%) !important;
  border: 1px solid #d9dee8 !important;
  box-shadow: 0 8px 24px rgba(31, 36, 48, 0.08) !important;
}

body.light #d-cards .card-img,
body.light #m-cards .m-thumb {
  background: linear-gradient(180deg, #f9fbfe 0%, #f1f5fa 100%) !important;
  border-color: #e0e6ef !important;
}

body.light #d-cards .card-title,
body.light #m-cards .m-title,
body.light .pcard-name,
body.light .m-pname,
body.light .trash-category-name {
  color: #1f2430 !important;
}

body.light #d-cards .card-url,
body.light #m-cards .m-url,
body.light .pcard-count,
body.light .m-pcount,
body.light .trash-category-sub,
body.light .trash-meta,
body.light .trash-meta div {
  color: #5f6b7a !important;
}

body.light #d-cards .card-cat,
body.light #m-cards .m-cat,
body.light .trash-category-type {
  color: #9a7400 !important;
}

body.light #d-cards.links-horizontal .link-card{
  background:linear-gradient(180deg, #ffffff 0%, #f7f9fc 100%) !important;
  border:1px solid #d9dee8 !important;
  box-shadow:0 8px 24px rgba(31,36,48,.08) !important;
}

body.light #d-cards.links-horizontal .card-img{
  background:linear-gradient(180deg, #f9fbfe 0%, #f1f5fa 100%) !important;
  border-right:1px solid #e0e6ef !important;
}

body.light #d-cards.links-horizontal .card-title{
  color:#1f2430 !important;
}

body.light #d-cards.links-horizontal .card-url{
  color:#5f6b7a !important;
}

body.light #d-cards.links-horizontal .card-cat{
  color:#9a7400 !important;
}

body.light #d-cards.links-horizontal .card-acts-mini .icon-btn{
  color:#4a5568 !important;
  background:#f3f5f9 !important;
  border:1px solid #d9dee8 !important;
}

body.light #d-cards .card-acts-mini .icon-btn,
body.light #m-cards .m-actions .icon-btn,
body.light .trash-category-actions .icon-btn {
  color: #4a5568 !important;
  background: #f3f5f9 !important;
  border: 1px solid #d9dee8 !important;
  border-radius: 10px !important;
}

body.light #d-cards .card-acts-mini .icon-btn:hover,
body.light #m-cards .m-actions .icon-btn:hover,
body.light .trash-category-actions .icon-btn:hover {
  background: #e9eef5 !important;
  color: #1f2430 !important;
}

body.light .trash-category-meta .trash-meta {
  background: #f5f7fb !important;
  border: 1px solid #dde3ec !important;
}



/* =========================================================
   SIDEBAR CLEAN FINAL
========================================================= */

/* 섹션 */
#d-catTop,
#d-catList {
  display: flex !important;
  flex-direction: column !important;
  gap: 10px !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: visible !important;
}

#d-catTop {
  margin-top: 10px !important;
}

/* 카드 공통 */
#d-catTop .cat-item,
#d-catList .cat-item,
#dv #d-trashBtnWrap .cat-item {
  display: flex !important;
  align-items: center !important;
  width: 100% !important;
  min-height: 56px !important;
  padding: 0 12px !important;
  margin: 0 !important;
  border-radius: 18px !important;
  gap: 10px !important;
  overflow: hidden !important;
}

/* 순서 고정 */
#d-catTop .cat-lock,
#d-catList .cat-lock {
  order: 1 !important;
  width: 10px !important;
  min-width: 10px !important;
  flex: 0 0 10px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  font-size: 10px !important;
  line-height: 1 !important;
}

#d-catTop .cat-icon,
#d-catList .cat-icon,
#dv #d-trashBtnWrap .cat-icon {
  order: 2 !important;
  width: 22px !important;
  min-width: 22px !important;
  flex: 0 0 22px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  margin: 0 !important;
  font-size: 1.05rem !important;
  line-height: 1 !important;
}

#d-catTop .cat-name,
#d-catList .cat-name,
#dv #d-trashBtnWrap .cat-name {
  order: 3 !important;
  flex: 1 1 auto !important;
  min-width: 0 !important;
  display: block !important;
  margin: 0 !important;
  padding: 0 4px 0 0 !important;
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
  font-size: .98rem !important;
  line-height: 1.2 !important;
}

/* spacer 완전 제거 */
#d-catTop .cat-spacer,
#d-catList .cat-spacer {
  display: none !important;
  width: 0 !important;
  min-width: 0 !important;
  flex: 0 0 0 !important;
}

/* 전체 링크 / 즐겨찾기 */
#d-catTop .cat-count {
  order: 4 !important;
  margin-left: auto !important;
}

/* 일반 카테고리 */
#d-catList .cat-star-btn {
  order: 4 !important;
  margin-left: auto !important;
  margin-right: 0 !important;
  width: 20px !important;
  min-width: 20px !important;
  height: 20px !important;
  flex: 0 0 20px !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  border: none !important;
  background: transparent !important;
  font-size: .82rem !important;
  line-height: 1 !important;
}

#d-catList .cat-count {
  order: 5 !important;
  margin-left: 8px !important;
}

/* 숫자 pill */
#d-catTop .cat-count,
#d-catList .cat-count,
#dv #d-trashBtnWrap .cat-count {
  min-width: 28px !important;
  width: 28px !important;
  height: 28px !important;
  flex: 0 0 28px !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
  border-radius: 999px !important;
  font-size: .88rem !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  opacity: 1 !important;
  visibility: visible !important;
}

/* 라이트 모드 */
body.light #d-catTop .cat-item,
body.light #d-catList .cat-item,
body.light #dv #d-trashBtnWrap .cat-item {
  background: #ffffff !important;
  border: 1px solid #dde3ec !important;
  color: #1f2430 !important;
  box-shadow: 0 6px 16px rgba(31, 36, 48, 0.05) !important;
}

body.light #d-catTop .cat-name,
body.light #d-catList .cat-name,
body.light #d-catTop .cat-icon,
body.light #d-catList .cat-icon,
body.light #d-catTop .cat-lock,
body.light #d-catList .cat-lock,
body.light #d-catTop .cat-count,
body.light #d-catList .cat-count {
  color: #1f2430 !important;
}

body.light #d-catTop .cat-count,
body.light #d-catList .cat-count,
body.light #dv #d-trashBtnWrap .cat-count {
  background: #f7f9fc !important;
  border: 1px solid #d8deea !important;
}

body.light #d-catList .cat-star-btn {
  color: #d4b24a !important;
  opacity: 1 !important;
}

body.light #d-catList .cat-star-btn:hover {
  background: #f7f1db !important;
  color: #b98a00 !important;
}

/* ===== Light mode category context menu ===== */
body.light .cat-context-menu {
  background: #ffffff !important;
  border: 1px solid #d9dee8 !important;
  box-shadow:
    0 12px 28px rgba(31, 36, 48, 0.12),
    0 2px 10px rgba(31, 36, 48, 0.06) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

body.light .cat-context-menu .ctx-item {
  color: #1f2430 !important;
}

body.light .cat-context-menu .ctx-item:hover {
  background: #f3f6fb !important;
  color: #1f2430 !important;
}

body.light .cat-context-menu .ctx-item.danger {
  color: #d94f4f !important;
}

body.light .cat-context-menu .ctx-item.danger:hover {
  background: #fff1f1 !important;
}

body.light .cat-context-menu .ctx-sep {
  background: #e5eaf2 !important;
}

/* Light mode trash button unify */
body.light #dv #d-trashBtnWrap .cat-item {
  background: #ffffff !important;
  border: 1px solid #f0d6d6 !important;
  color: #d94f4f !important;
  box-shadow: 0 6px 16px rgba(31, 36, 48, 0.05) !important;
}

body.light #dv #d-trashBtnWrap .cat-name,
body.light #dv #d-trashBtnWrap .cat-icon {
  color: #d94f4f !important;
}

body.light #dv #d-trashBtnWrap .cat-count {
  background: #f7f9fc !important;
  border: 1px solid #d8deea !important;
  color: #1f2430 !important;
}

#d-cards .card-title,
#d-cards .card-url,
#m-cards .m-title,
#m-cards .m-url {
  cursor: pointer;
}

/* =========================
   MOBILE FILTER / SORT BAR
========================= */
#mv .cat-scroll,
#mv .tag-scroll{
  display:flex;
  gap:.45rem;
  overflow-x:auto;
  padding:.55rem .9rem 0;
  scroll-snap-type:x proximity;
}

#mv .cat-scroll > *,
#mv .tag-scroll > *{
  flex:0 0 auto;
  scroll-snap-align:start;
}

#mv .filter-row{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:.65rem;
  padding:.7rem .9rem .8rem;
  margin:.35rem .9rem 0;
  background:var(--surface);
  border:1px solid var(--border);
  border-radius:18px;
  box-shadow:0 8px 24px rgba(0,0,0,.14);
}

body.light #mv .filter-row{
  background:#fff;
  box-shadow:0 8px 24px rgba(17,24,39,.06);
}

#mv .filter-chip{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:56px;
  height:40px;
  padding:0 .95rem;
  border-radius:999px;
  border:1px solid var(--border);
  background:var(--surface2);
  color:var(--text2);
  font-size:.86rem;
  font-weight:700;
  line-height:1;
  white-space:nowrap;
}

#mv .filter-chip.active{
  background:color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-color:color-mix(in srgb, var(--accent) 45%, var(--border));
  color:var(--text);
}

#mv .sort-wrap{
  flex:1;
  min-width:0;
  display:flex;
  align-items:center;
  gap:.55rem;
  padding:0 .2rem 0 .15rem;
}

#mv .sort-label{
  flex:0 0 auto;
  font-size:.74rem;
  font-weight:800;
  letter-spacing:.04em;
  color:var(--text2);
  text-transform:uppercase;
}

#mv .mobile-sort{
  flex:1;
  min-width:0;
  height:40px;
  padding:0 2.2rem 0 .9rem;
  border-radius:12px;
  border:1px solid var(--border);
  background:var(--surface2);
  color:var(--text);
  font-size:.88rem;
  font-weight:600;
  outline:none;
  appearance:none;
  -webkit-appearance:none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text2) 50%),
    linear-gradient(135deg, var(--text2) 50%, transparent 50%);
  background-position:
    calc(100% - 16px) 16px,
    calc(100% - 11px) 16px;
  background-size:5px 5px, 5px 5px;
  background-repeat:no-repeat;
}

#mv .mobile-sort:focus{
  border-color:var(--accent);
  box-shadow:0 0 0 3px rgba(240,204,69,.12);
}

body.light #mv .mobile-sort{
  background-color:#f7f8fc;
}

@media (max-width: 420px){
  #mv .filter-row{
    gap:.5rem;
    padding:.65rem .75rem;
    margin:.3rem .75rem 0;
    border-radius:16px;
  }

  #mv .filter-chip{
    min-width:52px;
    height:38px;
    padding:0 .8rem;
    font-size:.82rem;
  }

  #mv .sort-label{
    display:none;
  }

  #mv .mobile-sort{
    height:38px;
    font-size:.84rem;
  }

  #mv .cat-scroll,
  #mv .tag-scroll{
    padding-left:.75rem;
    padding-right:.75rem;
  }
}

/* =========================================================
   SELECT MODE - REFINED
========================================================= */

/* 선택 모드일 때 전체 비선택 카드 살짝 약하게 */
body.select-mode .link-card:not(.selecting),
body.select-mode .m-card:not(.selecting),
body.select-mode .pcard:not(.selecting),
body.select-mode .m-pcard:not(.selecting),
body.select-mode .trash-category-card:not(.selecting) {
  opacity: .62;
  filter: saturate(.82);
  transition: opacity .18s ease, filter .18s ease, transform .18s ease;
}

/* 선택된 카드 강조 */
body.select-mode .link-card.selecting,
body.select-mode .m-card.selecting,
body.select-mode .pcard.selecting,
body.select-mode .m-pcard.selecting,
body.select-mode .trash-category-card.selecting {
  position: relative !important;
  opacity: 1 !important;
  filter: none !important;
  border-color: var(--accent) !important;
  transform: translateY(-1px) !important;
  box-shadow:
    0 0 0 3px color-mix(in srgb, var(--accent) 55%, transparent),
    0 12px 28px rgba(0,0,0,.22) !important;
  z-index: 2;
}

/* 선택 체크 배지 */
body.select-mode .link-card.selecting::after,
body.select-mode .m-card.selecting::after,
body.select-mode .pcard.selecting::after,
body.select-mode .m-pcard.selecting::after,
body.select-mode .trash-category-card.selecting::after {
  content: '';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 8px 18px rgba(0,0,0,.24);
  z-index: 30;
}

body.select-mode .link-card.selecting::before,
body.select-mode .m-card.selecting::before,
body.select-mode .pcard.selecting::before,
body.select-mode .m-pcard.selecting::before,
body.select-mode .trash-category-card.selecting::before {
  content: '✓';
  position: absolute;
  top: 10px;
  right: 10px;
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #000;
  font-size: 13px;
  font-weight: 900;
  z-index: 31;
}

/* 다크 모드에서 카드 위에 은은한 강조 레이어 */
body.select-mode .link-card.selecting,
body.select-mode .m-card.selecting {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent) 8%, rgba(28,30,40,.96)),
      rgba(20,22,31,.96)
    ) !important;
}

/* 카테고리 카드도 같은 톤으로 */
body.select-mode .pcard.selecting,
body.select-mode .m-pcard.selecting,
body.select-mode .trash-category-card.selecting {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent) 9%, var(--surface)),
      var(--surface)
    ) !important;
}

/* 모바일에서는 체크 크기와 위치 조금 줄임 */
body.mobile.select-mode .m-card.selecting::after,
body.mobile.select-mode .m-pcard.selecting::after,
body.mobile.select-mode .trash-category-card.selecting::after,
body.mobile.select-mode .m-card.selecting::before,
body.mobile.select-mode .m-pcard.selecting::before,
body.mobile.select-mode .trash-category-card.selecting::before {
  top: 8px;
  right: 8px;
  width: 22px;
  height: 22px;
  font-size: 12px;
}

/* 가로 뷰에서 체크가 너무 이미지 위를 가리지 않게 */
#d-cards.links-horizontal .link-card.selecting::after,
#d-cards.links-horizontal .link-card.selecting::before {
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
}

/* 모바일 리스트도 동일 */
#m-cards.m-list .m-card.selecting::after,
#m-cards.m-list .m-card.selecting::before {
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
}

/* 라이트 모드 보정 */
body.light.select-mode .link-card.selecting,
body.light.select-mode .m-card.selecting,
body.light.select-mode .pcard.selecting,
body.light.select-mode .m-pcard.selecting,
body.light.select-mode .trash-category-card.selecting {
  box-shadow:
    0 0 0 3px rgba(179,143,0,.26),
    0 10px 24px rgba(31,36,48,.10) !important;
}

body.light.select-mode .link-card.selecting {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent) 9%, #ffffff),
      #f7f9fc
    ) !important;
}

body.light.select-mode .m-card.selecting,
body.light.select-mode .pcard.selecting,
body.light.select-mode .m-pcard.selecting,
body.light.select-mode .trash-category-card.selecting {
  background:
    linear-gradient(180deg,
      color-mix(in srgb, var(--accent) 8%, #ffffff),
      #f8fafc
    ) !important;
}

body.light.select-mode .link-card.selecting::before,
body.light.select-mode .m-card.selecting::before,
body.light.select-mode .pcard.selecting::before,
body.light.select-mode .m-pcard.selecting::before,
body.light.select-mode .trash-category-card.selecting::before {
  color: #fff;
}

/* hover가 선택 강조를 덮지 않도록 */
body.select-mode .link-card.selecting:hover,
body.select-mode .m-card.selecting:hover,
body.select-mode .pcard.selecting:hover,
body.select-mode .m-pcard.selecting:hover,
body.select-mode .trash-category-card.selecting:hover {
  border-color: var(--accent) !important;
  transform: translateY(-1px) !important;
}

.batch-actions{
  display:flex;
  gap:.5rem;
  flex-wrap:wrap;
  align-items:center;
}

.batch-mini-btn{
  padding:.5rem .75rem !important;
  font-size:.78rem !important;
  white-space:nowrap;
}

#mv .batch-actions{
  width:100%;
  justify-content:flex-end;
}

#mv .batch-mini-btn{
  padding:.48rem .68rem !important;
  font-size:.76rem !important;
}

body.select-mode .link-card,
body.select-mode .m-card,
body.select-mode .pcard,
body.select-mode .m-pcard,
body.select-mode .trash-category-card {
  user-select: none;
}

/* horizontal 카드뷰: 카테고리는 그대로, 제목/주소만 아래로 */
#d-cards.links-horizontal .card-body{
  display:grid !important;
  grid-template-rows:auto 1fr auto !important;
  align-content:stretch !important;
}

#d-cards.links-horizontal .card-topline{
  align-self:start !important;
}

#d-cards.links-horizontal .card-title{
  align-self:center !important;
}

#d-cards.links-horizontal .card-url{
  align-self:start !important;
  margin-top:2px !important;
}
