/* expert center (experts.js, ex-*): page, cards, detail dialog, composer chip, `@` menu, reply label. Load order matters: later files override earlier ones. */
:root {
  --ex-approved-bg:#e3f4ec; --ex-approved-fg:#1f6b4c;
  --ex-dept-bg:#e5f3fa; --ex-dept-fg:#155f7c;
  --ex-need-bg:#fff3e0; --ex-need-fg:#8a5413;
  --ex-off-bg:#f6e4e2; --ex-off-fg:#9a3029;
  --ex-soon-bg:#eef0f3; --ex-soon-fg:#69737f;
  --ex-fast:#1f7a5c; --ex-balanced:#2f6390; --ex-primary:#a2531a;
  --ex-scen-bg:#fff; --ex-sico-bg:transparent;
  --ex-card-shadow:0 1px 2px rgba(18, 59, 74, .05);
}
body.dark {
  --ex-approved-bg:#1d3a30; --ex-approved-fg:#8fdcb7;
  --ex-dept-bg:#17394a; --ex-dept-fg:#8fd8ec;
  --ex-need-bg:#3a2f1c; --ex-need-fg:#f1cf8e;
  --ex-off-bg:#432522; --ex-off-fg:#ffb4ab;
  --ex-soon-bg:#2a3139; --ex-soon-fg:#9aa6b3;
  --ex-fast:#8fdcb7; --ex-balanced:#a4c4e1; --ex-primary:#f5b27e;
  --ex-scen-bg:var(--fg-surface);
  /* The small icons are drawn in dark ink: give them a light tile on dark surfaces. */
  --ex-sico-bg:#e9f1f5;
  --ex-card-shadow:none;
}

/* Theme-dependent scenario pictures */
.ex-ico-dark { display:none; }
body.dark .ex-ico-light { display:none; }
body.dark .ex-ico-dark { display:block; }
.ex-ico { width:56px; height:56px; flex:none; }
.ex-ico-none { display:block; border-radius:14px; background:var(--fg-soft); }
.ex-sico { width:20px; height:20px; flex:none; border-radius:5px; background:var(--ex-sico-bg); }

/* Page frame */
.content:has(> .ex-page) { max-width:1120px; margin:0 auto; width:100%; }
.ex-page .page-head { margin-bottom:16px; }
.ex-search { margin:0 0 24px; }
.ex-search input { width:100%; height:46px; padding:0 18px; border:1px solid var(--fg-line); border-radius:999px; background:var(--fg-surface); color:var(--fg-text); font-size:15px; }
.ex-search input:focus { border-color:color-mix(in srgb, var(--fg-accent) 55%, var(--fg-line)); }
.ex-section { margin:0 0 28px; min-width:0; }
.ex-section > h2 { margin:0 0 12px; font-size:18px; }
.ex-group { margin:0 0 20px; }
.ex-group > h3 { margin:0 0 10px; font-size:15px; color:var(--fg-muted); font-weight:600; }
.ex-empty { margin:12px 0; }

/* 「我想要…」 scenario cards */
.ex-scenarios { display:grid; grid-template-columns:repeat(auto-fill, minmax(118px, 1fr)); gap:10px; }
.ex-scenario { display:flex; flex-direction:column; align-items:center; gap:8px; min-width:0; padding:14px 8px 12px; border:1px solid var(--fg-line); border-radius:var(--cf-radius-md); background:var(--ex-scen-bg); color:var(--fg-text); font-size:14px; line-height:1.35; text-align:center; box-shadow:var(--ex-card-shadow); }
.ex-scenario:hover { border-color:color-mix(in srgb, var(--fg-accent) 45%, var(--fg-line)); background:var(--ex-scen-bg); }
.ex-scenario[aria-pressed="true"] { border-color:var(--fg-accent); box-shadow:0 0 0 2px color-mix(in srgb, var(--fg-accent) 35%, transparent); background:color-mix(in srgb, var(--fg-accent) 7%, var(--ex-scen-bg)); }
.ex-scenario span { overflow-wrap:anywhere; }

/* Active filter */
.ex-filterbar { display:flex; flex-wrap:wrap; align-items:center; gap:8px 12px; margin:0 0 16px; }
.ex-filter-chip, .ex-chip { display:inline-flex; align-items:center; gap:6px; max-width:100%; min-height:32px; padding:0 4px 0 8px; border:1px solid var(--fg-line); border-radius:10px; background:var(--fg-bg); color:var(--fg-text); font-size:13px; }
.ex-filter-chip { border-color:color-mix(in srgb, var(--fg-accent) 45%, var(--fg-line)); }
.ex-chip-x { display:inline-grid; place-items:center; width:24px; height:24px; min-height:0; padding:0; border:0; border-radius:6px; background:transparent; color:var(--fg-muted); font-size:13px; line-height:1; }
.ex-chip-x:hover { background:var(--fg-soft); color:var(--fg-text); }

/* Group tabs (reuse .category-chips) */
.ex-tabs { margin:0 0 16px; }

/* Card wall */
.ex-wall { display:grid; grid-template-columns:repeat(auto-fill, minmax(240px, 1fr)); gap:12px; }
.ex-card { display:flex; flex-direction:column; align-items:stretch; gap:8px; min-width:0; min-height:0; margin:0; padding:16px; border:1px solid var(--fg-line); border-radius:var(--cf-radius-md); background:var(--fg-surface); color:var(--fg-text); text-align:left; font-size:14px; line-height:1.5; box-shadow:var(--ex-card-shadow); }
button.ex-card:hover { border-color:color-mix(in srgb, var(--fg-accent) 50%, var(--fg-line)); background:var(--fg-surface); }
button.ex-card:disabled { opacity:1; }
.ex-card.is-disabled { border-style:dashed; opacity:.75; }
.ex-card.is-soon { background:var(--ex-soon-bg); color:var(--ex-soon-fg); box-shadow:none; cursor:default; }
.ex-card-top { display:flex; align-items:center; gap:8px; min-height:22px; }
.ex-card-top .ex-status { margin-left:auto; }
.ex-card-name { font-size:16px; font-weight:650; overflow-wrap:anywhere; }
.ex-card-summary { color:var(--fg-muted); overflow-wrap:anywhere; }
.ex-card.is-soon .ex-card-summary { color:inherit; }
.ex-tags { display:flex; flex-wrap:wrap; gap:4px; }
.ex-tag { padding:1px 8px; border-radius:999px; background:var(--fg-soft); color:var(--fg-muted); font-size:12px; }
.ex-card-foot { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-top:auto; padding-top:4px; font-size:12px; color:var(--fg-muted); }

/* Governance status and tier */
.ex-status { display:inline-block; flex:none; padding:1px 8px; border-radius:999px; font-size:12px; font-weight:600; white-space:nowrap; }
.ex-status-approved { background:var(--ex-approved-bg); color:var(--ex-approved-fg); }
.ex-status-dept_recommended { background:var(--ex-dept-bg); color:var(--ex-dept-fg); }
.ex-status-needs_approval { background:var(--ex-need-bg); color:var(--ex-need-fg); }
.ex-status-disabled { background:var(--ex-off-bg); color:var(--ex-off-fg); }
.ex-status-other, .ex-status-soon { background:var(--ex-soon-bg); color:var(--ex-soon-fg); border:1px solid var(--fg-line); }
.ex-tier { display:inline-flex; align-items:center; gap:4px; font-size:12px; font-weight:600; white-space:nowrap; }
.ex-tier::before { content:""; width:7px; height:7px; border-radius:50%; background:currentColor; }
.ex-tier-fast { color:var(--ex-fast); }
.ex-tier-balanced { color:var(--ex-balanced); }
.ex-tier-primary { color:var(--ex-primary); }
.ex-tier-other { color:var(--fg-muted); }

/* Detail dialog */
dialog.modal.ex-modal { width:min(760px, calc(100% - 24px)); }
.ex-detail section { margin:0 0 18px; }
.ex-detail h3 { margin:0 0 6px; font-size:15px; }
.ex-detail-head { display:flex; flex-wrap:wrap; align-items:center; gap:8px; }
.ex-detail-summary { margin:8px 0 16px; font-size:15px; }
.ex-text { white-space:pre-line; overflow-wrap:anywhere; line-height:1.7; }
.ex-examples { display:flex; flex-direction:column; gap:6px; margin:0; padding:0; list-style:none; }
.ex-example { width:100%; min-height:0; padding:8px 12px; border:1px solid var(--fg-line); border-radius:10px; background:var(--fg-bg); color:var(--fg-text); text-align:left; line-height:1.5; }
.ex-example:hover { border-color:color-mix(in srgb, var(--fg-accent) 50%, var(--fg-line)); background:var(--fg-soft); }
.ex-info { display:grid; grid-template-columns:max-content 1fr; gap:4px 16px; margin:0; }
.ex-info dt { color:var(--fg-muted); }
.ex-info dd { margin:0; overflow-wrap:anywhere; }
.ex-disclaimer { margin:0 0 18px; }
.ex-sources { display:flex; flex-direction:column; gap:6px; margin:0; padding:0; list-style:none; }
.ex-sources li { display:flex; flex-wrap:wrap; align-items:baseline; gap:4px 8px; overflow-wrap:anywhere; }
.ex-sources small { color:var(--fg-muted); }
.ex-src-id { flex:none; padding:0 6px; border-radius:6px; background:var(--fg-soft); color:var(--fg-muted); font-size:12px; font-variant-numeric:tabular-nums; }
.ex-actions { position:sticky; bottom:-24px; display:flex; justify-content:flex-end; margin:0 -24px -24px; padding:12px 24px; border-top:1px solid var(--fg-line); background:var(--fg-surface); }

/* Composer: current expert chip and `@` menu */
.ex-chip-row { display:flex; margin:0 0 6px; }
.ex-chip-row[hidden] { display:none; }
.ex-chip { border-color:color-mix(in srgb, var(--fg-accent) 45%, var(--fg-line)); background:color-mix(in srgb, var(--fg-accent) 8%, var(--fg-surface)); }
.ex-chip strong { font-weight:650; }
.cumi-home .composer { position:relative; }
.ex-mention { left:8px; right:8px; bottom:calc(100% + 8px); max-height:min(360px, 50vh); overflow:auto; padding:6px; }
.ex-mention[hidden] { display:none; }
/* Empty conversation: the composer sits mid-page under the title, so the menu opens downwards (like the ＋ menu). */
.cumi-home:not(.is-chat) .ex-mention { bottom:auto; top:calc(100% + 8px); }
.ex-mention-head { display:flex; flex-wrap:wrap; justify-content:space-between; gap:4px 12px; margin:2px 6px 6px; font-size:13px; font-weight:600; }
.ex-mention-head small { color:var(--fg-muted); font-weight:400; }
.ex-mention-empty { margin:8px; color:var(--fg-muted); }
.ex-opt, .ex-mini { display:flex; align-items:center; gap:10px; width:100%; min-height:0; margin:0; padding:8px 10px; border:0; border-radius:10px; background:transparent; color:var(--fg-text); text-align:left; line-height:1.4; }
.ex-opt span, .ex-mini span { display:flex; flex-direction:column; min-width:0; }
.ex-opt small, .ex-mini small { color:var(--fg-muted); font-size:12px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.ex-opt:hover, .ex-opt.is-active { background:var(--fg-soft); }

/* Reply label 「名稱 回覆」 */
.msg-expert { display:inline-block; margin-left:6px; padding:0 8px; border-radius:999px; background:color-mix(in srgb, var(--fg-accent) 12%, transparent); color:var(--fg-text); font-size:12px; font-weight:600; }

/* Home: recommended experts on an empty conversation */
.ex-home { margin:22px 0 0; min-width:0; }
.cumi-home.is-chat .ex-home { display:none; }
.ex-home-head { display:flex; align-items:center; justify-content:space-between; gap:12px; margin:0 0 8px; font-size:13px; color:var(--fg-muted); }
.ex-home-list { display:grid; grid-template-columns:repeat(2, minmax(0, 1fr)); gap:8px; }
.ex-mini { border:1px solid var(--fg-line); background:var(--fg-surface); }
.ex-mini:hover { border-color:color-mix(in srgb, var(--fg-accent) 45%, var(--fg-line)); background:var(--fg-surface); }

@media (max-width:700px) {
  .ex-scenarios { grid-template-columns:repeat(auto-fill, minmax(96px, 1fr)); gap:8px; }
  .ex-scenario { padding:10px 6px; font-size:13px; }
  .ex-ico { width:44px; height:44px; }
  .ex-wall { grid-template-columns:1fr; }
  .ex-home-list { grid-template-columns:1fr; }
  .ex-info { grid-template-columns:1fr; gap:0; }
  .ex-info dd { margin-bottom:6px; }
  .ex-mention { left:0; right:0; }
}
