/* 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/image/editor.js）。ビルドで、この部品を使うツールの styles.css に入る。
   並び：1. 画像を開く → 2. プレビューと調整 → 3. 保存。プレビューの上に見比べ（元画像／調整後）と回転のボタン。
   ツールの表示幅（@container tot-tool）が広い時はプレビューと調整欄を左右、狭い時（スマートフォン・並べて表示の片側）は縦に並べる。 */
.tot-img { display: grid; gap: 16px; }
.tot-img-step { padding: 12px 14px 14px; border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-field-bg); }
.tot-img-step-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 17px; line-height: 1.4; }
.tot-img-step-no {
  display: inline-flex; align-items: center; justify-content: center; width: 26px; height: 26px; border-radius: 50%;
  background: var(--tot-primary); color: var(--tot-on-primary); font-size: 14px; font-weight: 700; flex: none;
}
.tot-btn.tot-btn-small { min-height: 40px; padding: 4px 12px; font-size: 14px; }
.tot-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.tot-btn-primary:disabled:hover { background: var(--tot-primary); }

/* 1. 画像を開く */
.tot-img-drop {
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; padding: 14px;
  border: 2px dashed var(--tot-input-border); border-radius: var(--tot-radius); background: var(--tot-surface);
}
.tot-img.is-dragover .tot-img-drop { border-color: var(--tot-primary); background: var(--tot-primary-soft); }
.tot-img-drop-lead { margin: 0; font-weight: 600; }
.tot-img-drop-note { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--tot-muted); }
/* 画像を開いた後は、プレビューが上に来るよう開く欄を小さくする（ボタン「別の画像を選ぶ」とドロップは使える） */
.tot-img:not(.is-empty) .tot-img-drop { padding: 6px 10px; border-width: 1px; }
.tot-img:not(.is-empty) .tot-img-drop-note { display: none; }
.tot-img:not(.is-empty) .tot-img-drop-lead { font-weight: 400; font-size: 13px; color: var(--tot-muted); }
.tot-img:not(.is-empty) .tot-img-pick { min-height: 40px; padding: 4px 14px; font-size: 14px; }
.tot-img-file, .tot-img-notice, .tot-img-privacy { margin: 8px 0 0; font-size: 14px; overflow-wrap: anywhere; }
.tot-img-notice { padding: 6px 10px; border-left: 4px solid var(--tot-focus); background: var(--tot-surface); }
.tot-img-privacy { color: var(--tot-muted); font-size: 13px; }
.tot-img-error {
  margin: 8px 0 0; padding: 8px 12px; border: 2px solid var(--tot-danger); border-radius: var(--tot-radius);
  background: var(--tot-danger-soft); color: var(--tot-danger); font-weight: 600; overflow-wrap: anywhere;
}

/* 2. プレビューと調整 */
.tot-img-work { display: grid; gap: 12px; }
.tot-img-view { min-width: 0; }
.tot-img-bar { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 6px 12px; margin-bottom: 8px; }
.tot-img-group { display: flex; flex-wrap: wrap; gap: 6px; }
.tot-img-seg[aria-pressed="true"] { background: var(--tot-primary); color: var(--tot-on-primary); }
.tot-img-seg[aria-pressed="true"]::before { content: "✓ "; }
.tot-img-frame {
  display: flex; align-items: center; justify-content: center; min-height: 200px; padding: 8px;
  border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-surface);
}
.tot-img.is-original .tot-img-frame { border-color: var(--tot-muted); border-style: dashed; }
/* 元画像と調整後は同じ canvas に同じ寸法で描く（向き・表示の大きさが揃う）。透過部分は市松模様で見せる */
.tot-img-canvas {
  display: block; max-width: 100%; max-height: min(45vh, 560px); width: auto; height: auto;
  background: repeating-conic-gradient(#c8ccd2 0% 25%, #ffffff 0% 50%) 0 0 / 16px 16px;
  box-shadow: 0 0 0 1px var(--tot-border);
}
.tot-img-empty { margin: 0; color: var(--tot-muted); font-size: 14px; text-align: center; }
.tot-img-viewnote { margin: 6px 0 0; font-size: 13px; color: var(--tot-muted); }
.tot-img-controls { min-width: 0; margin: 0; padding: 10px 12px 12px; border: 1px solid var(--tot-border); border-radius: var(--tot-radius); }
.tot-img-controls:disabled { opacity: 0.6; }
.tot-img-legend { padding: 0 4px; font-weight: 700; font-size: 15px; }

/* 3. 保存 */
.tot-img-out { margin: 0 0 10px; font-size: 14px; overflow-wrap: anywhere; }
.tot-img-save-row { display: flex; flex-wrap: wrap; gap: 8px; }
.tot-img-save { min-width: 220px; }
.tot-img-save-status { margin: 8px 0 0; font-size: 14px; color: var(--tot-success-text); overflow-wrap: anywhere; }
.tot-img-save-status:empty { display: none; }
.tot-img-save-error { margin-top: 10px; }

@container tot-tool (min-width: 720px) {
  .tot-img-work { grid-template-columns: minmax(0, 1fr) minmax(240px, 300px); align-items: start; }
  .tot-img-canvas { max-height: min(62vh, 640px); }
}

/* 利用状況の計測の設定（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-034 写真の明るさ調整（複数版）。調整欄は TOT-033 と同じ。画面の枠（開く・プレビュー・回転・見比べ・保存）は画像ツール共通の editor.css（ビルドでこの前に入る）。
   ここは調整欄（明るさのスライダーとリセット）と、作業タブの中の注意事項だけ。 */
.tot-bright { max-width: 1080px; }
.tot-bright-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.tot-bright-head label { font-weight: 700; }
.tot-bright-value { min-width: 3.5em; font-size: 22px; font-weight: 700; text-align: right; font-variant-numeric: tabular-nums; }
.tot-bright-range { display: block; width: 100%; min-height: 44px; margin: 2px 0 0; accent-color: var(--tot-primary); cursor: pointer; }
.tot-bright-range:disabled { cursor: not-allowed; }
.tot-bright-scale { display: flex; justify-content: space-between; font-size: 12px; color: var(--tot-muted); }
.tot-bright-help { margin: 6px 0 10px; font-size: 13px; color: var(--tot-muted); }
.tot-bright-reset { width: 100%; }
.tot-bright-notes { margin-top: 16px; padding-top: 10px; border-top: 1px solid var(--tot-border); font-size: 14px; }
.tot-bright-notes summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.tot-bright-notes ul { margin: 6px 0 0; padding-left: 1.2em; }
.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; }
/* ── 複数版（TOT-034）：一覧・進捗・結果。枠と開く・プレビュー・保存の見た目は editor.css と同じ ── */
.tot-batch-countrow { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 6px 12px; margin-top: 8px; }
.tot-batch-count { margin: 0; font-weight: 700; font-variant-numeric: tabular-nums; }
.tot-batch-notice { font-size: 14px; }
.tot-batch-notice-head, .tot-batch-failhead { margin: 0 0 4px; font-weight: 700; }
.tot-batch-names { margin: 0; padding-left: 1.2em; font-size: 13px; overflow-wrap: anywhere; max-height: 14em; overflow-y: auto; }
/* 段（開く・一覧と調整・保存）の幅を画面に収める（見本の横の列が段を押し広げないように） */
.tot-batch { grid-template-columns: minmax(0, 1fr); }
.tot-batch .tot-img-step { min-width: 0; }
/* 狭い幅（スマートフォン・並べて表示の片側）：見本は横に流す1列（横にスクロール）。プレビューとスライダーがすぐ下に来る */
.tot-batch-list { list-style: none; margin: 0 0 12px; padding: 2px 2px 8px; display: grid; grid-auto-flow: column; grid-auto-columns: 104px; gap: 8px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; }
.tot-batch-item { scroll-snap-align: start; }
.tot-batch-list:empty { display: none; }
.tot-batch-item { position: relative; display: flex; flex-direction: column; border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-surface); }
.tot-batch-item.is-selected { border: 2px solid var(--tot-primary); box-shadow: 0 0 0 2px var(--tot-primary-soft); }
.tot-batch-item.is-error { border-color: var(--tot-danger); background: var(--tot-danger-soft); }
.tot-batch-select { appearance: none; display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 6px; border: 0; background: transparent; color: var(--tot-text); font: inherit; text-align: center; cursor: pointer; min-height: 44px; }
.tot-batch-select:disabled { cursor: default; }
.tot-batch-thumb-img { display: block; max-width: 100%; height: 72px; width: auto; object-fit: contain; background: repeating-conic-gradient(#c8ccd2 0% 25%, #ffffff 0% 50%) 0 0 / 12px 12px; }
.tot-batch-item.is-loading .tot-batch-thumb-img, .tot-batch-item.is-error .tot-batch-thumb-img { visibility: hidden; }
.tot-batch-name { width: 100%; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; line-height: 1.35; }
.tot-batch-meta { font-size: 11px; color: var(--tot-muted); overflow-wrap: anywhere; line-height: 1.35; }
.tot-batch-item.is-error .tot-batch-meta { color: var(--tot-danger); font-weight: 600; }
.tot-batch-remove { appearance: none; margin: 0 6px 6px; min-height: 32px; border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-field-bg); color: var(--tot-muted); font: inherit; font-size: 12px; cursor: pointer; }
.tot-batch-rotnote { margin: 4px 0 0; font-size: 13px; color: var(--tot-muted); }
.tot-batch-progress { display: block; width: 100%; height: 14px; margin-top: 12px; accent-color: var(--tot-primary); }
.tot-batch-progress-text { margin: 6px 0 0; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tot-batch-progress-text:empty { display: none; }
.tot-batch-result { margin-top: 10px; padding: 10px 12px; border: 1px solid var(--tot-border); border-radius: var(--tot-radius); background: var(--tot-surface); }
.tot-batch-summary { margin: 0 0 6px; font-weight: 700; color: var(--tot-success-text); overflow-wrap: anywhere; }
.tot-batch-sub { margin: 0 0 6px; font-size: 13px; overflow-wrap: anywhere; }
.tot-batch-failhead { color: var(--tot-danger); margin-top: 6px; }
/* 広い幅：見本を折り返して並べる（24枚で3〜4行） */
@container tot-tool (min-width: 720px) {
  .tot-batch-list { grid-auto-flow: row; grid-auto-columns: auto; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); overflow-x: visible; max-height: 460px; overflow-y: auto; }
  .tot-batch-thumb-img { height: 84px; }
}
