/* ==========================================================================
   Hawkeye 画面モックアップ（Rails 版）スタイル
   - body 直下にアプリシェルを置き、各画面をフルスクリーンで表示する
   - サイドバーのアイコンは href ではなく data-icon で引く（Rails のパスに依存させない）
   - ドロップダウン・モーダル・トグル・スパークラインなど、Stimulus が動かす部品を持つ
   デザイントークンは DESIGN.md「Verdana Health デザインシステム」に一致させている。
   ========================================================================== */

:root {
  /* --- ブランドカラー（DESIGN.md「カラー」） --- */
  /* ライトテーマ（既定）：モノトーン。アクセントは黒系。ダークは下の :root[data-theme="dark"] で反転 */
  --c-primary: #16181F;       /* プライマリ 黒系：主要アクション（黒ボタン＋白文字） */
  --c-primary-hover: #2C313F;
  --c-on-primary: #FFFFFF;    /* primary 面に乗る文字（ライト=白 / ダーク=濃色） */
  --c-slate: #64748B;         /* セカンダリ スレート：補助テキスト・ボーダー */
  --c-sage: #16181F;          /* アクセント（本文側の図形・グラフ・トグル等）。変数名は据え置き */
  --c-sage-text: #16181F;     /* リンク等（黒） */
  --c-sage-hover: #000000;
  --c-sidebar-accent: #CDD2DD; /* 常時暗いサイドバー上のアクセント（アクティブ印・Pro タグ）。両テーマ共通の明色 */
  --c-bg: #F9FAFB;            /* ページ背景：中立の白ベース（ほぼ白） */
  --c-surface: #FFFFFF;       /* カード背景 */
  --c-success: #22C55E;
  --c-warning: #EAB308;
  --c-error: #EF4444;
  --c-info: #0EA5E9;

  /* 面塗り（15% ティント）と、その上で十分な視認性を持つ前景色。
     前景色はティント地（≒白）に対して 4.5:1 以上を満たす値に落としてある。 */
  --c-success-bg: #22C55E15;  --c-success-fg: #15803D;   /* 5.0:1 */
  --c-warning-bg: #EAB30815;  --c-warning-fg: #A16207;   /* 4.9:1 */
  --c-error-bg:   #EF444415;  --c-error-fg:   #DC2626;   /* 4.8:1 */
  --c-info-bg:    #0EA5E915;  --c-info-fg:    #0369A1;   /* 5.9:1 */

  --c-line: #E2E8F0;          /* 標準ボーダー */
  --c-line-soft: #F1F5F9;     /* リスト区切り線 */
  --c-line-strong: #CBD5E1;   /* 強めのボーダー（チェックボックス枠・トグル軌道・破線など） */
  --c-text: #0F172A;          /* 本文 */
  --c-text-2: #475569;        /* ヘルパー・説明文 */

  /* 黒サイドバー面上の補助テキスト（ニュートラルな明色）。--c-slate は濃地では AA 未達のため別に持つ。 */
  --c-on-navy-2: #AEB4C0;     /* 黒サイド（#14161E）上で読める中立グレー */

  /* フォーカスリング。面に応じて色を切り替える */
  --c-focus: #16181F;         /* 白地で黒のリング */
  --c-focus-on-navy: #E2E8F0;

  /* テーブル用のスレート淡色。ページ背景（--c-bg）を流用すると
     ヘッダーが背景と同化し、白い行のホバーも判別できなくなるため別に持つ。 */
  --c-table-head: #E8EDF4;    /* 見出し行：ページ背景より 1 段暗い */
  --c-row-hover: #EDF2F8;     /* 行ホバー：白い行の上ではっきり分かる濃さ */

  /* --- エレベーション（拡散・低不透明。Don't #9「重い影を使わない」） --- */
  --sh-sm: 0 1px 3px rgba(15, 23, 42, .03);
  --sh:    0 2px 6px rgba(15, 23, 42, .05);
  --sh-md: 0 4px 16px rgba(15, 23, 42, .07);
  --sh-lg: 0 8px 32px rgba(15, 23, 42, .10);

  /* --- 角丸 --- */
  --r-sm: 4px;    /* バッジ・タグ */
  --r: 8px;       /* ボタン・カード・入力欄 */
  --r-md: 12px;   /* モーダル・ドロップダウンパネル */
  --r-lg: 16px;   /* 大型コンテナ */
  --r-full: 9999px;

  /* --- タイポグラフィ（ローカルにあれば指定フォント、なければ OS 標準を使う） --- */
  --f-latin: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --f-jp: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic Medium", "Yu Gothic", Meiryo, sans-serif;

  --f-head: "Plus Jakarta Sans", "Noto Sans JP", var(--f-latin), var(--f-jp);
  --f-body: "DM Sans", "Noto Sans JP", var(--f-latin), var(--f-jp);
  --f-mono: "Fira Code", "Noto Sans Mono CJK JP", ui-monospace, SFMono-Regular,
            Menlo, Consolas, monospace;

  /* --- wf-* はワイヤーフレーム由来の名前。クラス語彙を保つため据え置き --- */
  --wf-border: var(--c-line);
  --wf-bg: var(--c-bg);
  --wf-box: var(--c-line-soft);
  --wf-dark: var(--c-primary);
  --wf-text: var(--c-text);
  --wf-muted: var(--c-slate);
  --wf-note: var(--c-info);
  --wf-up: var(--c-success);
  --wf-down: var(--c-error);
  --wf-pending: var(--c-slate);
  /* サイドバー（左メニュー）は黒＝近黒の中立色。コンテンツは白。
     ライト/ダークとも左メニューは暗いままで、切り替わるのは主にコンテンツ側（白／暗色）。 */
  --wf-sidebar: #14161E;
  --wf-sidebar-active: rgba(255, 255, 255, .14);
}

/* ============================================================================
   ダークテーマ（Indigo Night）。<html data-theme="dark"> で適用。
   初期属性は shared/_theme_init の先読みスクリプトが OS 設定 / localStorage から立てる。
   ライトの各トークンをここで上書きする（面・文字・境界を暗く、ブランドは淡インディゴへ）。
   ============================================================================ */
:root[data-theme="dark"] {
  --c-primary: #E6E8F2;       /* 主要アクション：白系（暗地・濃文字で潰れない） */
  --c-primary-hover: #FFFFFF;
  --c-on-primary: #16181F;    /* 白系ボタンに乗る濃文字 */
  --c-sage: #CDD2DD;          /* アクセント（淡色） */
  --c-sage-text: #CDD2DD;     /* リンク（淡色） */
  --c-sage-hover: #FFFFFF;

  /* 硬さを抑えるため、背景は純黒でなく少し持ち上げ、文字は純白でなく柔らかいオフホワイトにする */
  --c-bg: #191C24;            /* ページ背景（近黒より一段明るいダークスレート） */
  --c-surface: #20242F;       /* カード・入力欄・モーダル */
  --c-line: #2C3140;          /* 標準ボーダー */
  --c-line-soft: #242834;     /* 区切り線 */
  --c-line-strong: #3B4152;   /* 強めのボーダー */
  --c-text: #CDD2DD;          /* 本文：純白を避けた柔らかいオフホワイト（背景に約 11:1） */
  --c-text-2: #939AAC;        /* ヘルパー・説明文 */
  --c-slate: #868DA0;         /* 補助・プレースホルダ */
  --c-table-head: #242835;    /* テーブル見出し行 */
  --c-row-hover: #232732;     /* 行ホバー */

  --wf-sidebar: #14161E;      /* サイドバー：近黒の中立色（ライトと同じ） */
  --c-on-navy-2: #AEB4C0;

  --c-focus: #CDD2DD;         /* 暗地で見えるフォーカスリング（淡色） */

  /* ステータス文字は暗地で読める明るい版に（面塗りは 15% ティントのまま） */
  --c-success-fg: #4ADE80;
  --c-warning-fg: #FCD34D;
  --c-error-fg:   #F87171;
  --c-info-fg:    #7DD3FC;

  /* 影は暗地では黒を強めて存在感を出す */
  --sh-sm: 0 1px 3px rgba(0, 0, 0, .30);
  --sh:    0 2px 6px rgba(0, 0, 0, .38);
  --sh-md: 0 4px 16px rgba(0, 0, 0, .48);
  --sh-lg: 0 8px 32px rgba(0, 0, 0, .58);
}

/* サイドバーのテーマ切替トグル（両テーマとも暗いサイド地の上に載る） */
.wf-theme { padding: 2px 8px 6px; }
.wf-theme-toggle {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: var(--r);
  background: transparent; border: 0; cursor: pointer; text-align: left;
  color: var(--c-on-navy-2); font-size: 13px; font-family: var(--f-body);
  transition: background .15s, color .15s;
}
.wf-theme-toggle:hover { background: rgba(255, 255, 255, .06); color: #E2E8F0; }
.wf-theme-toggle:focus-visible { outline: 2px solid var(--c-focus-on-navy); outline-offset: -2px; }
.wf-theme-toggle .ic-emoji { font-size: 14px; width: 20px; text-align: center; }

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

/* フォーカスリング（全体既定）。ブランドの淡いリング（#065F4618 = 9%）は
   緑のボタン上でほぼ見えないため、実線のアウトラインを基準にする。 */
:focus-visible {
  outline: 2px solid var(--c-focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}

/* スクリーンリーダー専用テキスト（色だけに意味を持たせないため） */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip-path: inset(50%); white-space: nowrap;
}

/* 本文へスキップ（キーボード利用者。フォーカス時のみ可視化） */
.skip-link {
  position: absolute; left: 8px; top: -100px;
  z-index: 100;
  background: var(--c-surface);
  color: var(--c-primary);
  border: 1px solid var(--c-line);
  border-radius: var(--r);
  box-shadow: var(--sh-md);
  padding: 10px 16px;
  font-size: 14px; font-weight: 500;
  text-decoration: none;
  transition: top .15s;
}
.skip-link:focus-visible { top: 8px; color: var(--c-primary); }

/* モーション低減の要求に従う（アニメーションは一律で無効化） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

body {
  font-family: var(--f-body);
  background: var(--c-bg);
  color: var(--c-text);              /* 本文は #0F172A。--c-text-2 はヘルパー用に明示指定する */
  font-size: 16px;                   /* Body 16px / 1.75（和文のため行間を広く） */
  font-weight: 500;                  /* 400 は Noto Sans JP で細く見えるため 500 を基準にする */
  line-height: 1.75;
  /* antialiased（グレースケール）は Mac で字画が細って見えるため使わない。
     既定の subpixel/auto に任せて字画をしっかり描く。 */
  text-rendering: optimizeLegibility;
}

/* 数値は等幅で桁を揃える（Do #10） */
.num, .wf-kv td.v, table td, .badge.method, code {
  font-variant-numeric: tabular-nums;
}

/* 注釈（仕様メモ）— 情報カラーのコールアウト -------------------------------- */
.note {
  font-size: 12px;
  line-height: 1.6;
  color: var(--c-info-fg);
  background: var(--c-info-bg);
  border: none;
  border-left: 3px solid var(--c-info);
  border-radius: 0 var(--r) var(--r) 0;
  padding: 10px 14px;
  margin-top: 16px;
}

/* プレースホルダ箱 --------------------------------------------------------- */
.box {
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  border-radius: var(--r);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--c-slate);
  text-align: center;
  padding: 16px;
  font-size: 14px;
  line-height: 1.7;
}
.box.dashed {
  border-style: dashed;
  border-color: var(--c-line-strong);
  background: transparent;
}

/* ボタン ------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 42px;                   /* md サイズ */
  padding: 10px 22px;
  border: 1px solid var(--c-primary);
  background: var(--c-primary);
  color: var(--c-on-primary);
  border-radius: var(--r);
  font-family: var(--f-body);
  font-weight: 500;
  font-size: 14px;
  line-height: 1.4;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;                /* ラベルは折り返さない（「テスト送/信」のような分断を防ぐ） */
  cursor: pointer;
  box-shadow: var(--sh-sm);
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s;
}
.btn:hover { background: var(--c-primary-hover); border-color: var(--c-primary-hover); color: var(--c-on-primary); }
.btn:focus-visible { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* Secondary */
.btn.ghost {
  background: transparent;
  color: var(--c-primary);
  border-color: var(--c-primary);
  box-shadow: none;
}
.btn.ghost:hover { background: #4F46E50A; border-color: var(--c-primary); color: var(--c-primary); }

/* Destructive */
.btn.danger {
  background: var(--c-error);
  border-color: var(--c-error);
  color: #fff;
}
.btn.danger:hover { background: #DC2626; border-color: #DC2626; color: #fff; }

/* sm サイズ */
.btn.sm { min-height: 32px; padding: 6px 14px; font-size: 14px; }
.btn.block { display: flex; width: 100%; }

.btn[disabled], .btn.disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }

/* モックアップで未接続のボタン。見た目は活きたボタンのまま、支援技術には
   「利用不可」と伝え、ポインタでも「押せる」と約束しない（title で理由を出す）。
   disabled にすると opacity が落ち、完成後の見た目を確認できなくなるため使わない。 */
.btn[aria-disabled="true"] { cursor: default; }

/* 暗い面（LP 最終 CTA）のボタン。インライン style で色を上書きすると
   詳細度で :hover の背景色に勝ってしまい、ホバーの反応が消える。 */
.btn.on-dark { background: #fff; color: #16181F; border-color: #fff; }
.btn.on-dark:hover { background: #E6E8F2; color: #16181F; border-color: #E6E8F2; }
.btn.on-dark:focus-visible { outline-color: var(--c-focus-on-navy); }

/* button_to が生成する form をボタン並びで崩さない */
form.button_to { display: inline-block; }

/* ただし .btn.block を包むときは form も全幅にする。inline-block のままだと
   ボタンの width: 100% が form の内容幅までしか効かず、隣に並ぶ
   <a class="btn block"> と幅が食い違う（招待承諾画面）。 */
form.button_to:has(> .btn.block) { display: block; width: 100%; }

/* 見出し ------------------------------------------------------------------- */
h1, h2, h3, h4 {
  font-family: var(--f-head);
  color: var(--c-text);              /* 見出しは本文と同じ濃色。ブランド色は面・操作系に限定する */
  letter-spacing: 0.01em;
}
h1 { font-size: 32px; font-weight: 700; line-height: 1.3; }
h2 { font-size: 24px; font-weight: 600; line-height: 1.4; }
h3 { font-size: 20px; font-weight: 600; line-height: 1.45; }
h4 { font-size: 16px; font-weight: 500; line-height: 1.5; }
h2.center { text-align: center; margin-bottom: 12px; }
.lead { margin-bottom: 32px; font-size: 18px; line-height: 1.8; color: var(--c-text-2); }
.lead.center { text-align: center; }

/* リンク：セージはインタラクティブ要素とポジティブな状態のみ（Do #1）。
   テキストとしては --c-sage-text（AA 達成）を使う。 */
a { color: var(--c-sage-text); }
a:hover { color: var(--c-sage-hover); }

/* グリッド ----------------------------------------------------------------- */
.grid { display: grid; gap: 24px; }
.cols-2 { grid-template-columns: 1fr 1fr; }
.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.cols-4 { grid-template-columns: repeat(4, 1fr); }

/* テーブル ----------------------------------------------------------------- */
/* border-collapse: collapse だと th の背景がテーブルの境界まで届かず、
   角丸クリップとの隙間にテーブルの白背景が 1px 覗いてしまう。
   separate + border-spacing: 0 なら罫線は各セルが持つので、角丸と背景が噛み合う。 */
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 14px;
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r);
  overflow: hidden;
}
th, td {
  border: none;
  border-bottom: 1px solid var(--c-line-soft);
  padding: 12px 16px;
  text-align: center;
  line-height: 1.7;
}
th {
  background: var(--c-table-head);
  font-family: var(--f-body);
  font-size: 12px;
  font-weight: 600;
  color: var(--c-text-2);
  letter-spacing: 0.03em;
  border-bottom: 1px solid var(--c-line-strong);
}
tbody tr:last-child td { border-bottom: none; }
td { color: var(--c-text); }
td.y { font-weight: 500; color: var(--c-sage-text); }

/* 長い URL やメールアドレスは分割不能な 1 トークンなので、そのままだと表の
   最小幅が親を超えて突き抜ける（横スクロール化は 768px 以下でしか効かない）。
   途中で折ることで、どの幅でも表が親に収まる。 */
table:not(.wf-kv) td { overflow-wrap: anywhere; }
/* 見出しは折らない。折ると「最終チ／ェック」のように分断される。 */
table:not(.wf-kv) th { white-space: nowrap; }

/* URL や要約のような長い単一値。折り返すと行が 10 行を超えて一覧が読めなくなるので
   1 行に省略する。全文は title 属性と、行リンク先の詳細画面で参照できる。 */
table.data-left td.truncate {
  max-width: 34ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* アプリ内データテーブル（左寄せ・行ホバー） */
table.data-left th, table.data-left td { text-align: left; }
table.data-left th.right, table.data-left td.right { text-align: right; }

/* 操作列。<a class="btn"> と button_to の <form> はどちらも inline-block なので、
   並べると隙間が空白文字ぶん（約 4px）しか空かず、タッチ間隔の下限 8px を割る。
   .row で包んで明示的に間隔を取り、右寄せもクラスで行う（インライン style の代替）。 */
td .row { gap: 8px; }
td.right .row { justify-content: flex-end; }
/* 操作列に入力欄（ロール変更セレクト等）を置くときは、隣の .btn.sm と高さを揃える。
   既定の 42px のままだと 32px のボタンと段差ができる。≤768px では双方 44px。 */
td .wf-input { min-height: 32px; padding: 6px 10px; }
tbody tr td { transition: background .12s; }
tr.row-link td { cursor: pointer; }
tr.row-link:hover td { background: var(--c-row-hover); }
/* 行リンクはキーボードでも辿れる（row_link_controller が tabindex/role を付与）。
   tr に outline は描けないブラウザがあるため、内側インセットの影で枠を描く。 */
tr.row-link:focus-visible { outline: none; }
tr.row-link:focus-visible td {
  background: var(--c-row-hover);
  box-shadow: inset 0 2px 0 var(--c-focus), inset 0 -2px 0 var(--c-focus);
}
tr.row-link:focus-visible td:first-child { box-shadow: inset 2px 0 0 var(--c-focus), inset 0 2px 0 var(--c-focus), inset 0 -2px 0 var(--c-focus); }
tr.row-link:focus-visible td:last-child  { box-shadow: inset -2px 0 0 var(--c-focus), inset 0 2px 0 var(--c-focus), inset 0 -2px 0 var(--c-focus); }

/* カード ------------------------------------------------------------------- */
.card {
  border: 1px solid var(--c-line);
  border-radius: var(--r);
  padding: 24px;                      /* lg */
  background: var(--c-surface);
}
.card.pad-sm { padding: 16px; }
.card.danger { border-color: var(--c-error); }
.card.emphasis { border-width: 2px; border-color: var(--c-primary); }

.tag {
  display: inline-block;
  font-size: 12px;
  font-weight: 500;
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  color: var(--c-primary);
  padding: 4px 12px;
  border-radius: var(--r-sm);
  margin-bottom: 12px;
  white-space: nowrap;   /* .badge と同じくラベルは折らない */
}

/* =====================  アプリシェル（認証済み画面）  =====================
   モバイル Safari では 100vh がアドレスバー分だけ実表示領域より大きいため dvh を使う。 */
.app { display: flex; min-height: 100dvh; }

/* タップ遅延（約 300ms）を消す。ダブルタップズームは不要な UI のため。 */
a, button, .btn, label, summary, tr.row-link, .wf-toggle {
  touch-action: manipulation;
}

.wf-sidebar {
  width: 240px;
  flex: 0 0 240px;
  background: var(--wf-sidebar);
  color: #fff;
  display: flex;
  flex-direction: column;
  padding: 20px 0 16px;
  position: sticky;
  top: 0;
  height: 100dvh;
}
.wf-sidebar .brand-row {
  display: flex; align-items: center; gap: 8px;
  padding: 0 20px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.wf-sidebar .brand {
  display: flex; align-items: center; gap: 10px;
  flex: 1 1 auto; min-width: 0;
  font-family: var(--f-head);
  font-weight: 700; font-size: 17px;
  letter-spacing: 0.01em;
  color: #fff; text-decoration: none;
}
.wf-sidebar .brand:hover { color: #fff; }
/* ドロワーを閉じるボタン。デスクトップのサイドバーには不要なので隠す。 */
.wf-drawer-close { display: none; }
/* ブランドマーク（logo.svg）。透過 SVG なので背面塗りは持たせず、サイズと配置のみ。
   viewBox は中身のバー群ぴったり（38×26）に詰めてあり、四辺まで図形が広がる。 */
.wf-sidebar .brand .logo {
  height: 20px;
  flex: 0 0 38px;
  display: block;
}

/* 組織スイッチャ（Stimulus: dropdown_controller）
   左右マージンはナビ（.wf-nav の padding）・ユーザー行（.wf-user の margin）と同じ 8px に揃える。
   ここだけ 12px にすると、サイドバー内で 1 つだけ幅が狭く見える。 */
.wf-orgswitch-wrap { position: relative; margin: 16px 8px 8px; }
.wf-orgswitch {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, .1);
  background: rgba(255, 255, 255, .04);
  border-radius: var(--r);
  font-size: 13px;
  font-family: var(--f-body);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  color: #E2E8F0;
  cursor: pointer;
  text-align: left;
  transition: background .15s;
}
.wf-orgswitch:hover { background: rgba(255, 255, 255, .08); }
.wf-orgswitch .caret { transition: transform .15s; }
.wf-orgswitch[aria-expanded="true"] .caret { transform: rotate(180deg); }

.wf-dropdown {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--c-surface);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  padding: 6px;
  z-index: 20;
}
.wf-dropdown[hidden] { display: none; }
/* 項目は「その組織のダッシュボードへのリンク」。URL が使用セッションを決めるため、
   組織の切り替えは遷移そのものになる（AUTH-001 §7）。button_to 時代の <form> ラップも
   残しておく（他のドロップダウンで使う場合に効かせるため）。 */
.wf-dropdown form.button_to { display: block; width: 100%; }
.wf-dropdown a,
.wf-dropdown button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  width: 100%;
  /* 44px はタッチターゲットの下限（DESIGN.md）。見た目が小さくても領域は確保する。 */
  min-height: 44px;
  padding: 8px 10px;
  border: none; background: transparent; cursor: pointer;
  border-radius: var(--r-sm);
  font-family: var(--f-body); font-size: 13px; color: var(--c-primary);
  text-align: left; text-decoration: none;
}
.wf-dropdown a:hover,
.wf-dropdown button:hover { background: var(--c-bg); }
.wf-dropdown a[aria-current="true"],
.wf-dropdown button[aria-current="true"] { background: #4F46E50A; font-weight: 500; }
/* 白いポップオーバーの上なので、フォーカスリングはネイビーで足りる
   （ネイビー地に置く要素は #E2E8F0 に差し替える必要がある）。 */
.wf-dropdown a:focus-visible,
.wf-dropdown button:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: -2px;
}
.wf-dropdown .check { color: var(--c-sage); }
/* 組織作成の導線。項目リストの下に、区切り線付きで控えめに置く。 */
.wf-dropdown-add {
  display: flex; align-items: center;
  min-height: 44px;
  margin-top: 4px; padding: 8px 10px;
  border-top: 1px solid var(--c-border);
  border-radius: var(--r-sm);
  font-size: 13px; color: var(--c-primary); text-decoration: none;
}
.wf-dropdown-add:hover { background: var(--c-bg); }
.wf-dropdown-add:focus-visible {
  outline: 2px solid var(--c-primary);
  outline-offset: -2px;
}

.wf-nav { list-style: none; padding: 8px; flex: 1; overflow-y: auto; }
/* ナビが溢れたとき、OS 標準の明るいスクロールバーはダークなサイドバー上で目立つ。
   トラックを透明にし、つまみをサイドバーの hover 配色（半透明の白）に馴染ませて細く控えめにする。
   Firefox は scrollbar-*、WebKit/Chromium は ::-webkit-scrollbar-* で同じ見た目を作る。 */
.wf-nav {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, .14) transparent;
}
.wf-nav::-webkit-scrollbar { width: 6px; }
.wf-nav::-webkit-scrollbar-track { background: transparent; }
.wf-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, .14);
  border-radius: 3px;
}
/* ポインタがナビ上にあるときだけ、少しだけはっきりさせて操作対象と分かるようにする。 */
.wf-nav:hover { scrollbar-color: rgba(255, 255, 255, .28) transparent; }
.wf-nav:hover::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, .28); }

/* スクロールシャドウ（Lea Verou 方式）。中身が上／下へ続いているときだけ、その端に
   内側シャドウを出して「まだ続く＝スクロールできる」と分からせ、端まで来たら消す。JS なし。
   4 枚の背景を重ねる：上下 2 枚のカバー（サイドバー地色のエメラルド）は中身と一緒に動き（local）、
   上下 2 枚のシャドウ（黒の放射）は枠に固定（scroll）。端ではカバーがシャドウを覆って隠し、
   スクロールするとカバーが外れてシャドウが現れる。中央は透明のままで親のエメラルドを見せる。
   カバーの塗りはサイドバー地色（--wf-sidebar）と一致させる（ずれると帯が浮く）。 */
.wf-nav {
  background:
    linear-gradient(var(--wf-sidebar) 30%, transparent) top    / 100% 34px no-repeat,
    linear-gradient(transparent, var(--wf-sidebar) 70%) bottom / 100% 34px no-repeat,
    radial-gradient(farthest-side at 50% 0,   rgba(0, 0, 0, .38), rgba(0, 0, 0, 0)) top    / 100% 14px no-repeat,
    radial-gradient(farthest-side at 50% 100%, rgba(0, 0, 0, .38), rgba(0, 0, 0, 0)) bottom / 100% 14px no-repeat;
  background-attachment: local, local, scroll, scroll;
}
.wf-nav li { margin: 2px 0; }
.wf-nav a {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  color: #AEB4C0;
  text-decoration: none;
  font-size: 14px;
  border-radius: var(--r);
  transition: background .15s, color .15s;
}
.wf-nav a:hover { background: rgba(255, 255, 255, .06); color: #E2E8F0; }
.wf-nav a.active {
  background: var(--wf-sidebar-active);
  color: #fff;
  font-weight: 500;
}
/* アクティブ項目のセージのインジケータ */
.wf-nav a.active::before {
  content: "";
  position: absolute; left: 0; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 18px;
  border-radius: var(--r-full);
  background: var(--c-sidebar-accent);
}
/* 無料プランで使えない Pro 専用機能に付く Pro タグ。行末に寄せ、項目名より控えめに置く。
   英字ラベルなので .en 相当の大文字化・トラッキングを当てる（Do #6）。 */
.wf-nav a .pro-tag {
  margin-left: auto;
  flex: 0 0 auto;
  padding: 1px 6px;
  border-radius: var(--r-full);
  border: 1px solid var(--c-sidebar-accent);
  color: var(--c-sidebar-accent);
  font-size: 10px; font-weight: 600; line-height: 16px;
  text-transform: uppercase; letter-spacing: 0.5px;
}
.wf-nav a.active .pro-tag { background: var(--c-sidebar-accent); color: var(--wf-sidebar); }
/* 和文の見出しのため大文字化・トラッキングは行わない（Do #6） */
.wf-nav .group-label {
  font-size: 12px; font-weight: 500;
  color: var(--c-on-navy-2);
  padding: 20px 12px 6px;
}

/* ネイビー面ではダークのアウトラインが沈むので明色に差し替える。
   ただしドロップダウンパネルは白地なので、既定のダークのまま残す。 */
.wf-sidebar :focus-visible { outline-color: var(--c-focus-on-navy); }
.wf-dropdown :focus-visible { outline-color: var(--c-focus); }

/* ナビアイコン：data-icon をキーに実アイコンを差し込む（Do #8 テキスト＋アイコン） */
.wf-nav a .ic {
  width: 18px; height: 18px; flex: 0 0 18px;
  background-color: currentColor;
  -webkit-mask: var(--i) center / 18px 18px no-repeat;
  mask: var(--i) center / 18px 18px no-repeat;
  opacity: .9;
}
.ic[data-icon="dashboard"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="9" rx="1"/><rect x="14" y="3" width="7" height="5" rx="1"/><rect x="14" y="12" width="7" height="9" rx="1"/><rect x="3" y="16" width="7" height="5" rx="1"/></svg>');
}
.ic[data-icon="monitors"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M22 12h-4l-3 9L9 3l-3 9H2"/></svg>');
}
.ic[data-icon="incidents"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="m21.7 18-8-14a2 2 0 0 0-3.4 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.7-3Z"/><path d="M12 9v4"/><path d="M12 17h.01"/></svg>');
}
.ic[data-icon="channels"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M6 8a6 6 0 0 1 12 0c0 7 3 9 3 9H3s3-2 3-9"/><path d="M10.3 21a1.94 1.94 0 0 0 3.4 0"/></svg>');
}
.ic[data-icon="channel-groups"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.8 2.2a2 2 0 0 0-1.6 0L2.6 6.1a1 1 0 0 0 0 1.8l8.6 3.9a2 2 0 0 0 1.6 0l8.6-3.9a1 1 0 0 0 0-1.8Z"/><path d="m22 12.5-9.2 4.2a2 2 0 0 1-1.6 0L2 12.5"/><path d="m22 17.5-9.2 4.2a2 2 0 0 1-1.6 0L2 17.5"/></svg>');
}
.ic[data-icon="logs"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M8 6h13"/><path d="M8 12h13"/><path d="M8 18h13"/><path d="M3 6h.01"/><path d="M3 12h.01"/><path d="M3 18h.01"/></svg>');
}
.ic[data-icon="projects"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z"/></svg>');
}
.ic[data-icon="members"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><path d="M22 21v-2a4 4 0 0 0-3-3.87"/><path d="M16 3.13a4 4 0 0 1 0 7.75"/></svg>');
}
.ic[data-icon="billing"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="5" width="20" height="14" rx="2"/><path d="M2 10h20"/></svg>');
}
.ic[data-icon="settings"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 21v-7"/><path d="M4 10V3"/><path d="M12 21v-9"/><path d="M12 8V3"/><path d="M20 21v-5"/><path d="M20 12V3"/><path d="M1 14h6"/><path d="M9 8h6"/><path d="M17 16h6"/></svg>');
}

/* アバター + 名前/メール（上段）と、ログアウト（下段）の 2 段。
   1 行に 3 つ並べると名前・メール欄が 80px しか残らず、メールが省略記号で潰れる。 */
.wf-user {
  padding: 16px 4px 8px;
  margin: 0 8px;
  border-top: 1px solid rgba(255, 255, 255, .08);
  font-size: 13px;
  color: #E2E8F0;
  display: flex; flex-direction: column; gap: 4px;
}
.wf-user .profile {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
  padding: 0 8px 4px;
}
/* プロフィールはアカウント設定へのリンク。押せることが分かるようホバー・フォーカスを付ける。 */
.wf-user a.profile {
  text-decoration: none; color: inherit;
  padding: 6px 8px; border-radius: var(--r);
  transition: background .15s;
}
.wf-user a.profile:hover { background: rgba(255, 255, 255, .06); }
.wf-user a.profile[aria-current="page"] { background: rgba(255, 255, 255, .09); }
.wf-user a.profile:focus-visible { outline: 2px solid var(--c-focus-on-navy); outline-offset: 2px; }
.wf-user .avatar {
  width: 32px; height: 32px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, #52586B, #9AA0B5);
  flex: 0 0 32px;
}
/* ログアウト（組織単位 / 全体）。navy の地に載るため .btn（明色背景前提）は使わず、
   ナビ項目と同じ調子の控えめなテキストボタンにする。 */
.wf-user-actions { display: flex; flex-direction: column; gap: 2px; padding: 4px 8px 0; }
.wf-user-actions form.button_to { display: block; width: 100%; }
.wf-user-actions button {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: #AEB4C0;
  font-size: 12px;
  padding: 6px 8px;
  border-radius: var(--r);
  cursor: pointer;
  transition: background .15s, color .15s;
}
.wf-user-actions button:hover { background: rgba(255, 255, 255, .06); color: #E2E8F0; }
.wf-user-actions button:focus-visible {
  outline: 2px solid var(--c-focus-on-navy);
  outline-offset: 2px;
}

/* 名前・メールは残り幅いっぱいに。それでも入らなければ省略記号に。 */
.wf-user .who {
  min-width: 0; flex: 1 1 auto;
  display: flex; flex-direction: column;
  line-height: 1.4;
}
.wf-user .who > * {
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wf-user .small.muted { color: var(--c-on-navy-2); }

/* ボタン内アイコン（例: アカウント設定のログアウト）。ナビ等と同じ currentColor マスク方式。 */
.btn .ic {
  width: 16px; height: 16px; flex: 0 0 16px;
  background-color: currentColor;
  -webkit-mask: var(--i) center / 16px 16px no-repeat;
  mask: var(--i) center / 16px 16px no-repeat;
}
.ic[data-icon="logout"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4"/><polyline points="16 17 21 12 16 7"/><line x1="21" x2="9" y1="12" y2="12"/></svg>');
}

.wf-main { flex: 1; background: var(--c-bg); min-width: 0; }

/* --- 狭幅用のアプリバーとドロワー（既定は非表示。@media で有効化） --------- */
.wf-appbar { display: none; }
.wf-scrim { display: none; }
.wf-scrim[hidden] { display: none; }

.wf-appbar-toggle {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 44px;             /* タッチターゲット下限 */
  flex: 0 0 44px;
  border: none; background: transparent; cursor: pointer;
  border-radius: var(--r);
  color: #E2E8F0;
  transition: background .15s;
}
.wf-appbar-toggle:hover { background: rgba(255, 255, 255, .08); }
.wf-appbar-toggle .ic {
  width: 22px; height: 22px; flex: 0 0 22px;
  background-color: currentColor;
  -webkit-mask: var(--i) center / 22px 22px no-repeat;
  mask: var(--i) center / 22px 22px no-repeat;
}
.ic[data-icon="menu"] {
  --i: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="black" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M3 6h18"/><path d="M3 12h18"/><path d="M3 18h18"/></svg>');
}

.wf-appbar-brand {
  display: flex; align-items: center; gap: 10px;
  font-family: var(--f-head);
  font-weight: 700; font-size: 16px;
  letter-spacing: 0.01em;
  color: #fff; text-decoration: none;
}
.wf-appbar-brand:hover { color: #fff; }
.wf-appbar-brand .logo {
  height: 20px;
  flex: 0 0 38px;
  display: block;
}

/* フラッシュバナー（Stimulus: flash_controller が自動的に閉じる） */
.wf-flash {
  padding: 12px 32px;
  font-size: 14px;
  font-weight: 500;
  border-bottom: 1px solid var(--c-line);
  display: flex; align-items: center; gap: 12px;
  transition: opacity .3s, transform .3s;
}
.wf-flash.leaving { opacity: 0; transform: translateY(-4px); }
.wf-flash .close {
  margin-left: auto; cursor: pointer;
  border: none; background: transparent; color: inherit;
  font-size: 16px; line-height: 1; opacity: .6;
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; min-height: 32px; padding: 4px;   /* ≤768px では 44px（末尾の @media） */
  border-radius: var(--r-sm);
}
.wf-flash .close:hover { opacity: 1; }
.wf-flash.notice {
  background: var(--c-success-bg);
  color: var(--c-success-fg);
  border-color: #BBF7D0;
}
.wf-flash.alert {
  background: var(--c-error-bg);
  color: var(--c-error-fg);
  border-color: #FECACA;
}

.wf-content { padding: 32px; max-width: 1160px; }

/* ページヘッダ（タイトル + アクション） */
.wf-page-head {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 24px;
}
/* flex アイテムの既定 min-width: auto は、中身の min-content 未満に縮まない。
   長い URL を 1 トークンとして抱えるとページごと広がるので明示的に 0 にする。
   .actions は縮めない（ボタンは nowrap なので、縮むと文字が箱からあふれる）。 */
.wf-page-head > div:not(.actions) { min-width: 0; }
.wf-page-head .actions > * { flex: 0 0 auto; }
.wf-page-head h1 { font-size: 24px; font-weight: 600; line-height: 1.4; }
.wf-page-head .sub { font-size: 14px; color: var(--c-slate); margin-top: 4px; line-height: 1.7; }
.wf-page-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
/* ヘッダに絞り込み入力とボタンを並べる画面（モニター一覧）では、42px の入力と
   32px の .btn.sm が同じ行で高さ不揃いになる。ツールバーとして入力側を sm に揃える。
   ≤768px では下のメディアクエリで双方 44px（タッチ下限）へ戻す。 */
.wf-page-head .actions .wf-input { min-height: 32px; padding: 6px 12px; }
.wf-page-head .actions select.wf-input { padding-right: 32px; background-position: right 10px center; }
/* 破壊的操作は隣のボタンから離す。8px の共通ギャップのままだと「一時停止」の
   隣で「削除」を誤タップしうる（HIG / Material の destructive 分離）。 */
.wf-page-head .actions > .btn.danger,
.wf-page-head .actions > form.button_to:has(> .btn.danger) { margin-left: 16px; }

/* 長い URL・メールアドレス・JSON は途中で折る。放置すると min-content 幅が
   ビューポートを超え、ページ全体が横スクロールする。 */
.wf-page-head h1,
.wf-page-head .sub,
.wf-breadcrumb,
.wf-kv td.v,
.wf-timeline .ev,
.wf-empty .small {
  overflow-wrap: anywhere;
}

/* grid アイテムも同じ理由で縮めるようにする。
   .spread の子には広げない（中に .nowrap の金額ラベル等があり、縮むとあふれる）。 */
.grid > * { min-width: 0; }

.wf-breadcrumb { font-size: 12px; color: var(--c-slate); margin-bottom: 8px; }
.wf-breadcrumb a { color: var(--c-slate); text-decoration: none; }
.wf-breadcrumb a:hover { color: var(--c-sage); }

/* 集計スタットカード（ダッシュボード） */
.wf-stat {
  border: none;
  background: var(--c-surface);
  border-radius: var(--r);
  box-shadow: var(--sh-md);          /* Elevated カード */
  padding: 24px;
  text-decoration: none;
  display: block;
  transition: box-shadow .15s, transform .15s;
}
a.wf-stat:hover { box-shadow: var(--sh-lg); transform: translateY(-1px); }
.wf-stat .num {
  font-family: var(--f-mono);
  font-size: 32px; font-weight: 500;
  color: var(--c-text);
  line-height: 1.2;
  letter-spacing: -0.01em;
}
.wf-stat .lbl {
  font-size: 14px; color: var(--c-slate);
  margin-top: 8px;
  display: flex; align-items: center; gap: 8px;
}

/* 状態ドット & バッジ ------------------------------------------------------ */
.dot {
  display: inline-block;
  width: 10px; height: 10px;
  border-radius: var(--r-full);
  background: var(--c-slate);
  vertical-align: middle;
  flex: 0 0 10px;
}
/* ドットは意味を担う図形なので、白地で 3:1 以上を確保する（--c-success #22C55E は 2.3:1）。
   面塗り用の鮮やかな色ではなく、前景色系を使う。 */
.dot.up { background: var(--c-success-fg); box-shadow: 0 0 0 3px var(--c-success-bg); }
.dot.down { background: var(--c-error-fg); box-shadow: 0 0 0 3px var(--c-error-bg); }
.dot.pending { background: var(--c-slate); box-shadow: 0 0 0 3px #64748B15; }
/* 計測停止中は「対象サイトの異常」ではなく「こちらが測れていない」状態なので、
   error（down）と同色にしない。警告系で独立させる（JOB-001 §4）。 */
.dot.stalled { background: var(--c-warning-fg); box-shadow: 0 0 0 3px var(--c-warning-bg); }

/* チップ（DESIGN.md「チップ」） */
.badge {
  display: inline-block;
  font-size: 12px; font-weight: 500;
  padding: 4px 12px;
  border-radius: var(--r-sm);
  color: var(--c-primary);
  background: var(--c-bg);
  border: 1px solid var(--c-line);
  line-height: 1.6;
  /* チップは意味の最小単位。「認証済」が 2 行に割れると別の語に見える。
     祖先（table td）が overflow-wrap: anywhere でも折らせない。 */
  white-space: nowrap;
  overflow-wrap: normal;
  word-break: keep-all;
}
/* 英字ラベルのみ大文字＋トラッキング。和文には字間を足さない（Do #6） */
.badge.en { text-transform: uppercase; letter-spacing: 0.5px; }
.badge.up, .badge.resolved, .badge.sent {
  color: var(--c-success-fg); background: var(--c-success-bg); border-color: transparent;
}
.badge.down, .badge.ongoing, .badge.failed {
  color: var(--c-error-fg); background: var(--c-error-bg); border-color: transparent;
}
.badge.pending {
  color: var(--c-slate); background: #64748B12; border-color: transparent;
}
.badge.stalled {
  color: var(--c-warning-fg); background: var(--c-warning-bg); border-color: transparent;
}
.badge.method {
  color: var(--c-primary); background: var(--c-line-soft);
  border-color: transparent; font-family: var(--f-mono);
}

/* キー・バリュー設定行（詳細カード） */
/* 枠なしのキー・バリュー表。角丸クリップが要らないので、table の基底規則から
   受け継ぐ overflow: hidden を戻す（サブピクセル分の文字が切れる）。 */
.wf-kv { width: 100%; font-size: 14px; border: none; background: transparent; overflow: visible; }
.wf-kv tr td {
  border: none; border-bottom: 1px solid var(--c-line-soft);
  padding: 12px 4px; text-align: left; line-height: 1.7;
}
.wf-kv tr:last-child td { border-bottom: none; }
.wf-kv td.k { color: var(--c-slate); width: 40%; }
.wf-kv td.v { color: var(--c-text); font-weight: 500; }

/* サブリソースへのボタン列（詳細画面）／フィルタチップ列 */
.wf-subnav { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 24px; align-items: center; }

/* セクション見出しの右に置く「すべて見る →」等。
   .muted を当てると a の色指定（--c-sage-text）を後勝ちで潰し、
   リンクだと分からない灰色の文字になる。専用クラスで色と当たり判定を持たせる。 */
.link-more {
  display: inline-flex; align-items: center; gap: 4px;
  min-height: 32px;                   /* ≤768px では 44px */
  padding: 0 4px;
  border-radius: var(--r-sm);
  font-size: 12px; line-height: 1.6;
  color: var(--c-sage-text);
  text-decoration: none;
  white-space: nowrap;
}
.link-more:hover { color: var(--c-sage-hover); text-decoration: underline; }

/* 応答時間スパークライン */
.wf-graph {
  background: var(--c-surface);
  border: 1px solid var(--c-line);
  border-radius: var(--r);
  height: 180px;
  padding: 16px;
  position: relative;
  background-image:
    linear-gradient(var(--c-line-soft) 1px, transparent 1px),
    linear-gradient(90deg, var(--c-line-soft) 1px, transparent 1px);
  background-size: 100% 36px, 48px 100%;
}
.wf-graph svg { width: 100%; height: 100%; display: block; overflow: visible; }
.wf-graph .line { fill: none; stroke: var(--c-sage); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.wf-graph .area { fill: var(--c-sage); opacity: .08; }
.wf-graph .pt { fill: var(--c-sage); }
.wf-graph .caption {
  position: absolute; top: 10px; right: 14px;
  font-size: 12px; color: var(--c-slate); font-family: var(--f-mono);
}
.wf-graph.empty { display: flex; align-items: center; justify-content: center; color: var(--c-slate); font-size: 13px; }

/* フォーム ----------------------------------------------------------------- */
.wf-field { margin-bottom: 20px; }
/* .wf-field-label は「対応する入力欄がない見出し」用。<label> を for なしで置くと
   支援技術に空のラベルとして拾われるため、テキストの見出しには span を使う。 */
.wf-field > label,
.wf-field .wf-field-label {
  font-size: 14px; font-weight: 500;
  color: var(--c-text);
}
/* 直下に置くときだけブロック化して下余白を持つ（.spread の中では 1 行に並べる） */
.wf-field > label,
.wf-field > .wf-field-label { display: block; margin-bottom: 6px; }
.req { color: var(--c-error); font-size: 12px; margin-left: 4px; }
.hint { font-size: 12px; color: var(--c-text-2); margin-top: 4px; line-height: 1.6; }
.err { font-size: 12px; color: var(--c-error); margin-top: 4px; line-height: 1.6; }

.wf-input {
  border: 1px solid var(--c-line);
  background: var(--c-surface);
  border-radius: var(--r);
  min-height: 42px;
  padding: 10px 14px;
  font-family: var(--f-body);
  font-size: 14px;
  color: var(--c-text);
  width: 100%;
  transition: border-color .15s, box-shadow .15s;
}
.wf-input::placeholder { color: var(--c-slate); }
.wf-input:hover { border-color: var(--c-primary); }
/* 1px → 2px の border 切り替えは中身が 1px ずれるため、outline を内側に重ねて太らせる */
.wf-input:focus, .wf-input:focus-visible, .wf-input:focus-within {
  border-color: var(--c-primary);
  outline: 2px solid var(--c-primary);
  outline-offset: -1px;
  box-shadow: 0 0 0 3px #4F46E518;
}
.wf-input.invalid {
  border-color: var(--c-error);
  outline: 2px solid var(--c-error);
  outline-offset: -1px;
  background: var(--c-surface);
  box-shadow: 0 0 0 3px #EF444418;
}
.wf-input[disabled], .wf-input.disabled { background: var(--c-line-soft); color: var(--c-slate); }
textarea.wf-input { min-height: 96px; line-height: 1.7; display: block; }
select.wf-input {
  appearance: none;
  background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2364748B" stroke-width="2" stroke-linecap="round"><path d="m6 9 6 6 6-6"/></svg>');
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 34px;
}
.wf-input.w-xs { width: 100px; }
.wf-input.w-sm { width: 140px; }
.wf-input.w-md { width: 200px; }
.wf-input.w-lg { width: 280px; }

.wf-fieldset {
  border: 1px solid var(--c-line);
  border-radius: var(--r);
  background: var(--c-surface);
  padding: 24px;
  margin-bottom: 20px;
  /* fieldset の UA 既定は min-inline-size: min-content。中の表が nowrap だと
     その幅まで膨らみ、ページごと横スクロールする。 */
  min-width: 0;
}
.wf-fieldset > legend, .wf-fieldset > .legend {
  font-family: var(--f-head);
  font-size: 14px; font-weight: 600;
  color: var(--c-text);
  padding: 0 8px; margin-left: -8px;
}
.wf-fieldset[hidden] { display: none; }

/* 折りたたみ（段階的開示。Don't #7 の対処。Stimulus: collapse_controller） */
.wf-collapse {
  border: 1px solid var(--c-line);
  border-radius: var(--r);
  background: var(--c-surface);
  margin-bottom: 20px;
  overflow: hidden;
}
.wf-collapse > .summary {
  padding: 14px 20px;
  font-size: 14px; font-weight: 500;
  color: var(--c-text);
  display: flex; align-items: center; gap: 10px;
  cursor: pointer;
  background: var(--c-bg);
  width: 100%; border: none; font-family: var(--f-body); text-align: left;
}
.wf-collapse > .summary::before { content: "▸"; color: var(--c-slate); font-size: 12px; }
.wf-collapse.open > .summary::before { content: "▾"; }
.wf-collapse > .body { padding: 24px; border-top: 1px solid var(--c-line); }
.wf-collapse > .body[hidden] { display: none; }

.wf-form-actions {
  display: flex; gap: 12px; align-items: center;
  margin-top: 24px; padding-top: 24px;
  border-top: 1px solid var(--c-line);
}

/* チェックボックス / ラジオ ------------------------------------------------- */
input[type="checkbox"], input[type="radio"] {
  width: 18px; height: 18px;
  accent-color: var(--c-primary);
  cursor: pointer;
  vertical-align: middle;
}
input[type="checkbox"]:disabled, input[type="radio"]:disabled { opacity: .4; cursor: not-allowed; }
label.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }

/* トグルスイッチ（有効 / 無効） */
.wf-toggle { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; position: relative; }
/* .wf-field 直下に置くと `.wf-field > label`（display:block・14px・navy・下余白）が
   詳細度で勝ってスイッチが縦崩れするため、トグルとしての体裁を明示的に取り戻す。 */
.wf-field > label.wf-toggle {
  display: inline-flex; margin-bottom: 0;
  font-size: inherit; font-weight: inherit; color: inherit;
}
.wf-toggle input { position: absolute; opacity: 0; width: 40px; height: 22px; margin: 0; }
.wf-toggle .track {
  width: 40px; height: 22px; border-radius: var(--r-full);
  background: var(--c-line-strong); position: relative; flex: 0 0 40px;
  transition: background .15s;
}
.wf-toggle .track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 18px; height: 18px; border-radius: var(--r-full);
  background: #fff; box-shadow: var(--sh-sm);
  transition: transform .15s;
}
.wf-toggle input:checked + .track { background: var(--c-sage); }
.wf-toggle input:checked + .track::after { transform: translateX(18px); }
.wf-toggle input:focus-visible + .track { outline: 2px solid var(--c-focus); outline-offset: 2px; }

/* タイムライン（インシデント） --------------------------------------------- */
.wf-timeline { list-style: none; padding-left: 10px; }
.wf-timeline li {
  position: relative;
  padding: 0 0 24px 28px;
  border-left: 2px solid var(--c-line);
}
.wf-timeline li:last-child { border-left-color: transparent; }
.wf-timeline li::before {
  content: ""; position: absolute; left: -9px; top: 4px;
  width: 12px; height: 12px; border-radius: var(--r-full);
  background: var(--c-surface);
  border: 2px solid var(--c-slate);
}
.wf-timeline li.down::before { border-color: var(--c-error-fg); background: var(--c-error-fg); box-shadow: 0 0 0 3px var(--c-error-bg); }
.wf-timeline li.up::before { border-color: var(--c-success-fg); background: var(--c-success-fg); box-shadow: 0 0 0 3px var(--c-success-bg); }
.wf-timeline .t { font-size: 12px; color: var(--c-slate); font-family: var(--f-mono); }
.wf-timeline .ev { font-size: 14px; color: var(--c-text); font-weight: 500; }

/* 空状態 ------------------------------------------------------------------- */
.wf-empty {
  border: 1px dashed var(--c-line-strong);
  border-radius: var(--r-md);
  background: var(--c-surface);
  padding: 48px 24px;
  text-align: center;
  color: var(--c-slate);
}
.wf-empty .big {
  font-family: var(--f-head);
  font-size: 18px; color: var(--c-text); font-weight: 600;
  margin-bottom: 8px;
}
/* セクション内に差し込む小型の空状態。ページ全体の空状態（48px パディング）だと
   詳細画面の中で場所を取りすぎる。高さをインライン style で固定する代わりに使う。 */
.wf-empty.compact { padding: 24px 16px; }
.wf-empty.compact .big { font-size: 15px; margin-bottom: 4px; }

/* 認証カード（未認証レイアウト） ------------------------------------------- */
.auth-layout { min-height: 100dvh; background: var(--c-bg); padding: 48px 24px; }
.auth-wrap { max-width: 440px; margin: 16px auto; }
.auth-brand {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  margin-bottom: 24px;
  font-family: var(--f-head);
  font-weight: 700; font-size: 24px;
  color: var(--c-primary);
  letter-spacing: 0.01em;
  text-decoration: none;
}
.auth-brand:hover { color: var(--c-primary); }
.auth-brand .logo {
  height: 24px;
  flex: none;
  display: block;
}
.auth-card {
  border: none;
  border-radius: var(--r-md);
  background: var(--c-surface);
  box-shadow: var(--sh-md);
  padding: 32px;
}
/* 認証カードの見出し。5 画面が同じ値をインライン style で重複指定していた。
   説明文が続く画面だけ .tight で下余白を詰める。 */
.auth-card h2 { font-size: 18px; margin-bottom: 16px; }
.auth-card h2.tight { margin-bottom: 8px; }
/* 認証画面の flash はカード幅に収める。全幅バナー（.wf-flash 既定）のままだと
   440px の中央カラムで下線だけの帯になり、通知に見えない。
   通常はカード内のフォーム直上（shared/auth_flash）に出るが、置き忘れた画面と
   フォームを持たない分岐は auth レイアウトの保険でカードの上に出るので、両方揃える。 */
.auth-card .wf-flash,
.auth-wrap > .wf-flash { border-radius: var(--r); border: 1px solid currentColor; margin-bottom: 16px; padding: 10px 14px; }
.auth-alt { text-align: center; font-size: 14px; margin-top: 24px; color: var(--c-text-2); }

/* モーダル（<dialog>。Stimulus: modal_controller） --------------------------- */
dialog.wf-modal {
  border: none; padding: 0;
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  width: 520px; max-width: calc(100vw - 32px);
  color: var(--c-text-2);
  font-family: var(--f-body);
  /* リセットの `* { margin: 0 }` が dialog の UA 既定 `margin: auto` を潰し、
     showModal() したモーダルが左上に寄る。ここで戻して画面中央に置く。 */
  margin: auto;
  max-height: calc(100dvh - 32px);
}
dialog.wf-modal::backdrop { background: rgba(15, 23, 42, .4); }
dialog.wf-modal .head, dialog.wf-modal .foot {
  display: flex; align-items: center; gap: 8px;
  padding: 12px 16px;
}
dialog.wf-modal .head { border-bottom: 1px solid var(--c-line); justify-content: space-between; }
dialog.wf-modal .foot { border-top: 1px solid var(--c-line); justify-content: flex-end; }
dialog.wf-modal .body { padding: 12px 16px; }
dialog.wf-modal .head strong { font-family: var(--f-head); color: var(--c-text); }
dialog.wf-modal .close { border: none; background: none; cursor: pointer; color: var(--c-slate); font-size: 16px; }
.modal-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow: auto; }
.modal-list label { display: flex; align-items: center; gap: 8px; font-size: 14px; padding: 4px 2px; }
.modal-list label.added { opacity: .45; cursor: not-allowed; }
.modal-list label[hidden] { display: none; }

/* 確認ダイアログ（confirm_modal.js が data-turbo-confirm を置き換えて生成） */
dialog.wf-modal.confirm { width: 440px; }
.wf-modal .confirm-message { margin: 0; font-size: 14px; line-height: 1.7; white-space: pre-line; color: var(--c-text); }

/* コード ------------------------------------------------------------------- */
code { font-family: var(--f-mono); font-size: 14px; line-height: 1.6; }
.code-block {
  font-family: var(--f-mono); font-size: 13px; line-height: 1.7;
  background: var(--c-bg); border: 1px solid var(--c-line); border-radius: var(--r);
  padding: 12px 14px; white-space: pre-wrap; overflow-x: auto; color: var(--c-text-2);
}

/* ツールチップ（data-tip 属性で付与） -------------------------------------- */
[data-tip] { position: relative; }
[data-tip]::after {
  content: attr(data-tip);
  position: absolute; bottom: calc(100% + 8px); left: 50%;
  transform: translateX(-50%);
  background: var(--c-primary);
  color: var(--c-bg);
  font-size: 12px; line-height: 1.6;
  padding: 6px 12px;
  border-radius: var(--r);
  max-width: 240px; width: max-content;
  opacity: 0; pointer-events: none;
  transition: opacity .1s .15s;
  z-index: 10;
}
/* ホバーだけに依存しない：キーボードフォーカスでも出す */
[data-tip]:hover::after, [data-tip]:focus-visible::after { opacity: 1; }

/* Turbo の読み込み中表示 */
.turbo-progress-bar { background: var(--c-sage); height: 3px; }
turbo-frame[busy] { opacity: .5; transition: opacity .15s; }

/* ==========================  公開ページ（LP / ステータス）  ================= */
/* 公開ページ（LP / ステータス）は全幅。ページ全体を 1 枚の箱で囲うと、ヒーローや
   tinted/dark の帯まで幅が頭打ちになって左右に地の色が出てしまう。そこで背景（各
   セクション）は端まで届かせ、内容だけを中央の --content-max に収める。
   padding-inline の max() が「両脇の最小ガター」と「中央寄せぶんの余白」を自動で切り替える。 */
.public-wrap {
  --content-max: 1160px;
  --gutter: 48px;
  margin: 0;
  background: var(--c-surface);
  min-height: 100dvh;
}
section.site, header.site, footer.site {
  position: relative;
  border-bottom: 1px solid var(--c-line);
  padding-block: 64px;                /* 3xl 相当。余白をたっぷり取る（Do #2） */
  padding-inline: max(var(--gutter), (100% - var(--content-max)) / 2);
}
header.site { padding-block: 16px; display: flex; align-items: center; gap: 24px; }
header.site .brand { display: flex; align-items: center; gap: 10px; font-family: var(--f-head); font-weight: 700; font-size: 18px; color: var(--c-primary); text-decoration: none; }
header.site .brand .logo { height: 26px; flex: none; display: block; }
header.site nav { display: flex; gap: 20px; flex: 1; justify-content: center; font-size: 13px; }
header.site nav a { color: var(--c-text-2); text-decoration: none; }
header.site nav a:hover { color: var(--c-sage); }
section.site.tinted { background: var(--c-bg); }
section.site.dark { background: var(--wf-sidebar); text-align: center; }
section.site.dark h2 { color: #fff; }
footer.site { border-bottom: none; display: flex; gap: 40px; font-size: 12px; color: var(--c-slate); }
footer.site strong { display: block; color: var(--c-primary); font-weight: 600; }

/* 長文ページ（規約・プライバシー・特商法・ヘルプ） --------------------------
   全体リセット（* { margin: 0; padding: 0 }）により、素の h2/p/ul/ol には縦の
   リズムが一切ない。LP は要素ごとにインライン style で間隔を作っているが、条文が
   数十本並ぶページでは持たないので、この scope でだけ本文要素へマージンを戻す。
   行長も既定の 1160px では長すぎる（和文は 40〜50 字が読みやすい）ため詰める。 */
section.site.prose { --content-max: 760px; }

.prose p, .prose ul, .prose ol, .prose table, .prose .note, .prose .card { margin-top: 16px; }
.prose h2 { margin-top: 48px; font-size: 20px; }
.prose h3 { margin-top: 32px; font-size: 16px; }
/* 見出し直後は、見出しと本文が 1 かたまりに見える距離まで詰める */
.prose h2 + p, .prose h2 + ul, .prose h2 + ol, .prose h2 + table,
.prose h2 + .card, .prose h3 + p, .prose h3 + ul, .prose h3 + table { margin-top: 12px; }
/* リセットで消えたぶんのぶら下げインデント。マーカーが本文左端に重ならない幅 */
.prose ul, .prose ol { padding-left: 1.75em; }
.prose li + li { margin-top: 8px; }
.prose li > ul, .prose li > ol { margin-top: 8px; }
/* 入れ子の先頭要素は、親（カード・セル・リスト項目）の余白が既に効いているので
   二重に空けない */
.prose > :first-child,
.prose .card > :first-child,
.prose li > :first-child,
.prose td > :first-child,
.prose th > :first-child { margin-top: 0; }

/* 未記入の事業者情報。空欄と見分けがつくよう警告色で塗る */
.placeholder {
  color: var(--c-error-fg);
  background: var(--c-error-bg);
  font-weight: 600;
}
/* 本文中では前後の地に溶けるので下線と左右のアキを足す。表のセルは面だけで足りる
   （セルに下線を引くと行の罫線と重なって見える） */
span.placeholder { border-bottom: 1px dashed currentColor; padding: 0 4px; }

.hero-visual {
  height: 280px; border-radius: var(--r-md);
  border: 1px solid var(--c-line); background: var(--c-bg);
  /* flex コンテナでは <br> が効かず、テキストと span が横並びの匿名アイテムになる。
     縦積みにして 2 行として読ませる。 */
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 16px;
  color: var(--c-slate); font-size: 14px; text-align: center;
}
/* LP の機能カード。アイコン → タグ → 見出し → 本文を中央に積む（Do #8: テキストに
   アイコンを添える）。見出し・本文のサイズはカード側で決めるので、ERB にインライン
   style を持たせない。間隔は gap で通し、.tag の margin-bottom はここで打ち消す
   （両方効くと 12 + 8 = 20px になり、タグだけ見出しから離れる）。 */
.card.feature {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
}
.card.feature .tag { margin-bottom: 0; }
.card.feature h3 { font-size: 16px; }
.card.feature p { font-size: 13px; }

/* アイコンを載せる円。ページ背景（--c-bg）はライト / ダークとも --c-surface より
   一段沈んだ面なので、カード上で自然にくぼんで見える（.hero-visual と同じ扱い）。 */
.feature-icon {
  width: 56px; height: 56px; flex: none;
  display: grid; place-items: center;
  margin-bottom: 8px;                 /* gap 8px と合わせてタグまで 16px */
  border-radius: var(--r-full);
  border: 1px solid var(--c-line);
  background: var(--c-bg);
  color: var(--c-primary);
}
/* ナビ・ボタンと同じ currentColor マスク方式。--i は .ic[data-icon] 側が持つ。 */
.feature-icon .ic {
  width: 26px; height: 26px;
  background-color: currentColor;
  -webkit-mask: var(--i) center / 26px 26px no-repeat;
  mask: var(--i) center / 26px 26px no-repeat;
}

.check-list { font-size: 13px; list-style: none; margin-top: 12px; line-height: 2; }
.price { font-size: 28px; font-weight: 700; color: var(--c-primary); font-family: var(--f-head); }
/* 課金カードの金額。.price より 1 段小さい（インライン style の代替） */
.price.sm { font-size: 24px; }

/* カード冒頭の強調行。<strong style="font-size:16px"> の重複を置き換える。 */
.card-lead {
  font-family: var(--f-head);
  font-size: 16px; font-weight: 600;
  color: var(--c-text);
}
.price small { font-size: 13px; font-weight: 400; }

/* アカウント設定のアイコン。未設定のときは名前のイニシャルを円に表示する。 */
.account-avatar-row { display: flex; align-items: center; gap: 16px; }
.account-avatar {
  width: 64px; height: 64px; flex: 0 0 64px;
  border-radius: var(--r-full);
  background: linear-gradient(135deg, #52586B, #9AA0B5);
  object-fit: cover;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-family: var(--f-head); font-size: 24px; font-weight: 600;
}

/* 画面一覧（/screens） ------------------------------------------------------ */
.hub { max-width: 1080px; margin: 0 auto; padding: 48px 24px; }
.hub .grp { margin-top: 40px; }
.hub .grp > h2 {
  font-size: 16px; font-weight: 600;
  border-bottom: 1px solid var(--c-line);
  padding-bottom: 10px; margin-bottom: 16px;
}
.scr-list { list-style: none; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.scr {
  display: flex; align-items: center; gap: 12px;
  border: 1px solid var(--c-line); border-radius: var(--r);
  background: var(--c-surface); padding: 14px 16px; text-decoration: none;
  transition: border-color .15s, box-shadow .15s, transform .15s;
}
.scr:hover { border-color: var(--c-line-strong); box-shadow: var(--sh-md); transform: translateY(-1px); }
.scr .id {
  font-family: var(--f-mono);
  font-size: 12px; font-weight: 500; letter-spacing: 0.5px;
  background: var(--c-primary); color: var(--c-on-primary);
  padding: 3px 8px; border-radius: var(--r-sm); flex: 0 0 auto;
}
.scr .id.future { background: var(--c-line-soft); color: var(--c-slate); }
.scr .id.na { background: transparent; color: var(--c-slate); border: 1px solid var(--c-line); }
.scr .nm { color: var(--c-primary); font-weight: 500; font-size: 14px; }
.scr .u { color: var(--c-slate); font-size: 12px; font-family: var(--f-mono); margin-left: auto; }

/* ユーティリティ ----------------------------------------------------------- */
.mt-0 { margin-top: 0; } .mt-8 { margin-top: 8px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-16 { margin-bottom: 16px; } .mb-0 { margin-bottom: 0; }
.muted { color: var(--c-slate); }
.small { font-size: 12px; line-height: 1.6; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
/* flex 行の中で右端へ寄せる（margin-left:auto のインライン style の代替） */
.push-right { margin-left: auto; }
.row { display: flex; align-items: center; gap: 8px; }
.row.wrap { flex-wrap: wrap; }
.row.bottom { align-items: flex-end; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.spread.top { align-items: flex-start; }
/* 右端のアクションは縮めず、テキスト側に余りを吸わせる */
.spread > .btn, .spread > form.button_to { flex: 0 0 auto; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.narrow { max-width: 640px; }
.narrow-sm { max-width: 560px; }
.wide-md { max-width: 760px; }
.section-title {
  font-family: var(--f-head);
  font-size: 16px; font-weight: 600;
  color: var(--c-text);
  margin: 24px 0 12px;
  letter-spacing: 0.01em;
}
/* ページ先頭とページヘッダ直後は、上の余白（.wf-page-head の 24px）と二重になる */
.section-title:first-child,
.wf-page-head + .section-title { margin-top: 0; }

/* 見出しと右のリンクを 1 行に並べる .spread の中では、上下非対称なマージンが
   align-items:center の中心をずらし、リンクが見出しより上に浮く。
   セクション間の余白は .spread 側（と mt-* ユーティリティ）が持つ。 */
.spread > .section-title { margin: 0; }
.spread:has(> .section-title) { margin-bottom: 12px; }

/* ==========================  レスポンシブ  ================================
   ブレークポイント: 1024px（タブレット）/ 768px（スマホ横）/ 480px（スマホ縦）。
   240px 固定のサイドバーは狭幅で本文を潰すため、1024px 以下で上部バーに畳む。
   ========================================================================== */

@media (max-width: 1024px) {
  /* --- サイドバー → アプリバー + ドロワー -----------------------------------
     11 項目のナビを横スクロールのタブ列に押し込むと、隠れた項目が見つからず
     グループ分けも失われる。狭幅では上部にアプリバーを出し、ナビは
     スライドインのドロワー（Material の Top App Bar + Navigation Drawer）に置く。 */
  .wf-appbar {
    display: flex; align-items: center; gap: 8px;
    position: sticky; top: 0;
    z-index: 30;
    background: var(--wf-sidebar);
    padding: 8px 12px;
    padding-top: calc(8px + env(safe-area-inset-top));
    padding-left: calc(12px + env(safe-area-inset-left));
    padding-right: calc(12px + env(safe-area-inset-right));
  }

  .wf-scrim {
    display: block;
    position: fixed; inset: 0;
    z-index: 40;
    background: rgba(10, 12, 20, .6);   /* 中立の暗いスクリム。前景を分離できる濃さ */
  }
  .wf-scrim[hidden] { display: none; }

  .wf-sidebar {
    position: fixed;
    top: 0; bottom: 0; left: 0;
    z-index: 50;
    width: 280px; max-width: 86vw;
    flex: none;
    height: 100dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
    transform: translateX(-100%);
    transition: transform .2s ease-out;   /* 退出は CSS 側で同値。reduced-motion で無効化される */
    box-shadow: var(--sh-lg);
    padding-top: calc(20px + env(safe-area-inset-top));
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .wf-sidebar.open { transform: translateX(0); }

  .wf-drawer-close {
    display: inline-flex; align-items: center; justify-content: center;
    width: 44px; height: 44px; flex: 0 0 44px;
    margin-right: -10px;                  /* 視覚位置を保ちつつタップ領域だけ広げる */
    border: none; background: transparent; cursor: pointer;
    color: var(--c-on-navy-2); font-size: 16px;
    border-radius: var(--r);
    transition: color .15s, background .15s;
  }
  .wf-drawer-close:hover { color: #fff; background: rgba(255, 255, 255, .08); }

  /* ドロワー内は指で押しやすい高さに */
  .wf-nav a { padding: 12px; }
  .wf-orgswitch { min-height: 44px; }

  .wf-content { padding: 24px; }
  .cols-4 { grid-template-columns: 1fr 1fr; }
  .status-row { grid-template-columns: 1fr; gap: 8px; }
  .public-wrap { --gutter: 24px; }
  section.site, header.site, footer.site { padding-block: 48px; }
  header.site { padding-block: 12px; }
}

@media (max-width: 768px) {
  .wf-content { padding: 16px; }
  .wf-flash { padding: 12px 16px; }

  .grid, .cols-2, .cols-3, .cols-4 { grid-template-columns: 1fr; }
  .grid { gap: 16px; }

  /* 表は横スクロールに逃がす（本文側の横スクロールを起こさない）。
     はみ出す表には table_scroll_controller が tabindex / role=region を付ける。 */
  table {
    display: block;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    -webkit-overflow-scrolling: touch;
  }
  table.wf-kv { display: table; overflow: visible; }
  /* 狭幅では表そのものが横スクロールするので、省略せず全文を出す */
  table.data-left td.truncate { max-width: none; overflow: visible; text-overflow: clip; }

  /* セルを折り返さないことで、内側の表が親より広くなり overflow-x が効く。
     折り返しを許すと表が親幅に収まってしまい、URL 列が 1 文字ずつ改行されて読めなくなる。
     （table 自体に width: max-content を与えると箱ごと広がり、ページが横スクロールする） */
  table:not(.wf-kv) th, table:not(.wf-kv) td { white-space: nowrap; }

  /* オンボーディングのプラン比較は幅の狭い認証カード内にある。3 列・短い値なので、
     横スクロール（データテーブルの既定）よりも折り返してカード幅に収める方が読みやすい。
     table-layout: fixed でカード幅ちょうどに固定し、列内で折り返させる（auto だと
     内容の最小幅で表がカードをはみ出す）。 */
  .auth-card table.data-left { display: table; width: 100%; table-layout: fixed; }
  .auth-card table.data-left th, .auth-card table.data-left td { white-space: normal; overflow-wrap: anywhere; }
  .auth-card table.data-left th:first-child, .auth-card table.data-left td:first-child { width: 38%; }

  /* カード内の「説明 ↔ 金額」を 1 行に並べたままにすると、右の金額（.nowrap）が幅を譲らず、
     左の説明が数語ずつしか入らずに縦へ伸びる。狭幅では上下に分け、金額側は
     ラベル・値・日付を左寄せの 1 行に寝かせて（折り返しも許して）区切り線で仕切る。 */
  .card .spread { flex-direction: column; align-items: stretch; gap: 12px; }
  .card .spread > .right {
    display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 8px;
    text-align: left; white-space: normal;
    padding-top: 12px; border-top: 1px solid var(--c-line);
  }

  /* ページヘッダのアクション列は折り返す */
  .wf-page-head { flex-direction: column; }
  .wf-page-head .actions { margin-left: 0; width: 100%; flex-wrap: wrap; }
  .wf-input.w-xs, .wf-input.w-sm, .wf-input.w-md, .wf-input.w-lg { width: 100%; }

  /* タッチターゲット 44px 下限（Apple HIG / Material 48dp） */
  .btn, .btn.sm { min-height: 44px; }
  .wf-flash .close { min-width: 44px; min-height: 44px; }
  .wf-user .logout { min-height: 44px; }
  .wf-dropdown button { min-height: 44px; }
  label.check { min-height: 44px; }
  .link-more { min-height: 44px; }
  /* デスクトップでツールバーとして詰めた入力を、指で押せる高さへ戻す */
  .wf-page-head .actions .wf-input { min-height: 44px; padding: 10px 14px; }
  .wf-page-head .actions select.wf-input { padding-right: 34px; background-position: right 12px center; }
  td .wf-input { min-height: 44px; padding: 10px 12px; }

  /* モーダルはボトムシートとして扱う（親指の届く位置に出す） */
  dialog.wf-modal {
    width: 100%; max-width: none;
    margin: 0 auto;
    position: fixed;
    inset: auto 0 0 0;
    border-radius: var(--r-md) var(--r-md) 0 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  dialog.wf-modal .body { max-height: 60dvh; overflow-y: auto; }

  .scr-list { grid-template-columns: 1fr; }
  footer.site { flex-direction: column; gap: 24px; }
  header.site { flex-wrap: wrap; }
  header.site nav { justify-content: flex-start; flex-basis: 100%; overflow-x: auto; }
}

@media (max-width: 480px) {
  .public-wrap { --gutter: 16px; }
  section.site, header.site, footer.site { padding-block: 32px; }
  header.site { padding-block: 12px; }
  h1 { font-size: 24px; }
  h2 { font-size: 20px; }
  .wf-page-head h1 { font-size: 20px; }
  .wf-page-head .actions { flex-direction: column; align-items: stretch; }
  .wf-page-head .actions .btn { width: 100%; }
  /* 縦積みでは左マージンではなく上マージンで破壊的操作を離す */
  .wf-page-head .actions > .btn.danger,
  .wf-page-head .actions > form.button_to:has(> .btn.danger) { margin-left: 0; margin-top: 8px; }
  .wf-form-actions { flex-direction: column-reverse; align-items: stretch; }
  .wf-form-actions .btn { width: 100%; }
  .auth-layout { padding: 24px 16px; }
  .auth-card { padding: 24px; }
  .wf-fieldset, .wf-collapse > .body, .card { padding: 16px; }

  /* 集計カードは縦積みだと 3 枚で 1 画面を使い切る。数値とラベルを横並びにして畳む。 */
  .wf-stat {
    display: flex; align-items: center; justify-content: space-between;
    gap: 16px;
    padding: 16px 20px;
  }
  .wf-stat .num { font-size: 28px; }
  .wf-stat .lbl { margin-top: 0; }

  /* LP: ボタンと補足テキストの横並びは狭幅で潰れるため折り返す */
  section.site .row { flex-wrap: wrap; }
  .hero-visual { height: auto; min-height: 200px; padding: 24px 16px; }

  /* 下端のホームインジケータに本文が潜り込まないようにする */
  .wf-content { padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
}
