/* 落ち着いた灰色を基本にし、色はシートの種類を示す小さな点だけに使う */
:root {
  --data-soft: #f4f4f5;
  --bg: #fafafa;
  --surface: #ffffff;
  --subtle: #f4f4f5;
  --border: #e4e4e7;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --text-2: #3f3f46;
  --muted: #71717a;
  --faint: #a1a1aa;
  --primary: #18181b;
  --primary-hover: #27272a;
  --ring: rgba(24, 24, 27, 0.12);
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  --warning-text: #92400e;
  --ok: #16a34a;
  --dot-共通: #a1a1aa;
  --dot-大分類: #8b5cf6;
  --dot-グループ: #0ea5e9;
  --dot-商品: #10b981;
  --dot-未使用: #f59e0b;
  /* 結果の色（ログの一覧の点・集計の結果の内訳のドーナツ） */
  --r-answered: #16a34a;
  --r-clarify: #0ea5e9;
  --r-noanswer: #f59e0b;
  --r-escalation: #dc2626;
  --r-smalltalk: #a1a1aa;
  --r-irrelevant: #71717a;
  --radius: 8px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 24px 48px -12px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.65 Inter, "Noto Sans JP", -apple-system, BlinkMacSystemFont, "Hiragino Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
  letter-spacing: 0.01em;
}
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------------------------------------------------------------- 上のバー */
.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 24px;
  height: 56px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: saturate(180%) blur(8px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; }
/* ロゴはホーム画面用アイコンと同じ絵（空色に白い吹き出しと3つの点） */
.logo { width: 22px; height: 22px; border-radius: 6px; background: url("icon-192.png") center / cover no-repeat; flex-shrink: 0; }
.brand-title { font-weight: 600; font-size: 15px; }
.brand-client {
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 1px 8px;
}
.brand-client:empty { display: none; }
.tabs { display: flex; gap: 2px; height: 100%; }
.tab {
  position: relative;
  border: 0;
  background: none;
  padding: 0 12px;
  cursor: pointer;
  color: var(--muted);
  font-weight: 500;
  white-space: nowrap;
}
.tab:hover { color: var(--text); }
.tab.is-active { color: var(--text); }
.tab.is-active::after { content: ""; position: absolute; left: 12px; right: 12px; bottom: -1px; height: 2px; background: var(--text); border-radius: 2px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.mode { display: flex; align-items: center; gap: 10px; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--warning-text); }
.status.is-web::before { background: var(--ok); }
.user { font-size: 12px; color: var(--muted); }

.notice {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 24px 0;
  padding: 10px 14px;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius);
  background: var(--warning-bg);
  color: var(--warning-text);
  font-size: 13px;
}
.notice.error { border-color: #fecaca; background: var(--danger-soft); color: var(--danger); }

/* ---------------------------------------------------------------- 配置 */
.layout { display: grid; grid-template-columns: 272px minmax(0, 1fr); gap: 24px; padding: 20px 24px 48px; align-items: start; }
.single { padding: 24px 24px 48px; max-width: 1200px; }

/* 左の一覧は画面の上（上のバー 56px＋余白 20px）に貼りつけて、右の一覧をスクロールしても動かないようにする。
   高さは、下の余白（.layout の下 48px）の分まで引いておく。以前は 96px しか引いておらず、
   右の一覧を一番下までスクロールすると、ページの終わりに押されて左の一覧が 28px 上にずれていた（2026-10-02） */
.sidebar { position: sticky; top: 76px; max-height: calc(100vh - 124px); overflow: auto; padding-right: 4px; }
.sidebar-section { padding: 2px 2px 12px; border-bottom: 1px solid var(--border); margin-bottom: 8px; }
.sheet-group-title { font-size: 11px; font-weight: 600; color: var(--faint); margin: 14px 10px 4px; text-transform: uppercase; letter-spacing: 0.06em; }
.sheet-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: 0;
  border-radius: 6px;
  background: none;
  cursor: pointer;
  text-align: left;
  color: var(--text-2);
}
.sheet-item:hover { background: var(--subtle); color: var(--text); }
.sheet-item.is-active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.sheet-item .order { color: var(--faint); font-size: 12px; width: 14px; text-align: right; }
.sheet-item .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-item .count { font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; }
.sheet-item.is-special { color: var(--text); font-weight: 500; }

.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--dot, var(--faint)); flex-shrink: 0; }
.k-共通 { --dot: var(--dot-共通); }
.k-大分類 { --dot: var(--dot-大分類); }
.k-グループ { --dot: var(--dot-グループ); }
.k-商品 { --dot: var(--dot-商品); }
.k-未使用 { --dot: var(--dot-未使用); }
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 8px;
  background: var(--surface);
  white-space: nowrap;
}
.tag::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--dot, var(--faint)); }

/* ---------------------------------------------------------------- 見出し・操作 */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 24px; margin-bottom: 16px; }
.page-title { margin: 0; font-size: 20px; font-weight: 600; letter-spacing: -0.01em; display: flex; align-items: center; gap: 10px; }
.page-desc { margin: 4px 0 0; color: var(--muted); font-size: 13px; }

.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
/* ナレッジ一覧の見出し・検索を、上のバー（高さ56px）のすぐ下に残す */
.sticky-head { position: sticky; top: 56px; z-index: 4; background: var(--bg); margin-top: -20px; padding-top: 20px; }
.sticky-head .toolbar { margin-bottom: 0; padding-bottom: 12px; }
.search { position: relative; flex: 1 1 260px; max-width: 360px; }
.search svg { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--faint); }
.search input { width: 100%; height: 34px; padding: 0 10px 0 32px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.segmented { display: inline-flex; padding: 2px; background: var(--subtle); border-radius: var(--radius); }
.segmented button { border: 0; background: none; padding: 4px 10px; border-radius: 6px; cursor: pointer; color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.segmented button.is-on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.result-count { margin-left: auto; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

.label { display: flex; align-items: baseline; gap: 8px; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 16px 0 6px; }
.label:first-child { margin-top: 0; }
.label-note { font-weight: 400; color: var(--faint); }
.hint { color: var(--muted); font-size: 12px; margin: 8px 2px 0; }
.input, .select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  background: var(--surface);
  transition: border-color 0.12s, box-shadow 0.12s;
}
.select { height: 34px; padding: 0 30px 0 10px; appearance: none; background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%2371717a' stroke-width='1.6'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E") no-repeat right 8px center / 14px; }
.select-inline { width: auto; min-width: 150px; }
.textarea { resize: vertical; line-height: 1.7; }
.input:focus, .select:focus, .search input:focus { outline: 0; border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); }
.input:disabled, .select:disabled { background: var(--subtle); color: var(--text-2); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}
.btn:hover { background: var(--subtle); }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-danger-ghost { border-color: transparent; color: var(--danger); background: none; }
.btn-danger-ghost:hover { background: var(--danger-soft); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.link-btn { border: 0; background: none; padding: 0; color: #2563eb; font-size: 13px; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn { border: 0; background: none; width: 30px; height: 30px; border-radius: 6px; display: grid; place-items: center; color: var(--muted); cursor: pointer; }
.icon-btn:hover { background: var(--subtle); color: var(--text); }

/* ---------------------------------------------------------------- ナレッジの一覧 */
.list { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; }
.row {
  display: block;
  width: 100%;
  padding: 14px 16px;
  border: 0;
  border-bottom: 1px solid var(--border);
  background: none;
  text-align: left;
  cursor: pointer;
}
.row:last-child { border-bottom: 0; }
/* お気に入り：行の左端の星。付けたものは一覧の一番上に出る */
.row-wrap { position: relative; border-bottom: 1px solid var(--border); }
.row-wrap:last-child { border-bottom: 0; }
.row-wrap .row { border-bottom: 0; padding-left: 44px; }
.pin-btn { position: absolute; left: 10px; top: 12px; z-index: 1; width: 26px; height: 26px; border: 0; border-radius: 6px; background: none; display: grid; place-items: center; color: var(--border-strong); cursor: pointer; }
.pin-btn:hover { background: var(--subtle); color: var(--muted); }
.pin-btn:focus-visible { outline: 2px solid var(--ring); }
.row-wrap.is-pinned .pin-btn { color: #f59e0b; }
.row-wrap.is-pinned .pin-btn svg { fill: currentColor; }
.row-wrap.is-pinned .row { background: #fffdf5; }
.row:hover { background: #fcfcfd; }
.row:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.row-head { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; }
.row-title { flex: 1; min-width: 0; font-weight: 600; color: var(--text); }
.row-meta { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 12px; }
.row-body {
  color: var(--muted);
  font-size: 13px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.row.is-overridden { background: var(--bg); }
.row.is-overridden .row-title, .row.is-overridden .row-body { color: var(--faint); }
.row-note { font-size: 12px; color: var(--warning-text); margin-top: 6px; }
.badge { font-size: 11px; font-weight: 500; color: var(--warning-text); background: var(--warning-bg); border: 1px solid var(--warning-border); border-radius: 999px; padding: 0 7px; }
mark { background: #fef08a; color: inherit; border-radius: 2px; padding: 0 1px; }

.empty { padding: 48px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.empty strong { display: block; color: var(--text); font-weight: 600; margin-bottom: 4px; font-size: 14px; }

/* ---------------------------------------------------------------- 商品の表 */
.table-wrap { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { position: sticky; top: 0; background: var(--bg); font-size: 12px; font-weight: 500; color: var(--muted); text-align: left; padding: 9px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tbody tr { cursor: pointer; }
.table tbody tr:hover td { background: #fcfcfd; }
.table tr:last-child td { border-bottom: 0; }
.table .alias { white-space: pre-line; color: var(--muted); font-size: 13px; }
.table .num { font-variant-numeric: tabular-nums; color: var(--text-2); }
.table .product-name { font-weight: 600; }
.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.none { color: var(--faint); }

/* ---------------------------------------------------------------- ポップアップ */
.dialog {
  border: 0;
  padding: 0;
  border-radius: var(--radius-lg);
  width: min(560px, calc(100vw - 32px));
  max-height: calc(100vh - 48px);
  box-shadow: var(--shadow-lg);
  color: var(--text);
}
.dialog-wide { width: min(760px, calc(100vw - 32px)); }
.dialog[open] { animation: pop 0.14s ease-out; }
.dialog::backdrop { background: rgba(9, 9, 11, 0.45); backdrop-filter: blur(2px); }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.99); } to { opacity: 1; transform: none; } }
.dialog form { display: flex; flex-direction: column; max-height: calc(100vh - 48px); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; padding: 20px 24px 12px; }
.dialog-title { margin: 0; font-size: 17px; font-weight: 600; }
.dialog-desc { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.dialog-body { padding: 4px 24px 8px; overflow: auto; }
.dialog-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 24px; border-top: 1px solid var(--border); background: var(--bg); }
.dialog-foot-right { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.dialog-save, .dialog-more { display: none; }
.form-error { color: var(--danger); font-size: 13px; margin: 12px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0 12px;
  background: var(--surface);
  cursor: pointer;
  font-size: 13px;
  color: var(--text-2);
}
.chip:hover { border-color: var(--border-strong); }
.chip.is-on { background: var(--primary); border-color: var(--primary); color: #fff; }
.chip.is-on { cursor: default; padding-right: 4px; }
.chip-remove {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: inherit;
  opacity: 0.7;
  cursor: pointer;
}
.chip-remove:hover { opacity: 1; background: rgba(255, 255, 255, 0.18); }
.chip-remove svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.chips:not(:empty) + .combo { margin-top: 10px; }
.combo-menu {
  position: fixed;
  z-index: 10;
  max-height: 208px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 12px 28px -8px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.02);
  padding: 4px;
}
.combo-option {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  border: 0;
  border-radius: 6px;
  background: none;
  padding: 7px 10px;
  text-align: left;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
}
.combo-option.is-active { background: var(--subtle); }
.combo-option .combo-count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.combo-option.is-new { color: var(--text-2); }
.combo-option.is-new svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }
.combo-empty { padding: 8px 10px; color: var(--muted); font-size: 12px; }

/* 真ん中に寄せるのは左右の余白で行う（transform で寄せると、出てくるときの動き pop が transform を上書きして、
   一瞬右にずれて出てから真ん中へ飛ぶため） */
.toast {
  position: fixed;
  left: 0;
  right: 0;
  margin: 0 auto;
  width: fit-content;
  bottom: 24px;
  background: var(--primary);
  color: #fff;
  padding: 10px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  z-index: 20;
  animation: pop 0.14s ease-out;
}

/* ---------------------------------------------------------------- ログイン */
body.is-login .tabs, body.is-login .topbar-right { display: none; }
.login { min-height: calc(100vh - 56px); display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 32px 28px; box-shadow: var(--shadow-sm); }
.logo-lg { display: block; width: 44px; height: 44px; border-radius: 12px; margin-bottom: 16px; }
.login-title { margin: 0; font-size: 18px; font-weight: 600; }
.login-desc { margin: 6px 0 20px; color: var(--muted); font-size: 13px; }
.btn-block { width: 100%; margin-top: 16px; height: 38px; }

@media (max-width: 900px) {
  .topbar { height: auto; flex-wrap: wrap; gap: 8px 16px; padding: 10px 16px 0; }
  .topbar-right { margin-left: 0; width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
  .tabs { order: 3; width: 100%; height: 40px; overflow-x: auto; }
  .tab.is-active::after { bottom: 0; }
  .user { display: none; }
  .layout { grid-template-columns: 1fr; padding: 16px; }
  .sidebar { position: static; max-height: none; }
  .sticky-head { position: static; margin-top: 0; padding-top: 0; }
  .single { padding: 16px; }
  .notice { margin: 12px 16px 0; }
  .page-head { flex-direction: column; }
}

/* ---------------------------------------------------------------- ログ */
.single-wide { max-width: 1320px; }
.page-actions { display: flex; align-items: center; gap: 10px; flex-shrink: 0; flex-wrap: wrap; }
.retention-note { display: inline-block; margin-left: 8px; font-size: 11px; color: var(--faint); white-space: nowrap; }
.fetched-at { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.filter-bar { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px; margin-bottom: 16px; display: flex; flex-direction: column; gap: 10px; }
.filter-bar .toolbar { margin: 0; }
.log-filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.segmented-lg button { padding: 6px 16px; font-size: 14px; }
.segmented button { min-height: 30px; }
.chart-hint { margin: 0 0 10px; font-size: 12px; color: var(--muted); }
.date-range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.input-date { width: auto; height: 34px; padding: 0 8px; font-size: 13px; }
.active-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: -4px 0 12px; font-size: 12px; color: var(--muted); }
.filter-pill { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--border-strong); background: var(--surface); border-radius: 999px; padding: 2px 4px 2px 10px; color: var(--text); font-size: 12px; }
.filter-pill button { border: 0; background: none; cursor: pointer; color: var(--muted); width: 18px; height: 18px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; }
.filter-pill button:hover { background: var(--subtle); color: var(--text); }
.filter-pill svg { width: 10px; height: 10px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; }


.log-table td { font-size: 13px; }
.log-table .log-time { white-space: nowrap; color: var(--text-2); font-variant-numeric: tabular-nums; }
.log-table .log-q { min-width: 260px; }
.log-table .log-q-text { color: var(--text); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; white-space: pre-line; }
.log-table .log-a-text { margin-top: 4px; color: var(--muted); font-size: 12px; display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; }
.log-table .log-used { min-width: 240px; }
.log-table .log-used .tag { margin-bottom: 4px; }
.log-table .log-title { color: var(--text-2); }
.log-table tr.is-new td { animation: flash 2.4s ease-out; }
@keyframes flash { from { background: #f0fdf4; } to { background: transparent; } }
.log-table .log-user { white-space: nowrap; }
/* ログを選んで消す */
.log-table .log-check { width: 40px; padding-right: 0; }
.log-table .log-check label { display: flex; align-items: center; justify-content: center; margin: -9px -8px; padding: 9px 8px; cursor: pointer; }
.log-table .log-check input { width: 15px; height: 15px; margin: 0; cursor: pointer; accent-color: var(--primary); }
.log-table tr.is-selected td { background: #eff6ff; }
.selection-bar {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 15;
  display: flex; align-items: center; gap: 10px; white-space: nowrap; max-width: calc(100vw - 32px); overflow-x: auto;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 8px 10px 8px 16px;
  box-shadow: var(--shadow-lg);
}
.selection-count { font-size: 13px; font-weight: 600; color: var(--text); }
/* 帯が出ているあいだは、お知らせ（トースト）を帯の上に出す */
body:has(.selection-bar) .toast { bottom: 84px; }
/* 一番下の行が帯に隠れないよう、下に余白をとる */
body:has(.selection-bar) #viewLogs { padding-bottom: 96px; }
/* 列見出しを、上のバー（高さ56px）のすぐ下に残す。横スクロールの枠があると固定できないので、表が収まる幅の画面だけ枠を外す */
@media (min-width: 1100px) {
  .log-wrap { overflow: clip; }
  .log-table th { top: 56px; z-index: 3; }
}
.user-chip { display: inline-flex; align-items: center; gap: 5px; font: inherit; font-size: 12px; color: var(--text-2); background: none; border: 1px solid transparent; border-radius: 6px; padding: 1px 6px 1px 4px; margin-left: -5px; }
button.user-chip { cursor: pointer; }
button.user-chip:hover, button.user-chip:focus-visible { background: var(--subtle); border-color: var(--border); outline: 0; }
.user-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--u); flex: none; }
.user-code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-weight: 600; letter-spacing: 0.04em; color: var(--text); }
.user-count { font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.user-id { margin-top: 2px; font-size: 11px; color: var(--faint); word-break: break-all; }
.channel { display: inline-flex; align-items: center; font-size: 11px; font-weight: 600; border-radius: 4px; padding: 1px 6px; background: var(--subtle); color: var(--text-2); }
.channel-line { background: #ecfdf3; color: #067647; }
.result { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; white-space: nowrap; color: var(--text-2); }
.result::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--r, var(--faint)); }
.r-answered { --r: var(--r-answered); }
.r-clarify { --r: var(--r-clarify); }
.r-noanswer { --r: var(--r-noanswer); }
.r-escalation { --r: var(--r-escalation); }
.r-smalltalk { --r: var(--r-smalltalk); }
.r-irrelevant { --r: var(--r-irrelevant); }
.load-more { display: flex; justify-content: center; padding: 16px; }

.stat-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 14px 16px; }
.stat-label { font-size: 12px; color: var(--muted); }
.stat-value { font-size: 24px; font-weight: 600; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.stat-value small { font-size: 13px; font-weight: 500; color: var(--muted); margin-left: 4px; }
.chart-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.chart-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px; min-width: 0; }
.chart-card.span-2 { grid-column: 1 / -1; }
.chart-title { margin: 0 0 2px; font-size: 14px; font-weight: 600; }
.chart-note { margin: 0 0 12px; font-size: 12px; color: var(--muted); }
.chart-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.chart-head .chart-title { margin: 0; }
.chart-head .chart-note { margin: 0; }
.bars { display: flex; flex-direction: column; gap: 2px; }
.bar-row { display: grid; grid-template-columns: minmax(0, 40%) 1fr 44px; align-items: center; gap: 10px; border: 0; background: none; padding: 5px 6px; border-radius: 6px; text-align: left; font-size: 13px; color: var(--text); cursor: pointer; width: 100%; }
.bar-row:hover { background: var(--subtle); }
.bar-row.is-static { cursor: default; }
.bar-row.is-static:hover { background: none; }
.bar-label { display: flex; align-items: center; gap: 6px; min-width: 0; }
.bar-label span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-label .bar-sub { color: var(--muted); font-size: 11px; flex-shrink: 0; }
/* 名前を「…」で切らずに、折り返して全部出す（よく使われたシート） */
.bars.is-wrap .bar-label { align-items: flex-start; }
.bars.is-wrap .bar-label span:not(.dot) { white-space: normal; overflow: visible; text-overflow: clip; overflow-wrap: anywhere; line-height: 1.5; }
.bars.is-wrap .bar-label .dot { margin-top: 6px; }
.bar-track { display: block; height: 10px; background: var(--subtle); border-radius: 999px; overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 999px; background: var(--bar, var(--primary)); min-width: 2px; }
.bar-num { text-align: right; font-variant-numeric: tabular-nums; color: var(--text-2); font-size: 12px; }
.day-chart { width: 100%; height: auto; display: block; stroke: none; }
.day-chart .day-bar { fill: #3b82f6; }
.day-chart .day-bar:hover { fill: #1d4ed8; }
.day-chart text { font-size: 11px; fill: var(--muted); stroke: none; font-family: inherit; font-weight: 400; }
.day-chart .grid { stroke: var(--border); stroke-width: 1; }
.chart-empty { color: var(--muted); font-size: 13px; padding: 16px 0; }

.detail-grid { display: grid; grid-template-columns: 110px 1fr; gap: 10px 16px; font-size: 13px; margin-bottom: 16px; }
.detail-grid dt { color: var(--muted); }
.detail-grid dd { margin: 0; color: var(--text); word-break: break-all; }
.bubble { border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 12px 14px; white-space: pre-wrap; font-size: 14px; line-height: 1.75; margin-bottom: 12px; word-break: break-word; }
.bubble-q { background: var(--subtle); }
.bubble-label { font-size: 12px; font-weight: 600; color: var(--text-2); margin: 0 0 6px; }
.ref-list { margin: 0; padding-left: 18px; font-size: 13px; color: var(--text-2); line-height: 1.8; }

@media (max-width: 860px) {
  .chart-grid { grid-template-columns: 1fr; }
  .page-head { flex-direction: column; gap: 12px; }
  .detail-grid { grid-template-columns: 90px 1fr; }
}

/* ================================================================ スマホ
   パソコンの画面はそのまま。幅900px以下（スマホ・タブレット）だけ、次のように変える。
   ・上のタブ → 画面の下のバー（親指で押しやすい位置）
   ・ナレッジのシート一覧 → 「表示中のシート」ボタンで下から出すパネル
   ・商品とログの表 → 1件ずつのカード
   ・ポップアップ → 画面いっぱい（下のボタンは常に見える）
   ・入力欄の文字は16px（iPhoneで入力するときに画面が勝手に拡大されないように）
*/
.tab svg, .tab-short, .sheet-switch, .drawer-head, .drawer-backdrop, .filter-toggle, .select-page-mobile { display: none; }

@media (max-width: 900px) {
  :root { --nav-h: 60px; --safe-b: env(safe-area-inset-bottom, 0px); }
  body { padding-bottom: calc(var(--nav-h) + var(--safe-b)); }
  body.is-login { padding-bottom: 0; }

  /* 上のバー：ロゴとログアウトだけ。
     背景のぼかし（backdrop-filter）があると、中の下のバー（position: fixed）が上のバーに閉じ込められるので外す */
  .topbar { backdrop-filter: none; background: var(--surface); }
  .topbar { height: 52px; flex-wrap: nowrap; gap: 10px; padding: 0 16px; padding-top: env(safe-area-inset-top, 0px); height: calc(52px + env(safe-area-inset-top, 0px)); }
  .brand { min-width: 0; }
  .brand-title { font-size: 15px; white-space: nowrap; }
  .brand-client { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 40vw; }
  .topbar-right { margin-left: auto; width: auto; flex-wrap: nowrap; gap: 8px; }
  .mode .status { font-size: 12px; }

  /* 下のタブのバー */
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    order: 0; width: auto; height: calc(var(--nav-h) + var(--safe-b)); padding-bottom: var(--safe-b);
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; overflow: visible;
    background: rgba(255, 255, 255, 0.96); backdrop-filter: saturate(180%) blur(10px);
    border-top: 1px solid var(--border);
  }
  .tab { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; padding: 0 4px; font-size: 11px; color: var(--faint); }
  .tab svg { display: block; width: 22px; height: 22px; stroke-width: 1.5; }
  .tab-long { display: none; }
  .tab-short { display: inline; }
  .tab.is-active { color: var(--text); }
  .tab.is-active::after { left: 30%; right: 30%; top: 0; bottom: auto; height: 2px; }
  .tab.is-active svg { stroke-width: 1.9; }

  /* 押しやすい大きさ */
  .btn { height: 40px; padding: 0 14px; }
  .btn-sm { height: 34px; }
  .icon-btn { width: 40px; height: 40px; }
  .input, .select, .search input, .textarea { font-size: 16px; }
  .select, .search input { height: 42px; }
  .select-inline { min-width: 0; flex: 1 1 140px; }
  .search { flex: 1 1 100%; max-width: none; }
  .segmented { max-width: 100%; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .segmented::-webkit-scrollbar { display: none; }
  .segmented button { flex-shrink: 0; min-height: 36px; padding: 6px 12px; }
  .toast { bottom: calc(var(--nav-h) + var(--safe-b) + 12px); max-width: calc(100vw - 32px); white-space: normal; text-align: center; }

  .layout, .single { padding: 12px 16px 24px; }
  .page-head { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 10px 12px; margin-bottom: 12px; }
  .page-head > div:first-child { flex: 1 1 200px; min-width: 0; }
  .page-title { font-size: 18px; }
  .page-desc { font-size: 12px; }
  .notice { margin: 10px 16px 0; }

  /* ---- ナレッジ：シートの一覧は、画面の名前（シート名）の下に重ねて出す一覧（ほかの選択の一覧と同じ形）。外を押すと閉じる */
  .layout { display: block; }
  .drawer-backdrop { display: block; position: fixed; inset: 0; z-index: 40; background: transparent; }
  .drawer-backdrop[hidden] { display: none; }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  .sidebar {
    position: fixed; left: 12px; right: 12px; top: var(--dd-top, 64px); bottom: auto; z-index: 41;
    max-height: var(--dd-max, 70vh); overflow: auto; overscroll-behavior: contain; padding: 4px;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
    opacity: 0; transform: translateY(-4px); visibility: hidden; transition: opacity 0.14s ease-out, transform 0.14s ease-out, visibility 0.14s;
  }
  body.drawer-open .sidebar { opacity: 1; transform: none; visibility: visible; }
  body.drawer-open { overflow: hidden; }
  .drawer-head { display: none !important; }
  .sidebar .sidebar-section { padding: 6px 4px 8px; margin-bottom: 4px; }
  .sidebar .sheet-group-title { margin: 10px 12px 2px; }
  /* 一覧の行（ほかの選択の一覧と同じ高さ・選んでいるものに ✓） */
  .sheet-item { min-height: 44px; padding: 0 12px; border-radius: 8px; font-size: 15px; color: var(--text); }
  .sheet-item.is-active { background: none; box-shadow: none; font-weight: 600; }
  .sheet-item::after { content: ""; width: 16px; height: 16px; flex-shrink: 0; visibility: hidden; background: var(--primary);
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E") center / contain no-repeat;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='black' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m3.5 8.5 3 3 6-7'/%3E%3C/svg%3E") center / contain no-repeat; }
  .sheet-item.is-active::after { visibility: visible; }
  .sheet-item:active { background: var(--subtle); }
  /* 「商品で絞り込む」の選ぶ欄（押すと一覧が出る形） */
  .scope-select .dd-trigger { height: 40px; padding-left: 34px; font-weight: 500; }
  .scope-select.is-set .dd-trigger { border-color: var(--text); background: var(--primary); color: #fff; }
  .scope-select.is-set .dd-trigger svg { color: #fff; }
  /* 商品の一覧を広げても、アイコンは選ぶ欄の高さ（40px）の真ん中のまま */
  .sidebar .scope-select > svg { z-index: 1; top: 20px; }
  /* シートの一覧の中では、商品の一覧はその場で下に広げる（小さな一覧の中に重ねると切れるため） */
  .sidebar .dd-list { position: static; max-height: none !important; margin-top: 6px; box-shadow: none; animation: none; }

  .sticky-head .toolbar { padding-bottom: 10px; }
  .row { padding: 14px 14px; }
  .row-wrap .row { padding-left: 50px; }
  .pin-btn { left: 8px; top: 8px; width: 38px; height: 38px; }
  .row-head { flex-wrap: wrap; gap: 4px 8px; margin-bottom: 6px; }
  .row-title { flex: 1 1 100%; font-size: 15px; }
  .row-body { font-size: 13px; }

  /* ---- 商品の表 → カード */
  #productTable, #productTable tbody, #productTable tr, #productTable td { display: block; }
  #productTable thead { display: none; }
  #productTable tr { padding: 14px 16px; border-bottom: 1px solid var(--border); }
  #productTable tr:last-child { border-bottom: 0; }
  #productTable td { padding: 0; border: 0; }
  #productTable tbody tr:hover td { background: none; }
  #productTable .product-name { font-size: 16px; margin-bottom: 6px; }
  #productTable td[data-label] { display: flex; gap: 10px; align-items: baseline; font-size: 13px; margin-top: 4px; }
  #productTable td[data-label]::before { content: attr(data-label); flex: 0 0 76px; font-size: 11px; color: var(--faint); }
  #productTable .alias { white-space: normal; }
  #productTable .alias br { display: none; }
  .table-wrap { overflow: visible; }

  /* ---- ログの表 → カード */
  .log-wrap { overflow: visible; }
  .log-table, .log-table tbody { display: block; }
  .log-table thead { display: none; }
  .log-table tr {
    display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; column-gap: 8px; row-gap: 6px;
    grid-template-areas: "check time result" "check q q" "check used used" "check meta user";
    padding: 12px 14px 12px 8px; border-bottom: 1px solid var(--border);
  }
  .log-table tr:last-child { border-bottom: 0; }
  .log-table td { display: block; padding: 0; border: 0; min-width: 0; }
  .log-table .log-check { grid-area: check; width: auto; }
  .log-table .log-check label { margin: -6px 0 0; padding: 6px; }
  .log-table .log-check input { width: 20px; height: 20px; }
  .log-table .log-time { grid-area: time; font-size: 12px; color: var(--muted); align-self: center; }
  .log-table .log-result { grid-area: result; align-self: center; }
  .log-table .log-q { grid-area: q; min-width: 0; }
  .log-table .log-q-text { font-size: 14px; }
  .log-table .log-used { grid-area: used; min-width: 0; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; font-size: 12px; }
  .log-table .log-used .tag { margin-bottom: 0; }
  .log-table .log-used .none { display: none; }
  .log-table .log-channel { grid-area: meta; align-self: center; }
  .log-table .log-user { grid-area: user; justify-self: end; align-self: center; }
  .log-table tr.is-selected td { background: none; }
  .log-table tr.is-selected { background: #eff6ff; }
  .log-table tbody tr:hover td { background: none; }
  .select-page-mobile { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); cursor: pointer; padding: 4px 0; }
  .select-page-mobile input { width: 18px; height: 18px; margin: 0; accent-color: var(--primary); }
  .selection-bar {
    left: 12px; right: 12px; transform: none; max-width: none;
    bottom: calc(var(--nav-h) + var(--safe-b) + 10px); flex-wrap: wrap; white-space: normal; row-gap: 6px; padding: 10px 12px;
  }
  body:has(.selection-bar) .toast { bottom: calc(var(--nav-h) + var(--safe-b) + 92px); }
  body:has(.selection-bar) #viewLogs { padding-bottom: 120px; }

  .log-filters { gap: 8px; }
  .date-range { width: 100%; }
  .date-range .input-date { flex: 1; min-width: 0; height: 42px; font-size: 15px; }
  #logMonth { flex: 1 1 100%; }

  /* ---- 集計 */
  .stat-cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat-card { padding: 12px; }
  .stat-value { font-size: 20px; }
  .chart-card { padding: 14px 12px; }
  .chart-head { flex-wrap: wrap; gap: 2px 8px; }
  .bar-row { grid-template-columns: minmax(0, 46%) 1fr 36px; gap: 8px; padding: 7px 4px; }

  /* ---- ポップアップ・パネルを開いているあいだは、後ろの画面を固定する（スワイプで後ろが動かないように） */
  body.scroll-locked { position: fixed; left: 0; right: 0; width: 100%; overflow: hidden; }
  .dialog, .dialog-body, .combo-menu, .sidebar { overscroll-behavior: contain; }
  /* スマホのポップアップは画面いっぱいなので、後ろは白で隠す（透けた暗い幕だと、キーボードが出て押し上げたときに、後ろの一覧が動くのが見えるため）。
     後ろは押しても反応しない（ポップアップを開いているあいだ、後ろの画面は操作できない） */
  .dialog::backdrop { touch-action: none; background: #ffffff; backdrop-filter: none; }

  /* ---- ポップアップは画面いっぱい */
  .dialog, .dialog-wide {
    width: 100vw; max-width: 100vw; height: 100vh; height: 100dvh; max-height: 100dvh; margin: 0;
    border-radius: 0; inset: 0;
  }
  .dialog[open] { animation: slide-up 0.22s ease-out; }
  @keyframes slide-up { from { transform: translateY(24px); opacity: 0.6; } to { transform: none; opacity: 1; } }
  .dialog form { height: 100%; max-height: none; }
  .dialog-head { padding: calc(14px + env(safe-area-inset-top, 0px)) 12px 10px 16px; border-bottom: 1px solid var(--border); }
  .dialog-title { font-size: 16px; }
  .dialog-body { flex: 1; padding: 12px 16px 16px; -webkit-overflow-scrolling: touch; }
  .dialog-foot { padding: 10px 16px calc(10px + var(--safe-b)); flex-wrap: wrap; }
  .dialog-foot-right { flex: 1; justify-content: flex-end; flex-wrap: wrap; }
  .dialog-foot .btn-primary { flex: 1 1 120px; }
  #knowledgeAnswer { min-height: 40vh; resize: none; overflow: hidden; }

  /* ---- ナレッジ・商品の編集は、ふつうのページとして開く（.dialog-page。JS の openDialog）。
     重ねる窓の中をスクロールさせる形をやめ、画面全体をスクロールする。押した欄をキーボードの上へ動かすのは iPhone に任せる
     （窓の位置をJSで合わせていたころは、iPhone の動きとぶつかって、最初に欄を押したときだけかくっとしていた。2026-10-02）。
     上の帯「× 題名 保存」は画面の上に残る。下のボタンの帯は使わず、削除だけを入力欄の下に置く */
  body.editor-open { padding-bottom: 0; }
  body.editor-open .topbar, body.editor-open .notice, body.editor-open main,
  body.editor-open .m-backdrop, body.editor-open .fab { display: none !important; }
  .dialog.dialog-page[open] {
    position: static; display: block; inset: auto; width: 100%; max-width: none;
    height: auto; min-height: 100vh; min-height: 100dvh; max-height: none;
    margin: 0; border-radius: 0; box-shadow: none; overflow: visible; background: var(--surface);
    animation: page-in 0.2s ease-out;
  }
  @keyframes page-in { from { opacity: 0; } to { opacity: 1; } }
  .dialog-page form { display: block; height: auto; max-height: none; }
  .dialog-page .dialog-head {
    position: sticky; top: 0; z-index: 5; background: var(--surface);
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; gap: 4px 10px;
    padding: calc(8px + env(safe-area-inset-top, 0px)) 12px 8px 6px;
  }
  .dialog-page .dialog-head .icon-btn { order: -1; width: 40px; height: 40px; }
  .dialog-page .dialog-title { font-size: 16px; }
  .dialog-page .dialog-desc { margin-top: 2px; font-size: 12px; line-height: 1.4; }
  .dialog-page .dialog-save { display: inline-flex; height: 36px; padding: 0 18px; border-radius: 999px; font-size: 15px; }
  .dialog-page .dialog-save[hidden] { display: none; }
  .dialog-page .dialog-body { overflow: visible; padding: 16px 16px 8px; }
  .dialog-page .dialog-foot { display: block; border-top: 0; background: none; padding: 8px 16px calc(32px + var(--safe-b)); }
  .dialog-page .dialog-foot .btn-danger-ghost { width: 100%; height: 44px; justify-content: center; }
  /* 削除ボタンは「その他の操作」を押したときだけ出す。新しく追加するとき（削除ボタンが無いとき）は「その他の操作」も出さない */
  .dialog-page .dialog-more {
    display: flex; align-items: center; justify-content: center; gap: 4px; width: 100%; height: 44px;
    border: 0; background: none; color: var(--muted); font-size: 14px; cursor: pointer;
  }
  .dialog-page .dialog-more svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; transition: transform 0.2s ease; }
  .dialog-page.show-delete .dialog-more svg { transform: rotate(180deg); }
  .dialog-page .dialog-foot:has(.btn-danger-ghost[hidden]) .dialog-more { display: none; }
  .dialog-page:not(.show-delete) .dialog-foot .btn-danger-ghost { display: none; }
  .dialog-page.show-delete .dialog-foot .btn-danger-ghost { border: 1px solid var(--danger); margin-top: 4px; animation: page-in 0.18s ease-out; }
  .dialog-page .dialog-foot-right .btn { display: none; }
  .dialog-page .dialog-foot-right .hint { display: block; text-align: center; }
  .dialog-page .dialog-foot-right:not(:has(.hint:not([hidden]))) { display: none; }
  .detail-grid { grid-template-columns: 84px 1fr; gap: 8px 12px; }
  .bubble { font-size: 15px; }
  .combo-option { padding: 11px 12px; font-size: 15px; }
  .chip { height: 34px; font-size: 14px; }
  .chip-remove { width: 28px; height: 28px; }

  /* ---- ログイン */
  .login { min-height: calc(100vh - 52px); min-height: calc(100dvh - 52px); }
}

/* ================================================================ スマホの画面を軽く（2026-10-02）
   ・上のバー：いま見ている画面の名前だけ（ナレッジのときは押すとシートを選べる）
   ・検索欄は1行。絞り込み・並べ替えは右のボタンで下から出すパネルにしまう
   ・追加は右下の丸いボタン（よく使う操作を1つだけ）
   ・一覧は画面の端から端まで使う、区切り線だけのリスト
   パソコンでは、パネルの中身はその場に並ぶ（.m-sheet は display: contents） */
.m-title, .m-only, .m-filter-btn, .m-sheet-head, .m-list-meta, .m-backdrop, .fab { display: none; }
.m-sheet { display: contents; }

/* ポップアップを開いているあいだ、後ろの画面をスクロールさせない（パソコンも） */
html { scrollbar-gutter: stable; }
html:has(body.scroll-locked), body.scroll-locked { overflow: hidden; }
.dialog-body, .combo-menu { overscroll-behavior: contain; }

@media (max-width: 900px) {
  :root { --top-h: calc(52px + env(safe-area-inset-top, 0px)); }

  /* ---- 上のバー */
  .topbar .brand { display: none; }
  .m-title { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; flex: 1; border: 0; background: none; padding: 4px 0; text-align: left; color: var(--text); cursor: pointer; }
  .m-title:disabled { cursor: default; color: var(--text); opacity: 1; }
  .m-title-caption { font-size: 11px; line-height: 1.3; color: var(--faint); letter-spacing: 0.02em; }
  .m-title-caption:empty { display: none; }
  .m-title-main { display: flex; align-items: center; gap: 4px; max-width: 100%; }
  .m-title-text { display: flex; align-items: center; gap: 8px; min-width: 0; font-size: 17px; font-weight: 700; line-height: 1.35; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .m-title-chevron { width: 16px; height: 16px; color: var(--muted); stroke-width: 2; }
  .m-title:active .m-title-text { opacity: 0.6; }
  #logoutButton { width: 40px; height: 40px; padding: 0; border-color: transparent; background: none; color: var(--muted); }
  #logoutButton .btn-text { display: none; }
  #logoutButton .m-only { display: block; width: 20px; height: 20px; }

  /* ---- 下から出すパネル（絞り込み・並べ替え） */
  .m-backdrop { display: block; position: fixed; inset: 0; z-index: 44; background: rgba(9, 9, 11, 0.4); animation: fade 0.18s ease-out; }
  .m-backdrop[hidden] { display: none; }
  .m-sheet {
    display: flex; flex-direction: column; align-items: stretch; gap: 12px;
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    max-height: 85vh; max-height: 85dvh; overflow: auto; overscroll-behavior: contain;
    padding: 0 16px calc(20px + var(--safe-b));
    background: var(--surface); border-radius: 18px 18px 0 0; box-shadow: 0 -16px 48px rgba(0, 0, 0, 0.16);
    transform: translateY(105%); visibility: hidden; transition: transform 0.26s cubic-bezier(0.2, 0.8, 0.2, 1), visibility 0.26s;
  }
  .m-sheet.is-open { transform: none; visibility: visible; }
  /* パネルが見出しの固定（sticky-head）の中にあるときは、開いているあいだだけ固定をやめる。
     固定（sticky）の中にあると、パネルが下のバーや暗幕より前に出られないため */
  .sticky-head:has(.m-sheet.is-open) { position: static; }
  body:has(.m-sheet.is-open) .fab { display: none; }
  .m-sheet-head { display: flex; align-items: center; justify-content: space-between; position: sticky; top: 0; z-index: 1; margin: 0 -16px; padding: 18px 8px 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); }
  .m-sheet-head::before { content: ""; position: absolute; top: 7px; left: 50%; width: 36px; height: 4px; margin-left: -18px; border-radius: 999px; background: var(--border-strong); }
  .m-sheet-head strong { font-size: 16px; }
  .m-sheet-done { border: 0; background: none; padding: 8px 10px; color: #2563eb; font-weight: 600; font-size: 15px; cursor: pointer; }
  .m-sheet .select, .m-sheet .select-inline { width: 100%; flex: none; height: 44px; }
  .m-sheet .segmented { width: 100%; }
  .m-sheet .segmented button { flex: 1 0 auto; justify-content: center; }

  /* 検索欄の右の「絞り込み」ボタン（条件を付けているときは点が付く） */
  .m-filter-btn { display: grid; place-items: center; position: relative; flex: 0 0 42px; width: 42px; height: 42px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text-2); cursor: pointer; }
  .m-filter-btn svg { width: 18px; height: 18px; }
  .m-filter-dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: #2563eb; box-shadow: 0 0 0 2px var(--surface); }
  .m-filter-dot[hidden] { display: none; }
  .toolbar { flex-wrap: nowrap; }
  .toolbar .search { flex: 1 1 auto; }
  #viewKnowledge .result-count, #viewProducts .result-count { display: none; }
  .m-list-meta { display: block; margin: 2px 0 8px; font-size: 12px; color: var(--muted); }
  .m-list-meta:empty { display: none; }

  /* 右下の追加ボタン */
  .fab {
    display: grid; place-items: center; position: fixed; z-index: 25;
    right: 16px; bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
    width: 56px; height: 56px; border: 0; border-radius: 18px;
    background: var(--primary); color: #fff; cursor: pointer;
    box-shadow: 0 10px 24px -6px rgba(0, 0, 0, 0.35), 0 2px 6px rgba(0, 0, 0, 0.12);
    transition: transform 0.12s;
  }
  .fab:active { transform: scale(0.94); }
  .fab svg { width: 24px; height: 24px; stroke-width: 2; }
  .fab[hidden] { display: none; }

  /* ---- 余白をつめる・見出しの説明をしまう */
  .layout, .single { padding: 8px 16px 96px; }
  #viewKnowledge .page-head, #viewProducts .page-head { display: none; }
  .sheet-switch { display: none; }
  .sticky-head { position: sticky; top: var(--top-h); z-index: 4; margin: 0 -16px; padding: 8px 16px 4px; background: var(--bg); }
  .sticky-head .toolbar { padding-bottom: 4px; }
  #viewProducts .toolbar { margin-bottom: 4px; }

  /* ---- 一覧：端から端まで、区切り線だけ */
  .list, .table-wrap { margin: 0 -16px; border-radius: 0; border-left: 0; border-right: 0; box-shadow: none; }
  .row:active, #productTable tr:active, .log-table tr:active { background: var(--subtle); }
  .row-wrap .row { padding: 13px 48px 13px 16px; }
  .pin-btn { left: auto; right: 4px; top: 6px; width: 40px; height: 40px; }
  .row-head { margin-bottom: 4px; }
  .row-title { font-size: 15px; line-height: 1.45; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .row-meta { font-size: 11px; gap: 6px; }
  .row-meta .tag { font-size: 11px; }
  .row-body { font-size: 13px; line-height: 1.55; }
  #productTable tr { padding: 13px 16px; }
  #productTable .product-name { margin-bottom: 4px; }
  #productTable td[data-label] { margin-top: 2px; }

  /* ---- ログの画面の上：一覧・集計の切り替えと、取得・CSV（アイコンだけ） */
  #viewLogs .page-head > div:first-child { display: none; }
  #viewLogs .page-head { margin-bottom: 8px; }
  #viewLogs .page-actions { display: flex; width: 100%; flex-wrap: nowrap; gap: 8px; }
  #viewLogs #logMode { flex: 1; order: -1; display: grid; grid-template-columns: 1fr 1fr; }
  #viewLogs #logMode button { justify-content: center; padding: 6px 8px; }
  #viewLogs .page-actions .btn { width: 42px; height: 42px; padding: 0; flex: none; }
  #viewLogs .page-actions .btn .btn-text { display: none; }
  #viewLogs .page-actions .btn svg { width: 18px; height: 18px; }
  #viewLogs .fetched-at { display: none; }
  .filter-toggle {
    display: flex; align-items: center; gap: 8px; width: 100%; height: 42px; margin-bottom: 8px; padding: 0 12px;
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); color: var(--text-2); text-align: left; cursor: pointer;
  }
  .filter-toggle svg { width: 18px; height: 18px; }
  .filter-toggle-summary { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .filter-bar.m-sheet { border: 0; margin: 0; border-radius: 18px 18px 0 0; }
  .filter-bar.m-sheet .log-filters, .filter-bar.m-sheet .toolbar { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 12px; }
  .filter-bar.m-sheet .search { flex: none; }
  .active-filters { margin: 0 0 8px; }
  #viewLogs .toolbar { margin-bottom: 6px; }
}

@media (max-width: 900px) {
  /* 商品のカードを3行に詰める：1行目「商品名・大分類・専用のナレッジ数」、2行目「別称」、3行目「グループ」 */
  #productTable tr {
    display: grid; grid-template-columns: auto minmax(0, 1fr) auto; column-gap: 8px; row-gap: 4px; align-items: center;
    grid-template-areas: "name major count" "alias alias alias" "groups groups groups";
  }
  #productTable td[data-label]::before { display: none; }
  #productTable td[data-label] { margin: 0; display: block; }
  #productTable .product-name { grid-area: name; margin: 0; font-size: 16px; }
  #productTable .product-major { grid-area: major; min-width: 0; }
  #productTable .num { grid-area: count; font-size: 12px; color: var(--muted); }
  #productTable .num::after { content: "のナレッジ"; }
  #productTable .alias { grid-area: alias; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #productTable .product-groups { grid-area: groups; }
  #productTable .product-groups .none, #productTable .product-major .none { display: none; }
}

@media (max-width: 900px) {
  /* ログのカードを詰める：1行目「日時・経路・結果」、2〜3行目「質問と答え」、4行目「使ったナレッジ・お客様」 */
  .log-table tr {
    grid-template-columns: 28px auto minmax(0, 1fr) auto; column-gap: 8px; row-gap: 4px;
    grid-template-areas: "check time chan result" "check q q q" "check used used user";
    padding: 11px 16px 11px 12px; /* チェックボックスを、上の「表示中をすべて選ぶ」と同じ左から16pxにそろえる */
  }
  .log-table .log-channel { grid-area: chan; justify-self: start; }
  .log-table .log-check label { margin: -4px 0 0 -2px; padding: 4px; }
  .log-table .log-check input { width: 18px; height: 18px; }
  .log-table .log-q-text { font-size: 14px; font-weight: 600; -webkit-line-clamp: 2; }
  .log-table .log-a-text { margin-top: 2px; }
  .log-table .log-used { flex-wrap: nowrap; overflow: hidden; }
  .log-table .log-used .log-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .log-table .result { font-size: 11px; }
  .channel { font-size: 10px; padding: 0 5px; }
}

/* ================================================================ 集計（お客様にも見せる画面） */
.stat-cards { grid-template-columns: minmax(0, 1.6fr) repeat(3, minmax(0, 1fr)); align-items: stretch; }
.stat-card { display: flex; flex-direction: column; }
.stat-sub { margin-top: auto; padding-top: 6px; font-size: 11px; color: var(--muted); line-height: 1.5; }
.stat-note { margin: 8px 0 0; font-size: 11px; line-height: 1.5; color: var(--faint); }
.stat-hero { flex-direction: row; align-items: center; gap: 18px; background: linear-gradient(135deg, #f0fdf4 0%, var(--surface) 60%); }
.stat-hero-text { min-width: 0; }
.stat-hero-legend { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; font-size: 12px; color: var(--text-2); }
.stat-hero-legend span { display: flex; align-items: center; gap: 6px; }
.stat-hero-legend i { width: 8px; height: 8px; border-radius: 2px; flex: none; }
.stat-hero-legend b { font-variant-numeric: tabular-nums; color: var(--text); }
.ring { position: relative; width: 104px; height: 104px; flex: none; }
.ring svg { width: 100%; height: 100%; }
.ring circle { fill: none; stroke-width: 10; }
.ring-track { stroke: #e7f5ec; }
.ring-fill { stroke: #16a34a; stroke-linecap: round; transition: stroke-dasharray 0.6s ease; }
.ring-value { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.ring-value small { font-size: 13px; font-weight: 600; color: var(--muted); margin-left: 1px; }

/* よく聞かれた内容：順位・タイトル（全文）・件数 */
.rank-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.rank-list li + li { border-top: 1px solid var(--border); }
.rank-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: start; gap: 12px; width: 100%; padding: 12px 6px; border: 0; background: none; text-align: left; cursor: pointer; color: var(--text); border-radius: 8px; }
.rank-row:hover { background: var(--subtle); }
.rank-no { display: grid; place-items: center; width: 26px; height: 26px; border-radius: 8px; background: var(--subtle); color: var(--muted); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.rank-no.is-top { background: var(--primary); color: #fff; }
.rank-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.rank-title { font-size: 14px; font-weight: 600; line-height: 1.5; word-break: break-word; }
.rank-meta { display: flex; flex-wrap: wrap; gap: 6px; }
.rank-meta .tag { font-size: 11px; }
.rank-bar { display: block; height: 6px; border-radius: 999px; background: var(--subtle); overflow: hidden; }
.rank-bar span { display: block; height: 100%; border-radius: 999px; background: var(--bar, var(--primary)); min-width: 3px; }
.rank-count { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; padding-top: 1px; }
.rank-count small { font-size: 11px; font-weight: 500; color: var(--muted); margin-left: 2px; }

@media (max-width: 1100px) {
  .stat-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .stat-hero { grid-column: 1 / -1; }
}
@media (max-width: 900px) {
  .stat-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat-card { padding: 12px 10px; }
  .stat-hero { padding: 14px; gap: 14px; }
  .ring { width: 92px; height: 92px; }
  .ring-value { font-size: 23px; }
  .stat-value { font-size: 19px; }
  .stat-label { font-size: 11px; }
  .rank-row { padding: 12px 2px; gap: 10px; grid-template-columns: 26px minmax(0, 1fr) auto; }
  .rank-row:active { background: var(--subtle); }
  .rank-title { font-size: 14px; }
}
@media (min-width: 901px) {
  /* パソコンでは、よく聞かれた内容を左に1〜5位・右に6〜10位の2列で並べる */
  .rank-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(5, auto); grid-auto-flow: column; column-gap: 32px; }
  .rank-list li:nth-child(6) { border-top: 0; }
}

/* ================================================================ 説明文を減らし、見た目で伝える（2026-10-02） */
.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; }
.stat-hero { background: var(--surface); }
.ring-track { stroke: #eef1ef; }

/* 見出しの横の件数 */
.count-badge { display: inline-flex; align-items: center; margin-left: 10px; padding: 1px 9px; border-radius: 999px; background: var(--subtle); color: var(--muted); font-size: 12px; font-weight: 600; letter-spacing: 0; font-variant-numeric: tabular-nums; vertical-align: middle; }
.count-badge:empty { display: none; }
.retention-note { margin-left: 10px; padding: 1px 8px; border: 1px solid var(--border); border-radius: 999px; font-size: 11px; font-weight: 500; color: var(--faint); letter-spacing: 0; vertical-align: middle; cursor: help; }
.page-head { align-items: center; }
.page-sub { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 8px; }
.page-sub-text { font-size: 12px; color: var(--muted); }
.mini-chip { display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 6px; background: var(--subtle); color: var(--text-2); font-size: 12px; font-weight: 500; }

/* 商品で絞り込む欄：アイコン付き。選んでいるときは色が変わる */
.sidebar-section { padding-bottom: 14px; }
.scope-select { position: relative; }
.scope-select > svg { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.scope-select .select { padding-left: 34px; height: 38px; font-weight: 500; }
.scope-select.is-set .select { border-color: var(--text); background-color: var(--primary); color: #fff; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none' stroke='%23ffffff' stroke-width='1.6'%3E%3Cpath d='m4 6 4 4 4-4'/%3E%3C/svg%3E"); }
.scope-select.is-set > svg { color: #fff; }

/* 集計 › 防水機能について（押すと戻る） */
.crumbs { display: flex; align-items: center; gap: 6px; min-width: 0; margin: 0 0 12px; font-size: 13px; }
.crumb-back { display: inline-flex; align-items: center; gap: 4px; flex: none; height: 32px; padding: 0 12px 0 8px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-weight: 600; cursor: pointer; transition: background 0.12s, border-color 0.12s; }
.crumb-back:hover { background: var(--subtle); border-color: var(--border-strong); color: var(--text); }
.crumb-back svg { width: 14px; height: 14px; stroke-width: 2; }
.crumb-sep { color: var(--faint); }
.crumb-current { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; color: var(--text); }

/* 「i」マークと吹き出し */
.info-tip { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-left: 4px; padding: 0; border: 0; border-radius: 50%; background: none; color: var(--faint); cursor: pointer; vertical-align: -4px; }
.info-tip:hover, .info-tip:focus-visible { color: var(--text-2); background: var(--subtle); outline: 0; }
.info-tip svg { width: 15px; height: 15px; }
.tip-popover { position: fixed; z-index: 70; padding: 9px 11px; border-radius: 10px; background: #18181b; color: #fafafa; font-size: 12px; line-height: 1.6; box-shadow: 0 12px 32px -8px rgba(0, 0, 0, 0.35); animation: pop 0.12s ease-out; }
.tip-popover[hidden] { display: none; }
.stat-label { display: flex; align-items: center; gap: 0; }
.chart-title { display: flex; align-items: center; }

/* 押せる棒・行は、重ねると右に「›」が出る（押せることを見た目で伝える） */
.bar-row:not(.is-static), .rank-row { position: relative; }
.rank-row::after, .bar-row:not(.is-static)::after { content: "›"; position: absolute; right: -2px; top: 50%; transform: translate(-4px, -50%); opacity: 0; color: var(--muted); font-size: 16px; transition: opacity 0.12s, transform 0.12s; }
.rank-row:hover::after, .bar-row:not(.is-static):hover::after { opacity: 1; transform: translate(0, -50%); }
.rank-row { padding-right: 18px; }
.bar-row:not(.is-static) { padding-right: 18px; }

/* 最後のお問い合わせ（集計の一番上） */
.stats-last { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: 0 0 12px; font-size: 13px; color: var(--muted); }
.stats-last b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.stats-ago { padding: 1px 8px; border-radius: 999px; background: var(--subtle); font-size: 12px; color: var(--text-2); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15); }

/* 数字の位置をそろえる：見出しは1行（長いときは省略）、数字は見出しのすぐ下 */
.stat-card .stat-label { white-space: nowrap; min-width: 0; }
.stat-card .stat-label .info-tip { flex: none; }

/* ================================================================ グラフの色：棒は項目ごとの色（シートの種類・セッション）。日ごとの件数は青、回答できた割合は緑 */
.bar-fill, .rank-bar span { background: var(--bar, var(--primary)); }
.bar-track, .rank-bar { background: var(--data-soft); }
.ring-track { stroke: #eef1ef; }
.ring-fill { stroke: #16a34a; }
.day-chart .day-bar { fill: #3b82f6; }
.day-chart .day-bar:hover { fill: #1d4ed8; }

/* 結果の内訳：ドーナツ型の円グラフ。切れ目（2px）を入れ、押すとその結果の一覧へ */
.donut-wrap { display: flex; align-items: center; gap: 24px; }
.donut { position: relative; width: 168px; height: 168px; flex: none; }
.donut svg { width: 100%; height: 100%; overflow: visible; }
.donut-seg { fill: none; stroke-width: 18; stroke-linecap: butt; cursor: pointer; transition: stroke-width 0.15s, opacity 0.15s; }
.donut-seg:hover, .donut-seg.is-hover { stroke-width: 22; }
.donut-wrap:has(.is-hover) .donut-seg:not(.is-hover) { opacity: 0.35; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none; }
.donut-center b { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.1; }
.donut-center span { font-size: 11px; color: var(--muted); }
.donut-legend { flex: 1; min-width: 0; list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.donut-legend button { display: grid; grid-template-columns: 10px minmax(0, 1fr) auto 44px; align-items: center; gap: 8px; width: 100%; padding: 7px 8px; border: 0; border-radius: 8px; background: none; text-align: left; font-size: 13px; color: var(--text); cursor: pointer; }
.donut-legend button:hover, .donut-legend button.is-hover { background: var(--subtle); }
.donut-legend i { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend .lg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.donut-legend .lg-n { font-weight: 600; font-variant-numeric: tabular-nums; }
.donut-legend .lg-p { text-align: right; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
@media (max-width: 900px) {
  .donut-wrap { flex-direction: column; gap: 14px; }
  .donut { width: 180px; height: 180px; }
  .donut-legend { width: 100%; }
  .donut-legend button { padding: 9px 4px; }
}

/* 集計の数字は3つ（回答できた割合・お問い合わせ・使った人） */
.stat-cards { grid-template-columns: minmax(0, 1.6fr) repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .stat-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ================================================================ 入力の体験（2026-10-02） */
/* 押してから反応するまでの待ちをなくし、ダブルタップでの拡大をしない */
button, a, input, select, textarea, label, .row, .rank-row, .bar-row, .combo-option { touch-action: manipulation; }
/* スマホ：グループの候補は浮かせず、入力欄のすぐ下に並べる */
.combo-menu.is-inline { position: static; margin-top: 6px; max-height: 260px; box-shadow: none; }

/* ================================================================ 商品の表：大分類は札ではなく文字で（札はグループだけにそろえる） */
#productTable .product-major .tag { border: 0; background: none; padding: 0; font-size: 13px; color: var(--muted); }
#productTable .product-major .tag::before { display: none; }
@media (max-width: 900px) {
  #productTable .product-major { align-self: baseline; }
  #productTable .product-major .tag { font-size: 12px; }
}

/* ================================================================ ログの上（パソコン）：1行にまとめる（2026-10-02）
   期間はボタン1つ（押すと選び方が出る）・検索・経路・結果を横一列に。最後のお問い合わせは見出しの下 */
.period-btn { display: none; }
.log-last { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 8px; margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.log-last b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; }
.log-last[hidden] { display: none; }
@media (min-width: 901px) {
  .stats-last { display: none; }
  /* スマホ用のパネルの入れ物（.m-sheet は display: contents）を、パソコンでは横一列の入れ物にする */
  #logFilterBar { display: flex; flex-direction: row; align-items: center; gap: 8px; padding: 0; border: 0; background: none; margin-bottom: 16px; }
  #logFilterBar .log-filters { position: relative; flex: none; }
  #logFilterBar .toolbar { flex: 1; flex-wrap: nowrap; gap: 8px; }
  #logFilterBar .search { max-width: none; flex: 1 1 auto; }
  #logFilterBar .select-inline { flex: none; width: 150px; min-width: 0; }
  .period-btn { display: inline-flex; align-items: center; gap: 8px; height: 34px; padding: 0 10px 0 12px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-weight: 500; white-space: nowrap; cursor: pointer; }
  .period-btn:hover, .period-btn[aria-expanded="true"] { border-color: var(--border-strong); background: var(--subtle); }
  .period-btn svg { color: var(--muted); }
  .period-chevron { width: 14px; height: 14px; }
  .period-pop { display: none; position: absolute; top: calc(100% + 6px); left: 0; z-index: 20; flex-direction: column; gap: 10px; width: 460px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface); box-shadow: 0 16px 40px -12px rgba(0, 0, 0, 0.22); }
  .period-pop.is-open { display: flex; animation: pop 0.12s ease-out; }
  .period-pop .segmented { width: 100%; }
  .period-pop .segmented button { flex: 1; justify-content: center; white-space: nowrap; }
  .period-pop .select-inline { width: 100%; }
  .period-pop .date-range .input-date { flex: 1; }
}
@media (max-width: 900px) {
  .period-pop { display: flex; flex-direction: column; gap: 12px; }
  .period-pop #logMonth { height: 44px; width: 100%; flex: none; }
  /* 下から出すパネルの中身は、パネルの高さに合わせて縮めない（はみ出したらパネルの中でスクロール） */
  .m-sheet > *, .m-sheet .log-filters > *, .period-pop > * { flex-shrink: 0; }
}

/* スマホ：集計で1回目に押した項目（2回目で一覧へ）。背景を少し濃くするだけ（枠・文字・矢印は出さない） */
.rank-row.is-armed, .bar-row.is-armed, .donut-legend button.is-armed { background: var(--subtle); }
/* 押せる行の右の「›」は出さない（パソコンでも。押せることは、重ねたときの背景の色で伝える） */
.rank-row::after, .bar-row::after, .donut-legend button::after { display: none; }
.donut-legend button::after { content: "›"; position: absolute; right: -2px; top: 50%; transform: translate(-4px, -50%); opacity: 0; color: var(--muted); font-size: 16px; transition: opacity 0.12s, transform 0.12s; }
.donut-legend button { padding-right: 18px; }

/* 指で触れる画面（マウスがない）では、重ねたときの色付け（:hover）を使わない。
   スマホでは触れた後も :hover が残り、スクロールで指が触れただけの行が灰色のままになるため */
@media (hover: none) {
  .row:hover { background: none; }
  .row-wrap.is-pinned .row:hover { background: #fffdf5; }
  .sheet-item:not(.is-active):hover { background: none; color: var(--text-2); }
  .rank-row:not(.is-armed):hover, .bar-row:not(.is-armed):hover, .donut-legend button:not(.is-armed):hover { background: none; }
  .rank-row:not(.is-armed):hover::after, .bar-row:not(.is-armed):hover::after { opacity: 0; transform: translate(-4px, -50%); }
  .table tbody tr:hover td { background: none; }
  .btn:hover { background: var(--surface); }
  .btn-primary:hover { background: var(--primary); }
  .btn-danger:hover { background: var(--danger); }
  .btn-danger-ghost:hover { background: none; }
  .crumb-back:hover { background: var(--surface); border-color: var(--border); color: var(--text-2); }
  .chip:hover { border-color: var(--border); }
  .donut-seg:hover { stroke-width: 18; }
}

@media (max-width: 900px) {
  /* よく聞かれた内容：選んだ行の背景を、区切り線と同じ幅（角なし）にする */
  .rank-row { border-radius: 0; }
}

/* ================================================================ スマホ：パネルの中の選択は、押すと選択肢の一覧が出る形
   一覧はボタンの下（場所がなければ上）に重ねて出す。iPhone の select は画面の真ん中に重なって出るため使わない */
.choice-dd { display: none; }
@media (max-width: 900px) {
  select.has-choices { display: none; }
  .choice-title { margin: 0 0 8px; font-size: 12px; font-weight: 600; color: var(--muted); }
  .choice-dd { display: block; }
  .dd-anchor { position: relative; }
  .dd-trigger {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; height: 44px; padding: 0 12px 0 14px;
    border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); color: var(--text); font-size: 15px; cursor: pointer; text-align: left;
  }
  .dd-trigger span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .dd-trigger.is-placeholder span { color: var(--faint); }
  .dd-trigger svg { width: 16px; height: 16px; color: var(--muted); stroke-width: 2; flex-shrink: 0; transition: transform 0.15s; }
  .choice-dd.is-open .dd-trigger { border-color: var(--border-strong); box-shadow: 0 0 0 3px var(--ring); }
  .choice-dd.is-open .dd-trigger svg { transform: rotate(180deg); }
  .dd-list {
    position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 5; margin: 0; padding: 4px; list-style: none;
    background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: 0 12px 32px rgba(0, 0, 0, 0.16);
    overflow-y: auto; overscroll-behavior: contain; animation: dd-in 0.14s ease-out;
  }
  .dd-list[hidden] { display: none; }
  .dd-list.is-up { top: auto; bottom: calc(100% + 6px); animation-name: dd-in-up; }
  .dd-option {
    display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; min-height: 44px; padding: 0 12px;
    border: 0; border-radius: 8px; background: none; color: var(--text); font-size: 15px; text-align: left; cursor: pointer;
  }
  .dd-option:active { background: var(--subtle); }
  .dd-option svg { width: 16px; height: 16px; color: var(--primary); stroke-width: 2.2; visibility: hidden; flex-shrink: 0; }
  .dd-option.is-on { font-weight: 600; }
  .dd-option.is-on svg { visibility: visible; }
  @keyframes dd-in { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
  @keyframes dd-in-up { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
}

/* スマホ：下から出すパネルの見出しは、指でなぞっても何も動かさない。
   ここはスクロールする場所ではないので、なぞると iPhone が代わりに画面全体を動かしてしまうため（中のボタンは押せる）。
   ナレッジ・商品の編集はページ型で、上の帯をなぞってもページがスクロールするだけなので、止めない */
@media (max-width: 900px) {
  .m-sheet-head, .drawer-head, .dialog:not(.dialog-page) .dialog-head { touch-action: none; }
}

/* パソコン：画面の上下の端を超えてスクロールしたときに、画面全体が「ふにゃん」と伸びて戻る動き（トラックパッドなど）を止める。
   ページ全体（html・body）にだけ付ける。中の枠（ナレッジの一覧の枠など）にまで付けると、その枠の上でスクロールしたときに
   ページへ伝わらなくなり、一覧がスクロールできなくなった（2026-10-02）。
   スマホ（幅900px以下）はいつもの動きのまま */
@media (min-width: 901px) {
  html, body { overscroll-behavior: none; }
  /* 左の一覧（シート）は、右のナレッジの一覧とは別にスクロールする（Gmail・Notion・Slack の左の一覧と同じ）。
     一番上・一番下まで行っても、続きのスクロールを右の一覧（ページ全体）へ渡さない。
     以前は左の一覧の端まで行くと、そのままナレッジの一覧が動いていた（2026-10-02） */
  .sidebar { overscroll-behavior: contain; }
}

/* ================================================================ テスト用チャット（2026-10-02）
   お客様と同じ仕組みで答え、答えの下に「結果・判定・使ったナレッジ」を出す。
   入力欄は画面の下に貼りつける（パソコンは画面の一番下、スマホは下のタブの上）。キーボードに合わせて動かすJSは入れない */
/* ほかの画面は左寄せだが、チャットは画面の真ん中に置く（目線が真ん中に来るので読みやすい） */
.test-view { max-width: 820px; margin-left: auto; margin-right: auto; width: 100%; min-height: calc(100vh - 56px); min-height: calc(100dvh - 56px); display: flex; flex-direction: column; padding-bottom: 0; }
.test-view .page-head .btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.test-thread { flex: 1; display: flex; flex-direction: column; gap: 14px; padding: 8px 0 20px; }
.test-msg { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; max-width: 100%; scroll-margin-top: 72px; scroll-margin-bottom: 96px; }
.test-msg.is-user { align-items: flex-end; }
.test-bubble {
  max-width: min(620px, 88%); padding: 10px 14px; border-radius: 16px; font-size: 14px; line-height: 1.75;
  white-space: pre-wrap; overflow-wrap: anywhere; background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.test-bubble a { color: var(--dot-グループ); text-decoration: underline; text-underline-offset: 2px; }
.test-msg.is-user .test-bubble { background: var(--primary); border-color: var(--primary); color: #fff; border-bottom-right-radius: 6px; }
.test-msg.is-bot .test-bubble { border-bottom-left-radius: 6px; }
.test-bubble.is-error { background: var(--danger-soft); border-color: #fecaca; color: var(--danger); }
.test-bubble.is-pending { display: inline-flex; gap: 5px; padding: 14px 16px; }
.test-bubble.is-pending span { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); animation: test-dot 1.1s ease-in-out infinite; }
.test-bubble.is-pending span:nth-child(2) { animation-delay: 0.15s; }
.test-bubble.is-pending span:nth-child(3) { animation-delay: 0.3s; }
@keyframes test-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
@media (prefers-reduced-motion: reduce) { .test-bubble.is-pending span { animation: none; } }

/* 答えの下の、結果・判定・使ったナレッジ */
.test-meta { max-width: min(620px, 88%); width: 100%; display: flex; flex-direction: column; gap: 8px; padding: 2px 2px 0; font-size: 12px; color: var(--muted); }
.test-meta-row { display: flex; flex-wrap: wrap; gap: 6px; }
.test-result, .test-fact { display: inline-flex; align-items: center; gap: 6px; min-height: 24px; padding: 2px 10px; border-radius: 999px; background: var(--subtle); color: var(--text-2); }
.test-result { font-weight: 600; }
.test-result i { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.test-fact span { color: var(--faint); }
.test-refs-label { display: flex; align-items: baseline; gap: 8px; margin-top: 2px; font-weight: 600; color: var(--text-2); }
.test-refs-label span { font-weight: 400; color: var(--faint); }
.test-refs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.test-ref {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 40px; padding: 6px 10px; text-align: left;
  border: 1px solid var(--border); border-radius: 10px; background: var(--surface); color: var(--text); font-size: 13px; cursor: pointer;
}
.test-ref:hover:not(:disabled) { border-color: var(--border-strong); background: var(--bg); }
.test-ref:disabled { cursor: default; opacity: 0.7; }
.test-ref .dot { flex-shrink: 0; }
.test-ref-sheet { flex-shrink: 0; max-width: 34%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 12px; }
.test-ref-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.test-ref svg { width: 14px; height: 14px; flex-shrink: 0; fill: none; stroke: var(--faint); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.test-ref-gone { flex-shrink: 0; font-size: 11px; color: var(--faint); }
.test-memo { margin: 0; padding: 8px 12px; display: flex; flex-direction: column; gap: 6px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.test-memo-row { display: grid; grid-template-columns: 8.5em 1fr; gap: 8px; font-size: 12.5px; line-height: 1.6; }
.test-memo-row dt { color: var(--muted); font-weight: 600; }
.test-memo-row dd { margin: 0; color: var(--text); overflow-wrap: anywhere; }
@media (max-width: 560px) { .test-memo-row { grid-template-columns: 1fr; gap: 0; } }
.test-retry {
  align-self: flex-start; display: inline-flex; align-items: center; gap: 5px; min-height: 32px; padding: 0 6px; margin-left: -6px;
  border: 0; border-radius: 8px; background: none; color: var(--muted); font-size: 12px; cursor: pointer;
}
.test-retry:hover { background: var(--subtle); color: var(--text); }
.test-retry svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.test-divider { display: flex; align-items: center; gap: 12px; color: var(--faint); font-size: 11px; }
.test-divider::before, .test-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }

/* まだ何も送っていないとき */
.test-empty { margin: auto 0; padding: 32px 8px; text-align: center; }
.test-empty-icon { width: 44px; height: 44px; margin: 0 auto 12px; border-radius: 12px; display: grid; place-items: center; background: var(--subtle); }
.test-empty-icon svg { width: 22px; height: 22px; fill: none; stroke: var(--muted); stroke-width: 1.4; stroke-linejoin: round; }
.test-empty-title { margin: 0; font-size: 15px; font-weight: 600; }
.test-empty-desc { margin: 6px 0 0; font-size: 13px; color: var(--muted); }
.test-suggest-label { margin-top: 24px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.test-suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 10px; }
.test-chip {
  max-width: 100%; padding: 8px 14px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); font-size: 13px; text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.test-chip:hover { border-color: var(--border-strong); background: var(--bg); }
.test-suggest-note { margin: 8px 0 0; font-size: 11px; color: var(--faint); }

/* 入力欄 */
.test-composer {
  position: sticky; bottom: 0; z-index: 4; display: flex; align-items: flex-end; gap: 8px;
  margin: 0 -8px; padding: 12px 8px 16px; background: linear-gradient(to bottom, rgba(250, 250, 250, 0), var(--bg) 14px);
}
.test-input { flex: 1; min-height: 44px; max-height: 160px; padding: 11px 14px; border-radius: 22px; resize: none; line-height: 1.5; font-size: 14px; overflow-y: auto; }
.test-send { width: 44px; height: 44px; padding: 0; border-radius: 50%; flex-shrink: 0; justify-content: center; }
.test-send svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

@media (max-width: 900px) {
  .test-view { min-height: calc(100dvh - 52px - var(--nav-h) - var(--safe-b)); padding-top: 12px; }
  #viewTest .page-head { margin-bottom: 4px; flex-wrap: nowrap; align-items: flex-start; }
  #viewTest .page-title { display: none; }
  /* スマホでは上の説明文を出さない（同じことを、まだ何も送っていないときの案内に書いてある） */
  #viewTest .page-head > div:first-child { display: none; }
  #viewTest .page-head { justify-content: flex-end; }
  .test-empty-desc .m-only { display: inline; }
  #viewTest .page-head .btn { flex-shrink: 0; height: 34px; font-size: 13px; }
  .test-bubble { max-width: 92%; font-size: 15px; }
  .test-meta { max-width: 100%; }
  .test-composer { bottom: calc(var(--nav-h) + var(--safe-b)); margin: 0 -16px; padding: 10px 16px; }
  /* 16px より小さいと、iPhone は入力欄を押したときに画面を拡大してしまう */
  .test-input { font-size: 16px; }
}

/* ================================================================ 動作確認用の指示文の編集（2026-10-05）
   設定 admin.prompt_editor が true のクライアントだけ、JS が部品を作る（.test-view.has-prompt）。
   パソコン：左にチャット、右に指示文。指示文の枠は画面の高さに合わせて上に貼りつく。
   スマホ：上の「チャット・指示文」で切り替える */
.test-layout { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.test-chat { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.test-switch { display: none; }
.test-view.has-prompt { max-width: 1440px; }
.test-prompt {
  display: flex; flex-direction: column; gap: 10px; min-width: 0;
  padding: 14px; border: 1px solid var(--border); border-radius: var(--radius-lg); background: var(--surface);
}
.test-prompt-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.test-prompt-title { margin: 0; font-size: 14px; font-weight: 600; }
.test-prompt-status { margin: 2px 0 0; font-size: 12px; color: var(--muted); min-height: 1em; }
.test-prompt-status.is-dirty { color: var(--warning-text); font-weight: 600; }
.test-prompt-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.test-prompt-text {
  flex: 1; min-height: 240px; padding: 12px; resize: none; white-space: pre-wrap; overflow-wrap: anywhere;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Noto Sans JP", monospace; font-size: 12.5px; line-height: 1.65;
}
.test-prompt-note { margin: 0; font-size: 11px; line-height: 1.6; color: var(--faint); }

@media (min-width: 901px) {
  .test-view.has-prompt .test-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; align-items: stretch; }
  .test-view.has-prompt .test-prompt { position: sticky; top: 76px; height: calc(100vh - 100px); align-self: start; }
}

@media (max-width: 900px) {
  .test-view.has-prompt .test-switch { display: inline-flex; align-self: flex-start; margin-bottom: 10px; }
  .test-view.has-prompt .test-switch button { min-height: 34px; padding: 4px 16px; font-size: 14px; }
  .test-view.has-prompt .test-prompt { display: none; }
  .test-view.has-prompt.show-prompt .test-prompt { display: flex; margin-bottom: 16px; }
  .test-view.has-prompt.show-prompt .test-chat { display: none; }
  .test-prompt-text { min-height: 60vh; font-size: 14px; }
}

/* ---------------------------------------------------------------- まとめて貼り付け */
.page-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.page-actions .btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.import-text { min-height: 120px; font-size: 13px; }
.import-preview { margin-top: 14px; }
.import-empty { margin: 0; font-size: 13px; color: var(--muted); }
.import-summary { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.import-chip { display: inline-flex; align-items: center; flex-shrink: 0; height: 22px; padding: 0 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); background: var(--subtle); color: var(--text-2); }
.import-chip.is-new { border-color: #bbf7d0; background: #f0fdf4; color: #15803d; }
.import-chip.is-update { border-color: #bae6fd; background: #f0f9ff; color: #0369a1; }
.import-chip.is-same { color: var(--muted); }
.import-chip.is-error { border-color: #fecaca; background: var(--danger-soft); color: var(--danger); }
.import-list { list-style: none; margin: 0; padding: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.import-item { padding: 10px 12px; border-top: 1px solid var(--border); }
.import-item:first-child { border-top: 0; }
.import-item.is-same { opacity: 0.6; }
.import-item.is-error { background: var(--danger-soft); }
.import-item-head { display: flex; align-items: flex-start; gap: 8px; font-size: 14px; }
.import-item-head strong { font-weight: 600; overflow-wrap: anywhere; }
.import-item-body { margin-top: 4px; font-size: 13px; color: var(--text-2); white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.import-item-note { margin-top: 4px; font-size: 12px; color: var(--muted); }
.import-item.is-error .import-item-note { color: var(--danger); font-weight: 600; }
.m-import-btn { display: none; }
@media (max-width: 900px) {
  .m-list-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
  .m-import-btn { display: inline-flex; align-items: center; height: 30px; padding: 0 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text-2); font-size: 12px; font-weight: 600; cursor: pointer; }
  .m-import-btn:active { opacity: 0.6; }
}

/* ---------------------------------------------------------------- ナレッジの選択（まとめて削除） */
.select-mark {
  position: absolute; left: 12px; top: 14px; z-index: 1; pointer-events: none;
  display: grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  border: 1.5px solid var(--border-strong); background: var(--surface); color: #fff;
}
.select-mark svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.list.is-selecting .pin-btn { display: none; }
.list.is-selecting .row { cursor: pointer; user-select: none; }
.row-wrap.is-selected .select-mark { background: #2563eb; border-color: #2563eb; }
.row-wrap.is-selected .select-mark svg { opacity: 1; }
.row-wrap.is-selected .row, .row-wrap.is-selected.is-pinned .row { background: #eff6ff; }
.selection-bar .btn-danger:disabled { opacity: 0.45; cursor: default; }
body:has(#knowledgeSelection .selection-bar) #viewKnowledge { padding-bottom: 96px; }
.m-list-actions { display: inline-flex; align-items: center; gap: 6px; }
@media (max-width: 900px) {
  .select-mark { left: auto; right: 13px; top: 15px; width: 24px; height: 24px; }
  body:has(#knowledgeSelection .selection-bar) #viewKnowledge { padding-bottom: 130px; }
  body:has(#knowledgeSelection .selection-bar) .fab { display: none; }
}

/* よく聞かれた内容：件数の下に、全体のうちの割合 */
.rank-count { display: flex; flex-direction: column; align-items: flex-end; }
.rank-share { margin-top: 2px; font-size: 12px; font-weight: 600; color: var(--muted); }
.chart-note b { color: var(--text); font-weight: 700; }

/* テスト用チャット：答えるAIの切り替え（設定 test_models があるときだけ出る） */
.test-model { display: inline-flex; align-items: center; gap: 8px; margin-left: auto; font-size: 13px; color: var(--muted); white-space: nowrap; }
.test-model .select { height: 36px; max-width: 260px; }
.test-view .page-head:has(.test-model) { align-items: center; }
.test-view .page-head:has(.test-model) #testReset { margin-left: 0; }
@media (max-width: 900px) {
  .test-model { margin-left: 0; min-width: 0; flex: 1 1 auto; }
  .test-model span { display: none; }
  .test-model .select { height: 34px; width: 100%; max-width: none; font-size: 13px; }
}

/* ---- デモ版（設定 DEMO_MODE=1。見るだけ）：上に「デモ版：閲覧のみ」。編集のボタン・入力欄は消さずにグレーにする（押すと案内が出る） */
.demo-badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--warning-border); background: var(--warning-bg); color: var(--warning-text); font-size: 12px; font-weight: 600; white-space: nowrap; }
.demo-locked { opacity: 0.4; cursor: not-allowed !important; }
input.demo-locked, textarea.demo-locked { opacity: 1; background: var(--subtle); color: var(--text-2); }
.toast[popover] { top: auto; height: auto; border: 0; overflow: visible; }
