/* ═══════════════════════════════════════════════════════════════════════════
   kurumahub a11y.css v2 — 視認性最大化UI・高コントラストデザインシステム
   最終更新: 2026-04-15
   目的:
     (1) サイト全体で WCAG 2.1 AA以上を保証（本文 4.5:1, UI 7:1目標）
     (2) 高齢者・弱視・屋外環境でも明瞭に見えるUI
     (3) 既存コードを壊さず段階移行できる構造
     (4) 管理画面・フロント・マイページ 共通デザイン言語

   保護対象（絶対に影響を与えない）:
     - .pitch-section (/pitch) ... 独自 ds-* デザインシステム所有
     - .chat-widget             ... サードパーティUI
     - [data-cal-namespace], #cal-embed
     - .no-a11y-override        ... 明示オプトアウト

   使い方:
     A. 新規UI → .kh-btn-primary .kh-input .kh-table .kh-card 等を使う
     B. 既存UI → 自動的にグローバル防御ルールで最低ラインを保証
     C. ダーク背景 → .ds-* トークンで明示
   ═══════════════════════════════════════════════════════════════════════════ */

/* ═════════ 1. DESIGN TOKENS（CSS Variables） ═════════ */
:root {
  /* ── Brand Colors ─────────────────────────── */
  --kh-brand:         #2563EB;   /* blue-600 主ブランド（白文字で 4.7:1 AA） */
  --kh-brand-hover:   #1D4ED8;   /* blue-700 */
  --kh-brand-active:  #1E40AF;   /* blue-800 */
  --kh-brand-light:   #DBEAFE;   /* blue-100 背景用 */
  --kh-brand-ring:    rgba(37, 99, 235, 0.4);

  /* ── Semantic Colors ──────────────────────── */
  /* Danger */
  --kh-danger:        #DC2626;   /* red-600 (白文字 4.8:1) */
  --kh-danger-hover:  #B91C1C;   /* red-700 */
  --kh-danger-bg:     #FEF2F2;   /* red-50 */
  --kh-danger-border: #FECACA;   /* red-200 */
  --kh-danger-text:   #991B1B;   /* red-800 (白背景 7:1 AAA) */

  /* Success */
  --kh-success:        #059669;   /* emerald-600 (白文字 4.5:1) */
  --kh-success-hover:  #047857;   /* emerald-700 */
  --kh-success-bg:     #F0FDF4;
  --kh-success-border: #BBF7D0;
  --kh-success-text:   #065F46;   /* emerald-800 (白背景 7:1 AAA) */

  /* Warning */
  --kh-warning:        #D97706;   /* amber-600 (白文字 4.6:1) */
  --kh-warning-hover:  #B45309;   /* amber-700 */
  --kh-warning-bg:     #FFFBEB;
  --kh-warning-border: #FED7AA;
  --kh-warning-text:   #92400E;   /* amber-800 (白背景 7:1 AAA) */

  /* Info */
  --kh-info:        #0891B2;     /* cyan-600 */
  --kh-info-hover:  #0E7490;
  --kh-info-bg:     #ECFEFF;
  --kh-info-border: #A5F3FC;
  --kh-info-text:   #155E75;     /* cyan-800 AAA */

  /* ── Neutral Scale（白背景最適化）─────────── */
  --kh-gray-50:  #F8FAFC;        /* カード背景 */
  --kh-gray-100: #F1F5F9;        /* ストライプ偶数行 */
  --kh-gray-200: #E2E8F0;        /* 区切り線 */
  --kh-gray-300: #CBD5E1;        /* 装飾境界 */
  --kh-gray-400: #94A3B8;        /* 装飾のみ（本文禁止） */
  --kh-gray-500: #64748B;        /* 補足文字（白背景で AA） */
  --kh-gray-600: #475569;        /* 本文補足（AAA） */
  --kh-gray-700: #334155;        /* 本文（AAA 12.6:1） */
  --kh-gray-800: #1E293B;        /* 強調本文 */
  --kh-gray-900: #0F172A;        /* 見出し */

  /* ── Dark Surface Tokens（既存ds-*と互換） ──── */
  --ds-bg-base:    #020617;
  --ds-bg-card:    #0F172A;
  --ds-border:     #334155;
  --ds-border-soft:#1E293B;
  --ds-text:       #FFFFFF;
  --ds-text-body:  #E2E8F0;
  --ds-text-muted: #CBD5E1;
  --ds-text-dim:   #94A3B8;
  --ds-cyan:       #67E8F9;
  --ds-cyan-br:    #22D3EE;
  --ds-blue:       #93C5FD;
  --ds-emerald:    #6EE7B7;
  --ds-amber:      #FCD34D;
  --ds-red:        #FCA5A5;
  --ds-purple:     #D8B4FE;
  --ds-pink:       #F9A8D4;
  --ds-indigo:     #A5B4FC;

  /* ── Sizes（タッチターゲット最低44px） ────── */
  --kh-btn-h:       44px;
  --kh-btn-h-sm:    36px;
  --kh-btn-h-lg:    52px;
  --kh-input-h:     44px;
  --kh-radius:      0.5rem;
  --kh-radius-lg:   0.75rem;
  --kh-focus-width: 3px;
  --kh-focus-ring:  0 0 0 3px var(--kh-brand-ring);
}

/* ═════════ 2. ds-* トークン（ダーク用・既存互換） ═════════ */
.ds-card         { background: var(--ds-bg-card); border: 1px solid var(--ds-border); border-radius: 0.75rem; color: var(--ds-text); }
.ds-card-cyan    { background: var(--ds-bg-card); border: 1px solid #0891B2; color: var(--ds-text); }
.ds-card-blue    { background: var(--ds-bg-card); border: 1px solid #2563EB; color: var(--ds-text); }
.ds-card-emerald { background: var(--ds-bg-card); border: 1px solid #059669; color: var(--ds-text); }
.ds-card-amber   { background: var(--ds-bg-card); border: 1px solid #D97706; color: var(--ds-text); }
.ds-card-red     { background: var(--ds-bg-card); border: 1px solid #DC2626; color: var(--ds-text); }
.ds-card-purple  { background: var(--ds-bg-card); border: 1px solid #9333EA; color: var(--ds-text); }
.ds-card-pink    { background: var(--ds-bg-card); border: 1px solid #DB2777; color: var(--ds-text); }
.ds-card-indigo  { background: var(--ds-bg-card); border: 1px solid #4F46E5; color: var(--ds-text); }
.ds-text       { color: var(--ds-text); }
.ds-text-body  { color: var(--ds-text-body); }
.ds-text-muted { color: var(--ds-text-muted); }
.ds-text-dim   { color: var(--ds-text-dim); }
.ds-cyan     { color: var(--ds-cyan); }
.ds-cyan-br  { color: var(--ds-cyan-br); }
.ds-blue     { color: var(--ds-blue); }
.ds-emerald  { color: var(--ds-emerald); }
.ds-amber    { color: var(--ds-amber); }
.ds-red      { color: var(--ds-red); }
.ds-purple   { color: var(--ds-purple); }
.ds-pink     { color: var(--ds-pink); }
.ds-indigo   { color: var(--ds-indigo); }

/* ═════════ 3. タイポグラフィ・グローバルベース ═════════
   .pitch-section と .chat-widget は除外
   高齢者対応: 本文 16px、font-weight 500 をベース */
body:not(.chat-widget) {
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* 本文フォントウェイトを 500 (Japanese readability) に底上げ */
body > main p,
body > main li,
body > main td,
body > main dd,
body > main label {
  font-weight: 500;
}

/* ═════════ 4. BUTTONS — .kh-btn 系 ═════════
   最低 44px（タッチ対応）、focus リング、disabled 明示 */
.kh-btn,
.kh-btn-primary, .kh-btn-secondary, .kh-btn-danger,
.kh-btn-success, .kh-btn-warning, .kh-btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: var(--kh-btn-h);
  padding: 0.625rem 1.25rem;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
  border-radius: var(--kh-radius);
  border: 2px solid transparent;
  cursor: pointer;
  transition: background-color 150ms, border-color 150ms, box-shadow 150ms, transform 80ms;
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}
.kh-btn-sm { min-height: var(--kh-btn-h-sm); padding: 0.375rem 0.875rem; font-size: 14px; }
.kh-btn-lg { min-height: var(--kh-btn-h-lg); padding: 0.875rem 1.75rem; font-size: 16px; }

.kh-btn-primary    { background: var(--kh-brand); color: #FFFFFF; border-color: var(--kh-brand); }
.kh-btn-primary:hover:not(:disabled):not([aria-disabled="true"]) { background: var(--kh-brand-hover); border-color: var(--kh-brand-hover); }
.kh-btn-primary:active:not(:disabled) { background: var(--kh-brand-active); transform: translateY(1px); }

.kh-btn-secondary  { background: #FFFFFF; color: var(--kh-gray-800); border-color: var(--kh-gray-400); }
.kh-btn-secondary:hover:not(:disabled) { background: var(--kh-gray-50); border-color: var(--kh-gray-700); color: var(--kh-gray-900); }

.kh-btn-danger     { background: var(--kh-danger); color: #FFFFFF; border-color: var(--kh-danger); }
.kh-btn-danger:hover:not(:disabled) { background: var(--kh-danger-hover); border-color: var(--kh-danger-hover); }

.kh-btn-success    { background: var(--kh-success); color: #FFFFFF; border-color: var(--kh-success); }
.kh-btn-success:hover:not(:disabled) { background: var(--kh-success-hover); border-color: var(--kh-success-hover); }

.kh-btn-warning    { background: var(--kh-warning); color: #FFFFFF; border-color: var(--kh-warning); }
.kh-btn-warning:hover:not(:disabled) { background: var(--kh-warning-hover); border-color: var(--kh-warning-hover); }

.kh-btn-ghost      { background: transparent; color: var(--kh-brand); border-color: transparent; }
.kh-btn-ghost:hover:not(:disabled) { background: var(--kh-brand-light); color: var(--kh-brand-hover); }

.kh-btn-primary:focus-visible, .kh-btn-secondary:focus-visible, .kh-btn-danger:focus-visible,
.kh-btn-success:focus-visible, .kh-btn-warning:focus-visible, .kh-btn-ghost:focus-visible {
  outline: none;
  box-shadow: var(--kh-focus-ring);
}

.kh-btn-primary:disabled, .kh-btn-secondary:disabled, .kh-btn-danger:disabled,
.kh-btn-success:disabled, .kh-btn-warning:disabled, .kh-btn-ghost:disabled,
[aria-disabled="true"].kh-btn-primary, [aria-disabled="true"].kh-btn-secondary,
[aria-disabled="true"].kh-btn-danger {
  opacity: 0.55;
  cursor: not-allowed;
  filter: grayscale(0.3);
}

/* ═════════ 5. FORMS — .kh-input, .kh-select, .kh-textarea ═════════ */
.kh-input, .kh-select, .kh-textarea {
  display: block;
  width: 100%;
  min-height: var(--kh-input-h);
  padding: 0.625rem 0.875rem;
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
  color: var(--kh-gray-900);
  background: #FFFFFF;
  border: 2px solid var(--kh-gray-400);  /* 明確な境界 */
  border-radius: var(--kh-radius);
  transition: border-color 150ms, box-shadow 150ms;
}
.kh-textarea { min-height: 96px; padding-top: 0.625rem; resize: vertical; }
.kh-select   { padding-right: 2.5rem; appearance: none; background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23475569'><path fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/></svg>"); background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1.25rem; }

.kh-input:hover, .kh-select:hover, .kh-textarea:hover {
  border-color: var(--kh-gray-700);
}
.kh-input:focus, .kh-select:focus, .kh-textarea:focus {
  outline: none;
  border-color: var(--kh-brand);
  box-shadow: var(--kh-focus-ring);
}
.kh-input::placeholder, .kh-textarea::placeholder {
  color: var(--kh-gray-500);     /* WCAG AA 4.6:1 on white */
  opacity: 1;
  font-weight: 500;
}
.kh-input:disabled, .kh-select:disabled, .kh-textarea:disabled {
  background: var(--kh-gray-100);
  color: var(--kh-gray-600);
  cursor: not-allowed;
}
.kh-input[aria-invalid="true"], .kh-input.is-error,
.kh-select[aria-invalid="true"], .kh-textarea[aria-invalid="true"] {
  border-color: var(--kh-danger);
  background: var(--kh-danger-bg);
}
.kh-input[aria-invalid="true"]:focus { box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.3); }

.kh-label {
  display: block;
  margin-bottom: 0.375rem;
  font-size: 14px;
  font-weight: 700;
  color: var(--kh-gray-800);
}
.kh-label-required::after {
  content: " ※";
  color: var(--kh-danger);
  font-weight: 700;
}
.kh-help { display: block; margin-top: 0.375rem; font-size: 13px; color: var(--kh-gray-600); font-weight: 500; }
.kh-error { display: flex; align-items: flex-start; gap: 0.375rem; margin-top: 0.375rem; font-size: 14px; font-weight: 700; color: var(--kh-danger-text); }
.kh-error::before {
  content: "⚠";
  flex-shrink: 0;
  display: inline-block;
  min-width: 1.25rem;
  text-align: center;
  color: var(--kh-danger);
}

/* ═════════ 6. TABLES — .kh-table ═════════ */
.kh-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 15px;
  background: #FFFFFF;
  border: 1px solid var(--kh-gray-300);
  border-radius: var(--kh-radius);
  overflow: hidden;
}
.kh-table thead { background: var(--kh-gray-100); }
.kh-table thead th {
  padding: 0.75rem 1rem;
  font-weight: 700;
  color: var(--kh-gray-900);
  text-align: left;
  border-bottom: 2px solid var(--kh-gray-300);
  font-size: 14px;
  letter-spacing: 0.02em;
}
.kh-table tbody tr { border-bottom: 1px solid var(--kh-gray-200); }
.kh-table tbody tr:nth-child(even) { background: var(--kh-gray-50); }
.kh-table tbody tr:hover { background: var(--kh-brand-light); }
.kh-table tbody td {
  padding: 0.75rem 1rem;
  color: var(--kh-gray-800);
  vertical-align: top;
  font-weight: 500;
}
.kh-table-sticky thead { position: sticky; top: 0; z-index: 2; box-shadow: 0 2px 0 var(--kh-gray-300); }

/* ═════════ 7. BADGES — ステータス表示 ═════════ */
.kh-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.1875rem 0.625rem;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.4;
  border-radius: 9999px;
  border: 1px solid transparent;
  white-space: nowrap;
}
.kh-badge-neutral { background: var(--kh-gray-100); color: var(--kh-gray-800); border-color: var(--kh-gray-300); }
.kh-badge-primary { background: var(--kh-brand-light); color: var(--kh-brand-active); border-color: var(--kh-brand); }
.kh-badge-danger  { background: var(--kh-danger-bg); color: var(--kh-danger-text); border-color: var(--kh-danger-border); }
.kh-badge-success { background: var(--kh-success-bg); color: var(--kh-success-text); border-color: var(--kh-success-border); }
.kh-badge-warning { background: var(--kh-warning-bg); color: var(--kh-warning-text); border-color: var(--kh-warning-border); }
.kh-badge-info    { background: var(--kh-info-bg); color: var(--kh-info-text); border-color: var(--kh-info-border); }

/* ═════════ 8. ALERTS — 通知・メッセージ ═════════ */
.kh-alert {
  display: flex;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  border: 2px solid;
  border-left-width: 6px;
  border-radius: var(--kh-radius);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.5;
}
.kh-alert-danger  { background: var(--kh-danger-bg); color: var(--kh-danger-text); border-color: var(--kh-danger); }
.kh-alert-success { background: var(--kh-success-bg); color: var(--kh-success-text); border-color: var(--kh-success); }
.kh-alert-warning { background: var(--kh-warning-bg); color: var(--kh-warning-text); border-color: var(--kh-warning); }
.kh-alert-info    { background: var(--kh-info-bg); color: var(--kh-info-text); border-color: var(--kh-info); }
.kh-alert-title { font-weight: 700; font-size: 16px; margin-bottom: 0.25rem; }

/* ═════════ 9. CARDS — 汎用カード ═════════ */
.kh-card {
  background: #FFFFFF;
  border: 1px solid var(--kh-gray-300);
  border-radius: var(--kh-radius-lg);
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
  overflow: hidden;
}
.kh-card-header   { padding: 1rem 1.25rem; border-bottom: 1px solid var(--kh-gray-200); font-weight: 700; color: var(--kh-gray-900); background: var(--kh-gray-50); }
.kh-card-body     { padding: 1.25rem; color: var(--kh-gray-800); font-weight: 500; }
.kh-card-footer   { padding: 0.875rem 1.25rem; border-top: 1px solid var(--kh-gray-200); background: var(--kh-gray-50); }

/* ═════════ 10. NAVIGATION — サイドバー/トップ ═════════ */
.kh-nav-link {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 44px;
  padding: 0.5rem 0.875rem;
  font-size: 15px;
  font-weight: 600;
  color: var(--kh-gray-800);
  border-radius: var(--kh-radius);
  transition: background-color 120ms, color 120ms;
  text-decoration: none;
}
.kh-nav-link:hover { background: var(--kh-brand-light); color: var(--kh-brand-active); }
.kh-nav-link[aria-current="page"],
.kh-nav-link.is-active {
  background: var(--kh-brand);
  color: #FFFFFF;
  font-weight: 700;
}
.kh-nav-link[aria-current="page"]:hover,
.kh-nav-link.is-active:hover { background: var(--kh-brand-hover); color: #FFFFFF; }

/* ═════════ 11. グローバル防御オーバーライド
   既存コードを壊さず最低ラインを保証するガード。
   保護対象 (.pitch-section, .chat-widget) は除外 ═════════ */

/* 11-A. フォーカス可視化（WCAG 2.4.7）全サイト */
:where(a, button, [role="button"], input, textarea, select, [tabindex]):not(.pitch-section *):not(.chat-widget *):focus-visible {
  outline: var(--kh-focus-width) solid var(--kh-brand);
  outline-offset: 2px;
  border-radius: 2px;
}

/* 11-B. placeholder コントラスト昇格 */
body:not(.pitch-section *):not(.chat-widget *) input::placeholder,
body:not(.pitch-section *):not(.chat-widget *) textarea::placeholder {
  color: var(--kh-gray-600) !important;  /* 6:1 on white (AA) */
  opacity: 1 !important;
}

/* 11-C. 入力欄の薄い境界線 border-gray-200 を gray-400 へ昇格
        （291箇所対策 — 識別容易性を確保） */
body:not(.pitch-section *):not(.chat-widget *)
  :where(input, select, textarea).border-gray-200,
body:not(.pitch-section *):not(.chat-widget *)
  :where(input, select, textarea).border-gray-100 {
  border-color: var(--kh-gray-400) !important;
}

/* 11-D. 白背景上の text-gray-400 を gray-600 に昇格（AA境界から AAA へ） */
body:not(.pitch-section *):not(.chat-widget *) main .text-gray-400,
body:not(.pitch-section *):not(.chat-widget *) main .text-slate-400 {
  color: var(--kh-gray-600) !important;  /* 7:1 AAA */
}

/* ═════════ 12. ダーク背景自動検出 → opacity-text昇格
   既存の自動昇格ロジック（v1から継承・拡張） ═════════ */

/* dark-bg contexts: Tailwind bg-slate-900/gray-900/... + カスタム色 */
:where(.bg-slate-900, .bg-slate-950, .bg-gray-900, .bg-gray-950,
       .bg-neutral-900, .bg-neutral-950, .bg-zinc-900, .bg-zinc-950,
       .bg-stone-900, .bg-stone-950, .bg-black, .bg-midnight-navy,
       [class*="bg-[#0F172A]"], [class*="bg-[#020617]"],
       [class*="bg-[#0B1220]"], [class*="bg-[#0f172a]"],
       [class*="bg-[#020617]"], [style*="#0F172A"], [style*="#020617"],
       [style*="#0f172a"], [style*="#020617"]):not(.pitch-section):not(.chat-widget):not(.no-a11y-override) :is(
        .text-white\/5, .text-white\/10, .text-white\/15, .text-white\/20,
        .text-white\/25, .text-white\/30, .text-white\/35, .text-white\/40,
        .text-white\/45, .text-white\/50, .text-white\/55, .text-white\/60) {
  color: var(--ds-text-muted) !important;
}
:where(.bg-slate-900, .bg-slate-950, .bg-gray-900, .bg-gray-950,
       .bg-neutral-900, .bg-neutral-950, .bg-zinc-900, .bg-zinc-950,
       .bg-stone-900, .bg-stone-950, .bg-black, .bg-midnight-navy,
       [class*="bg-[#0F172A]"], [class*="bg-[#020617]"],
       [class*="bg-[#0B1220]"], [class*="bg-[#0f172a]"],
       [class*="bg-[#020617]"], [style*="#0F172A"], [style*="#020617"],
       [style*="#0f172a"], [style*="#020617"]):not(.pitch-section):not(.chat-widget):not(.no-a11y-override) :is(
        .text-white\/65, .text-white\/70, .text-white\/75, .text-white\/80,
        .text-white\/85, .text-white\/90, .text-white\/95) {
  color: #FFFFFF !important;
}
:where(.bg-slate-900, .bg-slate-950, .bg-gray-900, .bg-gray-950,
       .bg-neutral-900, .bg-neutral-950, .bg-zinc-900, .bg-zinc-950,
       .bg-black, .bg-midnight-navy,
       [class*="bg-[#0F172A]"], [class*="bg-[#020617]"],
       [style*="#0F172A"], [style*="#020617"]):not(.pitch-section):not(.chat-widget):not(.no-a11y-override) :is(
        .text-gray-400, .text-gray-500, .text-gray-600, .text-gray-700,
        .text-slate-400, .text-slate-500, .text-slate-600, .text-slate-700,
        .text-zinc-400, .text-zinc-500, .text-zinc-600, .text-zinc-700,
        .text-neutral-400, .text-neutral-500, .text-neutral-600, .text-neutral-700) {
  color: var(--ds-text-muted) !important;
}
:where(.bg-slate-900, .bg-slate-950, .bg-gray-900, .bg-gray-950,
       .bg-neutral-900, .bg-neutral-950, .bg-zinc-900, .bg-zinc-950,
       .bg-black, .bg-midnight-navy,
       [class*="bg-[#0F172A]"], [class*="bg-[#020617]"],
       [style*="#0F172A"], [style*="#020617"]):not(.pitch-section):not(.chat-widget):not(.no-a11y-override) :is(
        [class*="bg-white/[0."], .bg-white\/5, .bg-white\/10, .bg-white\/15, .bg-white\/20) {
  background-color: rgba(15, 23, 42, 0.9) !important;
}

/* 明示マーカー .a11y-dark */
.a11y-dark:not(.pitch-section) :is(
  .text-white\/5, .text-white\/10, .text-white\/15, .text-white\/20,
  .text-white\/25, .text-white\/30, .text-white\/35, .text-white\/40,
  .text-white\/45, .text-white\/50, .text-white\/55, .text-white\/60) { color: var(--ds-text-muted) !important; }
.a11y-dark:not(.pitch-section) :is(
  .text-white\/65, .text-white\/70, .text-white\/75, .text-white\/80,
  .text-white\/85, .text-white\/90, .text-white\/95) { color: #FFFFFF !important; }
.a11y-dark:not(.pitch-section) :is(
  .text-gray-400, .text-gray-500, .text-gray-600, .text-gray-700,
  .text-slate-400, .text-slate-500, .text-slate-600, .text-slate-700) { color: var(--ds-text-muted) !important; }

/* ═════════ 13. ACCESSIBILITY 拡張 ═════════ */

/* スクリーンリーダー専用（視覚的に非表示） */
.kh-sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

/* スキップリンク（キーボード操作） */
.kh-skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--kh-brand);
  color: #FFFFFF;
  padding: 8px 16px;
  text-decoration: none;
  font-weight: 700;
  z-index: 9999;
}
.kh-skip-link:focus { top: 0; }

/* 動きを控えめにしたいユーザーへの配慮 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ハイコントラスト設定への応答 */
@media (prefers-contrast: more) {
  :where(.bg-slate-900, .bg-slate-950, .bg-gray-900, .bg-gray-950,
         .bg-neutral-900, .bg-neutral-950, .bg-zinc-900, .bg-zinc-950,
         .bg-black, .bg-midnight-navy):not(.pitch-section) :is(
          [class*="text-white/"],
          .text-gray-400, .text-gray-500, .text-gray-600, .text-gray-700,
          .text-slate-400, .text-slate-500, .text-slate-600, .text-slate-700) {
    color: #FFFFFF !important;
  }
  .kh-btn-primary, .kh-btn-danger, .kh-btn-success, .kh-btn-warning { outline: 2px solid #FFFFFF; outline-offset: -4px; }
  .kh-input, .kh-select, .kh-textarea { border-width: 3px !important; }
}

/* 印刷時: ダークコンテキストを白背景＋黒文字に反転 */
@media print {
  :where(.bg-slate-900, .bg-slate-950, .bg-black, .bg-midnight-navy):not(.pitch-section):not(.chat-widget) {
    background: white !important;
    color: #0F172A !important;
  }
  :where(.bg-slate-900, .bg-slate-950, .bg-black, .bg-midnight-navy):not(.pitch-section):not(.chat-widget) [class*="text-white/"] {
    color: #0F172A !important;
  }
  .kh-btn { border: 1px solid #000 !important; }
}

/* ═════════ 14. レスポンシブ・ユーティリティ ═════════ */
@media (max-width: 640px) {
  /* スマホではボタン最低高さを少し大きく（親指到達） */
  .kh-btn, .kh-btn-primary, .kh-btn-secondary, .kh-btn-danger,
  .kh-btn-success, .kh-btn-warning, .kh-btn-ghost { min-height: 48px; }
  .kh-input, .kh-select, .kh-textarea { min-height: 48px; font-size: 16px; }  /* iOS ズーム対策 */
}

/* ═════════ 15. Web3.x スクロールバー統一 (2026-04-24) ═════════
 *
 * 目的: サイト全体でスクロールバーを "目立たない" かつ "美しい" 状態にする。
 *
 * 3階層の方針:
 *   (A) ページ縦スクロール: 細めの Web3.x グラデ (存在は見せる、圧は無くす)
 *   (B) 水平スクロール (カードカルーセル・テーブル等): 完全非表示、
 *       両端フェードで "scrollable" のヒントは残す
 *   (C) 明示 opt-in: .kh-no-scrollbar / .kh-fade-edge-x / .kh-fade-edge-y
 *
 * 保護: .pitch-section は独自デザインシステム所有 — 影響回避
 */

/* ── (A) ページ縦スクロール: 細く・Web3.x tinted ── */
html:not(.pitch-section) {
  scrollbar-width: thin;                                             /* Firefox */
  scrollbar-color: rgba(124, 58, 237, 0.25) transparent;             /* Firefox */
}
html:not(.pitch-section)::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
html:not(.pitch-section)::-webkit-scrollbar-track {
  background: transparent;
}
html:not(.pitch-section)::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg,
    rgba(8,145,178,0.25) 0%,
    rgba(124,58,237,0.25) 50%,
    rgba(192,38,211,0.25) 100%);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: padding-box;
}
html:not(.pitch-section)::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg,
    rgba(8,145,178,0.5) 0%,
    rgba(124,58,237,0.5) 50%,
    rgba(192,38,211,0.5) 100%);
  background-clip: padding-box;
}

/* ── (B) 水平スクロールコンテナ: デフォルトで完全非表示 ──
 *   Tailwind の overflow-x-auto / overflow-x-scroll を自動でカバー。
 *   モバイルでタッチスクロール維持。ホバー時のみ細線を表示（discoverability確保）。
 */
.overflow-x-auto:not(.pitch-section .overflow-x-auto),
.overflow-x-scroll:not(.pitch-section .overflow-x-scroll) {
  scrollbar-width: none;             /* Firefox */
  -ms-overflow-style: none;          /* IE/Edge */
}
.overflow-x-auto:not(.pitch-section .overflow-x-auto)::-webkit-scrollbar,
.overflow-x-scroll:not(.pitch-section .overflow-x-scroll)::-webkit-scrollbar {
  width: 0;
  height: 0;
  background: transparent;
}
/* desktopホバー時のみ細線 — モバイルには影響なし */
@media (hover: hover) and (pointer: fine) {
  .overflow-x-auto:not(.pitch-section .overflow-x-auto):hover {
    scrollbar-width: thin;
    scrollbar-color: rgba(124,58,237,0.35) transparent;
  }
  .overflow-x-auto:not(.pitch-section .overflow-x-auto):hover::-webkit-scrollbar {
    height: 4px;
  }
  .overflow-x-auto:not(.pitch-section .overflow-x-auto):hover::-webkit-scrollbar-thumb {
    background: rgba(124,58,237,0.35);
    border-radius: 2px;
  }
}

/* ── (C-1) 完全非表示ユーティリティ (opt-in) ── */
.kh-no-scrollbar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.kh-no-scrollbar::-webkit-scrollbar {
  width: 0;
  height: 0;
  display: none;
}

/* ── (C-2) 両端フェードで "スクロール可" の視覚ヒント (opt-in) ──
 *   水平スクロールバーを隠しつつ、端にフェードを見せることで
 *   「右にもっとある」というアフォーダンスを保つ。
 */
.kh-fade-edge-x {
  -webkit-mask-image: linear-gradient(to right,
    transparent 0,
    #000 16px,
    #000 calc(100% - 16px),
    transparent 100%);
          mask-image: linear-gradient(to right,
    transparent 0,
    #000 16px,
    #000 calc(100% - 16px),
    transparent 100%);
}

/* ── (C-3) チャット系の縦スクロール: ごく細く ── */
.kh-slim-scroll-y {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}
.kh-slim-scroll-y::-webkit-scrollbar {
  width: 4px;
}
.kh-slim-scroll-y::-webkit-scrollbar-track {
  background: transparent;
}
.kh-slim-scroll-y::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.15);
  border-radius: 4px;
}
.kh-slim-scroll-y::-webkit-scrollbar-thumb:hover {
  background: rgba(124,58,237,0.4);
}

/* 縮小モーション設定時: フェード/グラデの視覚変化を最小化 */
@media (prefers-reduced-motion: reduce) {
  html:not(.pitch-section)::-webkit-scrollbar-thumb {
    background: rgba(124,58,237,0.25);
  }
}

/* ═════════ 16. END ═════════ */
