/* ==== フォント基本 ==== */
* {
  font-family: 'Noto Sans JP', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  letter-spacing: 0.04em;
}
code, pre, .font-mono, .prompt-output {
  font-family: 'JetBrains Mono', 'Menlo', monospace;
  letter-spacing: 0;
}
html, body {
  font-size: 17px;
  line-height: 1.85;
  color: #1e293b;
}

/* ==== 工程の色 ==== */
:root {
  --p-input:    #0284c7;
  --p-process:  #7c3aed;
  --p-output:   #059669;
  --p-notify:   #d97706;
  --p-schedule: #e11d48;
  --p-setup:    #475569;
  --warning:    #b45309;
  --warning-bg: #fef3c7;
}
.phase-input    { --phase-color: var(--p-input); }
.phase-process  { --phase-color: var(--p-process); }
.phase-output   { --phase-color: var(--p-output); }
.phase-notify   { --phase-color: var(--p-notify); }
.phase-schedule { --phase-color: var(--p-schedule); }
.phase-setup    { --phase-color: var(--p-setup); }

/* ==== ヘッダー ==== */
.site-header {
  border-bottom: 1px solid #e2e8f0;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 50;
}
.app-header {
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}
.header-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  color: inherit;
}
.header-logo {
  width: 48px;
  height: 48px;
  border-radius: 14px;
  background: linear-gradient(135deg, #06b6d4, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: white;
  font-size: 1.25rem;
}
.header-title h1 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
  line-height: 1.3;
}
.header-title p {
  font-size: 0.82rem;
  color: #64748b;
  margin: 2px 0 0 0;
  line-height: 1.4;
}
.header-nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.header-sep {
  width: 1px;
  height: 24px;
  background: #e2e8f0;
  margin: 0 4px;
}

/* ==== ボタン共通 ==== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  font-size: 0.9rem;
  font-weight: 700;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all 0.12s ease;
  text-decoration: none;
  line-height: 1.3;
  letter-spacing: 0.05em;
  white-space: nowrap;
}
.btn-dark {
  background: #0f172a;
  color: white;
}
.btn-dark:hover { background: #1e293b; }
.btn-primary {
  background: linear-gradient(135deg, #f97316, #ec4899);
  color: white;
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.25);
}
.btn-ghost {
  color: #334155;
  border-color: #e2e8f0;
  background: white;
}
.btn-ghost:hover { background: #f1f5f9; }
.btn-outline {
  color: #334155;
  border-color: #e2e8f0;
  background: white;
}
.btn-outline:hover { background: #f1f5f9; border-color: #cbd5e1; }
.btn-link {
  background: transparent;
  border: none;
  color: #64748b;
  padding: 6px 8px;
}
.btn-link:hover { color: #0f172a; }
.btn-copilot {
  background: #0f172a;
  color: white;
  padding: 14px 26px;
  font-size: 0.95rem;
}
.btn-copilot:hover { background: #1e293b; }
.btn-copilot:disabled { opacity: 0.6; cursor: not-allowed; }

/* ==== 全体レイアウト ==== */
.app-layout {
  max-width: 1440px;
  margin: 0 auto;
  padding: 28px 32px 60px;
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 32px;
}

/* ==== パレット ==== */
.palette-aside {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 28px 24px;
  height: calc(100vh - 180px);
  position: sticky;
  top: 120px;
  display: flex;
  flex-direction: column;
}
.palette-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 16px;
}
.palette-heading h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}
.count-badge {
  font-size: 0.78rem;
  color: #64748b;
  font-weight: 600;
}
.count-badge.large {
  font-size: 0.92rem;
  background: #f1f5f9;
  padding: 8px 14px;
  border-radius: 999px;
}
.search-input {
  width: 100%;
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 0.95rem;
  margin-bottom: 20px;
  transition: all 0.12s;
}
.search-input:focus {
  outline: none;
  border-color: #f97316;
  background: white;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: #94a3b8;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.phase-pill, .palette-cat-pill {
  cursor: pointer;
  padding: 7px 14px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
  background: #f8fafc;
  color: #334155;
  border: 2px solid #e2e8f0;
  transition: all 0.12s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  line-height: 1.3;
}
.phase-pill:hover {
  border-color: var(--phase-color, #64748b);
  color: var(--phase-color, #64748b);
}
.phase-pill.active {
  background: var(--phase-color, #0ea5e9);
  color: white;
  border-color: var(--phase-color, #0ea5e9);
}
.phase-pill .ct {
  font-size: 0.72rem;
  padding: 0 8px;
  background: rgba(0,0,0,0.06);
  border-radius: 999px;
}
.phase-pill.active .ct {
  background: rgba(255,255,255,0.28);
}
.palette-cat-pill.active {
  background: #0f172a;
  color: white;
  border-color: #0f172a;
}
.palette-cat-pill:hover:not(.active) {
  background: #e2e8f0;
}

.palette-list {
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#palette::-webkit-scrollbar { width: 8px; }
#palette::-webkit-scrollbar-track { background: transparent; }
#palette::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
#palette::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ==== パレットチップ ==== */
.palette-chip {
  background: white;
  color: #0f172a;
  border-radius: 14px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all 0.12s;
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  gap: 10px;
  user-select: none;
  border: 2px solid #e2e8f0;
  border-left: 6px solid var(--phase-color, #64748b);
  text-align: left;
  width: 100%;
  line-height: 1.45;
}
.palette-chip:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.06);
  border-color: var(--phase-color, #64748b);
  border-left-color: var(--phase-color, #64748b);
}
.palette-chip .chip-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.palette-chip .chip-verb {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: white;
  background: var(--phase-color, #64748b);
  padding: 3px 10px;
  border-radius: 999px;
  flex-shrink: 0;
}
.palette-chip .chip-title {
  font-weight: 700;
  font-size: 0.96rem;
  color: #0f172a;
  flex: 1;
  min-width: 140px;
  line-height: 1.45;
}
.palette-chip .chip-lvl {
  font-size: 0.7rem;
  background: #f1f5f9;
  color: #475569;
  padding: 3px 9px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.palette-chip .chip-io {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.78rem;
  color: #64748b;
  flex-wrap: wrap;
}
.palette-chip .io-pill {
  background: #f1f5f9;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 600;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.palette-chip .io-arrow { color: #94a3b8; font-weight: 800; }
.palette-chip .chip-warn {
  background: var(--warning-bg);
  color: var(--warning);
  font-size: 0.72rem;
  padding: 2px 9px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* ==== ワークスペース ==== */
.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* AI コパイロット */
.copilot-panel {
  background: linear-gradient(135deg, #4338ca, #7c3aed, #db2777);
  color: white;
  border-radius: 24px;
  padding: 36px 40px;
  box-shadow: 0 10px 30px rgba(124, 58, 237, 0.25);
}
.copilot-heading {
  margin-bottom: 22px;
}
.copilot-label {
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: rgba(255,255,255,0.85);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.copilot-heading h2 {
  font-size: 1.4rem;
  font-weight: 900;
  margin: 0;
  line-height: 1.5;
}
.copilot-heading p {
  font-size: 0.92rem;
  color: rgba(255,255,255,0.8);
  margin: 12px 0 0 0;
  line-height: 1.7;
}
.copilot-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.copilot-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.97);
  color: #0f172a;
  border: none;
  border-radius: 12px;
  padding: 15px 20px;
  font-size: 1rem;
  min-width: 240px;
}
.copilot-input:focus {
  outline: 3px solid rgba(255,255,255,0.4);
}
.copilot-status {
  margin-top: 16px;
  font-size: 0.95rem;
  background: rgba(255,255,255,0.14);
  border-radius: 12px;
  padding: 14px 18px;
  line-height: 1.7;
}
.copilot-result {
  margin-top: 18px;
  background: white;
  color: #1e293b;
  border-radius: 18px;
  padding: 28px 30px;
}

/* セクションカード */
.section-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 24px;
  padding: 36px 40px;
}
.section-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 24px;
}
.section-head h2 {
  font-size: 1.25rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
  line-height: 1.4;
}
.section-head p {
  font-size: 0.88rem;
  color: #64748b;
  margin: 8px 0 0 0;
  line-height: 1.65;
}

/* テンプレート */
.templates-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}
.tpl-card {
  background: #f8fafc;
  border: 2px solid #e2e8f0;
  border-radius: 16px;
  padding: 22px 22px;
  cursor: pointer;
  transition: all 0.12s;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.tpl-card:hover {
  border-color: #f97316;
  background: white;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(249, 115, 22, 0.1);
}
.tpl-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}
.tpl-title {
  font-weight: 800;
  font-size: 1rem;
  color: #0f172a;
  line-height: 1.5;
  flex: 1;
}
.tpl-lvl {
  font-size: 0.7rem;
  background: white;
  color: #64748b;
  border: 1px solid #e2e8f0;
  padding: 3px 10px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.08em;
  white-space: nowrap;
}
.tpl-desc {
  font-size: 0.84rem;
  color: #475569;
  line-height: 1.7;
}
.tpl-count {
  font-size: 0.76rem;
  color: #94a3b8;
  font-weight: 600;
  letter-spacing: 0.05em;
}

/* ゴール入力 */
.goal-box {
  margin-bottom: 28px;
  padding: 22px 24px;
  background: #fffbeb;
  border: 2px solid #fde68a;
  border-radius: 14px;
}
.goal-box label {
  display: block;
  font-size: 0.78rem;
  font-weight: 800;
  color: #92400e;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.goal-box input {
  width: 100%;
  background: white;
  border: 1px solid #fde68a;
  border-radius: 10px;
  padding: 12px 16px;
  font-size: 0.95rem;
  line-height: 1.6;
}
.goal-box input:focus {
  outline: none;
  border-color: #f59e0b;
}

/* ワークスペース */
.workspace {
  min-height: 280px;
  position: relative;
}
.empty-state {
  text-align: center;
  padding: 72px 24px;
  color: #94a3b8;
}
.empty-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #64748b;
  margin-bottom: 14px;
  letter-spacing: 0.04em;
}
.empty-state p {
  font-size: 0.92rem;
  line-height: 1.85;
}

#block-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0;
}

/* ブロック本体 */
.block {
  background: var(--phase-color, #64748b);
  color: white;
  padding: 24px 30px;
  border-radius: 14px;
  width: 100%;
  max-width: 860px;
  position: relative;
  box-shadow: 0 4px 0 rgba(0,0,0,0.18), 0 0 0 2px rgba(0,0,0,0.12);
  margin-bottom: 8px;
}
.block-header {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.block-step-no {
  background: rgba(0,0,0,0.25);
  color: white;
  font-weight: 800;
  border-radius: 999px;
  min-width: 32px;
  height: 32px;
  padding: 0 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.88rem;
  flex-shrink: 0;
}
.block-verb {
  background: rgba(255,255,255,0.22);
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  flex-shrink: 0;
}
.block-title {
  font-weight: 800;
  font-size: 1.1rem;
  flex: 1;
  line-height: 1.55;
  min-width: 0;
  letter-spacing: 0.04em;
}
.block-lvl-badge {
  font-size: 0.72rem;
  background: rgba(0,0,0,0.28);
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: 0.1em;
  flex-shrink: 0;
}
.block-warn-badge {
  font-size: 0.68rem;
  background: var(--warning-bg);
  color: var(--warning);
  padding: 4px 11px;
  border-radius: 999px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  flex-shrink: 0;
}
.block-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}
.block-btn {
  background: rgba(0,0,0,0.22);
  color: white;
  border: none;
  border-radius: 8px;
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  transition: background 0.12s;
}
.block-btn:hover { background: rgba(0,0,0,0.4); }
.block-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.block-summary {
  margin-top: 14px;
  font-size: 0.92rem;
  line-height: 1.85;
  color: rgba(255,255,255,0.96);
  background: rgba(0,0,0,0.14);
  padding: 14px 18px;
  border-radius: 10px;
}
.block-io {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 0.8rem;
  align-items: center;
  line-height: 1.4;
}
.block-io-pill {
  background: rgba(255,255,255,0.2);
  padding: 3px 12px;
  border-radius: 999px;
  font-weight: 700;
}
.block-io-arrow { opacity: 0.65; font-weight: 900; }

.block-warning-note {
  margin-top: 12px;
  background: var(--warning-bg);
  color: var(--warning);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.82rem;
  font-weight: 600;
  line-height: 1.7;
}

/* ブロック間矢印 */
.step-arrow {
  align-self: center;
  color: #cbd5e1;
  font-size: 1.1rem;
  margin: 2px 0 6px 0;
  max-width: 860px;
  width: 100%;
  text-align: center;
  letter-spacing: 0.1em;
  font-weight: 600;
}

.stack-end {
  text-align: center;
  padding: 30px 0;
  color: #94a3b8;
}
.stack-end-mark {
  font-size: 0.78rem;
  font-weight: 800;
  color: #10b981;
  letter-spacing: 0.25em;
  margin-bottom: 6px;
}
.stack-end p {
  font-size: 0.88rem;
}

/* AI結果 */
.ai-step-card {
  display: flex;
  align-items: start;
  gap: 14px;
  padding: 14px 18px;
  background: #f8fafc;
  border-left: 4px solid var(--phase-color, #64748b);
  border-radius: 10px;
  margin-bottom: 8px;
}
.ai-step-card .num {
  font-weight: 800;
  color: var(--phase-color, #64748b);
  min-width: 26px;
  font-size: 1rem;
}
.ai-step-card .body {
  flex: 1;
  font-size: 0.92rem;
  line-height: 1.75;
}
.ai-step-card .body strong {
  color: #0f172a;
  font-weight: 800;
}
.ai-step-card .reason {
  color: #64748b;
  margin-top: 4px;
  font-size: 0.82rem;
  line-height: 1.7;
}

/* モーダル */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-card {
  background: white;
  border-radius: 20px;
  max-width: 960px;
  width: 100%;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,0.3);
}
.modal-header {
  padding: 22px 28px;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  color: #0f172a;
  margin: 0;
}
.modal-header p {
  font-size: 0.82rem;
  color: #64748b;
  margin: 4px 0 0 0;
  line-height: 1.6;
}
.modal-actions {
  display: flex;
  gap: 10px;
}
.modal-body {
  padding: 22px 28px;
  overflow-y: auto;
  flex: 1;
}

.prompt-output {
  background: #0f172a;
  color: #e2e8f0;
  border-radius: 12px;
  padding: 24px;
  font-size: 13.5px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  letter-spacing: 0;
}
.prompt-output::-webkit-scrollbar { width: 10px; }
.prompt-output::-webkit-scrollbar-track { background: #1e293b; border-radius: 5px; }
.prompt-output::-webkit-scrollbar-thumb { background: #475569; border-radius: 5px; }

/* トースト */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #0f172a;
  color: white;
  padding: 14px 22px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.25);
  transform: translateY(90px);
  opacity: 0;
  transition: all 0.25s;
  pointer-events: none;
  font-size: 0.92rem;
  font-weight: 600;
  z-index: 200;
  max-width: 480px;
}
.toast.toast-show {
  transform: translateY(0);
  opacity: 1;
}

/* スピナー */
.spin {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,0.4);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* レスポンシブ */
@media (max-width: 1100px) {
  .app-layout {
    grid-template-columns: 1fr;
    padding: 20px;
    gap: 24px;
  }
  .palette-aside {
    position: static;
    height: auto;
    max-height: 640px;
  }
  .section-card, .copilot-panel {
    padding: 26px 22px;
  }
  .app-header {
    padding: 16px 20px;
  }
}
@media (max-width: 640px) {
  html, body { font-size: 16px; }
  .copilot-heading h2 { font-size: 1.15rem; }
  .section-head h2 { font-size: 1.1rem; }
  .block-title { font-size: 1rem; }
}
