:root {
  --bg: #0e0f13;
  --panel: #171922;
  --panel-2: #1e2130;
  --line: #2a2e3d;
  --text: #e8eaf0;
  --muted: #9aa0b4;
  --accent: #6ea8ff;
  --accent-2: #a06eff;
  --danger: #ff6e7e;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Segoe UI", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}

#app { max-width: 1200px; margin: 0 auto; padding: 16px; }

.topbar { text-align: center; margin-bottom: 14px; }
.topbar h1 { font-size: 1.35rem; margin: 0; letter-spacing: .02em; }
.tagline { color: var(--muted); font-size: .8rem; margin: 4px 0 0; }

/* ---------- layout ---------- */
.layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 16px;
  align-items: start;
}
@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
}

/* ---------- loaders ---------- */
.loaders {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.chip {
  margin-left: auto;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: .8rem;
  color: var(--muted);
}

/* ---------- buttons ---------- */
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .9rem;
  cursor: pointer;
  transition: filter .12s, background .12s, opacity .12s;
  user-select: none;
}
.btn:hover:not(:disabled) { filter: brightness(1.15); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn-file { display: inline-flex; align-items: center; }
.btn-accent { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border: none; color: #fff; font-weight: 600; }
.btn-lg { width: 100%; padding: 14px; font-size: 1rem; margin-top: 14px; }
.btn-sm { padding: 8px 10px; font-size: .82rem; flex: 1; }
.btn-danger { color: var(--danger); border-color: #4a2530; }

/* ---------- stage ---------- */
.stage-wrap {
  position: relative;
  background:
    repeating-conic-gradient(#20222c 0% 25%, #191b24 0% 50%) 50% / 22px 22px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  touch-action: none;
  min-height: 220px;
  display: flex;
  align-items: center;
  justify-content: center;
}
#stage { display: block; max-width: 100%; height: auto; touch-action: none; }

.drop-hint {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: var(--muted); text-align: center; font-size: .9rem;
  pointer-events: none; padding: 20px;
}
.drop-hint.hide { display: none; }
.stage-wrap.empty { cursor: pointer; }
.stage-wrap.dragover { outline: 2px dashed var(--accent); outline-offset: -6px; }

/* ---------- thumbnails ---------- */
.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.thumb {
  width: 56px; height: 56px;
  border-radius: 8px;
  border: 2px solid var(--line);
  background: var(--panel-2) center/cover no-repeat;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}
.thumb.active { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(110,168,255,.35); }
.thumb .idx {
  position: absolute; top: 2px; left: 4px;
  font-size: .68rem; color: #fff; text-shadow: 0 1px 2px #000;
}

/* ---------- controls ---------- */
.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  position: sticky;
  top: 12px;
}
.control-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.control-head label { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.control-head select { flex: 1; }

select {
  appearance: none;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .88rem;
}

.panel { display: flex; flex-direction: column; gap: 4px; }
.panel-disabled { opacity: .4; pointer-events: none; }

.row { display: flex; align-items: center; gap: 8px; min-height: 34px; }
.row .lbl { width: 86px; font-size: .8rem; color: var(--muted); flex-shrink: 0; line-height: 1.25; }
.row output { width: 46px; text-align: right; font-size: .78rem; color: var(--text); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.row .grow { flex: 1; }
.row.btns { gap: 6px; margin-top: 4px; }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--accent);
  border: 3px solid var(--panel);
  box-shadow: 0 1px 4px rgba(0,0,0,.5);
  cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--accent); border: 3px solid var(--panel); cursor: pointer;
}

hr { border: none; border-top: 1px solid var(--line); margin: 8px 0; }

/* switch */
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex-shrink: 0; }
.switch input { display: none; }
.slider-sw {
  position: absolute; inset: 0; background: var(--line);
  border-radius: 999px; transition: .15s; cursor: pointer;
}
.slider-sw::before {
  content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px;
  background: #fff; border-radius: 50%; transition: .15s;
}
.switch input:checked + .slider-sw { background: var(--accent); }
.switch input:checked + .slider-sw::before { transform: translateX(18px); }

.note { color: var(--muted); font-size: .72rem; text-align: center; margin: 10px 0 0; }
.hint { color: var(--muted); font-size: .7rem; line-height: 1.5; margin: 2px 0 0; }
.hint.status:empty { display: none; }
.hint.status { color: var(--accent); }

/* ---------- サイト内ページ用 ---------- */
.app-footer {
  text-align: center;
  color: var(--muted);
  font-size: .75rem;
  margin: 28px 0 10px;
}
.app-footer a { color: var(--muted); }
.app-footer a:hover { color: var(--text); }
.app-footer .copyright { margin: 0 0 4px; }
