/* ════════════════════════════════════════════════════════════════
   Modern Dark - 視認性重視のオシャレ近未来デザイン
   コンセプト: 読みやすさ最優先 + 必要箇所だけアクセント発光
   ════════════════════════════════════════════════════════════════ */

:root {
  /* アクセントカラー (ネオンは控えめ) */
  --accent-cyan: #22d3ee;
  --accent-violet: #a78bfa;
  --accent-magenta: #ec4899;
  --accent-green: #34d399;
  --accent-amber: #fbbf24;
  --accent-red: #f87171;
  --accent-blue: #60a5fa;

  /* ベースカラー */
  --bg-base: #0b1020;
  --bg-card: #131b2e;
  --bg-card-hover: #1a2440;
  --bg-input: #0d1426;
  --bg-elevated: #1e2a44;

  /* テキスト (高コントラスト) */
  --text-primary: #f1f5f9;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --text-faint: #64748b;

  /* ボーダー */
  --border-default: rgba(148, 163, 184, 0.12);
  --border-hover: rgba(34, 211, 238, 0.35);
  --border-strong: rgba(148, 163, 184, 0.25);
}

/* ═════════ リセット ═════════ */
*, *::before, *::after { box-sizing: border-box; }
html { font-size: 15px; }

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif !important;
  color: var(--text-primary) !important;
  letter-spacing: 0.005em;
  font-feature-settings: "tnum" 1, "ss01" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  line-height: 1.55;
}

/* ═════════ 背景 (動かない控えめなオーラ) ═════════ */
body {
  background: var(--bg-base) !important;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 0% 0%, rgba(99, 102, 241, 0.10) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 100% 100%, rgba(34, 211, 238, 0.08) 0%, transparent 60%),
    radial-gradient(ellipse 40% 30% at 100% 0%, rgba(236, 72, 153, 0.05) 0%, transparent 60%);
  z-index: 0;
  pointer-events: none;
}

main, header, footer, nav { position: relative; z-index: 1; }

/* ═════════ タイポグラフィ ═════════ */
h1, h2, h3 {
  font-family: 'Inter', sans-serif !important;
  font-weight: 700 !important;
  letter-spacing: -0.01em !important;
  color: var(--text-primary) !important;
  line-height: 1.3;
}

h1 { font-size: 1.5rem; }
h2 { font-size: 1.25rem; }
h3 { font-size: 1.05rem; }

.font-mono, code, td.font-mono, [class*="font-mono"] {
  font-family: 'JetBrains Mono', 'SF Mono', Consolas, monospace !important;
  font-feature-settings: "tnum" 1, "zero" 1;
  letter-spacing: -0.02em;
}

p, span, div { color: inherit; }
.text-slate-400, .text-slate-500 { color: var(--text-muted) !important; }
.text-slate-300 { color: var(--text-secondary) !important; }
.text-slate-100, .text-slate-200, .text-white { color: var(--text-primary) !important; }

/* ═════════ ヘッダー: クリーン + 細い境界線 ═════════ */
header {
  background: rgba(11, 16, 32, 0.85) !important;
  backdrop-filter: blur(16px) saturate(150%);
  -webkit-backdrop-filter: blur(16px) saturate(150%);
  border-bottom: 1px solid var(--border-strong) !important;
  box-shadow: 0 1px 0 rgba(34, 211, 238, 0.15);
  position: sticky;
  top: 0;
  z-index: 50;
}

header h1 {
  background: linear-gradient(135deg, #f1f5f9 0%, #22d3ee 100%) !important;
  -webkit-background-clip: text !important;
  background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
  font-weight: 800 !important;
}

/* ═════════ カード: クリーンなグラス ═════════ */
.bg-slate-800,
[class*="bg-slate-800"]:not(button):not(input):not(select):not(textarea):not(option):not(span) {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: 12px !important;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 4px 12px rgba(0, 0, 0, 0.15) !important;
  transition: border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease !important;
}

.bg-slate-800:hover {
  border-color: var(--border-hover) !important;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.3),
    0 8px 24px rgba(0, 0, 0, 0.25),
    0 0 0 1px rgba(34, 211, 238, 0.1) !important;
}

[class*="bg-slate-900\\/"], .bg-slate-900\/50, .bg-slate-900\/60,
.bg-slate-900\/40, .bg-slate-900 {
  background: rgba(13, 20, 38, 0.7) !important;
  border-radius: 8px;
}

.bg-slate-950 {
  background: rgba(8, 12, 24, 0.9) !important;
}

/* ═════════ ボタン (落ち着いたが分かりやすい) ═════════ */
button, a[class*="bg-blue-"], a[class*="bg-green-"], a[class*="bg-yellow-"],
a[class*="bg-purple-"], a[class*="bg-pink-"], a[class*="bg-emerald-"],
a[class*="bg-cyan-"], a[class*="bg-orange-"], a[class*="bg-red-"] {
  font-weight: 600 !important;
  letter-spacing: 0.01em;
  transition: all 0.15s ease !important;
  border-radius: 8px !important;
  border: 1px solid transparent;
}

/* ボタンのホバー (光らせすぎず、明度を上げる) */
button:hover, a[class*="bg-"]:hover { filter: brightness(1.1); }

/* 各色のボタンに微発光 */
button[class*="bg-blue-6"], a[class*="bg-blue-6"] { box-shadow: 0 1px 3px rgba(59, 130, 246, 0.3); }
button[class*="bg-green-6"], a[class*="bg-green-6"] { box-shadow: 0 1px 3px rgba(34, 197, 94, 0.3); }
button[class*="bg-red-6"], a[class*="bg-red-6"] { box-shadow: 0 1px 3px rgba(239, 68, 68, 0.3); }
button[class*="bg-purple-6"], a[class*="bg-purple-6"] { box-shadow: 0 1px 3px rgba(147, 51, 234, 0.3); }
button[class*="bg-yellow-6"], a[class*="bg-yellow-6"] { box-shadow: 0 1px 3px rgba(234, 179, 8, 0.3); }
button[class*="bg-pink-6"], a[class*="bg-pink-6"] { box-shadow: 0 1px 3px rgba(236, 72, 153, 0.3); }
button[class*="bg-emerald-6"], a[class*="bg-emerald-6"] { box-shadow: 0 1px 3px rgba(16, 185, 129, 0.3); }
button[class*="bg-cyan-6"], a[class*="bg-cyan-6"], button[class*="bg-cyan-7"], a[class*="bg-cyan-7"] { box-shadow: 0 1px 3px rgba(6, 182, 212, 0.3); }
button[class*="bg-orange-6"], a[class*="bg-orange-6"] { box-shadow: 0 1px 3px rgba(249, 115, 22, 0.3); }

/* ホバー時のみ控えめなグロー */
button[class*="bg-blue-6"]:hover, a[class*="bg-blue-6"]:hover { box-shadow: 0 0 12px rgba(59, 130, 246, 0.4), 0 1px 3px rgba(0,0,0,0.3); }
button[class*="bg-green-6"]:hover, a[class*="bg-green-6"]:hover { box-shadow: 0 0 12px rgba(34, 197, 94, 0.4), 0 1px 3px rgba(0,0,0,0.3); }
button[class*="bg-red-6"]:hover, a[class*="bg-red-6"]:hover { box-shadow: 0 0 12px rgba(239, 68, 68, 0.4), 0 1px 3px rgba(0,0,0,0.3); }
button[class*="bg-purple-6"]:hover, a[class*="bg-purple-6"]:hover { box-shadow: 0 0 12px rgba(147, 51, 234, 0.4), 0 1px 3px rgba(0,0,0,0.3); }
button[class*="bg-yellow-6"]:hover, a[class*="bg-yellow-6"]:hover { box-shadow: 0 0 12px rgba(234, 179, 8, 0.4), 0 1px 3px rgba(0,0,0,0.3); }
button[class*="bg-pink-6"]:hover, a[class*="bg-pink-6"]:hover { box-shadow: 0 0 12px rgba(236, 72, 153, 0.4), 0 1px 3px rgba(0,0,0,0.3); }
button[class*="bg-emerald-6"]:hover, a[class*="bg-emerald-6"]:hover { box-shadow: 0 0 12px rgba(16, 185, 129, 0.4), 0 1px 3px rgba(0,0,0,0.3); }
button[class*="bg-cyan-6"]:hover, button[class*="bg-cyan-7"]:hover { box-shadow: 0 0 12px rgba(6, 182, 212, 0.4), 0 1px 3px rgba(0,0,0,0.3); }
button[class*="bg-orange-6"]:hover { box-shadow: 0 0 12px rgba(249, 115, 22, 0.4), 0 1px 3px rgba(0,0,0,0.3); }

/* ═════════ 入力欄 ═════════ */
input, select, textarea {
  background: var(--bg-input) !important;
  border: 1px solid var(--border-strong) !important;
  color: var(--text-primary) !important;
  border-radius: 8px !important;
  padding: 8px 12px !important;
  font-size: 0.9rem !important;
  transition: all 0.15s ease !important;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--accent-cyan) !important;
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15) !important;
  outline: none !important;
}
input::placeholder, textarea::placeholder { color: var(--text-faint) !important; }

/* ═════════ テーブル: 読みやすさ重視 ═════════ */
table { border-collapse: separate; border-spacing: 0; width: 100%; }

thead {
  background: var(--bg-elevated) !important;
}
thead th {
  font-family: 'Inter', sans-serif !important;
  font-weight: 600 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  font-size: 11px !important;
  color: var(--accent-cyan) !important;
  padding: 12px 16px !important;
  border-bottom: 1px solid var(--border-strong);
}

tbody tr {
  transition: background 0.1s ease;
}
tbody tr:hover {
  background: rgba(34, 211, 238, 0.06) !important;
}
tbody tr td {
  border-color: rgba(148, 163, 184, 0.08) !important;
  padding: 12px 16px !important;
}

/* ═════════ バッジ (控えめな彩度) ═════════ */
span[class*="bg-red-5"], span[class*="bg-red-6"], span[class*="bg-red-7"] {
  background-color: rgba(239, 68, 68, 0.85) !important;
  font-weight: 600;
}
span[class*="bg-green-5"], span[class*="bg-green-6"], span[class*="bg-green-7"] {
  background-color: rgba(34, 197, 94, 0.85) !important;
  font-weight: 600;
}
span[class*="bg-orange-5"], span[class*="bg-orange-6"] {
  background-color: rgba(249, 115, 22, 0.85) !important;
  font-weight: 600;
}
span[class*="bg-yellow-6"], span[class*="bg-yellow-7"] {
  background-color: rgba(234, 179, 8, 0.85) !important;
  font-weight: 600;
}
span[class*="bg-blue-6"], span[class*="bg-blue-7"] {
  background-color: rgba(59, 130, 246, 0.85) !important;
  font-weight: 600;
}
span[class*="bg-purple-6"], span[class*="bg-purple-7"] {
  background-color: rgba(147, 51, 234, 0.85) !important;
  font-weight: 600;
}
span[class*="bg-emerald-6"] {
  background-color: rgba(16, 185, 129, 0.85) !important;
  font-weight: 600;
}
span[class*="bg-pink-6"], span[class*="bg-pink-7"] {
  background-color: rgba(236, 72, 153, 0.85) !important;
  font-weight: 600;
}
span[class*="bg-cyan-6"], span[class*="bg-cyan-7"] {
  background-color: rgba(6, 182, 212, 0.85) !important;
  font-weight: 600;
}

/* ═════════ グラデーションパネル (落ち着いた色) ═════════ */
[class*="from-slate-800"],
[class*="from-blue-900"],
[class*="from-emerald-900"],
[class*="from-purple-900"],
[class*="from-pink-900"] {
  background: linear-gradient(135deg, var(--bg-card) 0%, rgba(20, 30, 50, 0.5) 100%) !important;
  border: 1px solid var(--border-default) !important;
  border-radius: 12px !important;
}

/* ═════════ 価格・数値表示 (発光は控えめ) ═════════ */
.text-3xl, .text-2xl[class*="font-bold"] {
  font-family: 'JetBrains Mono', 'Inter', sans-serif !important;
  letter-spacing: -0.02em;
  font-weight: 700;
}

/* 色付きテキスト: 視認性のため text-shadow なし */
.text-green-400, .text-green-300 { color: #4ade80 !important; }
.text-red-400, .text-red-300 { color: #f87171 !important; }
.text-red-500 { color: #ef4444 !important; }
.text-blue-400, .text-blue-300 { color: #60a5fa !important; }
.text-yellow-400, .text-yellow-300 { color: #fbbf24 !important; }
.text-purple-400, .text-purple-300 { color: #a78bfa !important; }
.text-pink-400, .text-pink-300 { color: #f472b6 !important; }
.text-emerald-400, .text-emerald-300 { color: #34d399 !important; }
.text-cyan-400, .text-cyan-300 { color: #22d3ee !important; }
.text-orange-400 { color: #fb923c !important; }

/* ═════════ スピナー ═════════ */
.animate-spin {
  border-color: var(--accent-cyan) transparent transparent transparent !important;
}

/* ═════════ AIチャットウィジェット (オシャレ + 読める) ═════════ */
#kabuChat .toggle {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet)) !important;
  box-shadow: 0 4px 20px rgba(34, 211, 238, 0.35), 0 2px 6px rgba(0, 0, 0, 0.3) !important;
  font-family: 'Inter', sans-serif !important;
  font-weight: 700 !important;
  letter-spacing: 0.02em !important;
  font-size: 13px !important;
  padding: 12px 20px !important;
  border-radius: 999px !important;
}
#kabuChat .toggle:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 28px rgba(34, 211, 238, 0.5), 0 3px 8px rgba(0, 0, 0, 0.4) !important;
}

#kabuChat .panel {
  background: var(--bg-card) !important;
  backdrop-filter: blur(16px) !important;
  border: 1px solid var(--border-strong) !important;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(34, 211, 238, 0.1) !important;
  border-radius: 16px !important;
}
#kabuChat .head {
  border-bottom: 1px solid var(--border-default) !important;
}
#kabuChat .head h3 {
  color: var(--text-primary) !important;
  font-weight: 700 !important;
}
#kabuChat .msg.user {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet)) !important;
  color: #fff !important;
}
#kabuChat .msg.bot {
  background: rgba(20, 30, 50, 0.6) !important;
  border: 1px solid var(--border-default) !important;
  color: var(--text-primary) !important;
}
#kabuChat .ctx {
  background: var(--bg-input) !important;
  color: var(--text-secondary) !important;
}
#kabuChat .suggestions button {
  background: var(--bg-elevated) !important;
  color: var(--text-secondary) !important;
}
#kabuChat .suggestions button:hover {
  background: var(--accent-cyan) !important;
  color: #0b1020 !important;
}

/* ═════════ 通知ボタン ═════════ */
#notifPermBtn {
  background: linear-gradient(135deg, var(--accent-violet), var(--accent-magenta)) !important;
  box-shadow: 0 4px 16px rgba(167, 139, 250, 0.4) !important;
  font-weight: 600 !important;
  border-radius: 999px !important;
}

/* ═════════ ツールチップ ═════════ */
#kabuTip {
  background: var(--bg-elevated) !important;
  border: 1px solid var(--accent-cyan) !important;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5) !important;
  font-family: 'Inter', sans-serif !important;
  font-size: 12px !important;
  color: var(--text-primary) !important;
  padding: 10px 14px !important;
  border-radius: 8px !important;
  font-weight: 500;
}

/* スクロールバー */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: rgba(11, 16, 32, 0.5); }
::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.25);
  border-radius: 6px;
  border: 2px solid var(--bg-base);
}
::-webkit-scrollbar-thumb:hover { background: var(--accent-cyan); }

/* セレクション */
::selection { background: var(--accent-cyan) !important; color: #0b1020 !important; }

.line-clamp-4 {
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* モーダル */
[id$="Modal"] > div {
  background: var(--bg-card) !important;
  border: 1px solid var(--border-strong) !important;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(34, 211, 238, 0.15) !important;
  border-radius: 16px !important;
}

a {
  transition: color 0.15s ease;
  color: var(--accent-cyan);
  text-decoration: none;
}
a:hover { color: var(--accent-violet); }
a.text-blue-400, a.text-blue-300 { color: var(--accent-cyan) !important; }
a.text-blue-400:hover, a.text-blue-300:hover { color: #67e8f9 !important; text-decoration: underline; }

details summary {
  cursor: pointer;
  transition: color 0.15s;
  color: var(--text-secondary);
  font-weight: 500;
}
details summary:hover { color: var(--accent-cyan) !important; }

input[type="checkbox"] {
  accent-color: var(--accent-cyan) !important;
}

hr { border-color: var(--border-default) !important; }

/* スコアバッジ用の発光 */
[class*="rounded-full"][class*="bg-red-5"],
[class*="rounded-full"][class*="bg-orange-5"],
[class*="rounded-full"][class*="bg-yellow-6"],
[class*="rounded-full"][class*="bg-blue-7"] {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

/* ─── レイアウト調整 (余白・行間) ─── */
.text-sm { font-size: 0.875rem; line-height: 1.55; }
.text-xs { font-size: 0.78rem; line-height: 1.45; }

/* リンク色指定上書き保護 */
a[href]:not([class*="bg-"]) { color: var(--accent-cyan); }

/* hover時の transformは控えめに */
.bg-slate-800:hover { transform: none; }

/* ─── ローディング系を見やすく ─── */
.animate-pulse { background: var(--bg-elevated) !important; }

/* ボタン凹み (押し込み感) */
button:active, a[class*="bg-"]:active {
  transform: translateY(1px);
}

/* ════════════════════════════════════════════════════════════════
   モード別 表示制御 (senior / beginner / pro)
   ════════════════════════════════════════════════════════════════ */

/* デフォルト: 全要素表示 (素人/プロ向け) */
.senior-only { display: none !important; }
.senior-hide { display: revert; }
.beginner-only { display: revert; }
.amateur-only { display: revert; }
.pro-only { display: none !important; }
.pro-only-flex { display: none !important; }
.pro-only-grid { display: none !important; }

/* プロモード */
body.pro-mode .pro-only { display: revert !important; }
body.pro-mode .pro-only-flex { display: flex !important; }
body.pro-mode .pro-only-grid { display: grid !important; }
body.pro-mode .beginner-only { display: none !important; }
body.pro-mode .amateur-only { display: none !important; }

/* 素人モード (beginner-mode) */
body.beginner-mode .pro-only,
body.beginner-mode .pro-only-flex,
body.beginner-mode .pro-only-grid { display: none !important; }
body.beginner-mode .senior-only { display: none !important; }
body.beginner-mode .amateur-only { display: revert; }

/* 超初心者モード (senior-mode) — 一番シンプルに */
body.senior-mode .pro-only,
body.senior-mode .pro-only-flex,
body.senior-mode .pro-only-grid { display: none !important; }
body.senior-mode .amateur-only { display: none !important; }
body.senior-mode .senior-only { display: revert !important; }
body.senior-mode .senior-hide { display: none !important; }

/* ════════════════════════════════════════════════════════════════
   👴 超初心者モード: 文字大きく・配色強く・余白広く
   ════════════════════════════════════════════════════════════════ */
body.senior-mode {
  font-size: 18px;  /* デフォルト 15px → 18px に拡大 */
  line-height: 1.7;
}
body.senior-mode h1 { font-size: 2.2rem !important; font-weight: 900 !important; }
body.senior-mode h2 { font-size: 1.7rem !important; font-weight: 800 !important; }
body.senior-mode h3 { font-size: 1.4rem !important; font-weight: 700 !important; }
body.senior-mode .text-xs { font-size: 0.9rem !important; }
body.senior-mode .text-sm { font-size: 1rem !important; }
body.senior-mode .text-base { font-size: 1.2rem !important; }
body.senior-mode .text-lg { font-size: 1.5rem !important; }
body.senior-mode .text-xl { font-size: 1.8rem !important; }
body.senior-mode .text-2xl { font-size: 2.1rem !important; }

/* 超初心者モード: ボタン大きめ */
body.senior-mode button,
body.senior-mode a[class*="bg-"] {
  min-height: 48px;
  padding: 10px 16px !important;
  font-size: 1.05rem !important;
  font-weight: 700 !important;
}

/* 超初心者モード: input 入力欄も大きく */
body.senior-mode input,
body.senior-mode select,
body.senior-mode textarea {
  font-size: 1.1rem !important;
  padding: 10px 14px !important;
  min-height: 44px;
}

/* 超初心者モード: 配色をハッキリ */
body.senior-mode {
  --text-primary: #ffffff;
  --text-secondary: #e2e8f0;
  --text-muted: #cbd5e1;
}
body.senior-mode .text-slate-400 { color: #cbd5e1 !important; }
body.senior-mode .text-slate-500 { color: #94a3b8 !important; }

/* 超初心者モード専用カード: より目立つ縁 */
body.senior-mode .senior-only.mega-card {
  border-width: 3px !important;
  font-size: 1.2rem;
}

/* ════════════════════════════════════════════════════════════════
   📱 スマートフォン対応 (max-width: 640px) — v2 包括版
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* ── 1. タッチターゲット最小 44px (Apple HIG 推奨) ── */
  /* 除外:
   *   .hidden     - 非表示要素
   *   .ann-close, .head-btn, .tab-btn - 小型ボタン
   *   .block       - カードラッパー (display: block 維持)
   * a タグでも .block が付いてないもの (ボタン風リンク) だけ対象
   */
  button:not(.hidden):not(.ann-close):not(.head-btn):not(.tab-btn):not(.block),
  a[class*="bg-"]:not(.hidden):not(.block):not([href^="/stock/"]):not([class*="rounded-lg p-3"]):not([class*="rounded-lg p-4"]) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  /* ナビ内のリンクは除外 */
  .dropdown a, nav a, header a.text-blue-400 {
    min-height: unset;
    display: block;
  }
  /* タブボタンは小さくしてもOK */
  .tab-btn { min-height: 36px !important; }
  /* カードラッパー (.block .bg-*) は display: block を維持 */
  a.block { display: block !important; }

  /* ── 2. iOS 自動ズーム回避 (input/select/textarea は font-size 16px 必須) ── */
  input[type="text"],
  input[type="email"],
  input[type="password"],
  input[type="number"],
  input[type="search"],
  input[type="tel"],
  input[type="url"],
  input[type="datetime-local"],
  input[type="date"],
  input:not([type]),
  select,
  textarea {
    font-size: 16px !important;
  }

  /* ── 3. フォントサイズ下限 (10px/11px は潰れる) ── */
  .text-\[10px\] { font-size: 11px !important; line-height: 1.5 !important; }
  .text-\[11px\] { font-size: 12px !important; line-height: 1.5 !important; }
  .text-\[9px\]  { font-size: 11px !important; line-height: 1.5 !important; }
  .text-\[8px\]  { font-size: 10px !important; line-height: 1.5 !important; }
  .text-xs       { font-size: 12px !important; line-height: 1.5 !important; }
  thead th       { font-size: 11px !important; padding: 8px 10px !important; }
  tbody tr td    { padding: 8px 10px !important; font-size: 13px; }

  /* ── 4. テーブルの横スクロール (全パターン対応) ── */
  .overflow-x-auto {
    -webkit-overflow-scrolling: touch;
    overflow-x: auto;
  }
  .overflow-x-auto table { min-width: 520px; }
  main table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }
  /* admin ダッシュボードのテーブル (.tab-content 内に直書き) */
  .tab-content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* ── 5. ヘッダー padding ── */
  header .max-w-7xl { padding-left: 10px !important; padding-right: 10px !important; }

  /* ── 6. メイン padding ── */
  main.max-w-7xl,
  main > * { padding-left: 8px; padding-right: 8px; }
  .max-w-7xl.mx-auto.px-4 { padding-left: 10px !important; padding-right: 10px !important; }

  /* ── 7. ツールチップ ── */
  #kabuTip {
    max-width: 250px !important;
    font-size: 12px !important;
    left: 10px !important;
    right: 10px !important;
    width: auto !important;
  }

  /* ── 8. AIチャットウィジェットは chat-widget.js 側でフルスクリーン化済み ── */

  /* ── 9. スクロールバー細く ── */
  ::-webkit-scrollbar { width: 4px; height: 4px; }

  /* ── 10. flex-wrap されたボタン群の間隔 ── */
  .flex.flex-wrap { gap: 6px !important; }

  /* ── 11. モーダルをフルスクリーン気味に ── */
  [id$="Modal"] > div {
    margin: 8px !important;
    max-height: calc(100vh - 16px) !important;
    overflow-y: auto;
  }

  /* ── 12. 大きなグリッドを2列以下に ── */
  .lg\:grid-cols-6 { grid-template-columns: repeat(3, 1fr) !important; }
  .lg\:grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }
  .md\:grid-cols-3 { grid-template-columns: repeat(2, 1fr) !important; }

  /* ── 13. 今年最安値フィルターボタンを2列に ── */
  .ytd-btn { font-size: 11px !important; padding: 8px 10px !important; }

  /* ── 14. iOS Safe Area (ノッチ・ホームバー対応) ── */
  body {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }
  /* sticky/fixed header はパディング込みで上に固定 */
  header.sticky {
    padding-top: env(safe-area-inset-top, 0px);
  }
  /* フローティングボタン (ChatWidget / FeedbackWidget) は下端の Safe Area 考慮 */
  #kabuChat .toggle,
  #fbBtn {
    bottom: max(12px, env(safe-area-inset-bottom, 12px)) !important;
  }

  /* ── 15. テキスト選択時のハイライト色 (見やすく) ── */
  ::selection {
    background: rgba(37, 99, 235, 0.4);
    color: white;
  }

  /* ── 16. リンクのタップハイライト ── */
  a, button {
    -webkit-tap-highlight-color: rgba(37, 99, 235, 0.2);
  }

  /* ── 17. ヘッダー内のテキスト省略 (長い文字列で改行壊れ防止) ── */
  header h1 {
    font-size: 14px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 60vw;
  }

  /* ── 18. textarea 適切な行高 ── */
  textarea {
    line-height: 1.5 !important;
    min-height: 80px;
  }

  /* ── 19. 1行に詰めすぎたカードの余白確保 ── */
  .rounded-xl, .rounded-2xl, .rounded-lg {
    /* padding は維持しつつ、margin で外側スペース */
  }
  .grid { gap: 8px !important; }

  /* ── 20. お知らせバナーが下端 Safe Area で隠れない ── */
  #annStack {
    padding-top: 0 !important;
  }

  /* ── 21. ユーザーバー (avatar + 名前) も小型化 ── */
  #userBar {
    padding-left: 8px !important;
    padding-right: 8px !important;
  }
  #userDisplayName {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  /* ── 22. お知らせバナーのテキストはスマホで詰めて表示 ── */
  .ann-bar {
    padding: 8px 12px !important;
  }
  .ann-bar .ann-title { font-size: 13px !important; }
  .ann-bar .ann-msg { font-size: 12px !important; }
  .ann-bar .ann-close {
    padding: 6px 10px !important;
    font-size: 11px !important;
    min-height: 36px !important;
  }

  /* ── 23. ボタンがテキストはみ出すのを防止 ── */
  button, a[class*="bg-"] {
    word-break: keep-all;
  }
}

/* ════════════════════════════════════════════════════════════════
   📱 縦長スマホ (iPhone SE 等 width < 380px) — さらに詰める
   ════════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  /* ヘッダーのボタン群を更にコンパクトに */
  header button, header a[class*="bg-"] {
    padding-left: 8px !important;
    padding-right: 8px !important;
    font-size: 11px !important;
  }
  /* タブもさらに小さく */
  .tab-btn {
    padding: 6px 10px !important;
    font-size: 11px !important;
  }
  /* グリッドを1列に */
  .lg\:grid-cols-6 { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-cols-3 { grid-template-columns: repeat(2, 1fr) !important; }
  .grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }
}

/* ── タブレット (641px〜1024px) も少し調整 ── */
@media (min-width: 641px) and (max-width: 1024px) {
  .lg\:grid-cols-6 { grid-template-columns: repeat(4, 1fr) !important; }
  .overflow-x-auto { -webkit-overflow-scrolling: touch; }
}
