/* リセット & 変数定義 */
:root {
  --primary-color: #2563eb;
  --primary-hover: #1d4ed8;
  --accent-color: #3b82f6;
  --bg-color: #f3f4f6;
  --surface-color: #ffffff;
  --text-main: #1f2937;
  --text-sub: #6b7280;
  --border-color: #e5e7eb;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --radius-md: 8px;
  --radius-lg: 12px;
  --font-family: "Hiragino Kaku Gothic ProN", "Noto Sans JP", Meiryo, sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  margin: 0;
  display: flex;
  min-height: 100vh;
  line-height: 1.6;
}

a {
  text-decoration: none;
  color: var(--primary-color);
  transition: color 0.15s ease;
}

a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* 見出し周りの調整 */
h1 {
  font-size: 1.5rem;
  margin: 0 0 1.5rem 0;
  color: var(--text-main);
  border-bottom: 2px solid var(--primary-color);
  display: inline-block;
  padding-bottom: 0.5rem;
  width: 100%;
  /* 下線のために幅確保 */
  max-width: fit-content;
  /* 文字幅に合わせる */
}

h2,
h3 {
  color: var(--text-main);
  margin-top: 1.5rem;
}

p {
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

/* --- レイアウト --- */

/* サイドバーメニュー */
#menu {
  background-color: #1e293b;
  color: white;
  width: 260px;
  height: 100vh;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  transition: transform 0.2s ease-out;
  display: flex;
  flex-direction: column;
  padding-top: 60px;
  overflow-y: auto;
}

#menu ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

#menu li {
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

#menu a {
  display: block;
  padding: 15px 20px;
  color: #e2e8f0;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.1s;
}

#menu a:hover {
  background-color: rgba(255, 255, 255, 0.1);
  color: white;
}

#menu img {
  display: block;
  margin: 0 auto 20px auto;
  max-width: 80%;
  height: auto;
}

/* メインコンテンツエリア (修正: 中央揃え対応)
*/
#content {
  margin-left: 260px;
  /* サイドバーの分だけ右へ */
  padding: 2rem;
  width: calc(100% - 260px);
  /* 残りの幅全体を使う */

  /* Flexboxで中身を中央寄せにする */
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* コンテンツ内の各要素（header, section, div等）の幅制限 */
#content>* {
  width: 100%;
  max-width: 800px;
  /* これにより大画面でも読みやすい幅で中央に収まる */
}

/* ハンバーガーボタン (PCでは非表示) */
#menu-button {
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1100;
  background-color: var(--primary-color);
  color: white;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  font-weight: bold;
  display: none;
  font-size: 1rem;
  user-select: none;
}

#menu-button span {
  display: flex;
  align-items: center;
  gap: 5px;
}

/* --- フォームスタイル --- */
#form {
  background-color: var(--surface-color);
  padding: 1.5rem;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
  border: 1px solid var(--border-color);
}

#koumoku {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  margin-top: 1.5rem;
  margin-bottom: 0.75rem;
  display: block;
}

#koumoku:first-of-type {
  margin-top: 0;
}

/* チップ型選択肢 */
.custom-radio,
.custom-toggle {
  display: inline-block;
  margin: 0 8px 8px 0;
}

.custom-radio input[type="radio"],
.custom-toggle input[type="checkbox"] {
  display: none;
}

.radio-text,
.toggle-text {
  display: inline-block;
  padding: 8px 16px;
  background-color: var(--bg-color);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: 999px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s ease-out;
  user-select: none;
}

.radio-text:hover,
.toggle-text:hover {
  background-color: #e5e7eb;
}

.custom-radio input:checked+.radio-text,
.custom-toggle input:checked+.toggle-text {
  background-color: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.3);
  font-weight: 600;
}

/* TomSelect調整 */
.ts-control {
  border-radius: var(--radius-md) !important;
  border: 1px solid var(--border-color) !important;
  padding: 10px 12px !important;
  font-size: 1rem !important;
  box-shadow: var(--shadow-sm) !important;
}

.ts-dropdown {
  border-radius: var(--radius-md) !important;
  box-shadow: var(--shadow-md) !important;
  border: 1px solid var(--border-color) !important;
  margin-top: 4px !important;
}

/* ラベルなど */
#sentaku,
#elementToShow p {
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: var(--text-main);
  margin-top: 1.5rem;
}

/* --- ボタン --- */
.generate-button {
  display: block;
  width: 100%;
  max-width: 400px;
  /* 親がalign-items:centerなので、margin: 2rem auto で中央配置を維持 */
  margin: 2rem auto;
  background-color: var(--primary-color);
  color: white;
  font-size: 1.1rem;
  font-weight: 700;
  padding: 1rem;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  box-shadow: var(--shadow-md);
  transition: transform 0.1s, background-color 0.15s;
}

.generate-button:hover {
  background-color: var(--primary-hover);
  transform: translateY(-2px);
}

.generate-button:active {
  transform: translateY(0);
}

/* ダウンロードボタン */
button[onclick="download()"] {
  background-color: var(--surface-color);
  color: var(--primary-color);
  border: 2px solid var(--primary-color);
  margin-top: 1rem;
}

button[onclick="download()"]:hover {
  background-color: #eff6ff;
}

/* --- 出力エリア --- */
#output {
  background-color: var(--surface-color);
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-lg);
  padding: 2rem;
  margin: 2rem 0;
  font-size: 1.1rem;
  font-weight: bold;
  color: var(--text-main);
  text-align: center;
  line-height: 1.8;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- 画像・注意書きエリア (修正: 画像サイズ制限) --- 
*/
.image {
  text-align: center;
  margin: 2rem 0;
}

.image img {
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);

  /* 幅は親に合わせるが、高さは最大250px程度に制限 */
  max-width: 100%;
  max-height: 250px;
  width: auto;

  /* 比率を保ったまま枠内に収める */
  object-fit: contain;
  background-color: #fff;
  /* 余白が出たとき用に白背景 */
}

/* フッター */
.mini {
  margin-top: 4rem;
  padding-top: 2rem;
  border-top: 1px solid var(--border-color);
  width: 100%;
  /* 幅いっぱいに線を引く */
}

.mini p {
  font-size: 0.8rem;
  color: var(--text-sub);
  text-align: center;
}


#ad {
  display: none;
}

#adsp {
  display: block;
}

@media (min-width: 1028px) {
  #ad {
    display: block;
  }

  #adsp {
    display: none;
  }
}



/* --- モバイル対応 --- */
@media (max-width: 768px) {
  #content {
    margin-left: 0;
    width: 100%;
    padding: 1rem;
    padding-top: 70px;
  }

  /* モバイルでも中身の最大幅制限は維持（タブレット対策） */
  #content>* {
    max-width: 100%;
  }

  #menu {
    transform: translateX(-100%);
    width: 260px;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
  }

  #menu.open {
    transform: translateX(0);
  }

  #menu-button {
    display: block;
  }

}