/* ========================================
   diagnosis/style.css - AI診断ページ
   3ペイン: 左サイドバー | 中央エディタ | 右結果
   全て 100vh 内に収める（スクロール不要）
   ======================================== */

/* --- サイトコンテナ上書き --- */
body:has(.diag-page) .site-footer { display: none; }
body:has(.diag-page) .site-main  { padding: 0; max-width: 100%; }

/* --- ページ全体: 3ペイン横並び --- */
.diag-page {
  display: flex;
  height: calc(100vh - 56px);
  overflow: hidden;
}

/* ========================================
   サイドバー共通 — 閉じるボタン
   ======================================== */
.side-close {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 10;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,0.08);
  color: #9c9080;
  font-size: 0.85rem;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.side-close:hover { background: rgba(255,255,255,0.15); color: #e74c3c; }

/* ========================================
   左サイドバー
   ======================================== */
.side-left {
  width: 260px;
  min-width: 260px;
  background: #1e1a16;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #2e2922;
  flex-shrink: 0;
  position: relative;
}

/* --- サイドバータブ --- */
.side-tabs {
  display: flex;
  border-bottom: 2px solid #2e2922;
  flex-shrink: 0;
}

.side-tab {
  flex: 1;
  padding: 10px 8px;
  background: #1e1a16;
  border: none;
  color: #7a7060;
  font-size: 0.75rem;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}

.side-tab:hover { color: #ccc4b8; }

.side-tab.active {
  background: #2a2520;
  color: #e8c97a;
  border-bottom: 2px solid #e8c97a;
  margin-bottom: -2px;
}

/* --- タブコンテンツ --- */
.side-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
  scrollbar-color: #3a342d #1e1a16;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.sb-section { margin-bottom: 18px; }

.sb-label {
  display: block;
  color: #9c9080;
  font-size: 0.7rem;
  font-weight: bold;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 8px;
}

/* --- プラットフォーム選択 --- */
.sb-platform {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sb-radio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #9c9080;
  font-size: 0.82rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  border: 1.5px solid transparent;
}

.sb-radio input { display: none; }
.sb-radio:hover { background: rgba(255,255,255,0.04); color: #ccc4b8; }

.sb-radio.selected {
  background: rgba(232,201,122,0.1);
  color: #e8c97a;
  border-color: rgba(232,201,122,0.3);
  font-weight: bold;
}

/* --- ジャンル選択 --- */
.sb-genre {
  width: 100%;
  padding: 8px 10px;
  border: 1.5px solid #3a342d;
  border-radius: 6px;
  font-size: 0.82rem;
  color: #e8e0d0;
  background: #2a2520;
  cursor: pointer;
}

.sb-genre:focus { outline: 2px solid #e8c97a; outline-offset: 1px; }

/* --- カード追加ボタン --- */
.sb-add-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px;
  background: linear-gradient(135deg, #e8c97a, #d4b260);
  color: #1a1612;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.15s;
}

.sb-add-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(232,201,122,0.4);
}

.sb-add-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.sb-count { font-size: 0.72rem; opacity: 0.7; }

/* --- プロジェクトタブ --- */
.sb-row {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.sb-small-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 8px;
  border: 1px solid #3a342d;
  border-radius: 6px;
  background: #2a2520;
  color: #ccc4b8;
  font-size: 0.72rem;
  cursor: pointer;
  transition: background 0.15s;
}

.sb-small-btn:hover { background: #3a342d; color: #e8c97a; }
.sb-small-btn.sb-danger:hover { color: #e74c3c; }
.sb-small-btn:disabled { opacity: 0.3; cursor: not-allowed; }

.sb-login-msg {
  color: #7a7060;
  font-size: 0.78rem;
  text-align: center;
  padding: 20px 8px;
  line-height: 1.6;
}

.sb-login-msg i { color: #e8c97a; display: block; font-size: 1.2rem; margin-bottom: 8px; }

/* --- プロジェクト説明 --- */
.pj-about-text {
  font-size: 0.72rem;
  color: #9c9080;
  line-height: 1.6;
  padding: 8px 10px;
  background: rgba(232,201,122,0.08);
  border-radius: 8px;
  border: 1px solid rgba(232,201,122,0.15);
}
.pj-about-text i { color: #e8c97a; margin-right: 4px; }

/* --- プロジェクトセレクター --- */
.pj-selector {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  margin-bottom: 8px;
}

.pj-selector-btn {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #2a2520;
  border: 1.5px solid #3a342d;
  border-radius: 8px;
  color: #ccc4b8;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  min-width: 0;
}
.pj-selector-btn:hover { background: #332e28; border-color: #5a5248; }
.pj-selector-btn.has-project { border-color: #e8c97a; }

.pj-sel-icon { color: #7a7060; font-size: 0.95rem; flex-shrink: 0; }
.pj-selector-btn.has-project .pj-sel-icon { color: #e8c97a; }

.pj-sel-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.pj-sel-caret { color: #7a7060; font-size: 0.7rem; flex-shrink: 0; }

.pj-add-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  background: #2a2520;
  border: 1px solid #3a342d;
  border-radius: 8px;
  color: #e8c97a;
  font-size: 1.1rem;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
.pj-add-btn:hover { background: #3a342d; transform: scale(1.05); }

/* --- プロジェクトドロップダウン --- */
.pj-dropdown {
  margin: 0 12px 8px;
  background: #1e1a16;
  border: 1px solid #3a342d;
  border-radius: 8px;
  overflow: hidden;
  animation: fadeIn 0.15s ease;
}
.pj-dropdown[hidden] { display: none; }

.pj-dropdown-list {
  max-height: 240px;
  overflow-y: auto;
}

.pj-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 14px;
  background: transparent;
  border: none;
  border-bottom: 1px solid #2a2520;
  color: #ccc4b8;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.12s;
}
.pj-item:last-child { border-bottom: none; }
.pj-item:hover { background: #2a2520; }
.pj-item.active {
  background: rgba(232,201,122,0.1);
  color: #f0e6c8;
}

.pj-item .pj-icon {
  font-size: 1rem;
  color: #7a7060;
  flex-shrink: 0;
}
.pj-item.active .pj-icon { color: #e8c97a; }

.pj-item .pj-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
  text-align: left;
}

.pj-item .pj-count {
  font-size: 0.7rem;
  color: #7a7060;
  flex-shrink: 0;
}

.pj-empty {
  text-align: center;
  color: #7a7060;
  font-size: 0.78rem;
  padding: 20px 12px;
  line-height: 1.6;
}
.pj-empty i { display: block; font-size: 1.2rem; margin-bottom: 6px; color: #5a5248; }

/* --- 選択中プロジェクトヘッダ --- */
.pj-selected-section {
  margin-top: 8px;
}

.pj-selected-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(232,201,122,0.08);
  border-radius: 8px;
  margin-bottom: 8px;
}

.pj-selected-name {
  flex: 1;
  font-size: 0.82rem;
  font-weight: bold;
  color: #e8c97a;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pj-selected-name i { margin-right: 6px; }

.pj-del-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #7a7060;
  font-size: 0.82rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
  flex-shrink: 0;
}
.pj-del-btn:hover { color: #e74c3c; background: rgba(231,76,60,0.1); }

/* --- 保存アイデア一覧 --- */
.saved-ideas {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.saved-ideas:empty::after {
  content: 'カードの「保存」ボタンでアイデアを保存できます';
  display: block;
  text-align: center;
  font-size: 0.72rem;
  color: #7a7060;
  padding: 12px 8px;
}

.saved-idea-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: #2a2520;
  border-radius: 8px;
  font-size: 0.78rem;
  color: #ccc4b8;
  cursor: default;
  border: 1px solid #3a342d;
  transition: background 0.12s;
}
.saved-idea-chip:hover { background: #332e28; }

.saved-idea-chip .idea-rank { font-weight: bold; color: #e8c97a; flex-shrink: 0; font-size: 0.75rem; }

.saved-idea-chip .idea-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-idea-chip .btn-idea-load {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: 1px solid #3a342d;
  border-radius: 6px;
  color: #9c9080;
  cursor: pointer;
  font-size: 0.78rem;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.saved-idea-chip .btn-idea-load:hover { color: #3498db; background: rgba(52,152,219,0.1); }

.saved-idea-chip .btn-idea-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: none;
  border: 1px solid transparent;
  border-radius: 6px;
  color: #7a7060;
  cursor: pointer;
  font-size: 0.72rem;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.saved-idea-chip .btn-idea-del:hover { color: #e74c3c; background: rgba(231,76,60,0.08); }

/* ========================================
   中央エリア
   ======================================== */
.center-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #f8f7f4;
}

/* --- カードタブバー --- */
.card-tabs {
  display: flex;
  align-items: center;
  padding: 0 16px;
  background: #eae6de;
  border-bottom: 1px solid #ddd6ca;
  flex-shrink: 0;
  height: 42px;
  gap: 4px;
}

.card-tabs-list {
  display: flex;
  gap: 2px;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
}

.tab-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.card-tab {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: transparent;
  border: none;
  border-radius: 8px 8px 0 0;
  color: #9c9080;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
  position: relative;
}

.card-tab:hover { background: rgba(255,255,255,0.5); color: #2d2926; }

.card-tab.active {
  background: #f8f7f4;
  color: #1a1612;
  font-weight: bold;
  box-shadow: 0 -2px 0 #e8c97a inset;
}

.card-tab.diagnosed { color: #27ae60; }
.card-tab.diagnosed.active { box-shadow: 0 -2px 0 #27ae60 inset; }

.card-tab .tab-badge {
  font-size: 0.65rem;
  font-weight: bold;
  color: #1a1612;
  background: #e8c97a;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-tab .tab-label {
  font-size: 0.72rem;
  color: inherit;
  max-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-tab .tab-close {
  background: none;
  border: none;
  color: #c0b8ac;
  font-size: 0.6rem;
  cursor: pointer;
  padding: 4px 6px;
  display: none;
  margin-left: 2px;
  border-radius: 4px;
}
.card-tab .tab-close:hover { color: #fff; background: #e74c3c; }

.card-tab:hover .tab-close,
.card-tab.active .tab-close { display: inline-flex; }

/* --- モバイル前後ナビ --- */
.mobile-tab-nav {
  display: none;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.mobile-tab-nav .nav-arrow {
  background: none;
  border: none;
  color: #9c9080;
  font-size: 1rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  flex-shrink: 0;
}
.mobile-tab-nav .nav-arrow:hover { background: rgba(0,0,0,0.06); color: #1a1612; }
.mobile-tab-nav .nav-arrow:disabled { opacity: 0.3; cursor: default; }

.mobile-tab-nav .nav-center {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  transition: background 0.12s;
}
.mobile-tab-nav .nav-center:hover,
.mobile-tab-nav .nav-center:active { background: rgba(0,0,0,0.06); }

.mobile-tab-nav .nav-counter {
  font-size: 0.8rem;
  font-weight: bold;
  color: #1a1612;
  flex-shrink: 0;
}

.mobile-tab-nav .nav-title {
  font-size: 0.82rem;
  color: #5a5248;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
}

.mobile-tab-nav .nav-caret {
  font-size: 0.7rem;
  color: #9c9080;
  flex-shrink: 0;
}

/* --- ヘルプボタン（タブバー内） --- */
.btn-help-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #9c9080;
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.btn-help-small:hover { color: #e8c97a; background: rgba(232,201,122,0.1); }

/* --- 診断実行ボタン --- */
.btn-run {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  background: linear-gradient(135deg, #27ae60, #219a52);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.12s, box-shadow 0.15s;
  flex-shrink: 0;
}

.btn-run:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 3px 12px rgba(39,174,96,0.4);
}

.btn-run:disabled { opacity: 0.4; cursor: not-allowed; }

/* --- エディタ本体 --- */
.editor-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  overflow: hidden;
}

/* --- カードパネル --- */
.card-panel {
  display: none;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  animation: fadeIn 0.2s ease;
}

.card-panel.active { display: flex; }

.card-panel.diagnosed {
  opacity: 0.55;
  pointer-events: auto;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.card-panel-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.cp-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: bold;
}

.cp-platform-badge {
  background: rgba(232,201,122,0.15);
  color: #a08330;
  border: 1px solid rgba(232,201,122,0.3);
}

.cp-genre-badge {
  background: #f0ede6;
  color: #7a7060;
}

.cp-save-btn {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  background: linear-gradient(135deg, #e8c97a, #d4b260);
  color: #1a1612;
  border: none;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.12s;
}

.cp-save-btn:hover { transform: translateY(-1px); }
.cp-save-btn[hidden] { display: none; }

.cp-del-btn {
  display: inline-flex;
  align-items: center;
  padding: 5px 8px;
  background: none;
  color: #c0b8ac;
  border: 1px solid transparent;
  border-radius: 6px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}
.cp-del-btn:hover { color: #e74c3c; background: rgba(231,76,60,0.08); }

/* --- 入力フィールド --- */
.card-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  min-height: 0;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.field-group:last-child { flex: 1; }
.field-group-grow { flex: 1; }

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  font-weight: bold;
  color: #9c9080;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.field-charcount {
  font-size: 0.65rem;
  font-weight: normal;
  color: #c0b8ac;
  letter-spacing: 0;
  text-transform: none;
}

.field-charcount.near-limit { color: #e67e22; }
.field-charcount.at-limit   { color: #e74c3c; font-weight: bold; }

.diag-field {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #ede9e0;
  border-radius: 8px;
  font-size: 0.9rem;
  color: #2d2926;
  background: #fff;
  font-family: inherit;
  line-height: 1.6;
  transition: border-color 0.15s, box-shadow 0.15s;
  resize: none;
}

.diag-field:focus {
  outline: none;
  border-color: #e8c97a;
  box-shadow: 0 0 0 3px rgba(232,201,122,0.12);
}

.diag-field.field-title {
  resize: none;
  overflow: hidden;
  min-height: 0;
  line-height: 1.5;
}

.diag-field.field-story {
  flex: 1;
  min-height: 80px;
}

.diag-field.field-comment {
  min-height: 0;
}

.card-panel.diagnosed .diag-field {
  background: #f4f0e8;
  color: #6a5e50;
}

/* ========================================
   右サイドバー（結果）
   ======================================== */
.side-right {
  width: 280px;
  min-width: 280px;
  background: #fff;
  border-left: 1px solid #ede9e0;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

.sr-header {
  padding: 10px 16px;
  background: linear-gradient(135deg, #1a1612, #2e2922);
  color: #e8c97a;
  font-size: 0.8rem;
  font-weight: bold;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 42px;
}

.sr-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  scrollbar-width: thin;
}

.sr-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  height: 100%;
  color: #c0b8ac;
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.6;
}

.sr-empty i { font-size: 1.5rem; opacity: 0.4; }

/* --- 結果カード --- */
.sr-section-title {
  font-size: 0.72rem;
  font-weight: bold;
  color: #e8c97a;
  padding: 6px 0 8px;
  margin-top: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.sr-section-title:first-child { margin-top: 0; }
.sr-section-best { color: #e67e22; }

.result-card {
  padding: 14px 16px;
  margin-bottom: 12px;
  background: #faf9f6;
  border-radius: 10px;
  border: 1px solid #ede9e0;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.result-card:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.08); }

.result-card-best {
  background: #fdf9f0;
  border-color: #e8d8b0;
}

.result-card-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  padding-bottom: 10px;
  border-bottom: 1px solid #ede9e0;
}

.result-card-num {
  width: 24px;
  height: 24px;
  font-size: 0.72rem;
  font-weight: bold;
  color: #1a1612;
  background: #e8c97a;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.result-card-name {
  font-size: 0.78rem;
  font-weight: bold;
  color: #2d2926;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

.rc-tweet-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #000;
  color: #fff;
  font-size: 0.68rem;
  font-weight: 600;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.15s, opacity 0.15s;
}
.rc-tweet-btn:hover { background: #222; opacity: 0.9; }

.rc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
}
.rc-item + .rc-item { border-top: 1px solid rgba(0,0,0,0.05); }

.rc-label {
  font-size: 0.72rem;
  font-weight: bold;
  color: #9c9080;
  width: 54px;
  flex-shrink: 0;
}

.rc-score {
  font-size: 1.6rem;
  font-weight: bold;
  color: #1a1612;
  line-height: 1;
  min-width: 48px;
}
.rc-unit {
  font-size: 0.65rem;
  font-weight: normal;
  color: #9c9080;
  margin-left: 2px;
}

.rc-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: bold;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  color: #fff;
  flex-shrink: 0;
}

.rank-s { background: linear-gradient(135deg, #d4a732, #f5d990, #d4a732); color: #1a1612; box-shadow: 0 0 12px rgba(232,201,122,0.5); animation: rankGlow 1.5s ease-in-out infinite alternate; }
.rank-a { background: linear-gradient(135deg, #f0b429, #e8a020); }
.rank-b { background: linear-gradient(135deg, #2ecc71, #27ae60); }
.rank-c { background: linear-gradient(135deg, #3498db, #2980b9); }
.rank-d { background: linear-gradient(135deg, #e67e22, #d35400); }
.rank-e { background: linear-gradient(135deg, #e74c3c, #c0392b); }

@keyframes rankGlow {
  from { box-shadow: 0 0 8px rgba(232,201,122,0.4); }
  to   { box-shadow: 0 0 18px rgba(232,201,122,0.7); }
}

.result-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #9c9080;
  font-size: 0.78rem;
  padding: 20px 0;
}

.result-error {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #e74c3c;
  font-size: 0.72rem;
  padding: 8px 0;
}

/* ========================================
   空状態 — オンボーディング
   ======================================== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  flex: 1;
  color: #7a7060;
  text-align: center;
}

.empty-icon {
  width: 72px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(232,201,122,0.12);
  border-radius: 50%;
  font-size: 2rem;
  color: #e8c97a;
}

.empty-title {
  font-size: 1.05rem;
  font-weight: bold;
  color: #2d2926;
  margin: 0;
}

.onboard-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
  max-width: 340px;
}

.onboard-step {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.85rem;
  color: #6a5e50;
  line-height: 1.5;
}

.onboard-num {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #e8c97a;
  color: #1a1612;
  font-weight: bold;
  font-size: 0.75rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.onboard-step i { color: #e8c97a; }

/* ========================================
   ヘルプモーダル
   ======================================== */
.help-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.help-overlay[hidden] { display: none; }

.help-modal {
  background: #fff;
  border-radius: 14px;
  width: 90%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #ede9e0;
  font-weight: bold;
  font-size: 0.95rem;
  color: #1a1612;
}

.help-header i { color: #e8c97a; margin-right: 4px; }

.help-close {
  background: none;
  border: none;
  font-size: 1.1rem;
  color: #9c9080;
  cursor: pointer;
  padding: 4px;
}
.help-close:hover { color: #e74c3c; }

.help-body {
  padding: 16px 20px;
  overflow-y: auto;
  scrollbar-width: thin;
}

.help-section { margin-bottom: 20px; }
.help-section:last-child { margin-bottom: 0; }

.help-section h4 {
  font-size: 0.85rem;
  color: #1a1612;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.help-section h4 i { color: #e8c97a; font-size: 0.9rem; }

.help-section ol {
  margin: 0;
  padding-left: 22px;
  font-size: 0.82rem;
  color: #4a4540;
  line-height: 1.8;
}

.help-section p {
  margin: 0;
  font-size: 0.82rem;
  color: #4a4540;
  line-height: 1.7;
}

.help-ranks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}

.help-ranks .rg {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #4a4540;
  font-size: 0.78rem;
  padding: 4px 10px;
  background: #f8f7f4;
  border-radius: 6px;
  border: 1px solid #ede9e0;
}

/* ========================================
   オーバーレイ（パネル背景）
   ======================================== */
.side-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
}
.side-overlay.active { display: block; }

/* ========================================
   カード一覧ドロワー
   ======================================== */
.card-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 400;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}
.card-drawer-overlay[hidden] { display: none; }

.card-drawer {
  width: 100%;
  max-width: 420px;
  max-height: 60vh;
  background: #faf9f6;
  border-radius: 16px 16px 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: drawerSlideUp 0.25s ease;
}

@keyframes drawerSlideUp {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}

.card-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  font-size: 0.88rem;
  font-weight: bold;
  color: #1a1612;
  border-bottom: 1px solid #ede9e0;
  flex-shrink: 0;
}

.card-drawer-close {
  background: none;
  border: none;
  font-size: 1rem;
  color: #9c9080;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
}
.card-drawer-close:hover { background: rgba(0,0,0,0.06); }

.card-drawer-list {
  overflow-y: auto;
  padding: 8px 0;
}

.card-drawer-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  border: none;
  background: transparent;
  width: 100%;
  cursor: pointer;
  font-size: 0.82rem;
  color: #2d2926;
  text-align: left;
  transition: background 0.12s;
}
.card-drawer-item:hover { background: rgba(232,201,122,0.12); }
.card-drawer-item.active { background: rgba(232,201,122,0.2); font-weight: bold; }
.card-drawer-item.diagnosed { color: #27ae60; }

.card-drawer-item .drawer-badge {
  font-size: 0.65rem;
  font-weight: bold;
  color: #1a1612;
  background: #e8c97a;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.card-drawer-item .drawer-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-drawer-item .drawer-status {
  font-size: 0.7rem;
  color: #9c9080;
  flex-shrink: 0;
}

/* ========================================
   モバイル底部バー
   ======================================== */
.mobile-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1e1a16;
  border-top: 2px solid #e8c97a;
  padding: 6px 12px;
  gap: 8px;
  z-index: 300;
}

.mb-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px;
  background: #2a2520;
  border: 1px solid #3a342d;
  border-radius: 8px;
  color: #9c9080;
  font-size: 0.75rem;
  cursor: pointer;
}

.mb-btn:hover { color: #e8c97a; }

#mobile-help-btn { flex: 0; padding: 8px 12px; }

.mb-primary {
  background: linear-gradient(135deg, #27ae60, #219a52);
  color: #fff;
  border-color: #27ae60;
}

.mb-primary:disabled { opacity: 0.4; }

/* ========================================
   トースト通知
   ======================================== */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  padding: 10px 22px;
  border-radius: 8px;
  font-size: 0.82rem;
  font-weight: bold;
  z-index: 9999;
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.toast.toast-success { background: #27ae60; color: #fff; }
.toast.toast-error   { background: #e74c3c; color: #fff; }
.toast.toast-info    { background: #1a1612; color: #e8c97a; }

/* ========================================
   Sランクおめでとうモーダル
   ======================================== */
.srank-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 9100;
  background: rgba(5, 4, 3, 0.75);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: srank-fadein 0.25s ease;
}
.srank-modal-overlay[hidden] { display: none; }

@keyframes srank-fadein {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.srank-modal {
  background: linear-gradient(160deg, #1e1b14 0%, #17140e 100%);
  border: 1px solid #c8a840;
  border-radius: 20px;
  padding: 36px 28px 28px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  position: relative;
  box-shadow: 0 0 40px rgba(232, 201, 122, 0.18), 0 12px 40px rgba(0,0,0,0.6);
  animation: srank-popup 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes srank-popup {
  from { transform: scale(0.82); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.srank-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.07);
  color: #9c9080;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.srank-modal-close:hover { background: rgba(255,255,255,0.14); color: #e8ddd0; }

.srank-confetti {
  font-size: 1.5rem;
  letter-spacing: 4px;
  margin-bottom: 12px;
  animation: srank-bounce 0.6s ease 0.1s both;
}

@keyframes srank-bounce {
  0%   { transform: translateY(-10px); opacity: 0; }
  60%  { transform: translateY(4px); }
  100% { transform: translateY(0); opacity: 1; }
}

.srank-badge-wrap {
  margin-bottom: 14px;
}

.srank-badge-big {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  border-radius: 50%;
  font-size: 2rem;
  font-weight: 900;
  box-shadow: 0 0 24px rgba(232, 201, 122, 0.4);
  animation: srank-glow 1.8s ease-in-out infinite alternate;
}

@keyframes srank-glow {
  from { box-shadow: 0 0 16px rgba(232, 201, 122, 0.3); }
  to   { box-shadow: 0 0 36px rgba(232, 201, 122, 0.7); }
}

.srank-modal-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #e8c97a;
  margin: 0 0 6px;
}

.srank-modal-sub {
  font-size: 0.82rem;
  color: #b8a878;
  margin: 0 0 10px;
}

.srank-modal-work {
  font-size: 0.88rem;
  font-weight: 700;
  color: #e8ddd0;
  margin: 0 0 10px;
  word-break: break-all;
}

.srank-modal-desc {
  font-size: 0.8rem;
  color: #9c9080;
  line-height: 1.65;
  margin: 0 0 20px;
}

.srank-tweet-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 11px 28px;
  border-radius: 999px;
  background: #000;
  color: #fff;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
  width: 100%;
  margin-bottom: 10px;
}
.srank-tweet-btn:hover { background: #222; transform: translateY(-1px); }

.srank-modal-skip {
  background: none;
  border: none;
  color: #7a7060;
  font-size: 0.75rem;
  cursor: pointer;
  padding: 4px 8px;
  text-decoration: underline;
  transition: color 0.15s;
}
.srank-modal-skip:hover { color: #a09080; }

/* ========================================
   診断中ローディングオーバーレイ
   ======================================== */
.diag-loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 9000;
  background: rgba(10, 8, 6, 0.82);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.diag-loading-overlay[hidden] { display: none; }

.diag-loading-box {
  background: #1e1a16;
  border: 1px solid #3a332a;
  border-radius: 16px;
  padding: 36px 32px;
  max-width: 480px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 48px rgba(0,0,0,0.6);
}

.diag-loading-spinner {
  font-size: 2.4rem;
  color: #e8c97a;
  margin-bottom: 16px;
}

.diag-loading-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #e8ddd0;
  margin: 0 0 12px;
}

.diag-loading-msg {
  font-size: 0.82rem;
  color: #9c9080;
  line-height: 1.7;
  margin: 0 0 20px;
}
.diag-loading-msg strong { color: #e8c97a; }

.diag-loading-tiers {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.dlt-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid #3a332a;
  min-width: 72px;
}

.dlt-label {
  font-size: 0.68rem;
  font-weight: 600;
  color: #7a7060;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.dlt-time {
  font-size: 1rem;
  font-weight: 700;
}

.dlt-nologin { background: #22201c; }
.dlt-nologin .dlt-time { color: #9c9080; }

.dlt-free { background: #23201a; }
.dlt-free .dlt-label { color: #8a9870; }
.dlt-free .dlt-time  { color: #a8c47a; }

.dlt-premium { background: #1e1e26; }
.dlt-premium .dlt-label { color: #7888b0; }
.dlt-premium .dlt-time  { color: #88aaee; }

.dlt-super { background: #221c14; border-color: #6b4e20; }
.dlt-super .dlt-label { color: #b89050; }
.dlt-super .dlt-time  { color: #e8c97a; }

.diag-loading-fantia {
  border-top: 1px solid #2e2922;
  padding-top: 16px;
  font-size: 0.78rem;
  color: #7a7060;
  line-height: 1.65;
}
.diag-loading-fantia p { margin: 2px 0; }
.diag-loading-fantia a { color: #e8c97a; text-decoration: underline; }
.diag-loading-fantia a:hover { color: #f0d98a; }

/* ========================================
   レスポンシブ
   ======================================== */
@media (max-width: 900px) {
  .side-left,
  .side-right {
    position: fixed;
    top: 56px;
    bottom: 48px;
    z-index: 250;
    transition: transform 0.3s ease;
  }

  .side-left {
    left: 0;
    width: 85vw;
    min-width: 0;
    max-width: 360px;
    transform: translateX(-100%);
  }

  .side-right {
    right: 0;
    width: 85vw;
    min-width: 0;
    max-width: 400px;
    transform: translateX(100%);
  }

  .side-left.open  { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.3); }
  .side-right.open { transform: translateX(0); box-shadow: -4px 0 20px rgba(0,0,0,0.3); }

  .side-close { display: flex; }

  .mobile-bar { display: flex; }

  .diag-page { height: calc(100vh - 56px - 48px); }

  .card-tabs { padding: 0 6px; order: 1; border-bottom: none; border-top: 1px solid #ddd6ca; height: 56px; }
  .card-tabs-list { display: none; }
  .mobile-tab-nav { display: flex; }
  .mobile-tab-nav .nav-arrow { font-size: 1.2rem; padding: 8px 12px; }
  .card-tabs .btn-run { display: none; }
  .card-tabs .btn-help-small { display: none; }
  .editor-body { order: 0; }
  .field-group-grow { flex: 0.6; }
  .mobile-bar { padding: 8px 12px; }
  .mb-btn { padding: 10px; font-size: 0.82rem; }
}

@media (max-width: 640px) {
  .editor-body { padding: 12px; }
  .card-tab { padding: 4px 8px; font-size: 0.72rem; }
  .onboard-steps { max-width: 280px; }
  .onboard-step { font-size: 0.78rem; }
}

/* ========================================
   自動保存トグル
   ======================================== */
.sb-autosave-section {
  border-top: 1px solid #2e2922;
  padding-top: 14px;
  margin-top: 4px;
}

.sb-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.sb-toggle input { display: none; }

.sb-toggle-track {
  position: relative;
  width: 36px;
  height: 20px;
  background: #3a342d;
  border-radius: 10px;
  transition: background 0.2s;
  flex-shrink: 0;
}

.sb-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: #7a7060;
  border-radius: 50%;
  transition: transform 0.2s, background 0.2s;
}

.sb-toggle input:checked ~ .sb-toggle-track {
  background: rgba(232,201,122,0.35);
}

.sb-toggle input:checked ~ .sb-toggle-track .sb-toggle-thumb {
  transform: translateX(16px);
  background: #e8c97a;
}

.sb-toggle-label {
  font-size: 0.78rem;
  color: #9c9080;
  transition: color 0.2s;
}

.sb-toggle input:checked ~ .sb-toggle-label {
  color: #e8c97a;
}

.sb-toggle-hint {
  margin: 6px 0 0;
  font-size: 0.68rem;
  color: #5a5448;
  line-height: 1.5;
}

/* ========================================
   復元モーダル
   ======================================== */
.restore-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
.restore-overlay[hidden] { display: none; }

.restore-modal {
  background: #fff;
  border-radius: 14px;
  width: 90%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  animation: modalPopIn 0.25s ease;
}

@keyframes modalPopIn {
  from { transform: scale(0.92); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.restore-header {
  padding: 16px 20px;
  border-bottom: 1px solid #ede9e0;
  font-weight: bold;
  font-size: 0.95rem;
  color: #1a1612;
}

.restore-header i { color: #e8c97a; margin-right: 4px; }

.restore-body {
  padding: 20px;
}

.restore-msg {
  margin: 0 0 14px;
  font-size: 0.88rem;
  color: #3a3530;
  line-height: 1.6;
}

.restore-summary {
  background: #f8f7f4;
  border: 1px solid #ede9e0;
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 18px;
  font-size: 0.8rem;
  color: #5a5448;
  line-height: 1.7;
}

.restore-summary .rs-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.restore-summary .rs-row + .rs-row { margin-top: 4px; }

.restore-summary .rs-row i {
  color: #e8c97a;
  width: 16px;
  text-align: center;
  font-size: 0.78rem;
}

.restore-actions {
  display: flex;
  gap: 10px;
}

.restore-btn {
  flex: 1;
  padding: 11px;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.1s, box-shadow 0.15s;
}

.restore-btn:hover { transform: translateY(-1px); }

.restore-btn-yes {
  background: linear-gradient(135deg, #e8c97a, #d4b260);
  color: #1a1612;
}
.restore-btn-yes:hover { box-shadow: 0 3px 12px rgba(232,201,122,0.4); }

.restore-btn-no {
  background: #ede9e0;
  color: #5a5448;
}
.restore-btn-no:hover { background: #e2ddd4; }
