:root{
  --bg:#f7f7f8; --surface:#ffffff; --surface-2:#f1f1f3; --border:#e4e4e7;
  --text:#18181b; --text-muted:#6b6b74; --text-faint:#9a9aa2;
  --primary:#4f46e5; --primary-hover:#4338ca; --primary-soft:#eef2ff; --primary-text:#4338ca;
  --radius-sm:6px; --radius-md:10px; --radius-lg:16px;
  --shadow-sm:0 1px 2px rgba(0,0,0,0.04); --shadow-md:0 4px 16px rgba(0,0,0,0.08);
  --font-sans:'Pretendard',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
}
*{ box-sizing:border-box; }
body{
  margin:0; background:var(--bg); color:var(--text); font-family:var(--font-sans);
  line-height:1.6; -webkit-font-smoothing:antialiased;
}
.wrap{ max-width:880px; margin:0 auto; padding:48px 24px 100px; }
.wrap-select{ max-width:1320px; }
header{ margin-bottom:32px; }
header .eyebrow{ display:flex; align-items:center; justify-content:space-between; gap:12px; color:var(--primary-text); font-weight:700; font-size:13px; letter-spacing:.04em; text-transform:uppercase; margin-bottom:8px; }
header h1{ font-size:32px; font-weight:800; margin:0 0 10px; letter-spacing:-0.02em; }
header p{ color:var(--text-muted); font-size:14.5px; margin:0; max-width:620px; }
.nav-link{
  text-transform:none; letter-spacing:0; font-weight:700; font-size:13px;
  color:var(--primary-text); text-decoration:none; background:var(--primary-soft);
  padding:6px 12px; border-radius:999px; white-space:nowrap;
}
.nav-link:hover{ background:var(--primary); color:#fff; }
.link-more{
  appearance:none; border:none; background:none; cursor:pointer; padding:0; margin-left:4px;
  font-family:inherit; font-size:14.5px; font-weight:700; color:var(--primary-text);
  text-decoration:underline;
}

.info-panel{
  position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:40;
  display:none; align-items:center; justify-content:center; padding:24px;
}
.info-panel.open{ display:flex; }
.info-box{
  background:var(--surface); border-radius:var(--radius-lg); width:100%; max-width:520px;
  max-height:80vh; overflow-y:auto; box-shadow:var(--shadow-md);
}
.info-head{
  display:flex; align-items:center; justify-content:space-between; padding:16px 20px;
  border-bottom:1px solid var(--border); position:sticky; top:0; background:var(--surface);
}
.info-head h3{ margin:0; font-size:16px; font-weight:700; }
.info-head button{
  appearance:none; border:none; background:transparent; cursor:pointer; font-size:20px;
  color:var(--text-muted); line-height:1;
}
.info-body{ padding:8px 20px 20px; font-size:13.5px; color:var(--text-muted); line-height:1.7; }
.info-body h4{ font-size:13.5px; color:var(--text); margin:16px 0 4px; font-weight:700; }
.info-body p{ margin:0; }

.detail-panel{
  position:fixed; inset:0; background:rgba(0,0,0,.5); z-index:45;
  display:none; align-items:center; justify-content:center; padding:24px;
}
.detail-panel.open{ display:flex; }
.detail-box{
  position:relative; background:var(--surface); border-radius:var(--radius-lg); width:100%;
  max-width:420px; max-height:85vh; overflow-y:auto; box-shadow:var(--shadow-md);
}
.detail-close{
  position:absolute; top:10px; right:10px; z-index:1; appearance:none; border:none;
  background:rgba(0,0,0,.45); color:#fff; width:28px; height:28px; border-radius:50%;
  cursor:pointer; font-size:18px; line-height:1;
}
.detail-box img{ width:100%; display:block; background:var(--surface-2); max-height:320px; object-fit:contain; }
.detail-body{ padding:18px 20px 20px; }
.detail-title-row{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.detail-title-row h3{ font-size:16px; font-weight:700; margin:0; }
.detail-tier{ cursor:default; }
.detail-tier:hover{ background:var(--primary-soft); color:var(--primary-text); }
.detail-creator{ font-size:12.5px; color:var(--text-faint); margin-top:4px; }
.detail-kw-head{
  display:flex; align-items:center; justify-content:space-between; margin-top:16px;
  font-size:12.5px; color:var(--text-muted); font-weight:700;
}
.detail-kw-chips{ display:flex; gap:6px; flex-wrap:wrap; margin-top:8px; }
.detail-kw-chips .chip{ cursor:default; }
.detail-kw-chips .chip:hover{ background:var(--primary-soft); color:var(--primary-text); }
.detail-open-btn{
  display:flex; align-items:center; justify-content:center; margin-top:18px; text-decoration:none;
}
.detail-open-note{ font-size:11.5px; color:var(--text-faint); margin-top:6px; text-align:center; }

.thumb-grid img{ cursor:pointer; }

.panel{
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-lg);
  padding:24px; box-shadow:var(--shadow-sm); margin-bottom:24px;
}
.search-row{ display:flex; gap:10px; flex-wrap:wrap; }
.input-wrap{ position:relative; flex:1; min-width:200px; }
.search-row input[type="text"]{
  width:100%; padding:12px 14px; font-size:15px; border:1px solid var(--border);
  border-radius:var(--radius-sm); font-family:inherit; color:var(--text); background:var(--bg);
}
.search-row input:focus{ outline:2px solid var(--primary); outline-offset:1px; }
.ac-dropdown{
  position:absolute; top:calc(100% + 4px); left:0; right:0; z-index:15;
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius-sm);
  box-shadow:var(--shadow-md); overflow:hidden;
}
.ac-dropdown button{
  display:block; width:100%; text-align:left; appearance:none; border:none; background:none;
  padding:9px 14px; font-family:inherit; font-size:14px; color:var(--text); cursor:pointer;
}
.ac-dropdown button:hover{ background:var(--surface-2); }
.ac-dropdown button strong{ color:var(--primary-text); font-weight:700; }
select{
  padding:12px 14px; border:1px solid var(--border); border-radius:var(--radius-sm);
  font-family:inherit; font-size:14px; background:var(--bg); color:var(--text);
}
input[type="number"]{
  width:90px; padding:12px 14px; border:1px solid var(--border); border-radius:var(--radius-sm);
  font-family:inherit; font-size:14px; background:var(--bg); color:var(--text);
}
input[type="number"]:focus{ outline:2px solid var(--primary); outline-offset:1px; }
.btn{
  appearance:none; border:none; cursor:pointer; font-family:inherit; font-weight:700;
  font-size:14px; padding:12px 22px; border-radius:var(--radius-sm); background:var(--primary);
  color:#fff; transition:background .15s;
}
.btn:hover{ background:var(--primary-hover); }
.btn:disabled{ opacity:.5; cursor:not-allowed; }
.btn-ghost{
  appearance:none; border:1px solid var(--border); background:var(--surface); color:var(--text-muted);
  cursor:pointer; font-family:inherit; font-weight:600; font-size:13px; padding:8px 14px;
  border-radius:999px;
}
.btn-ghost:hover{ background:var(--surface-2); }
.btn-ghost:disabled{ opacity:.5; cursor:not-allowed; }

.status{ margin-top:14px; font-size:13px; color:var(--text-muted); display:flex; align-items:center; gap:8px; min-height:20px; }
.spinner{
  width:14px; height:14px; border-radius:50%; border:2px solid var(--border);
  border-top-color:var(--primary); animation:spin .7s linear infinite; display:none;
}
.spinner.active{ display:inline-block; }
@keyframes spin{ to{ transform:rotate(360deg); } }
.progress-bar{ height:6px; background:var(--surface-2); border-radius:999px; overflow:hidden; margin-top:10px; }
.progress-fill{ height:100%; background:var(--primary); width:0%; transition:width .2s; }

.result-head{ display:flex; align-items:center; justify-content:space-between; gap:10px; flex-wrap:wrap; }
.results h2{ font-size:18px; font-weight:700; margin:0 0 4px; }
.results .meta{ color:var(--text-muted); font-size:13px; margin-bottom:18px; }

.kw-row{ display:flex; align-items:center; gap:10px; margin-bottom:8px; }
.kw-rank{ width:24px; flex-shrink:0; text-align:right; font-size:12px; color:var(--text-faint); font-weight:700; }
.kw-name{ width:130px; flex-shrink:0; font-size:14px; font-weight:600; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.kw-bar-track{ flex:1; background:var(--surface-2); border-radius:999px; height:20px; overflow:hidden; }
.kw-bar-fill{ height:100%; background:linear-gradient(90deg, var(--primary), #818cf8); border-radius:999px; }
.kw-count{ width:34px; flex-shrink:0; font-size:12.5px; color:var(--text-muted); font-weight:600; text-align:right; }

.thumb-grid{ display:grid; grid-template-columns:repeat(auto-fill,minmax(90px,1fr)); gap:8px; margin-top:20px; }
.thumb-grid img{ width:100%; aspect-ratio:1; object-fit:cover; border-radius:8px; border:1px solid var(--border); background:var(--surface-2); }

.empty{ color:var(--text-faint); font-size:14px; padding:30px 0; text-align:center; }

/* miricanvas iframe toggle */
.mc-toggle{
  background:var(--surface); border:1px solid var(--border); border-radius:999px;
  padding:9px 16px; font-size:13px; font-weight:700; color:var(--text-muted);
  cursor:pointer; box-shadow:var(--shadow-sm); display:inline-flex; align-items:center; gap:6px;
  margin-top:16px;
}
.mc-toggle:hover{ color:var(--text); }
.mc-panel{
  position:fixed; inset:0; background:rgba(0,0,0,.4); z-index:30;
  display:none; align-items:center; justify-content:center; padding:24px;
}
.mc-panel.open{ display:flex; }
.mc-panel .mc-box{
  background:var(--surface); border-radius:var(--radius-lg); width:100%; height:100%;
  max-width:1200px; max-height:900px; display:flex; flex-direction:column; overflow:hidden;
  box-shadow:var(--shadow-md);
}
.mc-box .mc-head{
  display:flex; align-items:center; justify-content:space-between; padding:10px 16px;
  border-bottom:1px solid var(--border); font-size:13px; color:var(--text-muted); font-weight:600;
}
.mc-box .mc-head button{
  appearance:none; border:none; background:transparent; cursor:pointer; font-size:20px;
  color:var(--text-muted); line-height:1;
}
.mc-box iframe{ flex:1; border:none; width:100%; }

footer{ margin-top:40px; color:var(--text-faint); font-size:12px; border-top:1px solid var(--border); padding-top:20px; }

.source-tabs-wrap{ display:flex; align-items:center; gap:8px; flex-wrap:wrap; margin-bottom:16px; }
.source-tabs{ display:flex; gap:8px; flex-wrap:wrap; }
.tab-divider{ width:1px; align-self:stretch; background:var(--border); }
.source-tab{
  appearance:none; border:1px solid var(--border); background:var(--bg); color:var(--text-muted);
  cursor:pointer; font-family:inherit; font-weight:700; font-size:13.5px; padding:8px 16px;
  border-radius:999px; transition:all .15s; white-space:nowrap; flex-shrink:0;
}
.source-tab.active{ background:var(--primary); color:#fff; border-color:var(--primary); }
.source-tab:hover:not(.active){ background:var(--surface-2); }

.related-row{ display:flex; align-items:center; gap:10px; margin-top:12px; flex-wrap:wrap; }
.related-chips{ display:flex; gap:6px; flex-wrap:wrap; }
.chip{
  appearance:none; border:1px solid var(--border); background:var(--primary-soft); color:var(--primary-text);
  cursor:pointer; font-family:inherit; font-weight:600; font-size:12.5px; padding:5px 12px;
  border-radius:999px; transition:all .15s;
}
.chip:hover{ background:var(--primary); color:#fff; border-color:var(--primary); }

.trending-head{ display:flex; align-items:center; justify-content:space-between; }
.trending-head h2{ font-size:16px; font-weight:700; margin:0; }
.thumb-grid.loading{ opacity:.5; }

/* 페이지2: 키워드 선택 모드 */
.hint-text{ color:var(--text-faint); font-size:12.5px; margin:10px 0 0; }
.item-kw-chips{ display:flex; flex-wrap:wrap; gap:6px; }
.kw-pick{
  appearance:none; border:1px solid var(--border); background:var(--surface-2); color:var(--text-muted);
  cursor:pointer; font-family:inherit; font-weight:600; font-size:12.5px; padding:5px 12px;
  border-radius:999px; transition:all .15s;
}
.kw-pick:hover{ background:var(--primary-soft); color:var(--primary-text); }
.kw-pick.selected{ background:var(--primary); color:#fff; border-color:var(--primary); }

.load-more-row{ text-align:center; margin-top:20px; }

/* 검색결과(왼쪽) + 담은 항목 카드 목록(오른쪽) 2단 레이아웃 */
.select-layout{ display:flex; flex-direction:column; gap:24px; }
.select-main{ min-width:0; }
.collected-list{ display:flex; flex-direction:column; gap:12px; margin-top:14px; }
.collected-card{
  position:relative; display:flex; gap:14px; padding:16px; padding-right:34px;
  border:1px solid var(--border); border-radius:var(--radius-md); background:var(--bg);
}
.collected-card img{
  width:80px; height:80px; flex-shrink:0; object-fit:cover; border-radius:8px;
  border:1px solid var(--border); background:var(--surface-2);
}
.collected-card-body{ flex:1; min-width:0; }
.collected-card-title{ font-size:14.5px; font-weight:700; margin-bottom:9px; overflow-wrap:anywhere; }
.collected-card-remove{
  position:absolute; top:8px; right:8px; appearance:none; border:none; background:transparent;
  color:var(--text-faint); cursor:pointer; font-size:14px; line-height:1; padding:4px;
}
.collected-card-remove:hover{ color:var(--text); }

@media (min-width:900px){
  .select-layout{ display:grid; grid-template-columns:1fr 500px; align-items:start; gap:28px; }
  .select-side{ position:sticky; top:20px; max-height:calc(100vh - 40px); overflow-y:auto; }
  .wrap-select .thumb-grid{ grid-template-columns:repeat(auto-fill,minmax(120px,1fr)); gap:12px; }
}

.selection-bar{
  position:fixed; left:0; right:0; bottom:0; z-index:25;
  background:var(--surface); border-top:1px solid var(--border);
  box-shadow:0 -4px 16px rgba(0,0,0,.06);
  padding:12px 24px; display:flex; align-items:center; gap:14px;
}
.selection-bar .selection-text{
  flex:1; min-width:0; font-size:13px; color:var(--text-muted); line-height:1.5;
  max-height:60px; overflow-y:auto;
}
.selection-bar .selection-text.has-items{ color:var(--text); font-weight:600; }
.selection-bar .selection-actions{ display:flex; gap:8px; flex-shrink:0; }

@media (max-width:640px){
  .source-tabs-wrap{ flex-direction:column; align-items:stretch; }
  .tab-divider{ display:none; }
  .wrap{ padding:32px 16px 80px; }
  header h1{ font-size:26px; }
  header p{ font-size:13.5px; }
  .panel{ padding:16px; }
  .search-row{ flex-direction:column; }
  .search-row > *{ width:100%; }
  .input-wrap{ min-width:0; }
  input[type="number"]{ width:100%; }
  .search-row .btn{ text-align:center; justify-content:center; }
  .kw-name{ width:84px; font-size:13px; }
  .kw-count{ width:28px; }
  .thumb-grid{ grid-template-columns:repeat(auto-fill,minmax(72px,1fr)); gap:6px; }
  .mc-panel{ padding:0; }
  .mc-box{ max-width:100%; max-height:100%; border-radius:0; }
  .info-panel{ padding:0; align-items:flex-end; }
  .info-box{ width:100%; max-width:100%; max-height:85vh; border-radius:var(--radius-lg) var(--radius-lg) 0 0; }
  .detail-panel{ padding:0; align-items:flex-end; }
  .detail-box{ width:100%; max-width:100%; max-height:90vh; border-radius:var(--radius-lg) var(--radius-lg) 0 0; }
  .trending-head h2{ font-size:15px; }
  .selection-bar{ padding:10px 14px; flex-wrap:wrap; }
  .selection-bar .selection-text{ order:1; width:100%; flex-basis:100%; }
  .selection-bar .selection-actions{ order:2; width:100%; }
  .selection-bar .selection-actions .btn,
  .selection-bar .selection-actions .btn-ghost{ flex:1; text-align:center; justify-content:center; }
}
