:root{
  --bg:#0b0f14;
  --card:#111826;
  --text:#e7eef8;
  --muted:#9fb0c6;
  --border:rgba(255,255,255,.08);
  --primary:#4da3ff;
  --radius:18px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans TC", Arial;
  background:var(--bg);
  color:var(--text);
}
.app{padding:18px; max-width:1200px; margin:0 auto;}

.topbar{
  display:flex; align-items:center; justify-content:space-between;
  padding:14px 16px;
  border:1px solid var(--border);
  border-radius:var(--radius);
  background:linear-gradient(180deg, rgba(255,255,255,.04), rgba(255,255,255,.02));
}
.brand{display:flex; gap:12px; align-items:center;}
.dot{width:12px;height:12px;border-radius:50%; background:var(--primary); box-shadow:0 0 0 6px rgba(77,163,255,.12);}
.title{font-weight:700}
.sub{font-size:12px; color:var(--muted); margin-top:2px}

.actions{display:flex; gap:10px; align-items:center}
.btn{
  border:1px solid var(--border);
  background:rgba(255,255,255,.03);
  color:var(--text);
  padding:10px 12px;
  border-radius:14px;
  cursor:pointer;
}
.btn:hover{background:rgba(255,255,255,.05)}
.btn:disabled{opacity:.5; cursor:not-allowed}
.btn.primary{background:rgba(77,163,255,.18); border-color:rgba(77,163,255,.35)}
.btn.primary:hover{background:rgba(77,163,255,.26)}
select.btn{padding:10px 10px}

.grid{
  margin-top:16px;
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:14px;
}
@media (max-width: 980px){ .grid{grid-template-columns:1fr} }

.card{
  border:1px solid var(--border);
  border-radius:var(--radius);
  padding:14px;
  background:linear-gradient(180deg, rgba(255,255,255,.035), rgba(255,255,255,.02));
}
.card h3{margin:0 0 10px 0; font-size:14px; color:#d7e6fb;}
.card.batch{opacity:.9}
.card.batch .desc{font-size:12px;color:var(--muted);margin-bottom:10px;line-height:1.5}
.card.batch .tag{font-size:11px;padding:2px 6px;border-radius:999px;background:rgba(255,255,255,.08);color:var(--muted);margin-left:6px}

.drop{
  border:1px dashed rgba(255,255,255,.18);
  border-radius:16px;
  padding:18px;
  background:rgba(0,0,0,.16);
}
.drop.hover{border-color:rgba(77,163,255,.65); box-shadow:0 0 0 6px rgba(77,163,255,.10)}
.dropText{font-weight:700}
.dropHint{font-size:12px; color:var(--muted); margin-top:6px}

.row{display:flex; gap:10px; margin-top:12px; align-items:center}
.label{width:60px; color:var(--muted); font-size:12px}
.muted{color:var(--muted)}
.mono{font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; font-size:12px}

.form{display:flex; flex-direction:column; gap:12px}
.field label{display:block; font-size:12px; color:var(--muted); margin-bottom:6px}
.inline{display:flex; gap:8px; align-items:center}
input[type="number"], select{
  background:rgba(0,0,0,.22);
  border:1px solid var(--border);
  color:var(--text);
  padding:8px 10px;
  border-radius:12px;
  outline:none;
  width:110px;
}
select{width:120px}
input[type="range"]{width:100%}

.paramActions{
  margin:6px 0 12px 0;
  display:flex;
  justify-content:flex-end;
}

.viewport{
  margin-top:10px;
  width:100%;
  aspect-ratio:16/9;
  border-radius:16px;
  border:1px solid var(--border);
  background:rgba(0,0,0,.22);
  overflow:hidden;
  position:relative;
  display:flex;
  align-items:center;
  justify-content:center;
}
.viewport.hover{
  border-color:rgba(77,163,255,.65);
  box-shadow:0 0 0 6px rgba(77,163,255,.10);
}
.viewport img{width:100%;height:100%;object-fit:cover;display:none}
.viewportEmpty{padding:14px;text-align:center;color:var(--muted);font-size:12px}

.previewActions{display:flex; gap:10px; align-items:center; margin-top:10px}
.sep{border:none;border-top:1px solid var(--border); margin:14px 0; opacity:.8}

.progress .bar{
  height:10px;
  border-radius:999px;
  background:rgba(255,255,255,.08);
  overflow:hidden;
  border:1px solid var(--border);
}
.fill{height:100%; background:rgba(77,163,255,.85)}
.stats{margin-top:12px; display:grid; gap:8px}

.log{
  margin-top:12px;
  max-height:190px;
  overflow:auto;
  padding:10px;
  border-radius:14px;
  border:1px solid var(--border);
  background:rgba(0,0,0,.20);
  white-space:pre-wrap;
}

/* ===== Pretty Select (native, styled) ===== */
select.btn,
select#format{
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;

  border: 1px solid var(--border);
  background: rgba(255,255,255,.03);
  color: var(--text);

  padding: 10px 38px 10px 12px; /* 右邊留箭頭空間 */
  border-radius: 14px;
  cursor: pointer;

  line-height: 1;
  outline: none;
}

/* 讓 select 跟 input 對齊高度 */
select#format{
  padding: 8px 38px 8px 10px;
  border-radius: 12px;
  background: rgba(0,0,0,.22);
}

/* hover / focus */
select.btn:hover,
select#format:hover{
  background: rgba(255,255,255,.05);
}

select.btn:focus,
select#format:focus{
  border-color: rgba(77,163,255,.55);
  box-shadow: 0 0 0 6px rgba(77,163,255,.10);
}

/* 下拉選單的 option（各瀏覽器支援度不同，但能用就用） */
select option{
  background: #0f1520;
  color: var(--text);
}

/* ===== Custom arrow via background SVG ===== */
select.btn,
select#format{
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24'%3E%3Cpath fill='%239fb0c6' d='M7 10l5 5l5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px 14px;
}

/* ===== Fixed Ad (collapsible) ===== */
.ad-dock{
  position: fixed;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(100%, 1200px);
  z-index: 9999;
  pointer-events: none; /* 讓 dock 本體不擋操作，裡面再開啟 */
}

.ad-dock *{ pointer-events: auto; }

/* 展開狀態：底部面板 */
.ad-panel{
  height: 110px;
  border-radius: 18px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  overflow: hidden;

  display: flex;
  align-items: center;
  justify-content: center;

  position: relative;
}

/* 右上角關閉按鈕 */
.ad-btn{
  position: absolute;
  top: 10px;
  right: 12px;
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,.06);
  color: var(--muted);
  cursor: pointer;
}
.ad-btn:hover{ background: rgba(255,255,255,.10); }

/* 左上角 AD 標章 */
.ad-badge{
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.08);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* 內容區（放廣告碼） */
.ad-slot{
  width: 100%;
  height: 100%;
  padding: 14px 56px; /* 留右上角按鈕空間 */
  display: flex;
  align-items: center;
  justify-content: center;
}
.ad-placeholder{
  font-size: 12px;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  opacity: .9;
}

/* 收合後的小膠囊（右下角） */
.ad-pill{
  position: fixed;
  right: 14px;
  bottom: 14px;
  height: 42px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(0,0,0,.55);
  backdrop-filter: blur(10px);
  color: var(--text);
  cursor: pointer;
  display: none;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
}
.ad-pill:hover{ background: rgba(0,0,0,.68); }

/* 狀態切換 */
.ad-dock[data-state="open"] .ad-panel{ display:flex; }
.ad-dock[data-state="open"] .ad-pill{ display:none; }

.ad-dock[data-state="collapsed"] .ad-panel{ display:none; }
.ad-dock[data-state="collapsed"] .ad-pill{ display:inline-flex; align-items:center; justify-content:center; }

/* 手機：建議直接不顯示（或只顯示 ad-pill） */
@media (max-width: 980px){
  .ad-dock{ display:none; }
}

.ad-link{
  display:flex;
  width:100%;
  height:100%;
  align-items:center;
  justify-content:center;
  text-decoration:none;
  color:var(--text);
}

.ad-content{
  text-align:center;
  line-height:1.4;
}

.ad-content strong{
  display:block;
  font-size:14px;
}

.ad-content span{
  font-size:12px;
  color:var(--muted);
}

.ad-panel{
  pointer-events: auto;
}

.ad-badge,
.ad-btn{
  pointer-events: auto;
}

.adsbygoogle{
  pointer-events: auto;
}

.footer a{
  color: white;
  padding: 20px;
  text-decoration: none;
}
