/**
 * =====================================================
 * horomusume.net - 共通コンポーネントスタイル
 * =====================================================
 * 
 * 【概要】
 * 全フィルターツールで共通使用するUIコンポーネントのスタイルを定義。
 * design-tokens.cssの変数を使用。
 * 
 * 【使用方法】
 * @import '/css/shared/components.css';
 * ※ design-tokens.css の後に読み込むこと
 */

/* ========================================
   基本設定
   ======================================== */

html {
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-family);
  background-color: var(--c-bg);
  color: var(--c-text);
}

/* CLS防止: スクロールバー出現時のレイアウトシフトを防ぐ */
html {
  scrollbar-gutter: stable;
}

/* ========================================
   スクロールバー
   ======================================== */

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--c-scrollbar-track);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: var(--c-scrollbar-thumb);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--c-scrollbar-thumb-hover);
}

/* ========================================
   アクセシビリティ
   ======================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* ========================================
   ボタン
   ======================================== */

.custom-btn {
  color: #fff;
  font-weight: 600;
  font-size: var(--font-size-sm);
  padding: 10px var(--spacing-md);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: background-color var(--transition-fast);
  border: none;
  cursor: pointer;
}

.custom-btn:focus-visible {
  outline: 2px solid var(--c-focus-ring);
  outline-offset: 2px;
}

.custom-btn-primary {
  background-color: var(--c-primary);
}
.custom-btn-primary:hover {
  background-color: var(--c-primary-hover);
}
.custom-btn-primary:focus-visible {
  box-shadow: 0 0 0 2px var(--c-primary-border);
}

.custom-btn-success {
  background-color: var(--c-success);
}
.custom-btn-success:hover {
  background-color: var(--c-success-hover);
}

.custom-btn-danger {
  background-color: var(--c-error);
}
.custom-btn-danger:hover {
  background-color: var(--c-error-hover);
}

.custom-btn-secondary {
  background-color: var(--c-border);
  color: var(--c-text);
}
.custom-btn-secondary:hover {
  background-color: var(--c-border-strong);
}

/* ブランドカラーボタン */
.btn-brand-primary {
  background-color: var(--brand-primary);
  color: white;
}
.btn-brand-primary:hover {
  background-color: var(--brand-primary-hover);
}

.btn-brand-accent {
  background-color: var(--brand-accent);
  color: #000; /* 白文字は2.15:1でAA不合格。黒文字なら21.00:1 */
}
.btn-brand-accent:hover {
  background-color: var(--brand-accent-hover);
}

.btn-brand-neutral {
  background-color: var(--brand-neutral);
  color: white;
}
.btn-brand-neutral:hover {
  background-color: var(--brand-neutral-hover);
}

.reset-button {
  background-color: var(--brand-neutral);
}
.reset-button:hover {
  background-color: var(--brand-neutral-hover);
}

/* focus ring・transition 統一（リセット系ボタン） */
.search-reset-button,
.reset-button,
.reset-button-alt,
.gray-button,
.selection-reset-button {
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.search-reset-button:focus-visible,
.reset-button:focus-visible,
.reset-button-alt:focus-visible,
.gray-button:focus-visible,
.selection-reset-button:focus-visible {
  outline: 2px solid var(--c-focus-ring);
  outline-offset: 2px;
}

/* ========================================
   入力フィールド
   ======================================== */

.filter-input {
  width: 100%;
  padding: 0.625rem;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-lg);
  background-color: var(--c-bg);
  box-shadow: var(--shadow-sm);
  font-size: var(--font-size-base);
}

.filter-input:focus-visible {
  outline: 2px solid transparent;
  outline-offset: 2px;
  border-color: var(--c-focus-ring);
  box-shadow: 0 0 0 2px var(--c-focus-shadow);
}

/* 言語選択 */
.language-select-header {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--c-border-strong);
  border-radius: var(--radius-md);
  font-size: var(--font-size-xs);
  color: var(--c-text-sub);
  background-color: var(--c-bg-alt);
  min-width: 100px;
  box-shadow: var(--shadow-sm);
}

.language-select-header:focus-visible {
  border-color: var(--c-focus-ring);
  box-shadow: 0 0 0 2px var(--c-focus-shadow);
}

/* ========================================
   テーブル
   ======================================== */

.table-container {
  min-height: 300px; /* CLS防止: データ読込前にスペースを予約 */
  max-height: 70vh;
  max-width: 100%; /* テーブルがビューポートをはみ出さないよう制約 */
  overflow: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--c-border);
  box-shadow: var(--shadow-sm);
}

.table-container table {
  width: 100%;
  min-width: max-content;
  border-collapse: collapse;
}

.table-container th,
.table-container td {
  padding: 0.5rem 0.75rem;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--c-border);
  white-space: nowrap;
  font-size: var(--font-size-sm);
}

.table-container th {
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: var(--c-bg-header);
  cursor: pointer;
  user-select: none;
}

.table-container th:hover {
  background-color: var(--brand-neutral-light);
}

.table-container tbody tr:nth-child(odd) {
  background-color: var(--c-bg);
}

.table-container tbody tr:nth-child(even) {
  background-color: var(--c-bg-alt);
}

.table-container tbody tr:hover {
  background-color: var(--c-bg-hover) !important;
}

/* ソートインジケーター */
.sort-indicator {
  margin-left: 0.25rem;
  font-size: 0.65rem;
  display: inline-block;
  width: 1em;
}

/* 総合値カラム */
.total-stat-column {
  font-weight: 600;
  color: var(--c-primary);
}

/* ========================================
   セットA/B 選択行スタイル
   ======================================== */

.selected-row-a td {
  background-color: var(--c-set-a-bg) !important;
  color: var(--c-set-a-text);
  font-weight: 700;
}

.selected-row-b td {
  background-color: var(--c-set-b-bg) !important;
  color: var(--c-set-b-text);
  font-weight: 700;
}

/* ========================================
   サマリーパネル (セットA/B)
   ======================================== */

.summary-panel {
  padding: 0.75rem;
  border-radius: var(--radius-lg);
}

.summary-panel.set-a {
  background-color: var(--c-set-a-bg);
  border: 1px solid var(--c-set-a-border);
  color: var(--c-set-a-text-dark);
}

.summary-panel.set-a h4 {
  color: var(--c-set-a-text);
  border-bottom: 1px solid var(--c-set-a-border);
}

.summary-panel.set-b {
  background-color: var(--c-set-b-bg);
  border: 1px solid var(--c-set-b-border);
  color: var(--c-set-b-text-dark);
}

.summary-panel.set-b h4 {
  color: var(--c-set-b-text);
  border-bottom: 1px solid var(--c-set-b-border);
}

/* ========================================
   メッセージボックス
   ======================================== */

.message-box {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  color: #fff;
  padding: 1rem 1.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  z-index: 1000;
  display: none;
  opacity: 0;
  transition: opacity var(--transition-slow);
  text-align: center;
}

.message-box.show {
  display: block;
  opacity: 1;
}

.message-box.success {
  background-color: var(--c-success);
}

.message-box.error {
  background-color: var(--c-error);
}

.message-box.warning {
  background-color: var(--c-warning);
  color: #000; /* 白文字は2.15:1でAA不合格。黒文字なら21.00:1 */
}

.message-box.info {
  background-color: var(--c-info);
}

/* ========================================
   差分表示
   ======================================== */

.stat-diff {
  margin-left: 0.5rem;
  font-weight: 600;
  font-size: 0.9em;
}

.stat-diff.positive {
  color: var(--c-primary);
}

.stat-diff.negative {
  color: var(--c-error);
}

/* ========================================
   削除ボタン (×)
   ======================================== */

.deselect-item-btn {
  background-color: var(--c-border-strong);
  color: var(--c-text-sub);
  border: 1px solid var(--c-text-muted);
  border-radius: var(--radius-sm);
  /* 1.1rem(17.6px)は小さすぎるためタップ領域を拡大。
     一覧行の間隔が0.125rem(2px)しかなく隣接行と密接するため、
     完全な44pxではなくWCAG 2.2 AAの実寸下限(24px)相当まで広げる */
  width: 1.5rem;
  height: 1.5rem;
  font-size: 0.75rem;
  line-height: 1.4rem;
  text-align: center;
  margin-left: 0.5rem;
  cursor: pointer;
  transition: background-color var(--transition-fast),
    color var(--transition-fast);
}

.deselect-item-btn:hover {
  background-color: var(--c-text-muted);
  color: var(--c-text-dark);
}

/* ========================================
   モーダル
   ======================================== */

.custom-modal-overlay {
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition-normal),
    visibility var(--transition-normal);
}

.custom-modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.custom-modal-overlay > div {
  transform: scale(0.95);
  transition: transform var(--transition-normal);
}

.custom-modal-overlay.show > div {
  transform: scale(1);
}

.custom-modal-content {
  background-color: var(--c-bg);
  padding: var(--spacing-lg);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 400px;
}

/* ========================================
   レスポンシブ調整
   ======================================== */

/* モバイル: テーブル横スクロールインジケーター */
@media (max-width: 767px) {
  .table-scroll-hint {
    position: relative;
  }
  .table-scroll-hint::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 24px;
    background: linear-gradient(to right, transparent, rgba(255,255,255,0.8));
    pointer-events: none;
    border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
    z-index: 1;
    transition: opacity 0.3s;
  }
  .table-scroll-hint.scrolled-end::after {
    opacity: 0;
  }
}

@media (max-width: 640px) {
  .table-container {
    min-height: 200px; /* モバイル: 小さめの予約 */
    max-height: 50vh;
  }

  .table-container th,
  .table-container td {
    font-size: 0.7rem;
    padding: 0.25rem 0.5rem;
  }
}

@media (max-width: 767px) {
  /* iOSでのズーム防止 */
  input,
  select,
  textarea,
  .filter-input {
    font-size: 16px !important;
  }
}

@media (hover: none) and (pointer: coarse) {
  .custom-btn {
    min-height: 44px;
    touch-action: manipulation;
    white-space: nowrap;
  }

  input[type="checkbox"],
  input[type="radio"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
  }

  button,
  .btn,
  a.btn,
  [role="button"],
  input[type="button"],
  input[type="submit"],
  input[type="reset"],
  select {
    min-height: 44px;
    min-width: 44px;
  }

  input[type="text"],
  input[type="search"],
  input[type="email"],
  input[type="number"],
  textarea {
    min-height: 44px;
    font-size: 16px;
  }
}

/* ========================================
   タッチフィードバック（モバイル体験向上）
   ======================================== */

/* ボタン: 押し込み感 */
.custom-btn:active,
.btn-brand-primary:active,
.btn-brand-accent:active,
.btn-brand-neutral:active,
.reset-button:active {
  transform: scale(0.97);
  filter: brightness(0.92);
}

/* ボタン: 無効化（共通 disabled スタイル） */
.custom-btn:disabled,
.btn-brand-primary:disabled,
.btn-brand-accent:disabled,
.btn-brand-neutral:disabled,
.reset-button:disabled,
.custom-btn[aria-disabled="true"],
.btn-brand-primary[aria-disabled="true"],
.btn-brand-accent[aria-disabled="true"],
.btn-brand-neutral[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  filter: none;
  transform: none;
}

/* テーブル行: タップ確認 */
.table-container tbody tr:active {
  background-color: var(--c-bg-hover) !important;
}

/* テーブルヘッダー: タップフィードバック */
.table-container th:active {
  background-color: var(--brand-primary-light) !important;
}

/* チェックボックス・ラジオ: タップ領域拡大（タッチデバイスのみ） */
@media (hover: none) and (pointer: coarse) {
  input[type="checkbox"],
  input[type="radio"] {
    width: 22px;
    height: 22px;
  }

  label:has(input[type="checkbox"]),
  label:has(input[type="radio"]) {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    gap: 8px;
  }
}

/* ========================================
   テーブルレスポンシブ（横スクロール対応）
   ======================================== */

.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 1rem;
  position: relative;
}

.table-responsive::-webkit-scrollbar {
  height: 6px;
}

.table-responsive::-webkit-scrollbar-track {
  background: var(--c-scrollbar-track);
  border-radius: 3px;
}

.table-responsive::-webkit-scrollbar-thumb {
  background: var(--c-scrollbar-thumb);
  border-radius: 3px;
}

.table-responsive::-webkit-scrollbar-thumb:hover {
  background: var(--c-scrollbar-thumb-hover);
}

/* スクロール可能テーブルの右端フェードヒント（タッチデバイス） */
@media (hover: none) and (pointer: coarse) {
  .table-responsive {
    scrollbar-width: thin;
    scroll-snap-type: x proximity;
  }

  /* 右端フェード（スクロール到達時はJS側で .scroll-end クラスを付与して非表示） */
  .table-responsive:not(.scroll-end)::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 32px;
    background: linear-gradient(to right, transparent, rgba(255, 255, 255, 0.85));
    pointer-events: none;
  }
}

/* ========================================
   レイアウトユーティリティ
   ======================================== */

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .stack-mobile {
    flex-direction: column !important;
  }

  .stack-mobile > * {
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  .full-width-mobile {
    width: 100% !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 1rem !important;
    padding-right: 1rem !important;
  }
}

@media (min-width: 769px) {
  .hide-desktop {
    display: none !important;
  }
}

/* ========================================
   セーフエリア対応（ノッチ付きデバイス）
   ======================================== */

@supports (padding: env(safe-area-inset-top)) {
  .safe-area-top {
    padding-top: env(safe-area-inset-top, 0px);
  }

  .safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }
}

/* ========================================
   アクセシビリティ
   ======================================== */

@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: high) {
  button,
  .btn,
  input,
  select {
    border: 2px solid currentColor !important;
  }
}

/* ========================================
   お知らせバナー（全ページ共通）
   ======================================== */

.global-announcement {
  background: var(--brand-primary-light, #dbeafe);
  border-bottom: 1px solid var(--c-primary-border, #93c5fd);
  margin: calc(var(--space-4) * -1) calc(var(--space-4) * -1) var(--space-4);
  padding: var(--space-3) var(--space-4);
  transition: opacity 200ms ease, transform 200ms ease;
}

.global-announcement-inner {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
}

.global-announcement-content {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  min-width: 0;
}

.global-announcement-icon {
  flex-shrink: 0;
  color: var(--brand-primary, #1d4ed8);
  margin-top: 1px;
}

.global-announcement-text {
  font-size: 0.8125rem;
  line-height: 1.6;
  color: var(--c-text, #374151);
}

.global-announcement-close {
  flex-shrink: 0;
  padding: 4px;
  border-radius: 4px;
  color: var(--c-text-sub, #6b7280);
  cursor: pointer;
  background: none;
  border: none;
  transition: background-color 200ms ease, color 200ms ease;
}

.global-announcement-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--c-text, #374151);
}

/* ========================================
   ダークモードトグルボタン
   ======================================== */

.theme-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  border: 1px solid var(--c-border);
  background: var(--c-bg);
  color: var(--c-text-sub);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

.theme-toggle-btn:hover {
  background: var(--brand-neutral-light);
  color: var(--c-text-dark);
}

.theme-toggle-btn:focus-visible {
  outline: 2px solid var(--c-focus-ring);
  outline-offset: 2px;
}

@media (hover: none) and (pointer: coarse) {
  .theme-toggle-btn {
    min-width: 44px;
    min-height: 44px;
  }
}

/* ========================================
   印刷対応
   ======================================== */

@media print {
  .no-print {
    display: none !important;
  }

  .table-responsive {
    overflow: visible;
  }

  body {
    font-size: 12pt;
    line-height: 1.4;
  }
}

/* ========================================
   SNS シェアボタン（FAB + ポップオーバー）
   ======================================== */

.sns-share-fab {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 900;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #000;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 200ms ease, box-shadow 200ms ease, opacity 300ms ease;
}

.sns-share-fab.fab-hidden {
    opacity: 0;
    pointer-events: none;
}

.sns-share-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.sns-share-popover {
    position: fixed;
    bottom: 5rem;
    right: 1.5rem;
    z-index: 901;
    display: flex;
    flex-direction: column;
    gap: 2px;
    background: #fff;
    border: 1px solid var(--c-border, #e5e7eb);
    border-radius: 8px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
    padding: 0.25rem;
    min-width: 200px;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 200ms ease, transform 200ms ease;
}

.sns-share-popover-open {
    opacity: 1;
    transform: translateY(0);
}

.sns-share-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border: none;
    background: none;
    color: var(--c-text, #374151);
    font-size: 0.8125rem;
    cursor: pointer;
    border-radius: 6px;
    transition: background-color 200ms ease;
    width: 100%;
    text-align: left;
}

.sns-share-item:hover {
    background: var(--c-surface, #f9fafb);
}

.sns-share-item svg {
    flex-shrink: 0;
}

@media (max-width: 640px) {
    .sns-share-fab {
        bottom: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
    }
    .sns-share-popover {
        bottom: 4.25rem;
        right: 1rem;
    }
}

/* ボトムナビ対応: FAB・ポップオーバーをナビバーの上方に移動 */
@media (max-width: 767px) {
    .sns-share-fab {
        bottom: calc(60px + env(safe-area-inset-bottom) + 0.75rem);
        right: 1rem;
    }
    .sns-share-popover {
        bottom: calc(8rem + env(safe-area-inset-bottom));
        right: 1rem;
    }
}

/* ========================================
   サイトフッター（E-E-A-T対応）
   ======================================== */

.site-footer {
    margin-top: auto;
    padding: 2rem 1rem 1.5rem;
    text-align: center;
    font-size: 0.75rem;
    color: var(--c-text-muted);
    border-top: 1px solid var(--c-border, #e5e7eb);
    background: var(--c-bg, #fff);
    position: relative;
    z-index: 20;
}

.site-footer-inner {
    max-width: 600px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.site-footer-note {
    color: var(--c-text-muted);
}

.site-footer-author a {
    color: #6b7280;
    text-decoration: none;
    transition: color 200ms ease;
}

.site-footer-author a:hover {
    color: #374151;
    text-decoration: underline;
}

.site-footer-trust {
    color: var(--c-text-muted);
    font-size: 0.6875rem;
}

.site-footer-links a {
    color: #6b7280;
    text-decoration: none;
    transition: color 200ms ease;
}

.site-footer-links a:hover {
    color: #374151;
    text-decoration: underline;
}

.site-footer-copy a {
    color: var(--c-text-muted);
    text-decoration: none;
    transition: color 200ms ease;
}

.site-footer-copy a:hover {
    color: #6b7280;
    text-decoration: underline;
}

/* ========================================
   広告ユニット
   ======================================== */

.ad-unit {
    text-align: center;
    margin: 2rem auto;
    overflow: hidden;
}
.ad-unit:empty { display: none; }
.ad-unit ins { display: block; }

/* 広告ダミー（レイアウト確認用・審査通過後に削除） */
.ad-dummy {
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 6px;
    padding: 1.5rem 1rem;
    color: var(--c-text-muted);
    font-size: 0.8rem;
    min-height: 90px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    max-width: 728px;
    margin: 0 auto;
}

/* ========================================
   バッジ / タグ
   ======================================== */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: var(--font-size-xs);
    font-weight: 500;
    line-height: var(--line-height-dense);
    white-space: nowrap;
}

.badge-primary {
    background-color: var(--brand-primary-light);
    color: var(--c-primary-text);
}

.badge-accent {
    background-color: var(--brand-accent-light);
    color: #92400e;
}

.badge-neutral {
    background-color: var(--brand-neutral-light);
    color: var(--c-text-sub);
}

.badge-success {
    background-color: var(--c-success-light);
    color: #065f46;
}

.badge-error {
    background-color: #fee2e2;
    color: #991b1b;
}

.badge-outline {
    background-color: transparent;
    border: 1px solid var(--c-border);
    color: var(--c-text-sub);
}

.badge-coming-soon {
    background-color: var(--brand-neutral-light);
    color: var(--c-text-sub);
    border: 1px solid var(--c-border);
    font-size: 0.6875rem;
    letter-spacing: 0.02em;
}

/* ========================================
   タブ
   ======================================== */

.tab-group {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tab-item {
    padding: 6px 14px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    background: var(--c-bg);
    color: var(--c-text-sub);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

.tab-item:hover {
    background: var(--brand-neutral-light);
}

.tab-item:focus-visible {
    outline: 2px solid var(--c-focus-ring);
    outline-offset: 2px;
}

.tab-item.active {
    background: #000;
    color: #fff;
    border-color: #000;
}

/* ========================================
   カード
   ======================================== */

.card {
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-xl);
    padding: var(--spacing-md) var(--spacing-lg);
    transition: border-color 200ms ease, box-shadow 200ms ease;
}

.card:hover {
    border-color: var(--c-border-strong);
    box-shadow: var(--shadow-md);
}

.card-link {
    text-decoration: none;
    color: inherit;
    display: block;
}

.card-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--c-text-dark);
    margin: 0 0 4px;
    letter-spacing: var(--letter-spacing-tight);
}

.card-desc {
    font-size: 0.8125rem;
    color: var(--c-text-sub);
    margin: 0;
    line-height: var(--line-height-normal);
}

/* ========================================
   ローディングスピナー
   ======================================== */

@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 24px;
    height: 24px;
    border: 2px solid var(--c-border);
    border-top-color: var(--brand-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 2px;
}

.spinner-lg {
    width: 36px;
    height: 36px;
    border-width: 3px;
}

/* ========================================
   スケルトンローダー
   ======================================== */

@keyframes skeleton-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.skeleton {
    background-color: var(--brand-neutral-light);
    border-radius: var(--radius-md);
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.skeleton-text {
    height: 0.875rem;
    margin-bottom: 0.5rem;
}

.skeleton-text:last-child {
    width: 60%;
}

.skeleton-heading {
    height: 1.25rem;
    width: 40%;
    margin-bottom: 0.75rem;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    height: 80px;
    margin-bottom: 0.5rem;
}

/* ========================================
   空状態
   ======================================== */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-md);
    text-align: center;
}

.empty-state-icon {
    width: 48px;
    height: 48px;
    color: var(--c-border-strong);
    margin-bottom: var(--spacing-md);
}

.empty-state-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--c-text);
    margin: 0 0 var(--spacing-xs);
}

.empty-state-desc {
    font-size: var(--font-size-sm);
    color: var(--c-text-sub);
    margin: 0 0 var(--spacing-md);
    max-width: 360px;
    line-height: var(--line-height-normal);
}

.empty-state-action {
    margin-top: var(--spacing-sm);
}

/* C1: 空状態の「次の一手」CTA群（ボタンを横並び配置） */
.empty-state-cta {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    justify-content: center;
    margin-top: var(--spacing-md);
}
.empty-state-cta .custom-btn {
    font-size: var(--font-size-sm);
    padding: 8px 14px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}
@media (max-width: 480px) {
    .empty-state-cta {
        flex-direction: column;
        align-items: stretch;
    }
    .empty-state-cta .custom-btn {
        justify-content: center;
    }
}

/* ========================================
   エラー状態
   ======================================== */

.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-md);
    text-align: center;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: var(--radius-lg);
}

.error-state-icon {
    width: 48px;
    height: 48px;
    color: var(--c-error);
    margin-bottom: var(--spacing-md);
}

.error-state-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: #991b1b;
    margin: 0 0 var(--spacing-xs);
}

.error-state-desc {
    font-size: var(--font-size-sm);
    color: #7f1d1d;
    margin: 0 0 var(--spacing-md);
    max-width: 360px;
    line-height: var(--line-height-normal);
}

.error-state-retry {
    padding: 8px 20px;
    background: var(--c-error);
    color: #fff;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-sm);
    font-weight: 500;
    cursor: pointer;
    transition: background-color 200ms ease;
}

.error-state-retry:hover {
    background: var(--c-error-hover);
}

.error-state-retry:focus-visible {
    outline: 2px solid var(--c-error);
    outline-offset: 2px;
}

/* ========================================
   ツールチップ
   ======================================== */

.tooltip-wrapper {
    position: relative;
    display: inline-flex;
}

.tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    padding: 6px 10px;
    background: #1f2937;
    color: #fff;
    font-size: var(--font-size-xs);
    line-height: var(--line-height-dense);
    border-radius: var(--radius-md);
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity 200ms ease;
    z-index: var(--z-tooltip, 600);
}

.tooltip::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}

.tooltip-wrapper:hover .tooltip,
.tooltip-wrapper:focus-within .tooltip {
    opacity: 1;
}

/* ========================================
   アコーディオン (details/summary)
   ======================================== */

.accordion {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.accordion + .accordion {
    margin-top: -1px;
}

.accordion-header {
    padding: 12px 16px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--c-text-dark, #000);
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background-color 200ms ease;
}

.accordion-header:hover {
    background: var(--brand-neutral-light);
}

.accordion-header:focus-visible {
    outline: 2px solid var(--c-focus-ring);
    outline-offset: -2px;
}

.accordion-header::-webkit-details-marker {
    display: none;
}

.accordion-header::after {
    content: "";
    width: 16px;
    height: 16px;
    margin-left: auto;
    flex-shrink: 0;
    background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7'/%3E%3C/svg%3E") center / contain no-repeat;
    transition: transform 200ms ease;
}

.accordion[open] .accordion-header::after {
    transform: rotate(180deg);
}

.accordion-body {
    padding: 0 16px 14px;
    font-size: var(--font-size-sm);
    color: var(--c-text-sub);
    line-height: var(--line-height-normal);
}

/* ========================================
   ローディングコンテナ（中央配置）
   ======================================== */

.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: var(--spacing-xl) var(--spacing-md);
    gap: var(--spacing-sm);
}

.loading-state-text {
    font-size: var(--font-size-sm);
    color: var(--c-text-sub);
}

/* ========================================
   使い方ガイド（モーダル）
   ======================================== */

.help-guide-body {
    padding: 16px;
    font-size: 13px;
    line-height: 1.7;
}

.help-guide-steps {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
}

.help-guide-step {
    display: flex;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 1px solid #f3f4f6;
}

.help-guide-step:last-child {
    border-bottom: none;
}

.help-guide-step-num {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--c-primary, #1d4ed8);
    color: #fff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 600;
}

.help-guide-step-text {
    padding-top: 2px;
}

.help-guide-step-text strong {
    color: var(--c-text-dark, #000);
}

.help-guide-tips {
    padding: 10px 14px;
    background: #fffbeb;
    border-radius: var(--radius-md);
    font-size: 12px;
}

.help-guide-tips-title {
    font-weight: 600;
    color: var(--c-text-dark, #000);
    margin-bottom: 4px;
}

.help-guide-tips ul {
    margin: 4px 0 0;
    padding: 0 0 0 16px;
}

.help-guide-tips li {
    color: var(--c-text-sub, #6b7280);
    margin-bottom: 2px;
}

/* モーダル */
.help-guide-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 200ms ease, visibility 200ms ease;
}

.help-guide-overlay.active {
    opacity: 1;
    visibility: visible;
}

.help-guide-modal {
    position: relative;
    width: 92%;
    max-width: 500px;
    max-height: min(809px, 90vh);
    background: #fff;
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    transform: translateY(8px);
    transition: transform 200ms ease;
}

.help-guide-overlay.active .help-guide-modal {
    transform: translateY(0);
}

.help-guide-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--c-border);
    flex-shrink: 0;
}

.help-guide-modal-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--c-text-dark, #000);
}

.help-guide-modal-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    color: var(--c-text-sub, #6b7280);
    transition: background-color 200ms ease;
}

.help-guide-modal-close:hover {
    background: #f3f4f6;
}

.help-guide-modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

@media (max-width: 640px) {
    .help-guide-modal {
        width: 96%;
        max-height: 85vh;
    }

    .help-guide-body {
        padding: 12px;
    }

    .help-guide-step {
        gap: 8px;
    }
}

/* ========================================
   モバイル向けボタンサイジング（人間工学ベース）
   ======================================== */

@media (hover: none) and (pointer: coarse) {
  /* Primary: タップ可能かつ抑制された上品なサイズ */
  .custom-btn-primary,
  .btn-brand-primary,
  .btn-brand-accent {
    min-height: 44px;
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius-lg, 0.5rem);
  }

  /* Secondary: リセット系ボタン — Primaryより控えめ */
  .custom-btn-secondary,
  .btn-brand-neutral,
  .reset-button,
  .search-reset-button,
  .gray-button,
  .selection-reset-button {
    min-height: 40px;
    padding: 8px 16px;
    font-size: 0.8125rem;
    font-weight: 600;
  }

  /* Tertiary: 補助操作 — 最小限だがタップ可能 */
  .custom-btn-danger,
  .reset-button-alt,
  .copy-button {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.75rem;
    font-weight: 500;
  }

  /* モバイルでリセットボタン説明文を非表示 */
  .reset-btn-desc {
    display: none;
  }

  /*
   * ボタン間の最小間隔（誤タップ防止）。横並びの通常幅ボタン専用。
   * w-full（縦積みの全幅ボタン）には適用しない — margin-leftが
   * コンテナ右端からのはみ出しを起こすため（2026-08-29 tsukumo-filter/
   * eiketsu-filterで発覚）。縦積みの間隔は各ページのgap/space-yで担保する。
   */
  .custom-btn:not(.w-full) + .custom-btn:not(.w-full),
  .btn-brand-primary:not(.w-full) + .btn-brand-primary:not(.w-full),
  .btn-brand-primary:not(.w-full) + .btn-brand-neutral:not(.w-full),
  .btn-brand-neutral:not(.w-full) + .btn-brand-primary:not(.w-full) {
    margin-left: var(--touch-spacing, 8px);
  }
}

/* ========================================
   テーブル行高の最適化（タッチデバイス）
   ======================================== */

@media (hover: none) and (pointer: coarse) {
  .table-container tbody td {
    padding: 0.625rem 0.5rem;
    min-height: 48px;
    line-height: 1.4;
  }

  .table-container th {
    padding: 0.75rem 0.5rem;
    min-height: 48px;
  }
}

/* ========================================
   ソート可能列の視覚的区別（常時表示）
   ======================================== */

.table-container th.sortable {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding-right: 1.25rem;
}

.table-container th.sortable::after {
  content: '\2195';
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.25;
  font-size: 0.7em;
}

.table-container th.sortable.sort-asc::after {
  content: '\25B2';
  opacity: 0.7;
}

.table-container th.sortable.sort-desc::after {
  content: '\25BC';
  opacity: 0.7;
}

/* ========================================
   横スクロールヒント強化（タッチデバイス）
   ======================================== */

@media (hover: none) and (pointer: coarse) {
  .table-responsive.needs-scroll::before {
    content: '';
    position: absolute;
    right: 8px;
    top: 50%;
    width: 24px;
    height: 24px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%236b7280' stroke-width='1.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M7.5 21L3 16.5m0 0L7.5 12M3 16.5h13.5m0-13.5L21 7.5m0 0L16.5 12M21 7.5H7.5'/%3E%3C/svg%3E");
    background-size: contain;
    opacity: 0;
    animation: scroll-hint 2s ease-in-out 1;
    pointer-events: none;
    z-index: 5;
  }

  @keyframes scroll-hint {
    0%, 100% { transform: translateX(0) translateY(-50%); opacity: 0; }
    30% { opacity: 0.6; }
    50% { transform: translateX(-12px) translateY(-50%); opacity: 0.6; }
    70% { opacity: 0.6; }
  }
}

/* ========================================
   エラー状態・オフラインバナー
   ======================================== */

.horo-offline-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #fef2f2;
  color: #991b1b;
  border-bottom: 2px solid #ef4444;
  padding: 10px 16px;
  font-size: 14px;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}

.horo-error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  text-align: center;
  gap: 8px;
}

.horo-error-title {
  font-size: 14px;
  color: var(--c-text-sub, #6b7280);
  margin: 8px 0 0;
}

.horo-stale-notice {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fcd34d;
  border-radius: var(--radius-md, 6px);
  padding: 6px 12px;
  font-size: 12px;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (prefers-color-scheme: dark) {
  .horo-offline-banner {
    background: #450a0a;
    color: #fecaca;
    border-color: #dc2626;
  }
  .horo-stale-notice {
    background: #451a03;
    color: #fef3c7;
    border-color: #d97706;
  }
}

/* ========================================
   設定バックアップ
   ======================================== */

.horo-private-warning {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%);
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #f59e0b;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  z-index: 800;
  display: flex;
  align-items: center;
  box-shadow: var(--shadow-md);
  max-width: 90vw;
}

@media (prefers-color-scheme: dark) {
  .horo-private-warning {
    background: #451a03;
    color: #fef3c7;
    border-color: #d97706;
  }
}

/* ページリード文（2026-09-09拡充: SEO/AIO向けに 100〜250字程度の説明文を表示する。
   目立たせすぎない小さめ・控えめな配色に留める）
   2026-09-13: 配置を本文末尾（.page-intro-tail）へ変更。ファーストビューを消費させないため。
   ヘッダー直後に置く旧レイアウトは、本文が見つからないページ向けの退避動作としてのみ残す。 */
.page-intro {
  display: block;
  margin: 0;
  padding: 10px 32px;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--c-text-sub);
  background: var(--c-bg);
  border-bottom: 1px solid var(--brand-neutral-light);
}

/* 本文末尾に置かれたリード文。.app-main の左右パディング内に入るため
   自前の左右パディングは持たず、本文との区切りは上罫線で示す。
   .app-main は flex column のため、flex-shrink:0 で高さを潰さない。 */
.page-intro-tail {
  flex-shrink: 0;
  margin: 24px 0 0;
  padding: 16px 0 0;
  background: transparent;
  border-bottom: 0;
  border-top: 1px solid var(--brand-neutral-light);
}

@media (max-width: 767px) {
  .page-intro {
    padding: 8px 16px;
    font-size: 0.7rem;
  }

  .page-intro-tail {
    margin-top: 16px;
    padding: 12px 0 0;
  }
}

/* ========================================
   共通タップ領域の是正（2026-08-19）
   ------------------------------------------------------------
   [data-info-provide] は11ページにインラインstyleで直書きされており、
   inline style は外部CSSより優先度が高いため !important が必要
   ======================================== */
@media (max-width: 767px) {
  [data-info-provide] {
    min-height: 44px !important;
    min-width: 44px !important;
  }
}

/* ========================================
   button 実体クラス（サイト全体UI統一 Phase3・2026-08-22）
   ------------------------------------------------------------
   .btn-brand-* は色のみのmodifierでサイズ・角丸を持たず、各ページが
   個別にpadding/border-radiusを定義していたため角丸が7種類に分散していた。
   ここでは高さ・padding・角丸を持つ「実体」を新設する。
   既存の .custom-btn / .btn-brand-* は変更せず、併用可能なクラスとして追加のみ行う
   （class="btn btn-brand-primary" のように色は既存クラスと組み合わせる）。
   ======================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--spacing-sm);             /* 8px */
  min-height: var(--touch-target-sm); /* 44px 通常ボタン */
  padding: 0 var(--spacing-md);       /* 16px */
  border-radius: var(--radius-lg);    /* 8px */
  font-size: var(--font-size-sm);     /* 14px */
  font-weight: 600;
  box-sizing: border-box;
  white-space: nowrap;
  border: none;
  cursor: pointer;
}
.btn-cta {
  /* 強調CTA。通常ボタンより一段大きい */
  min-height: var(--touch-target-md); /* 48px */
  font-size: var(--font-size-base);   /* 16px */
}
.btn-icon {
  /* アイコンのみボタン。正方形でタップ領域を確保 */
  min-width: var(--touch-target-sm);
  min-height: var(--touch-target-sm);
  padding: 0;
  border-radius: var(--radius-lg);
}
.btn-danger {
  background-color: var(--c-error);
  color: #fff;
}
.btn-danger:hover {
  background-color: var(--c-error-hover);
}
.btn-danger:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* ========================================
   最小タップ領域の保証（幅ベース・2026-08-22）
   ------------------------------------------------------------
   既存の @media(hover:none) and (pointer:coarse) ブロック（上記）は
   「タッチ最適化」としてpadding/font-sizeまで含むフルセットを担う。
   このブロックは目的が異なり、マウス＋狭幅ウィンドウ（折りたたみ端末・
   デスクトップの分割表示等）でもタップ領域の最低ラインだけを保証する。
   min-height/min-widthのみを担当し、padding/font-sizeはhover:coarse側に
   委譲する（!importantも付けない。置き換えではなく補完として共存させる） */
@media (max-width: 767px) {
  .btn,
  .btn-icon,
  /* Primary系（既存 pointer:coarse ブロックで既に44px化対象）は、
     マウス＋狭幅ウィンドウでも同じ44pxを保証する。Secondary(40px)/
     Tertiary(36px)の階層は変更しない（既存の意図的な視覚階層のため）。
     .custom-btn 自体に display 指定がなく <a class="custom-btn ..."> が
     既定の display:inline のままだと min-height が効かないため、
     inline-flex を明示する（kashin-data-sim の導線リンクで実測確認） */
  .custom-btn-primary,
  .btn-brand-primary,
  .btn-brand-accent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--touch-target-sm);
  }
  .btn-icon {
    min-width: var(--touch-target-sm);
  }
  .btn-cta {
    min-height: var(--touch-target-md);
  }
}
