:root {
  --bg: #f4f8fb;
  --panel: #ffffff;
  --ink: #172433;
  --muted: #607083;
  --line: #dbe5ee;
  --blue: #1367d1;
  --blue-2: #eaf3ff;
  --green: #16835c;
  --green-2: #e9f8f1;
  --orange: #b85e00;
  --orange-2: #fff2df;
  --red: #b42318;
  --red-2: #fff0ef;
  --shadow: 0 10px 30px rgba(23, 36, 51, .08);
  --radius: 22px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); color: var(--ink); font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif; }
button, input, select, textarea { font: inherit; }
button { touch-action: manipulation; }
.hidden { display: none !important; }
.app-shell { min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 16px; background: rgba(244,248,251,.94); backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); }
.brand { font-weight: 900; letter-spacing: .04em; }
.topbar .spacer { flex: 1; }
.topbar .mini { color: var(--muted); font-size: .9rem; }
.icon-btn, .small-btn, .primary-btn, .soft-btn, .danger-btn { border: 0; border-radius: 14px; min-height: 46px; padding: 10px 16px; cursor: pointer; font-weight: 800; }
.icon-btn, .soft-btn { background: #fff; border: 1px solid var(--line); color: var(--ink); }
.primary-btn { background: var(--blue); color: white; box-shadow: 0 6px 16px rgba(19,103,209,.22); }
.danger-btn { background: var(--red-2); color: var(--red); }
.small-btn { min-height: 38px; padding: 7px 11px; border: 1px solid var(--line); background: white; color: var(--ink); }
.page { width: min(980px, 100%); margin: 0 auto; padding: 22px 18px 96px; }
.page.narrow { width: min(720px, 100%); }
.hero { padding: 20px 0 14px; }
.hero h1 { margin: 0 0 8px; font-size: clamp(1.8rem, 5vw, 3rem); line-height: 1.1; }
.hero p { margin: 0; color: var(--muted); font-size: 1.05rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin: 14px 0; }
.card.flat { box-shadow: none; }
.card h2, .card h3 { margin: 0 0 14px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.metric { border-radius: 18px; background: #f8fbfd; border: 1px solid var(--line); padding: 15px; }
.metric .label { color: var(--muted); font-size: .88rem; font-weight: 700; }
.metric .value { margin-top: 5px; font-size: clamp(1.45rem, 4vw, 2.15rem); font-weight: 900; font-variant-numeric: tabular-nums; }
.big-value { font-size: clamp(2.5rem, 10vw, 5rem); font-weight: 950; letter-spacing: -.04em; font-variant-numeric: tabular-nums; }
.subtle { color: var(--muted); }
.center { text-align: center; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.stack { display: grid; gap: 12px; }
label.field { display: grid; gap: 7px; font-weight: 800; color: var(--muted); }
input, select, textarea { width: 100%; min-height: 48px; border-radius: 13px; border: 1px solid #c9d6e1; background: white; color: var(--ink); padding: 10px 12px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(19,103,209,.12); }
.target-adjust { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.target-adjust button { min-height: 52px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font-weight: 900; cursor: pointer; }
.passes { display: grid; grid-template-columns: repeat(3,1fr); gap: 8px; }
.pass { background: var(--blue-2); border-radius: 14px; padding: 12px; text-align: center; }
.pass strong { display: block; font-size: 1.25rem; margin-top: 3px; }
.footer-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 12px; z-index: 25; display: grid; grid-template-columns: repeat(3, 1fr); width: min(620px, calc(100% - 24px)); background: rgba(255,255,255,.97); border: 1px solid var(--line); border-radius: 20px; box-shadow: var(--shadow); padding: 7px; }
.footer-nav button { border: 0; background: transparent; border-radius: 14px; padding: 10px 8px; min-height: 54px; font-weight: 900; color: var(--muted); }
.footer-nav button.active { background: var(--blue-2); color: var(--blue); }

/* Timer screen */
.timer-screen { min-height: 100svh; background: #fff; display: grid; grid-template-rows: auto 1fr auto; }
.timer-header { padding: max(14px, env(safe-area-inset-top)) 18px 10px; display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line); }
.timer-header .name { font-weight: 900; font-size: 1.15rem; }
.timer-header .goal { margin-left: auto; color: var(--muted); font-weight: 800; }
.timer-main { width: min(780px, 100%); margin: 0 auto; padding: 18px; display: grid; align-content: center; gap: 18px; }
.lap-counter { text-align: center; color: var(--muted); font-size: 1.15rem; font-weight: 900; }
.lap-counter strong { color: var(--ink); font-size: clamp(2.2rem, 8vw, 4.5rem); }
.elapsed { text-align: center; font-size: clamp(4rem, 17vw, 9rem); line-height: .95; font-weight: 950; letter-spacing: -.06em; font-variant-numeric: tabular-nums; }
.timer-info { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; }
.timer-info .box { min-height: 88px; border-radius: 18px; background: #f7fafc; border: 1px solid var(--line); padding: 12px; display: grid; place-content: center; text-align: center; }
.timer-info .box span { color: var(--muted); font-weight: 800; font-size: .9rem; }
.timer-info .box strong { font-size: clamp(1.3rem, 5vw, 2.1rem); font-variant-numeric: tabular-nums; }
.timer-info .good { background: var(--green-2); color: var(--green); }
.timer-info .warm { background: var(--orange-2); color: var(--orange); }
.timer-info .bad { background: var(--red-2); color: var(--red); }
.timer-actions { padding: 10px 18px max(18px, env(safe-area-inset-bottom)); width: min(780px, 100%); margin: 0 auto; }
.lap-btn { width: 100%; min-height: min(29vh, 220px); border: 0; border-radius: 30px; background: var(--blue); color: white; font-size: clamp(2.4rem, 9vw, 5rem); font-weight: 950; cursor: pointer; box-shadow: 0 12px 28px rgba(19,103,209,.28); }
.lap-btn:active { transform: translateY(2px); }
.timer-secondary { margin-top: 9px; display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.timer-secondary button { min-height: 48px; border-radius: 14px; border: 1px solid var(--line); background: #fff; font-weight: 800; }

/* Charts and results */
.chart-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 18px; background: #fff; padding: 10px; }
canvas.chart { display: block; width: 100%; min-width: 520px; height: 260px; }
.lap-list { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.lap-chip { padding: 10px 8px; border: 1px solid var(--line); border-radius: 14px; text-align: center; background: #fff; }
.lap-chip span { display:block; color:var(--muted); font-size:.8rem; }
.lap-chip strong { font-size:1.12rem; font-variant-numeric: tabular-nums; }
.comment { padding: 16px 18px; border-radius: 18px; background: var(--green-2); color: #105b42; font-weight: 900; font-size: 1.08rem; }
.reflection-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.reflection-grid button { min-height: 58px; border: 1px solid var(--line); border-radius: 15px; background: #fff; font-weight: 850; }
.reflection-grid button.selected { background: var(--blue-2); border-color: #84b8ef; color: var(--blue); }
.empty { padding: 30px 16px; text-align: center; color: var(--muted); }

/* Teacher */
.teacher-shell { min-height: 100vh; background: #eef3f6; }
.teacher-topbar { display:flex; align-items:center; gap:12px; position:sticky; top:0; z-index:20; background:#fff; border-bottom:1px solid var(--line); padding:12px 18px; }
.teacher-layout { width:min(1180px,100%); margin:0 auto; padding:20px 18px 70px; }
.teacher-tabs { display:flex; gap:8px; overflow:auto; padding-bottom:6px; }
.teacher-tabs button { flex:0 0 auto; border:1px solid var(--line); background:#fff; border-radius:999px; padding:10px 15px; font-weight:850; }
.teacher-tabs button.active { background:var(--ink); color:#fff; border-color:var(--ink); }
.table-wrap { overflow:auto; border:1px solid var(--line); border-radius:16px; }
table { width:100%; border-collapse:collapse; min-width:720px; background:#fff; }
th, td { padding:12px 11px; border-bottom:1px solid var(--line); text-align:left; vertical-align:middle; }
th { background:#f6f9fb; color:var(--muted); font-size:.84rem; position:sticky; top:0; }
td.num { font-variant-numeric:tabular-nums; }
.badge { display:inline-flex; align-items:center; border-radius:999px; padding:5px 9px; background:#eef3f7; color:#506174; font-size:.78rem; font-weight:850; }
.badge.ok { background:var(--green-2); color:var(--green); }
.badge.warn { background:var(--orange-2); color:var(--orange); }
.teacher-kpis { display:grid; grid-template-columns: repeat(4,1fr); gap:10px; }
.teacher-kpis .metric { background:#fff; }
.qr-card-grid { display:grid; grid-template-columns:repeat(3,1fr); gap:12px; }
.qr-card { border:1px dashed #9db0c0; border-radius:16px; padding:14px; background:#fff; break-inside:avoid; }
.qr-placeholder { aspect-ratio:1/1; display:grid; place-items:center; border-radius:12px; background:repeating-linear-gradient(45deg,#eef3f7,#eef3f7 8px,#f9fbfc 8px,#f9fbfc 16px); color:var(--muted); font-size:.82rem; text-align:center; padding:10px; }
.code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; background:#f3f6f8; border-radius:8px; padding:3px 6px; word-break:break-all; }
.notice { border-left:4px solid var(--orange); background:var(--orange-2); border-radius:12px; padding:12px 14px; color:#7c4200; }
.login-wrap { min-height:100vh; display:grid; place-items:center; padding:20px; }
.login-card { width:min(440px,100%); background:#fff; border:1px solid var(--line); border-radius:28px; box-shadow:var(--shadow); padding:24px; }
.role-grid { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.role-card { min-height:170px; border:1px solid var(--line); border-radius:24px; background:#fff; padding:20px; text-align:left; cursor:pointer; }
.role-card strong { display:block; font-size:1.45rem; margin-bottom:8px; }
.role-card span { color:var(--muted); line-height:1.5; }

@media (max-width: 720px) {
  .grid-2, .grid-3, .teacher-kpis { grid-template-columns: 1fr 1fr; }
  .qr-card-grid { grid-template-columns: 1fr 1fr; }
  .lap-list { grid-template-columns: repeat(2, 1fr); }
  .page { padding-left:14px; padding-right:14px; }
  .card { padding:16px; }
}
@media (max-width: 480px) {
  .grid-2, .grid-3, .teacher-kpis, .role-grid { grid-template-columns:1fr; }
  .qr-card-grid { grid-template-columns:1fr; }
  .timer-main { padding:12px; }
  .timer-actions { padding-left:12px; padding-right:12px; }
  .timer-info .box { min-height:78px; }
}
@media (orientation: landscape) and (max-height: 700px) {
  .timer-screen { grid-template-rows:auto 1fr; grid-template-columns: 1fr minmax(330px, 42vw); }
  .timer-header { grid-column:1 / -1; }
  .timer-main { grid-column:1; grid-row:2; padding:10px 18px; gap:8px; }
  .timer-actions { grid-column:2; grid-row:2; align-self:stretch; display:grid; align-content:center; padding:12px; }
  .elapsed { font-size:clamp(4rem,12vw,7.2rem); }
  .lap-btn { min-height:52vh; }
}
@media print {
  body { background:#fff; }
  .no-print, .teacher-topbar, .teacher-tabs { display:none !important; }
  .teacher-layout { width:100%; padding:0; }
  .card { box-shadow:none; border:0; padding:0; }
  .qr-card-grid { grid-template-columns:repeat(3,1fr); gap:8mm; }
  .qr-card { min-height:78mm; border:1px solid #888; page-break-inside:avoid; }
}

/* PACE RUNNER sporty refresh */
:root { --bg:#f0f5f8; --ink:#142333; --muted:#52667a; --blue:#075fd0; --blue-2:#e5f0ff; --green:#067a55; --radius:20px; --shadow:0 9px 26px rgba(3,29,60,.09); }
body { background:linear-gradient(160deg,#edf6fc 0%,#f7f9fb 55%,#eaf2f6 100%); }
.brand { font-style:italic; font-weight:950; letter-spacing:.08em; }
.topbar, .teacher-topbar { border-bottom:3px solid #b8e43a; }
.hero h1 { font-style:italic; letter-spacing:-.035em; }
.primary-btn { background:linear-gradient(110deg,#0d65dd,#0643a1); }
.metric { border-top:4px solid #b4dd35; }
.lap-chip { border-left:4px solid #1673da; }
.timer-screen { color:#fff; background:linear-gradient(150deg,#071c33,#103a68 70%,#08274b); }
.timer-header { border-bottom:1px solid rgba(255,255,255,.2); }
.timer-header .goal, .timer-screen .lap-counter { color:#dbeafc; }
.timer-screen .lap-counter strong { color:#fff; }
.lap-next { display:block; font-size:.85rem; font-weight:800; color:#bde64c; }
.timer-screen .elapsed { color:#fff; text-shadow:0 3px 25px rgba(29,125,249,.33); }
.timer-info .box { background:#fff; color:#142b45; border:2px solid #dee8f4; }
.timer-info .box span { color:#506982; }
.timer-info .good { background:#dbfce9;color:#075d39; }
.timer-info .warm { background:#fff0cf;color:#854900; }
.timer-info .bad { background:#ffe1df;color:#a02923; }
.lap-btn { background:linear-gradient(130deg,#caff44,#a6dd28);color:#142a08; box-shadow:0 10px 0 #67951e,0 16px 35px rgba(0,0,0,.38); touch-action:none; -webkit-tap-highlight-color:transparent; user-select:none; -webkit-user-select:none; min-height:clamp(160px,30vh,255px); border:3px solid #e1ff95; letter-spacing:.015em; }
.lap-btn small { display:block;font-size:clamp(.85rem,2vw,1.15rem);font-weight:800;letter-spacing:0; }
.lap-btn:active { transform:translateY(5px);box-shadow:0 5px 0 #67951e,0 8px 22px rgba(0,0,0,.3); }
.lap-feedback { min-height:22px;text-align:center; color:#d3edb4;font-weight:850; margin:9px 0 0; }
.timer-secondary button { background:#e6edf6; color:#17304b; }
.advice-panel { border-radius:22px; background:linear-gradient(125deg,#082d56,#075ac1); padding:22px 24px; color:#fff; box-shadow:0 13px 30px rgba(9,52,107,.17); margin:16px 0; border-left:7px solid #caff44; }
.advice-kicker { color:#caff44;font-weight:950;letter-spacing:.07em;font-size:.83rem; }
.advice-panel h2 { margin:12px 0 8px;font-size:clamp(1.15rem,3.5vw,1.55rem);line-height:1.55; }
.advice-panel p { margin:0;line-height:1.65;font-weight:650; }
@media (orientation:landscape) and (max-height:700px) { .lap-btn { min-height:50vh; } .timer-actions { align-content:center; } }
@media (max-height:650px) and (orientation:portrait) { .timer-main { gap:8px; padding:8px 14px; } .timer-screen .elapsed { font-size:clamp(3.4rem,15vw,7rem); } .lap-btn { min-height:25vh; } }
@media print { .advice-panel { background:#fff;color:#111;border:1px solid #777; } }

/* Coach v3: clear two-part feedback, high contrast outdoors */
.coach-label {display:inline-block;background:#caff44;color:#142c10;border-radius:9px;padding:6px 11px;font-weight:950;font-size:.78rem;letter-spacing:.02em;margin-top:18px;}
.coach-label.next {background:#fff;color:#082d56;margin:20px 0 10px;}
.advice-panel h2 {margin:9px 0 0;}
.advice-panel p {font-size:1.08rem;line-height:1.7;}
@media print {.coach-label,.coach-label.next{border:1px solid #555;background:white;color:black;}}

/* Ver.4 touch and outdoor visibility */
.timer-screen .lap-btn { touch-action:manipulation; position:relative; outline-offset:4px; }
.timer-screen .lap-btn.lap-confirmed { background:#ffffff; border-color:#caff44; box-shadow:0 0 0 7px rgba(202,255,68,.55); }
.timer-screen .lap-feedback { min-height:28px; font-size:clamp(.9rem,2.5vw,1.16rem); }
.timer-screen .timer-info .box span { font-size:clamp(.7rem,2vw,.94rem); }
.next-goal-card .proposed-time {font-size:clamp(1.6rem,4vw,2.4rem); color:#0b5dc0;font-variant-numeric:tabular-nums;}
@media (prefers-reduced-motion:reduce){.lap-btn{transition:none!important;}}
