:root { --fs: 46px; --bg: #1e2228; --panel: #2a2f37; --fg: #f5f5f5; --dim: #9aa3ad; --green: #3fc06b; --yellow: #f2c03c; --red: #ee554b; --cur: #1f5fa8; --orange: #e88a2e; --accent: #1f5fa8; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font-family: -apple-system, "Hiragino Sans", "Yu Gothic UI", sans-serif; overflow: hidden; -webkit-user-select: none; user-select: none; -webkit-text-size-adjust: 100%; }
body { display: flex; flex-direction: column; height: 100vh; height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.green { color: var(--green); } .yellow { color: var(--yellow); } .red { color: var(--red); } .dim { color: var(--dim); }

header { display: flex; align-items: center; gap: 12px; padding: 6px 10px; background: #111418; font-size: 20px; flex: none; }
.beta { background: #7b2fbf; color: #fff; font-weight: 800; padding: 4px 10px; border-radius: 6px; font-size: 18px; white-space: nowrap; }
#apptitle { font-weight: 700; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 18px; color: var(--dim); }
.conn { font-weight: 800; padding: 4px 12px; border-radius: 20px; white-space: nowrap; font-size: 19px; }
.conn.on { background: #164d2a; color: #7dffaa; }
.conn.try, .conn.nohost { background: #5a4710; color: #ffe07a; }
.conn.off { background: #5c1616; color: #ffb0a8; animation: blink 1.2s infinite; }
@keyframes blink { 50% { opacity: .55; } }
.bat { font-weight: 800; font-size: 22px; white-space: nowrap; }
.bat.old { opacity: .6; }
#clock { font-variant-numeric: tabular-nums; font-size: 22px; color: var(--dim); }
.hbtn { background: var(--panel); color: var(--fg); border: 0; font-size: 22px; border-radius: 8px; padding: 6px 12px; }

main { flex: 1; display: grid; grid-template-columns: 36% 1fr; gap: 8px; padding: 8px; min-height: 0; }
#timer { background: var(--panel); border-radius: 10px; padding: 10px 14px; overflow-y: auto; min-height: 0; }
#slideno { font-size: 22px; font-weight: 800; }
#slidetitle { font-size: 22px; margin: 2px 0 4px; line-height: 1.3; }
.remain { font-size: 112px; font-weight: 800; line-height: 1; font-variant-numeric: tabular-nums; margin: 4px 0; }
.barbg { height: 12px; background: #1a1d22; border-radius: 6px; overflow: hidden; }
.fill { height: 100%; background: var(--green); } .fill.yellow { background: var(--yellow); } .fill.red { background: var(--red); } .fill.dim { background: var(--dim); }
.behind { font-size: 22px; font-weight: 800; margin-top: 6px; }
#seg { font-size: 19px; font-weight: 700; margin-top: 4px; }
#elapsed { font-size: 16px; color: var(--dim); margin-top: 2px; }
.work { font-size: 26px; font-weight: 800; margin-top: 4px; }
#pausing { font-size: 26px; font-weight: 800; color: var(--orange); }
.must { background: var(--orange); color: #000; font-weight: 800; font-size: 22px; padding: 8px 10px; border-radius: 8px; margin: 6px 0; line-height: 1.35; }
.fix { background: #c62828; color: #fff; font-weight: 800; font-size: 20px; padding: 8px 10px; border-radius: 8px; margin: 6px 0; }
#memo { font-size: 16px; color: var(--dim); margin-top: 6px; white-space: normal; } #memo.user { color: var(--yellow); }
.nhead { font-size: 15px; color: var(--dim); font-weight: 700; margin-top: 10px; }
.nrow { display: flex; justify-content: space-between; gap: 8px; font-size: 16px; color: var(--dim); padding: 1px 0; }
.nrow span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; } .nrow b { color: var(--fg); } .nrow b.yellow { color: var(--yellow); }
#test { background: var(--orange); color: #000; font-weight: 800; padding: 4px 8px; border-radius: 6px; margin-bottom: 6px; }

#flow { overflow-y: auto; min-height: 0; scroll-behavior: smooth; padding-right: 4px; }
.card { background: var(--panel); border-radius: 10px; padding: 8px 14px; margin: 0 0 8px; }
.card .head { font-size: 19px; font-weight: 700; }
.card .sno { color: var(--dim); font-weight: 400; font-size: 16px; }
.card .body { font-size: 22px; line-height: 1.4; margin-top: 2px; white-space: normal; word-break: break-word; }
.card .sub { font-size: 16px; color: var(--dim); margin-top: 2px; }
.card.done { opacity: .45; }
.card.k-slide { border-left: 6px solid var(--yellow); } .card.k-slide .head { color: var(--yellow); }
.card.k-work { border-left: 6px solid var(--green); }
.card.cur { background: var(--cur); padding: 12px 18px; }
.card.cur .head { font-size: 26px; color: #fff; }
.card.cur .body { font-size: var(--fs); font-weight: 700; line-height: 1.38; }
.card.cur .sub { font-size: 22px; color: #d6e4f5; }
.card .body.big { color: var(--yellow); font-weight: 700; }
.card.k-must, .card.k-warn { background: #6a4510; } .card.cur.k-must, .card.cur.k-warn { background: var(--orange); } .card.cur.k-must .body, .card.cur.k-warn .body, .card.cur.k-must .head, .card.cur.k-warn .head { color: #000; }
.card.k-fix { background: #5c1616; } .card.cur.k-fix { background: #c62828; } .card.k-fix .body { color: #fff; }
.card.end { font-size: 30px; color: var(--green); font-weight: 800; }
.wait { font-size: 30px; color: var(--dim); padding: 40px 20px; text-align: center; line-height: 1.6; } .wait small { font-size: 20px; }
#status { font-size: 16px; color: var(--yellow); padding: 0 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: none; min-height: 20px; }

footer { flex: none; display: grid; grid-template-columns: repeat(4, 1fr) 2.2fr; grid-template-rows: 78px 78px; gap: 8px; padding: 6px 8px 8px; }
footer button, .modal button { font-size: 22px; font-weight: 700; border: 0; border-radius: 12px; background: #3a414c; color: #fff; touch-action: manipulation; }
footer button:active, .modal button:active { filter: brightness(1.4); transform: scale(.98); }
footer button:disabled { opacity: .35; }
#next-btn { grid-column: 5; grid-row: 1 / span 2; font-size: 46px; background: var(--accent); }
.b-skip { background: var(--orange) !important; color: #000 !important; }
.b-small { font-size: 20px !important; }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal[hidden] { display: none; }
.mbox { background: var(--panel); border-radius: 16px; padding: 20px 24px; width: min(720px, 94vw); max-height: 92vh; overflow-y: auto; }
.mbox h2 { margin: 0 0 12px; font-size: 28px; }
.mbox p { font-size: 19px; line-height: 1.5; color: #dde; }
#paircode { font-size: 64px; letter-spacing: 14px; width: 100%; text-align: center; padding: 10px; border-radius: 12px; border: 0; background: #fff; color: #000; font-weight: 800; -webkit-user-select: text; user-select: text; }
#pairmsg { font-size: 22px; color: var(--yellow); min-height: 30px; margin: 8px 0; }
.mrow { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; } .mrow button { flex: 1; min-height: 72px; min-width: 140px; }
.primary { background: var(--accent) !important; }
#jumpval { font-size: 80px; font-weight: 800; text-align: center; min-height: 96px; font-variant-numeric: tabular-nums; }
#jumptitle { text-align: center; font-size: 22px; min-height: 30px; color: var(--dim); }
#jumphint { text-align: center; color: var(--dim); font-size: 18px; }
.pad { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; } .pad button { height: 86px; font-size: 40px; }
#listbody { max-height: 70vh; overflow-y: auto; }
.lrow { font-size: 22px; padding: 10px 8px; border-bottom: 1px solid #3a414c; } .lrow.cur { background: var(--cur); } .lrow b { display: inline-block; width: 52px; color: var(--yellow); }
#baturl { width: 100%; font-size: 15px; padding: 8px; border-radius: 8px; border: 0; -webkit-user-select: text; user-select: text; }
#setinfo { font-size: 15px; color: var(--dim); } #setoff { white-space: pre-line; }
.toast { position: fixed; left: 50%; bottom: 190px; transform: translateX(-50%); background: #000c; color: #fff; font-size: 24px; padding: 12px 22px; border-radius: 12px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; } .toast.bad { background: #8b1d1dee; }
body:not(.linked) main { opacity: .8; }

/* 縦向き（834×1112 など） */
@media (orientation: portrait) {
  main { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  #timer { max-height: 38vh; display: grid; grid-template-columns: auto 1fr; column-gap: 16px; align-content: start; }
  #timer > * { grid-column: 2; }
  #timer > .remain { grid-column: 1; grid-row: 1 / span 4; font-size: 100px; align-self: center; }
  #timer > .barbg { grid-column: 1 / span 2; }
  #timer > .nhead, #next { display: none; }
  footer { grid-template-columns: repeat(4, 1fr); grid-template-rows: 70px 70px 96px; }
  #next-btn { grid-column: 1 / span 4; grid-row: 3; font-size: 44px; }
  header { font-size: 17px; } #apptitle { display: none; }
}

/* ───── オフライン カンペで足した物 ───── */
.beta.off { background: #1e7a4a; }
.offbadge { font-weight: 800; padding: 4px 12px; border-radius: 20px; white-space: nowrap; font-size: 18px; }
.offbadge.ok { background: #164d2a; color: #7dffaa; } .offbadge.ng { background: #5a4710; color: #ffe07a; }
#app { display: flex; flex-direction: column; height: 100%; min-height: 0; flex: 1; }
#app[hidden], #home[hidden] { display: none; }
body:not(.linked) main { opacity: 1; }

/* 最初の画面 */
#home { flex: 1; overflow-y: auto; padding: 30px 40px; text-align: center; }
#home h1 { font-size: 40px; margin: 10px 0; }
#home .lead { font-size: 20px; color: #cfd6de; line-height: 1.6; }
.courses { display: flex; gap: 24px; justify-content: center; margin: 26px 0; flex-wrap: wrap; }
.course { width: min(340px, 42vw); min-height: 190px; border: 0; border-radius: 18px; background: #1f5fa8; color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; }
.course:disabled { background: #3a414c; opacity: .6; }
.course:active { filter: brightness(1.3); }
.cbig { font-size: 52px; font-weight: 800; } .csub { font-size: 20px; line-height: 1.4; }
.offbox { background: var(--panel); border-radius: 16px; padding: 18px 20px; max-width: 760px; margin: 0 auto; }
.offstate { font-size: 22px; font-weight: 800; margin-bottom: 12px; line-height: 1.4; }
.savebtn { font-size: 28px; font-weight: 800; border: 0; border-radius: 14px; background: #1e7a4a; color: #fff; padding: 18px 26px; width: 100%; }
.savebtn:disabled { opacity: .5; }
.offhint { font-size: 17px; color: var(--dim); margin-top: 10px; line-height: 1.5; }

/* セリフ と 動作 */
.card .lab { font-size: 15px; font-weight: 800; color: var(--dim); letter-spacing: 1px; }
.say { margin-top: 4px; }
.act { display: flex; gap: 12px; align-items: flex-start; margin-top: 8px; background: #0d4a3a; border-left: 8px solid #35d39a; border-radius: 10px; padding: 8px 12px; }
.act .hand { font-size: 44px; line-height: 1; flex: none; filter: drop-shadow(0 0 2px #000); }
.act .atext { font-size: 21px; font-weight: 700; line-height: 1.4; color: #eafff6; white-space: normal; word-break: break-word; }
.act .lab { color: #8fe9c6; }
.card.cur .act { background: #0b5e47; border-left-width: 12px; }
.card.cur .act .hand { font-size: 84px; }
.card.cur .act .atext { font-size: calc(var(--fs) * .78); }
.card.cur .say .body { font-size: var(--fs); font-weight: 700; line-height: 1.38; }
.card.cur .lab { color: #d6e4f5; }
.card.cur .act .lab { color: #9ff5d2; }
.card.cur.onlyact { background: #0f3d33; }
.card.done .act { background: #1d3a33; }
.card.k-must .say .body { color: #ffd9a0; font-weight: 700; } .card.cur.k-must .say .body, .card.cur.k-must .lab { color: #000; }
.copy { margin-top: 8px; } .copy pre { margin: 4px 0 0; background: #111418; color: #e8e8e8; font-size: 16px; line-height: 1.45; padding: 8px 10px; border-radius: 8px; white-space: pre-wrap; word-break: break-word; max-height: 30vh; overflow-y: auto; -webkit-user-select: text; user-select: text; }
.tsec { font-size: .9em; color: var(--yellow); font-weight: 800; }
.stitle { color: var(--fg); font-weight: 700; }
.slact { font-size: 17px; color: var(--dim); margin-top: 2px; }
.card.cur.k-slide .slact { font-size: 22px; color: #fff; }
.card.cur.k-slide .stitle { font-size: 30px; }
.bsub { font-size: 16px; color: var(--dim); font-weight: 400; }
.nrow.ncur span, .nrow.ncur b { color: var(--yellow); font-weight: 800; }
.ltime { display: inline-block; width: 70px; color: var(--dim); font-size: 18px; font-variant-numeric: tabular-nums; }
.b-danger { background: #8b1d1d !important; }
footer button:disabled { opacity: .35; }

/* 研修準備（時間） */
.mbox.wide { width: min(980px, 96vw); }
.trow { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; font-size: 24px; font-weight: 800; }
.tin { font-size: 38px; width: 170px; text-align: center; border-radius: 10px; border: 0; padding: 6px; font-weight: 800; font-variant-numeric: tabular-nums; -webkit-user-select: text; user-select: text; }
.tsep { font-size: 36px; }
.tsmall { font-size: 18px !important; min-height: 56px; padding: 0 14px; }
.plabel { font-size: 16px; color: var(--dim); margin: 8px 0 4px; font-weight: 700; }
.prow { display: flex; gap: 10px; flex-wrap: wrap; }
.prow button { font-size: 18px; min-height: 54px; padding: 6px 16px; flex: 1 1 150px; } .prow small { font-size: 16px; color: #cfd6de; }
.tmsg { font-size: 19px; font-weight: 800; margin: 14px 0 8px; line-height: 1.45; }
.ttable { width: 100%; border-collapse: collapse; font-size: 17px; }
.ttable th { text-align: left; color: var(--dim); font-size: 15px; border-bottom: 1px solid #3a414c; padding: 4px 6px; }
.ttable td { padding: 2px 6px; border-bottom: 1px solid #333a44; font-variant-numeric: tabular-nums; }
.ttable tr.brk td { color: var(--dim); }

@media (orientation: portrait) {
  .card.cur .act .hand { font-size: 64px; }
  #home { padding: 24px 20px; }
}

#timebox .mbox { padding-bottom: 0; }
#timebox .mrow { position: sticky; bottom: 0; background: var(--panel); padding: 10px 0 14px; margin-top: 6px; }
#timebox h2 { font-size: 24px; margin-bottom: 8px; }
