/* 画像の確認画面と PDF の画面で共通の見た目。書き込みの道具箱もここ。 */

:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --bg-sunken: #f4f5f7;
  --fg: #16181d;
  --fg-muted: #656b76;
  --line: #e2e4e9;
  --accent: #2f6feb;
  --accent-fg: #ffffff;
  --checker-a: #ffffff;
  --checker-b: #ededf0;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1c1f26;
    --bg-sunken: #24272f;
    --fg: #e7e9ee;
    --fg-muted: #9aa1ad;
    --line: #343842;
    --accent: #5b8cff;
    --accent-fg: #0f1218;
    --checker-a: #22252c;
    --checker-b: #2a2e36;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 13px;
  user-select: none;
}

/* ---- 道具箱 ---- */

.tools {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: var(--bg);
}

.group { display: flex; align-items: center; gap: 3px; }
.group-right { margin-left: auto; }

.tools button {
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-muted);
  border-radius: 7px;
  padding: 5px 8px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}
.tools button:hover { background: var(--bg-sunken); color: var(--fg); }
.tools button.is-active:not(.swatch) {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
  font-weight: 700;
}
.tools button:disabled { opacity: .35; cursor: not-allowed; background: transparent; }

.swatch {
  width: 22px;
  height: 22px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid var(--line);
  cursor: pointer;
}
.swatch[data-color="red"] { background: #e5342b; }
.swatch[data-color="yellow"] { background: #ffd21e; }
.swatch[data-color="blue"] { background: #2f6feb; }
.swatch[data-color="green"] { background: #1aa260; }
.swatch[data-color="black"] { background: #101114; }
.swatch[data-color="white"] { background: #ffffff; border-color: var(--fg-muted); }

.swatch.is-active { border-color: var(--fg); outline: 2px solid var(--accent); outline-offset: 1px; }

/* ---- 絵 ---- */

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  /* 透過部分が分かるように市松模様を敷く */
  background-image:
    linear-gradient(45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(-45deg, var(--checker-b) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, var(--checker-b) 75%),
    linear-gradient(-45deg, transparent 75%, var(--checker-b) 75%);
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-color: var(--checker-a);
}

#canvas {
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 2px 12px rgba(0, 0, 0, .18);
  cursor: crosshair;
  touch-action: none;
}
#canvas.is-eraser { cursor: cell; }

/* ---- 下の操作欄 ---- */

.bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--line);
  background: var(--bg);
}

.info {
  flex: 1;
  min-width: 0;
  color: var(--fg-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.info .edited { color: var(--accent); font-weight: 700; }

.btn {
  flex: 0 0 auto;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--bg-sunken);
  color: var(--fg);
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 700; }

kbd {
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0 3px;
  font-family: inherit;
  font-size: 10.5px;
  opacity: .7;
  margin-left: 2px;
}

/* ---- ページ送り(PDFの画面) ---- */

.pager { display: flex; align-items: center; gap: 6px; }

.pager .page-input {
  width: 56px;
  text-align: center;
  padding: 5px 6px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--bg-sunken);
  color: var(--fg);
  font: inherit;
  user-select: text;
}

.pager .count { color: var(--fg-muted); white-space: nowrap; }

.marked {
  color: var(--accent);
  font-weight: 700;
  white-space: nowrap;
}

.stage.is-scroll { overflow: auto; align-items: flex-start; justify-content: center; }

.busy {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  color: var(--fg-muted);
  font-weight: 700;
}
.busy[hidden] { display: none; }

.wrap { position: relative; flex: 1; min-height: 0; display: flex; }
