/* note Paste Studio — 白基調・落ち着いた配色・タッチ操作向け */

:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --surface-2: #fbfaf7;
  --text: #22241f;
  --muted: #6c6f68;
  --border: #e3e1da;
  --border-strong: #cfccc2;
  --accent: #2f6f62;
  --accent-hover: #285f54;
  --accent-soft: #e6f0ec;
  --accent-text: #ffffff;
  --ok: #2c7a4b;
  --ok-soft: #e8f3ec;
  --ng: #b0412e;
  --ng-soft: #f8ebe7;
  --warn: #8a6414;
  --warn-soft: #f7f0de;
  --focus: #3c8c7b;
  --shadow: 0 1px 2px rgba(30, 30, 20, 0.04), 0 4px 16px rgba(30, 30, 20, 0.04);
  /* プレビュー用紙は常に明るい色（コピー時に暗い配色が混ざらないようにする） */
  --paper-bg: #ffffff;
  --paper-text: #222;
  --paper-muted: #777;
  --paper-border: #e6e4de;
  --radius: 14px;
  --radius-sm: 10px;
  --tap: 48px;
  --font: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #161816;
    --surface: #1f2220;
    --surface-2: #242826;
    --text: #e8e8e3;
    --muted: #a1a59d;
    --border: #333833;
    --border-strong: #464c46;
    --accent: #7cc2ae;
    --accent-hover: #93d0be;
    --accent-soft: #23362f;
    --accent-text: #10201b;
    --ok: #7fce9c;
    --ok-soft: #1d3326;
    --ng: #f0957f;
    --ng-soft: #3a231d;
    --warn: #e3c06e;
    --warn-soft: #362d17;
    --focus: #8fd3c0;
    --shadow: none;
    --paper-bg: #f4f3ef;
    --paper-border: #3a3f3a;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #161816;
  --surface: #1f2220;
  --surface-2: #242826;
  --text: #e8e8e3;
  --muted: #a1a59d;
  --border: #333833;
  --border-strong: #464c46;
  --accent: #7cc2ae;
  --accent-hover: #93d0be;
  --accent-soft: #23362f;
  --accent-text: #10201b;
  --ok: #7fce9c;
  --ok-soft: #1d3326;
  --ng: #f0957f;
  --ng-soft: #3a231d;
  --warn: #e3c06e;
  --warn-soft: #362d17;
  --focus: #8fd3c0;
  --shadow: none;
  --paper-bg: #f4f3ef;
  --paper-border: #3a3f3a;
  color-scheme: dark;
}

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

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { line-height: 1.35; }

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

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

.muted { color: var(--muted); }
.hint { color: var(--muted); font-size: 0.875rem; margin: 0.4rem 0 0.8rem; }

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

/* ---------- ヘッダー ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 10px max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--surface);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--accent);
  box-shadow: inset 0 0 0 5px var(--accent), inset 0 0 0 7px var(--surface);
  flex: none;
}
.brand-name { font-weight: 700; letter-spacing: 0.01em; white-space: nowrap; }
.badge {
  font-size: 0.72rem;
  color: var(--muted);
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  padding: 1px 8px;
  white-space: nowrap;
}

.tabs { display: flex; gap: 4px; margin-left: auto; }
.tabs a {
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.92rem;
}
.tabs a[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

.theme-btn { min-width: 72px; }

/* ---------- ボタン ---------- */

.btn, .btn-primary, .btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tap);
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  transition: background-color 0.15s, border-color 0.15s, transform 0.05s;
}
.btn:active, .btn-primary:active { transform: scale(0.98); }
.btn svg, .btn-primary svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.btn {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
}
.btn:hover { border-color: var(--muted); }
.btn[disabled] { opacity: 0.45; cursor: not-allowed; }
.btn.small { min-height: 40px; padding: 0 12px; font-size: 0.85rem; }
.btn.wide { width: 100%; }
.btn.danger { color: var(--ng); }

.btn-primary {
  width: 100%;
  min-height: 60px;
  font-size: 1.1rem;
  background: var(--accent);
  color: var(--accent-text);
  border: 0;
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  padding: 0 12px;
  font-size: 0.85rem;
}
.btn-ghost:hover { border-color: var(--border); }

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- エディタのレイアウト ---------- */

.workspace {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  padding: 16px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  max-width: 1440px;
  margin: 0 auto;
}

@media (min-width: 768px) {
  .workspace {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr);
    align-items: start;
    gap: 20px;
    padding-top: 20px;
  }
  .pane-input {
    position: sticky;
    top: 80px;
    max-height: calc(100vh - 96px);
    max-height: calc(100dvh - 96px);
    overflow: auto;
  }
}

.pane {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.pane-output { background: transparent; border: 0; padding: 0; box-shadow: none; display: grid; gap: 16px; }

.pane-head, .section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 12px;
}
.pane-head h2 { font-size: 1.05rem; margin: 0; }
.section-head h2, .section-head h3 { margin: 0; }
.section-head h3 { font-size: 0.98rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; }

textarea, select, input[type="text"] {
  font: inherit;
  color: var(--text);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
}

#md {
  display: block;
  width: 100%;
  min-height: 52vh;
  padding: 14px;
  font-size: 16px; /* 16px未満だとiOSで入力時に拡大される */
  line-height: 1.75;
  resize: vertical;
  tab-size: 4;
}
#md:focus { outline: 2px solid var(--focus); outline-offset: 0; background: var(--surface); }

.statusline {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.8rem;
  color: var(--muted);
  padding: 6px 2px 0;
}

.images { margin-top: 20px; padding-top: 16px; border-top: 1px solid var(--border); }
.image-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.image-item {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 6px 12px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.image-item.used { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.image-item img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: 8px;
  background: var(--border);
  grid-row: span 2;
}
.image-info { display: grid; gap: 2px; min-width: 0; font-size: 0.85rem; }
.image-info strong, .image-info code { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-info code { font-family: var(--mono); font-size: 0.78rem; color: var(--muted); }
.image-actions { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- コピー操作 ---------- */

.copy-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 12px;
}

.options { display: grid; gap: 8px; }
.options.inline { display: flex; flex-wrap: wrap; gap: 8px 20px; margin-bottom: 12px; }
.field { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 12px; font-size: 0.9rem; }
.field select { min-height: 44px; padding: 0 10px; width: 100%; }
.check { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }

.result {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  border: 1px solid var(--border);
  font-size: 0.9rem;
  display: grid;
  gap: 8px;
}
.result[hidden] { display: none; }
.result.is-ok { background: var(--ok-soft); border-color: color-mix(in srgb, var(--ok) 35%, transparent); }
.result.is-ng { background: var(--ng-soft); border-color: color-mix(in srgb, var(--ng) 35%, transparent); }
.result-head { display: flex; align-items: center; gap: 10px; }
.result-head strong { flex: 1; }
.result-icon {
  display: inline-grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  font-weight: 700;
  color: #fff;
  flex: none;
}
.is-ok .result-icon { background: var(--ok); }
.is-ng .result-icon { background: var(--ng); }
:root[data-theme="dark"] .result-icon { color: #111; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .result-icon { color: #111; } }
.result-time { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.result-note { margin: 0; }
.result-warn {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 0.85rem;
}
.result-meta {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 2px 12px;
  margin: 0;
  font-size: 0.82rem;
}
.result-meta dt { color: var(--muted); }
.result-meta dd { margin: 0; overflow-wrap: anywhere; }
.attempt {
  display: grid;
  gap: 2px;
  font-size: 0.82rem;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--surface);
}
.attempt code { font-family: var(--mono); font-size: 0.78rem; overflow-wrap: anywhere; }
.attempt.ng strong { color: var(--ng); }
.attempt.ok strong { color: var(--ok); }

details > summary {
  cursor: pointer;
  min-height: 44px;
  display: flex;
  align-items: center;
  font-weight: 600;
  font-size: 0.92rem;
  list-style: none;
}
details > summary::-webkit-details-marker { display: none; }
details > summary::before {
  content: "";
  width: 8px;
  height: 8px;
  margin: 0 12px 0 4px;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(-45deg);
  transition: transform 0.15s;
  flex: none;
}
details[open] > summary::before { transform: rotate(45deg); }

.fallback { border-top: 1px solid var(--border); padding-top: 4px; }
.fallback-body { display: grid; gap: 10px; padding-bottom: 4px; }
.steps { margin: 0; padding-left: 1.4em; font-size: 0.88rem; color: var(--muted); }
.steps li + li { margin-top: 4px; }

/* ---------- プレビュー（note風の読みやすい記事レイアウト） ---------- */

.paper {
  background: var(--paper-bg);
  color: var(--paper-text);
  border: 1px solid var(--paper-border);
  border-radius: var(--radius);
  padding: 28px 22px 40px;
  box-shadow: var(--shadow);
  min-width: 0;
}
@media (min-width: 768px) { .paper { padding: 40px 48px 56px; } }
.paper.compact { padding: 24px 22px 32px; }
.paper-label {
  margin: 0 0 18px;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: var(--paper-muted);
}
.paper-title {
  font-size: 1.75rem;
  line-height: 1.45;
  margin: 0 0 28px;
  font-weight: 700;
  color: var(--paper-text);
}

.paper-body {
  max-width: 640px;
  margin: 0 auto;
  font-size: 17px;
  line-height: 2;
  color: var(--paper-text);
  overflow-wrap: anywhere;
}
.paper .paper-title { max-width: 640px; margin-left: auto; margin-right: auto; }
.paper-body > :first-child { margin-top: 0; }
.paper-body p { margin: 0 0 1.4em; }
.paper-body h1 { font-size: 1.6em; margin: 2em 0 0.8em; line-height: 1.45; }
.paper-body h2 { font-size: 1.35em; margin: 2.2em 0 0.8em; line-height: 1.5; }
.paper-body h3 { font-size: 1.14em; margin: 1.9em 0 0.6em; line-height: 1.55; }
.paper-body h4, .paper-body h5, .paper-body h6 { font-size: 1em; margin: 1.6em 0 0.5em; }
.paper-body strong { font-weight: 700; }
.paper-body ul, .paper-body ol { margin: 0 0 1.4em; padding-left: 1.5em; }
.paper-body li { margin: 0.2em 0; }
.paper-body li > ul, .paper-body li > ol { margin: 0.2em 0 0; }
.paper-body blockquote {
  margin: 0 0 1.4em;
  padding: 0.2em 0 0.2em 1.1em;
  border-left: 3px solid #d6d4cc;
  color: #555;
}
.paper-body blockquote p:last-child { margin-bottom: 0; }
.paper-body a { color: #1f5f8b; text-decoration: underline; text-underline-offset: 3px; }
.paper-body figure { margin: 2em 0; }
.paper-body img { max-width: 100%; height: auto; display: block; border-radius: 4px; }
.paper-body p img { display: inline-block; vertical-align: middle; }
.paper-body figcaption { font-size: 0.85em; color: var(--paper-muted); text-align: center; margin-top: 0.6em; }
.paper-body hr { border: 0; border-top: 1px solid #e2e0d9; margin: 2.4em 0; }
.paper-body code { font-family: var(--mono); font-size: 0.88em; background: #f1f0ec; padding: 0.1em 0.35em; border-radius: 4px; }
.paper-body pre { background: #f4f3ef; padding: 14px 16px; border-radius: 8px; overflow-x: auto; line-height: 1.6; font-size: 0.86em; }
.paper-body pre code { background: none; padding: 0; }
.paper-body table { border-collapse: collapse; margin: 0 0 1.4em; font-size: 0.92em; display: block; overflow-x: auto; }
.paper-body th, .paper-body td { border: 1px solid #dedcd5; padding: 0.4em 0.8em; text-align: left; }
.paper-body .empty { color: var(--paper-muted); }

/* ---------- 検証ページ ---------- */

.testpage {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px max(16px, env(safe-area-inset-right)) 24px max(16px, env(safe-area-inset-left));
  display: grid;
  gap: 16px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card > h1 { font-size: 1.4rem; margin: 0 0 8px; }
.card > h2, .card .section-head h2 { font-size: 1.1rem; margin: 0 0 4px; }
.card .section-head { margin-bottom: 12px; }
.intro p { margin: 0 0 12px; }

.pill-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.pill-list li { background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.92rem; }

.env {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 8px 16px;
  margin: 0;
  font-size: 0.9rem;
}
.env dt { color: var(--muted); font-family: var(--mono); font-size: 0.82rem; padding-top: 2px; }
.env dd { margin: 0; display: grid; gap: 2px; }
.env small { color: var(--muted); }
.ok { color: var(--ok); font-weight: 600; }
.ng { color: var(--ng); font-weight: 600; }

.sample-grid { display: grid; gap: 16px; }
@media (min-width: 900px) { .sample-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; } }
.source pre {
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.6;
  white-space: pre-wrap;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin: 0;
  max-height: 360px;
  overflow: auto;
}
.explain { margin-top: 12px; font-size: 0.88rem; }
.explain h3 { font-size: 0.95rem; margin: 0 0 6px; }
.explain p { margin: 0 0 8px; color: var(--muted); }
.explain strong, .explain em { color: var(--text); }

.methods { display: grid; gap: 12px; margin-top: 8px; }
@media (min-width: 768px) { .methods { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.method {
  display: grid;
  gap: 10px;
  align-content: start;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  background: var(--surface-2);
}
.method h3 { margin: 0; font-size: 1rem; }
.method .hint { margin: 0; }
.method .btn-primary { min-height: 52px; font-size: 1rem; }

.record {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 10px 12px 12px;
  margin: 0;
  display: grid;
  gap: 8px;
}
.record legend { font-size: 0.82rem; font-weight: 600; color: var(--muted); padding: 0 6px; }
.record select { min-height: 44px; padding: 0 10px; }
.record textarea { padding: 8px 10px; font-size: 16px; resize: vertical; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; font-size: 0.85rem; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
}
.chip input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }
.chip:has(input:checked) { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.callout {
  background: var(--warn-soft);
  color: var(--text);
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 0.9rem;
  margin: 8px 0 12px;
}
.paste-wrap { display: grid; gap: 10px; }
.paste-area {
  min-height: 220px;
  max-width: none;
  padding: 20px;
  background: var(--paper-bg);
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 16px;
}
.paste-area:focus { outline: none; border-color: var(--focus); border-style: solid; }
.paste-area:empty::before { content: attr(data-placeholder); color: var(--paper-muted); }
.paste-info { display: grid; gap: 10px; }
@media (min-width: 768px) { .paste-info { grid-template-columns: 1fr 1fr; } .paste-info > p { grid-column: 1 / -1; } }
.info-block { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; background: var(--surface-2); }
.info-block h4 { margin: 0 0 6px; font-size: 0.88rem; }

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.records { width: 100%; border-collapse: collapse; font-size: 0.85rem; min-width: 720px; }
.records th, .records td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.records th { color: var(--muted); font-weight: 600; font-size: 0.78rem; white-space: nowrap; }
.records td.memo { max-width: 240px; overflow-wrap: anywhere; }

/* ---------- その他 ---------- */

.footer {
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 8px 16px calc(28px + env(safe-area-inset-bottom));
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translate(-50%, 20px);
  max-width: min(92vw, 520px);
  background: #2a2d29;
  color: #f2f2ee;
  padding: 12px 18px;
  border-radius: 12px;
  font-size: 0.9rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 560px) {
  .badge { display: none; }
  .brand-name { font-size: 0.95rem; }
  .topbar { flex-wrap: wrap; row-gap: 6px; padding-top: 8px; padding-bottom: 8px; }
  .tabs { order: 3; width: 100%; margin-left: 0; }
  .tabs a { flex: 1; justify-content: center; padding: 0 10px; font-size: 0.88rem; min-height: 38px; }
  .theme-btn { min-width: 0; margin-left: auto; min-height: 40px; }
  .field { grid-template-columns: 1fr; gap: 4px; }
  .paper-title { font-size: 1.45rem; }
  .paper-body { font-size: 16px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- 画像を順番に貼る ---------- */

.step-card { display: flex; align-items: center; gap: 12px; min-width: 0; }
.step-card img { object-fit: cover; border-radius: 8px; flex: none; background: var(--border); }
.step-info { display: grid; gap: 2px; min-width: 0; }
.step-info .muted { font-size: 0.82rem; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 54px;
  border-radius: var(--radius-sm);
  font: inherit;
  font-weight: 700;
  font-size: 1.02rem;
  background: var(--surface);
  color: var(--accent);
  border: 2px solid var(--accent);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
}
.btn-secondary:active { transform: scale(0.98); }
.btn-secondary[disabled] { opacity: 0.45; cursor: not-allowed; }

.verified {
  justify-self: start;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--muted);
}
.verified.ok { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.verified.ng { color: var(--ng); background: var(--ng-soft); border-color: transparent; }

.findings { margin: 12px 0 0; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--accent-soft); font-size: 0.9rem; }
.findings h2 { font-size: 0.95rem; margin: 0 0 6px; }
.findings ul { margin: 0; padding-left: 1.3em; }

/* ---------- 普段使い向けエディタ ---------- */

[hidden] { display: none !important; }

.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.topbar-actions { display: flex; gap: 4px; margin-left: auto; }

.help {
  max-width: 1440px;
  margin: 16px auto 0;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: calc(100% - 32px);
  font-size: 0.92rem;
}
.help ol { margin: 0; padding-left: 1.4em; display: grid; gap: 6px; }
.help .hint { margin: 10px 0 0; }

.panel-title { font-size: 1.05rem; margin: 0; }

.flow { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; counter-reset: flow; }
.flow-step {
  counter-increment: flow;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.flow-step::before {
  content: counter(flow);
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
  font-size: 0.9rem;
}
.flow-body { display: grid; gap: 2px; min-width: 0; }
.flow-body .muted { font-size: 0.82rem; }
.flow-step.is-main,
.flow-step.is-images { grid-template-columns: 32px minmax(0, 1fr); }
.flow-step.is-main > .btn-primary,
.flow-step.is-images > .step-card,
.flow-step.is-images > .btn-secondary,
.flow-step.is-images > .btn-row { grid-column: 1 / -1; }
.flow-step.is-images { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 30%, var(--border)); }
.flow-step.is-images::before { background: var(--surface); }
.step-card img { width: 56px; height: 56px; }
.step-info .ellipsis { font-weight: 600; }

.btn-primary.is-done, .btn-secondary.is-done { opacity: 0.85; }
.btn-primary.is-done::after { content: "✓ コピー済み"; font-size: 0.8rem; font-weight: 600; margin-left: 4px; opacity: 0.9; }

.settings { border-top: 1px solid var(--border); padding-top: 4px; }
.settings .options { padding: 4px 0 8px; }

.mobile-bar { display: none; }

@media (max-width: 767px) {
  .editor-page { padding-bottom: calc(76px + env(safe-area-inset-bottom)); }
  .mobile-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: flex;
    gap: 8px;
    padding: 10px max(12px, env(safe-area-inset-right)) calc(10px + env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
    background: var(--surface);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    -webkit-backdrop-filter: saturate(1.4) blur(12px);
    backdrop-filter: saturate(1.4) blur(12px);
    border-top: 1px solid var(--border);
  }
  .mobile-bar > * { flex: 1; min-height: 52px; width: auto; font-size: 0.95rem; padding: 0 8px; }
  .mobile-bar .btn-primary { flex: 1.6; }
  .mobile-bar .btn-primary.is-done::after { content: "✓"; }
  .toast { bottom: calc(92px + env(safe-area-inset-bottom)); }
}

.toc-field { padding: 2px 2px 0; }
.toc-hint { margin: -4px 2px 0; font-size: 0.8rem; }

/* ---------- 記事一覧 ---------- */

.sheet {
  width: min(560px, calc(100vw - 32px));
  max-height: min(80vh, 720px);
  max-height: min(80dvh, 720px);
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  overflow: auto;
}
.sheet[open] { display: grid; gap: 12px; align-content: start; }
.sheet::backdrop { background: rgba(20, 22, 20, 0.45); }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h2 { margin: 0; font-size: 1.05rem; }
.sheet-head .muted { font-size: 0.85rem; font-weight: 400; }
.sheet .btn-primary { min-height: 52px; font-size: 1rem; }
.sheet .hint { margin: 0; }

.article-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.article-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px 4px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.article-item.is-current { border-color: var(--accent); background: var(--accent-soft); }
.article-open {
  flex: 1;
  min-width: 0;
  display: grid;
  gap: 2px;
  min-height: 56px;
  padding: 8px 10px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.article-open .muted { font-size: 0.8rem; }

.pane-input .pane-head { flex-direction: column; align-items: stretch; gap: 12px; margin-bottom: 12px; }
.pane-input .toolbar .btn { flex: 1 1 auto; }
.pane-input .toolbar .btn { padding: 0 14px; }

.backup { border-top: 1px solid var(--border); padding-top: 12px; display: grid; gap: 8px; }
.backup h3 { margin: 0; font-size: 0.95rem; }
.backup-status { margin: 0; font-size: 0.82rem; }

.pane-title-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.pane-title-row h2 { margin: 0; font-size: 1.05rem; }

.prompt-list { display: grid; gap: 12px; }
.prompt-card {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.prompt-card h3 { margin: 0; font-size: 0.95rem; }
.prompt-card .hint { margin: 0; }
.prompt-card pre {
  margin: 0;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: 0.82rem;
  line-height: 1.7;
  white-space: pre-wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
}
.prompt-card .btn-primary { min-height: 48px; font-size: 0.95rem; }
