/* かんじ とれーなー スタイル（iPad想定） */
:root {
  --paper: #fdf6ea;
  --card: #ffffff;
  --ink: #2b3442;
  --sub: #7a8494;
  --line: #e8dcc6;
  --red: #e4593c;
  --red-soft: #fdeae4;
  --green: #2e9e57;
  --green-soft: #e7f5ec;
  --yellow: #e8a13c;
  --blue: #4674c8;
  --radius: 18px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  font-size: 17px;
  line-height: 1.5;
  padding-bottom: calc(76px + env(safe-area-inset-bottom));
}
body.size-large { font-size: 21px; }

#appbar {
  text-align: center;
  padding: 14px 16px 10px;
}
#appbar h1 { margin: 0; font-size: 20px; letter-spacing: .06em; color: var(--red); }
body.size-large #appbar h1 { font-size: 24px; }

#view { max-width: 760px; margin: 0 auto; padding: 4px 14px 20px; }

/* ---------- カード ---------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin: 12px 0;
  box-shadow: 0 2px 10px rgba(90, 70, 40, .07);
}
.card h2 { margin: 0 0 10px; font-size: 17px; color: var(--ink); }
.card h2 .badge { font-size: 12px; color: var(--sub); font-weight: normal; }
body.size-large .card h2 { font-size: 20px; }
.muted { color: var(--sub); font-size: 14px; }
.danger { color: var(--red); }
.note-line { color: var(--sub); font-size: 14px; margin-top: 6px; white-space: pre-wrap; }

/* ---------- ボタン ---------- */
button { font-family: inherit; color: var(--ink); }
.btn {
  display: block; width: 100%;
  min-height: 56px;
  margin: 10px 0 0;
  padding: 12px 18px;
  font-size: 19px; font-weight: 700;
  border: none; border-radius: 14px;
  background: var(--red); color: #fff;
  cursor: pointer;
}
body.size-large .btn { font-size: 23px; min-height: 64px; }
.btn:disabled { background: #cfc6b8; color: #fff; }
.btn.sub { background: var(--blue); }
.btn.ghost { background: #efe7d8; color: var(--ink); }
.btn.green { background: var(--green); }
.btn.small { display: inline-block; width: auto; min-height: 40px; font-size: 15px; padding: 8px 14px; margin: 4px 6px 0 0; }

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0 2px; }
.chip {
  min-height: 46px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--line);
  background: #fff;
  font-size: 16px; font-weight: 600;
  cursor: pointer;
}
body.size-large .chip { font-size: 19px; }
.chip .count { color: var(--sub); font-weight: normal; font-size: 13px; margin-left: 4px; }
.chip.on { border-color: var(--red); background: var(--red-soft); color: var(--red); }

.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; min-width: 0; }
label.field { display: block; margin: 10px 0 4px; font-size: 14px; color: var(--sub); font-weight: 600; }
input[type=text], input[type=search], select, textarea {
  width: 100%;
  min-height: 46px;
  padding: 8px 12px;
  font-size: 17px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
}
textarea { min-height: 120px; font-size: 16px; line-height: 1.6; }
body.size-large input, body.size-large select, body.size-large textarea { font-size: 20px; }

/* ---------- 出題 ---------- */
.q-head { display: flex; justify-content: space-between; align-items: center; margin: 6px 2px; }
.q-progress { font-weight: 700; color: var(--sub); }
.linkish { border: none; background: none; color: var(--blue); font-size: 15px; cursor: pointer; padding: 6px; }
.q-type {
  display: inline-block; padding: 4px 12px; border-radius: 999px;
  background: var(--green-soft); color: var(--green); font-weight: 700; font-size: 14px;
}
.q-type.read { background: #eef1fb; color: var(--blue); }
.q-instruction { text-align: center; color: var(--sub); font-size: 16px; margin: 8px 0 2px; }
.big-glyph {
  font-size: clamp(56px, 14vw, 120px);
  line-height: 1.15;
  text-align: center;
  font-weight: 600;
  margin: 12px 0 4px;
  word-break: keep-all;
  letter-spacing: .02em;
}
body.size-large .big-glyph { font-size: clamp(66px, 16vw, 140px); }
.kana-part { color: var(--sub); font-size: .62em; font-weight: 600; }
.core-part.kanji { font-weight: 700; }
.big-sub { text-align: center; color: var(--sub); font-size: 15px; margin: 2px 0 0; }
.judges { display: flex; gap: 12px; margin-top: 14px; }
.judges button {
  flex: 1; min-height: 96px;
  border: none; border-radius: var(--radius);
  font-size: 26px; font-weight: 800; color: #fff; cursor: pointer;
}
.judges .ok { background: var(--green); }
.judges .ng { background: var(--red); }
body.size-large .judges button { font-size: 32px; }

.qlist { list-style: none; margin: 8px 0 0; padding: 0; }
.qlist li {
  display: flex; align-items: baseline; gap: 10px;
  padding: 12px 4px; border-bottom: 1px solid var(--line);
  font-size: 18px;
}
.qlist li .num { color: var(--sub); width: 34px; text-align: right; flex: none; font-size: 14px; }
.qlist li .read { color: var(--sub); font-size: 15px; }

/* ---------- 成績 ---------- */
.score-cards { display: flex; gap: 10px; }
.score-cards .card { flex: 1; text-align: center; margin: 10px 0; padding: 14px 8px; }
.score-cards .n { font-size: 30px; font-weight: 800; color: var(--red); }
body.size-large .score-cards .n { font-size: 38px; }
.score-cards .l { font-size: 13px; color: var(--sub); }

.ratebar { height: 12px; border-radius: 999px; background: #eee5d4; overflow: hidden; margin: 6px 0 2px; }
.ratebar > div { height: 100%; background: var(--green); }
.ratebar > div.warn { background: var(--yellow); }
.ratebar > div.bad { background: var(--red); }
.wlist { list-style: none; margin: 6px 0 0; padding: 0; }
.wlist li { padding: 10px 2px; border-bottom: 1px dashed var(--line); }
.wlist .head-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.wlist .name { font-size: 19px; font-weight: 700; }
body.size-large .wlist .name { font-size: 23px; }
.wlist .meta { color: var(--sub); font-size: 13px; white-space: nowrap; }
.wlist .read { color: var(--sub); font-size: 14px; }
.hist { list-style: none; margin: 4px 0 0; padding: 0; }
.hist li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 2px; border-bottom: 1px dashed var(--line); font-size: 15px; }
.hist .ok { color: var(--green); font-weight: 700; }
.hist .ng { color: var(--red); font-weight: 700; }
.seg { display: inline-flex; border: 2px solid var(--line); border-radius: 999px; overflow: hidden; }
.seg button { border: none; background: #fff; min-height: 40px; padding: 6px 16px; font-size: 14px; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--red-soft); color: var(--red); }

/* ---------- 管理 ---------- */
.wtable { list-style: none; margin: 6px 0 0; padding: 0; }
.wtable li {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 2px; border-bottom: 1px dashed var(--line);
}
.wtable .ans { font-size: 18px; font-weight: 700; }
.wtable .read { color: var(--sub); font-size: 14px; }
.wtable .unit-tag {
  flex: none; font-size: 11px; color: var(--sub);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 8px;
  max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.wtable .spacer { flex: 1; }
.mini { border: 2px solid var(--line); background: #fff; border-radius: 10px; padding: 8px 12px; font-size: 14px; cursor: pointer; }
.mini.warn { color: var(--red); border-color: var(--red-soft); }
.preview-box {
  background: #f8f2e4; border-radius: 12px; padding: 12px; text-align: center;
  margin-top: 10px; font-size: 26px;
}
.tag-confirm { display: inline-block; background: var(--yellow); color: #fff; font-size: 12px; border-radius: 999px; padding: 1px 8px; font-weight: 700; }
.err-list { list-style: none; margin: 6px 0; padding: 0; font-size: 13px; color: var(--red); }
.err-list li { padding: 2px 0; }

/* ---------- タブバー ---------- */
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: flex;
  background: #fffdf7;
  border-top: 1px solid var(--line);
  padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
  max-width: 100%;
  z-index: 10;
}
#tabbar button {
  flex: 1; border: none; background: none; cursor: pointer;
  font-size: 15px; font-weight: 700; color: var(--sub);
  padding: 10px 0; border-radius: 12px;
}
body.size-large #tabbar button { font-size: 18px; }
#tabbar button.on { color: var(--red); }

/* ---------- モーダル・トースト ---------- */
#toast[hidden] { display: none; }

#modal {
  position: fixed; inset: 0; background: rgba(40, 35, 25, .45);
  display: flex; align-items: center; justify-content: center; z-index: 30;
  padding: 20px;
}
#modal[hidden] { display: none; }
.modal-box { background: #fff; border-radius: 18px; padding: 20px; max-width: 420px; width: 100%; text-align: center; }
#modal-msg { margin: 4px 0 14px; font-size: 16px; }
.modal-btns { display: flex; gap: 10px; }
.modal-btns button { flex: 1; min-height: 48px; border: none; border-radius: 12px; font-size: 16px; font-weight: 700; cursor: pointer; }
#modal-no { background: #efe7d8; color: var(--ink); }
#modal-yes { background: var(--red); color: #fff; }

#toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(96px + env(safe-area-inset-bottom));
  background: rgba(43, 52, 66, .92); color: #fff;
  border-radius: 999px; padding: 10px 20px; font-size: 15px; z-index: 40;
  max-width: 90vw;
}

@keyframes pop-in { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.anim { animation: pop-in .18s ease-out; }
