/* ══════════════════════════════════════════════════════════
   数値変換ツール — スタイル
   テーマカラー: Violet (#7c3aed)
   ══════════════════════════════════════════════════════════ */

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f5f3ff;
  color: #1e1b4b;
  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: 900px;
  margin: 0 auto;
  padding: 0 16px;
  height: 52px;
  display: flex;
  align-items: center;
}
.logo {
  font-weight: 700;
  font-size: 1.1rem;
  color: #7c3aed;
  text-decoration: none;
}
.logo:hover { color: #6d28d9; }

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

/* ── ヒーロー ── */
.hero {
  text-align: center;
  padding: 32px 0 24px;
}
.hero-icon { font-size: 3rem; margin-bottom: 12px; }
.hero h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #4c1d95;
  margin-bottom: 8px;
}
.description {
  color: #6d28d9;
  font-size: 0.95rem;
  line-height: 1.7;
}

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

/* ── ビット幅タブ ── */
.bit-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 20px;
}
.bit-tab {
  padding: 10px;
  border: 2px solid #ede9fe;
  border-radius: 10px;
  background: #f5f3ff;
  color: #7c3aed;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  touch-action: manipulation;
}
.bit-tab:hover { border-color: #a78bfa; background: #ede9fe; }
.bit-tab.active {
  background: #7c3aed;
  border-color: #7c3aed;
  color: #fff;
  box-shadow: 0 2px 8px rgba(124,58,237,.35);
}

/* ── エラーメッセージ ── */
.error-msg {
  background: #fef2f2;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  color: #dc2626;
  font-size: 0.875rem;
  padding: 10px 14px;
  margin-bottom: 16px;
}
.error-msg.hidden { display: none; }

/* ── 変換グリッド ── */
.conv-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.conv-item-bin {
  grid-column: 1 / -1;  /* 2進数は横幅全体 */
}

.conv-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: #4c1d95;
  margin-bottom: 6px;
}

/* バッジ */
.conv-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  letter-spacing: .04em;
}
.badge-dec { background: #dbeafe; color: #1d4ed8; }
.badge-hex { background: #d1fae5; color: #065f46; }
.badge-bin { background: #fce7f3; color: #9d174d; }
.badge-oct { background: #fff7ed; color: #c2410c; }

.conv-input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}
.conv-input {
  flex: 1;
  border: 2px solid #ede9fe;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 1rem;
  color: #1e1b4b;
  background: #fafafa;
  outline: none;
  transition: border-color .18s, box-shadow .18s;
  width: 100%;
}
.conv-input:focus {
  border-color: #7c3aed;
  box-shadow: 0 0 0 3px rgba(124,58,237,.15);
  background: #fff;
}
.conv-input.mono { font-family: 'SFMono-Regular', Consolas, monospace; letter-spacing: .04em; }

/* コピーボタン */
.copy-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: 2px solid #ede9fe;
  border-radius: 8px;
  background: #f5f3ff;
  color: #7c3aed;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all .18s;
  display: flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
}
.copy-btn:hover { background: #ede9fe; border-color: #c4b5fd; }
.copy-btn.copied { background: #d1fae5; border-color: #6ee7b7; }

/* ── クリアボタン ── */
.clear-wrap { display: flex; justify-content: flex-end; margin-bottom: 20px; }
.clear-btn {
  padding: 7px 18px;
  border: 2px solid #e2e8f0;
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s;
  touch-action: manipulation;
}
.clear-btn:hover { border-color: #dc2626; color: #dc2626; background: #fef2f2; }

/* ── セクションラベル ── */
.section-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #7c3aed;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 10px;
}

/* ── ビット視覚化 ── */
.bit-visual-wrap {
  background: #f5f3ff;
  border: 1px solid #ede9fe;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}
.bit-visual {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.bit-empty {
  text-align: center;
  color: #a78bfa;
  font-size: 0.875rem;
  padding: 8px 0;
}
.bit-row {
  display: flex;
  align-items: center;
  gap: 3px;
  margin-bottom: 4px;
  width: max-content;
}
.bit-cell {
  width: 28px;
  height: 28px;
  border-radius: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'SFMono-Regular', Consolas, monospace;
  font-size: 0.9rem;
  font-weight: 700;
  transition: background .2s;
  flex-shrink: 0;
}
.bit-one  { background: #7c3aed; color: #fff; }
.bit-zero { background: #ede9fe; color: #a78bfa; border: 1px solid #c4b5fd; }
.bit-gap  { width: 8px; flex-shrink: 0; }

.bit-labels {
  display: flex;
  align-items: center;
  gap: 3px;
  width: max-content;
}
.bit-pos {
  width: 28px;
  text-align: center;
  font-size: 0.6rem;
  color: #a78bfa;
  flex-shrink: 0;
}
.bit-gap-label { width: 8px; flex-shrink: 0; }

/* ── ASCII + 範囲カード ── */
.ascii-card {
  display: flex;
  gap: 20px;
  background: #f5f3ff;
  border: 1px solid #ede9fe;
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  align-items: flex-start;
}
.ascii-left { flex: 1; text-align: center; }
.ascii-right { flex: 1; }

.ascii-char {
  font-size: 2.5rem;
  font-weight: 700;
  line-height: 1;
  margin: 8px 0 6px;
  min-height: 2.5rem;
  font-family: 'SFMono-Regular', Consolas, monospace;
}
.ascii-char.ascii-printable { color: #4c1d95; }
.ascii-char.ascii-ctrl      { color: #7c3aed; font-size: 1.5rem; }
.ascii-char.ascii-out       { color: #a78bfa; }

.ascii-desc {
  font-size: 0.8rem;
  color: #6d28d9;
}

.range-info {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}
.range-row {
  font-size: 0.875rem;
  color: #4c1d95;
}
.range-row strong {
  font-family: 'SFMono-Regular', Consolas, monospace;
  color: #7c3aed;
}

/* ── クイック入力 ── */
.quick-section {
  margin-top: 4px;
}
.quick-vals {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.quick-btn {
  padding: 5px 12px;
  border: 1px solid #c4b5fd;
  border-radius: 20px;
  background: #f5f3ff;
  color: #6d28d9;
  font-size: 0.8rem;
  font-family: 'SFMono-Regular', Consolas, monospace;
  cursor: pointer;
  transition: all .15s;
  touch-action: manipulation;
}
.quick-btn:hover { background: #7c3aed; color: #fff; border-color: #7c3aed; }

/* ── 汎用カード ── */
.card {
  background: #fff;
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px rgba(109,40,217,.06);
}
.card h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #4c1d95;
  margin-bottom: 16px;
}

/* ── 使い方 ── */
.how-item { margin-bottom: 16px; }
.how-item:last-child { margin-bottom: 0; }
.how-item h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #6d28d9;
  margin-bottom: 4px;
}
.how-item p {
  font-size: 0.875rem;
  color: #374151;
  line-height: 1.6;
}

/* ── Amazon ── */
.amazon-note { font-size: 0.85rem; color: #64748b; margin-bottom: 16px; }
.amazon-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
.amazon-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: all .18s;
}
.amazon-item:hover { border-color: #a78bfa; background: #faf5ff; box-shadow: 0 2px 8px rgba(124,58,237,.1); }
.amazon-item-icon { font-size: 1.5rem; }
.amazon-item-name { font-size: 0.875rem; font-weight: 600; color: #1e1b4b; }
.amazon-item-desc { font-size: 0.78rem; color: #64748b; line-height: 1.45; }
.amazon-item-link { font-size: 0.78rem; color: #7c3aed; font-weight: 600; margin-top: 4px; }

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

/* ── hidden ── */
.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: 600px) {
  .hero h1 { font-size: 1.4rem; }
  .tool-wrap { padding: 16px; }

  .conv-grid { grid-template-columns: 1fr; }
  .conv-item-bin { grid-column: auto; }

  .ascii-card { flex-direction: column; gap: 12px; }
  .ascii-left { text-align: left; }

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

  .bit-cell { width: 22px; height: 22px; font-size: 0.75rem; border-radius: 4px; }
  .bit-pos  { width: 22px; font-size: 0.55rem; }

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

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

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

/* ── 活用シーン ── */
.scene-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: .75rem;
}
.scene-item {
  display: flex;
  align-items: flex-start;
  gap: .75rem;
  padding: .85rem 1rem;
  background: #f5f3ff;
  border: 1.5px solid #c4b5fd;
  border-radius: 12px;
}
.scene-icon { font-size: 1.7rem; flex-shrink: 0; }
.scene-body strong { display: block; font-size: .88rem; font-weight: 700; color: #4c1d95; margin-bottom: .2rem; }
.scene-body p { font-size: .78rem; color: #4b5563; 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 #ddd6fe;
  border-radius: 10px;
  text-decoration: none;
  color: inherit;
  transition: border-color .15s, box-shadow .15s;
}
.related-tool-item:hover { border-color: #7c3aed; box-shadow: 0 2px 8px rgba(124,58,237,.1); }
.related-tool-icon { font-size: 1.6rem; flex-shrink: 0; }
.related-tool-item strong { display: block; font-size: .88rem; font-weight: 700; color: #7c3aed; margin-bottom: .2rem; }
.related-tool-item p { font-size: .76rem; color: #6b7280; line-height: 1.5; margin: 0; }

/* ── FAQ ── */
.faq-list { display: flex; flex-direction: column; }
.faq-item { padding: .9rem 0; border-bottom: 1px solid #ede9fe; }
.faq-item:last-child { border-bottom: none; padding-bottom: 0; }
.faq-q { font-size: .9rem; font-weight: 700; color: #7c3aed; margin-bottom: .35rem; }
.faq-a { font-size: .85rem; color: #374151; line-height: 1.75; }

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