/* ══════════════════════════════════════════════════════════
   Base64 エンコード・デコード — スタイル
   テーマカラー: Sky (#0284c7)
   ══════════════════════════════════════════════════════════ */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f9ff;
  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: 860px;
  margin: 0 auto;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
}
.logo { font-weight: 700; font-size: 1.1rem; color: #0284c7; text-decoration: none; }
.logo:hover { color: #0369a1; }

/* ── メイン ── */
main {
  flex: 1;
  max-width: 860px;
  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: #0c4a6e; margin-bottom: 6px; }
.description { color: #0284c7; font-size: 0.9rem; line-height: 1.7; }

/* ── モードタブ ── */
.mode-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.mode-tab {
  padding: 10px 22px;
  border: 2px solid #bae6fd;
  border-radius: 12px;
  background: #f0f9ff;
  color: #0284c7;
  font-size: 0.9rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .18s;
  touch-action: manipulation;
}
.mode-tab:hover { border-color: #7dd3fc; background: #e0f2fe; }
.mode-tab.active {
  background: #0284c7;
  border-color: #0284c7;
  color: #fff;
  box-shadow: 0 2px 10px rgba(2,132,199,.35);
}

/* ── ツールラップ ── */
.tool-wrap {
  background: #fff;
  border-radius: 20px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 16px rgba(2,132,199,.1);
}

/* ══════════════════════════════
   方向 + オプション行
   ══════════════════════════════ */
.dir-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e0f2fe;
}

/* 方向トグル */
.dir-toggle {
  display: flex;
  gap: 6px;
  background: #f0f9ff;
  border: 1.5px solid #bae6fd;
  border-radius: 12px;
  padding: 4px;
}
.dir-btn {
  padding: 8px 16px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: #0369a1;
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.dir-btn.active {
  background: #0284c7;
  color: #fff;
  box-shadow: 0 2px 6px rgba(2,132,199,.3);
}
.dir-btn:hover:not(.active) { background: #e0f2fe; }
.dir-arrow { font-size: 0.8rem; }

/* オプション */
.options-group { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.opt-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.84rem;
  font-weight: 600;
  color: #0369a1;
  cursor: pointer;
  user-select: none;
}
.opt-label input[type="checkbox"] {
  accent-color: #0284c7;
  width: 15px;
  height: 15px;
  cursor: pointer;
}

/* ══════════════════════════════
   入出力グリッド
   ══════════════════════════════ */
.io-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: start;
  margin-bottom: 12px;
}

/* 入出力パネル */
.io-panel { display: flex; flex-direction: column; gap: 8px; }
.io-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 24px;
}
.io-title { font-size: 0.8rem; font-weight: 700; color: #0284c7; text-transform: uppercase; letter-spacing: .06em; }
.io-stat  { font-size: 0.72rem; color: #9ca3af; font-family: monospace; }
.io-hint  { font-size: 0.75rem; color: #0284c7; min-height: 18px; }

/* テキストエリアラップ */
.ta-wrap { position: relative; }
.base64-ta {
  width: 100%;
  height: 220px;
  padding: 12px 38px 12px 12px;
  border: 1.5px solid #bae6fd;
  border-radius: 12px;
  font-size: 0.83rem;
  font-family: 'SFMono-Regular', 'Consolas', 'Courier New', monospace;
  color: #0c4a6e;
  background: #f0f9ff;
  resize: vertical;
  outline: none;
  line-height: 1.6;
  transition: border-color .15s, background .15s;
  word-break: break-all;
}
.base64-ta:focus { border-color: #0284c7; background: #fff; }
.base64-ta::placeholder { color: #94a3b8; font-family: -apple-system, sans-serif; font-size: 0.82rem; }
.output-ta { background: #fafafa; color: #374151; cursor: default; }
.output-ta:focus { border-color: #bae6fd; background: #fafafa; }

.ta-file-btn {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 28px;
  height: 28px;
  border: 1px solid #bae6fd;
  border-radius: 7px;
  background: #fff;
  color: #0284c7;
  cursor: pointer;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .15s;
}
.ta-file-btn:hover { background: #0284c7; color: #fff; }

/* ドロップオーバーレイ */
.drop-overlay {
  position: absolute;
  inset: 0;
  background: rgba(2,132,199,.1);
  border: 2.5px dashed #0284c7;
  border-radius: 12px;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-weight: 700;
  color: #0284c7;
  backdrop-filter: blur(2px);
  pointer-events: none;
}

/* 出力アクション */
.output-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── 中央の変換ボタン列 ── */
.io-arrow-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 32px;
}
.io-arrow-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 2px solid #0284c7;
  background: #0284c7;
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  transition: all .18s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 10px rgba(2,132,199,.35);
}
.io-arrow-btn:hover { background: #0369a1; transform: scale(1.08); }
.io-swap-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid #bae6fd;
  background: #f0f9ff;
  color: #0284c7;
  font-size: 1rem;
  cursor: pointer;
  transition: all .15s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.io-swap-btn:hover { background: #e0f2fe; border-color: #7dd3fc; }

/* ══════════════════════════════
   ボタン共通
   ══════════════════════════════ */
.act-btn {
  padding: 7px 14px;
  border: 1.5px solid #bae6fd;
  border-radius: 20px;
  background: #f0f9ff;
  color: #0369a1;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
  white-space: nowrap;
}
.act-btn:hover { background: #0284c7; color: #fff; border-color: #0284c7; }
.act-btn.primary { background: #0284c7; color: #fff; border-color: #0284c7; box-shadow: 0 2px 8px rgba(2,132,199,.3); }
.act-btn.primary:hover { background: #0369a1; border-color: #0369a1; }

/* ══════════════════════════════
   エラーバー
   ══════════════════════════════ */
.error-bar {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 10px;
  margin-top: 10px;
}
.error-icon { font-size: 0.95rem; flex-shrink: 0; }
.error-bar span:last-child { font-size: 0.82rem; color: #991b1b; line-height: 1.5; }

/* ══════════════════════════════
   統計バー
   ══════════════════════════════ */
.stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}
.stat-chip {
  padding: 4px 10px;
  background: #e0f2fe;
  color: #0369a1;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: monospace;
}

/* ══════════════════════════════
   ファイルモード
   ══════════════════════════════ */

/* サブタブ */
.sub-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid #e0f2fe;
}
.sub-tab {
  padding: 8px 16px;
  border: 1.5px solid #bae6fd;
  border-radius: 10px;
  background: #f0f9ff;
  color: #0284c7;
  font-size: 0.84rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .15s;
}
.sub-tab.active { background: #0284c7; color: #fff; border-color: #0284c7; }
.sub-tab:hover:not(.active) { background: #e0f2fe; }

/* ファイルドロップゾーン */
.file-drop-zone {
  border: 2.5px dashed #7dd3fc;
  border-radius: 16px;
  background: #f0f9ff;
  padding: 40px 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
  cursor: pointer;
  transition: all .2s;
}
.file-drop-zone:hover,
.file-drop-zone.dragover { border-color: #0284c7; background: #e0f2fe; }
.file-drop-icon { font-size: 3rem; }
.file-drop-text { font-size: 1rem; font-weight: 700; color: #0c4a6e; }
.file-drop-or   { font-size: 0.8rem; color: #9ca3af; }
.file-drop-note { font-size: 0.75rem; color: #94a3b8; margin-top: 4px; }

/* ファイル情報バー */
.file-info-bar {
  padding: 10px 14px;
  background: #e0f2fe;
  border-radius: 10px;
  font-size: 0.82rem;
  color: #0369a1;
  font-weight: 600;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.file-info-item { display: flex; gap: 4px; }
.file-info-label { color: #64748b; font-weight: 500; }

/* 画像プレビュー */
.img-preview-label { font-size: 0.8rem; font-weight: 700; color: #0284c7; margin-bottom: 8px; }
.img-preview {
  max-width: 100%;
  max-height: 300px;
  border-radius: 10px;
  border: 1.5px solid #bae6fd;
  object-fit: contain;
  background: repeating-conic-gradient(#e5e7eb 0% 25%, #fff 0% 50%) 0 0 / 16px 16px;
  display: block;
}

/* Base64→ファイル ダウンロード行 */
.file-dl-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-top: 14px;
  flex-wrap: wrap;
}
.file-dl-group { display: flex; flex-direction: column; gap: 4px; }
.dl-label { font-size: 0.72rem; font-weight: 700; color: #0284c7; }
.mime-sel {
  padding: 7px 10px;
  border: 1.5px solid #bae6fd;
  border-radius: 9px;
  background: #f0f9ff;
  color: #0c4a6e;
  font-size: 0.82rem;
  outline: none;
  cursor: pointer;
  transition: border-color .15s;
}
.mime-sel:focus { border-color: #0284c7; }
.dl-filename {
  padding: 7px 10px;
  border: 1.5px solid #bae6fd;
  border-radius: 9px;
  background: #f0f9ff;
  color: #0c4a6e;
  font-size: 0.82rem;
  outline: none;
  width: 160px;
  transition: border-color .15s;
}
.dl-filename:focus { border-color: #0284c7; background: #fff; }

/* ══════════════════════════════
   汎用カード
   ══════════════════════════════ */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(2,132,199,.07);
}
.card h2 { font-size: 1.05rem; font-weight: 700; color: #0c4a6e; 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: #0284c7; margin-bottom: 4px; }
.how-item p  { font-size: 0.83rem; color: #374151; line-height: 1.65; }
.how-item code {
  background: #e0f2fe;
  color: #0369a1;
  padding: 1px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.85em;
  word-break: break-all;
}

/* ── フッター ── */
footer {
  text-align: center;
  padding: 24px 16px;
  font-size: 0.8rem;
  color: #9ca3af;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}
footer a { color: #0284c7; 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: 620px) {
  .hero h1 { font-size: 1.35rem; }
  .tool-wrap { padding: 18px 14px; }

  /* テキストモードを縦積み */
  .io-grid {
    grid-template-columns: 1fr;
    gap: 8px;
  }
  .io-arrow-col {
    flex-direction: row;
    justify-content: center;
    padding-top: 0;
  }
  .arrow-icon { transform: none !important; }

  .dir-options-row { flex-direction: column; align-items: flex-start; }
  .dir-toggle { width: 100%; }
  .dir-btn { flex: 1; text-align: center; }

  .how-grid { grid-template-columns: 1fr; }
  .file-dl-row { flex-direction: column; align-items: stretch; }
  .dl-filename { width: 100%; }

  .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: #0284c7; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #555; line-height: 1.75; }

/* ━━━ ヒーローバッジ ━━━ */
.hero-badges {
  display: flex; justify-content: center; flex-wrap: wrap;
  gap: .5rem; margin-top: .75rem;
}
.badge {
  display: inline-block;
  background: #e0f2fe; color: #0284c7;
  border: 1px solid #bae6fd;
  border-radius: 999px;
  font-size: .78rem; font-weight: 600;
  padding: .2rem .75rem;
}

/* ━━━ Base64早見表 ━━━ */
.table-note-top { font-size: .8rem; color: #aaa; margin-bottom: .65rem; }
.table-note     { font-size: .75rem; color: #bbb; margin-top: .5rem; }
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.b64-table {
  width: 100%; border-collapse: collapse;
  font-size: .83rem; min-width: 480px;
}
.b64-table th {
  background: #0284c7; color: #fff;
  padding: .5rem .75rem; text-align: left;
  font-weight: 700; font-size: .78rem; white-space: nowrap;
}
.b64-table td {
  padding: .45rem .75rem;
  border-bottom: 1px solid #f0f0f0;
  color: #444; vertical-align: middle;
}
.b64-table td code {
  background: #e0f2fe; color: #0369a1;
  padding: .1rem .35rem; border-radius: 4px;
  font-size: .82em; word-break: break-all;
}
.b64-table tr:hover td { background: #f0f9ff; }
.hl-row td { background: #e0f2fe !important; font-weight: 600; }

/* ━━━ 活用シーン ━━━ */
.scene-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: .9rem; }
.scene-item { display: flex; gap: .65rem; align-items: flex-start; }
.scene-icon { font-size: 1.5rem; flex-shrink: 0; }
.scene-body strong { display: block; font-size: .88rem; font-weight: 700; margin-bottom: .15rem; color: #333; }
.scene-body p { font-size: .8rem; color: #666; line-height: 1.55; margin: 0; }

/* ━━━ 関連ツール ━━━ */
.related-tools { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .75rem; }
.related-tool-item {
  display: flex; align-items: flex-start; gap: .75rem;
  padding: .85rem 1rem;
  border: 1.5px solid #e0f2fe; border-radius: 10px;
  text-decoration: none; color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.related-tool-item:hover { border-color: #0284c7; box-shadow: 0 2px 8px rgba(2,132,199,.1); }
.related-tool-icon { font-size: 1.6rem; flex-shrink: 0; }
.related-tool-item strong { display: block; font-size: .88rem; font-weight: 700; color: #0284c7; margin-bottom: .2rem; }
.related-tool-item p { font-size: .76rem; color: #888; line-height: 1.5; margin: 0; }

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