/* ══════════════════════════════════════════════════════════
   JSON整形ツール — スタイル
   テーマカラー: Teal (#0d9488)
   ══════════════════════════════════════════════════════════ */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0fdfa;
  color: #1c1917;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── ヘッダー ── */
header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 920px;
  margin: 0 auto;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
}
.logo { font-weight: 700; font-size: 1.1rem; color: #0d9488; text-decoration: none; }
.logo:hover { color: #0f766e; }

/* ── メイン ── */
main {
  flex: 1;
  max-width: 920px;
  margin: 0 auto;
  padding: 24px 16px 48px;
  width: 100%;
}

/* ── ヒーロー ── */
.hero { text-align: center; padding: 24px 0 20px; }
.hero-icon { font-size: 3rem; margin-bottom: 10px; }
.hero h1 { font-size: 1.65rem; font-weight: 700; color: #134e4a; margin-bottom: 6px; }
.description { color: #0d9488; font-size: 0.9rem; line-height: 1.7; }

/* ── JSON ツール全体レイアウト ── */
.json-tool {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

/* ── パネル ── */
.panel {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 2px 16px rgba(13,148,136,.1);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  background: #f0fdfa;
  border-bottom: 1px solid #ccfbf1;
}
.panel-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: #0f766e;
  letter-spacing: .03em;
}

/* ── ツールバー右側 ── */
.toolbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.indent-wrap { display: flex; align-items: center; gap: 6px; }
.indent-label { font-size: 0.75rem; font-weight: 600; color: #0d9488; white-space: nowrap; }
.indent-sel {
  padding: 4px 8px;
  border: 1.5px solid #99f6e4;
  border-radius: 7px;
  background: #fff;
  color: #134e4a;
  font-size: 0.8rem;
  cursor: pointer;
  outline: none;
}
.indent-sel:focus { border-color: #0d9488; }

/* ── ボタン ── */
.act-btn {
  padding: 7px 14px;
  border: 1.5px solid #99f6e4;
  border-radius: 20px;
  background: #f0fdfa;
  color: #0f766e;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
  white-space: nowrap;
}
.act-btn:hover { background: #0d9488; color: #fff; border-color: #0d9488; }
.act-btn.primary { background: #0d9488; color: #fff; border-color: #0d9488; box-shadow: 0 2px 8px rgba(13,148,136,.3); }
.act-btn.primary:hover { background: #0f766e; border-color: #0f766e; }
.act-btn.danger { color: #dc2626; border-color: #fca5a5; background: #fff5f5; }
.act-btn.danger:hover { background: #dc2626; color: #fff; border-color: #dc2626; }
.act-btn.sm { padding: 5px 10px; font-size: 0.76rem; }
.act-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── アクション行 ── */
.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid #f0fdfa;
}

/* ── URL取得バー ── */
.url-bar {
  display: flex;
  gap: 8px;
  padding: 10px 16px;
  border-bottom: 1px solid #f0fdfa;
}
.url-input {
  flex: 1;
  padding: 7px 12px;
  border: 1.5px solid #99f6e4;
  border-radius: 8px;
  font-size: 0.85rem;
  color: #134e4a;
  background: #f0fdfa;
  outline: none;
  transition: border-color .15s;
  min-width: 0;
}
.url-input:focus { border-color: #0d9488; background: #fff; }
.url-input::placeholder { color: #9ca3af; }

/* ── テキストエリアラップ ── */
.textarea-wrap {
  position: relative;
}
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13,148,136,.12);
  border: 3px dashed #0d9488;
  border-radius: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.drop-msg {
  font-size: 1.3rem;
  font-weight: 700;
  color: #0f766e;
  background: #fff;
  padding: 16px 28px;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.1);
}

.json-textarea {
  width: 100%;
  height: 280px;
  padding: 14px 44px 14px 16px;
  border: none;
  border-bottom: 1px solid #f0fdfa;
  font-size: 0.875rem;
  font-family: 'SFMono-Regular', 'Consolas', 'Courier New', monospace;
  color: #134e4a;
  background: #fff;
  resize: vertical;
  outline: none;
  line-height: 1.6;
  tab-size: 2;
}
.json-textarea::placeholder { color: #9ca3af; font-family: -apple-system, sans-serif; font-size: 0.84rem; }

.file-pick-btn {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 32px;
  height: 32px;
  border: 1.5px solid #99f6e4;
  border-radius: 8px;
  background: #f0fdfa;
  color: #0d9488;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
  z-index: 2;
}
.file-pick-btn:hover { background: #0d9488; color: #fff; border-color: #0d9488; }

/* ── エラーバー ── */
.error-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 16px;
  background: #fef2f2;
  border-top: 1px solid #fecaca;
}
.error-icon { font-size: 1rem; flex-shrink: 0; margin-top: 1px; }
#error-msg {
  font-size: 0.82rem;
  color: #991b1b;
  line-height: 1.5;
  font-family: 'SFMono-Regular', monospace;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ── 入力フッター ── */
.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: #f8fafc;
  border-top: 1px solid #f0fdfa;
}
.char-count { font-size: 0.75rem; color: #9ca3af; font-family: monospace; }
.input-hint  { font-size: 0.72rem; color: #9ca3af; }

/* ══════════════════════════════
   統計バー
   ══════════════════════════════ */
.stats-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 0;
  padding: 10px 16px;
  background: #d1fae5;
  border-radius: 12px;
  border: 1px solid #6ee7b7;
  font-size: 0.8rem;
  font-weight: 600;
  color: #065f46;
  animation: slide-in .3s ease;
}
@keyframes slide-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.stat-item { white-space: nowrap; }
.stat-divider { color: #6ee7b7; margin: 0 10px; }

/* ══════════════════════════════
   出力パネル
   ══════════════════════════════ */

/* ビュータブ */
.view-tabs { display: flex; gap: 6px; }
.view-tab {
  padding: 7px 14px;
  border: 1.5px solid #99f6e4;
  border-radius: 20px;
  background: #f0fdfa;
  color: #0d9488;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.view-tab.active { background: #0d9488; color: #fff; border-color: #0d9488; }
.view-tab:hover:not(.active) { background: #ccfbf1; }

.output-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.search-input {
  padding: 5px 10px;
  border: 1.5px solid #99f6e4;
  border-radius: 20px;
  background: #f0fdfa;
  color: #134e4a;
  font-size: 0.8rem;
  outline: none;
  width: 140px;
  transition: all .15s;
}
.search-input:focus { border-color: #0d9488; background: #fff; width: 180px; }
.search-input::placeholder { color: #9ca3af; }

/* 出力ボディ */
.output-body {
  min-height: 280px;
  max-height: 520px;
  overflow: auto;
  position: relative;
}

/* プレースホルダー */
.output-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 48px 24px;
  color: #9ca3af;
  font-size: 0.875rem;
  text-align: center;
  min-height: 200px;
}
.ph-icon { font-size: 2.5rem; }
.ph-tip  { font-size: 0.78rem; color: #0d9488; background: #f0fdfa; padding: 4px 12px; border-radius: 20px; }

/* ══════════════════════════════
   ツリービュー
   ══════════════════════════════ */
.tree-container {
  padding: 12px 16px 16px;
  font-family: 'SFMono-Regular', 'Consolas', 'Courier New', monospace;
  font-size: 0.855rem;
  line-height: 1.7;
}

/* details/summary のデフォルト矢印を非表示 */
.tree-node > summary { list-style: none; }
.tree-node > summary::-webkit-details-marker { display: none; }

.tree-node {
  margin-left: 18px;
  border-left: 1.5px solid #ccfbf1;
  padding-left: 10px;
}
/* ルートノードは左ボーダーなし */
.tree-container > .tree-entry { margin-left: 0; }
.tree-container > .tree-entry > .tree-node { margin-left: 14px; }

.tree-entry { position: relative; }

.tree-summary {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 1px 4px;
  border-radius: 4px;
  transition: background .12s;
  user-select: none;
}
.tree-summary:hover { background: #f0fdfa; }

.tree-toggle {
  display: inline-block;
  width: 14px;
  text-align: center;
  color: #9ca3af;
  font-size: 0.65rem;
  transition: transform .15s;
  flex-shrink: 0;
}
.tree-node[open] > summary .tree-toggle { transform: rotate(90deg); }

.tree-bracket { color: #374151; font-weight: 700; }
.tree-count   { font-size: 0.72rem; color: #9ca3af; margin-left: 4px; }
.tree-preview { color: #9ca3af; font-size: 0.8rem; }
.tree-node[open] > summary .tree-preview { display: none; }

.tree-children { margin-top: 2px; }
.tree-close-line { padding: 1px 0; }

/* エントリー行 */
.tree-entry-line {
  display: flex;
  align-items: baseline;
  gap: 2px;
  flex-wrap: nowrap;
  padding: 1px 0;
}

/* キー・インデックス（クリッカブル） */
.tree-key,
.tree-idx {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 3px;
  transition: background .12s, color .12s;
  flex-shrink: 0;
  position: relative;
}
.tree-key { color: #0f766e; font-weight: 600; }
.tree-idx { color: #0891b2; }
.tree-key:hover,
.tree-idx:hover { background: #ccfbf1; color: #134e4a; }
.tree-key:hover::after,
.tree-idx:hover::after {
  content: '  📋 パスをコピー';
  font-size: 0.65rem;
  color: #0d9488;
  font-weight: 400;
}

.tree-colon { color: #9ca3af; margin: 0 2px; flex-shrink: 0; }
.tree-comma { color: #9ca3af; }

/* 値の色 */
.tv-str  { color: #15803d; }
.tv-num  { color: #1d4ed8; }
.tv-bool { color: #c2410c; font-weight: 700; }
.tv-null { color: #9ca3af; font-style: italic; }

/* 長い文字列の省略 */
.tv-str.long {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: bottom;
  cursor: help;
}

/* 検索ハイライト */
.search-match {
  background: #fef08a;
  border-radius: 3px;
  outline: 1.5px solid #facc15;
}

/* ══════════════════════════════
   コードビュー
   ══════════════════════════════ */
.code-container {
  padding: 16px;
  font-family: 'SFMono-Regular', 'Consolas', 'Courier New', monospace;
  font-size: 0.855rem;
  line-height: 1.7;
  color: #134e4a;
  white-space: pre;
  tab-size: 2;
  overflow: auto;
  max-height: 520px;
  cursor: text;
  user-select: text;
}

/* シンタックスハイライト */
.hl-key  { color: #0f766e; font-weight: 600; }
.hl-str  { color: #15803d; }
.hl-num  { color: #1d4ed8; }
.hl-bool { color: #c2410c; font-weight: 700; }
.hl-null { color: #9ca3af; font-style: italic; }
.hl-pct  { color: #374151; }

/* ══════════════════════════════
   パスコピー通知
   ══════════════════════════════ */
.path-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: #134e4a;
  color: #fff;
  padding: 9px 20px;
  border-radius: 24px;
  font-size: 0.82rem;
  font-family: 'SFMono-Regular', monospace;
  box-shadow: 0 4px 20px rgba(0,0,0,.25);
  z-index: 9999;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  transition: opacity .2s, transform .2s;
  pointer-events: none;
}
.path-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════
   汎用カード
   ══════════════════════════════ */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(13,148,136,.07);
}
.card h2 { font-size: 1.05rem; font-weight: 700; color: #134e4a; margin-bottom: 16px; }

.how-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
}
.how-item h3 { font-size: 0.9rem; font-weight: 700; color: #0d9488; margin-bottom: 4px; }
.how-item p  { font-size: 0.83rem; color: #374151; line-height: 1.65; }
.how-item code {
  background: #f0fdfa;
  color: #0f766e;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
}

/* ── フッター ── */
footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.8rem;
  color: #9ca3af;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
footer a { color: #0d9488; text-decoration: none; }
footer a:hover { text-decoration: underline; }
footer p + p { margin-top: 4px; }

.hidden { display: none !important; }

/* ══════════════════════════════
   レスポンシブ
   ══════════════════════════════ */

/* ─── Tips grid (rank-tracker 統一パターン) ──────── */
.tips-grid { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.tip-item { display: flex; gap: .65rem; }
.tip-icon { font-size: 1.4rem; flex-shrink: 0; }
.tip-text strong { display: block; font-weight: 700; margin-bottom: .15rem; font-size: .88rem; }
.tip-text p { font-size: .8rem; color: #78716c; line-height: 1.55; }
@media (max-width: 640px) {
  .hero h1 { font-size: 1.3rem; }
  .description { font-size: 0.83rem; }

  .action-row { gap: 6px; }
  .act-btn { padding: 6px 11px; font-size: 0.78rem; }

  .search-input { width: 110px; }
  .search-input:focus { width: 130px; }

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

  .tv-str.long { max-width: 200px; }

  .output-body { max-height: 400px; }

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

/* ━━━ Amazonおすすめ ━━━ */
.amazon-card h2 { margin-bottom: 0.25rem; }
.amazon-note { font-size: 0.82rem; color: #999; margin-bottom: 1rem; }
.amazon-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.amazon-item {
  display: block;
  border: 1px solid #e0e0e0;
  border-radius: 10px;
  padding: 0.9rem;
  text-decoration: none;
  color: inherit;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.1s;
}
.amazon-item:hover {
  border-color: #FF9900;
  box-shadow: 0 2px 8px rgba(255,153,0,0.15);
  transform: translateY(-1px);
}
.amazon-item-icon { font-size: 1.7rem; margin-bottom: 0.35rem; }
.amazon-item-name { font-size: 0.88rem; font-weight: bold; margin-bottom: 0.2rem; }
.amazon-item-desc { font-size: 0.76rem; color: #888; line-height: 1.5; margin-bottom: 0.45rem; }
.amazon-item-link { font-size: 0.78rem; color: #FF9900; font-weight: bold; }

.amazon-notice {
  font-size: 0.72rem;
  color: #bbb;
  margin-top: 0.2rem;
}

/* ━━━ FAQ ━━━ */
.faq-list { display: flex; flex-direction: column; }
.faq-item { padding: .9rem 0; border-bottom: 1px solid #f0f0f0; }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q { font-size: .9rem; font-weight: 700; color: #0d9488; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #555; line-height: 1.75; }
.faq-a code {
  background: #f0fdfa;
  color: #0f766e;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
}

/* ━━━ ヒーローバッジ ━━━ */
.hero-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 14px;
}
.badge {
  display: inline-block;
  padding: 5px 13px;
  background: #ccfbf1;
  color: #0d9488;
  border: 1.5px solid #99f6e4;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}

/* ━━━ JSONデータ型早見表 ━━━ */
.table-note-top {
  font-size: 0.83rem;
  color: #666;
  margin-bottom: 10px;
}
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 10px;
}
.json-ref-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.83rem;
}
.json-ref-table th {
  background: #ccfbf1;
  color: #0f766e;
  font-weight: 700;
  padding: 8px 12px;
  text-align: left;
  border-bottom: 2px solid #99f6e4;
  white-space: nowrap;
}
.json-ref-table td {
  padding: 8px 12px;
  border-bottom: 1px solid #f0fdfa;
  color: #374151;
  vertical-align: top;
  line-height: 1.55;
}
.json-ref-table tr:last-child td { border-bottom: none; }
.json-ref-table .hl-row td { background: #f0fdfa; }
.json-ref-table code {
  background: #f0fdfa;
  color: #0f766e;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
}
.table-note {
  font-size: 0.78rem;
  color: #888;
  line-height: 1.6;
}

/* ━━━ 活用シーン ━━━ */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}
.scene-item {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  background: #f0fdfa;
  border-radius: 12px;
  padding: 14px;
}
.scene-icon {
  font-size: 1.6rem;
  flex-shrink: 0;
  line-height: 1;
}
.scene-body strong {
  display: block;
  font-size: 0.88rem;
  font-weight: 700;
  color: #0f766e;
  margin-bottom: 4px;
}
.scene-body p {
  font-size: 0.8rem;
  color: #555;
  line-height: 1.6;
  margin: 0;
}

/* ━━━ 関連ツール ━━━ */
.related-tools {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.related-tool-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 14px;
  background: #f0fdfa;
  border: 1.5px solid #ccfbf1;
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.related-tool-item:hover {
  border-color: #0d9488;
  box-shadow: 0 2px 8px rgba(13,148,136,.15);
}
.related-tool-icon { font-size: 1.6rem; flex-shrink: 0; line-height: 1; }
.related-tool-item strong { display: block; font-size: 0.85rem; font-weight: 700; color: #0f766e; margin-bottom: 4px; }
.related-tool-item p { font-size: 0.78rem; color: #666; line-height: 1.55; margin: 0; }

@media (max-width: 640px) {
  .scene-grid { grid-template-columns: 1fr; }
  .related-tools { grid-template-columns: 1fr; }
}
