*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #fafafa;
  color: #1a1a1a;
  min-height: 100vh;
  padding: 2rem;
}

/* ── レイアウト ── */
.app {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 24px;
  align-items: start;
  max-width: 1100px;
  margin: 0 auto;
}

.app > * {
  min-width: 0;
}

/* ── 右パネル ── */
.panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: #888;
}

.panel-note {
  font-size: 11px;
  color: #777;
  line-height: 1.45;
}

.url-input {
  width: 100%;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0 12px;
  font-size: 13px;
  color: #1a1a1a;
  background: #fff;
  transition: border-color .15s;
}
.url-input:focus {
  outline: none;
  border-color: #999;
}

.btn-primary {
  width: 100%;
  height: 36px;
  background: #1a1a1a;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s;
}
.btn-primary:hover  { background: #333; }
.btn-primary:disabled { opacity: .4; cursor: not-allowed; }

.btn-secondary {
  width: 100%;
  height: 36px;
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  transition: background .15s;
}
.btn-secondary:hover { background: #f5f5f5; }

.status {
  font-size: 12px;
  color: #888;
  min-height: 16px;
  line-height: 1.4;
}
.status.error   { color: #c0392b; }
.status.success { color: #27ae60; }

/* ── 手動アップロード ── */
.drop-zone {
  display: flex;
  flex-direction: column;
  gap: 2px;
  align-items: center;
  justify-content: center;
  min-height: 64px;
  padding: 12px 8px;
  border: 1.5px dashed #ccc;
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.drop-zone:hover   { border-color: #999; background: #f5f5f5; }
.drop-zone.dragover { border-color: #1a1a1a; background: #f0f0f0; }
.drop-zone.loading {
  border-color: #999;
  background: #f7f7f7;
  cursor: wait;
}
.drop-zone.set {
  border-style: solid;
  border-color: #27ae60;
  background: #f3faf5;
}

.drop-label {
  font-size: 12px;
  font-weight: 600;
  color: #1a1a1a;
}

.drop-hint {
  font-size: 10px;
  color: #aaa;
  line-height: 1.3;
}
.drop-zone.set .drop-hint { color: #27ae60; }

/* ── 背景色スウォッチ ── */
.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.swatch {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  cursor: pointer;
  border: 2px solid transparent;
  transition: border-color .15s, transform .1s;
}
.swatch:hover  { transform: scale(1.1); }
.swatch.active { border-color: #1a1a1a; }
.swatch[data-color="#ffffff"]        { border-color: #ddd; }
.swatch[data-color="#ffffff"].active { border-color: #1a1a1a; }

/* ── カラーピッカー ── */
.color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

input[type="color"] {
  width: 36px;
  height: 36px;
  padding: 2px;
  border: 1px solid #ddd;
  border-radius: 8px;
  cursor: pointer;
  background: none;
}

.color-hex {
  font-size: 13px;
  color: #555;
  font-family: monospace;
}

/* ── プレビューキャンバス ── */
.canvas-wrap {
  position: relative;
  width: 100%;
  padding-bottom: 100%;   /* 正方形を維持 */
  border-radius: 16px;
  background: #ffffff;    /* デフォルト背景色 */
  overflow: hidden;
  transition: background .2s;
}

.canvas-inner {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* デバイス全体のコンテナ */
.device-container {
  position: relative;
  width: 90%;
  aspect-ratio: 1 / 1;   /* devices.png が正方形のため */
}

/* デバイスフレーム画像（最前面） */
.device-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 3;
  pointer-events: none;
  user-select: none;
}

/* スクリーンショット画像の共通スタイル */
.screen-img {
  position: absolute;
  z-index: 1;
  pointer-events: none;
  display: none;          /* スクリーンショット取得後に表示 */
  object-fit: fill;
}

/*
  画面領域をパーセントで指定（計測値ベース）
  devices.png 1024×1024px を計測した結果：

  PC画面:   top=279px(27.25%), left=134px(13.09%), w=679px(66.31%), h=420px(41.02%)
  SP画面:   top=437px(42.68%), left=741px(72.36%), w=209px(20.41%), h=435px(42.48%)
  ※ ベゼル内側に3pxずつ重ねて隙間を防止
*/
.pc-screen {
  top:    27.25%;
  left:   13.09%;
  width:  66.31%;
  height: 41.02%;
}

.sp-screen {
  top:    42.8%;
  left:   72.36%;
  width:  20.41%;
  height: 42.26%;
  border-radius: 0 0 16px 16px;
}

/* スマホ ダイナミックアイランド部分のマスク */
.sp-status-mask {
  position: absolute;
  top:    40.80%;
  left:   72.36%;
  width:  20.41%;
  height: 2.25%;
  background: #000;
  border-radius: 16px 16px 0 0;
  z-index: 2;             /* 画像(1)より上、デバイスフレーム(3)より下 */
  pointer-events: none;
}

@media (max-width: 760px) {
  body {
    padding: 16px;
  }

  .app {
    grid-template-columns: 1fr;
    max-width: 520px;
  }

  .panel {
    gap: 16px;
  }

  .device-container {
    width: 86%;
  }
}
