/* テーマ: 既定は端末の設定（prefers-color-scheme）に従い、
   html[data-theme="light" | "dark"] が付いたときは手動の選択を優先する */
:root {
  --bg: #f6f7fb;
  --card: #ffffff;
  --text: #1d2433;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #4f46e5;
  --accent-text: #ffffff;
  --accent-weak: #eef0ff;
  --ok: #12b76a;
  --ok-weak: #e7f8ef;
  --ok-text: #067647;
  --badge-bg: #067647;
  --badge-fg: #ffffff;
  --ng: #f04438;
  --ng-weak: #fdecea;
  --ng-text: #b42318;
  --ng-badge-bg: #b42318;
  --ng-badge-fg: #ffffff;
  --warn: #f79009;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
}
:root[data-theme="light"] { color-scheme: light; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1220;
    --card: #181c2e;
    --text: #e8eaf3;
    --muted: #98a2b3;
    --line: #2a2f45;
    --accent: #8b8bff;
    --accent-text: #11142a;
    --accent-weak: #23264a;
    --ok: #32d583;
    --ok-weak: #10281d;
    --ok-text: #a6f4c5;
    --badge-bg: #32d583;
    --badge-fg: #06281a;
    --ng: #f97066;
    --ng-weak: #2e1715;
    --ng-text: #fda29b;
    --ng-badge-bg: #f97066;
    --ng-badge-fg: #2a0a08;
    --shadow: none;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1220;
  --card: #181c2e;
  --text: #e8eaf3;
  --muted: #98a2b3;
  --line: #2a2f45;
  --accent: #8b8bff;
  --accent-text: #11142a;
  --accent-weak: #23264a;
  --ok: #32d583;
  --ok-weak: #10281d;
    --ok-text: #a6f4c5;
    --badge-bg: #32d583;
    --badge-fg: #06281a;
  --ng: #f97066;
  --ng-weak: #2e1715;
    --ng-text: #fda29b;
    --ng-badge-bg: #f97066;
    --ng-badge-fg: #2a0a08;
  --shadow: none;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Noto Sans JP", Meiryo, sans-serif;
  padding-bottom: env(safe-area-inset-bottom);
}
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 1.45rem; margin: 0.2em 0 0.4em; line-height: 1.35; }
h2 { font-size: 1.1rem; margin: 0 0 0.6em; }
h3 { font-size: 1rem; margin: 0 0 0.4em; }
p { margin: 0.4em 0; }
small, .muted { color: var(--muted); }
small { font-size: 0.85rem; }

/* ---- layout ---- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  background: var(--card); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; color: var(--text); font-size: 1.05rem; }
.topbar nav { display: flex; gap: 4px; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); padding: 6px 12px; border-radius: 999px; font-size: 0.92rem; }
.topbar nav a.active { background: var(--accent-weak); color: var(--accent); font-weight: 600; }
main { max-width: 780px; margin: 0 auto; padding: 16px 16px 96px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.grow { flex: 1 1 auto; min-width: 0; }
.spread { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.loading { color: var(--muted); text-align: center; padding: 48px 0; }
.back { font-size: 0.9rem; display: inline-block; }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow);
}
.card.accent { background: var(--accent-weak); border-color: transparent; }
.error-card { border-color: var(--ng); }
.error { color: var(--ng); font-size: 0.92rem; }

/* ---- controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 18px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; -webkit-tap-highlight-color: transparent;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--ng); }
.btn.ghost { background: transparent; }
.btn.sm { min-height: 36px; padding: 4px 12px; font-size: 0.88rem; }
.btn.lg { min-height: 52px; font-size: 1.05rem; }
.btn.block { width: 100%; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.icon-btn {
  width: 40px; height: 40px; flex: 0 0 auto; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit;
}
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.input {
  width: 100%; min-height: 44px; padding: 9px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit;
}
textarea.input { resize: vertical; line-height: 1.55; }
.input:focus, .btn:focus-visible, .icon-btn:focus-visible, .choice:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 1px;
}
.field { display: flex; flex-direction: column; gap: 6px; }
.label { font-weight: 600; font-size: 0.92rem; }
.check { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }
input[type="number"].input { max-width: 120px; }

.chip {
  display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78rem; line-height: 1.7;
  background: var(--accent-weak); color: var(--accent); border: 1px solid transparent; white-space: nowrap;
}
.chip.gray { background: var(--bg); color: var(--muted); border-color: var(--line); }
button.chip { cursor: pointer; font: inherit; font-size: 0.9rem; padding: 6px 14px; background: var(--card); color: var(--text); border-color: var(--line); }
button.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.25s; }
.bar.ok > i { background: var(--ok); }

/* ---- home / exam ---- */
.exam-card { display: flex; flex-direction: column; gap: 10px; }
.exam-card h2 { margin: 0; }
.stat-line { display: flex; gap: 16px; flex-wrap: wrap; font-size: 0.9rem; color: var(--muted); }
.big { font-size: 1.6rem; font-weight: 700; color: var(--text); }
.topic-row { display: flex; align-items: center; gap: 8px; padding: 10px 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.topic-row:first-of-type { border-top: 0; }
.topic-row .name { flex: 1 1 180px; min-width: 0; font-weight: 600; }
.qitem {
  display: flex; gap: 10px; align-items: flex-start; padding: 12px 4px; color: var(--text);
  border-top: 1px solid var(--line);
}
.qitem:first-child { border-top: 0; }
.qitem .qtext { flex: 1 1 auto; min-width: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.qitem .meta { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 4px; }
.dot { flex: 0 0 auto; width: 12px; height: 12px; border-radius: 50%; margin-top: 7px; background: var(--line); }
.dot.ok { background: var(--ok); }
.dot.ng { background: var(--ng); }

/* ---- editor ---- */
.choice-row, .order-row, .pair-row { display: flex; align-items: center; gap: 8px; }
.choice-row input[type="radio"], .choice-row input[type="checkbox"] { width: 22px; height: 22px; accent-color: var(--ok); flex: 0 0 auto; }
.letter { width: 1.2em; text-align: center; font-weight: 700; color: var(--muted); flex: 0 0 auto; }
.pair-arrow { color: var(--muted); flex: 0 0 auto; }
.pair-row .input { flex: 1 1 0; min-width: 0; }
.st-edit { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.st-edit .input { flex: 1 1 220px; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: 0 0 auto; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 9px 16px; min-width: 64px; text-align: center; font-weight: 600; background: var(--card); }
.seg input:checked + span { background: var(--accent); color: var(--accent-text); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: -2px; }
.actionbar {
  position: sticky; bottom: 0; z-index: 5; display: flex; gap: 8px; flex-wrap: wrap;
  padding: 12px 0; padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 70%, transparent);
}

/* ---- study ---- */
.qcard { display: flex; flex-direction: column; gap: 14px; }
.qhead { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.scenario { background: var(--bg); border-left: 4px solid var(--accent); padding: 10px 14px; border-radius: 6px; white-space: pre-wrap; }
.qtext-main { font-size: 1.08rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.hint { color: var(--muted); font-size: 0.9rem; }
.choices { display: flex; flex-direction: column; gap: 10px; }
.choice {
  display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%;
  padding: 12px 14px; min-height: 52px; border-radius: 12px; cursor: pointer;
  border: 2px solid var(--line); background: var(--card); color: var(--text); font: inherit;
  -webkit-tap-highlight-color: transparent;
}
.choice .mark {
  flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--line); font-size: 0.85rem; font-weight: 700; color: var(--muted);
}
.choice .ctext { flex: 1 1 auto; white-space: pre-wrap; overflow-wrap: anywhere; padding-top: 2px; }
.choice.selected { border-color: var(--accent); background: var(--accent-weak); }
.choice.selected .mark { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.choice.correct { border-color: var(--ok); background: var(--ok-weak); }
.choice.correct .mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.missed { border-color: var(--ok); border-style: dashed; background: var(--ok-weak); }
.choice.missed .mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.choice.wrong { border-color: var(--ng); background: var(--ng-weak); }
.choice.wrong .mark { background: var(--ng); border-color: var(--ng); color: #fff; }
.choice:disabled { cursor: default; }

.st-row { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 2px solid var(--line); border-radius: 12px; }
.st-row.correct { border-color: var(--ok); background: var(--ok-weak); }
.st-row.wrong { border-color: var(--ng); background: var(--ng-weak); }
.st-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.yn-group { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
.yn-group .verdict { grid-column: 1 / -1; }
.yn-group .verdict:empty { display: none; }
.pv-verdicts { display: flex; }
.yn {
  min-width: 0; min-height: 44px; border-radius: 10px; cursor: pointer; font: inherit; font-weight: 600;
  border: 2px solid var(--line); background: var(--card); color: var(--text);
}
.yn.selected { border-color: var(--accent); background: var(--accent); color: var(--accent-text); }
.yn.is-answer { box-shadow: 0 0 0 3px var(--ok); }
.yn:disabled { cursor: default; }
.verdict { font-weight: 700; font-size: 0.92rem; }
.verdict.ok { color: var(--ok-text); }
.verdict.ng { color: var(--ng); }

.order-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; counter-reset: o; }
.order-list li {
  counter-increment: o; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border: 2px solid var(--line); border-radius: 12px; background: var(--card);
}
.order-list li::before {
  content: counter(o); flex: 0 0 auto; width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center;
  background: var(--bg); border: 1px solid var(--line); font-weight: 700; font-size: 0.85rem; color: var(--muted);
}
.order-list li.correct { border-color: var(--ok); background: var(--ok-weak); }
.order-list li.wrong { border-color: var(--ng); background: var(--ng-weak); }
.order-list .ctext { flex: 1 1 auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.order-list .mv { display: flex; gap: 6px; }
.correct-order { background: var(--bg); border-radius: 12px; padding: 12px 16px; }
.correct-order ol { margin: 6px 0 0; padding-left: 1.4em; }

.match-row { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 2px solid var(--line); border-radius: 12px; }
.match-row.correct { border-color: var(--ok); background: var(--ok-weak); }
.match-row.wrong { border-color: var(--ng); background: var(--ng-weak); }
.match-left { font-weight: 600; white-space: pre-wrap; overflow-wrap: anywhere; }

.banner { padding: 12px 16px; border-radius: 12px; font-weight: 700; }
.banner.ok { background: var(--ok-weak); color: var(--ok-text); }
.banner.ng { background: var(--ng-weak); color: var(--ng); }
.explain { white-space: pre-wrap; overflow-wrap: anywhere; }
.score { font-size: 2.4rem; font-weight: 800; line-height: 1.2; }
.progress-line { display: flex; align-items: center; gap: 12px; }
.progress-line .bar { flex: 1 1 auto; }
.flag { font-size: 1.2rem; line-height: 1; }
.flag.on { color: var(--warn); }

/* ---- misc ---- */
details > summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.login { max-width: 460px; margin: 6vh auto 0; }
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px);
  background: #1d2433; color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 0.92rem;
  opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 50; max-width: 92vw; text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.ok { background: #067647; }
.toast.ng { background: #b42318; }

@media (min-width: 640px) {
  .match-row { flex-direction: row; align-items: center; }
  .match-row .match-left { flex: 1 1 45%; }
  .match-row .match-right { flex: 1 1 55%; }
  .st-row { flex-direction: row; align-items: center; justify-content: space-between; }
  .st-row .st-text { flex: 1 1 auto; }
  .yn-group { flex: none; grid-template-columns: 96px 96px; }
  .pv-verdicts { flex: none; justify-content: flex-end; }
}

/* ---- 画像 ---- */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 96px; height: 96px; border-radius: 10px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.thumb-del {
  position: absolute; top: 4px; right: 4px; width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  border: 0; background: rgba(15, 18, 32, 0.72); color: #fff; font: inherit; line-height: 1;
}
.qimgs { display: flex; flex-direction: column; gap: 10px; }
.qimg { display: block; max-width: 100%; height: auto; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; }
.overlay { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 16px; background: rgba(15, 18, 32, 0.78); }
.lightbox { cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; }

/* ---- テーマ切り替えボタン ---- */
.topbar-actions { display: flex; align-items: center; gap: 4px; }
#theme-toggle { width: 36px; height: 36px; border-radius: 999px; font-size: 1.1rem; line-height: 1; }

/* 問題プレビュー */
.choice.pv { cursor: default; }

.pv-pairs { display: flex; flex-direction: column; gap: 8px; }
.pv-pair { display: grid; grid-template-columns: 1fr; gap: 4px; padding: 12px 14px; border: 2px solid var(--line); border-radius: 12px; text-align: left; }
.pv-pair.correct { border-color: var(--ok); background: var(--ok-weak); }
.pv-pair .pv-l { font-weight: 700; overflow-wrap: anywhere; }
.pv-pair .pv-r { overflow-wrap: anywhere; padding-left: 12px; border-left: 3px solid var(--line); }
.pv-pair.correct .pv-r { color: var(--text); font-weight: 600; border-left-color: var(--ok); }
.pv-pair .pv-arrow { display: none; color: var(--ok-text); font-size: 1.4rem; font-weight: 800; line-height: 1; }
.pv-pair:not(.correct) .pv-arrow { color: var(--muted); }
.pv-pool { margin-top: 4px; padding: 10px 14px; border: 1px dashed var(--line); border-radius: 12px; }
.pv-pool-title { font-size: 0.82rem; font-weight: 700; color: var(--muted); margin-bottom: 4px; }
.pv-pool ul { margin: 0; padding-left: 1.2em; color: var(--muted); font-size: 0.92rem; }
.pv-pool li { margin: 2px 0; }
.pv-pool li small { margin-left: 8px; padding: 1px 6px; border-radius: 999px; border: 1px solid var(--line); font-size: 0.75rem; }
@media (min-width: 640px) {
  .pv-pair { grid-template-columns: minmax(0, 1fr) auto minmax(0, 3fr); align-items: center; gap: 16px; }
  .pv-pair .pv-arrow { display: block; }
  .pv-pair .pv-r { padding-left: 0; border-left: 0; }
}

/* 正解バッジ（緑の文字ではなく、塗りつぶしのバッジ＋通常色の文字で読みやすく） */
.ans-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; background: var(--badge-bg); color: var(--badge-fg); font-weight: 800; font-size: 0.85rem; white-space: nowrap; }
.pv-r .ans-badge { margin-right: 8px; }
.pv-explain-note { color: var(--text); }

.ans-badge.ng { background: var(--ng-badge-bg); color: var(--ng-badge-fg); }
.badges { display: inline-flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.choice.pv.wrong .ctext { color: var(--text); }
.pv-pool ul { list-style: none; padding-left: 0; }
.pv-pool li { display: flex; align-items: flex-start; gap: 8px; color: var(--text); }
.pv-pool li .ans-badge { flex: none; padding: 0 8px; }
.pv-pool li.extra { color: var(--text); }

/* ブランド（アイコン + 名前） */
.brand { display: inline-flex; align-items: center; gap: 8px; }
.brand-icon { width: 28px; height: 28px; border-radius: 7px; display: block; }
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.login-brand img { border-radius: 16px; box-shadow: 0 2px 8px rgba(67, 56, 202, .35); }

/* ===== アニメーション（「視覚効果を減らす」設定の端末では無効） ===== */
@media (prefers-reduced-motion: no-preference) {
  /* 画面の切り替え */
  @keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
  @keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.12); } 100% { transform: scale(1); } }
  @keyframes shake { 0%, 100% { transform: none; } 20% { transform: translateX(-6px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(3px); } }
  @keyframes slide-in { from { opacity: 0; transform: translateY(-8px) scale(.98); } to { opacity: 1; transform: none; } }
  @keyframes fade { from { opacity: 0; } to { opacity: 1; } }
  @keyframes zoom-in { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
  @keyframes bar-grow { from { width: 0; } }
  @keyframes spin-once { to { transform: rotate(360deg); } }

  #app > * { animation: rise .28s ease-out backwards; }
  #app > .stack > *, #app > .card.stack > *, .stack-sm > .card { animation: rise .32s ease-out backwards; }
  #app > .stack > :nth-child(2) { animation-delay: .03s; }
  #app > .stack > :nth-child(3) { animation-delay: .06s; }
  #app > .stack > :nth-child(4) { animation-delay: .09s; }
  #app > .stack > :nth-child(5) { animation-delay: .12s; }
  #app > .stack > :nth-child(n+6) { animation-delay: .15s; }

  /* ボタン・カード・チップ */
  .btn, button.chip, .yn, .choice, .icon-btn, .topbar nav a, .qitem { transition: background-color .18s, border-color .18s, color .18s, transform .12s, box-shadow .18s; }
  .btn:active, button.chip:active, .yn:active, .icon-btn:active { transform: scale(.96); }
  .choice:not(:disabled):not(.pv):active { transform: scale(.985); }
  .btn:hover:not(:disabled), .qitem:hover { transform: translateY(-1px); }
  .qitem:hover { background: var(--accent-weak); }
  button.chip.on, .yn.selected, .choice.selected { animation: pop .25s ease-out; }

  /* 採点の演出 */
  .choice.correct, .choice.missed, .st-row.correct, .match-row.correct, .order-list li.correct { animation: pop .35s ease-out; }
  .choice.wrong, .st-row.wrong, .match-row.wrong, .order-list li.wrong { animation: shake .4s ease-out; }
  .banner { animation: slide-in .3s ease-out backwards; }
    .verdict:not(:empty) { animation: fade .3s ease-out backwards; }
  .flag.pop { animation: pop .3s ease-out; }

  /* 進捗バー・ダイアログ */
  .bar > i { transition: width .45s cubic-bezier(.4, 0, .2, 1); }
  .bar.ok > i { animation: bar-grow .7s cubic-bezier(.4, 0, .2, 1) backwards; }
  .progress-line .bar > i { animation: none; }
  .overlay { animation: fade .18s ease-out backwards; }
  .overlay > * { animation: zoom-in .22s ease-out backwards; }
  #theme-toggle.spin { animation: spin-once .5s ease-in-out; }

  /* テーマ切り替え: 対応ブラウザでは画面全体がクロスフェードする */
  html.vt-theme::view-transition-old(root), html.vt-theme::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
  html.vt-theme::view-transition-old(root) { z-index: 1; }
  html.vt-theme::view-transition-new(root) { z-index: 2; }
  /* 非対応ブラウザ: 色をなめらかに変える */
  html.theme-fade, html.theme-fade *, html.theme-fade *::before, html.theme-fade *::after {
    transition: background-color .4s ease, color .4s ease, border-color .4s ease, box-shadow .4s ease, fill .4s ease, stroke .4s ease !important;
  }
}

/* ドラッグ&ドロップ並べ替え */
.drag-handle { flex: none; display: grid; place-items: center; width: 28px; height: 36px; color: var(--muted); font-size: 1.3rem; line-height: 1; cursor: grab; touch-action: none; user-select: none; border-radius: 8px; }
.drag-handle:hover { color: var(--text); background: var(--accent-weak); }
.order-list li.sortable { cursor: grab; user-select: none; -webkit-user-select: none; }
.order-list li.sortable .mv { align-items: center; }
.order-row { display: flex; align-items: center; gap: 8px; }
.sorting, .sorting * { cursor: grabbing !important; }
.dragging { position: relative; z-index: 5; opacity: .95; box-shadow: 0 10px 24px rgba(16, 24, 40, .28); border-color: var(--accent) !important; background: var(--accent-weak) !important; transition: none !important; animation: none !important; }
.sorting > :not(.dragging) { transition: none; }

/* ---- 原文(英語)切替 ---- */
.lang-toggle { display: inline-flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--bg); }
.lang-btn { border: 0; background: transparent; color: var(--muted); font: inherit; font-size: 0.82rem; padding: 5px 12px; cursor: pointer; min-height: 32px; transition: background-color 0.18s, color 0.18s; }
.lang-btn.on { background: var(--accent); color: var(--accent-text); font-weight: 600; }
.lang-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.hide-explain .explain-card { display: none; }
.qhead { gap: 8px; }
.qhead .row.nowrap { align-items: center; }
.en-flag { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; cursor: pointer; }
.en-flag input { width: 20px; height: 20px; accent-color: var(--accent); }
.row-group { display: grid; gap: 6px; }
.row-group + .row-group { margin-top: 0; }
.en-input { border-style: dashed; margin-left: 30px; width: calc(100% - 30px); font-size: 0.95rem; }
.en-pair { margin-left: 0; }
.en-pair .en-input { margin-left: 0; width: auto; }
.en-pair .pair-arrow::before { content: '→'; visibility: hidden; }
.icon-btn-gap { flex: 0 0 40px; }
.order-row + .en-input { margin-left: 56px; width: calc(100% - 56px); }
