/* ============================================================
   VOLUNTAS — 学校ポータル（school.html）
   公開サイトのクリームとゴールド。白いカード・角丸 14px。
   明るい配色で固定（印刷・業務用途のためダークテーマには対応しない）。
   promo-kit.css / poster.css がそのまま効くよう、管理画面（admin.css の
   body.adx ライト値）と同名のトークンを :root に置く。
   ============================================================ */

:root {
  color-scheme: light;

  /* 面 */
  --bg:        #faf7ef;            /* 公開サイトのクリーム       */
  --panel:     #ffffff;
  --field:     #faf7ef;
  --line:      #e5dcc5;
  --line-soft: #eee8d8;

  /* 文字 */
  --tx:      #26221a;
  --tx-mid:  #4d4638;
  --tx-dim:  #7d7462;
  --sp-dim:  #6b6252;            /* このページの小さな補足文字用（白地・クリーム地で 4.3:1 前後） */

  /* アクセント（ゴールド＝主 / ブルー＝情報） */
  --acc:       #b49157;
  --acc-deep:  #8f7038;
  --acc-soft:  #f5eedd;
  --acc-line:  #e7dcc4;
  --sec:       #3f8fb5;
  --sec-deep:  #2e7ba0;
  --sec-soft:  #e9f4fa;
  --sec-line:  #cfe7f3;

  --ok:   #2b8557;  --ok-soft:   #e2f2e8;
  --warn: #9a6b16;  --warn-soft: #f7ecd2;
  --bad:  #b3402f;  --bad-soft:  #f9e8e3;

  /* 幾何・影 */
  --r: 6px; --r-sm: 4px; --r-pill: 999px;
  --sh-1: none;
  --sh-2: none;
  --sh-pop: 0 32px 80px -24px rgba(24,20,12,.42);
  --ring: 0 0 0 3px var(--sec-soft);

  /* 書体 */
  /* 書体：BIZ UDPゴシック（読みやすさを優先したユニバーサルデザイン書体）。数字も同じ書体でそろえる */
  --disp: "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --jp:   "BIZ UDPGothic", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif;
  --num:  "BIZ UDPGothic", "Hiragino Sans", sans-serif;

  /* 広報キットの「できあがり」帯を止める位置（school.js が実測して上書き） */
  --pk-sticky-top: 108px;
  --wrap: 1080px;
  --gut: 24px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; background: var(--bg); }
body {
  margin: 0; min-height: 100vh;
  background: var(--bg); color: var(--tx);
  font-family: var(--jp); font-size: 16px; line-height: 1.8;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "palt" 0;
}
img { max-width: 100%; height: auto; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
h1, h2, h3, p, dl, dd, ul { margin: 0; }
/* 日本語を文節で折り返す（対応ブラウザのみ）。行末の1〜2文字だけの行を避ける */
h1, h2, h3, p, li, dt, dd { word-break: auto-phrase; text-wrap: pretty; }
ul { padding: 0; list-style: none; }
a { color: var(--sec-deep); text-underline-offset: 3px; }
a:hover { color: var(--tx); }
svg { width: 18px; height: 18px; flex: 0 0 auto; }
:focus-visible { outline: 2px solid var(--sec); outline-offset: 2px; }

.sp-sr { position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.sp-skip { position: absolute; left: 12px; top: -60px; z-index: 50; padding: 8px 14px; background: var(--tx); color: #fff; border-radius: var(--r-sm); text-decoration: none; }
.sp-skip:focus { top: 12px; color: #fff; }

/* 見本データの帯 */
.sp-demo {
  position: relative; z-index: 30;
  padding: 7px var(--gut); text-align: center;
  font-size: 13px; font-weight: 700; letter-spacing: .02em;
  color: #6b4d12; background: #f3e3bd;
  border-bottom: 1px solid #e6d29f;
}

/* ------------------------------------------------------------
   ボタン・入力
   ------------------------------------------------------------ */
.sp-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 42px; padding: 0 18px;
  font-weight: 700; font-size: 14px; line-height: 1.2; white-space: nowrap;
  border-radius: var(--r-sm); border: 1px solid transparent; cursor: pointer;
  transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
}
.sp-btn:disabled { cursor: default; opacity: .55; }
.sp-btn svg { width: 17px; height: 17px; }
.sp-btn-primary { background: var(--tx); color: #fff; }
.sp-btn-primary:hover:not(:disabled) { background: #3b3528; }
.sp-btn-ghost { background: var(--panel); color: var(--tx); border-color: var(--line); box-shadow: var(--sh-1); }
.sp-btn-ghost:hover:not(:disabled) { border-color: var(--acc); background: #fffdf8; }
.sp-btn-quiet { background: transparent; color: var(--tx-mid); border-color: transparent; padding: 0 12px; }
.sp-btn-quiet:hover:not(:disabled) { background: var(--acc-soft); color: var(--tx); }
.sp-btn-sm { min-height: 34px; font-size: 13px; padding: 0 10px; }
.sp-btn-block { width: 100%; min-height: 48px; font-size: 15px; }
.sp-btn[aria-busy="true"] { opacity: .8; }

.sp-field { display: grid; gap: 6px; }
.sp-field > label { font-weight: 700; font-size: 14px; display: flex; align-items: baseline; gap: 10px; }
.sp-hint { font-weight: 500; font-size: 13px; color: var(--sp-dim); }
.sp-in {
  width: 100%; min-height: 48px; padding: 10px 14px;
  font-size: 16px;                         /* iOS の自動ズームを避ける */
  background: var(--field); border: 1px solid var(--line); border-radius: var(--r-sm);
  transition: border-color .15s, box-shadow .15s, background-color .15s;
}
.sp-in:hover { border-color: #d6c9a8; }
.sp-in:focus { outline: none; background: #fff; border-color: var(--sec); box-shadow: var(--ring); }
.sp-in[aria-invalid="true"] { border-color: var(--bad); }
.sp-pwwrap { position: relative; }
.sp-pwwrap .sp-in { padding-right: 52px; }
.sp-eye {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 42px; height: 40px; display: grid; place-items: center;
  border: 0; border-radius: 7px; background: transparent; color: var(--tx-mid); cursor: pointer;
}
.sp-eye:hover { background: var(--acc-soft); color: var(--tx); }
.sp-eye svg { width: 20px; height: 20px; }
.sp-fieldnote { font-size: 13px; line-height: 1.6; color: var(--tx-mid); }

/* ------------------------------------------------------------
   起動中
   ------------------------------------------------------------ */
.sp-boot { min-height: 100vh; display: grid; place-content: center; justify-items: center; gap: 22px; }
.sp-boot img { width: 170px; opacity: .9; }
.sp-spin { display: inline-block; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--acc-line); border-top-color: var(--acc-deep); animation: sp-spin .8s linear infinite; }
@keyframes sp-spin { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------
   ログイン：1列。ロゴ・名前・フォームを縦に置くだけ
   ------------------------------------------------------------ */
.sp-login {
  min-height: 100vh;
  display: grid; justify-content: center; align-content: start;
  grid-template-columns: min(100% - var(--gut) * 2, 400px);
  padding: clamp(40px, 12vh, 120px) 0 64px;
}
body.is-demo .sp-login { min-height: calc(100vh - 36px); }
.sp-brand { padding-bottom: 24px; border-bottom: 2px solid var(--tx); }
.sp-brand-logo { width: 150px; margin-bottom: 36px; }
.sp-brand h1 { font-family: var(--disp); font-weight: 700; font-size: 26px; line-height: 1.35; letter-spacing: .02em; }
.sp-brand-lead { margin-top: 6px; font-size: 14px; line-height: 1.8; color: var(--tx-mid); }

.sp-login-card { padding: 28px 0 0; }
.sp-login-card h2 { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.sp-login-sub { font-size: 13.5px; color: var(--tx-mid); line-height: 1.7; }
#sp-login-form, #sp-setup-form { margin-top: 20px; display: grid; gap: 18px; }
#sp-login-form .sp-btn-block, #sp-setup-form .sp-btn-block { margin-top: 4px; }
#sp-setup-form { margin-top: 0; }
#sp-su-id, #sp-su-code { font-family: var(--num); font-weight: 700; letter-spacing: .03em; }
.sp-login-switch { margin-top: 18px; font-size: 14px; font-weight: 700; }
.sp-login-switch a { color: var(--acc-deep); }
.sp-login .sp-in { background: var(--panel); }
.sp-login-err {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 12px; font-size: 14px; line-height: 1.65; font-weight: 500;
  color: #8a2f21; background: var(--bad-soft); border-left: 3px solid var(--bad);
}
.sp-login-err svg { margin-top: 2px; color: var(--bad); }
.sp-login-help { margin-top: 28px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 13px; line-height: 1.8; color: var(--tx-mid); }
.sp-login-help a { font-family: var(--num); font-weight: 700; }

/* ------------------------------------------------------------
   ポータル：ヘッダーとタブ
   ------------------------------------------------------------ */
.sp-portal { min-height: 100vh; display: flex; flex-direction: column; }
.sp-top { position: sticky; top: 0; z-index: 20; background: rgba(250,247,239,.94); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.sp-bar, .sp-tabs, .sp-main, .sp-foot p { width: 100%; max-width: calc(var(--wrap) + var(--gut) * 2); margin: 0 auto; padding-left: var(--gut); padding-right: var(--gut); }
.sp-bar { display: flex; align-items: center; gap: 18px; min-height: 62px; }
.sp-bar-logo { display: block; flex: 0 0 auto; line-height: 0; }
.sp-bar-logo img { width: 134px; }
.sp-bar-who { flex: 1 1 auto; min-width: 0; display: flex; align-items: baseline; gap: 12px; padding-left: 18px; border-left: 1px solid var(--line); line-height: 1.4; }
.sp-bar-kind { flex: 0 0 auto; font-size: 13px; color: var(--sp-dim); font-weight: 500; }
.sp-bar-school { min-width: 0; font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sp-bar .sp-logout { flex: 0 0 auto; }

.sp-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.sp-tabs::-webkit-scrollbar { display: none; }
.sp-tabs [role="tab"] {
  position: relative; flex: 0 0 auto;
  min-height: 46px; padding: 0 14px;
  font-weight: 700; font-size: 14.5px; color: var(--tx-mid);
  background: none; border: 0; cursor: pointer; white-space: nowrap;
}
.sp-tabs [role="tab"]:first-child { margin-left: -14px; }
.sp-tabs [role="tab"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 3px; border-radius: 3px 3px 0 0; background: transparent; transition: background-color .15s; }
.sp-tabs [role="tab"]:hover { color: var(--tx); }
.sp-tabs [role="tab"][aria-selected="true"] { color: var(--tx); }
.sp-tabs [role="tab"][aria-selected="true"]::after { background: var(--acc); }
.sp-tabs [role="tab"]:focus-visible { outline-offset: -4px; border-radius: 10px; }

.sp-main { flex: 1 0 auto; padding-top: 34px; padding-bottom: 72px; }
.sp-main:focus { outline: none; }
.sp-panel:focus { outline: none; }
.sp-panel:focus-visible { outline: 2px solid var(--sec); outline-offset: 8px; border-radius: 4px; }

.sp-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 24px; flex-wrap: wrap; margin-bottom: 22px; }
.sp-head-t { min-width: 0; flex: 1 1 420px; }
.sp-head h1 { font-family: var(--disp); font-size: 22px; font-weight: 700; line-height: 1.4; }
.sp-head p { margin-top: 6px; max-width: 54em; font-size: 14px; color: var(--tx-mid); }
.sp-head-a { display: flex; align-items: center; gap: 4px; }
.sp-asof { font-family: var(--num); font-size: 13px; font-weight: 700; color: var(--sp-dim); font-variant-numeric: tabular-nums; }

.sp-inline-err { display: flex; align-items: flex-start; gap: 8px; margin: -8px 0 18px; padding: 10px 14px; font-size: 13.5px; color: #8a2f21; background: var(--bad-soft); border-radius: var(--r-sm); }
.sp-inline-err svg { color: var(--bad); margin-top: 2px; }

.sp-foot { border-top: 1px solid var(--line); }
.sp-foot p { padding-top: 18px; padding-bottom: 28px; font-size: 13px; color: var(--sp-dim); }
.sp-foot a { color: var(--tx-mid); }

/* ------------------------------------------------------------
   生徒の参加状況：数字
   ------------------------------------------------------------ */
.sp-stats { margin-bottom: 22px; }
.sp-stats-row {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--tx); border-bottom: 1px solid var(--line);
}
.sp-stat { padding: 12px 20px 12px 0; min-width: 0; }
.sp-stat + .sp-stat { padding-left: 20px; }
.sp-stat + .sp-stat { border-left: 1px solid var(--line-soft); }
.sp-stat dt { font-size: 13px; font-weight: 700; color: var(--tx-mid); }
.sp-stat dd { display: flex; align-items: baseline; gap: 4px; margin-top: 2px; }
.sp-stat dd b { font-family: var(--num); font-weight: 700; font-size: 28px; line-height: 1.15; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.sp-stat dd span { font-size: 14px; color: var(--tx-mid); font-weight: 500; }
.sp-stat.is-plan dd b { color: var(--sec-deep); }
.sp-note { margin-top: 8px; font-size: 13px; color: var(--sp-dim); }

/* ------------------------------------------------------------
   生徒の参加状況：操作
   ------------------------------------------------------------ */
.sp-tools { display: grid; gap: 12px; margin-bottom: 14px; }
.sp-tools-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; }
.sp-seg { display: inline-flex; border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--panel); overflow: hidden; }
.sp-seg button {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 36px; padding: 0 14px;
  font-size: 13.5px; font-weight: 700; color: var(--tx-mid);
  background: transparent; border: 0; cursor: pointer; white-space: nowrap;
}
.sp-seg button + button { border-left: 1px solid var(--line); }
.sp-seg button:hover { color: var(--tx); background: var(--field); }
.sp-seg button[aria-pressed="true"] { background: var(--tx); color: #fff; }
.sp-seg-n { font-family: var(--num); font-size: 13px; font-weight: 700; color: var(--sp-dim); font-variant-numeric: tabular-nums; }
.sp-seg button[aria-pressed="true"] .sp-seg-n { color: rgba(255,255,255,.7); }

.sp-search { position: relative; flex: 1 1 280px; max-width: 420px; display: block; }
.sp-search svg { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--sp-dim); pointer-events: none; }
.sp-search input {
  width: 100%; min-height: 42px; padding: 8px 12px 8px 40px;
  font-size: 15px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r-sm);
}
.sp-search input:focus { outline: none; border-color: var(--sec); box-shadow: var(--ring); }
.sp-result { flex: 1 1 auto; font-size: 13px; color: var(--tx-mid); font-variant-numeric: tabular-nums; }
#sp-csv { margin-left: auto; }

/* ------------------------------------------------------------
   状態チップ
   ------------------------------------------------------------ */
.sp-chip {
  display: inline-block; flex: 0 0 auto;
  font-size: 13px; font-weight: 700; line-height: 1.4; white-space: nowrap;
}
.sp-chip i, .sp-chip svg { display: none; }
.sp-chip.is-plan { color: var(--sec-deep); }
.sp-chip.is-done { color: var(--tx-mid); font-weight: 500; }
.sp-chip.is-applied { color: var(--sp-dim); font-weight: 500; }

/* ------------------------------------------------------------
   一覧（生徒ごと／活動ごと）
   ------------------------------------------------------------ */
.sp-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); min-width: 0; }
.sp-list { display: grid; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); }
.sp-list > .sp-card { border: 0; border-radius: 0; background: none; }
.sp-list > .sp-card + .sp-card { border-top: 1px solid var(--line); }

/* 生徒ごと：左に名前、右に活動の行（名簿のように） */
.sp-stu { display: grid; grid-template-columns: 220px minmax(0, 1fr); }
.sp-stu-h { padding: 18px 22px; border-right: 1px solid var(--line-soft); display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sp-stu-name { font-size: 16px; font-weight: 700; line-height: 1.45; overflow-wrap: anywhere; }
.sp-count { font-size: 13px; color: var(--sp-dim); white-space: nowrap; }
.sp-count b { font-family: var(--num); font-weight: 700; font-size: 14px; color: var(--tx-mid); margin-right: 1px; font-variant-numeric: tabular-nums; }
.sp-acts { display: grid; min-width: 0; }
.sp-act { display: grid; grid-template-columns: minmax(150px, 14em) minmax(0, 1fr) auto; align-items: center; gap: 4px 18px; padding: 13px 20px; min-width: 0; }
.sp-act + .sp-act { border-top: 1px solid var(--line-soft); }
.sp-act-when { font-size: 13px; color: var(--tx-mid); font-variant-numeric: tabular-nums; line-height: 1.5; white-space: pre-line; }
.sp-act-when.is-none, .sp-actc-when.is-none { color: var(--sp-dim); }
.sp-act-title { font-size: 14.5px; font-weight: 500; line-height: 1.55; overflow-wrap: anywhere; }

/* 活動ごと */
.sp-actc { padding: 18px 22px 18px; }
.sp-actc-h { display: flex; align-items: flex-start; gap: 10px 18px; }
.sp-actc-t { flex: 1 1 auto; min-width: 0; }
.sp-actc-t h3 { font-size: 16px; font-weight: 700; line-height: 1.55; overflow-wrap: anywhere; }
.sp-actc-when { margin-top: 2px; font-size: 13px; color: var(--tx-mid); white-space: pre-line; }
.sp-actc-meta { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; }
.sp-names { display: flex; flex-wrap: wrap; gap: 4px 14px; margin-top: 14px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.sp-names li { display: inline-flex; align-items: center; gap: 8px; padding: 2px 0; font-size: 14px; font-weight: 500; }
.sp-names li + li::before { content: "、"; margin: 0 2px 0 -8px; color: var(--sp-dim); }
.sp-names-x { font-family: var(--num); font-size: 13px; font-weight: 700; color: var(--sp-dim); }
.sp-names .sp-chip { font-size: 13px; }

/* 状態（読み込み中・0件・該当なし・失敗） */
.sp-loading { display: flex; align-items: center; justify-content: center; gap: 12px; padding: 64px 16px; color: var(--tx-mid); font-size: 14px; }
.sp-state {
  display: grid; justify-items: center; gap: 10px; text-align: center;
  padding: 56px 24px 52px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.sp-state-h { font-size: 17px; font-weight: 700; }
.sp-state-p { max-width: 30em; font-size: 14px; color: var(--tx-mid); }
.sp-state .sp-btn { margin-top: 10px; }
.sp-state-err svg { width: 26px; height: 26px; color: var(--bad); }
.sp-state-none { padding: 40px 24px; }

/* ------------------------------------------------------------
   アカウント
   ------------------------------------------------------------ */
.sp-acc { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr); gap: 16px; align-items: start; }
.sp-acc > :nth-child(2) { grid-row: span 2; grid-column: 2; }
.sp-acc-card { padding: 24px 26px 26px; }
.sp-acc-card h2 { font-size: 15px; font-weight: 700; line-height: 1.5; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--line-soft); }
.sp-acc-card > p { font-size: 14px; color: var(--tx-mid); }
.sp-kv { display: grid; gap: 12px; }
.sp-kv > div { display: grid; grid-template-columns: 5em minmax(0, 1fr); gap: 12px; align-items: baseline; }
.sp-kv dt { font-size: 13px; color: var(--sp-dim); font-weight: 500; }
.sp-kv dd { font-weight: 700; overflow-wrap: anywhere; }
.sp-kv code { font-family: var(--num); font-size: 15px; font-weight: 700; padding: 3px 9px; background: var(--field); border: 1px solid var(--line-soft); border-radius: 6px; }
.sp-acc-note { margin-top: 16px; font-size: 13px !important; line-height: 1.7; color: var(--sp-dim) !important; }
#sp-pw-form { display: grid; gap: 18px; }
#sp-pw-form > .sp-btn { justify-self: start; }
.sp-formmsg { display: flex; align-items: flex-start; gap: 8px; padding: 11px 14px; font-size: 14px; font-weight: 500; border-radius: var(--r-sm); }
.sp-formmsg svg { margin-top: 2px; }
.sp-formmsg.is-ok { color: #1f6a43; background: var(--ok-soft); border: 1px solid #bfdfcb; }
.sp-formmsg.is-ok svg { color: var(--ok); }
.sp-formmsg.is-err { color: #8a2f21; background: var(--bad-soft); border: 1px solid #efc9bf; }
.sp-formmsg.is-err svg { color: var(--bad); }
.sp-contact { margin-top: 12px; }
.sp-contact a { display: inline-flex; align-items: center; gap: 8px; font-family: var(--num); font-weight: 700; font-size: 15px; }
.sp-acc-out { margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--line-soft); }

/* ------------------------------------------------------------
   幅ごとの調整
   ------------------------------------------------------------ */
@media (max-width: 960px) {
  .sp-acc { grid-template-columns: minmax(0, 1fr); }
  .sp-acc > :nth-child(2) { grid-row: auto; grid-column: auto; }
}
@media (max-width: 760px) {
  :root { --gut: 16px; }
  body { font-size: 15px; }
  .sp-bar { gap: 12px; min-height: 56px; }
  .sp-bar-logo img { width: 104px; }
  .sp-bar-who { flex-direction: column; gap: 0; padding-left: 12px; }
  .sp-bar-kind { font-size: 13px; }
  .sp-bar-school { font-size: 13.5px; }
  .sp-bar .sp-logout span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .sp-bar .sp-logout { width: 42px; padding: 0; }
  .sp-tabs { gap: 0; }
  .sp-tabs [role="tab"] { padding: 0 11px; font-size: 13.5px; min-height: 44px; }
  .sp-tabs [role="tab"]:first-child { margin-left: -11px; }
  .sp-tabs [role="tab"]::after { left: 11px; right: 11px; }
  .sp-main { padding-top: 24px; padding-bottom: 56px; }
  .sp-head { margin-bottom: 16px; }
  .sp-head h1 { font-size: 21px; }
  .sp-head p { font-size: 13.5px; }

  .sp-stat, .sp-stat + .sp-stat { padding: 10px 8px 10px 0; }
  .sp-stat + .sp-stat { padding-left: 10px; }
  .sp-stat dt { font-size: 13px; line-height: 1.45; }
  .sp-stat dd b { font-size: 26px; }
  .sp-stat dd span { font-size: 13px; }

  .sp-tools-row { gap: 10px; }
  .sp-seg { display: flex; width: 100%; }
  .sp-seg button { flex: 1 1 0; justify-content: center; padding: 0 6px; font-size: 13px; }
  .sp-search { flex: 1 1 100%; max-width: none; }
  .sp-result { flex: 1 1 auto; }
  /* 狭い幅：まとめ方 → 状態 → 検索 → 件数と CSV の順に並べ直す */
  .sp-tools { display: flex; flex-wrap: wrap; gap: 10px; }
  .sp-tools-row { display: contents; }
  #sp-viewsw { order: 1; } #sp-filter { order: 2; } .sp-search { order: 3; } .sp-result { order: 4; } #sp-csv { order: 5; }
  #sp-csv { min-height: 38px; padding: 0 14px; font-size: 13px; }

  .sp-stu { grid-template-columns: minmax(0, 1fr); }
  .sp-stu-h { flex-direction: row; align-items: baseline; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; border-right: 0; border-bottom: 1px solid var(--line-soft); }
  .sp-stu-name { font-size: 16px; }
  .sp-act { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "when chip" "title title"; padding: 12px 16px; gap: 4px 10px; }
  .sp-act-when { grid-area: when; font-size: 13px; }
  .sp-act-title { grid-area: title; font-size: 14px; }
  .sp-act .sp-chip { grid-area: chip; }

  .sp-actc { padding: 16px; }
  .sp-actc-h { flex-direction: column; gap: 8px; }
  .sp-names li { font-size: 13.5px; }

  .sp-demo { font-size: 13px; padding: 6px var(--gut); }
  .sp-demo-x { display: none; }
  .sp-tab-pre { display: none; }
  .sp-acc-card { padding: 20px 18px 22px; }
  .sp-kv > div { grid-template-columns: 4.5em minmax(0, 1fr); }
  .sp-state { padding: 40px 18px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

@media print {
  .sp-top, .sp-tools, .sp-foot, .sp-demo, .sp-head-a { display: none !important; }
  body { background: #fff; }
  .sp-card, .sp-stats-row { box-shadow: none; break-inside: avoid; }
}
