/* Canary File Generator - style.css
   色はすべて :root のトークンで指定する。ダークは OS の設定（prefers-color-scheme）と、手動の切り替え（data-theme）の両方で同じ値にする */

/* ========== Base ========== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --surface: #eef1f6;
  --field-bg: #ffffff;
  --text: #111827;
  --muted: #4b5563;
  --border: #d1d5db;
  --field-border: #6b7280;
  --accent: #0b62c4;
  --on-accent: #ffffff;
  --accent-text: #0b5cb8;
  --accent-weak: #e6f0fb;
  --ok-text: #116b3f;
  --ok-bg: #e6f6ee;
  --warn-text: #8a4b00;
  --warn-bg: #fff4e5;
  --info-text: #1e4f8f;
  --info-bg: #e8f1fc;
  --danger-text: #b42318;
  --danger-bg: #fdecea;
  --pri-critical: #d92d20;
  --pri-warning: #c2670a;
  --pri-info: #957c00;
  --pri-muted: #6b7280;
  --shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0b0c10;
    --card: #111318;
    --surface: #171a21;
    --field-bg: #0e1118;
    --text: #e6e8ef;
    --muted: #9ca3af;
    --border: #2b3242;
    --field-border: #6b7280;
    --accent: #4aa3ff;
    --on-accent: #061120;
    --accent-text: #7cc0ff;
    --accent-weak: #13233a;
    --ok-text: #5fe0a8;
    --ok-bg: #0f2a1f;
    --warn-text: #ffb366;
    --warn-bg: #2a1d0f;
    --info-text: #9cc8ff;
    --info-bg: #122238;
    --danger-text: #ff8a8a;
    --danger-bg: #2a1215;
    --pri-critical: #ff6b6b;
    --pri-warning: #ff9f43;
    --pri-info: #ffd93d;
    --pri-muted: #8b93a1;
    --shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0b0c10;
  --card: #111318;
  --surface: #171a21;
  --field-bg: #0e1118;
  --text: #e6e8ef;
  --muted: #9ca3af;
  --border: #2b3242;
  --field-border: #6b7280;
  --accent: #4aa3ff;
  --on-accent: #061120;
  --accent-text: #7cc0ff;
  --accent-weak: #13233a;
  --ok-text: #5fe0a8;
  --ok-bg: #0f2a1f;
  --warn-text: #ffb366;
  --warn-bg: #2a1d0f;
  --info-text: #9cc8ff;
  --info-bg: #122238;
  --danger-text: #ff8a8a;
  --danger-bg: #2a1215;
  --pri-critical: #ff6b6b;
  --pri-warning: #ff9f43;
  --pri-info: #ffd93d;
  --pri-muted: #8b93a1;
  --shadow: 0 10px 24px rgba(0, 0, 0, 0.3);
  color-scheme: dark;
}

body {
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  /* 英数字は先に欧文の書体で描く（日本語の書体はバックスラッシュを ¥ の形で描くものがある） */
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  font-size: 16px;
  line-height: 1.7;
}

[hidden] { display: none !important; }

:focus-visible {
  outline: 3px solid var(--accent-text);
  outline-offset: 2px;
}

a { color: var(--accent-text); }

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

.small { font-size: 14px; }
.muted { color: var(--muted); }

/* ========== Header（広い幅ではタイトルを中央、ボタンを右端に置く） ========== */
.site-header {
  max-width: 1000px;
  margin: 28px auto 12px;
  padding: 0 16px;
  text-align: center;
}

.header-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.header-spacer { display: none; }

h1 {
  margin: 0;
  font-size: clamp(24px, 3.2vw, 32px);
  font-weight: 800;
}

.subtitle {
  margin: 8px auto 0;
  max-width: 760px;
  color: var(--muted);
}

.notice {
  margin: 12px auto 0;
  max-width: 760px;
  padding: 8px 14px;
  border: 1px solid var(--danger-text);
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 14px;
}

.header-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

@media (min-width: 769px) {
  .header-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
    align-items: center;
  }
  .header-spacer { display: block; }
  .header-actions { justify-content: flex-end; }
}

.icon-btn {
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.noscript {
  max-width: 1000px;
  margin: 0 auto 12px;
  padding: 10px 16px;
  background: var(--warn-bg);
  color: var(--warn-text);
}

/* ========== Tabs ========== */
.tabs {
  max-width: 1000px;
  margin: 0 auto 16px;
  padding: 0 16px;
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
}

.tab-btn {
  min-height: 44px;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 10px 10px 0 0;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
}

.tab-btn[aria-selected="true"] {
  background: var(--card);
  color: var(--accent-text);
  box-shadow: inset 0 -3px 0 0 var(--accent);
}

/* ========== Layout ========== */
.container {
  max-width: 1000px;
  margin: 0 auto 48px;
  padding: 0 16px;
}

.tabpanel h2 {
  margin: 8px 0 8px;
  font-size: 22px;
}

.card {
  margin: 16px 0;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.card h3 {
  margin: 0 0 6px;
  font-size: 18px;
}

/* ========== Form ========== */
.field-label {
  display: block;
  margin: 0 0 6px;
  font-weight: 700;
}

.text-input,
.text-area {
  display: block;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.5;
}

.text-area { resize: vertical; }

.text-area:disabled {
  background: var(--surface);
  color: var(--muted);
  cursor: not-allowed;
}

.label-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.label-row .field-label,
.label-row h3 { margin: 0; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  margin-bottom: 8px;
}

.check-row input {
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.check-row label { cursor: pointer; }

.save-as {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.issues {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.issues li {
  margin: 6px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 14px;
}

.issues li.warn { background: var(--warn-bg); color: var(--warn-text); }
.issues li.info { background: var(--info-bg); color: var(--info-text); }

.presets { margin-top: 16px; }

.presets-label {
  margin: 0 0 8px;
  font-weight: 700;
  font-size: 15px;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.help {
  margin: 8px 0 0;
  font-size: 14px;
  color: var(--muted);
}

.hint {
  margin: 10px 0 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--accent-weak);
  color: var(--text);
  font-size: 14px;
}

/* ========== Buttons ========== */
.btn {
  min-height: 44px;
  padding: 8px 16px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.btn:hover:not(:disabled) { background: var(--surface); }

.btn.primary {
  border-color: var(--accent);
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent);
  filter: brightness(1.08);
}

.btn.small { font-size: 14px; padding: 6px 12px; }

.btn:disabled {
  cursor: not-allowed;
  color: var(--muted);
  background: var(--surface);
  border-color: var(--border);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.status {
  margin: 10px 0 0;
}

.status p {
  margin: 6px 0 0;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--ok-bg);
  color: var(--ok-text);
}

.note-box {
  margin: 10px 0;
  padding: 10px 14px;
  border-radius: 8px;
}

.note-box.warn { background: var(--warn-bg); color: var(--warn-text); }

/* ========== Records（台帳と検知ログ） ========== */
.records {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.record {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  align-items: center;
  margin: 0 0 10px;
  padding: 12px;
  border: 1px solid var(--border);
  border-left: 6px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
}

.record.empty {
  display: block;
  border-left-width: 1px;
  color: var(--muted);
}

.record-title {
  margin: 0;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.record-meta {
  margin: 2px 0 0;
  font-size: 14px;
  color: var(--muted);
  overflow-wrap: anywhere;
}

.record-meta code {
  color: var(--text);
  font-size: 14px;
}

.badge {
  display: inline-block;
  margin-right: 8px;
  padding: 0 8px;
  border: 1px solid currentColor;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--pri-muted);
  vertical-align: middle;
}

.record.pri-critical { border-left-color: var(--pri-critical); }
.record.pri-critical .dot { background: var(--pri-critical); animation: pulse 1s infinite; }
.record.pri-warning { border-left-color: var(--pri-warning); }
.record.pri-warning .dot { background: var(--pri-warning); }
.record.pri-info { border-left-color: var(--pri-info); }
.record.pri-info .dot { background: var(--pri-info); }
.record.pri-muted { border-left-color: var(--pri-muted); }
.record.pri-muted .record-title { color: var(--muted); }

.record-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.record .code {
  font-size: 13px;
  margin: 6px 0 0;
}

/* 特定の結果。台帳に結びつくものは緑、候補は橙、形が崩れているものは赤の線（区分は文字でも出す） */
.record.kind-exact,
.record.kind-variant,
.record.kind-place { border-left-color: var(--ok-text); }
.record.kind-near { border-left-color: var(--warn-text); }
.record.kind-unknown { border-left-color: var(--pri-muted); }
.record.kind-malformed { border-left-color: var(--danger-text); }

.snippet {
  margin: 6px 0;
  padding: 6px 10px;
  border-radius: 6px;
  background: var(--card);
  font-size: 14px;
  overflow-wrap: anywhere;
}

mark {
  background: var(--accent-weak);
  color: var(--text);
  outline: 1px solid var(--accent-text);
  border-radius: 3px;
}

/* ========== Monitor・Find ========== */
.spaced { margin-top: 14px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.file-input { display: none; }

.os-choice {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
  padding: 0;
  border: none;
}

.os-choice legend {
  margin-bottom: 6px;
  font-weight: 700;
}

.os-choice input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
}

.os-choice label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 6px 14px;
  border: 1px solid var(--field-border);
  border-radius: 999px;
  background: var(--card);
  cursor: pointer;
}

.os-choice input:checked + label {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
}

.os-choice input:focus-visible + label {
  outline: 3px solid var(--accent-text);
  outline-offset: 2px;
}

.steps { padding-left: 1.4em; }
.steps li { margin: 12px 0; }
.step-title { margin: 0; }

.format-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 0;
}

.format-row .field-label { margin: 0; }

.select {
  min-height: 44px;
  padding: 6px 10px;
  border: 1px solid var(--field-border);
  border-radius: 10px;
  background: var(--field-bg);
  color: var(--text);
  font-size: 16px;
}

#monitor-title:focus { outline: none; }
#monitor-title:focus-visible { outline: 3px solid var(--accent-text); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ========== Study ========== */
.study h3 {
  margin: 24px 0 8px;
  font-size: 18px;
}

.terms dt {
  margin-top: 10px;
  font-weight: 700;
}

.terms dd { margin: 2px 0 0 1.2em; }

.bullets { padding-left: 1.4em; }
.bullets li { margin: 4px 0; }

.code {
  margin: 8px 0;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font-size: 14px;
  overflow-x: auto;
  white-space: pre;
}

/* ========== Footer ========== */
.site-footer {
  max-width: 1000px;
  margin: 0 auto 32px;
  padding: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

/* ========== Responsive ========== */
@media (max-width: 720px) {
  .preset-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }
  .actions .btn { width: 100%; }
  .record { grid-template-columns: minmax(0, 1fr); }
  .record-actions { flex-direction: row; flex-wrap: wrap; }
}

/* 動きを減らす設定では、点滅と切り替えのアニメーションを止める */
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}

.text-input.num { max-width: 10em; }
