/* 問いボード
   カメラに写る収録画面なので明るい地に固定。番組資料（One Hour）の白・墨・金に合わせ、
   金は「番号・見出し」だけに使う。数字と英字は Geist、日本語は Zen Kaku Gothic New。 */
:root {
  --bg: #edeff2;
  --bg-deep: #e3e6eb;
  --surface: #ffffff;
  --ink: #0f1013;
  --ink-2: #33363e;
  --sub: #767a86;
  --hair: rgba(15, 16, 19, .08);
  --hair-2: rgba(15, 16, 19, .16);
  --gold: #b8892a;
  --gold-ink: #8a6519;
  --gold-soft: #f4ecda;
  --danger: #a8352d;
  --pen: #111216;

  --jp: "Zen Kaku Gothic New", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", Meiryo, sans-serif;
  --latin: "Geist", var(--jp);

  --r-s: 10px;
  --r-m: 14px;
  --r-l: 22px;
  --lift: 0 1px 2px rgba(15, 16, 19, .04), 0 12px 32px -20px rgba(15, 16, 19, .28);
  --lift-hi: 0 2px 4px rgba(15, 16, 19, .05), 0 24px 48px -24px rgba(15, 16, 19, .32);
  --ease: cubic-bezier(.2, .7, .1, 1);
  /* 出演者が見る画面（一覧・答える画面）の大きさの単位。iPad の横（1366×1024）で 1px、
     大きい画面ほど比例して大きくなる（4K で約 2.1px・上限 2.6px）。
     数字の枠は画面から計算しているので、文字やボタンもこれで揃えて大きくする */
  --u: clamp(1px, calc(min(100vw, 133.33vh) / 1366), 2.6px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: var(--bg); color: var(--ink);
  font-family: var(--latin); font-size: 15px; line-height: 1.6;
  -webkit-font-smoothing: antialiased; font-feature-settings: "palt" 1;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-appearance: none; appearance: none; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.screen {
  position: fixed; inset: 0;
  padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
}
.board, .answer:not(.pv-screen) { padding: max(calc(20 * var(--u)), env(safe-area-inset-top)) max(calc(20 * var(--u)), env(safe-area-inset-right)) max(calc(20 * var(--u)), env(safe-area-inset-bottom)) max(calc(20 * var(--u)), env(safe-area-inset-left)); }
.eyebrow {
  font-family: "Geist", var(--jp); font-weight: 500; font-size: 12px;
  letter-spacing: .24em; text-transform: uppercase; color: var(--sub);
}
.eyebrow.gold { color: var(--gold-ink); }
.answer .eyebrow { font-size: calc(14 * var(--u)); }
.label { font-family: var(--jp); font-size: 12px; font-weight: 700; letter-spacing: .06em; color: var(--sub); }
.hint { color: var(--sub); font-size: 13px; line-height: 1.7; }

/* ---------- ボタン ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 56px; padding: 0 22px; border-radius: var(--r-m); cursor: pointer;
  border: 1px solid var(--hair-2); background: var(--surface); color: var(--ink);
  font-family: var(--jp); font-weight: 700; font-size: 16px; letter-spacing: .02em; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .1s, opacity .15s;
  touch-action: manipulation;
}
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: scale(.97); }
.btn.ghost { background: transparent; }
.btn.ghost:hover { background: rgba(15, 16, 19, .04); }
.btn.solid { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn.solid:hover { background: #24262c; }
.btn.wide { min-width: 168px; }
.btn.small { height: 40px; padding: 0 14px; font-size: 14px; border-radius: var(--r-s); gap: 6px; }
.btn.danger { color: var(--danger); }
.btn.danger:hover { border-color: var(--danger); background: rgba(168, 53, 45, .05); }
.btn:disabled { opacity: .28; pointer-events: none; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.btn.small .ic { width: 16px; height: 16px; }
.ic.rec { fill: #d23c32; stroke: none; }

.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--bg-deep); }
.seg button {
  height: 36px; padding: 0 14px; border: 0; border-radius: 9px; background: transparent; cursor: pointer;
  font-family: var(--jp); font-weight: 700; font-size: 13px; color: var(--sub); transition: background .15s, color .15s;
}
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 16, 19, .1); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }

/* ---------- 一覧 ---------- */
/* 見出しと数字の枠を **ひとまとまりとして画面の中央に置く**（見出しを上に固定すると、枠が画面を
   埋めきれないときに見出しと枠の間が大きく空く）。間は画面の大きさに合わせて空け、
   見出しの幅は枠の並びの幅に合わせて左端をそろえる（layoutBoard が幅を入れる） */
.board { display: flex; flex-direction: column; justify-content: center; gap: calc(28 * var(--u)); }
.board-head { padding: 0; display: grid; gap: calc(8 * var(--u)); align-self: center; max-width: 100%; }
.board-head .eyebrow { font-size: calc(13 * var(--u)); }
.board-title { font-family: var(--jp); font-weight: 700; font-size: calc(32 * var(--u)); letter-spacing: .02em; line-height: 1.3; }
.board-stage { flex: none; display: grid; place-items: center; }
.grid { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; }
/* **押せる範囲は角まで含む四角（.tile）、見た目の枠は中の .tile-card。**
   押したときに縮めるのは見た目だけにする —— ボタンごと縮めると、角の近くを押したとき
   指を離す位置が枠の外になり、押したことにならない（20 問で 01 の左上が押せなかった） */
.tile {
  position: relative; padding: 0; cursor: pointer; background: transparent; border: 0; border-radius: 0;
  touch-action: manipulation;
}
.tile-card {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
  background: var(--surface); border: 1px solid var(--hair); border-radius: var(--tile-r, 18px);
  box-shadow: var(--lift); transition: transform .18s var(--ease), box-shadow .18s var(--ease);
}
.tile:hover .tile-card { box-shadow: var(--lift-hi); }
.tile:active .tile-card { transform: scale(.97); }
.tile:focus-visible { outline: none; }
.tile:focus-visible .tile-card { outline: 2px solid var(--gold); outline-offset: 3px; }
.tile-no {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: "Geist", var(--jp); font-weight: 300; font-size: var(--no-size, 40px);
  font-variant-numeric: tabular-nums; letter-spacing: -.01em; color: var(--ink-2);
  transition: opacity .25s;
}
.tile-ink { position: absolute; inset: 0; width: 100%; height: 100%; }
.tile.answered .tile-no { opacity: 0; }
.board-empty { text-align: center; font-family: var(--jp); font-weight: 500; color: var(--sub); line-height: 2; }
/* 左上の隅を押し続けている間だけ出る輪（触れても何もしない。押した指は下の番号へそのまま届く）。
   短く押したときに見えないよう、0.3 秒たってから出す */
.staff-hot { position: absolute; left: 0; top: 0; width: calc(96 * var(--u)); height: calc(96 * var(--u)); display: grid; place-items: center; pointer-events: none; z-index: 2; }
.staff-hot svg { width: calc(44 * var(--u)); height: calc(44 * var(--u)); opacity: 0; transform: rotate(-90deg); }
.staff-hot circle { fill: rgba(255, 255, 255, .85); stroke: var(--gold); stroke-width: 3; stroke-dasharray: 101; stroke-dashoffset: 101; }
.staff-hot.holding svg { opacity: 1; transition: opacity .15s .3s; }
.staff-hot.holding circle { stroke-dashoffset: 0; transition: stroke-dashoffset 1.5s linear .3s; }

/* ---------- 答える画面 ---------- */
.answer { background: var(--bg); }
.answer-inner { height: 100%; display: flex; flex-direction: column; gap: calc(18 * var(--u)); }
/* 答える画面のボタンも画面に合わせて大きくする（編集室のボタンは据え置き） */
.answer .btn { height: calc(56 * var(--u)); padding: 0 calc(22 * var(--u)); border-radius: calc(14 * var(--u)); font-size: calc(17 * var(--u)); gap: calc(8 * var(--u)); }
.answer .btn.wide { min-width: calc(168 * var(--u)); }
.answer .btn.small { height: calc(42 * var(--u)); padding: 0 calc(15 * var(--u)); border-radius: calc(10 * var(--u)); font-size: calc(14 * var(--u)); gap: calc(6 * var(--u)); }
.answer .ic { width: calc(20 * var(--u)); height: calc(20 * var(--u)); }
.answer .btn.small .ic { width: calc(16 * var(--u)); height: calc(16 * var(--u)); }
.answer-bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: calc(16 * var(--u)); }
.answer-bar > :first-child { justify-self: start; }
.answer-bar > :last-child { justify-self: end; }
.answer-q { padding: 0 calc(4 * var(--u)); }
.pad-tools { display: flex; justify-content: flex-end; gap: calc(8 * var(--u)); margin-bottom: calc(-9 * var(--u)); }
.q-text {
  font-family: var(--jp); font-weight: 700; line-height: 1.5; letter-spacing: .02em;
  font-size: 40px; max-height: 26vh; overflow: hidden; white-space: pre-wrap; overflow-wrap: anywhere; text-wrap: pretty;
}
.pad {
  flex: 1; min-height: 0; position: relative; overflow: hidden;
  background: var(--surface); border-radius: calc(22 * var(--u)); border: 1px solid var(--hair); box-shadow: var(--lift);
}
.pad.dots {
  background-image: radial-gradient(circle at center, rgba(15, 16, 19, .13) calc(1.1 * var(--u)), transparent calc(1.6 * var(--u)));
  background-size: calc(32 * var(--u)) calc(32 * var(--u)); background-position: center;
}
.pad canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.pad-hint {
  position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none;
  font-family: var(--jp); font-weight: 500; font-size: calc(20 * var(--u)); letter-spacing: .08em; color: rgba(15, 16, 19, .26);
  transition: opacity .3s;
}
.pad-hint.nudge { color: var(--gold-ink); animation: nudge .5s var(--ease); }
@keyframes nudge { 30% { transform: translateX(-6px); } 60% { transform: translateX(5px); } }

/* ---------- 編集室 ---------- */
.studio { background: var(--bg); display: flex; flex-direction: column; gap: 18px; padding-top: max(14px, env(safe-area-inset-top)); -webkit-user-select: text; user-select: text; }
.st-top { display: flex; align-items: center; gap: 16px 24px; flex-wrap: wrap; }
.brand { display: flex; align-items: baseline; gap: 10px; }
.brand-mark { width: 10px; height: 10px; border-radius: 3px; background: var(--gold); align-self: center; }
.brand-name { font-family: var(--jp); font-weight: 700; font-size: 17px; letter-spacing: .04em; }
.brand-sub { font-size: 12px; color: var(--sub); letter-spacing: .12em; }
.tabs { display: flex; gap: 4px; padding: 4px; background: var(--bg-deep); border-radius: 12px; margin-inline: auto; }
.tabs button { height: 36px; padding: 0 22px; border: 0; border-radius: 9px; background: transparent; cursor: pointer; font-family: var(--jp); font-weight: 700; font-size: 14px; color: var(--sub); }
.tabs button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(15, 16, 19, .1); }
.st-top-r { display: flex; align-items: center; gap: 14px; }
.st-top-r .btn { height: 44px; font-size: 14px; }
.saved { font-size: 12px; color: var(--sub); min-width: 7em; text-align: right; transition: opacity .4s; }

.st-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 220px minmax(0, 1fr) 340px; gap: 18px; }
.st-body.single { display: block; overflow: auto; }
.sets, .editor, .preview, .st-body.single { min-height: 0; overflow: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.sets { display: flex; flex-direction: column; gap: 12px; padding: 6px 2px; }
#setNewBtn { justify-content: flex-start; }
.file-btn { position: relative; overflow: hidden; }
.file-input { position: absolute; inset: 0; opacity: 0; cursor: pointer; font-size: 0; }
/* セットの一覧：**セットを 1 つずつ離した、同じ形のカード**にする。選んでいるカードは濃い枠とチェックで示す。
   （選んでいるものだけカードにすると、ほかが押せるものに見えない。1 つの箱に区切り線で並べると、
   2 つのセットが 1 枚のカードの中身のようにつながって見える） */
.set-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.set-item {
  width: 100%; text-align: left; display: flex; align-items: center; justify-content: space-between; gap: 10px;
  min-height: 60px; padding: 10px 12px 10px 14px; cursor: pointer;
  border: 1px solid var(--hair); border-radius: var(--r-m); background: var(--surface); box-shadow: var(--lift);
  transition: border-color .15s, box-shadow .15s;
}
.set-item:hover { border-color: var(--hair-2); }
.set-item[aria-current="true"] { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink), var(--lift); }
.set-item-main { display: grid; gap: 2px; min-width: 0; }
.set-check { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--ink); stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.set-item[aria-current="true"] .set-check { opacity: 1; }
.set-item-name { font-family: var(--jp); font-weight: 700; font-size: 14px; line-height: 1.45; overflow-wrap: anywhere; }
.set-item-name.untitled { color: var(--sub); font-weight: 500; }
.set-add { height: 48px; font-size: 14px; }
/* 主な操作（新しいセット）の下に置く、控えめな文字のボタン */
.link-btn {
  display: flex; align-items: center; justify-content: center; gap: 6px; height: 40px; border-radius: var(--r-s); cursor: pointer;
  font-family: var(--jp); font-weight: 700; font-size: 13px; color: var(--sub);
}
.link-btn:hover { color: var(--ink); background: rgba(15, 16, 19, .04); }
.link-btn .ic { width: 15px; height: 15px; }
.link-btn:focus-within { outline: 2px solid var(--gold); outline-offset: 2px; }
.set-item-meta { display: flex; gap: 8px; align-items: center; font-size: 12px; color: var(--sub); font-variant-numeric: tabular-nums; }
.dot-live { width: 7px; height: 7px; border-radius: 50%; background: var(--gold); }

.editor { background: var(--surface); border-radius: var(--r-l); border: 1px solid var(--hair); box-shadow: var(--lift); padding: 22px 22px 26px; display: flex; flex-direction: column; gap: 16px; }
.ed-head { display: grid; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--hair); }
.ed-title { display: flex; align-items: center; gap: 10px; }
.ed-title .icon-btn { flex: none; }
/* 名前はそのまま書き換えられる。選んだときは下線で示す（四角の囲みは横にはみ出して上下の線だけが見えた） */
.title-input { flex: 1; min-width: 0; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 4px 0; font-family: var(--jp); font-weight: 700; font-size: 24px; letter-spacing: .02em; background: transparent; transition: border-color .15s; }
.title-input:hover { border-bottom-color: var(--hair); }
.title-input:focus, .title-input:focus-visible { outline: none; border-bottom-color: var(--gold); }
.title-input::placeholder { color: var(--hair-2); }
.ed-meta { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; }
.ed-meta:not(:has(#setUseBtn:not([hidden]))) .ed-meta-l:empty { display: none; }
.ed-meta-l, .ed-meta-r { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.sep { width: 1px; height: 22px; background: var(--hair-2); margin: 0 4px; }
.ed-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; padding-top: 4px; }
.ed-fields input { font-size: 15px; padding: 9px 12px; }
.ql-head { position: sticky; top: -22px; z-index: 3; display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin: -6px -22px 0; padding: 10px 22px; background: var(--surface); }
/* 欄の中身があふれても、行やボタンを押しつぶさない（縦に並べた子は縮ませない） */
.sets > *, .editor > *, .preview > * { flex-shrink: 0; }
.q-add {
  display: flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 56px; padding: 0 14px; cursor: pointer;
  border: 1.5px dashed var(--hair-2); border-radius: var(--r-s); background: transparent; color: var(--sub);
  font-family: var(--jp); font-weight: 700; font-size: 14px; transition: border-color .15s, color .15s, background .15s;
}
.q-add:hover { border-color: var(--ink-2); color: var(--ink); background: #f7f8fa; }
.count { font-family: "Geist", var(--jp); font-size: 13px; color: var(--sub); font-variant-numeric: tabular-nums; margin-right: 6px; }
.badge { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border-radius: 99px; background: var(--gold-soft); color: var(--gold-ink); font-size: 12px; font-weight: 700; }
.badge i { width: 6px; height: 6px; border-radius: 50%; background: var(--gold); }

.qlist { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.qrow {
  display: grid; grid-template-columns: 22px 34px minmax(0, 1fr) auto; align-items: start; gap: 8px;
  padding: 8px 6px; border-radius: var(--r-s); background: var(--surface); transition: background .15s, box-shadow .15s;
}
.qrow:hover, .qrow:focus-within { background: #f7f8fa; }
.qrow.dragging { box-shadow: var(--lift-hi); background: var(--surface); position: relative; z-index: 2; }
.qhandle { width: 22px; height: 34px; display: grid; place-items: center; cursor: grab; touch-action: none; color: var(--hair-2); }
.qhandle:hover { color: var(--sub); }
.qhandle svg { width: 12px; height: 18px; fill: currentColor; }
.qno { font-family: "Geist", var(--jp); font-weight: 400; font-size: 14px; color: var(--gold-ink); font-variant-numeric: tabular-nums; line-height: 34px; text-align: right; padding-right: 4px; }
.qtext {
  width: 100%; resize: none; border: 0; background: transparent; padding: 5px 2px; overflow: hidden;
  font-family: var(--jp); font-weight: 500; font-size: 16px; line-height: 1.6; color: var(--ink);
}
.qtext::placeholder { color: rgba(15, 16, 19, .25); }
.qtools { display: flex; gap: 2px; align-items: center; height: 34px; }
.qmark { font-size: 11px; color: var(--gold-ink); background: var(--gold-soft); border-radius: 99px; padding: 2px 8px; white-space: nowrap; }
.qdel { width: 32px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--sub); cursor: pointer; display: grid; place-items: center; opacity: .5; }
.qrow:hover .qdel, .qrow:focus-within .qdel { opacity: 1; }
.qdel:hover { background: rgba(168, 53, 45, .08); color: var(--danger); }
.qdel .ic { width: 16px; height: 16px; }
.qempty { padding: 28px 8px; text-align: center; color: var(--sub); font-size: 14px; }
.ed-add { display: flex; flex-wrap: wrap; gap: 8px; padding-top: 4px; }

.preview { display: flex; flex-direction: column; gap: 12px; padding: 6px 2px; }
.pv-box { position: relative; overflow: hidden; border-radius: 12px; border: 1px solid var(--hair); box-shadow: var(--lift); background: var(--bg); }
.pv-screen { position: absolute; left: 0; top: 0; transform-origin: 0 0; pointer-events: none; }
.pv-screen .btn { pointer-events: none; }
.pv-note { font-size: 13px; line-height: 1.7; color: var(--sub); min-height: 1.7em; }
.pv-note.warn { color: var(--gold-ink); }
.pv-grid { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; align-content: center; padding: 14px; border-radius: 12px; background: var(--bg-deep); aspect-ratio: 16 / 10; }
.pv-grid i { display: grid; place-items: center; background: var(--surface); border-radius: 4px; font-style: normal; font-family: "Geist", var(--jp); font-weight: 300; color: var(--sub); }
.pv-grid i.on { outline: 1.5px solid var(--gold); outline-offset: 1px; color: var(--ink); }

/* 回答タブ */
.ans-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; padding: 6px 2px 18px; }
.ans-count { font-family: var(--jp); font-weight: 700; font-size: 22px; margin-top: 4px; }
.ans-count b { font-family: "Geist", var(--jp); font-weight: 500; font-variant-numeric: tabular-nums; }
.ans-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; padding-bottom: 24px; }
.ans-card { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-m); box-shadow: var(--lift); overflow: hidden; display: flex; flex-direction: column; }
.ans-thumb { aspect-ratio: 3 / 2; width: 100%; display: block; background: var(--surface); border-bottom: 1px solid var(--hair); }
.ans-thumb.none { display: grid; place-items: center; color: var(--hair-2); font-family: "Geist", var(--jp); font-weight: 300; font-size: 36px; background: #f7f8fa; }
.ans-body { padding: 12px 14px 14px; display: grid; gap: 8px; flex: 1; align-content: start; }
.ans-q { font-family: var(--jp); font-weight: 500; font-size: 13px; line-height: 1.6; color: var(--ink-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.ans-acts { display: flex; gap: 6px; margin-top: auto; }
.ans-empty { padding: 60px 0; text-align: center; color: var(--sub); }
.save-slot { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; padding: 14px 16px; margin-bottom: 18px; border-radius: var(--r-m); background: var(--gold-soft); color: var(--gold-ink); font-size: 14px; font-weight: 600; }

/* 設定タブ */
.settings { max-width: 760px; margin: 0 auto; display: grid; gap: 18px; padding-bottom: 32px; }
.set-sec { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-l); box-shadow: var(--lift); padding: 22px 24px; display: grid; gap: 16px; }
.set-sec h3 { font-family: var(--jp); font-size: 17px; font-weight: 700; }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 16px 24px; flex-wrap: wrap; padding-top: 16px; border-top: 1px solid var(--hair); }
.set-sec h3 + .set-row, .set-sec h3 + [hidden] + .set-row { border-top: 0; padding-top: 0; }
.set-row > div:first-child { flex: 1 1 280px; min-width: 0; display: grid; gap: 4px; }
.set-name { font-family: var(--jp); font-weight: 700; font-size: 15px; }
.steps { margin: 6px 0 4px; padding-left: 1.4em; display: grid; gap: 4px; font-size: 14px; line-height: 1.7; color: var(--ink-2); }
.steps strong { color: var(--ink); }
.sample { width: 100%; max-width: 360px; height: 64px; display: block; margin-top: 6px; border-radius: var(--r-s); background: var(--bg); }
.field { display: grid; gap: 6px; font-size: 13px; color: var(--sub); }
.field input, .field textarea {
  border: 1px solid var(--hair-2); border-radius: var(--r-s); padding: 11px 14px; background: var(--surface); color: var(--ink);
  font-family: var(--jp); font-size: 16px; line-height: 1.6; -webkit-user-select: text; user-select: text;
}
.field input:focus, .field textarea:focus { border-color: var(--ink-2); }
.field input:focus-visible, .field textarea:focus-visible { outline: none; border-color: var(--ink-2); box-shadow: 0 0 0 3px var(--gold-soft); }
/* 問いの欄は、行の地の色で選んでいることを示す */
.qtext:focus-visible { outline: none; }
.qrow:focus-within { background: #f3f4f7; }
.qrow:focus-within .qno { color: var(--gold); }
.field textarea { resize: vertical; min-height: 200px; }
.switch { position: relative; width: 52px; height: 32px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; border-radius: 99px; background: var(--bg-deep); transition: background .2s; }
.switch span::after { content: ""; position: absolute; left: 3px; top: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(15, 16, 19, .2); transition: transform .2s var(--ease); }
.switch input:checked + span { background: var(--ink); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 2px solid var(--gold); outline-offset: 3px; }

/* ---------- 再生 ---------- */
.replay { background: var(--bg); display: flex; flex-direction: column; gap: 16px; }
.rp-top { display: flex; align-items: center; gap: 20px; }
.rp-q { display: grid; gap: 4px; flex: 1; min-width: 0; }
.rp-text { font-family: var(--jp); font-weight: 700; font-size: 20px; line-height: 1.5; }
.rp-stage { flex: 1; min-height: 0; display: grid; place-items: center; }
.rp-stage canvas { background: #fff; border-radius: var(--r-l); box-shadow: var(--lift); border: 1px solid var(--hair); }
.rp-foot { display: grid; gap: 12px; }
.rp-controls { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; }
.rp-controls > :first-child { justify-self: start; }
.rp-controls > :last-child { justify-self: end; }
.btn.play { min-width: 160px; }
.rp-status { text-align: center; min-height: 1.7em; }
.rp-bar { height: 3px; border-radius: 3px; background: var(--bg-deep); overflow: hidden; }
.rp-bar i { display: block; height: 100%; width: 0; background: var(--gold); }

/* ---------- 重ねる画面 ---------- */
.overlay { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 20px; background: rgba(15, 16, 19, .38); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); -webkit-user-select: text; user-select: text; }
.sheet { width: min(860px, 100%); max-height: calc(100vh - 40px); max-height: calc(100dvh - 40px); display: flex; flex-direction: column; gap: 14px; padding: 18px 20px 20px; border-radius: var(--r-l); background: var(--surface); box-shadow: var(--lift-hi); }
.sheet.narrow { width: min(620px, 100%); }
.sheet-head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--hair); }
.sheet-head > :first-child { justify-self: start; }
.sheet-head > :last-child { justify-self: end; }
.sheet-head h2 { font-family: var(--jp); font-size: 17px; font-weight: 700; text-align: center; }
.sheet-status { text-align: center; min-height: 1.7em; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips button { height: 34px; padding: 0 14px; border-radius: 99px; border: 1px solid var(--hair-2); background: transparent; font-family: var(--jp); font-weight: 700; font-size: 13px; color: var(--ink-2); cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: #fff; }
.lib-list { list-style: none; margin: 0 -8px; padding: 0 8px; overflow-y: auto; min-height: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; overscroll-behavior: contain; -webkit-overflow-scrolling: touch; touch-action: pan-y; }
.lib-list li { flex: none; }
.lib-item { width: 100%; display: grid; grid-template-columns: 24px minmax(0, 1fr) auto; gap: 12px; align-items: center; text-align: left; padding: 12px 14px; border-radius: var(--r-s); border: 1px solid transparent; background: transparent; cursor: pointer; }
.lib-item:hover { background: #f7f8fa; }
.lib-item[aria-pressed="true"] { background: var(--gold-soft); border-color: rgba(184, 137, 42, .3); }
.lib-check { width: 22px; height: 22px; border-radius: 7px; border: 1.5px solid var(--hair-2); display: grid; place-items: center; }
.lib-item[aria-pressed="true"] .lib-check { background: var(--ink); border-color: var(--ink); }
.lib-check svg { width: 14px; height: 14px; fill: none; stroke: #fff; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; opacity: 0; }
.lib-item[aria-pressed="true"] .lib-check svg { opacity: 1; }
.lib-text { font-family: var(--jp); font-weight: 500; font-size: 15px; line-height: 1.6; }
.lib-cat { font-size: 11px; color: var(--sub); letter-spacing: .08em; }
.lib-item.added { opacity: .45; cursor: default; }

.modal-box { width: min(460px, 100%); display: grid; gap: 10px; padding: 26px; border-radius: var(--r-l); background: var(--surface); box-shadow: var(--lift-hi); }
.modal-msg { font-family: var(--jp); font-weight: 700; font-size: 18px; line-height: 1.6; }
.modal-box .row { margin-top: 12px; }
.pass-input { font-family: "Geist", ui-monospace, Menlo, monospace !important; font-size: 18px !important; letter-spacing: .08em; text-transform: uppercase; }
.hint.err { color: var(--danger); min-height: 1.7em; }
.sync-chip { height: 30px; padding: 0 12px; border-radius: 99px; border: 1px solid var(--hair-2); background: var(--surface); font-family: var(--jp); font-size: 12px; font-weight: 700; color: var(--sub); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.sync-chip::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--sub); }
.sync-chip.ok::before { background: #2f8f5b; }
.sync-chip.wait::before { background: var(--gold); }
.sync-chip.err::before { background: var(--danger); }
.modal-box .btn.solid.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.toast {
  position: fixed; left: 50%; bottom: max(28px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 30;
  padding: 12px 20px; border-radius: 12px; background: var(--ink); color: #fff;
  font-family: var(--jp); font-weight: 500; font-size: 14px; max-width: calc(100% - 40px); box-shadow: var(--lift-hi);
}

/* ---------- はじめての使い方 ---------- */
.onboard { position: fixed; inset: 0; z-index: 25; display: grid; place-items: center; padding: 20px; pointer-events: none; }
.ob-backdrop, .ob-card { pointer-events: auto; }
/* 地は暗くする。2 枚目は左上の隅だけ穴を開け（clip-path）、押した指がその下の一覧へそのまま届くようにする */
.ob-backdrop { position: absolute; inset: 0; background: rgba(15, 16, 19, .55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.ob-ring { position: absolute; left: 0; top: 0; display: none; place-items: center; pointer-events: none; }
.onboard.corner .ob-ring { display: grid; }
.ob-ring i { width: 64%; height: 64%; border-radius: 50%; border: 3px solid var(--gold); box-shadow: 0 0 0 6px rgba(184, 137, 42, .25); }
@media (prefers-reduced-motion: no-preference) {
  .ob-ring i { animation: ob-pulse 1.4s ease-in-out infinite; }
  @keyframes ob-pulse { 50% { transform: scale(.82); box-shadow: 0 0 0 14px rgba(184, 137, 42, .08); } }
  .ob-card { animation: rise .3s var(--ease); }
}
.ob-card {
  position: relative; width: min(460px, 100%); display: grid; gap: 12px; padding: 26px 26px 22px;
  border-radius: var(--r-l); background: var(--surface); box-shadow: var(--lift-hi);
}
.ob-step { font-family: "Geist", var(--jp); font-size: 12px; font-weight: 600; letter-spacing: .16em; color: var(--gold-ink); }
.ob-art { height: 120px; border-radius: var(--r-m); background: var(--bg); display: grid; place-items: center; overflow: hidden; }
.ob-art svg { height: 100%; width: auto; }
.ob-title { font-family: var(--jp); font-weight: 700; font-size: 20px; line-height: 1.45; }
.ob-body { font-family: var(--jp); font-size: 15px; line-height: 1.8; color: var(--ink-2); }
.ob-body kbd { font-family: "Geist", var(--jp); font-size: 13px; padding: 1px 6px; border: 1px solid var(--hair-2); border-bottom-width: 2px; border-radius: 6px; background: var(--surface); }
.ob-acts { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; }
.ob-acts .btn { height: 48px; }

/* ---------- 狭い幅だけの部品 ---------- */
.narrow-only { display: none !important; }
.ql-count { font-family: "Geist", var(--jp); font-weight: 500; color: var(--sub); margin-left: 4px; font-variant-numeric: tabular-nums; }
.qnote { grid-column: 3 / -1; margin: -2px 0 4px; font-size: 12px; line-height: 1.6; color: var(--gold-ink); }
.set-switch {
  width: 100%; min-height: 64px; padding: 10px 14px 10px 16px; border-radius: var(--r-m); cursor: pointer;
  border: 1px solid var(--hair); background: var(--surface); box-shadow: var(--lift);
  align-items: center; justify-content: space-between; gap: 12px; text-align: left;
}
.set-switch-txt { display: grid; gap: 2px; min-width: 0; }
.set-switch-name { font-family: var(--jp); font-weight: 700; font-size: 16px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-switch-meta { font-size: 12px; color: var(--sub); display: flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; }
.set-switch .ic { color: var(--sub); }
.add-more { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.add-more .btn { height: 48px; }
.icon-btn { width: 44px; padding: 0; }
.icon-btn .ic { width: 20px; height: 20px; fill: currentColor; stroke: none; }

/* 広い画面の「…」は、ボタンの下に出るメニュー（地を暗くしない） */
.overlay.as-menu { background: transparent; -webkit-backdrop-filter: none; backdrop-filter: none; place-items: start; padding: 0; }
.overlay.as-menu .act-box { position: fixed; width: 240px; gap: 0; }
.overlay.as-menu .act-title, .overlay.as-menu .act-cancel { display: none; }
.overlay.as-menu .act-group { border: 1px solid var(--hair); }
.overlay.as-menu .act-group button { height: 44px; text-align: left; padding: 0 16px; font-size: 14px; font-weight: 700; }
.overlay.as-menu .act-group button:hover { background: #f5f6f8; }

/* 下から出るシート（狭い幅）。広い幅では中央に出る */
.act-box { width: min(520px, 100%); display: grid; gap: 8px; }
.act-group { background: var(--surface); border-radius: var(--r-m); overflow: hidden; box-shadow: var(--lift-hi); }
.act-title { padding: 14px 16px 12px; text-align: center; font-size: 13px; color: var(--sub); border-bottom: 1px solid var(--hair); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.act-group button, .act-cancel {
  display: block; width: 100%; height: 56px; border: 0; background: var(--surface); cursor: pointer;
  font-family: var(--jp); font-weight: 500; font-size: 17px; color: var(--ink);
}
.act-group button + button { border-top: 1px solid var(--hair); }
.act-group button.danger { color: var(--danger); }
.act-group button:disabled { color: var(--hair-2); cursor: default; }
.act-cancel { border-radius: var(--r-m); font-weight: 700; box-shadow: var(--lift-hi); }
.act-group button:active, .act-cancel:active { background: #f3f4f6; }
.sheet-sets { overflow-y: auto; min-height: 0; flex: 1 1 auto; }
.sheet-sets .set-item { min-height: 60px; }

/* ---------- 狭い画面 ---------- */
@media (max-width: 1180px) {
  .st-body { grid-template-columns: 200px minmax(0, 1fr); }
  /* 「見え方」の欄は出さないが、問いの長さを測るために画面の外で組んでおく（display: none だと測れない）。
     長すぎるときは、その問いのすぐ下に知らせを出す（.qnote） */
  .preview { position: fixed; left: -10000px; top: 0; width: 340px; visibility: hidden; pointer-events: none; }
}
@media (max-width: 760px) {
  /* 縦 1 列のときは、欄ごとにスクロールさせず画面全体（.st-body）でスクロールする。
     **欄の高さを中身に合わせる**（min-height: 0 のままだと欄が画面の高さで止まり、
     白い枠の外へ問いの行がはみ出す） */
  .st-body { grid-template-columns: minmax(0, 1fr); overflow: auto; align-content: start; }
  .sets, .editor, .preview { min-height: auto; overflow: visible; }
  .ql-head { top: 0; }
  /* 上の帯：1 段目に名前と「収録画面へ」、2 段目にタブを横いっぱい */
  .st-top { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "brand right" "tabs tabs"; gap: 12px; }
  .brand { grid-area: brand; }
  .st-top-r { grid-area: right; }
  .saved { display: none; }
  .tabs { grid-area: tabs; margin-inline: 0; }
  .tabs button { flex: 1; }

  /* --- 問いの画面：iOS の設定画面のように、灰色の地にまとまった白い一覧を置く --- */
  .narrow-only { display: flex !important; }
  .add-more.narrow-only { display: grid !important; }
  .wide-only { display: none !important; }
  .sets { display: none; }
  .editor { background: transparent; border: 0; box-shadow: none; padding: 4px 0 24px; gap: 14px; }
  .ed-head { border-bottom: 0; padding-bottom: 0; gap: 12px; }
  .title-input { font-size: 20px; padding: 2px 0; }
  .ed-meta .count, .ed-meta .badge { display: none; } /* 上の「編集しているセット」に出ている */
  .ed-meta:not(:has(#setUseBtn:not([hidden]))) { display: none; } /* 「収録で使う」も無ければ行ごと出さない */
  .ed-fields { grid-template-columns: 1fr; gap: 10px; }
  .ed-fields input { background: var(--surface); }
  .ql-head { position: sticky; top: 0; margin: 4px 0 -6px; padding: 10px 2px 8px; background: var(--bg); }
  .qlist { background: var(--surface); border: 1px solid var(--hair); border-radius: var(--r-m); gap: 0; overflow: hidden; }
  .qlist:empty { display: none; }
  .qrow { grid-template-columns: 32px 26px minmax(0, 1fr) auto; gap: 6px; padding: 6px 4px 6px 2px; border-radius: 0; border-top: 1px solid var(--hair); }
  .qrow:first-child { border-top: 0; }
  .qrow:hover, .qrow:focus-within { background: var(--surface); }
  .qrow.dragging { border-radius: var(--r-s); }
  .qhandle { width: 32px; height: 44px; color: var(--hair-2); }
  .qno { line-height: 44px; font-size: 13px; padding-right: 0; }
  .qtext { padding: 10px 2px; }
  .qtools { height: 44px; }
  .qdel { width: 44px; height: 44px; opacity: 1; }
  .qempty { background: var(--surface); }
  .q-add { background: var(--surface); height: 52px; }
  .sheet-head h2 { font-size: 16px; }
  .overlay.from-bottom { place-items: end center; padding: 0 8px max(8px, env(safe-area-inset-bottom)); }
  .overlay.from-bottom .sheet { width: 100%; max-height: 85dvh; border-radius: var(--r-l) var(--r-l) 0 0; margin: 0 -8px calc(-1 * max(8px, env(safe-area-inset-bottom))); padding-bottom: max(20px, env(safe-area-inset-bottom)); }
  .btn.wide { min-width: 120px; }
  .btn { height: 50px; padding: 0 16px; }
}
@media (hover: none) {
  .kbd-hint { display: none; }
  .qdel { opacity: 1; }
}
@media (prefers-reduced-motion: no-preference) {
  .overlay.from-bottom .sheet, .overlay.from-bottom .act-box { animation: rise .26s var(--ease); }
  @keyframes rise { from { transform: translateY(24px); opacity: 0; } }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
