/* =========================================
   ツール共通CSS
   tool-base.css
========================================= */


/* =========================================
   基本
========================================= */
* {
  box-sizing: border-box;
}

:root {
  --blue: #2563eb;
  --blue-dark: #1d4ed8;
  --navy: #0f172a;
  --text: #334155;
  --border: #dbe3ef;
  --bg: #f5f8fc;
  --panel: #ffffff;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}


/* =========================================
   ツール全体
========================================= */
.tool-generator {
  width: min(1500px, 96%);
  margin: 30px auto;
}


/* =========================================
   ツールタイトル
========================================= */
.tool-title {
  margin: 0 0 24px;
  color: var(--navy);
  font-size: 30px;
}


/* =========================================
   ツールレイアウト
========================================= */
.tool-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 24px;
  align-items: start;
}

.settings-panel,
.preview-panel,
.code-panel {
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
}


/* =========================================
   設定パネル
========================================= */
.settings-panel {
  position: sticky;
  top: 20px;
  max-height: calc(100vh - 40px);
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
}


/* =========================================
   設定セクション
========================================= */
.setting-section {
  margin: 0 0 22px;
  padding: 0 0 22px;
  border-bottom: 1px solid #e5e7eb;
}

.setting-section:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: 0;
}

.setting-section h2 {
  margin: 0 0 16px;
  padding: 8px 10px;
  border-left: 4px solid var(--blue);
  border-radius: 6px;
  background: #f1f5f9;
  color: var(--navy);
  font-size: 17px;
}


/* =========================================
   設定グリッド
========================================= */
.setting-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.setting-field {
  min-width: 0;
}

.setting-field.full {
  grid-column: 1 / -1;
}

.setting-field label {
  display: block;
  margin-bottom: 6px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}


/* =========================================
   入力欄
========================================= */
.setting-field input[type="number"],
.setting-field input[type="text"],
.setting-field select {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
}


/* =========================================
   カラー入力
========================================= */
.color-control {
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 8px;
}

.color-control input[type="color"] {
  width: 44px;
  height: 40px;
  padding: 3px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  cursor: pointer;
}

.color-control input[type="text"] {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 8px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #0f172a;
  font-family:
    "SFMono-Regular",
    Consolas,
    monospace;
}

.color-control input[type="text"].invalid {
  border-color: #dc2626;
  outline: 1px solid #dc2626;
}


/* =========================================
   チェックボックス
========================================= */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
}

.check-row input {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
}


/* =========================================
   アクションボタン配置
========================================= */
.action-row {
  display: grid;
  grid-column: 1 / -1;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}


/* =========================================
   共通ボタン
========================================= */
.action-button {
  padding: 9px 13px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #ffffff;
  color: #334155;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.action-button:hover {
  background: #f8fafc;
}

.action-button.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #ffffff;
}

.action-button.primary:hover {
  background: var(--blue-dark);
}

.action-button.danger {
  border-color: #fecaca;
  background: #ffffff;
  color: #b91c1c;
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}


/* =========================================
   ヘルプツールチップ
========================================= */
.help-tooltip {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  border: 1px solid #94a3b8;
  border-radius: 50%;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  cursor: help;
}

.help-tooltip-text {
  position: absolute;
  z-index: 1000;
  bottom: calc(100% + 8px);
  width: 240px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #0f172a;
  color: #ffffff;
  font-size: 12px;
  font-weight: 400;
  line-height: 1.6;
  text-align: left;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition:
    opacity 0.15s ease,
    transform 0.15s ease,
    visibility 0.15s ease;
}

.help-tooltip-text::after {
  content: "";
  position: absolute;
  top: 100%;
  border: 6px solid transparent;
  border-top-color: #0f172a;
}

.help-tooltip-left .help-tooltip-text {
  right: -12px;
}

.help-tooltip-left .help-tooltip-text::after {
  right: 15px;
}

.help-tooltip-right .help-tooltip-text {
  left: -12px;
}

.help-tooltip-right .help-tooltip-text::after {
  left: 15px;
}

.help-tooltip:hover .help-tooltip-text,
.help-tooltip:focus .help-tooltip-text,
.help-tooltip:focus-within .help-tooltip-text {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
}


/* =========================================
   右メインエリア
========================================= */
.main-area {
  display: grid;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  gap: 24px;
  overflow: hidden;
}


/* =========================================
   プレビューパネル
========================================= */
.preview-panel {
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 20px;
  overflow: hidden;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.panel-header h2 {
  margin: 0;
  color: var(--navy);
  font-size: 20px;
}


/* =========================================
   デバイス切り替え
========================================= */
.device-buttons {
  display: flex;
  gap: 6px;
}

.device-button {
  padding: 7px 10px;
  border: 1px solid #cbd5e1;
  border-radius: 7px;
  background: #ffffff;
  color: #475569;
  font-size: 12px;
}

.device-button.active {
  border-color: var(--blue);
  background: #eff6ff;
  color: var(--blue);
}


/* =========================================
   プレビュー領域
========================================= */
.preview-stage {
  width: 100%;
  margin: 0 auto;
  padding: 24px;
  border: 1px dashed #cbd5e1;
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
  transition: max-width 0.2s ease;
}

.preview-stage.desktop {
  max-width: 100%;
}

.preview-stage.tablet {
  max-width: 768px;
}

.preview-stage.mobile {
  max-width: 390px;
}


/* =========================================
   コードパネル
========================================= */
.code-panel {
  overflow: hidden;
}


/* =========================================
   コードタブ
========================================= */
.code-tabs {
  display: flex;
  gap: 6px;
  padding: 16px 16px 0;
  border-bottom: 1px solid var(--border);
  background: #ffffff;
}

.code-tab {
  flex: none;
  min-width: 120px;
  padding: 10px 20px;
  border: 1px solid #cbd5e1;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: #f1f5f9;
  color: #64748b;
  font-weight: 700;
}

.code-tab.active {
  position: relative;
  margin-bottom: -1px;
  border-color: var(--blue);
  border-bottom: 1px solid #ffffff;
  background: #ffffff;
  color: var(--blue);
}


/* =========================================
   コード表示
========================================= */
.code-area {
  padding: 16px;
}

.code-area textarea {
  display: none;
  width: 100%;
  min-height: 300px;
  padding: 16px;
  border: 0;
  border-radius: 10px;
  outline: none;
  resize: vertical;
  background: #f1f5f9;
  color: #0f172a;
  font-family:
    "SFMono-Regular",
    Consolas,
    "Liberation Mono",
    monospace;
  font-size: 13px;
  line-height: 1.7;
}

.code-area textarea.active {
  display: block;
}


/* =========================================
   コード操作
========================================= */
.code-actions {
  padding: 0 16px 16px;
}

.status-message {
  min-height: 22px;
  padding: 0 16px 16px;
  color: #15803d;
  font-size: 13px;
}


/* =========================================
   サイトへ戻るボタン
========================================= */
.back-to-site {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  margin-bottom: 16px;
  padding: 0 16px;
  border: 1px solid #2563eb;
  border-radius: 10px;
  background: #2563eb;
  color: #ffffff;
  font-size: 14px;
  font-weight: 700;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(37, 99, 235, 0.18);
}

.back-to-site:hover {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #ffffff;
}


/* =========================================
   関連カテゴリー記事一覧
========================================= */
.mh-tool-articles {
  width: 100%;
  margin: 48px 0 0;
  padding: 32px;
  box-sizing: border-box;
  border: 1px solid #dbeafe;
  border-radius: 20px;
  background: #ffffff;
  box-shadow:
    0 4px 12px rgba(15, 23, 42, .03),
    0 14px 34px rgba(37, 99, 235, .06);
}

.mh-tool-articles-head {
  margin: 0 0 32px;
}

.mh-tool-articles-label {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  margin: 0 0 10px;
  padding: 0 11px;
  border: 1px solid #bfdbfe;
  border-radius: 999px;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: .03em;
}

.mh-tool-articles-title {
  margin: 0 0 8px;
  padding: 0;
  color: #0f172a;
  font-size: 26px;
  font-weight: 900;
  line-height: 1.45;
}

.mh-tool-articles-description {
  margin: 0;
  color: #64748b;
  font-size: 14px;
  font-weight: 500;
  line-height: 1.8;
}

.mh-tool-articles-group {
  margin: 0 0 32px;
}

.mh-tool-articles-group-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 0 0 12px;
}

.mh-tool-articles-group-head::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    #bfdbfe 0%,
    rgba(191, 219, 254, 0) 100%
  );
}

.mh-tool-articles-group-title {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-shrink: 0;
  margin: 0;
  padding: 0;
  color: #0f172a;
  font-size: 18px;
  font-weight: 900;
  line-height: 1.5;
}

.mh-tool-articles-group-title::before {
  content: "";
  display: block;
  width: 4px;
  height: 22px;
  flex-shrink: 0;
  border-radius: 999px;
  background: #2563eb;
}

.mh-tool-articles-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mh-tool-article-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 54px;
  padding: 12px 16px;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  background: #f8fafc;
  color: #334155;
  text-decoration: none;
  transition:
    border-color .2s ease,
    background .2s ease,
    color .2s ease,
    box-shadow .2s ease,
    transform .2s ease;
}

.mh-tool-article-card:hover {
  border-color: #93c5fd;
  background: #ffffff;
  color: #1d4ed8;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, .09);
}

.mh-tool-article-title {
  min-width: 0;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.6;
}

.mh-tool-article-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  background: #eff6ff;
  color: #2563eb;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  transition:
    background .2s ease,
    transform .2s ease;
}

.mh-tool-article-card:hover .mh-tool-article-arrow {
  background: #dbeafe;
  transform: translateX(2px);
}

.mh-tool-articles-footer {
  display: flex;
  justify-content: center;
  margin: 8px 0 0;
  padding-top: 24px;
  border-top: 1px solid #e2e8f0;
}

.mh-tool-articles-category-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 46px;
  padding: 0 20px;
  border: 1px solid #2563eb;
  border-radius: 10px;
  background: #2563eb;
  color: #ffffff;
  font-size: 13px;
  font-weight: 800;
  line-height: 1.5;
  text-decoration: none;
  transition:
    background .2s ease,
    border-color .2s ease,
    box-shadow .2s ease,
    transform .2s ease;
}

.mh-tool-articles-category-link:hover {
  border-color: #1d4ed8;
  background: #1d4ed8;
  color: #ffffff;
  text-decoration: none;
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(37, 99, 235, .20);
}


/* =========================================
   タブレット
========================================= */
@media (max-width: 1000px) {

  .tool-layout {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    position: static;
    max-height: none;
  }

}


/* =========================================
   SP
========================================= */
@media (max-width: 600px) {

  .tool-generator {
    width: min(100% - 20px, 1500px);
    margin: 15px auto;
  }

  .setting-grid {
    grid-template-columns: 1fr;
  }

  .setting-field.full,
  .action-row {
    grid-column: auto;
  }

  .preview-stage {
    padding: 12px;
  }

  .back-to-site {
    position: static;
    margin: 10px 10px 0;
  }

  .mh-tool-articles {
    margin-top: 36px;
    padding: 22px 16px;
    border-radius: 16px;
  }

  .mh-tool-articles-head {
    margin-bottom: 26px;
  }

  .mh-tool-articles-title {
    font-size: 21px;
  }

  .mh-tool-articles-description {
    font-size: 13px;
    line-height: 1.7;
  }

  .mh-tool-articles-group {
    margin-bottom: 28px;
  }

  .mh-tool-articles-group-title {
    font-size: 17px;
  }

  .mh-tool-articles-list {
    grid-template-columns: 1fr;
    gap: 9px;
  }

  .mh-tool-article-card {
    min-height: 52px;
    padding: 11px 13px;
  }

  .mh-tool-article-title {
    font-size: 13px;
  }

  .mh-tool-articles-footer {
    padding-top: 20px;
  }

  .mh-tool-articles-category-link {
    width: 100%;
    box-sizing: border-box;
  }

}