:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --line: #e2e5ea;
  --text: #1f2328;
  --muted: #6b7280;
  --accent: #ff5a5f;
  --accent-dark: #e14b50;
  --radius: 10px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

/* ---- ヘッダー ---- */
.header {
  padding: 20px 28px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.header h1 { margin: 0; font-size: 20px; }
.header .sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

/* ---- レイアウト ---- */
.layout {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  padding: 20px;
  align-items: start;
}
@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  padding-right: 4px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}
.card h2 {
  margin: 0 0 12px;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .02em;
}

/* ---- フォーム ---- */
.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.field > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

input[type="number"],
input[type="text"],
select {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
}
select { width: 100%; }
input[type="number"]:focus,
input[type="text"]:focus,
select:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.num { width: 72px; }
.num.wide { width: 100%; }

input[type="range"] { flex: 1; accent-color: var(--accent); }
input[type="color"] {
  width: 42px; height: 34px; padding: 2px;
  border: 1px solid var(--line); border-radius: 6px; background: #fff;
}

.row { display: flex; align-items: center; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }

.sub-field { display: flex; flex-direction: column; gap: 4px; }
.sub-field span { font-size: 11px; color: var(--muted); }
.sub-field input { width: 100%; }

.check {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--muted); margin-top: 8px;
  cursor: pointer;
}
.check input { accent-color: var(--accent); }

.hint { margin: 6px 0 0; font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 11px; }
.hidden { display: none !important; }

/* ---- ボタン ---- */
.btn {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s;
}
.btn:hover { background: #f6f7f9; }
.btn-sm { padding: 4px 8px; font-size: 11px; }
.btn-ghost { border-color: transparent; color: var(--muted); }
.btn-block { width: 100%; margin-top: 4px; }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 700;
  padding: 11px 14px;
}
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-primary:disabled {
  background: #d1d5db; border-color: #d1d5db; cursor: not-allowed;
}

/* ---- ドロップゾーン ---- */
.dropzone {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
.dropzone p { margin: 2px 0; font-size: 13px; }
.dropzone.dragover { border-color: var(--accent); background: #fff5f5; }

/* ---- サムネイル ---- */
.list-head {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 14px; font-size: 12px; font-weight: 600;
}
.thumbs {
  list-style: none; margin: 8px 0 6px; padding: 0;
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px;
}
.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--line);
  cursor: grab;
  background: #eee;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.thumb.dragging { opacity: .4; }
.thumb.drop-target { outline: 2px solid var(--accent); outline-offset: -2px; }
.thumb .idx {
  position: absolute; left: 3px; top: 3px;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 10px; line-height: 1;
  padding: 3px 5px; border-radius: 4px;
}
.thumb .del {
  position: absolute; right: 2px; top: 2px;
  width: 18px; height: 18px; line-height: 16px; text-align: center;
  border: none; border-radius: 50%;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 12px; cursor: pointer; padding: 0;
}
.thumb .del:hover { background: var(--accent); }

/* ---- プレビュー ---- */
.preview-area {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  position: sticky;
  top: 20px;
}
.preview-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.preview-head h2 { margin: 0; font-size: 14px; }

.preview-stage {
  display: flex; align-items: center; justify-content: center;
  min-height: 420px;
  background:
    repeating-conic-gradient(#eceef1 0% 25%, #f8f9fa 0% 50%) 50% / 20px 20px;
  border-radius: 8px;
  padding: 16px;
}
#canvas {
  max-width: 100%;
  max-height: calc(100vh - 220px);
  box-shadow: 0 2px 14px rgba(0,0,0,.12);
  display: none;
}
.empty { text-align: center; color: var(--muted); }
.empty p { margin: 2px 0; }
