:root{
  /* Light theme (default) */
  --bg: #ffffff;
  --card-bg: #ffffff;
  --glass: #ffffff;
  --border: #e5e7eb;
  --txt: #111827;
  --muted:#6b7280;
  --accent1:#ffa41c;
  --accent2:#cc8200;
  --ok:#059669;
  --warn:#b45309;
  --err:#dc2626;
  --ad-bg: #f9fafb;
  --shadow: 0 10px 30px rgba(0,0,0,0.10);
  --radius: 16px;
}
/* Dark theme overrides */
[data-theme="dark"]{
  --bg:  linear-gradient(135deg,#0f1027 0%,#1b1b3a 50%,#2a0d4a 100%);
  --card-bg: rgba(255,255,255,0.08);
  --glass: rgba(255,255,255,0.10);
  --border: rgba(255,255,255,0.18);
  --txt: #e9ecf1;
  --muted:#b8c0d4;
  --ok:#35d07f;
  --warn:#ffb020;
  --err:#ff5d5d;
  --ad-bg: rgba(255,255,255,0.9);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; font-family:Inter,'Noto Sans JP','Noto Sans KR',system-ui,-apple-system,Segoe UI,Roboto,Ubuntu,'Helvetica Neue','Noto Sans',Arial,sans-serif;
  color:var(--txt); background:var(--bg);
}
a{color:var(--accent2); text-decoration:none}
.wrap{max-width:1200px;margin:0 auto;padding:16px}
.header-bar{display:flex; gap:14px; align-items:center}
.brand{display:flex;gap:12px;align-items:center}
.logo{width:38px;height:38px;border-radius:12px;background:linear-gradient(135deg,var(--accent1),var(--accent2)); box-shadow: var(--shadow)}
.title{font-weight:800;letter-spacing:.3px}
.lang-switch{ display:none; }
.lang-box{ margin-left:auto; display:flex; flex-direction:column; gap:6px; align-items:flex-end; }
.lang-select{ padding:8px 10px; border-radius:12px; border:1px solid var(--border); background:var(--card-bg); color:var(--txt); }
.btn{
  background: var(--accent1);
  border:1px solid #f08804;
  color:#111827;
  padding:12px 16px;
  border-radius:8px;
  cursor:pointer;
  font-weight:700;
  font-size:16px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.6), 0 1px 2px rgba(0,0,0,0.06);
  transition: background-color .15s ease, transform .08s ease;
}
.btn:hover{ background:#ff9900; transform: translateY(-1px); }
.btn:active{ transform: translateY(0); background:#f08a00; }
.btn.secondary{
  background:#f3f4f6;
  border:1px solid #d1d5db;
  color:#111827;
  font-weight:600
}
.action-row{display:flex; gap:12px;align-items:center}
.action-row.right{justify-content:flex-end}
.grid{display:grid; gap:16px; align-items:start; grid-template-columns: 1fr; padding:16px}
@media (min-width:1024px){ .grid{grid-template-columns: 1fr 320px} }
header{
  position:sticky; top:0; z-index:20;
  background: #ffffff;
  border-bottom:1px solid var(--border);
}
/* Compact header spacing */
header .wrap{ padding-top:8px !important; padding-bottom:8px !important; }
[data-theme="dark"] header{ background: linear-gradient(0deg, rgba(0,0,0,0.0), rgba(0,0,0,0.35)); }
.ad{
  border:2px dashed #e5e7eb; background:var(--ad-bg); color:#1b1b3a;
  border-radius:20px; padding:18px; text-align:center; font-weight:700;
  transition:.2s; cursor:default
}
.ad:hover{background:#ffffff;border-color:#c9ced8}
.ad.top{min-height:140px}
.ad.footer{min-height:160px}
.ad.sb{width:100%; min-height:200px}
.ad.loading{width:300px; height:250px; margin:12px auto 0; display:flex; align-items:center; justify-content:center}
.card{
  background: #ffffff;
  border:1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 1px 2px rgba(0,0,0,0.06);
  padding:16px;
}
.card.warn{border-color: rgba(255,176,32,.6)}
.section-title{font-weight:800; margin:0 0 10px 0}
.muted{color:var(--muted); font-size:14px}
.caps{font-size:12px; text-transform:uppercase; letter-spacing:.4px; color:var(--muted)}
.row{display:grid; gap:12px}
.cols-2{grid-template-columns:1fr}
.cols-3{grid-template-columns:1fr}
@media(min-width:768px){ .cols-2{grid-template-columns:1fr 1fr} .cols-3{grid-template-columns:1fr 1fr 1fr} }
.mtop-8{margin-top:8px}.mtop-10{margin-top:10px}.mtop-12{margin-top:12px}.mtop-16{margin-top:16px}
.field label{display:block; font-weight:600; margin-bottom:6px}
.input, textarea, select{
  width:100%; padding:12px 12px; border-radius:12px; border:1px solid var(--border);
  background: #fff; color:var(--txt); outline:none;
}
[data-theme="dark"] .btn{ box-shadow: var(--shadow); }
[data-theme="dark"] .btn.secondary{ background:#374151; color:#e5e7eb; border-color:#4b5563; }
[data-theme="dark"] .btn.secondary:hover{ background:#4b5563; }
[data-theme="dark"] .card{ background: var(--glass); box-shadow: var(--shadow); }
input:focus, textarea:focus, select:focus{ border-color: var(--accent2); box-shadow: 0 0 0 3px rgba(37,99,235,0.18); }
[data-theme="dark"] .input, [data-theme="dark"] textarea, [data-theme="dark"] select{ background: rgba(255,255,255,0.06); }
textarea{min-height:110px; resize:vertical}
.hint{font-size:12px; color:var(--muted); margin-top:6px}
.hint-badge{display:inline-block;margin-top:6px;padding:4px 8px;border-radius:999px;font-weight:700;font-size:12px;color:#111827;background:linear-gradient(135deg,var(--accent1),var(--accent2));}
[data-theme="dark"] .hint-badge{ color:#111827; }
.chip-group{display:grid; gap:8px; grid-template-columns:repeat(2,1fr)}
@media(min-width:768px){.chip-group{grid-template-columns:repeat(6,1fr)}}
.chip{padding:10px;border-radius:12px;border:1px solid var(--border);text-align:center;cursor:pointer;background:rgba(255,255,255,0.06)}
.chip.active{outline:2px solid var(--accent2)}
.mode-tabs{display:flex; gap:8px; flex-wrap:wrap}
.mode-tabs .tab{padding:10px 12px; border-radius:12px; border:1px solid var(--border); background:rgba(255,255,255,0.06); cursor:pointer}
.tab.active{background:linear-gradient(135deg,var(--accent1),var(--accent2)); color:white; border-color:transparent}
.dropzone{
  position:relative;
  border:2px dashed var(--border); border-radius:16px; padding:16px; text-align:center;
  background:#fafafa;
}
[data-theme="dark"] .dropzone{ background:rgba(255,255,255,0.04); }
.thumbs{display:grid; gap:10px; grid-template-columns:repeat(auto-fill,minmax(90px,1fr)); margin-top:12px}
.thumb{position:relative;border-radius:12px;overflow:hidden;border:1px solid var(--border);background:rgba(0,0,0,.25)}
.thumb img{width:100%;height:90px;object-fit:cover;display:block}
.thumb button{position:absolute; top:6px; right:6px; border:none; background:rgba(0,0,0,.6); color:#fff; border-radius:8px; padding:4px 6px; cursor:pointer}
.results-grid,.gallery-grid{display:grid; gap:12px; grid-template-columns:repeat(auto-fill,minmax(180px,1fr))}
.results-grid.single{ grid-template-columns:minmax(320px, 900px); justify-content:center }
.img-card{position:relative;border-radius:16px; overflow:hidden; border:1px solid var(--border); background:#fff}
[data-theme="dark"] .img-card{ background:rgba(0,0,0,.25) }
.img-card img{width:100%; height:100%; object-fit:cover; display:block}
.img-actions{position:absolute; bottom:6px; left:6px; right:6px; display:flex; gap:6px; justify-content:space-between; opacity:0; transition:opacity .2s ease}
.img-card:hover .img-actions{ opacity:1 }
.img-actions .btn{padding:6px 10px; font-size:12px; border-radius:10px}
.overlay{position:fixed; inset:0; display:none; place-items:center; background:rgba(0,0,0,0.45); z-index:50}
.overlay.show{display:grid}
.loader{width:420px; max-width:92vw; background: var(--glass); border:1px solid var(--border); border-radius:18px; padding:18px; box-shadow: var(--shadow)}
.progress{height:10px; border-radius:999px; background:rgba(255,255,255,0.08); overflow:hidden}
.bar{height:100%; width:0%; background: linear-gradient(135deg,var(--accent1),var(--accent2)); transition: width .3s ease}
.spinner{width:36px;height:36px;border-radius:50%;border:4px solid rgba(255,255,255,.25); border-top-color:#fff; animation:spin 1s linear infinite; margin-right:8px}
@keyframes spin{to{transform:rotate(360deg)}}
.toasts{position:fixed; right:16px; bottom:16px; display:flex; flex-direction:column; gap:8px; z-index:60}
.toast{padding:10px 12px; border-radius:12px; font-weight:600}
.toast.ok{background:rgba(53,208,127,.15); border:1px solid rgba(53,208,127,.35); color:#b7f5d7}
.toast.err{background:rgba(255,93,93,.15); border:1px solid rgba(255,93,93,.35); color:#ffd2d2}
.toast.warn{background:rgba(255,176,32,.15); border:1px solid rgba(255,176,32,.35); color:#ffe9c7}
.footer-row{display:flex; gap:10px; align-items:center; flex-wrap:wrap}
@media(min-width:480px){ .wrap{padding:20px} }
@media(min-width:768px){ .wrap{padding:24px} }
@media(min-width:1024px){ .wrap{padding:28px} }

/* Hidden but clickable file input */
.file-input-hidden{ position:absolute !important; left:-9999px; width:1px; height:1px; opacity:0; }
.file-input-cover{ position:absolute; inset:0; width:100%; height:100%; opacity:0; cursor:pointer; z-index:1 }

/* Mobile-friendly buttons in action rows */
@media (max-width: 480px){
  .action-row{ flex-direction: column; align-items: stretch }
  .action-row .btn{ width: 100%; }
}
