/* ============================================================
   Paper Harmony - paper-harmony-style.css
   prefix: ph-  /  root: .ph-root
   ============================================================ */

/* ---------- リセット・スコープ ---------- */
.ph-root {
  all: initial;
  display: block;
  box-sizing: border-box;
  font-family: "Hiragino Kaku Gothic ProN", "BIZ UDGothic", Meiryo, sans-serif;
  font-size: 14px;
  color: #1f2937;
  line-height: 1.4;
  background: #edeae3;
  position: relative;

  /* CSS変数 */
  --ph-board-bg: #f6f3e9;
  --ph-ui:       #2563eb;
  --ph-ui-h:     #1d4ed8;
  --ph-line:     #e5e7eb;
  --ph-success:  #10b981;
  --ph-danger:   #ef4444;
  --ph-navy:     #1e3a5f;
}

.ph-root * {
  box-sizing: border-box;
  font-family: inherit;
}

/* ---------- レイアウト ---------- */
.ph-main {
  display: flex;
  min-height: 600px;
  overflow: hidden;
}

/* 左サイドバー */
.ph-sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid var(--ph-line);
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  padding: 16px 14px;
  gap: 14px;
}

/* 右サイドバー */
.ph-sidebar-right {
  width: 210px;
  flex-shrink: 0;
  background: #fff;
  border-left: 1px solid var(--ph-line);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px 14px;
  gap: 12px;
}

/* キャンバスエリア */
.ph-canvas-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 16px;
  overflow: hidden;
}

/* ---------- タイトル ---------- */
.ph-title-block {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ph-line);
}
.ph-title-icon { font-size: 1.5rem; }
.ph-title-text {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ph-navy);
  letter-spacing: .04em;
  display: block;
}
.ph-title-sub {
  font-size: .72rem;
  color: #94a3b8;
  margin-top: 1px;
  display: block;
}

/* ---------- セクション ---------- */
.ph-section { display: block; }
.ph-section-title {
  font-size: .78rem;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.ph-op-section { margin-top: auto; }

/* ---------- カラーパレット ---------- */
.ph-palette {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.ph-swatch-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 5px 3px;
  border: 1.5px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  background: none;
  transition: all .2s;
}
.ph-swatch-wrap:hover { background: #f1f5f9; }
.ph-swatch-wrap.ph-active {
  background: #eff6ff;
  border-color: var(--ph-ui);
}
.ph-swatch-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 3px solid rgba(0,0,0,.08);
  box-shadow: 0 2px 6px rgba(0,0,0,.15);
  transition: transform .2s;
  display: block;
}
.ph-swatch-wrap:hover .ph-swatch-circle { transform: scale(1.08); }
.ph-swatch-wrap.ph-active .ph-swatch-circle {
  box-shadow: 0 0 0 3px rgba(37,99,235,.3);
}
.ph-swatch-label {
  font-size: .7rem;
  color: #64748b;
  font-weight: 600;
  display: block;
}
.ph-swatch-wrap.ph-active .ph-swatch-label { color: var(--ph-ui); }

.ph-custom-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
}
.ph-custom-row label { font-size: .8rem; color: #64748b; }
.ph-root input[type="color"] {
  width: 44px;
  height: 36px;
  border: 1px solid var(--ph-line);
  border-radius: 8px;
  cursor: pointer;
  padding: 2px;
  background: #fff;
}

/* ---------- 形状セレクタ ---------- */
.ph-shapes { display: flex; gap: 6px; }
.ph-shape-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 8px 4px;
  border: 1.5px solid var(--ph-line);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  transition: all .2s;
  font-size: .7rem;
  color: #64748b;
}
.ph-shape-btn span:first-child { font-size: 1.25rem; display: block; }
.ph-shape-btn:hover { background: #f8fafc; border-color: var(--ph-ui); }
.ph-shape-btn.ph-active {
  background: var(--ph-ui);
  color: #fff;
  border-color: var(--ph-ui);
}

/* ---------- 操作ボタングループ ---------- */
.ph-op-group { display: flex; flex-direction: column; gap: 8px; }
.ph-op-row   { display: flex; gap: 6px; }
.ph-op-row .ph-btn {
  flex: 1;
  justify-content: center;
  font-size: .82rem;
  padding: 9px 6px;
}

/* ---------- ボタン共通 ---------- */
.ph-btn {
  appearance: none;
  border: 1.5px solid var(--ph-line);
  background: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
  font-size: .88rem;
  font-weight: 600;
  font-family: inherit;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all .2s;
  color: #1f2937;
  text-decoration: none;
}
.ph-btn:hover { background: #f8fafc; border-color: var(--ph-ui); transform: translateY(-1px); }
.ph-btn:active { transform: translateY(0); }
.ph-btn:disabled,
.ph-btn[disabled] {
  opacity: .38;
  cursor: not-allowed;
  transform: none;
  pointer-events: none;
}
.ph-primary-btn {
  background: var(--ph-ui) !important;
  color: #fff !important;
  border-color: var(--ph-ui) !important;
}
.ph-primary-btn:hover { background: var(--ph-ui-h) !important; }
.ph-success-btn {
  background: var(--ph-success) !important;
  color: #fff !important;
  border-color: var(--ph-success) !important;
}
.ph-success-btn:hover { background: #059669 !important; }
.ph-danger-btn {
  color: var(--ph-danger) !important;
  border-color: var(--ph-danger) !important;
}

/* ---------- キャンバス ---------- */
.ph-board-wrap {
  position: relative;
  width: 100%;
  max-width: 860px;
}
.ph-board {
  width: 100%;
  aspect-ratio: 10 / 7;
  border-radius: 12px;
  border: 2px solid #d6d3d1;
  background: var(--ph-board-bg);
  overflow: hidden;
  cursor: crosshair;
  box-shadow: 0 4px 20px rgba(0,0,0,.1), inset 0 2px 4px rgba(0,0,0,.05);
  display: block;
}
.ph-board canvas {
  width: 100%;
  height: 100%;
  display: block;
}
.ph-mode-badge {
  position: absolute;
  top: 10px;
  left: 12px;
  background: rgba(255,255,255,.92);
  border: 1px solid var(--ph-line);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: .75rem;
  font-weight: 700;
  backdrop-filter: blur(4px);
  pointer-events: none;
}
.ph-mode-badge.ph-compose {
  color: var(--ph-ui);
  border-color: #bfdbfe;
  background: rgba(239,246,255,.92);
}

/* ---------- 縦ステップ ---------- */
.ph-vsteps { display: flex; flex-direction: column; gap: 0; }
.ph-vstep {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 4px;
  font-size: .82rem;
  color: #94a3b8;
  transition: all .3s;
  position: relative;
}
.ph-vstep:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 10px;
  bottom: -8px;
  width: 2px;
  height: 10px;
  background: #e2e8f0;
}
.ph-vstep-active { color: var(--ph-ui); font-weight: 700; }
.ph-vstep-done   { color: var(--ph-success); }
.ph-vstep-num {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #64748b;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  flex-shrink: 0;
  transition: all .3s;
}
.ph-vstep-active .ph-vstep-num { background: var(--ph-ui); color: #fff; }
.ph-vstep-done   .ph-vstep-num { background: var(--ph-success); color: #fff; }

/* ---------- 保存枚数 ---------- */
.ph-paper-count-row {
  font-size: .8rem;
  color: #64748b;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--ph-line);
}
.ph-count-num { font-weight: 700; }
.ph-layer-count { font-weight: 400; color: #94a3b8; margin-left: 4px; }

/* ---------- サムネイル一覧 ---------- */
.ph-thumbs { display: flex; flex-direction: column; gap: 6px; }
.ph-thumb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border: 1.5px solid var(--ph-line);
  border-radius: 10px;
  background: #fafafa;
  cursor: pointer;
  transition: all .2s;
  font-size: .83rem;
}
.ph-thumb-item:hover { background: #f0f9ff; border-color: var(--ph-ui); }
.ph-thumb-item.ph-active { background: #eff6ff; border-color: var(--ph-ui); }
.ph-thumb-item.ph-drag-over {
  border-color: var(--ph-ui);
  background: #dbeafe;
  transform: scale(1.02);
}
.ph-thumb-chip {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: 1px solid rgba(0,0,0,.1);
  flex-shrink: 0;
  display: block;
}
.ph-thumb-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: block;
}
.ph-thumb-del {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: .9rem;
  padding: 2px 5px;
  border-radius: 4px;
  transition: all .2s;
}
.ph-thumb-del:hover { color: var(--ph-danger); background: #fee2e2; }
.ph-thumbs-empty {
  font-size: .8rem;
  color: #94a3b8;
  text-align: center;
  padding: 12px 0;
  display: block;
}
.ph-drag-handle {
  color: #cbd5e1;
  font-size: 1rem;
  cursor: grab;
  padding: 0 4px 0 0;
  flex-shrink: 0;
  user-select: none;
  display: block;
}
.ph-drag-handle:active { cursor: grabbing; }

/* ---------- トースト ---------- */
.ph-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: #1e293b;
  color: #fff;
  padding: 11px 22px;
  border-radius: 30px;
  font-size: .88rem;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  transition: transform .35s cubic-bezier(.34,1.56,.64,1);
  z-index: 9999;
  pointer-events: none;
  white-space: nowrap;
}
.ph-toast.ph-show { transform: translateX(-50%) translateY(0); }

/* ---------- 完成モーダル ---------- */
.ph-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s;
}
.ph-modal-overlay.ph-show { opacity: 1; pointer-events: auto; }
.ph-modal {
  background: #fff;
  border-radius: 20px;
  padding: 32px 36px;
  max-width: 460px;
  width: 92%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,.25);
  transform: scale(.9);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1);
}
.ph-modal-overlay.ph-show .ph-modal { transform: scale(1); }
.ph-modal-emoji  { font-size: 3.5rem; margin-bottom: 10px; display: block; }
.ph-modal-title  { font-size: 1.4rem; font-weight: 700; margin-bottom: 8px; display: block; }
.ph-modal-sub    { font-size: .88rem; color: #64748b; margin-bottom: 20px; line-height: 1.6; display: block; }
.ph-modal-canvas {
  width: 100%;
  aspect-ratio: 10 / 7;
  border-radius: 10px;
  border: 1px solid var(--ph-line);
  margin-bottom: 20px;
  display: block;
}
.ph-modal-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- レスポンシブ ---------- */
@media (max-width: 900px) {
  .ph-main { flex-direction: column; }
  .ph-sidebar,
  .ph-sidebar-right {
    width: 100%;
    border-right: none;
    border-left: none;
    border-bottom: 1px solid var(--ph-line);
  }
  .ph-palette { grid-template-columns: repeat(6, 1fr); }
  .ph-swatch-circle { width: 38px; height: 38px; }
}
