/* ToT 共通の土台スタイル。サイト共通の /css/common.css の後に読み込む。
   白基調・主操作は青・成功は緑・エラーは赤＋文字。common.css に合わせてダークモードにも対応。 */
:root {
  --tot-surface: #f6f8fb;
  --tot-field-bg: #ffffff;
  --tot-border: #d6dce5;
  --tot-input-border: #9aa5b5;
  --tot-text: #1a2230;
  --tot-muted: #5a6575;
  --tot-primary: #1d5fd1;
  --tot-primary-hover: #164ba8;
  --tot-primary-soft: #e8f0fd;
  --tot-on-primary: #ffffff;
  --tot-success: #157347;
  --tot-success-text: #0f5132;
  --tot-success-soft: #e7f5ee;
  --tot-danger: #b42318;
  --tot-danger-soft: #fdecea;
  --tot-focus: #f2a900;
  --tot-radius: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --tot-surface: #20242b;
    --tot-field-bg: #15181d;
    --tot-border: #3a414c;
    --tot-input-border: #5c6675;
    --tot-text: #e8ecf2;
    --tot-muted: #a7b0bd;
    --tot-primary: #6ea2ff;
    --tot-primary-hover: #8fb7ff;
    --tot-primary-soft: #1d2a40;
    --tot-on-primary: #0b1220;
    --tot-success: #4cc38a;
    --tot-success-text: #9be0bd;
    --tot-success-soft: #15291f;
    --tot-danger: #ff8a7a;
    --tot-danger-soft: #3a1d1a;
  }
}

.tot-main *, .tot-main *::before, .tot-main *::after { box-sizing: border-box; }

.tot-main {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px 16px 64px;
  color: var(--tot-text);
  font-size: 16px;
  line-height: 1.7;
}
.tot-main a { color: var(--tot-primary); }
/* ツールの表示部分。中の2列・1列の切り替えは画面幅ではなくこの幅で決める（@container tot-tool。作業画面の並べて表示の片側でも合う） */
.tot-tool { container: tot-tool / inline-size; }
.tot-main :focus-visible { outline: 3px solid var(--tot-focus); outline-offset: 2px; }

.tot-visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}
.tot-main [hidden] { display: none !important; }

/* ── パンくず ── */
.tot-crumbs ol {
  display: flex;
  flex-wrap: wrap;
  gap: 0 6px;
  margin: 0 0 16px;
  padding: 0;
  list-style: none;
  font-size: 12px;
  color: var(--tot-muted);
}
.tot-crumbs li + li::before { content: "›"; margin-right: 6px; }
.tot-crumbs a { color: var(--tot-muted); text-decoration: none; }
.tot-crumbs a:hover { text-decoration: underline; }

/* ── タイトル ── */
.tot-version {
  display: inline-block;
  margin-bottom: 4px;
  padding: 0 8px;
  border: 1px solid var(--tot-border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--tot-muted);
}
.tot-main .tot-open-tab {
  display: inline-flex; align-items: center; min-height: 36px; margin-left: 8px; padding: 2px 12px;
  border: 1px solid var(--tot-primary); border-radius: var(--tot-radius);
  font-size: 14px; font-weight: 600; text-decoration: none; vertical-align: middle;
}
.tot-main .tot-open-tab:hover { background: var(--tot-primary-soft); }
.tot-main .tot-title h1 { margin: 0 0 4px; font-size: 26px; line-height: 1.35; letter-spacing: 0; }
.tot-main .tot-lead { margin: 0 0 12px; color: var(--tot-muted); }

.tot-main .tot-privacy {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 0 0 20px;
  padding: 10px 14px;
  border-radius: var(--tot-radius);
  background: var(--tot-success-soft);
  color: var(--tot-success-text);
  font-size: 14px;
}

.tot-doc { margin-top: 36px; }
.tot-main .tot-doc h2 {
  font-size: 20px;
  margin: 0 0 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--tot-border);
}

/* ── ボタン ── */
.tot-btn {
  appearance: none;
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--tot-primary);
  border-radius: var(--tot-radius);
  background: transparent;
  color: var(--tot-primary);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}
.tot-btn:hover { background: var(--tot-primary-soft); }
.tot-btn-primary { background: var(--tot-primary); color: var(--tot-on-primary); }
.tot-btn-primary:hover { background: var(--tot-primary-hover); }
.tot-btn-quiet { border-color: var(--tot-border); color: var(--tot-muted); }
.tot-btn-quiet:hover { background: var(--tot-surface); }

@media (min-width: 900px) {
  .tot-main { padding: 24px 24px 80px; }
  .tot-main .tot-title h1 { font-size: 30px; }
}

/* 利用状況の計測の設定（src/shared/usage/usage-page.js。画面の下に出し、ツールの操作を妨げない。閉じられる） */
.tot-usage-note { position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 50; max-width: 720px; max-height: 70vh; overflow: auto; margin: 0 auto; padding: 12px 14px; border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-field-bg); color: var(--tot-text); font-size: 13px; line-height: 1.6; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15); }
.tot-usage-note p { margin: 0 0 6px; }
.tot-usage-title { font-weight: 700; font-size: 14px; }
.tot-usage-state { color: var(--tot-muted); }
.tot-usage-note a { color: var(--tot-primary); }
.tot-usage-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 8px; }
/* 「許可する」「許可しない」は同じ見た目（どちらかを目立たせない） */
.tot-usage-btn { min-height: 36px; padding: 4px 16px; border: 1px solid var(--tot-input-border); border-radius: 6px; background: var(--tot-surface); color: var(--tot-text); font: inherit; font-weight: 600; cursor: pointer; }
.tot-usage-btn:focus-visible, .tot-usage-note-close:focus-visible { outline: 3px solid var(--tot-focus); outline-offset: 2px; }
.tot-usage-note-close { margin-left: auto; padding: 2px 10px; border: 1px solid var(--tot-input-border); border-radius: 6px; background: transparent; color: var(--tot-text); font: inherit; cursor: pointer; }

/* TOT-017 タイトル作成支援。1列で縦に並べる（作業画面の並べて表示の片側・スマートフォンでも同じ） */
.tot-tb { max-width: 860px; }
.tot-tb-sec { margin: 0 0 20px; padding: 12px 14px 14px; border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-field-bg); }
.tot-main .tot-tb-h { margin: 0 0 8px; font-size: 17px; }
.tot-tb-field { margin-bottom: 10px; }
.tot-tb-field label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; }
.tot-tb-input {
  display: block; width: 100%; min-height: 44px; padding: 8px 12px;
  border: 1px solid var(--tot-input-border); border-radius: var(--tot-radius);
  font: inherit; font-size: 16px; color: var(--tot-text); background: var(--tot-field-bg);
}
.tot-tb-addrow { display: flex; gap: 8px; }
.tot-tb-addrow .tot-tb-input { flex: 1 1 auto; min-width: 0; }
.tot-tb-add-btn { flex: 0 0 auto; }
.tot-tb-hint { margin: 4px 0 0; font-size: 13px; color: var(--tot-muted); }
.tot-tb-msg { margin: 6px 0 0; font-size: 14px; min-height: 0; overflow-wrap: anywhere; }
.tot-tb-msg:empty { display: none; }
.tot-tb-msg.is-ok { color: var(--tot-success-text); }
.tot-tb-msg.is-warn { color: var(--tot-text); font-weight: 600; }
.tot-tb-msg.is-error { color: var(--tot-danger); font-weight: 600; }
.tot-tb-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-bottom: 8px; }
.tot-tb-count { font-size: 14px; color: var(--tot-muted); font-variant-numeric: tabular-nums; }
.tot-tb-empty { margin: 0; font-size: 14px; color: var(--tot-muted); }
.tot-btn.tot-btn-small { min-height: 36px; padding: 4px 12px; font-size: 14px; }
.tot-btn:disabled { opacity: 0.5; cursor: not-allowed; background: transparent; }
.tot-btn-primary:disabled { background: var(--tot-primary); }
.tot-tb-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 8px; }

/* 保存したボタン */
.tot-tb-keybtns { display: flex; flex-wrap: wrap; gap: 8px; }
.tot-tb-key {
  appearance: none; display: inline-flex; align-items: center; gap: 4px; min-height: 40px; max-width: 100%; padding: 4px 12px;
  border: 1px solid var(--tot-primary); border-radius: 999px; background: var(--tot-primary-soft); color: var(--tot-text);
  font: inherit; font-size: 15px; text-align: left; cursor: pointer; overflow-wrap: anywhere;
}
.tot-tb-key:hover { background: var(--tot-field-bg); }
.tot-tb-key.is-compound { border-style: double; border-width: 3px; }
.tot-tb-key-plus { color: var(--tot-primary); font-weight: 700; }

/* 縦の一覧（管理・作成中のタイトル） */
.tot-tb-rows { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.tot-tb-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 6px 8px;
  border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-surface);
}
.tot-tb-row.is-name { background: var(--tot-primary-soft); }
.tot-tb-row.is-dragging { opacity: 0.55; }
.tot-tb-row.is-drop-before { box-shadow: 0 -3px 0 0 var(--tot-primary); }
.tot-tb-row.is-drop-after { box-shadow: 0 3px 0 0 var(--tot-primary); }
.tot-tb-rows.is-sorting { user-select: none; -webkit-user-select: none; }
.tot-tb-check { width: 20px; height: 20px; margin: 0 2px; flex: 0 0 auto; }
.tot-tb-handle {
  appearance: none; flex: 0 0 auto; width: 32px; min-height: 36px; padding: 0;
  border: 1px dashed var(--tot-input-border); border-radius: 6px; background: transparent; color: var(--tot-muted);
  font: inherit; font-size: 16px; letter-spacing: -2px; cursor: grab; touch-action: none;
}
.tot-tb-rows.is-sorting .tot-tb-handle { cursor: grabbing; }
.tot-tb-row-input { flex: 1 1 12em; min-width: 0; width: auto; min-height: 40px; padding: 6px 10px; }
.tot-tb-row-body { flex: 1 1 12em; min-width: 0; display: flex; }
.tot-tb-row-body .tot-tb-row-input { width: 100%; }
.tot-tb-name-part { flex: 1 1 12em; min-width: 0; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.tot-tb-badge { flex: 0 0 auto; padding: 0 8px; border: 1px solid var(--tot-border); border-radius: 999px; font-size: 12px; color: var(--tot-muted); background: var(--tot-field-bg); }
.tot-tb-row-btns { display: flex; gap: 4px; margin-left: auto; }
.tot-tb-move { min-width: 40px; padding: 4px 8px; }
.tot-tb-del { border-color: var(--tot-danger); color: var(--tot-danger); }
.tot-tb-confirm, .tot-tb-compound { margin-top: 10px; padding: 10px 12px; border: 2px solid var(--tot-primary); border-radius: var(--tot-radius); background: var(--tot-primary-soft); }
.tot-tb-confirm-text, .tot-tb-compound-h { margin: 0 0 6px; font-weight: 600; overflow-wrap: anywhere; }
.tot-tb-compound label { display: block; margin-bottom: 4px; font-size: 14px; }
.tot-tb-compound { margin: 0 0 20px; }
.tot-tb-sec .tot-tb-compound { margin: 10px 0 0; }

/* 完成タイトル */
.tot-tb-title {
  display: block; width: 100%; padding: 10px 12px; resize: vertical;
  border: 1px solid var(--tot-input-border); border-radius: var(--tot-radius);
  font: inherit; font-size: 17px; line-height: 1.6; color: var(--tot-text); background: var(--tot-surface); overflow-wrap: anywhere;
}
.tot-tb-chars { margin: 6px 0 0; font-size: 15px; font-weight: 600; font-variant-numeric: tabular-nums; }
.tot-tb-chars.is-over { color: var(--tot-danger); }
.tot-tb-note { margin: 4px 0 0; font-size: 13px; color: var(--tot-muted); }

/* CSV */
.tot-tb-file { display: block; max-width: 100%; font: inherit; font-size: 15px; }
.tot-tb-csv-result { margin-top: 10px; }
.tot-tb-csv-file { margin: 0 0 6px; font-size: 14px; overflow-wrap: anywhere; }
.tot-tb-stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(10.5em, 1fr)); gap: 6px; margin: 0 0 8px; }
.tot-tb-stat { padding: 6px 10px; border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-surface); }
.tot-tb-stat dt { font-size: 12px; color: var(--tot-muted); }
.tot-tb-stat dd { margin: 0; font-size: 17px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tot-tb-csv-notes { margin: 0 0 8px; padding-left: 1.2em; font-size: 14px; }
.tot-tb-invalid { margin: 0 0 8px; font-size: 14px; }
.tot-tb-invalid summary { cursor: pointer; font-weight: 600; color: var(--tot-danger); }
.tot-tb-invalid.is-limit summary { color: var(--tot-text); } /* 上限による除外（形式の誤りではない）*/
.tot-tb-size { margin: 0 0 12px; padding: 8px 12px; border: 2px solid var(--tot-danger); border-radius: var(--tot-radius); background: var(--tot-danger-soft); }
.tot-tb-cands { list-style: none; margin: 8px 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(12em, 1fr)); gap: 4px 12px; max-height: 22em; overflow: auto; }
.tot-tb-cands li { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.tot-tb-cands input { width: 20px; height: 20px; flex: 0 0 auto; }
.tot-tb-cands label { overflow-wrap: anywhere; }

.tot-privacy-short { margin: 0 0 12px; font-size: 13px; color: var(--tot-muted); }
.tot-rules { padding-left: 1.2em; margin: 0; }
.tot-rules li { margin-bottom: 4px; }
.tot-noscript { color: var(--tot-danger); font-weight: 700; }

/* v2：タイトルの全文の欄・語句の並び・区分 */
.tot-tb-label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; }
.tot-tb-sec .tot-tb-title { background: var(--tot-field-bg); }
.tot-tb-part { flex: 1 1 12em; min-width: 0; display: flex; align-items: center; gap: 8px; overflow-wrap: anywhere; }
.tot-tb-rows.is-editing { opacity: 0.55; }
.tot-tb-editing { margin: 0 0 6px; }
.tot-tb-select { min-height: 40px; max-width: 100%; padding: 4px 8px; border: 1px solid var(--tot-input-border); border-radius: var(--tot-radius); font: inherit; font-size: 15px; color: var(--tot-text); background: var(--tot-field-bg); }
.tot-tb-inline { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin: 8px 0 0; }
.tot-tb-field.tot-tb-inline label { display: inline; margin: 0; }
.tot-tb-inline .tot-tb-hint { flex: 1 1 100%; }
.tot-tb-groups { display: grid; gap: 10px; }
.tot-tb-group { border: 1px solid var(--tot-border); border-radius: var(--tot-radius); padding: 6px 10px 10px; background: var(--tot-surface); }
.tot-tb-group-h {
  appearance: none; display: flex; flex-wrap: wrap; align-items: center; gap: 6px; width: 100%; min-height: 40px; margin: 0 0 6px; padding: 4px 0;
  border: 0; background: transparent; color: var(--tot-text); font: inherit; font-size: 16px; font-weight: 600; text-align: left;
}
button.tot-tb-group-h { cursor: pointer; }
.tot-tb-group-arrow { width: 1.2em; color: var(--tot-primary); }
.tot-tb-group-name { overflow-wrap: anywhere; }
.tot-tb-badge.is-target { border-color: var(--tot-primary); color: var(--tot-primary); }
.tot-tb-group-tools { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin-bottom: 8px; }
.tot-tb-group-tools label { font-size: 14px; font-weight: 600; }
.tot-tb-group-input { flex: 1 1 10em; min-width: 0; width: auto; min-height: 40px; }
.tot-tb-group-add { padding: 8px 10px; border: 1px dashed var(--tot-input-border); border-radius: var(--tot-radius); }
.tot-tb-group-add label { display: block; margin-bottom: 4px; font-size: 14px; font-weight: 600; }
.tot-tb-move-to { min-height: 36px; font-size: 14px; }

/* 共通のキーワード（2026-11-20）：状態・［共通にする］の予定・［共通をやめる］ */
.tot-tb-link { border: 1px solid var(--tot-border); border-radius: var(--tot-radius); padding: 10px 12px; margin: 0 0 10px; background: var(--tot-primary-soft); }
.tot-tb-link-text { margin: 0 0 6px; }
.tot-tb-link .tot-tb-tools { margin-top: 6px; }
.tot-tb-plan { list-style: none; margin: 8px 0; padding: 0; display: grid; gap: 8px; }
.tot-tb-plan > li { border-top: 1px solid var(--tot-border); padding-top: 6px; }
.tot-tb-plan-h { margin: 0 0 4px; overflow-wrap: anywhere; }
.tot-tb-plan select { margin-left: 4px; max-width: 100%; }
/* 未保存の編集候補（共通の時に保存できなかった編集。2026-11-20） */
.tot-tb-input.is-unsaved { border-color: var(--tot-warn-text); border-style: dashed; }
.tot-tb-cand { flex-basis: 100%; }
.tot-tb-cand .tot-tb-msg { margin: 2px 0 4px; }
.tot-tb-group-tools .tot-tb-cand { margin-top: 4px; }
