:root {
  --brand: #2f7d5f;
  --brand-dark: #23624a;
  --brand-light: #e8f3ee;
  --ink: #1c2321;
  --muted: #6b7975;
  --line: #dde5e2;
  --bg: #f7faf9;
  --warn: #c2410c;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP",
    "Yu Gothic", Meiryo, system-ui, -apple-system, sans-serif;
  font-size: 17px;
  line-height: 1.75;
  -webkit-text-size-adjust: 100%;
}

.wrap { max-width: 560px; margin: 0 auto; padding: 20px 18px 96px; }

/* ---------------------------------------------------------- typography */
h1 { font-size: 1.45rem; line-height: 1.45; margin: 0 0 6px; }
h2 { font-size: 1.25rem; line-height: 1.5; margin: 0 0 12px; }
.hint { color: var(--muted); font-size: .92rem; margin: 0 0 18px; }
.muted { color: var(--muted); }

/* ---------------------------------------------------------- header */
.bar {
  background: var(--brand);
  color: #fff;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.bar .t { font-weight: 700; font-size: 1rem; }
.bar .s { font-size: .82rem; opacity: .85; }

/* ---------------------------------------------------------- card */
.card {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 18px;
  margin-bottom: 16px;
}

/* ---------------------------------------------------------- buttons */
.btn {
  display: block;
  width: 100%;
  min-height: 58px;
  padding: 14px 18px;
  margin-bottom: 12px;
  font: inherit;
  font-size: 1.05rem;
  text-align: left;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .12s, background .12s;
}
.btn:hover { border-color: var(--brand); }
.btn.sel { border-color: var(--brand); background: var(--brand-light); font-weight: 700; }
.btn.correct { border-color: #17803d; background: #e7f6ec; }
.btn.wrong { border-color: #b91c1c; background: #fdeaea; }
.btn:disabled { opacity: .55; cursor: default; }

.primary {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
  text-align: center;
  font-weight: 700;
}
.primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); }
.primary:disabled { background: var(--muted); border-color: var(--muted); }

.small { min-height: 42px; padding: 8px 14px; width: auto; display: inline-block;
  font-size: .9rem; margin: 0 8px 8px 0; }

/* ---------------------------------------------------------- input */
input[type=text], textarea {
  width: 100%;
  padding: 14px;
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 12px;
}
input[type=text]:focus, textarea:focus { outline: none; border-color: var(--brand); }
textarea { min-height: 110px; resize: vertical; }
.count { text-align: right; font-size: .82rem; color: var(--muted); margin: -8px 0 12px; }

/* ----------------------------------------------------------状態表示 */
.done {
  background: var(--brand-light);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  padding: 16px 18px;
  color: var(--brand-dark);
  font-weight: 700;
}
.waiting { text-align: center; padding: 56px 20px; color: var(--muted); }
.dots::after {
  content: '';
  animation: dots 1.4s steps(4, end) infinite;
}
@keyframes dots { 0% { content:''; } 25% { content:'・'; } 50% { content:'・・'; } 75% { content:'・・・'; } }

/* ---------------------------------------------------------- Q&A */
.qa-item {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 10px;
  background: #fff;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.qa-item.answered { opacity: .55; }
.qa-body { flex: 1; }
.vote {
  flex-shrink: 0;
  min-width: 56px;
  padding: 6px 10px;
  font: inherit;
  font-size: .9rem;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: #fff;
  cursor: pointer;
  text-align: center;
}
.vote.on { border-color: var(--brand); background: var(--brand-light); color: var(--brand-dark); font-weight: 700; }

/* ---------------------------------------------------------- report */
.report { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 22px 20px; }
.report h2 { color: var(--brand-dark); border-bottom: 2px solid var(--brand-light);
  padding-bottom: 8px; margin-top: 26px; font-size: 1.12rem; }
.report h2:first-child { margin-top: 0; }
.report ol, .report ul { padding-left: 1.3em; }
.report li { margin-bottom: 10px; }

/* ---------------------------------------------------------- 投影用 */
body.screen {
  background: #101816;
  color: #fff;
  font-size: 20px;
  overflow: hidden;
}
.screen-wrap { height: 100vh; display: flex; flex-direction: column; padding: 40px 56px; }
.screen-head { display: flex; justify-content: space-between; align-items: baseline;
  border-bottom: 2px solid rgba(255,255,255,.14); padding-bottom: 18px; margin-bottom: 32px; }
.screen-head h1 { font-size: 2.6rem; margin: 0; }
.screen-body { flex: 1; display: flex; flex-direction: column; justify-content: center;
  overflow: hidden; }
/* 中身が縦に溢れたら、切れる代わりに全体を縮めて必ず1画面に収める */
.fitbox { width: 100%; transform-origin: center center; transition: transform .2s; }
.joinbox { text-align: right; font-size: 1rem; opacity: .8; line-height: 1.5; }
.joincode { font-size: 2.1rem; font-weight: 700; letter-spacing: .12em; color: #7fdcb4; }

.bar-row { display: flex; align-items: center; gap: 20px; margin-bottom: 20px; }
.bar-label { width: 30%; font-size: 1.45rem; text-align: right; }
.bar-track { flex: 1; background: rgba(255,255,255,.1); border-radius: 999px; height: 46px; position: relative; }
.bar-fill { background: linear-gradient(90deg, #2f7d5f, #57c496); height: 100%;
  border-radius: 999px; transition: width .5s cubic-bezier(.2,.8,.2,1); min-width: 4px; }
.bar-num { position: absolute; right: 18px; top: 50%; transform: translateY(-50%);
  font-size: 1.35rem; font-weight: 700; }
.bar-row.is-answer .bar-fill { background: linear-gradient(90deg, #15803d, #4ade80); }

.cloud { display: flex; flex-wrap: wrap; gap: 10px 26px; align-items: center;
  justify-content: center; align-content: center; height: 100%; }
.cloud span { line-height: 1.2; animation: pop .45s cubic-bezier(.2,1.4,.4,1); }
@keyframes pop { from { opacity: 0; transform: scale(.5); } to { opacity: 1; transform: scale(1); } }

.counter { text-align: center; font-size: 1.5rem; opacity: .75; margin-top: 28px; }
.counter b { font-size: 2.4rem; color: #7fdcb4; }

.rank { max-width: 720px; margin: 0 auto; width: 100%; }
.rank-row { display: flex; gap: 20px; align-items: center; padding: 12px 20px;
  background: rgba(255,255,255,.06); border-radius: 12px; margin-bottom: 10px; font-size: 1.4rem; }
.rank-row .n { width: 48px; font-weight: 700; color: #7fdcb4; }
.rank-row .p { margin-left: auto; font-weight: 700; }

.screen-qa { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-content: start;
  overflow-y: auto; }
.screen-qa .item { background: rgba(255,255,255,.07); border-radius: 12px; padding: 16px 20px;
  font-size: 1.25rem; }
.screen-qa .item .v { color: #7fdcb4; font-weight: 700; margin-right: 10px; }

.explain { background: rgba(127,220,180,.14); border-left: 5px solid #7fdcb4;
  padding: 18px 24px; margin-top: 28px; font-size: 1.35rem; border-radius: 0 12px 12px 0; }

/* ---------------------------------------------------------- 講師画面 */
.admin { max-width: 900px; }
.slide-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 20px; }
.slide-btn { display: flex; gap: 12px; align-items: center; width: 100%; padding: 10px 14px;
  font: inherit; text-align: left; background: #fff; border: 2px solid var(--line);
  border-radius: 10px; cursor: pointer; }
.slide-btn.now { border-color: var(--brand); background: var(--brand-light); font-weight: 700; }
.tag { font-size: .72rem; padding: 2px 8px; border-radius: 999px; background: var(--line);
  color: var(--muted); flex-shrink: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.stat { display: flex; gap: 28px; padding: 14px 0; border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line); margin-bottom: 18px; }
.stat div b { display: block; font-size: 1.6rem; color: var(--brand-dark); line-height: 1.2; }
.stat div span { font-size: .82rem; color: var(--muted); }
.progress { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; margin: 10px 0; }
.progress i { display: block; height: 100%; background: var(--brand); transition: width .3s; }

@media (max-width: 720px) {
  .screen-wrap { padding: 20px; }
  .screen-head h1 { font-size: 1.6rem; }
  .screen-qa { grid-template-columns: 1fr; }
  .bar-label { width: 38%; font-size: 1.05rem; }
}

/* ============================================================
   ここから下は講師画面（/admin と /admin/edit）専用。
   投影スクリーンと参加者画面は上の定義だけを使っているので、
   ここに追記しても投影の自動縮小（fitToScreen）には影響しない。
   クラス名は必ず a- で始めること。
   ============================================================ */

.a-note { color: var(--muted); font-size: .85rem; margin: 0 0 10px; line-height: 1.6; }
.a-zero { margin: -8px 0 16px; color: var(--warn); font-weight: 700; }
.a-empty { color: var(--muted); font-size: .92rem; margin: 12px 0 0; }

/* ---------------------------------------------------------- 回答パネル */
.a-panel { padding-top: 14px; }
.a-peek {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  align-items: center;
  padding-bottom: 12px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.a-peek label { font-size: .85rem; color: var(--muted); flex-shrink: 0; }
.a-peek select {
  flex: 1 1 220px;
  min-width: 0;
  min-height: 42px;
  padding: 8px 12px;
  font: inherit;
  font-size: .95rem;
  color: var(--ink);
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 10px;
}
.a-peek select:focus { outline: none; border-color: var(--brand); }
.a-peek .a-note { margin: 0; flex-basis: 100%; }

.a-panel-head {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 12px;
}
.a-panel-title { font-size: 1.05rem; font-weight: 700; line-height: 1.5; }
.a-panel-right { font-size: .88rem; color: var(--muted); white-space: nowrap; }

/* ---------------------------------------------------------- 横棒（講師用） */
.a-bar-row {
  display: grid;
  grid-template-columns: minmax(96px, 34%) 1fr auto;
  gap: 12px;
  align-items: center;
  margin-bottom: 9px;
  font-size: .95rem;
}
.a-bar-label { text-align: right; line-height: 1.45; word-break: break-word; }
.a-bar { background: var(--line); border-radius: 999px; height: 20px; overflow: hidden; }
.a-bar-fill {
  display: block;
  height: 100%;
  min-width: 3px;
  background: var(--brand);
  border-radius: 999px;
  transition: width .25s;
}
.a-bar-num { font-size: .85rem; color: var(--muted); white-space: nowrap; }
.a-bar-row.is-answer .a-bar-fill { background: #15803d; }
.a-bar-row.is-answer .a-bar-label { font-weight: 700; color: #15803d; }
.a-ok { color: #15803d; font-weight: 700; }

/* ---------------------------------------------------------- ひとこと */
.a-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.a-chip {
  display: inline-block;
  padding: 6px 12px;
  font-size: .92rem;
  background: var(--brand-light);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
}
.a-chip b { color: var(--brand-dark); margin-left: 2px; }

/* ---------------------------------------------------------- 文章の回答 */
.a-entry {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  font-size: .96rem;
  line-height: 1.7;
}
.a-entry b {
  flex-shrink: 0;
  min-width: 74px;
  font-size: .82rem;
  color: var(--muted);
  font-weight: 700;
  padding-top: 3px;
}
.a-entry span { flex: 1; word-break: break-word; }
.a-mask { letter-spacing: .18em; color: var(--muted); }

.a-badge-private {
  background: #fdeaea;
  border: 2px solid #b91c1c;
  color: #b91c1c;
  border-radius: 10px;
  padding: 8px 14px;
  font-size: .9rem;
  font-weight: 700;
  margin-bottom: 10px;
}
.a-toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 8px;
  cursor: pointer;
}
.a-toggle input { width: 20px; height: 20px; }

/* ---------------------------------------------------------- 設問の編集画面 */
.a-edit-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--brand-light);
  border: 1px solid var(--brand);
  border-radius: var(--radius);
  padding: 10px 14px;
  margin-bottom: 18px;
  font-size: .9rem;
  color: var(--brand-dark);
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  align-items: center;
  justify-content: space-between;
}
.a-edit-bar b { font-weight: 700; }
.a-kind {
  display: inline-block;
  font-size: .74rem;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--line);
  color: var(--muted);
  margin-bottom: 8px;
}
.a-field { margin-bottom: 14px; }
.a-field > label {
  display: block;
  font-size: .84rem;
  color: var(--muted);
  margin-bottom: 4px;
}
.a-field input[type=text], .a-field textarea {
  margin-bottom: 0;
  font-size: .98rem;
}
.a-field textarea { min-height: 84px; }
.a-field.a-bad input[type=text], .a-field.a-bad textarea { border-color: #b91c1c; }
.a-field input[readonly], .a-field textarea[readonly] { background: #f2f5f4; color: var(--muted); }
.a-err { color: #b91c1c; font-size: .84rem; margin: 4px 0 0; }
.a-lock {
  background: #fff7ed;
  border: 1px solid var(--warn);
  color: var(--warn);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: .86rem;
  margin-bottom: 12px;
}
.a-opt { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 8px; }
.a-opt .a-err { flex-basis: 100%; margin: 0 0 0 36px; }
.a-opt .a-optno { flex-shrink: 0; width: 26px; font-size: .84rem; color: var(--muted); }
.a-opt input[type=text] { flex: 1 1 180px; width: auto; min-width: 0; margin-bottom: 0; }
.a-opt input[type=radio] { width: 20px; height: 20px; }
.a-opt .a-optpick { flex-shrink: 0; display: flex; gap: 6px; align-items: center;
  font-size: .82rem; color: var(--muted); white-space: nowrap; }
.a-keys { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.a-keys button {
  font: inherit;
  font-size: .86rem;
  padding: 6px 12px;
  background: var(--brand-light);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink);
  cursor: pointer;
}
.a-keys button:hover { border-color: var(--brand); }
.a-save {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  border-top: 1px solid var(--line);
  padding: 12px 0;
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.a-save .a-note { margin: 0; }
.a-msg { padding: 10px 14px; border-radius: 10px; font-size: .9rem; margin-bottom: 14px; }
.a-msg.ok { background: var(--brand-light); color: var(--brand-dark); border: 1px solid var(--brand); }
.a-msg.ng { background: #fdeaea; color: #b91c1c; border: 1px solid #b91c1c; }

@media (max-width: 560px) {
  .a-bar-row { grid-template-columns: 1fr auto; }
  .a-bar-label { grid-column: 1 / -1; text-align: left; }
  .a-entry { flex-direction: column; gap: 2px; }
  .a-entry b { padding-top: 0; }
}
