/* ============================================================
   LP Forge — アプリシェル デザインシステム
   中立・清潔・キャンバス主役。単一アクセント(インディゴ)。
   ============================================================ */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --ink: #17181c;
  --muted: #676e79;
  --line: #e4e6ea;
  --line-strong: #d3d6dc;
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --ai-from: #6d5df6;
  --ai-to: #a855f7;
  --danger: #dc2626;
  --ok: #16a34a;
  --radius: 10px;
  --shadow-sm: 0 1px 2px rgba(20, 22, 26, 0.06);
  --shadow-md: 0 6px 24px rgba(20, 22, 26, 0.1);
  --font: "Inter", "Hiragino Sans", "Yu Gothic UI", "Noto Sans JP", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; }
h1, h2, h3 { margin: 0; font-weight: 800; }
[hidden] { display: none !important; }

/* ---------- 汎用UI ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 38px; padding: 0.45rem 1.05rem;
  border: 1px solid transparent; border-radius: var(--radius);
  font-size: 0.92rem; font-weight: 700; cursor: pointer;
  transition: filter 0.12s ease, transform 0.12s ease, background 0.12s ease;
  white-space: nowrap;
}
.btn:hover { filter: brightness(1.04); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn-primary { background: var(--ink); color: #fff; }
.btn-ghost { background: var(--surface); border-color: var(--line-strong); color: var(--ink); }
.btn-danger { background: #fff2f2; border-color: #f3c1c1; color: var(--danger); }
.btn-ai {
  background: linear-gradient(120deg, var(--ai-from), var(--ai-to));
  color: #fff;
  box-shadow: 0 4px 16px rgba(109, 93, 246, 0.35);
}
.btn-lg { min-height: 46px; font-size: 1rem; padding: 0.6rem 1.5rem; }
.btn-block { width: 100%; }
.ai-spark { font-size: 1.05em; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px;
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--muted);
  font-size: 1rem; cursor: pointer;
}
.icon-btn:hover { background: var(--bg); color: var(--ink); }

.link-btn {
  border: none; background: none; color: var(--accent);
  font-size: 0.9rem; font-weight: 700; cursor: pointer; padding: 0.4rem 0;
}
.link-btn:hover { text-decoration: underline; }

.field-label { display: block; font-size: 0.8rem; font-weight: 700; color: var(--muted); margin: 0.8rem 0 0.3rem; }
.field-input {
  width: 100%;
  border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--ink);
  padding: 0.5rem 0.7rem; font-size: 0.92rem; font-family: inherit;
}
.field-input:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea.field-input { resize: vertical; }

/* ---------- トースト ---------- */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  z-index: 200;
  background: var(--ink); color: #fff;
  border-radius: 999px; padding: 0.6rem 1.3rem;
  font-size: 0.9rem; font-weight: 700;
  box-shadow: var(--shadow-md);
  animation: toast-in 0.2s ease;
}
@keyframes toast-in { from { opacity: 0; transform: translate(-50%, 8px); } }

/* ============================================================
   ログイン
   ============================================================ */
.auth {
  min-height: 100vh; display: grid; place-items: center;
  background:
    radial-gradient(ellipse 60% 40% at 20% 0%, rgba(109, 93, 246, 0.08), transparent),
    radial-gradient(ellipse 50% 40% at 90% 100%, rgba(168, 85, 247, 0.07), transparent),
    var(--bg);
  padding: 1.5rem;
}
.auth-card {
  width: min(420px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow-md);
  padding: 2rem 1.8rem;
}
.auth-title { font-size: 1.15rem; text-align: center; margin: 1.2rem 0 1.4rem; }
.auth-social { display: grid; gap: 0.6rem; }
.auth-divider {
  display: flex; align-items: center; gap: 0.8rem; margin: 1.1rem 0 0.2rem;
  color: var(--muted); font-size: 0.76rem; font-weight: 700;
}
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.auth-error { color: var(--danger); font-size: 0.82rem; min-height: 1.2em; margin: 0.6rem 0 0.2rem; }
#authSubmitBtn { margin-top: 0.4rem; }
#authModeBtn { display: block; margin: 0.6rem auto 0; }
.account-chip { display: flex; align-items: center; gap: 0.5rem; font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.account-chip span { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============================================================
   ホーム
   ============================================================ */
.home { min-height: 100%; display: flex; flex-direction: column; }
.home-bar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.6rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 0.7rem; }
.brand-mark {
  display: grid; place-items: center;
  width: 38px; height: 38px; border-radius: 10px;
  background: linear-gradient(135deg, var(--ai-from), var(--ai-to));
  color: #fff; font-weight: 900; font-size: 0.85rem; letter-spacing: 0.02em;
}
.brand strong { display: block; font-size: 1.05rem; line-height: 1.2; }
.brand-sub { font-size: 0.74rem; color: var(--muted); font-weight: 600; }

.home-main { flex: 1; width: min(1200px, calc(100% - 48px)); margin: 0 auto; padding: 2rem 0 4rem; }
.home-heading { font-size: 1.05rem; margin-bottom: 1rem; color: var(--ink); }

.empty-state { text-align: center; padding: 9vh 1rem 4rem; }
.empty-state-art { font-size: 3rem; margin-bottom: 1rem; }
.empty-state h1 { font-size: 1.9rem; margin-bottom: 0.8rem; }
.empty-state p { color: var(--muted); margin: 0 0 1.8rem; font-size: 1rem; }

.project-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.1rem;
}
.project-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
  cursor: pointer;
  transition: box-shadow 0.15s ease, transform 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.project-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }
.project-thumb {
  position: relative; height: 160px; overflow: hidden;
  background: #101014;
  pointer-events: none;
}
.project-thumb iframe {
  width: 1080px; height: 640px;
  transform: scale(0.2315); transform-origin: 0 0;
  border: 0; pointer-events: none;
}
.project-thumb-blank {
  display: grid; place-items: center; height: 100%;
  color: #6b7280; font-size: 0.85rem; font-weight: 700;
}
.project-meta { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.8rem 1rem; }
.project-meta-name { font-weight: 800; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-meta-sub { color: var(--muted); font-size: 0.76rem; margin-top: 0.1rem; display: flex; gap: 0.5rem; align-items: center; }
.badge-live { color: var(--ok); font-weight: 800; }
.card-actions { display: flex; gap: 0.15rem; }
.card-actions .icon-btn { width: 30px; height: 30px; font-size: 0.9rem; }

/* ============================================================
   モーダル / ドロワー
   ============================================================ */
.modal-backdrop, .drawer-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(15, 17, 22, 0.45);
  display: flex; align-items: center; justify-content: center;
  padding: 1.5rem;
}
.drawer-backdrop { justify-content: flex-end; padding: 0; }
.modal {
  width: min(640px, 100%);
  max-height: calc(100vh - 3rem);
  overflow: auto;
  background: var(--surface);
  border-radius: 16px;
  padding: 1.5rem 1.6rem 1.7rem;
  box-shadow: var(--shadow-md);
}
.drawer {
  width: min(420px, 100vw);
  height: 100%;
  overflow: auto;
  background: var(--surface);
  padding: 1.4rem 1.5rem 2rem;
  box-shadow: -12px 0 40px rgba(15, 17, 22, 0.18);
  animation: drawer-in 0.22s ease;
}
@keyframes drawer-in { from { transform: translateX(30px); opacity: 0; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.modal-head h2 { font-size: 1.15rem; }
.modal-sub { color: var(--muted); font-size: 0.88rem; margin: 0.5rem 0 1.2rem; }

/* おまかせウィザード */
.wiz-hero {
  display: flex; align-items: center; gap: 0.9rem; width: 100%;
  border: none; border-radius: 14px; cursor: pointer;
  background: linear-gradient(120deg, var(--ai-from), var(--ai-to));
  color: #fff; padding: 1.1rem 1.2rem; text-align: left;
  box-shadow: 0 8px 24px rgba(109, 93, 246, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.wiz-hero:hover { transform: translateY(-2px); box-shadow: 0 12px 30px rgba(109, 93, 246, 0.45); }
.wiz-hero-icon { font-size: 1.7rem; }
.wiz-hero-body { flex: 1; display: flex; flex-direction: column; gap: 0.1rem; }
.wiz-hero-body strong { font-size: 1.1rem; }
.wiz-hero-body span { font-size: 0.8rem; opacity: 0.9; }
.wiz-hero-arrow { font-size: 1.2rem; font-weight: 900; }

.wizard { max-width: 560px; }
.wiz-dots { display: flex; gap: 0.4rem; }
.wiz-dots i { width: 26px; height: 5px; border-radius: 3px; background: var(--line); }
.wiz-dots i.is-on { background: var(--accent); }
.wiz-q { font-size: 1.35rem; margin: 1.2rem 0 1rem; }
.wiz-big { font-size: 1.1rem; padding: 0.85rem 1rem; border-radius: 12px; }
.wiz-genres { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-top: 0.9rem; }
.wiz-genre {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  padding: 0.7rem 0.3rem; cursor: pointer; font-size: 0.82rem; font-weight: 700; color: var(--ink);
}
.wiz-genre span:first-child { font-size: 1.4rem; }
.wiz-genre.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.wiz-nav { display: flex; align-items: center; justify-content: flex-end; gap: 1rem; margin-top: 1.4rem; }
.wiz-themes { grid-template-columns: 1fr 1fr; }
.wiz-themes .theme-chip { padding: 0.75rem 0.8rem; }
@media (max-width: 640px) {
  .wiz-genres { grid-template-columns: repeat(2, 1fr); }
}

.preset-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.8rem; margin-bottom: 1rem; max-height: 46vh; overflow-y: auto; padding-right: 0.3rem; }
.preset-group-head { grid-column: 1 / -1; font-size: 0.78rem; color: var(--muted); margin: 0.4rem 0 -0.2rem; font-weight: 800; letter-spacing: 0.04em; }
.wiz-group-head { grid-column: 1 / -1; font-size: 0.74rem; color: var(--muted); font-weight: 800; margin-top: 0.4rem; }
.wiz-genre-more { border-style: dashed; color: var(--accent); }
.wiz-genres { max-height: 40vh; overflow-y: auto; }
.preset-card {
  display: flex; flex-direction: column; gap: 0.35rem;
  border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface);
  padding: 1rem 1.1rem;
  text-align: left; cursor: pointer;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.preset-card:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.preset-card-head { display: flex; align-items: center; gap: 0.55rem; font-weight: 800; font-size: 0.98rem; }
.preset-card-icon { font-size: 1.25rem; }
.preset-card p { margin: 0; color: var(--muted); font-size: 0.8rem; }
.preset-swatch { display: flex; gap: 4px; margin-top: 0.3rem; }
.preset-swatch i { width: 16px; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.08); }

/* ============================================================
   スタジオ
   ============================================================ */
.studio { display: flex; flex-direction: column; height: 100vh; }
.studio-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  height: 56px; padding: 0 0.9rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.studio-bar-left { display: flex; align-items: center; gap: 0.5rem; min-width: 0; flex: 1; }
.project-name {
  border: 1px solid transparent; border-radius: 8px;
  background: transparent; color: var(--ink);
  font-size: 0.98rem; font-weight: 800; font-family: inherit;
  padding: 0.35rem 0.55rem; width: min(260px, 40vw);
}
.project-name:hover { border-color: var(--line-strong); }
.project-name:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.save-state { color: var(--muted); font-size: 0.76rem; font-weight: 700; white-space: nowrap; }
.save-state.is-busy { color: var(--accent); }

.studio-bar-center { display: flex; align-items: center; gap: 0.6rem; }
.seg { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.seg-btn {
  border: none; background: transparent; color: var(--muted);
  min-width: 44px; padding: 0.3rem 0.7rem; border-radius: 7px;
  font-size: 0.84rem; font-weight: 700; cursor: pointer;
}
.seg-btn:hover { color: var(--ink); }
.seg-btn.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }

.studio-bar-right { display: flex; align-items: center; gap: 0.55rem; flex: 1; justify-content: flex-end; }

.studio-body { display: flex; flex: 1; min-height: 0; }

/* ---------- レール ---------- */
.rail {
  width: 272px; flex-shrink: 0;
  background: var(--surface);
  display: flex; flex-direction: column;
  min-height: 0;
}
.rail-left { border-right: 1px solid var(--line); }
.rail-right { width: 296px; border-left: 1px solid var(--line); }
.rail-tabs { display: flex; border-bottom: 1px solid var(--line); flex-shrink: 0; }
.rail-tab {
  flex: 1; border: none; background: none; cursor: pointer;
  padding: 0.7rem 0.4rem; font-size: 0.86rem; font-weight: 700; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.rail-tab.is-active { color: var(--ink); border-bottom-color: var(--accent); }
.rail-pane { flex: 1; overflow-y: auto; padding: 0.9rem; min-height: 0; }
.rail-hint { color: var(--muted); font-size: 0.76rem; margin: 0 0 0.8rem; }
.rail-title { font-size: 0.85rem; margin: 1.1rem 0 0.5rem; }
.rail-pane .rail-title:first-child { margin-top: 0; }
.rail-note { color: var(--muted); font-size: 0.74rem; margin: 0.4rem 0 0; }

/* テーマチップ */
.theme-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; }
.theme-chip {
  display: flex; flex-direction: column; gap: 0.3rem;
  border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer;
  padding: 0.55rem 0.6rem; text-align: left;
}
.theme-chip:hover { border-color: var(--line-strong); }
.theme-chip.is-active { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.theme-chip-swatch { display: flex; gap: 3px; }
.theme-chip-swatch i { flex: 1; height: 16px; border-radius: 4px; border: 1px solid rgba(0,0,0,0.1); }
.theme-chip span { font-size: 0.76rem; font-weight: 700; }
.theme-chip small { font-size: 0.64rem; color: var(--muted); font-weight: 600; line-height: 1.3; }

/* 素材ライブラリ — サブタブ */
.lib-tabs { display: flex; gap: 0.25rem; margin-bottom: 0.6rem; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 3px; }
.lib-tab {
  flex: 1; border: none; background: transparent; color: var(--muted);
  padding: 0.35rem 0.2rem; border-radius: 7px;
  font-size: 0.78rem; font-weight: 700; cursor: pointer; white-space: nowrap;
}
.lib-tab:hover { color: var(--ink); }
.lib-tab.is-active { background: var(--surface); color: var(--ink); box-shadow: var(--shadow-sm); }
.lib-search { margin-bottom: 0.7rem; }

/* アイコングリッド */
.icon-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0.35rem; }
.icon-cell {
  display: grid; place-items: center; aspect-ratio: 1;
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); color: #3d4350; cursor: pointer;
  transition: border-color 0.12s ease, color 0.12s ease, box-shadow 0.12s ease;
}
.icon-cell:hover { border-color: var(--accent); color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* 図形グリッド */
.shape-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.45rem; margin-top: 0.7rem; }
.shape-cell {
  display: flex; flex-direction: column; align-items: center; gap: 0.25rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); color: #5a6170; cursor: pointer;
  padding: 0.55rem 0.3rem 0.45rem;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.shape-cell svg { width: 52px; height: 40px; }
.shape-cell span { font-size: 0.66rem; font-weight: 700; color: var(--muted); }
.shape-cell:hover { border-color: var(--accent); color: var(--accent); }

/* 写真グリッド */
.photo-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.45rem; }
.photo-cell {
  position: relative; border-radius: 8px; overflow: hidden;
  background: var(--bg); min-height: 70px;
}
.photo-cell img { width: 100%; height: 90px; object-fit: cover; display: block; }
.photo-cell-actions {
  position: absolute; inset: auto 0 0 0;
  display: flex; gap: 1px;
  opacity: 0; transition: opacity 0.12s ease;
  background: rgba(15, 17, 22, 0.72);
}
.photo-cell:hover .photo-cell-actions { opacity: 1; }
.photo-cell-actions button {
  flex: 1; border: none; background: transparent; color: #fff;
  font-size: 0.68rem; font-weight: 700; padding: 0.35rem 0; cursor: pointer;
}
.photo-cell-actions button:hover { background: rgba(255, 255, 255, 0.18); }
#photoMoreBtn { margin-top: 0.7rem; }

/* 動きグリッド + デモ用キーフレーム（出力側 base.css と同名定義のビルダー版） */
.anim-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 0.45rem; margin-bottom: 0.7rem; }
.anim-cell {
  display: flex; flex-direction: column; align-items: center; gap: 0.3rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); cursor: pointer; padding: 0.6rem 0.3rem 0.5rem;
}
.anim-cell:hover { border-color: var(--accent); }
.anim-cell span:last-child { font-size: 0.66rem; font-weight: 700; color: var(--muted); }
.anim-demo { font-size: 1.3rem; color: var(--accent); display: inline-block; }
@keyframes lpFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes lpPulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.15); } }
@keyframes lpBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }
@keyframes lpShake { 0%, 100% { transform: rotate(0); } 20% { transform: rotate(-8deg); } 60% { transform: rotate(8deg); } }
@keyframes lpSpin { to { transform: rotate(360deg); } }
@keyframes lpBounce { 0%, 100% { transform: translateY(0); } 40% { transform: translateY(-8px); } 60% { transform: translateY(-3px); } }
@keyframes lpFadeUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes lpZoomIn { from { opacity: 0; transform: scale(0.7); } to { opacity: 1; transform: scale(1); } }
.anim-demo.lp-anim-float { animation: lpFloat 2.4s ease-in-out infinite; }
.anim-demo.lp-anim-pulse { animation: lpPulse 1.4s ease-in-out infinite; }
.anim-demo.lp-anim-blink { animation: lpBlink 1.2s ease-in-out infinite; }
.anim-demo.lp-anim-shake { animation: lpShake 1s ease-in-out infinite; }
.anim-demo.lp-anim-spin { animation: lpSpin 4s linear infinite; }
.anim-demo.lp-anim-bounce { animation: lpBounce 1.4s ease-in-out infinite; }
.anim-demo.lp-anim-fadeup { animation: lpFadeUp 1.6s ease-out infinite; }
.anim-demo.lp-anim-zoomin { animation: lpZoomIn 1.6s ease-out infinite; }
.anim-demo.lp-anim-shine { animation: lpBlink 2s ease-in-out infinite; }

/* 素材ライブラリ */
.asset-grid { display: grid; gap: 0.7rem; margin-top: 0.8rem; }
.asset-card {
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  background: var(--surface);
}
.asset-thumb {
  height: 110px; background: repeating-conic-gradient(#f0f1f3 0 25%, #fff 0 50%) 0 0 / 16px 16px;
  display: grid; place-items: center; overflow: hidden;
}
.asset-thumb img { max-width: 100%; max-height: 110px; object-fit: contain; }
.asset-body { padding: 0.55rem 0.65rem 0.7rem; }
.asset-name {
  width: 100%; border: none; background: none; font: inherit; font-size: 0.8rem; font-weight: 700;
  color: var(--ink); padding: 0.1rem 0; border-bottom: 1px dashed transparent;
}
.asset-name:focus { outline: none; border-bottom-color: var(--accent); }
.asset-kinds { display: flex; gap: 0.25rem; margin: 0.35rem 0; flex-wrap: wrap; }
.asset-kind {
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--muted); font-size: 0.68rem; font-weight: 700; padding: 0.1rem 0.5rem; cursor: pointer;
}
.asset-kind.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.asset-actions { display: flex; gap: 0.3rem; margin-top: 0.4rem; }
.asset-actions .btn { min-height: 28px; font-size: 0.72rem; padding: 0.2rem 0.55rem; flex: 1; }
.asset-ai {
  display: flex; align-items: center; gap: 0.35rem;
  font-size: 0.72rem; font-weight: 700; color: var(--muted); cursor: pointer; margin-top: 0.45rem;
}
.asset-ai input { accent-color: var(--accent); margin: 0; }
.asset-empty { color: var(--muted); font-size: 0.78rem; text-align: center; padding: 1.2rem 0.5rem; }

/* 重ね配置 */
.place-row {
  display: flex; align-items: center; gap: 0.35rem;
  margin-bottom: 0.6rem; font-size: 0.72rem; font-weight: 700; color: var(--muted);
}
.place-btn {
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
  color: var(--muted); font-size: 0.7rem; font-weight: 700; padding: 0.18rem 0.6rem; cursor: pointer;
}
.place-btn.is-active { border-color: var(--accent); color: var(--accent); background: var(--accent-soft); }
.section-look { display: flex; flex-wrap: wrap; gap: 0.3rem; }
.overlay-actions { display: flex; gap: 0.4rem; }
.overlay-actions .btn { flex: 1; min-height: 30px; font-size: 0.78rem; }
.emoji-cell { font-size: 1.35rem; }
.ai-asset-box { border: 1px dashed var(--line-strong); border-radius: 10px; padding: 0.7rem 0.8rem; margin-top: 0.7rem; }
.ai-asset-box .btn { margin-top: 0.5rem; min-height: 34px; font-size: 0.82rem; }

/* 選択中パネル */
.selected-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.4rem; }
.edit-hint { color: var(--muted); font-size: 0.74rem; margin: 0 0 0.6rem; }
.rail-toggle { display: none; }
.selected-label { font-weight: 800; font-size: 0.9rem; color: var(--accent); }
.link-field { margin-bottom: 0.6rem; }
#deleteElBtn { margin-top: 1rem; }

/* ブリーフフォーム */
.brief-group { margin-bottom: 1.2rem; }
.brief-group > h3 {
  font-size: 0.8rem; color: var(--ink);
  padding-bottom: 0.35rem; margin-bottom: 0.2rem;
  border-bottom: 1px solid var(--line);
}
.brief-group .field-label { margin-top: 0.6rem; }
#rebuildBtn { margin-top: 0.4rem; }

.range-row { display: flex; align-items: center; gap: 0.6rem; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); }
.range-row output { font-size: 0.8rem; font-weight: 800; color: var(--accent); min-width: 2.2em; text-align: right; }

/* ---------- キャンバス ---------- */
.canvas-area {
  flex: 1; min-width: 0;
  background:
    radial-gradient(circle at 1px 1px, rgba(23,24,28,0.06) 1px, transparent 0) 0 0 / 22px 22px,
    var(--bg);
  padding: 0;
  display: flex;
}
.canvas-frame { flex: 1; position: relative; }
#gjs { height: 100%; }

/* ============================================================
   GrapesJS リスキン（自前レール内の .gjs-* を上書き）
   ============================================================ */
.gjs-one-bg { background-color: var(--surface); }
.gjs-two-color { color: var(--ink); }
.gjs-three-bg { background-color: var(--accent); color: #fff; }
.gjs-four-color, .gjs-four-color-h:hover { color: var(--accent); }

/* キャンバス（デフォルトのパネル余白を回収して全面化） */
.gjs-cv-canvas { background: transparent; width: 100%; height: 100%; top: 0; left: 0; }
.gjs-frame-wrapper { padding: 18px 18px 40px; }
.gjs-frame { border-radius: 6px; box-shadow: 0 2px 18px rgba(15,17,22,0.14); background: #fff; }
.gjs-toolbar { background-color: var(--accent); border-radius: 6px; }
.gjs-badge { background-color: var(--accent); border-radius: 5px; font-family: var(--font); }
.gjs-com-badge, .gjs-badge__name { font-size: 11px; }
.gjs-highlighter, .gjs-highlighter-sel { outline: 1.5px solid var(--accent) !important; }
.gjs-placeholder.horizontal { border-color: transparent var(--accent); }
.gjs-placeholder.vertical { border-color: var(--accent) transparent; }
.gjs-placeholder-int { background-color: var(--accent); }

/* ブロックパレット */
#blocks .gjs-blocks-c { display: grid; grid-template-columns: 1fr 1fr; gap: 0.5rem; padding: 0.1rem 0 0.8rem; }
#blocks .gjs-block-category { border: none; }
#blocks .gjs-block-category .gjs-title {
  background: none; border: none; padding: 0.7rem 0 0.35rem;
  font-size: 0.76rem; font-weight: 800; color: var(--muted);
  letter-spacing: 0.04em; font-family: var(--font);
}
#blocks .gjs-block-category .gjs-title i { display: none; }
#blocks .gjs-blocks-cs { background: none; }
#blocks .gjs-block {
  width: auto; min-height: 0; margin: 0; padding: 0.65rem 0.4rem 0.55rem;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface); box-shadow: none;
  display: flex; flex-direction: column; align-items: center; gap: 0.35rem;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
  font-family: var(--font);
}
#blocks .gjs-block:hover {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#blocks .gjs-block svg { width: 30px; height: 30px; fill: var(--muted); }
#blocks .gjs-block:hover svg { fill: var(--accent); }
#blocks .gjs-block-label { font-size: 0.72rem; font-weight: 700; color: var(--ink); line-height: 1.3; }
#blocks .gjs-block__media { margin-bottom: 0; }

/* レイヤー（構成） */
#layers .gjs-layer { font-family: var(--font); background: var(--surface); }
#layers .gjs-layer-title {
  background: var(--surface); border-bottom: 1px solid var(--line);
  padding: 0.45rem 0.5rem; font-size: 0.82rem; color: var(--ink);
}
#layers .gjs-layer.gjs-selected .gjs-layer-title { background: var(--accent-soft); color: var(--accent); }
#layers .gjs-layer-count, #layers .gjs-layer-move { color: var(--muted); }
#layers .gjs-layer-vis { color: var(--muted); }

/* スタイルマネージャ */
#styles .gjs-sm-sector { font-family: var(--font); }
#styles .gjs-sm-sector-title {
  background: none; border: none; border-top: 1px solid var(--line);
  padding: 0.65rem 0.2rem; font-size: 0.82rem; font-weight: 800; color: var(--ink);
}
#styles .gjs-sm-sector:first-child .gjs-sm-sector-title { border-top: none; }
#styles .gjs-sm-sector-caret { width: 14px; height: 14px; top: 1px; }
#styles .gjs-sm-properties { padding: 0.1rem 0.1rem 0.7rem; }
#styles .gjs-sm-property { padding: 0.25rem 0.15rem; }
#styles .gjs-sm-label { font-size: 0.76rem; color: var(--muted); font-weight: 700; margin-bottom: 3px; }
#styles .gjs-field {
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  color: var(--ink); font-size: 0.82rem;
}
#styles .gjs-field input, #styles .gjs-field select { color: var(--ink); }
#styles .gjs-radio-item { border-left: 1px solid var(--line); }
#styles .gjs-radio-item-label { color: var(--muted); font-size: 0.78rem; padding: 3px 2px; }
#styles input:checked + .gjs-radio-item-label { background: var(--accent-soft); color: var(--accent); }
#styles .gjs-sm-clear { color: var(--muted); }
#styles .gjs-field-arrows { color: var(--muted); }
#styles .gjs-field-color-picker { border-radius: 0 7px 7px 0; }

/* アセットモーダルなどGrapesJSモーダルの最低限の馴染ませ */
.gjs-mdl-dialog { font-family: var(--font); border-radius: 14px; }
.gjs-mdl-header { background: var(--surface); border-bottom: 1px solid var(--line); }
.gjs-mdl-title { color: var(--ink); font-weight: 800; }
.gjs-mdl-content { background: var(--surface); color: var(--ink); }
.gjs-am-assets-cont, .gjs-am-file-uploader > form { background: var(--bg); }
.gjs-btn-prim { background: var(--accent); border-radius: 8px; }

/* RTEツールバー */
.gjs-rte-toolbar { border-radius: 8px; border: 1px solid var(--line); box-shadow: var(--shadow-md); }
.gjs-rte-action { color: var(--ink); }

/* ============================================================
   AIドロワー
   ============================================================ */
.ai-mode { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem; margin: 0.4rem 0 0.4rem; }
.ai-mode-card {
  display: block; cursor: pointer; position: relative;
  border: 1.5px solid var(--line); border-radius: 10px;
  padding: 0.7rem 0.8rem;
}
.ai-mode-card input { position: absolute; opacity: 0; }
.ai-mode-card strong { display: block; font-size: 0.88rem; }
.ai-mode-card span { color: var(--muted); font-size: 0.74rem; }
.ai-mode-card:has(input:checked) { border-color: var(--ai-from); box-shadow: 0 0 0 3px rgba(109, 93, 246, 0.14); }
#aiStartBtn { margin-top: 1.1rem; }

.ai-status {
  margin-top: 1.2rem; border: 1px solid var(--line); border-radius: 12px;
  padding: 1rem 1.1rem; background: var(--bg);
}
.ai-status-row { display: flex; align-items: center; gap: 0.55rem; font-size: 0.92rem; }
.ai-dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--muted); flex-shrink: 0;
}
.ai-dot.is-working { background: var(--ai-from); animation: pulse 1.2s ease infinite; }
.ai-dot.is-done { background: var(--ok); }
.ai-dot.is-failed { background: var(--danger); }
@keyframes pulse { 50% { opacity: 0.35; } }
.ai-progress {
  height: 4px; border-radius: 4px; background: var(--line);
  margin-top: 0.7rem; overflow: hidden;
}
.ai-progress span {
  display: block; height: 100%; width: 40%;
  background: linear-gradient(90deg, var(--ai-from), var(--ai-to));
  border-radius: 4px;
  animation: slide 1.4s ease-in-out infinite;
}
.ai-progress.is-idle span { animation: none; width: 0; }
.ai-progress.is-done span { animation: none; width: 100%; }
@keyframes slide { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
.ai-bridge-hint { color: var(--muted); font-size: 0.78rem; margin: 0.6rem 0 0; }
.ai-bridge-hint code { background: var(--line); border-radius: 4px; padding: 0.1rem 0.35rem; }
.ai-details { margin-top: 0.7rem; }
.ai-details summary { color: var(--muted); font-size: 0.76rem; cursor: pointer; }
.ai-details p { color: var(--muted); font-size: 0.74rem; word-break: break-all; margin: 0.4rem 0 0; }

/* ============================================================
   公開モーダル
   ============================================================ */
.publish-section { border-top: 1px solid var(--line); padding: 1.1rem 0 1.2rem; margin-top: 0.6rem; }
.publish-section:first-of-type { border-top: none; }
.publish-section h3 { font-size: 0.95rem; margin-bottom: 0.2rem; }
.publish-section .btn { margin-top: 0.7rem; }
.slug-row { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.6rem; }
.slug-prefix { color: var(--muted); font-size: 0.82rem; font-weight: 700; white-space: nowrap; }
.published-box {
  margin-top: 0.9rem; border: 1px solid #bfe3cd; background: #f0faf4;
  border-radius: 10px; padding: 0.8rem 0.9rem;
}
.published-box a { color: var(--ok); font-weight: 800; font-size: 0.88rem; word-break: break-all; }
.published-actions { display: flex; gap: 0.5rem; margin-top: 0.6rem; }
.published-actions .btn { margin-top: 0; min-height: 32px; font-size: 0.8rem; }
.publish-msg { color: var(--muted); font-size: 0.8rem; margin: 0.6rem 0 0; min-height: 1.2em; }

/* ============================================================
   レスポンシブ（ビルダー自体）
   ============================================================ */
.mobile-style-chip {
  display: none; position: fixed; right: 14px; bottom: 18px; z-index: 55;
  border-radius: 999px; box-shadow: var(--shadow-md); min-height: 44px;
}
@media (max-width: 1080px) {
  .rail-right {
    position: fixed; right: 0; top: 56px; bottom: 0; z-index: 60;
    width: min(320px, 88vw);
    transform: translateX(105%); transition: transform 0.2s ease;
    box-shadow: var(--shadow-md);
  }
  .rail-right.is-open { transform: none; }
  .mobile-style-chip { display: inline-flex; }
}
@media (max-width: 860px) {
  .studio-bar { flex-wrap: wrap; height: auto; padding: 0.5rem 0.7rem; row-gap: 0.4rem; }
  .studio-bar-center { order: 3; width: 100%; justify-content: center; }
  .rail-toggle { display: inline-flex; }
  .rail-left { position: fixed; left: 0; top: 0; bottom: 0; z-index: 60; transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow-md); width: min(320px, 86vw); }
  .rail-left.is-open { transform: none; }
  .preset-grid { grid-template-columns: 1fr; }
  .home-main { width: calc(100% - 28px); }
}
