/* ダークテーマ（デフォルト） */
:root, [data-theme="dark"] {
  --bg: #0e1117;
  --panel: #151a23;
  --ink: #e9eef7;
  --muted: #9aa4b2;
  --line: #2a3240;
  --brand: #6aa1ff;
  --ok: #5fd39a;
  --warn: #ffb86b;
  --bad: #ff6b6b;
}

/* ライトテーマ */
[data-theme="light"] {
  --bg: #f5f7fa;
  --panel: #ffffff;
  --ink: #1a202c;
  --muted: #4a5568;
  --line: #e2e8f0;
  --brand: #3182ce;
  --ok: #38a169;
  --warn: #d69e2e;
  --bad: #e53e3e;
}

/* ライトテーマ時の追加調整 */
[data-theme="light"] .header {
  background: #ffffff;
  border-bottom: 1px solid #e2e8f0;
}

[data-theme="light"] .tab {
  background: #f7fafc;
  border-color: #cbd5e0;
}

[data-theme="light"] .tab.active {
  background: #ebf8ff;
  border-color: #3182ce;
}

[data-theme="light"] .tab-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #e2e8f0 !important;
  color: #a0aec0 !important;
}

[data-theme="light"] .tab-disabled:hover {
  background: #e2e8f0 !important;
}

/* アップグレードボタンのパルスアニメーション */
@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.7);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(102, 126, 234, 0);
  }
}

/* アップグレードバナーのモバイル対応 */
@media (max-width: 768px) {
  .upgrade-banner > div {
    flex-direction: column !important;
    text-align: center !important;
  }
  
  .upgrade-banner h3 {
    font-size: 18px !important;
  }
  
  .upgrade-banner p {
    font-size: 14px !important;
  }
}

/* フッター広告枠のスタイル */
#sticky-affiliate {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
  padding: 8px;
  max-width: 300px;
  animation: slideInUp 0.5s ease-out;
}

#sticky-affiliate .sticky-close {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bad);
  color: white;
  border: 2px solid var(--panel);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s, background 0.2s;
  z-index: 1;
}

#sticky-affiliate .sticky-close:hover {
  transform: scale(1.1);
  background: #d32f2f;
}

@keyframes slideInUp {
  from {
    transform: translateY(100px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* モバイル対応 */
@media (max-width: 768px) {
  #sticky-affiliate {
    bottom: 10px;
    right: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
  }
  
  #sticky-affiliate ins {
    display: flex;
    justify-content: center;
  }
}

/* ライトテーマ対応 */
[data-theme="light"] #sticky-affiliate {
  background: #ffffff;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

[data-theme="light"] #sticky-affiliate .sticky-close {
  border-color: #ffffff;
}

[data-theme="light"] .card {
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="light"] .out {
  background: #f7fafc;
  border-color: #cbd5e0;
}

[data-theme="light"] input, 
[data-theme="light"] select, 
[data-theme="light"] textarea {
  background: #ffffff !important;
  border-color: #cbd5e0 !important;
  color: #1a202c !important;
}

/* 特定の入力欄のライトテーマ対応 */
[data-theme="light"] input[type="text"],
[data-theme="light"] input[type="password"] {
  background: #ffffff !important;
  border: 1px solid #cbd5e0 !important;
  color: #1a202c !important;
}

/* ライトテーマ用のカラーホイール */
[data-theme="light"] .wheel {
  box-shadow: 
    0 0 0 1px #cbd5e0,
    0 0 0 3px #ffffff;
}

/* ライトテーマ用のスライダー */
[data-theme="light"] input[type="range"] {
  background: #e2e8f0;
}

[data-theme="light"] input[type="range"]::-webkit-slider-track {
  background: #e2e8f0;
  border: 1px solid #cbd5e0;
}

[data-theme="light"] input[type="range"]::-webkit-slider-thumb {
  background: #ffffff;
  border: 2px solid #3182ce;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

[data-theme="light"] input[type="range"]::-moz-range-track {
  background: #e2e8f0;
  border: 1px solid #cbd5e0;
}

[data-theme="light"] input[type="range"]::-moz-range-thumb {
  background: #ffffff;
  border: 2px solid #3182ce;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

/* ライトテーマ用のスウォッチ */
[data-theme="light"] .swatch {
  border-color: #cbd5e0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="light"] .btn {
  background: #ffffff;
  border-color: #cbd5e0;
  color: #1a202c;
}

[data-theme="light"] .btn:hover {
  background: #f7fafc;
}

[data-theme="light"] .btn.ok {
  background: #38a169;
  color: white;
}

[data-theme="light"] .btn.bad {
  background: #e53e3e;
  color: white;
}

[data-theme="light"] .btn.warn {
  background: #d69e2e;
  color: white;
}

[data-theme="light"] .btn.ghost {
  background: transparent;
  border-color: #cbd5e0;
  color: #4a5568;
}

[data-theme="light"] .btn.ghost:hover {
  background: #f7fafc;
  color: #2d3748;
}

[data-theme="light"] .btn.small {
  background: #f7fafc;
  border-color: #cbd5e0;
  color: #4a5568;
}

[data-theme="light"] .btn.small:hover {
  background: #e2e8f0;
  color: #2d3748;
}

[data-theme="light"] .modal {
  background-color: rgba(0, 0, 0, 0.6);
}

[data-theme="light"] .scroller {
  background: #f7fafc;
  border-color: #cbd5e0;
}

/* ライトテーマ用のラジオボタンスタイル */
[data-theme="light"] input[type="radio"] {
  accent-color: #3182ce;
}

[data-theme="light"] label input[type="radio"]:checked + span {
  color: #2d3748;
  font-weight: 600;
}

[data-theme="light"] label input[type="radio"]:checked + span::before {
  background: #3182ce;
  border-color: #3182ce;
}

[data-theme="light"] label input[type="radio"] + span::before {
  border-color: #cbd5e0;
}

/* ライトテーマ用のラベルテキスト */
[data-theme="light"] label {
  color: #1a202c;
}

[data-theme="light"] label:hover {
  color: #2d3748;
}

/* 基本情報と服装のselectスタイル */
.basic-select,
.outfit-select {
  width: 100%;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s;
}

.basic-select:hover,
.outfit-select:hover {
  border-color: var(--brand);
}

.basic-select:focus,
.outfit-select:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(106, 161, 255, 0.1);
}

/* モバイル対応 */
@media (max-width: 768px) {
  .basic-select,
  .outfit-select {
    padding: 12px;
    font-size: 16px; /* iOSのズーム防止 */
  }
}

[data-theme="light"] .wheel-box {
  border-color: #cbd5e0;
  background: #ffffff;
}

/* ライトテーマ用のカラーホイールボックス内の要素 */
[data-theme="light"] .wheel-box .row.mini {
  background: #f7fafc;
  border-radius: 6px;
  padding: 4px 8px;
}

[data-theme="light"] .wheel-box input[type="text"] {
  background: #ffffff;
  border: 1px solid #cbd5e0;
  color: #1a202c;
}

[data-theme="light"] code.tag {
  background: #edf2f7;
  color: #2d3748;
}

[data-theme="light"] .panel {
  background: rgba(0,0,0,0.02);
}

/* ライトテーマ用の追加要素 */
[data-theme="light"] .row.mini {
  color: #2d3748;
}

[data-theme="light"] .mini {
  color: #4a5568;
}

[data-theme="light"] .status {
  color: #4a5568;
}

/* ライトテーマ用のラベル */
[data-theme="light"] .inline.mini {
  color: #2d3748;
}

[data-theme="light"] .inline.mini label {
  color: #2d3748;
}

[data-theme="light"] .note {
  background: #edf2f7;
  border-color: #cbd5e0;
  color: #2d3748;
}

[data-theme="light"] .chips {
  background: #f7fafc;
}

[data-theme="light"] .chip {
  background: #e2e8f0;
  color: #2d3748;
}

[data-theme="light"] .chip.active {
  background: #3182ce;
  color: white;
}

/* ライトテーマ用のプリセット詳細表示 */
[data-theme="light"] .preset-detail {
  color: #2d3748;
}

[data-theme="light"] .preset-detail strong {
  color: #1a202c;
}

[data-theme="light"] .preset-detail code {
  background: #edf2f7;
  color: #2d3748;
  border: 1px solid #cbd5e0;
}

[data-theme="light"] .preset-detail .tag {
  background: #e2e8f0;
  color: #2d3748;
}

/* プリセット詳細表示のライトテーマ対応 */
[data-theme="light"] .preset-details {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .preset-details-header {
  color: #1a202c !important;
}

[data-theme="light"] .preset-details-content {
  color: #2d3748 !important;
}

[data-theme="light"] .preset-details-content strong {
  color: #1a202c !important;
}

[data-theme="light"] .preset-details-content code {
  background: #edf2f7 !important;
  color: #2d3748 !important;
  border: 1px solid #cbd5e0 !important;
}

/* ライトテーマ用のネガティブプロンプト */
[data-theme="light"] .negative-prompt {
  background: #f7fafc;
  border-color: #cbd5e0;
  color: #2d3748;
}

[data-theme="light"] .negative-prompt .title {
  color: #1a202c;
}

[data-theme="light"] .negative-prompt .content {
  background: #ffffff;
  border-color: #cbd5e0;
  color: #1a202c;
}

/* ライトテーマ用のテーブル */
[data-theme="light"] table {
  background: #ffffff;
  border-color: #cbd5e0;
}

[data-theme="light"] table th {
  background: #f7fafc !important;
  border-color: #cbd5e0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] table td {
  background: #ffffff !important;
  border-color: #cbd5e0 !important;
  color: #1a202c !important;
}

[data-theme="light"] table tr:nth-child(even) td {
  background: #f7fafc !important;
}

[data-theme="light"] table tr:hover td {
  background: #edf2f7 !important;
}

/* 特定のテーブルクラスのライトテーマ対応 */
[data-theme="light"] .table th {
  background: #f7fafc !important;
  color: #2d3748 !important;
  border-bottom: 1px solid #cbd5e0 !important;
}

[data-theme="light"] .table td {
  background: #ffffff !important;
  color: #1a202c !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .wm-table th {
  background: #f7fafc !important;
  color: #2d3748 !important;
  border-bottom: 1px solid #cbd5e0 !important;
}

[data-theme="light"] .wm-table td {
  background: #ffffff !important;
  color: #1a202c !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .wm-table thead th {
  background: #edf2f7 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .fieldset {
  border-color: #cbd5e0;
}

[data-theme="light"] legend {
  color: #2d3748;
}

/* ライトテーマ用の出力エリアラベル */
[data-theme="light"] .out + .btn {
  margin-top: 6px;
}

[data-theme="light"] .out {
  border: 1px solid #cbd5e0;
}

/* 出力エリアのラベルテキスト */
[data-theme="light"] .out::before,
[data-theme="light"] .grid > div > .mini {
  color: #4a5568;
}

/* ライトテーマ用のドロップダウン */
[data-theme="light"] select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3E%3Cpath stroke='%234a5568' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
}

/* 謎のチェック文字を削除 */
[data-theme="light"] select option::before,
[data-theme="light"] select::before {
  display: none !important;
}

/* ライトテーマ用のプレースホルダー */
[data-theme="light"] input::placeholder,
[data-theme="light"] textarea::placeholder {
  color: #a0aec0;
}

/* ライトテーマ用のフォーカス状態 */
[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
  border-color: #3182ce;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1);
  outline: none;
}

/* ライトテーマ用の追加要素 */
[data-theme="light"] .card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

[data-theme="light"] .card h3,
[data-theme="light"] .card h4 {
  color: #1a202c;
}

[data-theme="light"] .card .mini {
  color: #4a5568;
}

/* ライトテーマ用のグリッド要素 */
[data-theme="light"] .grid > div {
  background: #ffffff;
  border: 1px solid #e2e8f0;
}

[data-theme="light"] .grid > div:hover {
  background: #f7fafc;
}

/* ライトテーマ用のセクション */
[data-theme="light"] section {
  background: #f7fafc;
  border: 1px solid #e2e8f0;
}

[data-theme="light"] section h2,
[data-theme="light"] section h3 {
  color: #1a202c;
}

/* ライトテーマ用のリスト */
[data-theme="light"] ul,
[data-theme="light"] ol {
  color: #2d3748;
}

[data-theme="light"] li {
  color: #2d3748;
}

/* ライトテーマ用のリンク */
[data-theme="light"] a {
  color: #3182ce;
}

[data-theme="light"] a:hover {
  color: #2c5282;
}

/* ライトテーマ用の強調テキスト */
[data-theme="light"] strong,
[data-theme="light"] b {
  color: #1a202c;
}

[data-theme="light"] em,
[data-theme="light"] i {
  color: #2d3748;
}

/* ライトテーマ用の量産モードガイド */
[data-theme="light"] .production-guide {
  background: #ebf8ff !important;
  border: 1px solid #bee3f8 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .production-guide summary {
  color: #1a202c !important;
}

[data-theme="light"] .guide-content {
  color: #2d3748 !important;
}

[data-theme="light"] .guide-card {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .guide-card h4 {
  color: #1a202c !important;
}

[data-theme="light"] .guide-card ul {
  color: #2d3748 !important;
}

[data-theme="light"] .guide-card li {
  color: #2d3748 !important;
}

[data-theme="light"] .guide-card strong {
  color: #1a202c !important;
}

/* ライトテーマ用のプリセットボタン */
[data-theme="light"] .production-presets {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .preset-buttons {
  background: transparent !important;
}

/* ライトテーマ用のバッジ */
[data-theme="light"] .badge {
  background: #e2e8f0 !important;
  color: #2d3748 !important;
  border: 1px solid #cbd5e0 !important;
}

[data-theme="light"] .badge.ok {
  background: #d1fae5 !important;
  color: #065f46 !important;
  border: 1px solid #a7f3d0 !important;
}

[data-theme="light"] .badge.warn {
  background: #fef3c7 !important;
  color: #92400e !important;
  border: 1px solid #fde68a !important;
}

[data-theme="light"] .badge.bad {
  background: #fee2e2 !important;
  color: #991b1b !important;
  border: 1px solid #fecaca !important;
}

/* ライトテーマ用のdetails/summary */
[data-theme="light"] details {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
}

[data-theme="light"] summary {
  background: #f7fafc !important;
  color: #1a202c !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="light"] summary:hover {
  background: #edf2f7 !important;
}

[data-theme="light"] summary .caret {
  color: #4a5568 !important;
}

/* ライトテーマ用のカラーコード */
[data-theme="light"] .vary {
  color: #d69e2e !important;
}

[data-theme="light"] .fixed {
  color: #38a169 !important;
}

/* ライトテーマ用の漫画モードプリセット */
[data-theme="light"] .manga-result-item {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .manga-result-item:hover {
  background: #f7fafc !important;
  border-color: #3182ce !important;
}

[data-theme="light"] .manga-result-item.selected {
  background: #ebf8ff !important;
  border-color: #3182ce !important;
}

[data-theme="light"] .manga-result-item-main {
  color: #1a202c !important;
}

[data-theme="light"] .manga-result-item-category {
  color: #4a5568 !important;
}

[data-theme="light"] .manga-result-item-tag {
  color: #4a5568 !important;
  background: #edf2f7 !important;
  border: 1px solid #cbd5e0 !important;
}

[data-theme="light"] .manga-results-close {
  color: #4a5568 !important;
}

[data-theme="light"] .manga-results-close:hover {
  background: #fee2e2 !important;
  color: #e53e3e !important;
}

[data-theme="light"] .manga-search-results-content {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
}

/* ライトテーマ用のプリセット詳細表示（漫画モード） */
[data-theme="light"] .manga-preset-detail {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .manga-preset-detail h3,
[data-theme="light"] .manga-preset-detail h4 {
  color: #1a202c !important;
}

[data-theme="light"] .manga-preset-detail p {
  color: #2d3748 !important;
}

[data-theme="light"] .manga-preset-detail strong {
  color: #1a202c !important;
}

[data-theme="light"] .manga-preset-detail code {
  background: #edf2f7 !important;
  color: #2d3748 !important;
  border: 1px solid #cbd5e0 !important;
}

/* ライトテーマ用のプリセットタグ */
[data-theme="light"] .preset-tag {
  background: #e2e8f0 !important;
  color: #2d3748 !important;
  border: 1px solid #cbd5e0 !important;
}

[data-theme="light"] .preset-tag.active {
  background: #3182ce !important;
  color: #ffffff !important;
  border: 1px solid #3182ce !important;
}

/* ライトテーマ用のプリセット表示全体 */
[data-theme="light"] .manga-preset-display {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .manga-preset-display .title {
  color: #1a202c !important;
}

[data-theme="light"] .manga-preset-display .description {
  color: #2d3748 !important;
}

[data-theme="light"] .manga-preset-display .content {
  color: #2d3748 !important;
}

/* ライトテーマ用のプリセット選択エリア */
[data-theme="light"] .manga-preset-selection {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .manga-preset-selection .current-preset {
  color: #1a202c !important;
}

[data-theme="light"] .manga-preset-selection .preset-list {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .manga-preset-selection .preset-item {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .manga-preset-selection .preset-item:hover {
  background: #f7fafc !important;
  border-color: #3182ce !important;
}

[data-theme="light"] .manga-preset-selection .preset-item.selected {
  background: #ebf8ff !important;
  border-color: #3182ce !important;
  color: #1a202c !important;
}

/* ライトテーマ用の単語モードアコーディオン */
[data-theme="light"] .wm-acc {
  border: 1px solid #e2e8f0 !important;
  background: #ffffff !important;
}

[data-theme="light"] .wm-acc > summary {
  background: #f7fafc !important;
  color: #1a202c !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .wm-acc[open] > summary {
  background: #edf2f7 !important;
  color: #1a202c !important;
}

[data-theme="light"] .wm-acc .wm-count {
  color: #4a5568 !important;
  background: #e2e8f0 !important;
}

[data-theme="light"] .wm-items {
  background: #ffffff !important;
  color: #2d3748 !important;
}

[data-theme="light"] .wm-item {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .wm-item:hover {
  background: #f7fafc !important;
  border-color: #3182ce !important;
}

[data-theme="light"] .wm-item.active {
  background: #ebf8ff !important;
  border-color: #3182ce !important;
  color: #1a202c !important;
}

[data-theme="light"] .wm-tip {
  color: #4a5568 !important;
}

[data-theme="light"] .wm-acc.wm-no-results > summary {
  color: #a0aec0 !important;
}

[data-theme="light"] .wm-selected {
  background: #f0fff4 !important;
  border: 1px solid #9ae6b4 !important;
}

[data-theme="light"] .wm-chip {
  background: #e2e8f0 !important;
  color: #2d3748 !important;
  border: 1px solid #cbd5e0 !important;
}

[data-theme="light"] .wm-chip .x {
  color: #4a5568 !important;
}

[data-theme="light"] .wm-chip small {
  color: #4a5568 !important;
}

[data-theme="light"] .wm-acc-title {
  color: #3182ce !important;
  border-bottom-color: #3182ce !important;
}

/* ライトテーマ用のその他の要素 */
[data-theme="light"] .mangaEmotionPrimary,
[data-theme="light"] .mangaEmotionDetail,
[data-theme="light"] .mangaNSFWEmotion {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .mangaEmotionPrimary label,
[data-theme="light"] .mangaEmotionDetail label,
[data-theme="light"] .mangaNSFWEmotion label {
  color: #2d3748 !important;
}

[data-theme="light"] .mangaEmotionPrimary label:hover,
[data-theme="light"] .mangaEmotionDetail label:hover,
[data-theme="light"] .mangaNSFWEmotion label:hover {
  background: #f7fafc !important;
  color: #1a202c !important;
}

[data-theme="light"] .mangaEmotionPrimary label input[type="radio"]:checked + span,
[data-theme="light"] .mangaEmotionDetail label input[type="radio"]:checked + span,
[data-theme="light"] .mangaNSFWEmotion label input[type="radio"]:checked + span {
  color: #1a202c !important;
  font-weight: 600;
}

/* ライトテーマ用の検索ボックス */
[data-theme="light"] .wm-search {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #1a202c !important;
}

[data-theme="light"] .wm-search::placeholder {
  color: #a0aec0 !important;
}

[data-theme="light"] .wm-search:focus {
  border-color: #3182ce !important;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1) !important;
}

/* ライトテーマ用のボタン（追加） */
[data-theme="light"] .wm-btn {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .wm-btn:hover {
  background: #f7fafc !important;
  border-color: #3182ce !important;
}

[data-theme="light"] .wm-btn.ok {
  background: #38a169 !important;
  color: #ffffff !important;
  border-color: #38a169 !important;
}

[data-theme="light"] .wm-btn.bad {
  background: #e53e3e !important;
  color: #ffffff !important;
  border-color: #e53e3e !important;
}

/* ライトテーマ用の漫画モードプリセット（動的生成要素） */
[data-theme="light"] .manga-presets-container {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .manga-presets-container h3 {
  color: #1a202c !important;
}

[data-theme="light"] .preset-tabs {
  background: #f7fafc !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .preset-tab {
  background: transparent !important;
  color: #4a5568 !important;
  border: 1px solid transparent !important;
}

[data-theme="light"] .preset-tab:hover {
  background: #edf2f7 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .preset-tab.active {
  background: #ebf8ff !important;
  color: #1a202c !important;
  border-color: #3182ce !important;
}

[data-theme="light"] .preset-content {
  background: #ffffff !important;
  color: #2d3748 !important;
}

[data-theme="light"] .preset-grid {
  background: #ffffff !important;
}

[data-theme="light"] .preset-card {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .preset-card:hover {
  background: #f7fafc !important;
  border-color: #3182ce !important;
}

[data-theme="light"] .preset-card.selected {
  background: #ebf8ff !important;
  border-color: #3182ce !important;
  color: #1a202c !important;
}

[data-theme="light"] .preset-card h4 {
  color: #1a202c !important;
}

[data-theme="light"] .preset-card p {
  color: #4a5568 !important;
}

[data-theme="light"] .preset-card .preset-tags {
  color: #4a5568 !important;
}

[data-theme="light"] .preset-card .preset-tag {
  background: #e2e8f0 !important;
  color: #2d3748 !important;
  border: 1px solid #cbd5e0 !important;
}

[data-theme="light"] .current-preset-display {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .current-preset-display h4 {
  color: #1a202c !important;
}

[data-theme="light"] .current-preset-display p {
  color: #4a5568 !important;
}

[data-theme="light"] .preset-details {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .preset-details h5 {
  color: #1a202c !important;
}

[data-theme="light"] .preset-details .detail-item {
  color: #2d3748 !important;
}

[data-theme="light"] .preset-details .detail-item strong {
  color: #1a202c !important;
}

[data-theme="light"] .preset-details .detail-item code {
  background: #edf2f7 !important;
  color: #2d3748 !important;
  border: 1px solid #cbd5e0 !important;
}

/* ライトテーマ用の漫画モード検索セクション */
[data-theme="light"] .manga-search {
  background: #ebf8ff !important;
  border: 1px solid #bee3f8 !important;
}

[data-theme="light"] .manga-search-container {
  background: transparent !important;
}

[data-theme="light"] .manga-search-input {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #1a202c !important;
}

[data-theme="light"] .manga-search-input:focus {
  border-color: #3182ce !important;
  box-shadow: 0 0 0 3px rgba(49, 130, 206, 0.1) !important;
}

[data-theme="light"] .manga-search-input::placeholder {
  color: #a0aec0 !important;
}

[data-theme="light"] .manga-search-clear {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .manga-search-clear:hover {
  background: #edf2f7 !important;
  border-color: #3182ce !important;
}

[data-theme="light"] .manga-search-stats {
  color: #4a5568 !important;
}

[data-theme="light"] .manga-search-results {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .manga-search-results-header {
  background: #f7fafc !important;
  border-bottom: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .manga-search-results-title {
  color: #1a202c !important;
}

[data-theme="light"] .manga-search-highlight {
  background-color: rgba(255, 235, 59, 0.3) !important;
}

/* ライトテーマ用のプリセット詳細表示（具体的な要素） */
[data-theme="light"] #presetDetails {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] #presetDetailsContent {
  color: #2d3748 !important;
}

[data-theme="light"] #presetDetailsContent h4 {
  color: #1a202c !important;
}

[data-theme="light"] #presetDetailsContent p {
  color: #4a5568 !important;
}

/* プリセット詳細の設定項目 */
[data-theme="light"] #presetDetailsContent div[style*="margin: 2px 0"] {
  color: #2d3748 !important;
}

[data-theme="light"] #presetDetailsContent span[style*="color: #4ade80"] {
  color: #38a169 !important;
  font-weight: bold;
}

[data-theme="light"] #presetDetailsContent span[style*="color: rgba(255,255,255,0.9)"] {
  color: #2d3748 !important;
}

/* プリセットボタン */
[data-theme="light"] .preset-btn {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .preset-btn:hover {
  background: #f7fafc !important;
  border-color: #3182ce !important;
}

[data-theme="light"] .preset-btn.active {
  background: #ebf8ff !important;
  border-color: #3182ce !important;
  color: #1a202c !important;
}

[data-theme="light"] .preset-btn.nsfw-l1 {
  background: #fef3c7 !important;
  border-color: #f59e0b !important;
  color: #92400e !important;
}

[data-theme="light"] .preset-btn.nsfw-l2 {
  background: #fee2e2 !important;
  border-color: #ef4444 !important;
  color: #991b1b !important;
}

[data-theme="light"] .preset-btn.nsfw-l3 {
  background: #f3e8ff !important;
  border-color: #8b5cf6 !important;
  color: #6b21a8 !important;
}

/* プリセットセクション */
[data-theme="light"] .preset-section {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
}

[data-theme="light"] .preset-section h5 {
  color: #1a202c !important;
}

[data-theme="light"] .preset-buttons {
  background: transparent !important;
}

/* プリセットクリアボタン */
[data-theme="light"] .preset-clear-btn {
  background: #fee2e2 !important;
  border: 1px solid #fecaca !important;
  color: #991b1b !important;
}

[data-theme="light"] .preset-clear-btn:hover {
  background: #fecaca !important;
  border-color: #f87171 !important;
}

/* プリセット詳細の具体的な要素 */
/* ダークテーマ用（デフォルト） */
.preset-detail-category {
  color: #00ff41 !important; /* 蛍光緑色 */
  font-weight: bold !important;
}

[data-theme="light"] .preset-detail-category {
  color: #38a169 !important;
  font-weight: bold !important;
}

[data-theme="light"] .preset-detail-value {
  color: #2d3748 !important;
}

[data-theme="light"] .preset-level-badge {
  background: rgba(239, 68, 68, 0.2) !important;
  color: #991b1b !important;
  padding: 2px 6px !important;
  border-radius: 8px !important;
  font-size: 10px !important;
  margin-left: 8px !important;
}



/* 現在のプリセット表示 */
[data-theme="light"] .preset-status {
  background: #f7fafc !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] #currentPresetInfo {
  background: #ffffff !important;
  border: 1px solid #e2e8f0 !important;
  color: #2d3748 !important;
}

[data-theme="light"] .preset-current {
  color: #2d3748 !important;
}

[data-theme="light"] .preset-current strong {
  color: #1a202c !important;
}

[data-theme="light"] .preset-desc {
  color: #4a5568 !important;
}

[data-theme="light"] #currentPresetName {
  color: #1a202c !important;
}

[data-theme="light"] #currentPresetDesc {
  color: #4a5568 !important;
}

/* テーマ切り替えボタンのスタイル */
#themeToggle {
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
}

#themeToggle:hover {
  transform: scale(1.1);
}

#themeIcon {
  font-size: 18px;
  display: inline-block;
  transition: transform 0.3s ease;
}

#themeToggle:active #themeIcon {
  transform: rotate(360deg);
}

/* 基本リセット & ベース */
* { box-sizing: border-box; }
html, body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 system-ui, -apple-system, Segoe UI, Roboto;
}
h1, h2, h3 { margin: 0 0 8px; }
a { color: var(--brand); text-decoration: none; }

/* ========================
   レイアウト / コンテナ
   ======================== */

/* 画面が広くても読みやすい上限幅＋可変パディング */
.container {
  max-width: 1400px;                 /* ← 1200→1400に拡張。好みで調整可 */
  margin: 0 auto;
  padding-inline: clamp(12px, 2vw, 24px);
  padding-block: 16px;
}

/* 汎用グリッド */
.grid { display: grid; gap: 12px; }

/* 既存の固定カラムユーティリティ（そのまま使えます） */
.g2 { grid-template-columns: repeat(2, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g5 { grid-template-columns: repeat(5, 1fr); }
.g6 { grid-template-columns: repeat(6, 1fr); }

/* 新：自動カラム（広い画面でも崩れにくい） */
.grid.auto {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-content: start;
}

/* 背の高いカードを2カラム占有させたい時に付ける */
@media (min-width: 1200px) {
  .span-2 { grid-column: span 2; }
}

@media (max-width: 1024px) {
  .g3, .g2 { grid-template-columns: 1fr; }
  .g4, .g5, .g6 { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .g4, .g5, .g6 { grid-template-columns: 1fr; }
}

/* ========================
   ヘッダー / タブ / ボタン
   ======================== */
.header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #0b0f16;
  border-bottom: 1px solid #121826;
}
.header .inner {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
}
.header-row { display: flex; align-items: center; gap: 8px; }
.header-row .card-title { margin: 0; }
.header-row .push { margin-left: auto; }
@media (max-width: 640px) {
  .header-row { flex-wrap: wrap; }
  .header-row .push { margin-left: 0; }
}

.tabbar { 
  display: flex; 
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
}

.tab {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  cursor: pointer;
  background: #121723;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.2s;
}

.tab .tab-icon {
  font-size: 18px;
}

.tab .tab-text {
  margin-left: 4px;
}

.tab.active {
  border-color: #3e58a6;
  background: #172036;
}
.tab-disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background: #0e1117 !important;
  color: #666 !important;
}
.tab-disabled:hover {
  background: #0e1117 !important;
}

/* モバイル: テキストを非表示、アイコンのみ */
@media (max-width: 768px) {
  .tab {
    padding: 10px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  
  .tab .tab-text {
    display: none;
  }
  
  .tab .tab-icon {
    margin: 0;
    font-size: 20px;
  }
  
  .tabbar {
    gap: 4px;
  }
  
  /* ステータス表示もモバイルでは簡略化 */
  .status {
    font-size: 11px;
    padding: 4px 8px;
  }
}

.btn {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
  color: #0b1119;
  background: linear-gradient(180deg, #6aa1ff, #497fff);
}
.btn.small { padding: 6px 10px; font-weight: 600; }
.btn.ghost { background: #1d2432; color: #e6eeff; border: 1px solid var(--line); }
.btn.ok { background: linear-gradient(180deg, #65d77c, #43b96f); }
.btn.bad { background: linear-gradient(180deg, #ff7b7b, #ff5454); }

/* ========================
   カード / パネル
   ======================== */
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  margin: 14px 0;
  min-width: 0;            /* ← はみ出し防止（chipが多くてもOK） */
}
.panel {
  border: 1px dashed #283244;
  border-radius: 10px;
  padding: 10px;
}
.panel > .card {
  background: #101520;
  border-color: #232b3a;
  margin-top: 10px;
}

/* ========================
   フォーム / リスト
   ======================== */
label.inline {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 4px 8px 4px 0;
}
textarea,
input[type="text"],
input[type="password"],
select {
  width: 100%;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #0f141d;
  color: var(--ink);
  padding: 10px;
}

.scroller {
  max-height: 190px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px;
  background: #0f141d;
}

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #1b2232;
  border: 1px solid var(--line);
  color: #cbd6ea;
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 12px;
}

/* 小要素 */
.mini { color: var(--muted); font-size: 12px; }
.status {
  padding: 6px 12px;
  background: #111a28;
  border: 1px solid #21304a;
  border-radius: 10px;
}
.toast {
  background: #111c2a;
  border: 1px solid #2a3a52;
  padding: 6px 10px;
  border-radius: 8px;
}
.out {
  white-space: pre-wrap;
  background: #0b0f16;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px;
  min-height: 140px;
  max-height: 140px;   /* 好きな高さに調整可 */
  overflow-y: auto;
  white-space: pre-wrap;   /* 折り返し維持 */
}

/* テーブル */
.table {
  width: 100%;
  border-collapse: collapse;
  background: #0b0f16;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
}
.table th, .table td {
  border-bottom: 1px solid #1e2635;
  padding: 8px 10px;
  text-align: left;
  font-size: 13px;
}
.table th {
  background: #121a2a;
  color: #cfe0ff;
  position: sticky;
  top: 0;
  z-index: 1;
}

/* インラインコード */
kbd {
  background: #101826;
  border: 1px solid #2a3342;
  border-radius: 6px;
  padding: 1px 6px;
}
code.tag {
  background: #101826;
  border: 1px solid #233045;
  border-radius: 6px;
  padding: 1px 6px;
  color: #d9e6ff;
}

/* ========================
   色ホイール（共通）
   ======================== */
.wheel-box {
  position: relative;
  width: 180px;
  height: 180px;            /* ← 共通は固定。髪/瞳/学習アクセ等はこちらを使う */
  margin: 6px 0 8px;
}
.wheel {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(red, yellow, lime, cyan, blue, magenta, red);
  box-shadow:
    0 0 0 10px #0f141d inset,
    0 0 0 1px #2a3342 inset;
  z-index: 1;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.wheel::after {
  content: "";
  position: absolute;
  inset: 28px;
  border-radius: 50%;
  background: #0e131c;
  pointer-events: none;
}
.thumb {
  position: absolute;
  left: 83px;
  top: -6px;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px #000;
  z-index: 2;
  pointer-events: none;
}
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: #333;
}


/* セパレーター */
hr.sep {
  border: 0;
  border-top: 1px solid #223048;
  margin: 12px 0;
}

/* details */
details {
  border: 1px dashed #283244;
  border-radius: 10px;
  padding: 8px;
  background: #0f141d;
}
summary {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 8px;
}
summary::-webkit-details-marker { display: none; }
summary .caret { transform: rotate(0deg); transition: transform .15s; }
details[open] summary .caret { transform: rotate(90deg); }

/* バッジ & ノート */
.badge {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid #2a3240;
  background: #121a2a;
  color: #cfe0ff;
  margin-left: 6px;
}
.badge.warn { background: #1b1420; border-color: #4a2a3a; color: #ffb6c1; }
.badge.ok   { background: #132019; border-color: #294b38; color: #9be7b3; }
.note {
  margin: 8px 0;
  padding: 10px;
  border: 1px dashed #2a3240;
  border-radius: 10px;
  background: #0f141d;
  color: #cfd7e6;
}
.note .mini { opacity: .9; }

/* ========================
   有効/無効 表現の統一
   ======================== */

/* .disabled は“見た目だけ”にする（クリックは殺さない） */
.disabled {
  opacity: .5;
  filter: grayscale(30%);
  pointer-events: auto !important;   /* ← これが肝 */
}

/* 念のため：パネルを is-disabled にしても“モード切替ラジオ”は触れる */
#panel_outfitFixed input[name="outfitMode"] {
  pointer-events: auto;
}

/* 無効状態の見た目（下カテゴリのfieldsetや親パネルに付く想定） */
.is-disabled {
  opacity: .45;
  pointer-events: none;   /* 操作も止める */
}

/* パネルは見た目を落とす＋操作制御（チェックボックスだけは押せる） */
.panel.is-disabled {
  opacity: .5;
}
.panel.is-disabled .wheel-box,
.panel.is-disabled input[type="range"],
.panel.is-disabled select,
.panel.is-disabled input[type="text"] {
  pointer-events: none;
  filter: grayscale(80%);
}
.panel.is-disabled input[type="checkbox"] {
  pointer-events: auto;   /* ← チェックは常に戻せる */
}

/* 機能としての無効化は fieldset[disabled] を使うが、見た目は変えない */
fieldset { border: 0; margin: 0; padding: 0; }
fieldset:disabled {
  pointer-events: none;   /* 入力は止める */
  opacity: inherit;             /* ← ここがキモ：見た目は .is-disabled に任せる */
}

/* Safari 対策 */
fieldset, fieldset:disabled {
  -webkit-appearance: none;
  appearance: none;
  outline: 0;
}
legend { display: none; }


/* ====== Ultra-wide layout（選択肢の枠を広げる）====== */
/* コンテナを広くしてカラムを“最小幅指定付き”で拡張 */
@media (min-width: 1280px) {
  .container { max-width: 1600px; }  /* 1400→1600に拡張 */

  /* 髪型/目/服 の3カラム。各枠の最小幅を与えるのがポイント */
  #grid_shape {
    display: grid;
    grid-template-columns:
      minmax(440px, 1fr)   /* 髪型 */
      minmax(440px, 1fr)   /* 目の形 */
      minmax(560px, 1.2fr) /* 服（広め） */
    ;
    gap: 16px;
    align-items: start;
  }

  /* 一覧性UP（任意） */
  #grid_shape .scroller { max-height: 320px; }
}

@media (min-width: 1600px) {
  .container { max-width: 1760px; }
  #grid_shape {
    grid-template-columns:
      minmax(520px, 1fr)
      minmax(520px, 1fr)
      minmax(640px, 1.3fr);
  }
}

/* ===== 服カラー（固定）- 旧grid_fixed_colors削除済み ===== */
/* 新レイアウトでは各服の下に色選択が統合されています */

/* ===== 量産モードの“服カラー”ホイールも同様に復活＆可変 ===== */
#prodColorCard .panel { overflow: hidden; }
#prodColorCard .panel .wheel-box {
  width: clamp(180px, calc(100% - 40px), 300px);
  aspect-ratio: 1 / 1;
  height: auto;
  margin: 10px auto 8px;
}

/* ===== 量産モードのアクセ：ラベルとホイールのずれ修正 ===== */
#panelProduction .panel .row.mini {
  display: block;              /* ← 横並びをやめて縦に積む */
  margin-bottom: 8px;          /* 下に余白を確保 */
}

#panelProduction .panel select + .wheel-box {
  margin-top: 6px;             /* セレクトの直下にホイール */
}

/* ===== 服（固定）の選択 UI：全画面時は折り返し ===== */
/* 服（固定）3ブロックを画面幅に応じて確実に折り返す */
#panel_outfitFixed .grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(380px, 1fr)); /* ← 最小幅を少し広げて3列を強制 */
  gap: 12px;
  align-items: start;                                   /* パネルの頭を揃える */
}
#panel_outfitFixed .grid > .panel { min-width: 0; }     /* 長いチップでも折り返せる */

@media (max-width: 1440px) {
  #panel_outfitFixed .grid {
    grid-template-columns: repeat(2, minmax(380px, 1fr)); /* 2列 */
  }
}
@media (max-width: 980px) {
  #panel_outfitFixed .grid { grid-template-columns: 1fr; } /* 1列 */
}

/* 服リストの縦を少しだけ広げる（はみ出し防止） */
#panel_outfitFixed .scroller { max-height: 460px; }
@media (min-width: 1600px) {
  #panel_outfitFixed .scroller { max-height: 520px; }
}

/* ===== 髪型/目/服（3カラム）の“選択肢の枠”を広げる ===== */
@media (min-width: 1280px) {
  .container { max-width: 1600px; }
  #grid_shape {
    display: grid;
    grid-template-columns:
      minmax(480px, 1fr)      /* 髪型 */
      minmax(480px, 1fr)      /* 目の形 */
      minmax(640px, 1.2fr);   /* 服（広め） */
    gap: 16px;
    align-items: start;
  }
  #grid_shape .scroller { max-height: 320px; }
  #panel_outfitFixed .scroller { max-height: 360px; }
}
@media (min-width: 1700px) {
  .container { max-width: 1760px; }
  #grid_shape {
    grid-template-columns:
      minmax(520px, 1fr)
      minmax(520px, 1fr)
      minmax(680px, 1.3fr);
  }
}

/* ===== 共通の縮小（タブレット以下） ===== */
@media (max-width: 1024px) {
  #prodColorCard  .panel .wheel-box { display: none; }
}

/* ===== 既存の“ホイール固定サイズ”は髪/瞳/学習アクセに適用 ===== */
/* 服カラー系で上書きするので、ここは残す */
@media (max-width: 1024px) {
  .panel .wheel-box { width: 160px; height: 160px; }
}
@media (max-width: 640px) {
  .panel .wheel-box { width: 140px; height: 140px; }
}

/* 超ワイドでさらに広げる */
/* grid_fixed_colorsは新レイアウトで削除済み */

/* grid 直下のパネルは最小幅0（長いタグでも折り返せる） */
.grid > .panel { min-width: 0; }

/* タグは1行（幅計算を安定化） */
.row.mini code.tag { white-space: nowrap; }

/* 見た目のグレーアウト：is-disabled に集約（チェックは常に押せる） */
.is-disabled { opacity: .5; }
.panel.is-disabled .wheel-box,
.panel.is-disabled input[type="range"],
.panel.is-disabled select,
.panel.is-disabled input[type="text"] {
  pointer-events: none;
  filter: grayscale(80%);
}
.panel.is-disabled input[type="checkbox"] { pointer-events: auto; }

/* fieldsetは機能的に無効化するが、見た目は変えない */
fieldset { border: 0; margin: 0; padding: 0; }
fieldset:disabled { pointer-events: none; opacity: 1; }
legend { display: none; }

/* 服カラー（固定・量産）どちらも同じ大きさに統一して枠内に収める */
#prodColorCard .panel { overflow: hidden; } /* 罫線から出さない */

#prodColorCard  .panel .wheel-box {
  display: none !important;        /* カラーホイールを非表示 */
}

/* 服（固定）3ブロックを画面幅に応じて自動折り返し */
#panel_outfitFixed .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 12px;
}

/* 服リストの縦を広げて“中身のはみ出し”を防止 */
#panel_outfitFixed .scroller { max-height: 460px; }
@media (min-width: 1600px) {
  #panel_outfitFixed .scroller { max-height: 520px; }
}

/* アクセA/B/C：セレクト→ホイール→S/L の順に縦積みで揃える */
#panelProduction .panel select + .wheel-box { margin-top: 6px; }
#panelProduction .panel .row.mini { display: block; margin-bottom: 8px; }

/* 服カラー（固定・量産）の"罫線の枠"を広げる */
#panel_outfitFixed .panel,
#prodColorCard .panel {
  overflow: visible;         /* 念のため：内側を切らない */
  box-sizing: border-box;
}

/* カラーホイールは不要になったので削除 */
#panel_outfitFixed .panel .wheel-box,
#prodColorCard  .panel .wheel-box {
  display: none;             /* カラーホイールを非表示 */
}


/* ====== フルスクリーン時の“服”はみ出し対策（外側3カラム） ====== */
/* minmaxで広がりすぎるのをやめて、frだけで必ず収まる比率にする */
@media (min-width: 1280px) {
  #grid_shape {
    display: grid;
    grid-template-columns: 1fr 1fr 1.2fr;  /* ← 3.2fr = 画面内に必ず収まる */
    gap: 16px;
    align-items: start;
  }
}
/* さらに超ワイドでも“比率のみ”で維持（はみ出さない） */
@media (min-width: 1600px) {
  #grid_shape { grid-template-columns: 1fr 1fr 1.3fr; }
}

/* パネル内の長い内容が横幅を押し広げないように */
#grid_shape > .panel { min-width: 0; }     /* 既にあればOK（再掲） */

/* ====== 服パネル内の3分割も折り返して収める ====== */
#panel_outfitFixed .grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); /* 収まらない時は自動で2列/1列へ */
  gap: 12px;
}
@media (max-width: 1280px) {
  #panel_outfitFixed .grid { grid-template-columns: repeat(2, minmax(320px, 1fr)); }
}
@media (max-width: 900px) {
  #panel_outfitFixed .grid { grid-template-columns: 1fr; }
}

/* パネルの内側からはみ出る装飾をカット（念のため） */
#panel_outfitFixed { overflow: hidden; }
#panel_outfitFixed .scroller { max-width: 100%; overflow-x: hidden; }

/* 共通の固定サイズ */
#prodColorCard .panel .wheel-box {
  display: none !important;        /* カラーホイールを非表示 */
}
#accCard .wheel-box {
  width: 180px !important;
  height: 180px !important;
  margin: 10px 0 12px !important; /* 左寄せ */
}

/* 量産モード：最初の「服（カテゴリ別）」パネルを全幅に */
@media (min-width: 1024px) {
  #panelProduction > .grid.g3 > .panel:first-child {
    grid-column: 1 / -1;   /* ← 右の空白を潰して全幅化 */
  }

  /* 中の g2 を可変カラムに（2 → 3〜5列へ広がる） */
  #panelProduction > .grid.g3 > .panel:first-child .grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  }
}

/* 基本情報の服パネルを独立段落っぽく見せる */
#panelBasic .panel.clothes-block {
  grid-column: 1 / -1;   /* 全幅 */
  margin-top: 1.5rem;    /* 髪・目から少し余白 */
}


/* 小さめラベル（例: 推奨 / enタグミニ表示） */
.mini {
  height: 1.4em;
  display: inline-flex;          /* ← これで勝つ */
  align-items: center;           /* 縦センター */
  line-height: 1;                /* ベースラインのズレを抑える */
  vertical-align: middle;        /* テキストと高さ合わせ */
  padding: 0.05em 0.45em;
  border: 1px solid var(--fg-30, #0003);
  border-radius: .6em;
  font-size: .78em;
  opacity: .8;
}

/* チップ自体も高さがブレないように（任意） */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .35em;
  line-height: 1.2;  /* 既存より大きすぎれば 1.2〜1.3 程度に */
}

/* iOS Safari だけ微調整（任意） */
@supports (-webkit-touch-callout: none) {
  .mini { transform: translateY(-0.02em); } /* ほんの少しだけ下ろす */
}

/* 学習セット生成カードまわりの被り対策 */
#learnBatchCard{
  clear: both;          /* 前のfloatを無視して独立行にする */
  margin-top: 16px;     /* 前ブロックと離す */
}

#learnBatchCard .row{
  display: flex;
  flex-wrap: wrap;      /* 横が溢れたら折り返す＝高さが潰れない */
  gap: 8px;
  align-items: center;
}

/* テーブルやテキストがはみ出して次要素に重ならないように */
#tblLearn{
  width: 100%;
  table-layout: fixed;
}
#tblLearn th, #tblLearn td{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#outLearn{
  max-height: 420px;    /* 任意：スクロールにして高さ固定 */
  overflow: auto;
}

/* パネル/グリッドの下に一定の余白を持たせる（全体の保険） */
.card > .panel,
.card > .grid { margin-bottom: 16px; }

/* 親パネルがfloat子を内包できていない場合の保険 */
.panel::after { content:""; display:block; clear:both; }

/* ========= Word Mode (単語モード) ========= */
#panelWordMode { padding: 16px 18px; color: var(--ink); }

.wm-header h2 { margin: 0 0 6px; font-size: 1.15rem; color: var(--ink); }
.wm-note { margin: 0 0 16px; opacity: .8; color: var(--ink); }

.wm-selected {
  margin: 12px 0 18px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 8px; padding: 10px;
  background: rgba(255,255,255,.03);
  color: var(--ink);
}
.wm-selected-head { display:flex; align-items:center; justify-content:space-between; gap:10px; }
.wm-selected-actions button { font-size:.85rem; padding:6px 10px; }
.wm-chip-area { display:flex; align-items:center; gap:6px; flex-wrap:wrap; margin-top:8px; }
.wm-chip {
  display:inline-flex; align-items:center; gap:6px;
  padding:4px 8px; border-radius:999px;
  border:1px solid rgba(255,255,255,.15); background:rgba(255,255,255,.06);
  font-size:.9rem; color: var(--ink);
}
.wm-chip small { opacity:.8; color: var(--muted); }
.wm-chip .x { margin-left:2px; cursor:pointer; opacity:.8; color: var(--ink); }

.wm-accordion { margin: 18px 0; }
.wm-acc-title { margin: 10px 0 6px; font-size: 1rem; opacity:.9; color: var(--ink); }

.wm-acc { border:1px solid rgba(255,255,255,.12); border-radius:8px; margin:8px 0; overflow:hidden; }
.wm-acc > summary {
  list-style:none; cursor:pointer; padding:10px 12px;
  background:rgba(255,255,255,.04); display:flex; align-items:center; justify-content:space-between;
  color: var(--ink);
}
.wm-acc[open] > summary { background:rgba(255,255,255,.07); }
.wm-acc summary::-webkit-details-marker { display:none; }
.wm-acc .wm-count { font-size:.85rem; opacity:.8; color: var(--muted); }
.wm-items {
  padding:12px; display:grid; gap:10px;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  color: var(--ink);
}
.wm-tip { margin: 6px 12px 12px; opacity:.75; font-size:.9rem; color: var(--muted); }

.wm-item {
  width:100%; text-align:left; padding:10px 12px; border-radius:10px;
  border:1px solid rgba(255,255,255,.12); background:rgba(255,255,255,.03);
  display:flex; align-items:center; justify-content:space-between; gap:8px;
  color: var(--ink);
}
.wm-item:hover { background:rgba(255,255,255,.06); }
.wm-item .wm-jp { font-size: .98rem; line-height:1.2; color: var(--ink); }
.wm-item .wm-en { font-size: .78rem; opacity:.85; display:block; color: var(--muted); }
.wm-actions { display:flex; align-items:center; gap:6px; margin-left:auto; }
.wm-actions button { font-size:.78rem; padding:4px 8px; border-radius:8px; }

.wm-item-color .wm-actions .wm-copy-both { display:none; }

.wm-table-wrap { margin-top:18px; }
.wm-table-head { display:flex; align-items:center; justify-content:space-between; gap:10px; margin-bottom:8px; }
.wm-table-actions button { padding:6px 10px; font-size:.9rem; }
.wm-table {
  width:100%; border-collapse: collapse; overflow:hidden;
  border:1px solid rgba(255,255,255,.12); border-radius:10px;
  color: var(--ink);
}
.wm-table th, .wm-table td {
  padding:10px; border-bottom:1px solid rgba(255,255,255,.08);
  color: var(--ink);
}
.wm-table thead th { background:rgba(255,255,255,.06); font-weight:600; color: var(--ink); }
.wm-row-actions { display:flex; gap:6px; }
.wm-row-actions button { padding:4px 8px; font-size:.82rem; }
.wm-table tr:last-child td { border-bottom:none; }

/* 小さめ端末 */
@media (max-width: 720px){
  .wm-items { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .wm-table th:nth-child(1), .wm-table td:nth-child(1) { width:45%; }
  .wm-table th:nth-child(2), .wm-table td:nth-child(2) { width:35%; }
}


/* === 服（固定）リストを少し低く固定 === */
:root{
  /* 好みでここだけ変えれば全体が連動 */
  --outfit-scroll-h: 200px; /* 例: 180～220pxあたりが見やすい */
}

/* 基本情報タブの服エリアだけを対象に（他モードは触らない） */
#panelBasic #panel_outfitFixed .scroller{
  max-height: var(--outfit-scroll-h);
  overflow: auto;
}

/* 余白を少しだけ締める（任意） */
#panelBasic #panel_outfitFixed .panel h4{
  margin-bottom: 4px;
}
#panelBasic #panel_outfitFixed .scroller{
  padding-right: 4px; /* スクロールバー分の見切れ軽減 */
}

/* iPad/横幅狭い時はさらに低め（任意） */
@media (max-width: 1024px){
  :root{ --outfit-scroll-h: 180px; }
}

/* 漫画モード用CSS追加スタイル - styles.cssの末尾に追加してください */

/* 漫画モード統一スタイル */
.manga-mode-header {
  margin-bottom: 20px;
}

.manga-priority-note {
  font-size: 0.9em;
  color: var(--muted);
  margin-top: 8px;
}

.manga-params-section {
  margin-bottom: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.manga-section-divider {
  height: 1px;
  background: var(--line);
  margin: 20px 0;
}

/* チェックボックス統一スタイル */
.manga-params-section .row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.manga-params-section .inline {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9em;
  cursor: pointer;
}

.manga-params-section .inline input[type="checkbox"] {
  margin: 0;
}

/* 任意項目のスタイル */
.manga-optional-section {
  margin-top: 16px;
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.01);
}

/* 重み調整スライダー */
.lora-weight-control {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.lora-weight-control input[type="range"] {
  flex: 1;
  max-width: 120px;
}

.weight-value {
  font-family: monospace;
  font-size: 0.9em;
  min-width: 30px;
  text-align: center;
}

/* 2人目キャラ設定 */
.second-char-content {
  margin-top: 12px;
}

.second-char-io {
  background: rgba(255, 255, 255, 0.03);
}

.second-char-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 8px;
}

.second-char-colors {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.color-picker-item {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
}

/* 出力エリア */
.manga-output {
  margin-top: 24px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.02);
}

.conflict-warning {
  background: rgba(255, 193, 7, 0.1);
  border: 1px solid rgba(255, 193, 7, 0.3);
  color: rgba(255, 193, 7, 1);
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 12px;
}

/* ボタンとコントロールの統一 */
.manga-params-section button {
  font-size: 0.9em;
}

.manga-params-section select {
  font-size: 0.9em;
}

/* グリッドレスポンシブ調整 */
@media (max-width: 768px) {
  .manga-params-section .grid.g2 {
    grid-template-columns: 1fr;
  }
  
  .manga-params-section .grid.g3 {
    grid-template-columns: 1fr;
  }
  
  .second-char-grid {
    grid-template-columns: 1fr;
  }
  
  .second-char-colors {
    grid-template-columns: 1fr;
  }
}

/* ============================================ */
/* 漫画モードプリセットボタン 小サイズ専用CSS */
/* ============================================ */

/* 🎯 プリセットボタンのサイズ調整のみ */
.preset-btn {
  padding: 4px 8px !important;        /* 元: 6px 12px */
  border-radius: 4px !important;      /* 元: 6px */
  font-size: 10px !important;         /* 元: 12px */
  min-width: 50px !important;         /* 元: 60px */
}

/* ホバー効果も調整 */
.preset-btn:hover {
  transform: translateY(-1px) !important;  /* 元: -1px（維持） */
}

/* モバイル対応（さらに小さく） */
@media (max-width: 768px) {
  .preset-btn {
    padding: 3px 8px !important;      /* モバイルも中間サイズ */
    font-size: 10px !important;
    min-width: 45px !important;
    line-height: 1.2 !important;
  }
}

/* プリセット詳細表示 */
.preset-details {
  background: rgba(0,0,0,0.1);
  border-radius: 8px;
  padding: 15px;
  margin: 15px 0;
  border: 1px solid rgba(255,255,255,0.1);
}

.preset-details-header {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 10px;
  color: rgba(255,255,255,0.9);
}

.preset-details-content {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  line-height: 1.4;
}

.preset-tag {
    display: inline-block;
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
    margin: 1px;
    font-size: 10px;
    color: #555;
    border: 1px solid rgba(0, 0, 0, 0.1);
}






/* 単語モード検索機能用CSS - styles.cssに追加 */

/* 検索エリア */
.wm-search {
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(100, 150, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(100, 150, 255, 0.2);
}

.wm-search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.wm-search-input {
  flex: 1;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.wm-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(100, 150, 255, 0.2);
}

.wm-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.wm-search-clear:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.wm-search-stats {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
}

/* 検索結果での非表示アイテム */
.wm-item.wm-hidden {
  display: none !important;
}

/* 検索結果がないカテゴリ */
.wm-acc.wm-no-results {
  opacity: 0.5;
}

.wm-acc.wm-no-results > summary {
  color: var(--text-muted);
}

/* 選択中チップエリア */
.wm-selected {
  background: rgba(100, 200, 100, 0.05);
  border: 1px solid rgba(100, 200, 100, 0.2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.wm-selected-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.wm-selected-actions button {
  background: var(--accent-bad);
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.wm-selected-actions button:hover {
  opacity: 0.8;
}

.wm-chip-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
}

.wm-selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: white;
  padding: 4px 8px;
  border-radius: 16px;
  font-size: 12px;
}

.wm-selected-chip button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.wm-selected-chip button:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* テーブルアクション */
.wm-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.wm-table-actions {
  display: flex;
  gap: 8px;
}

.wm-table-actions button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.wm-table-actions button:hover {
  opacity: 0.8;
}

.wm-table-actions button:last-child {
  background: var(--accent-bad);
}

/* カテゴリカウント */
.wm-count {
  font-size: 11px;
  color: var(--text-muted);
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

/* 単語モード専用スタイル - HTMLのheadセクションまたは適切な場所に追加 */
.wm-hidden {
  display: none !important;
}

.wm-no-results {
  opacity: 0.5;
}

.wm-no-results > summary {
  color: #666;
}

.wm-search {
  margin-bottom: 16px;
  padding: 12px;
  background: rgba(100, 150, 255, 0.05);
  border-radius: 8px;
  border: 1px solid rgba(100, 150, 255, 0.2);
}

.wm-search-container {
  position: relative;
  display: flex;
  align-items: center;
}

.wm-search-input {
  flex: 1;
  padding: 8px 32px 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.wm-search-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(100, 150, 255, 0.2);
}

.wm-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #999;
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  line-height: 1;
}

.wm-search-clear:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text);
}

.wm-search-stats {
  margin-top: 8px;
  font-size: 12px;
  color: #999;
  text-align: center;
}

.wm-selected {
  background: rgba(100, 200, 100, 0.05);
  border: 1px solid rgba(100, 200, 100, 0.2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 16px;
}

.wm-selected-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.wm-selected-actions button {
  background: #dc3545;
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.wm-selected-actions button:hover {
  opacity: 0.8;
}

.wm-chip-area {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 32px;
  align-items: flex-start;
}

.wm-selected-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--accent);
  color: white;
  padding: 4px 8px;
  border-radius: 16px;
  font-size: 12px;
}

.wm-selected-chip small {
  opacity: 0.8;
  margin-left: 2px;
}

.wm-selected-chip button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 0;
  margin-left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
}

.wm-selected-chip button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.wm-table-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.wm-table-actions {
  display: flex;
  gap: 8px;
}

.wm-table-actions button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}

.wm-table-actions button:hover {
  opacity: 0.8;
}

.wm-table-actions button:last-child {
  background: #dc3545;
}

.wm-count {
  font-size: 11px;
  color: #999;
  background: rgba(255, 255, 255, 0.1);
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 4px;
}

.wm-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
}

.wm-table th,
.wm-table td {
  padding: 8px;
  text-align: left;
  border-bottom: 1px solid var(--line);
}

.wm-table th {
  background: rgba(100, 150, 255, 0.1);
  font-weight: bold;
}

.wm-row-actions {
  display: flex;
  gap: 4px;
}

.wm-row-actions button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 4px 8px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 10px;
}

.wm-row-actions button:hover {
  opacity: 0.8;
}

.wm-row-actions button:last-child {
  background: #dc3545;
}

.wm-items {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.wm-item {
  display: flex;
  flex-direction: column;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--card-bg);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

.wm-item:hover {
  background: rgba(100, 150, 255, 0.1);
  border-color: var(--accent);
}

.wm-jp {
  font-weight: bold;
  margin-bottom: 2px;
}

.wm-en {
  font-size: 11px;
  color: #999;
  opacity: 0.8;
}

.wm-actions {
  position: absolute;
  top: 4px;
  right: 4px;
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.wm-item:hover .wm-actions {
  opacity: 1;
}

.wm-actions button {
  background: var(--accent);
  color: white;
  border: none;
  padding: 2px 4px;
  border-radius: 3px;
  cursor: pointer;
  font-size: 9px;
  line-height: 1;
}

.wm-actions button:hover {
  opacity: 0.8;
}

.wm-acc-title {
  margin: 16px 0 8px 0;
  padding: 8px 0;
  border-bottom: 2px solid var(--accent);
  color: var(--accent);
}




/* 商用LoRA用のスタイル */
.commercial-lora-grid {
  max-height: 400px;
  overflow-y: auto;
}

.lora-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg-card);
  transition: all 0.2s ease;
}

.lora-item:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.lora-item.selected {
  border-color: var(--accent-ok);
  background: rgba(34, 197, 94, 0.05);
}

.lora-item-header {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 8px;
}

.lora-checkbox {
  margin-top: 2px;
}

.lora-info {
  flex: 1;
}

.lora-title {
  font-weight: 600;
  margin: 0 0 4px 0;
  color: var(--text);
}

.lora-description {
  font-size: 12px;
  color: var(--text-dim);
  margin: 0 0 8px 0;
}

.lora-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.lora-weight-control {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
}

.lora-weight-slider {
  flex: 1;
  min-width: 80px;
}

.lora-tag-display {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: var(--text-dim);
  background: rgba(0,0,0,0.1);
  padding: 2px 6px;
  border-radius: 3px;
  word-break: break-all;
}

.lora-tab-btn {
  padding: 6px 12px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.2s ease;
}

.lora-tab-btn:hover {
  background: var(--bg-hover);
}

.lora-tab-btn.active {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

.lora-category-badge {
  display: inline-block;
  padding: 2px 6px;
  background: var(--accent);
  color: white;
  font-size: 10px;
  border-radius: 3px;
  margin-left: 8px;
}



<!-- ================================ -->
<!-- CSS追加コード -->
<!-- ================================ -->
/* styles.cssに追加 */
/* 漫画モード専用の検索スタイル */
.manga-search {
  margin: 12px 0;
  padding: 12px;
  background: rgba(100, 150, 255, 0.1);
  border-radius: 8px;
}

.manga-search-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.manga-search-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.manga-search-input:focus {
  outline: none;
  border-color: var(--accent-ok);
  box-shadow: 0 0 0 2px rgba(100, 150, 255, 0.2);
}

.manga-search-clear {
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-light);
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  min-width: 60px;
}

.manga-search-clear:hover {
  background: var(--bg-hover);
}

.manga-search-stats {
  font-size: 12px;
  color: var(--text-muted);
  text-align: right;
}

/* 🆕 検索結果表示エリア */
.manga-search-results {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  max-height: 300px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.manga-search-results-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg-light);
  border-bottom: 1px solid var(--line);
}

.manga-search-results-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.manga-results-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
}

.manga-results-close:hover {
  background: rgba(255, 100, 100, 0.1);
  color: var(--accent-bad);
}

.manga-search-results-content {
  max-height: 240px;
  overflow-y: auto;
  padding: 8px;
}

/* 検索結果の選択肢アイテム */
.manga-result-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  margin-bottom: 4px;
  border-radius: 6px;
  background: var(--bg);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.manga-result-item:hover {
  background: var(--bg-hover);
  border-color: var(--accent-ok);
}

.manga-result-item.selected {
  background: rgba(100, 150, 255, 0.1);
  border-color: var(--accent-ok);
}

.manga-result-item input[type="radio"],
.manga-result-item input[type="checkbox"] {
  margin: 0;
}

.manga-result-item-label {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.manga-result-item-main {
  font-size: 14px;
  color: var(--text);
}

.manga-result-item-category {
  font-size: 12px;
  color: var(--text-muted);
}

.manga-result-item-tag {
  font-size: 11px;
  color: var(--text-muted);
  font-family: monospace;
  background: rgba(100, 150, 255, 0.1);
  padding: 1px 4px;
  border-radius: 3px;
}

/* 検索ハイライト */
.manga-search-highlight {
  background-color: rgba(255, 255, 0, 0.3);
  padding: 1px 2px;
  border-radius: 2px;
}


/* 量産モード専用CSS */
.production-guide {
  background: rgba(59, 130, 246, 0.1);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 20px;
}

.guide-content {
  margin-top: 12px;
}

.guide-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.guide-card {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 6px;
  padding: 12px;
}

.guide-card h4 {
  margin: 0 0 8px 0;
  color: var(--accent-ok);
}

.guide-card ul {
  margin: 0;
  padding-left: 20px;
}

.vary { color: #f59e0b; font-weight: bold; }
.fixed { color: #10b981; font-weight: bold; }

.production-presets {
  margin-bottom: 20px;
}

.preset-buttons {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-top: 12px;
}


.preset-btn.active {
  border-color: var(--accent-ok);
  background: rgba(34, 197, 94, 0.1);
}

.production-status {
  margin: 20px 0;
}

.status-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}

.status-card {
  background: var(--bg-secondary);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 12px;
}

.status-card h4 {
  margin: 0 0 8px 0;
  font-size: 14px;
}

.status-content {
  font-size: 12px;
  color: var(--text-muted);
  min-height: 20px;
}

.production-details {
  margin-top: 20px;
}

.production-section {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg-card);
}

.production-section summary {
  padding: 12px 16px;
  cursor: pointer;
  font-weight: 500;
  border-bottom: 1px solid transparent;
}

.production-section[open] summary {
  border-bottom-color: var(--line);
}

.section-content {
  padding: 16px;
}

.clothing-mode,
.expression-mode {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
}

.mode-card {
  border: 2px solid var(--line);
  border-radius: 6px;
  padding: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: block;
}

.mode-card:hover {
  border-color: var(--accent-ok);
}

.mode-card input[type="radio"] {
  display: none;
}

.mode-card input[type="radio"]:checked + .mode-content {
  border-left: 3px solid var(--accent-ok);
  padding-left: 12px;
}

.mode-content h4 {
  margin: 0 0 4px 0;
}

.mode-content p {
  margin: 0;
  font-size: 12px;
  color: var(--text-muted);
}

.production-generate {
  margin: 20px 0;
  padding: 16px;
  background: rgba(34, 197, 94, 0.1);
  border-radius: 8px;
  border: 1px solid rgba(34, 197, 94, 0.2);
}

.btn.large {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: 600;
}

.production-output {
  margin-top: 20px;
}

.caret {
  transition: transform 0.2s ease;
}

details[open] .caret {
  transform: rotate(90deg);
}

/* ========================
   モーダルスタイル
   ======================== */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0, 0, 0, 0.75);
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-content {
  background: var(--panel);
  border-radius: 12px;
  border: 1px solid var(--line);
  width: 90%;
  max-width: 600px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-header h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.25rem;
}

.modal-close {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: all 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

.modal-body {
  padding: 24px;
  color: var(--ink);
  line-height: 1.6;
}

.modal-body h3 {
  margin-top: 20px;
  margin-bottom: 12px;
  font-size: 1.1rem;
}

.modal-body ul {
  margin: 8px 0;
  padding-left: 24px;
}

.modal-body li {
  margin: 8px 0;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

@media (max-width: 640px) {
  .modal-content {
    width: 95%;
    margin: 10px;
  }
  
  .modal-header,
  .modal-body,
  .modal-footer {
    padding: 16px;
  }
}
