/* img2figma UI */
:root {
  --c-photo: #2f6fdb;
  --c-text: #1e9e5a;
  --c-deco: #e08a1e;
  --c-bg: #f5f4f0;
  --c-card: #ffffff;
  --c-ink: #33322e;
  --c-sub: #7a776f;
  --c-line: #e3e1da;
  --c-primary: #33322e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Hiragino Sans", "Noto Sans JP", "Yu Gothic", sans-serif;
  background: var(--c-bg);
  color: var(--c-ink);
  line-height: 1.7;
  font-size: 14px;
}

header { padding: 28px 24px 8px; max-width: 1200px; margin: 0 auto; }
header h1 { margin: 0; font-size: 22px; letter-spacing: 0.04em; }
header .sub { margin: 4px 0 0; color: var(--c-sub); font-size: 13px; }

main { max-width: 1200px; margin: 0 auto; padding: 8px 24px 40px; }

footer { max-width: 1200px; margin: 0 auto; padding: 0 24px 32px; color: var(--c-sub); font-size: 12px; }

.card {
  background: var(--c-card);
  border: 1px solid var(--c-line);
  border-radius: 10px;
  padding: 20px 24px;
  margin-top: 16px;
}
.card h2 { font-size: 16px; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%;
  background: var(--c-ink); color: #fff; font-size: 12px;
}

/* ドロップゾーン */
#dropzone {
  border: 2px dashed var(--c-line);
  border-radius: 10px;
  padding: 40px 20px;
  text-align: center;
  transition: border-color .15s, background .15s;
}
#dropzone.dragover { border-color: var(--c-photo); background: #eef4fd; }
.dz-main { font-size: 15px; margin: 0 0 6px; }
.dz-sub { color: var(--c-sub); margin: 0; }

/* ボタン */
.btn {
  font: inherit; font-size: 13px;
  padding: 6px 14px;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  background: #fff; color: var(--c-ink);
  cursor: pointer;
}
.btn:hover:not(:disabled) { background: #f2f1ec; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--c-primary); color: #fff; border-color: var(--c-primary); }
.btn-primary:hover:not(:disabled) { background: #4a4942; }
.btn-ghost { border-color: transparent; color: var(--c-sub); }
.btn-ai { border-color: #c9b8e8; background: #f7f3fd; }
.btn-ai:hover:not(:disabled) { background: #efe6fb; }

/* ステータス */
#statusBar { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; min-height: 24px; }
#statusText { color: var(--c-sub); font-size: 13px; }
#statusProgress { width: 180px; }

/* 凡例 */
.legend { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px; }
.chip { font-size: 12px; padding: 2px 10px; border-radius: 999px; color: #fff; }
.chip-photo { background: var(--c-photo); }
.chip-text { background: var(--c-text); }
.chip-deco { background: var(--c-deco); }
.legend-hint { color: var(--c-sub); font-size: 12px; }

.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar-sep { flex: 1; }

/* エディタ */
.editor-layout { display: flex; gap: 16px; align-items: flex-start; }

#stage {
  position: relative;
  flex: 1;
  min-width: 0;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  overflow: hidden;
  background:
    repeating-conic-gradient(#fafafa 0% 25%, #f0f0f0 0% 50%) 0 0 / 20px 20px;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}
#stage.draw-mode { cursor: crosshair; }
#stageImg { display: block; width: 100%; height: auto; pointer-events: none; }
#boxesLayer { position: absolute; inset: 0; }

.region-box {
  position: absolute;
  border: 2px solid;
  border-radius: 2px;
  cursor: move;
}
.region-box .region-label {
  position: absolute; top: -1px; left: -1px;
  font-size: 10px; line-height: 1.4;
  color: #fff; padding: 0 6px;
  border-radius: 0 0 4px 0;
  white-space: nowrap;
  pointer-events: none;
}
.region-box.type-photo { border-color: var(--c-photo); background: rgba(47,111,219,.12); }
.region-box.type-photo .region-label { background: var(--c-photo); }
.region-box.type-text { border-color: var(--c-text); background: rgba(30,158,90,.12); }
.region-box.type-text .region-label { background: var(--c-text); }
.region-box.type-deco { border-color: var(--c-deco); background: rgba(224,138,30,.14); }
.region-box.type-deco .region-label { background: var(--c-deco); }
.region-box.selected { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--c-ink); }

.handle {
  position: absolute; width: 10px; height: 10px;
  background: #fff; border: 1.5px solid var(--c-ink);
  border-radius: 2px;
}
.handle-nw { top: -6px; left: -6px; cursor: nwse-resize; }
.handle-ne { top: -6px; right: -6px; cursor: nesw-resize; }
.handle-sw { bottom: -6px; left: -6px; cursor: nesw-resize; }
.handle-se { bottom: -6px; right: -6px; cursor: nwse-resize; }

#drawRect {
  position: absolute;
  border: 2px dashed var(--c-deco);
  background: rgba(224,138,30,.1);
  pointer-events: none;
}

/* サイドパネル */
#panel {
  width: 300px; flex-shrink: 0;
  border: 1px solid var(--c-line);
  border-radius: 6px;
  padding: 14px 16px;
  background: #fbfaf8;
}
#panel h3 { margin: 0 0 8px; font-size: 14px; }
#panel h4 { margin: 16px 0 4px; font-size: 13px; }
.panel-note { color: var(--c-sub); font-size: 12px; margin: 4px 0; }
#typeField { border: 1px solid var(--c-line); border-radius: 6px; margin: 8px 0; padding: 6px 10px; }
#typeField legend { font-size: 12px; color: var(--c-sub); padding: 0 4px; }
#typeField label { margin-right: 10px; font-size: 13px; }
#textField label { font-size: 12px; color: var(--c-sub); display: block; margin-bottom: 4px; }
#regionText { width: 100%; font: inherit; font-size: 13px; border: 1px solid var(--c-line); border-radius: 6px; padding: 6px 8px; resize: vertical; }
.ai-buttons { display: flex; flex-direction: column; gap: 6px; margin-top: 6px; }
.ai-buttons .btn { text-align: left; }
#aiStatus:empty { display: none; }
#aiStatus { margin-top: 8px; }
#aiStatus.error { color: #c0392b; }

@media (max-width: 900px) {
  .editor-layout { flex-direction: column; }
  #panel { width: 100%; }
}
