/* ============================================================
 * styles.css — デザインシステム（design.md / components.md 準拠）
 * 色は役割で固定 / 余白は4の倍数 / 角丸標準8px / 影は3段階定義 /
 * カード=白+1px罫線+低影 / フォントチェーン固定 / BEM命名。
 * ============================================================ */

:root {
  /* ブランド / アクセント */
  --brand: #3178E2;
  --brand-dark: #0069D3;
  --navy: #405D9C;
  /* テキスト */
  --text: #3B455B;
  --muted: #606E7F;
  --placeholder: #99A0AD;
  --link: #0069D3;
  --invert: #FFFFFF;
  /* 背景・面: L0 奥(サイドバー) → L1 中(キャンバス/ヘッダー) → L2 手前(カード) → L3 埋込 */
  --bg-sidebar: #F1F4F7;
  --bg-canvas: #FAFBFC;
  --canvas: var(--bg-canvas);
  --white: #FFFFFF;
  --surface: #FFFFFF;
  --surface-inset: #F6F8FA;
  --brand-soft: #f3f9ff;
  /* 罫線 */
  --border-card: #ECEEF1;
  --border-divider: #F1F3F5;
  --line: #E2E6ED;
  --line-soft: #EDF1F6;
  --input-border: #DADEE4;
  /* ステータス（薄背景＋同系ボーダー＋同系文字の3点セット） */
  --success: #00A16C; --success-bg: #e7f7f0; --success-bd: #b6e6d3; --success-tx: #00875c;
  --warning: #f28100; --warning-bg: #fff6ea; --warning-bd: #fcdcb3; --warning-tx: #b85e00;
  --danger: #EF4444;  --danger-bg: #fdeced;  --danger-bd: #f6c6c9;  --danger-tx: #d12d2d;
  --info: #0069D3;    --info-bg: #eef5ff;    --info-bd: #c9def9;    --info-tx: #0069D3;
  --neutral: #606e7f; --neutral-bg: #f0f2f5; --neutral-bd: #dfe3e9; --neutral-tx: #606e7f;
  --purple: #8B5CF6;  --purple-bg: #f3eefe;  --purple-bd: #ddd0fa;  --purple-tx: #7c4ddb;
  /* 後から書かれた画面(AIパネル・共有レイアウト)が使っていたのに未定義だった名前。
     既存の名前への別名として定義する — 未定義のままだと var() が解決できず、
     背景・文字色がその場で無効になっていた（AIパネルが素通しで表示されていた） */
  --primary: #2456d6;               /* 各所の var(--primary, #2456d6) と同値 */
  --surface-card: var(--surface);
  --text-muted: var(--muted);
  /* 影（ネイビー寄り低不透明度） */
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04);
  --shadow-raised: 0 1px 3px rgba(16, 24, 40, 0.08);
  --radius-card: 12px;
  --shadow-low: 0 1px 3px rgba(78,91,149,.04), 0 4px 6px -1px rgba(78,91,149,.02);
  --shadow-mid: 0 3px 6px -1px rgba(78,91,149,.08), 0 8px 15px -3px rgba(78,91,149,.06);
  --shadow-high: 0 5px 15px -3px rgba(78,91,149,.15), 0 12px 50px -12px rgba(78,91,149,.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', Meiryo, sans-serif;
  font-size: 14px;
  line-height: 1.7;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p, dl, dd, figure { margin: 0; }
a { color: var(--link); text-decoration: none; }
a:hover { color: var(--brand-dark); }
button, input, textarea, select { font: inherit; color: inherit; }
.tnum { font-variant-numeric: tabular-nums; }

.icon { width: 24px; height: 24px; display: inline-block; vertical-align: middle; flex: none; }
.icon--lg { width: 40px; height: 40px; }
.icon--sm { width: 18px; height: 18px; }
.icon--xs { width: 14px; height: 14px; }
.icon--btn { width: 18px; height: 18px; }

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

/* ============================================================
 * アプリシェル（サイドバー240px + ヘッダー56px）
 * ============================================================ */
.app {
  display: grid;
  grid-template-columns: 240px minmax(920px, 1fr);
  grid-template-rows: 56px 1fr;
  min-height: 100vh;
}

.sidebar {
  grid-row: 1 / 3;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.sidebar__brand { display: flex; align-items: center; gap: 12px; padding: 16px 16px 12px; }
.sidebar__mark {
  width: 40px; height: 40px; border-radius: 8px;
  background: var(--brand-soft); color: var(--brand-dark);
  display: grid; place-items: center; border: 1px solid var(--info-bd);
}
.sidebar__brand-name { font-size: 18px; font-weight: 700; line-height: 1.3; }
.sidebar__brand-sub { font-size: 12px; color: var(--muted); line-height: 1.4; }
.sidebar__nav { padding: 8px 12px; display: flex; flex-direction: column; gap: 2px; }
.sidebar__group-label { font-size: 12px; color: var(--placeholder); padding: 12px 12px 6px; font-weight: 500; }
.nav-item {
  display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 10px;
  min-height: 40px; padding: 0 12px; border-radius: 8px;
  border: 0; background: transparent; color: #475467;
  font-size: 14px; font-weight: 500; text-align: left; cursor: pointer; width: 100%;
}
.nav-item:hover { background: rgba(255, 255, 255, 0.6); color: var(--text); }
/* アクティブ項目は「手前=白」ルールに従い白面+浮き影(青枠スタイルは廃止) */
.nav-item.is-active { background: var(--surface); box-shadow: var(--shadow-raised); color: #2563EB; }
.nav-item.is-active .icon { color: #2563EB; }
.nav-item__badge {
  min-width: 22px; height: 20px; padding: 0 6px; border-radius: 999px;
  background: var(--line-soft); color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 500; font-variant-numeric: tabular-nums;
}
.nav-item.is-active .nav-item__badge { background: var(--info-bd); color: var(--brand-dark); }
.nav-item__badge--alert { background: var(--danger-bg); color: var(--danger-tx); border: 1px solid var(--danger-bd); }

/* 受信箱直下のチャンネル一覧（すべて / 各サイト） */
.nav-subnav { display: flex; flex-direction: column; margin: 2px 0 4px; }
.nav-sub {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px 6px 34px; border-radius: 8px; border: 0;
  color: var(--muted); font-size: 13px; text-decoration: none;
}
.nav-sub:hover { background: rgba(255, 255, 255, 0.6); color: var(--text); }
/* 選択中サブメニューは他のメニュー(.nav-item.is-active)と同じ見た目に揃える */
.nav-sub.is-active { background: var(--surface); box-shadow: var(--shadow-raised); color: #2563EB; font-weight: 500; }
.nav-sub.is-active .nav-item__badge { background: var(--info-bd); color: var(--brand-dark); }
.nav-sub.is-active .nav-sub__err { color: var(--danger); }
.nav-sub__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-sub__err { color: var(--danger); display: inline-flex; }
.sidebar__foot {
  margin-top: auto; padding: 16px;
}
.sidebar__foot-card { border: 1px solid var(--border-card); border-radius: 8px; padding: 16px; background: var(--surface); box-shadow: var(--shadow-card); }
.sidebar__foot-label { font-size: 12px; color: var(--muted); }
.sidebar__foot-value { font-size: 14px; font-weight: 500; margin-top: 4px; font-variant-numeric: tabular-nums; }
.sidebar__foot-note { font-size: 12px; color: var(--muted); line-height: 1.5; margin-top: 8px; }

.header {
  grid-column: 2; position: sticky; top: 0; z-index: 10;
  height: 56px; background: var(--bg-canvas);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; gap: 16px;
}
.header.is-scrolled { box-shadow: 0 1px 0 var(--border-card); }
.breadcrumb { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--brand-dark); }
.breadcrumb__sep { color: var(--placeholder); }
.breadcrumb__current { color: var(--text); }
.header__actions { display: flex; align-items: center; gap: 12px; }
.header__sync { font-size: 13px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.header__sync .dot { margin: 0; }
.header__icon-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border-card);
  background: transparent; color: var(--muted); display: grid; place-items: center; cursor: pointer;
}
.header__icon-btn:hover { background: var(--surface-inset); color: var(--text); }

.main { grid-column: 2; min-width: 920px; }
.main__inner { padding: 24px; display: flex; flex-direction: column; gap: 24px; }
.main--flush .main__inner { padding: 0; }

/* ============================================================
 * Page header
 * ============================================================ */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.page-head__title-row { display: flex; align-items: center; gap: 12px; }
.page-head__icon {
  width: 40px; height: 40px; border-radius: 8px; flex: none;
  background: var(--brand-soft); color: var(--brand); display: grid; place-items: center;
}
.page-head__title { font-size: 26px; font-weight: 500; line-height: 1.3; }
.page-head__title--detail { font-size: 22px; }
.page-head__desc { color: var(--muted); margin-top: 8px; max-width: 70ch; }
.page-head__actions { display: flex; align-items: center; gap: 12px; flex: none; }


/* ============================================================
 * Button
 * ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border-radius: 8px; border: 1px solid transparent; cursor: pointer;
  font-weight: 500; white-space: nowrap; text-decoration: none;
  transition: filter .12s ease, background-color .12s ease, border-color .12s ease;
}
.btn--lg { height: 48px; padding: 0 24px; font-size: 16px; gap: 8px; }
.btn--md { height: 40px; padding: 0 20px; font-size: 14px; gap: 6px; }
.btn--sm { height: 32px; padding: 0 16px; font-size: 12px; gap: 4px; }
.btn--xs { height: 24px; padding: 0 12px; font-size: 10px; gap: 2px; }
.btn--lg .icon--btn { width: 20px; height: 20px; }
.btn--sm .icon--btn { width: 16px; height: 16px; }
.btn--xs .icon--btn { width: 14px; height: 14px; }
.btn--icon { padding: 0; aspect-ratio: 1 / 1; }
.btn--icon.btn--md { width: 40px; }
.btn--icon.btn--sm { width: 32px; }

.btn--primary { background: var(--brand); border-color: var(--brand); color: var(--invert); }
.btn--primary:hover { filter: brightness(1.08); color: var(--invert); }
.btn--primary:active { background: var(--brand-dark); border-color: var(--brand-dark); filter: none; }
.btn--secondary { background: var(--white); border-color: var(--input-border); color: var(--text); }
.btn--secondary:hover { background: var(--surface-inset); color: var(--text); }
.btn--secondary:active { background: var(--line-soft); }
.btn--secondary.is-selected { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.btn--tertiary { background: transparent; border-color: transparent; color: var(--link); }
.btn--tertiary:hover { color: var(--brand-dark); text-decoration: underline; }
.btn--sub { background: var(--navy); border-color: var(--navy); color: var(--invert); }
.btn--sub:hover { filter: brightness(1.08); color: var(--invert); }
.btn--danger { background: var(--danger); border-color: var(--danger); color: var(--invert); }
.btn--danger:hover { filter: brightness(1.06); color: var(--invert); }
.btn--danger-outline { background: var(--white); border-color: var(--danger-bd); color: var(--danger-tx); }
.btn--danger-outline:hover { background: var(--danger-bg); }
.btn:disabled, .btn.is-loading { background: var(--line-soft); border-color: var(--line); color: var(--placeholder); cursor: not-allowed; filter: none; }
.btn:focus-visible { outline: 3px solid rgba(49,120,226,.4); outline-offset: 1px; }

/* ============================================================
 * Badge / Chip / Status dot / importance
 * ============================================================ */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 10px; border-radius: 999px;
  font-size: 12px; font-weight: 500; line-height: 1; white-space: nowrap; border: 1px solid;
}
.badge--sm { height: 20px; padding: 0 8px; }
.badge--success { background: var(--success-bg); border-color: var(--success-bd); color: var(--success-tx); }
.badge--warning { background: var(--warning-bg); border-color: var(--warning-bd); color: var(--warning-tx); }
.badge--danger  { background: var(--danger-bg);  border-color: var(--danger-bd);  color: var(--danger-tx); }
.badge--info    { background: var(--info-bg);    border-color: var(--info-bd);    color: var(--info-tx); }
.badge--neutral { background: var(--neutral-bg); border-color: var(--neutral-bd); color: var(--neutral-tx); }
.badge--purple  { background: var(--purple-bg);  border-color: var(--purple-bd);  color: var(--purple-tx); }

.chip {
  display: inline-flex; align-items: center; height: 22px; padding: 0 10px;
  border-radius: 6px; background: var(--surface-inset); border: 1px solid var(--line);
  font-size: 12px; color: var(--muted); white-space: nowrap;
}

.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; background: var(--neutral); }
.dot--success { background: var(--success); }
.dot--warning { background: var(--warning); }
.dot--danger { background: var(--danger); }
.dot--info { background: var(--info); }
.dot--neutral { background: var(--neutral); }

.imp { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); white-space: nowrap; }
.imp--high { color: var(--danger-tx); font-weight: 500; }

/* ============================================================
 * Card
 * ============================================================ */
.card { background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--radius-card); box-shadow: var(--shadow-card); }
.card__head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  padding: 16px 24px; border-bottom: 1px solid var(--border-divider);
}
.card__head-titles { min-width: 0; }
.card__title { font-size: 18px; font-weight: 500; line-height: 1.3; }
.card__subtitle { font-size: 13px; color: var(--muted); margin-top: 4px; }
.card__head-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.card__body { padding: 24px; }
.card__body--flush { padding: 0; }

/* ============================================================
 * 統計カードグリッド（ダッシュボード）
 * ============================================================ */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }
.stat-card {
  background: var(--white); border: 1px solid var(--line); border-radius: 8px;
  box-shadow: var(--shadow-low); padding: 20px; display: flex; flex-direction: column; gap: 12px;
}
.stat-card__head { display: flex; align-items: center; gap: 10px; }
.stat-card__icon { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; flex: none; }
.stat-card__icon--info { background: var(--info-bg); color: var(--info); }
.stat-card__icon--success { background: var(--success-bg); color: var(--success); }
.stat-card__icon--warning { background: var(--warning-bg); color: var(--warning); }
.stat-card__icon--purple { background: var(--purple-bg); color: var(--purple); }
.stat-card__label { font-size: 13px; color: var(--muted); }
.stat-card__value { font-size: 28px; font-weight: 500; line-height: 1.3; font-variant-numeric: tabular-nums; }
.stat-card__value-unit { font-size: 14px; color: var(--muted); margin-left: 4px; }
.stat-card__delta { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }
.stat-card__delta--up { color: var(--success-tx); }
.stat-card__delta--down { color: var(--danger-tx); }
.stat-card__delta--flat { color: var(--muted); }

/* 内訳バー */
.breakdown { display: flex; flex-direction: column; gap: 14px; }
.breakdown__row { display: grid; grid-template-columns: 140px 1fr 44px; align-items: center; gap: 12px; }
.breakdown__label { font-size: 13px; color: var(--text); display: inline-flex; align-items: center; gap: 6px; }
.breakdown__track { height: 8px; border-radius: 999px; background: var(--line-soft); overflow: hidden; }
.breakdown__fill { height: 100%; border-radius: 999px; background: var(--brand); }
.breakdown__fill--success { background: var(--success); }
.breakdown__fill--info { background: var(--info); }
.breakdown__fill--warning { background: var(--warning); }
.breakdown__fill--purple { background: var(--purple); }
.breakdown__fill--neutral { background: var(--neutral); }
.breakdown__fill--danger { background: var(--danger); }
.breakdown__count { font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); }

/* ============================================================
 * Table
 * ============================================================ */
.table-wrap { width: 100%; overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table thead th {
  background: var(--surface-inset); font-size: 13px; font-weight: 500; color: var(--muted); text-align: left;
  padding: 12px 16px; border-bottom: 1px solid var(--border-divider); white-space: nowrap;
}
.table thead th:first-child, .table tbody td:first-child { padding-left: 24px; }
.table tbody td { padding: 12px 16px; border-bottom: 1px solid var(--border-divider); vertical-align: middle; }
.table tbody tr:hover { background: var(--surface-inset); }
.table tbody tr.is-selected { background: var(--brand-soft); }
.table__num { font-variant-numeric: tabular-nums; text-align: right; }
.table__link { color: var(--link); }
.table__sub { font-size: 12px; color: var(--muted); }
.table-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ============================================================
 * Segment / Tabs
 * ============================================================ */
.segment { display: inline-flex; padding: 4px; gap: 2px; background: var(--line-soft); border-radius: 8px; }
.segment__btn {
  border: 0; background: transparent; color: var(--muted); cursor: pointer;
  padding: 6px 14px; border-radius: 6px; font-size: 13px; font-weight: 500;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.segment__btn.is-selected { background: var(--white); color: var(--brand-dark); box-shadow: var(--shadow-low); }
.segment__count { font-size: 12px; font-variant-numeric: tabular-nums; color: var(--placeholder); }
.segment__btn.is-selected .segment__count { color: var(--brand); }

.tabs { display: flex; gap: 24px; border-bottom: 1px solid var(--line); }
.tabs__btn {
  border: 0; background: transparent; cursor: pointer; color: var(--muted);
  padding: 12px 0; font-size: 14px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tabs__btn:hover { color: var(--text); }
.tabs__btn.is-active { color: var(--brand-dark); border-bottom-color: var(--brand); }

/* ============================================================
 * Notice / Alert
 * ============================================================ */
.notice {
  display: flex; align-items: flex-start; gap: 12px; padding: 14px 16px;
  border: 1px solid; border-left-width: 4px; border-radius: 8px; background: var(--white);
}
.notice__icon { flex: none; }
.notice__body { flex: 1; min-width: 0; }
.notice__title { font-weight: 500; }
.notice__text { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 2px; }
.notice__action { flex: none; }
.notice--info { border-color: var(--info-bd); }
.notice--info .notice__icon { color: var(--info); }
.notice--success { border-color: var(--success-bd); }
.notice--success .notice__icon { color: var(--success); }
.notice--warning { border-color: var(--warning-bd); }
.notice--warning .notice__icon { color: var(--warning); }
.notice--danger { border-color: var(--danger-bd); background: var(--white); }
.notice--danger .notice__icon { color: var(--danger); }
/* neutral はカード内の埋め込み注記(L3): ボーダーなしの面差のみで表現 */
.notice--neutral { background: var(--surface-inset); border: 0; border-radius: 8px; }
.notice--neutral .notice__icon { color: var(--muted); }

/* ============================================================
 * 状態表示: Loading / Empty / Error
 * ============================================================ */
.state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px; padding: 48px 24px; text-align: center; min-height: 220px;
}
.state__icon { width: 80px; height: 80px; border-radius: 50%; display: grid; place-items: center; }
.state__icon--neutral { background: var(--surface-inset); color: var(--muted); }
.state__icon--danger { background: var(--danger-bg); color: var(--danger); }
.state__icon--success { background: var(--success-bg); color: var(--success); }
.state__title { font-size: 15px; font-weight: 500; }
.state__text { font-size: 13px; color: var(--muted); max-width: 46ch; }
.state__action { margin-top: 4px; }

.spinner {
  width: 40px; height: 40px; border-radius: 50%;
  border: 3px solid var(--line); border-top-color: var(--brand);
  animation: spin .8s linear infinite;
}
.spinner--btn { width: 16px; height: 16px; border-width: 2px; border-color: rgba(255,255,255,.5); border-top-color: #fff; }
.is-loading .spinner--btn { border-color: var(--line); border-top-color: var(--muted); }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
 * Toast
 * ============================================================ */
.toast-host { position: fixed; right: 24px; bottom: 24px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast {
  display: inline-flex; align-items: center; gap: 8px; padding: 12px 16px; border-radius: 6px;
  color: var(--invert); box-shadow: var(--shadow-high); font-size: 14px;
  transform: translateY(8px); opacity: 0; transition: transform .2s ease, opacity .2s ease;
}
.toast.is-in { transform: translateY(0); opacity: 1; }
.toast--success { background: var(--success); }
.toast--danger { background: var(--danger); }
.toast--warning { background: var(--warning); }
.toast--info { background: var(--brand-dark); }

/* ============================================================
 * Modal
 * ============================================================ */
.modal-overlay {
  position: fixed; inset: 0; z-index: 70; background: rgba(35,42,60,.42);
  backdrop-filter: blur(2px); display: grid; place-items: center; padding: 24px;
}
.modal { width: 100%; max-width: 800px; background: var(--white); border-radius: 16px; box-shadow: var(--shadow-high); overflow: hidden; }
.modal--wide { max-width: 896px; }
.modal__head { display: flex; align-items: center; gap: 12px; padding: 24px; border-bottom: 1px solid var(--line); }
.modal__icon { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; flex: none; }
.modal__icon--danger { background: var(--danger-bg); color: var(--danger); }
.modal__title { font-size: 20px; font-weight: 500; flex: 1; }
.modal__close { width: 32px; height: 32px; border: 0; background: transparent; color: var(--muted); border-radius: 6px; cursor: pointer; display: grid; place-items: center; }
.modal__close:hover { background: var(--surface-inset); color: var(--text); }
.modal__body { padding: 24px; max-height: 64vh; overflow-y: auto; }
.modal__foot { display: flex; justify-content: flex-end; gap: 12px; padding: 16px 24px; border-top: 1px solid var(--line); }

/* ============================================================
 * Form 部品
 * ============================================================ */
.field { display: flex; flex-direction: column; gap: 8px; margin-bottom: 24px; }
.field__label { font-size: 14px; font-weight: 500; }
.field__hint { font-size: 13px; color: var(--muted); }
.input, .select select, .textarea {
  height: 40px; padding: 0 12px; border: 1px solid var(--input-border); border-radius: 8px;
  background: var(--white); font-size: 14px; width: 100%;
}
.textarea { height: auto; padding: 12px; line-height: 1.7; resize: vertical; }
.input:focus, .select select:focus, .textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(49,120,226,.15); }
.input::placeholder, .textarea::placeholder { color: var(--placeholder); }
.select { position: relative; display: inline-block; width: 100%; }
.select select { appearance: none; padding-right: 32px; }
.select__arrow { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }

.toggle { position: relative; display: inline-block; width: 36px; height: 20px; flex: none; }
.toggle input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.toggle__track { position: absolute; inset: 0; background: var(--line); border-radius: 999px; transition: background .15s ease; }
.toggle__track::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: var(--shadow-low); transition: transform .15s ease; }
.toggle input:checked + .toggle__track { background: var(--brand); }
.toggle input:checked + .toggle__track::after { transform: translateX(16px); }

/* 定義リスト */
.deflist { display: grid; grid-template-columns: 132px 1fr; gap: 12px 16px; }
.deflist dt { color: var(--muted); font-size: 13px; }
.deflist dd { font-variant-numeric: tabular-nums; }

/* ============================================================
 * 検知詳細（旧・受信箱リーダーを検知一覧に統合）
 * ============================================================ */
.detail-bar { display: flex; align-items: center; gap: 8px; }
.table tr.is-unread-row > td { background: var(--brand-soft); }

/* リーダー */
.reader { padding: 24px 28px; max-width: 1120px; margin: 0 auto; }
.reader__meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; color: var(--muted); font-size: 13px; }
.reader__sep { color: var(--placeholder); }
.reader__mon { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.reader__conclusion { margin-top: 12px; }
.reader__summary { font-size: 22px; font-weight: 500; line-height: 1.4; margin-top: 4px; }
.reader__class { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.reader__facts { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.fact-pill { display: inline-flex; align-items: baseline; gap: 4px; padding: 6px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); font-size: 13px; }
.fact-pill strong { font-size: 16px; font-weight: 500; font-variant-numeric: tabular-nums; }
.reader__actions { display: flex; align-items: center; gap: 8px; margin-top: 16px; }
.reader__actions .spacer { flex: 1; }

.reader__url { font-size: 12px; color: var(--muted); text-decoration: none; margin-left: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40%; }
.reader__url:hover { color: var(--primary, #2456d6); text-decoration: underline; }
.reader__tags { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.tag-add-chip { display: inline-flex; align-items: center; gap: 2px; border: 1px dashed var(--line); background: transparent; border-radius: 999px; padding: 2px 10px; font-size: 12px; color: var(--muted); cursor: pointer; }
.tag-add-chip:hover { border-color: var(--primary, #2456d6); color: var(--primary, #2456d6); }

/* 監視の調整メニュー */
.menu-wrap { position: relative; }
.menu-pop { position: absolute; right: 0; top: calc(100% + 6px); z-index: 60; min-width: 320px; background: var(--white); border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 12px 32px rgba(20, 30, 50, .12); padding: 6px; display: flex; flex-direction: column; gap: 2px; }
.menu-pop[hidden] { display: none; }

/* 検知詳細のコメント */
.reader__comments { margin-top: 24px; border-top: 1px solid var(--line); padding-top: 16px; }
.comment { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--white); margin-bottom: 8px; }
.comment__head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; font-size: 13px; }
.comment__head .picker-row__x { margin-left: auto; }
.comment__body { font-size: 13px; line-height: 1.7; white-space: pre-wrap; word-break: break-word; }
.comment-form { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; }

/* セレクタピッカーの候補・選択リスト */
.picker-list { display: flex; flex-direction: column; gap: 4px; max-height: 160px; overflow-y: auto; }
.picker-row {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--white); font-size: 12px; color: var(--text); cursor: pointer;
}
.picker-row:hover { border-color: var(--brand); background: var(--brand-soft); }
.picker-row--picked { cursor: default; background: var(--brand-soft); border-color: var(--info-bd); }
.picker-row--picked:hover { background: var(--brand-soft); }
.picker-row__tag { font-family: monospace; font-weight: 600; flex: none; }
.picker-row__sel { font-family: monospace; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-row__meta { flex: none; color: var(--muted); }
.picker-row__text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.picker-row__x { flex: none; border: 0; background: none; cursor: pointer; color: var(--muted); display: inline-flex; padding: 2px; }
.picker-row__x:hover { color: var(--danger); }

/* 変化量セル（検知一覧） */
.rate { display: flex; align-items: center; gap: 8px; min-width: 110px; }
.rate__bar { flex: none; width: 56px; height: 6px; border-radius: 3px; background: var(--line-soft, #eef1f6); overflow: hidden; }
.rate__bar span { display: block; height: 100%; border-radius: 3px; background: var(--primary, #2456d6); }
.rate .tnum { font-size: 12px; color: var(--muted); }
.th-sort { color: inherit; text-decoration: none; }
.th-sort:hover { color: var(--primary, #2456d6); }
.th-sort.is-on { color: var(--primary, #2456d6); font-weight: 600; }
.menu-pop > button, .menu-pop > a { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 10px 12px; cursor: pointer; text-decoration: none; color: inherit; font: inherit; }
.menu-pop > button:hover, .menu-pop > a:hover { background: var(--line-soft, #f2f4f8); }
.menu-pop strong { display: block; font-size: 13px; font-weight: 500; }
.menu-pop small { display: block; font-size: 11px; color: var(--muted); margin-top: 2px; line-height: 1.5; }
.menu-pop .icon, .menu-pop svg { flex: none; margin-top: 2px; color: var(--muted); }

.evidence { margin-top: 20px; }
.evidence__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.evidence__label { font-size: 12px; color: var(--placeholder); font-weight: 500; }

/* スクリーンショット比較 */
.shots-side { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.shot { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--white); }
.shot__cap { padding: 8px 12px; border-bottom: 1px solid var(--line); font-size: 12px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.shot__cap--after { color: var(--brand-dark); }
/* スクショは常にページ全長を表示（スライダー表示と統一。2026-07-24仕様変更） */
.shot__scroll { background: var(--surface-inset); }
.shot__scroll img { display: block; width: 100%; }
.shot__missing { height: 420px; display: grid; place-items: center; padding: 24px; text-align: center; color: var(--muted); font-size: 13px; background: var(--surface-inset); }

/* スライダー比較 */
/* 修正(2026-07-01): 固定高さ460pxの切れ問題を解消。after を通常フローで置いて全高を確保し、
 * before を絶対配置で重ねて clip-path で左%だけ表示。上下スクロールでページ全体を比較できる。 */
.cmp-slider { position: relative; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--surface-inset); }
.cmp-slider__base { display: block; width: 100%; }
.cmp-slider__before { position: absolute; top: 0; left: 0; width: 100%; overflow: hidden; clip-path: inset(0 50% 0 0); z-index: 2; }
.cmp-slider__before img { display: block; width: 100%; }
.cmp-slider__handle { position: absolute; top: 0; bottom: 0; left: 50%; width: 2px; background: var(--brand); z-index: 3; transform: translateX(-1px); pointer-events: none; }
.cmp-slider__handle span { position: sticky; top: calc(50vh - 96px); left: 50%; transform: translateX(-50%); width: 32px; height: 32px; border-radius: 50%; background: var(--brand); color: #fff; display: grid; place-items: center; font-size: 12px; box-shadow: var(--shadow-mid); }
.cmp-slider input[type=range] { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; cursor: ew-resize; z-index: 4; margin: 0; }
.cmp-slider__tag { position: absolute; top: 8px; z-index: 3; font-size: 11px; padding: 2px 8px; border-radius: 999px; background: rgba(35,42,60,.7); color: #fff; }
.cmp-slider__tag--l { left: 8px; }
.cmp-slider__tag--r { right: 8px; }

/* テキスト差分（add=緑 / del=赤） */
.diff { border: 1px solid var(--line); border-radius: 8px; overflow: hidden; font-family: 'Roboto Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.6; background: var(--white); max-height: 560px; overflow-y: auto; }
.diff__row { display: grid; grid-template-columns: 28px 1fr auto; }
.diff__mark { text-align: center; color: var(--placeholder); user-select: none; border-right: 1px solid var(--line-soft); }
.diff__text { padding: 1px 12px; white-space: pre-wrap; word-break: break-word; }
.diff__row--add { background: var(--success-bg); }
.diff__row--add .diff__mark { color: var(--success-tx); }
.diff__row--del { background: var(--danger-bg); }
.diff__row--del .diff__mark { color: var(--danger-tx); }
.diff__row--del .diff__text { text-decoration: line-through; text-decoration-color: rgba(209,45,45,.4); }
.diff__skip { padding: 4px 12px; color: var(--muted); background: var(--surface-inset); font-size: 12px; }

/* 実行ログ（構造化ログの行表示。差分表示とは別物なので取り消し線などは流用しない） */
.runlog { border: 1px solid var(--border-card); border-radius: 8px; overflow: hidden; background: var(--surface); font-size: 12.5px; max-height: 60vh; overflow-y: auto; }
.runlog__row { display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 8px; padding: 7px 11px; border-top: 1px solid var(--border-divider); line-height: 1.75; }
.runlog__row:first-child { border-top: 0; }
.runlog__mark { text-align: center; color: var(--placeholder); user-select: none; font-weight: 600; }
.runlog__text { min-width: 0; overflow-wrap: anywhere; }
.runlog__row--phase { background: var(--surface-inset); }
.runlog__row--add .runlog__mark { color: var(--success-tx); }
.runlog__row--err { background: var(--danger-bg); }
.runlog__row--err .runlog__mark { color: var(--danger-tx); }
.runlog__row--warn { background: var(--warning-bg); }
.runlog__row--warn .runlog__mark { color: var(--warning-tx); }
.runlog__empty { padding: 10px 12px; color: var(--muted); }

/* 差分行 → 無視ルール化ボタン（行ホバーで表示） */
.diff__ign { border: 0; background: transparent; color: var(--muted); padding: 0 10px; cursor: pointer; opacity: 0; display: inline-flex; align-items: center; }
.diff__row:hover .diff__ign { opacity: 1; }
.diff__ign:hover { color: var(--brand); }

/* 一覧の絞り込みチップ（ページ単位の履歴表示中など） */
.filter-chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 8px 5px 10px; border: 1px solid var(--info-bd); background: var(--brand-soft); color: var(--brand-dark); border-radius: 999px; font-size: 12.5px; font-weight: 500; max-width: 320px; }
.filter-chip > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.filter-chip a { display: inline-flex; color: var(--brand-dark); border-radius: 50%; padding: 2px; }
.filter-chip a:hover { background: var(--info-bd); }

/* スター（要報告マーク） */
.star-btn.is-on { color: var(--warning-tx); border-color: var(--warning-bd); background: var(--warning-bg); }
.star-btn.is-on svg { fill: currentColor; }
.star-filter.is-selected svg { fill: currentColor; }
.star-toggle { border: 0; background: transparent; cursor: pointer; color: var(--placeholder); padding: 4px; display: inline-flex; border-radius: 6px; }
.trash-toggle { border: 0; background: transparent; cursor: pointer; color: var(--placeholder); padding: 4px; display: inline-flex; border-radius: 6px; }
.trash-toggle:hover { color: var(--danger-tx); background: var(--danger-bg); }
.star-toggle:hover { color: var(--warning-tx); background: var(--warning-bg); }
.star-toggle.is-on { color: var(--warning-tx); }
.star-toggle.is-on svg { fill: currentColor; }

/* リーダー: 追加されたリンク（新着お知らせ等への直リンク） */
.reader__links { margin-top: 16px; padding: 12px 14px; background: var(--brand-soft); border: 1px solid var(--info-bd); border-radius: 8px; }
.reader__links-label { display: flex; gap: 6px; align-items: center; font-size: 12px; font-weight: 600; color: var(--info-tx); margin-bottom: 8px; }
.reader__links-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.reader__links-list a { font-size: 13px; color: var(--link); word-break: break-all; }

/* 検知除外モーダルのルール案 */
.ign-prop { display: flex; gap: 10px; align-items: flex-start; padding: 10px 0; border-bottom: 1px solid var(--line-soft); }
.ign-prop:last-child { border-bottom: 0; }
.ign-prop__use { padding-top: 8px; cursor: pointer; }
.ign-prop__fields { flex: 1; display: grid; gap: 6px; }
.legend { display: flex; gap: 16px; margin-top: 12px; font-size: 12px; color: var(--muted); align-items: center; }
.legend__sw { width: 14px; height: 14px; border-radius: 4px; display: inline-block; margin-right: 4px; vertical-align: -2px; }
.legend__sw--add { background: var(--success-bg); border: 1px solid var(--success-bd); }
.legend__sw--del { background: var(--danger-bg); border: 1px solid var(--danger-bd); }

/* 詳細リスト（マーケ観点など） */
.bullet-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.bullet-list li { line-height: 1.6; }

/* ============================================================
 * ダイジェスト / レポート
 * ============================================================ */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }


.report { background: var(--white); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow-low); }
.report__inner { padding: 40px; max-width: 760px; margin: 0 auto; }
.report__brand { display: flex; align-items: center; justify-content: space-between; border-bottom: 2px solid var(--text); padding-bottom: 16px; margin-bottom: 24px; }
.report__brand-name { font-size: 16px; font-weight: 500; }
.report__title { font-size: 26px; font-weight: 500; line-height: 1.3; }
.report__period { color: var(--muted); margin-top: 4px; }
.report__lead { margin-top: 20px; font-size: 15px; line-height: 1.8; }
.report__section-title { font-size: 18px; font-weight: 500; margin: 28px 0 12px; }
.report__counts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 16px 0; }
.report__count-cell { border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.report__count-num { font-size: 24px; font-weight: 500; font-variant-numeric: tabular-nums; }
.report__count-label { font-size: 13px; color: var(--muted); }
.report__hl { border-top: 1px solid var(--line-soft); padding: 12px 0; }
.report__hl-title { font-weight: 500; }
.report__hl-meta { font-size: 13px; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.report__foot { margin-top: 28px; border-top: 1px solid var(--line); padding-top: 16px; font-size: 12px; color: var(--muted); }

@media print {
  .sidebar, .header, .toast-host, .report__toolbar, .no-print { display: none !important; }
  .app { display: block; }
  .main, .main__inner { padding: 0 !important; min-width: 0; }
  .report { border: 0; box-shadow: none; }
}

/* ============================================================
 * 起動失敗（致命的）
 * ============================================================ */
/* ============================================================
 * ログイン画面（レイヤールール: 背景=L1キャンバス / カード=L2）
 * ============================================================ */
.login-page {
  min-height: 100dvh;
  background: var(--bg-canvas);
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  padding: 40px 32px;
  text-align: center;
  margin-bottom: 8vh; /* 完全中央より少し上げる（視覚的中央） */
}
.login-card__title { font-size: 20px; font-weight: 700; color: #101828; letter-spacing: 0.02em; }
.login-card__desc { font-size: 14px; font-weight: 400; color: #667085; line-height: 1.6; margin-top: 8px; }
.login-card__note { font-size: 12px; color: #98A2B3; margin-top: 16px; }
.login-error {
  background: #FEF3F2;
  border: 1px solid #FDA29B;
  border-radius: 8px;
  padding: 12px 14px;
  margin-top: 24px;
  color: #B42318;
  font-size: 13px;
  line-height: 1.6;
  text-align: left;
}
.login-error:focus { outline: none; }
/* Google 公式ブランドガイドライン準拠のライトテーマボタン(独自配色不可) */
.btn-google {
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  width: 100%; max-width: 320px; height: 40px; padding: 0 12px;
  background: #FFFFFF; border: 1px solid #747775; border-radius: 4px;
  font-family: 'Roboto', system-ui, sans-serif; font-size: 14px; font-weight: 500;
  letter-spacing: 0.25px; color: #1F1F1F; cursor: pointer; text-decoration: none;
}
.btn-google:hover { background: #F8F9FA; color: #1F1F1F; }
.btn-google:active { background: #F1F3F4; }
.btn-google:focus-visible { outline: 2px solid #2563EB; outline-offset: 2px; }
.btn-google.is-loading, .btn-google[aria-disabled="true"] { opacity: .6; cursor: not-allowed; pointer-events: none; }
.btn-google__logo { display: inline-flex; align-items: center; justify-content: center; width: 18px; height: 18px; flex: none; }
.btn-google__logo img { display: block; width: 18px; height: 18px; }
@media (max-width: 419px) {
  .login-card { border: none; box-shadow: none; background: transparent; padding: 24px; }
}

.boot-fatal { display: grid; place-items: center; min-height: 100vh; padding: 40px; text-align: center; }
.boot-fatal__box { max-width: 480px; display: flex; flex-direction: column; align-items: center; gap: 16px; }
.boot-fatal code { background: var(--line-soft); padding: 8px 12px; border-radius: 6px; font-size: 13px; }

/* 補助 */
.muted { color: var(--muted); }
.stack { display: flex; flex-direction: column; gap: 24px; }
.stack--sm { gap: 16px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.toolbar { display: flex; align-items: center; gap: 12px; padding: 16px 24px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }

/* ============================================================
 * v0.2 追加部品（監視対象タブ / 小型入力 / 検索）— 2026-07-01
 * ============================================================ */
.toolbar--tabs { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 0 4px; margin: 0 0 20px; border: none; flex-wrap: wrap; }
.input--sm { height: 32px; padding: 0 10px; font-size: 13px; }
.select--sm select { height: 32px; font-size: 13px; padding: 0 28px 0 10px; }
.card__foot { padding: 12px 24px; border-top: 1px solid var(--border-divider); }
.req { color: var(--danger); font-weight: 500; }
.table code { font-family: 'Roboto Mono', ui-monospace, monospace; font-size: 12.5px; background: var(--surface-inset); padding: 2px 6px; border-radius: 4px; }

/* ==== ビジュアルハイライト(テキストアンカー方式) ==== */
.shot__stage { position: relative; }
.shot__stage img { display: block; }
.vhl { position: absolute; pointer-events: none; border: 2px solid rgba(220, 38, 38, .92); background: rgba(220, 38, 38, .08); border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.6); }
.vhl--del { border-color: rgba(147, 51, 234, .92); background: rgba(147, 51, 234, .08); }
.cmp-slider .vhl { z-index: 2; }
.is-hl-off .vhl { display: none; }

/* ==== 検知一覧の一括操作バー ==== */
.bulkbar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; background: var(--brand-soft, #EAF1FC); border-bottom: 1px solid var(--line, #E4E8EE); }
.bulkbar[hidden] { display: none; }
.bulkbar__count { font-size: 12.5px; font-weight: 600; margin-right: 4px; }
.ev-sel, [data-sel-all] { width: 15px; height: 15px; cursor: pointer; accent-color: #3178E2; }

/* ===== GUI内AIアシスタント ===== */
.ai-fab { position: fixed; right: 24px; bottom: 24px; z-index: 70; width: 52px; height: 52px; border-radius: 50%;
  border: 1px solid var(--border-card); background: var(--brand); color: #fff; cursor: pointer;
  box-shadow: var(--shadow-high); display: flex; align-items: center; justify-content: center; transition: transform .15s; }
.ai-fab:hover { transform: translateY(-2px); }
.ai-fab.is-open { background: var(--surface); color: var(--text-muted); }

.ai { position: fixed; right: 24px; bottom: 88px; z-index: 71; width: 420px; max-width: calc(100vw - 32px);
  height: 620px; max-height: calc(100vh - 130px); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border-card); border-radius: var(--radius-card);
  box-shadow: var(--shadow-high); overflow: hidden; }
.ai[hidden] { display: none; }
.ai__head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--border-divider); }
.ai__title { display: flex; align-items: center; gap: 6px; font-size: 13.5px; font-weight: 600; }
.ai__head-actions { display: flex; gap: 4px; }
.ai__iconbtn { border: 0; background: transparent; color: var(--text-muted); cursor: pointer; padding: 4px;
  border-radius: 6px; display: inline-flex; }
.ai__iconbtn:hover { background: var(--surface-inset); color: var(--text); }

.ai__log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai__row { display: flex; }
.ai__row--user { justify-content: flex-end; }
.ai__bubble { max-width: 88%; font-size: 13px; line-height: 1.8; border-radius: 10px; padding: 9px 12px;
  background: var(--surface-inset); overflow-wrap: anywhere; }
.ai__row--user .ai__bubble { background: var(--brand); color: #fff; }
.ai__bubble p { margin: 0 0 6px; } .ai__bubble p:last-child { margin: 0; }
.ai__bubble ul { margin: 4px 0; padding-left: 18px; } .ai__bubble li { margin-bottom: 2px; }
.ai__bubble code { background: var(--surface); border-radius: 4px; padding: 1px 5px; font-size: .92em; }
.ai__row--user .ai__bubble code { background: rgba(255,255,255,.2); }

.ai__tool { color: var(--text-muted); font-size: 12px; display: inline-flex; align-items: center; gap: 5px; }
.ai__dots { display: inline-flex; gap: 4px; }
.ai__dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--placeholder); animation: ai-blink 1.2s infinite; }
.ai__dots i:nth-child(2) { animation-delay: .2s; } .ai__dots i:nth-child(3) { animation-delay: .4s; }
@keyframes ai-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.ai__chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.ai__chip { border: 1px solid var(--border-card); background: var(--surface); color: var(--text-muted);
  border-radius: 20px; padding: 4px 11px; font-size: 12px; cursor: pointer; }
.ai__chip:hover { color: var(--text); border-color: var(--brand); }

.ai__row--confirm .ai__bubble { max-width: 100%; width: 100%; background: var(--warning-bg);
  border: 1px solid var(--warning-bd); }
.ai__confirm-title { font-weight: 600; display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.ai__confirm-detail { font-size: 12.5px; color: var(--text-muted); white-space: pre-wrap; margin-bottom: 6px; }
.ai__confirm-warn { margin: 0 0 8px; padding-left: 18px; font-size: 12.5px; }
.ai__confirm-sample { font-size: 11.5px; color: var(--text-muted); margin-bottom: 8px; }
.ai__confirm-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center; font-size: 12.5px; }

.ai__form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--border-divider); align-items: flex-end; }
.ai__input { flex: 1; resize: none; border: 1px solid var(--border-card); border-radius: 8px; padding: 8px 10px;
  font: inherit; font-size: 13px; line-height: 1.6; max-height: 140px; background: var(--surface); color: var(--text); }
.ai__input:focus { outline: none; border-color: var(--brand); }
@media (max-width: 520px) { .ai { right: 8px; left: 8px; width: auto; bottom: 78px; } }


/* ===== AIアシスタント（全画面 #/assistant） =====
   左に履歴、右にチャット。チャット部分は常駐パネルと同じ .ai__* を使う */
.asst { display: grid; grid-template-columns: 280px 1fr; gap: 16px; align-items: stretch; }
.asst__side { background: var(--surface-card); border: 1px solid var(--border-card); border-radius: 12px;
  padding: 12px; display: flex; flex-direction: column; min-height: 0; max-height: calc(100vh - 220px); }
.asst__side-head { font-size: 13px; font-weight: 600; padding: 2px 4px 10px; display: flex; gap: 6px; align-items: baseline; }
.asst__list { flex: 1; overflow-y: auto; margin: 0 -4px; }
.asst__note { margin: 10px 4px 0; padding-top: 10px; border-top: 1px solid var(--border-divider); }
.asst__item { display: flex; align-items: center; gap: 4px; padding: 8px 6px; border-radius: 8px; cursor: pointer; }
.asst__item:hover { background: var(--surface-inset); }
.asst__item.is-active { background: var(--brand-soft, #EAF1FC); }
.asst__item-body { flex: 1; min-width: 0; }
.asst__item-title { font-size: 13px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asst__item-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 2px; }
.asst__star, .asst__del { border: 0; background: none; cursor: pointer; padding: 2px; color: var(--text-muted);
  border-radius: 6px; display: flex; opacity: .55; }
.asst__star:hover, .asst__del:hover { opacity: 1; background: var(--surface); }
.asst__star.is-on { color: #E8A33D; opacity: 1; }
.asst__del { visibility: hidden; }
.asst__item:hover .asst__del { visibility: visible; }
.asst__main { background: var(--surface-card); border: 1px solid var(--border-card); border-radius: 12px;
  display: flex; flex-direction: column; min-height: 0; height: calc(100vh - 220px); }
.asst__log { flex: 1; overflow-y: auto; padding: 16px; }
.asst__form { border-top: 1px solid var(--border-divider); padding: 12px; }
@media (max-width: 900px) {
  .asst { grid-template-columns: 1fr; }
  .asst__side { max-height: 240px; }
  .asst__main { height: calc(100vh - 380px); }
}


/* ===== 共有ページのレイアウト設定（#/shares） ===== */
.layout-rows { display: flex; flex-direction: column; gap: 8px; }
.layout-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 1px solid var(--border-card); border-radius: 8px; background: var(--surface-inset); }
.layout-row__ord { display: flex; flex-direction: column; gap: 2px; }
.layout-row__btn { border: 1px solid var(--border-card); background: var(--surface-card); border-radius: 5px;
  cursor: pointer; padding: 1px 4px; display: flex; color: var(--text-muted); line-height: 1; }
.layout-row__btn:disabled { opacity: .3; cursor: default; }
.layout-row__btn:not(:disabled):hover { color: var(--text); border-color: var(--brand); }
/* 上向きは同じ字形を反転して使う（アイコンを増やさない） */
.layout-row__btn[data-dir="-1"] svg { transform: rotate(180deg); }


/* 承認待ちの復帰表示（AIアシスタント画面の上部） */
.asst__pending { border: 1px solid var(--warning-bd, #E9C46A); background: var(--warning-bg, #FFF8E7);
  border-radius: 10px; margin: 12px 12px 0; padding: 10px 12px; }
.asst__pending-hd { display: flex; gap: 6px; align-items: center; font-size: 13px; font-weight: 600; margin-bottom: 8px; }
.asst__pending-row { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
  padding: 8px 0; border-top: 1px solid rgba(0,0,0,.06); }
.asst__pending-row:first-of-type { border-top: 0; }
.asst__pending-body { min-width: 0; flex: 1; font-size: 13px; }


/* ===== 応答中の表示 =====
   ログ内の点滅だけだと、文章が流れ始めた後に「まだ書いている」のか
   「書き終わった」のかが分からない。入力欄の上に状態を出し、完了で消す */
.ai__status { display: flex; align-items: center; gap: 8px; padding: 6px 12px 0;
  font-size: 12px; color: var(--text-muted); }
.ai__status[hidden] { display: none; }
/* 生成中のバブルにキャレットを出す（止まったら消える＝完了が分かる） */
.ai__bubble.is-streaming::after { content: ''; display: inline-block; width: 2px; height: 1em;
  background: var(--brand); margin-left: 2px; vertical-align: text-bottom; animation: ai-blink 1s steps(1) infinite; }
.is-busy .ai__input { background: var(--surface-inset); }

/* 全画面アシスタントの入力欄は複数行を既定にする（依頼文が長くなりやすい） */
.asst__input { min-height: 92px; max-height: 40vh; line-height: 1.7; }
.asst__form { align-items: flex-end; }
