:root {
  --theme: #2b78c5;
  --theme-dark: #1c5e9e;
  --bg: #f7f4ee;
  --card: #ffffff;
  --ink: #33302b;
  --muted: #8a857c;
  --line: #eae5da;
  --accent: #f5f1e8;
  --danger: #d64545;
  --ok: #2f9e63;
  --warn: #d9822b;
  --star: #e8a70a;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "M PLUS Rounded 1c", -apple-system, BlinkMacSystemFont, "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
  line-height: 1.6;
  -webkit-text-size-adjust: 100%;
}
button { font-family: inherit; }
input, select, textarea {
  font-family: inherit;
  font-size: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 12px;
  background: #fff;
  color: var(--ink);
  max-width: 100%;
}
input:focus, select:focus, textarea:focus {
  outline: 2px solid color-mix(in srgb, var(--theme) 40%, transparent);
  border-color: var(--theme);
}
textarea { width: 100%; min-height: 72px; resize: vertical; }
label.fld { display: block; margin: 10px 0 2px; font-size: 12.5px; color: var(--muted); font-weight: 600; }

/* ---------- app bar ---------- */
.appbar {
  background: linear-gradient(135deg, var(--theme), var(--theme-dark));
  color: #fff;
  padding: 10px 16px calc(10px);
  padding-top: max(10px, env(safe-area-inset-top));
  position: sticky; top: 0; z-index: 40;
  box-shadow: 0 2px 10px rgba(0,0,0,.12);
}
.appbar-inner { display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; }
.applogo { font-size: 26px; filter: drop-shadow(0 1px 2px rgba(0,0,0,.2)); }
.apptitle { font-weight: 700; font-size: 17px; line-height: 1.3; }
.appsub { font-size: 11.5px; opacity: .85; }

/* ---------- layout ---------- */
.container { max-width: 760px; margin: 0 auto; padding: 14px 12px 110px; }
.tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 4px 2px 10px;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 64px; padding: 8px 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  font-size: 11.5px; font-weight: 600; color: var(--muted);
  cursor: pointer;
}
.tab-ic { font-size: 18px; }
.tab.on { background: var(--theme); border-color: var(--theme); color: #fff; box-shadow: 0 3px 8px color-mix(in srgb, var(--theme) 40%, transparent); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px; margin-bottom: 12px;
}
.card h2 { margin: 0 0 10px; font-size: 15px; color: var(--theme-dark); display: flex; align-items: center; gap: 6px; }
.card h2 .h2-side { margin-left: auto; font-size: 12px; color: var(--muted); font-weight: 500; }
.hint { font-size: 12px; color: var(--muted); background: var(--accent); border-radius: 8px; padding: 8px 10px; margin: 8px 0; }

/* ---------- stats row ---------- */
.stat-row { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-bottom: 12px; }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  text-align: center; padding: 10px 4px;
}
.stat b { display: block; font-size: 19px; color: var(--ink); }
.stat span { font-size: 11px; color: var(--muted); }
.stat[data-go] { cursor: pointer; }
.stat[data-go]:hover { border-color: var(--theme); }
@media (max-width: 420px) { .stat b { font-size: 16px; } }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--theme); color: #fff; border: none; border-radius: 10px;
  padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.ghost { background: #fff; color: var(--theme-dark); border: 1px solid var(--line); }
.btn.ghost.on { background: var(--theme); color: #fff; border-color: var(--theme); }
.btn.sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.btn.danger { background: #fff; color: var(--danger); border: 1px solid #f0c9c9; }
.btn.wide { width: 100%; padding: 13px; font-size: 15px; }
.btn.ok { background: var(--ok); }

/* ---------- chips & badges ---------- */
.badge {
  display: inline-block; font-size: 11px; font-weight: 700; border-radius: 999px;
  padding: 2px 8px; vertical-align: middle;
}
.badge.subj { color: #fff; }
.badge.gray { background: #eef1f5; color: var(--muted); }
.badge.warn { background: #fdf0e3; color: var(--warn); }
.badge.ok { background: #e6f6ed; color: var(--ok); }
.badge.danger { background: #fdeaea; color: var(--danger); }
.badge.star { background: #fdf6e0; color: var(--star); }
.badge.bday { background: #fdeef3; color: #d4527e; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  border-radius: 999px; padding: 5px 12px; font-size: 13px; cursor: pointer;
}
.chip.on { background: var(--theme); border-color: var(--theme); color: #fff; }

/* ---------- student list ---------- */
.filters { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.filters select { padding: 6px 8px; font-size: 13px; border-radius: 8px; }
.search { width: 100%; }
.slist { display: flex; flex-direction: column; gap: 8px; }
.scard {
  display: flex; align-items: center; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 12px; cursor: pointer;
}
.scard:hover { border-color: var(--theme); }
.avatar {
  flex: 0 0 40px; width: 40px; height: 40px; border-radius: 50%;
  background: var(--theme); color: #fff; font-weight: 700; font-size: 16px;
  display: flex; align-items: center; justify-content: center;
}
.avatar.rest { background: #a5afba; }
.avatar.trial { background: var(--warn); }
.scard .smain { flex: 1; min-width: 0; }
.scard .sname { font-weight: 700; font-size: 15px; }
.scard .ssub { font-size: 12px; color: var(--muted); }
.scard .sbadges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.scard .arrow { color: var(--muted); }

/* ---------- group accordion ---------- */
.gblock { margin-bottom: 10px; }
.ghead {
  display: flex; align-items: center; gap: 8px;
  background: color-mix(in srgb, var(--theme) 10%, #fff);
  border: 1px solid color-mix(in srgb, var(--theme) 25%, var(--line));
  border-radius: 10px; padding: 9px 12px; cursor: pointer;
  font-size: 14px; margin-bottom: 8px; user-select: none;
}
.ghead:hover { border-color: var(--theme); }
.gcaret { color: var(--theme-dark); font-size: 12px; width: 14px; }
.scard select { max-width: 130px; font-size: 12.5px; padding: 6px 8px; }

/* ---------- list rows ---------- */
.row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 9px 0; border-bottom: 1px solid var(--line);
}
.row:last-child { border-bottom: none; }
.row .grow { flex: 1; min-width: 0; }
.row small { color: var(--muted); }

/* ---------- overlay (student detail) ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(30,40,50,.45);
  overflow-y: auto; padding: 12px;
}
.overlay.hidden { display: none; }
.sheet {
  max-width: 720px; margin: 0 auto 40px;
  background: var(--bg); border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0,0,0,.3);
}
.sheet-head {
  position: sticky; top: 0; z-index: 5;
  background: #fff; padding: 10px 14px 8px; border-bottom: 1px solid var(--line);
  border-radius: 16px 16px 0 0;
}
.sheet-head-row { display: flex; align-items: center; gap: 10px; }
.sheet-head b { font-size: 17px; flex: 1; }
.sheet-nav { display: flex; gap: 6px; overflow-x: auto; padding-top: 8px; scrollbar-width: none; }
.sheet-nav::-webkit-scrollbar { display: none; }
.sheet-nav button {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--accent);
  color: var(--theme-dark); border-radius: 999px; padding: 4px 12px;
  font-size: 12px; font-weight: 600; cursor: pointer;
}
.sheet-body .card { scroll-margin-top: 108px; }
.sheet-body { padding: 12px; }

/* ---------- calendar ---------- */
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-head b { font-size: 16px; }
.cal { width: 100%; border-collapse: collapse; table-layout: fixed; }
.cal th { font-size: 11.5px; color: var(--muted); padding: 4px 0; font-weight: 600; }
.cal th.sun { color: #d64545; } .cal th.sat { color: #3a7fd5; }
.cal td {
  border: 1px solid var(--line); background: #fff; height: 56px;
  vertical-align: top; padding: 3px 4px; font-size: 12px; cursor: pointer;
}
.cal td.dim { background: transparent; border-color: transparent; cursor: default; }
.cal td.classday { background: #f3f9ff; }
.cal td.today { outline: 2px solid var(--theme); outline-offset: -2px; }
.cal td.sel { background: color-mix(in srgb, var(--theme) 14%, #fff); }
.cal .dnum { font-weight: 700; }
.cal td .mk { display: block; font-size: 10.5px; line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mk.att { color: var(--ok); } .mk.ev { color: var(--warn); } .mk.bd { color: #d4527e; }

/* attendance check list */
.attrow { display: flex; align-items: center; gap: 6px; padding: 7px 0; border-bottom: 1px solid var(--line); }
.attrow:last-child { border-bottom: none; }
.attrow .nm { flex: 1; min-width: 0; font-size: 14px; }
.attrow .nm small { color: var(--muted); font-size: 11.5px; }
.attbtn {
  min-width: 40px; padding: 6px 0; border-radius: 8px; border: 1px solid var(--line);
  background: #fff; color: var(--muted); font-size: 13px; font-weight: 700; cursor: pointer;
}
.attbtn.o.on { background: var(--ok); border-color: var(--ok); color: #fff; }
.attbtn.x.on { background: var(--danger); border-color: var(--danger); color: #fff; }
.attbtn.f.on { background: var(--warn); border-color: var(--warn); color: #fff; }

/* ---------- bars (stats) ---------- */
.bar-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; font-size: 13px; }
.bar-row .bl { flex: 0 0 92px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-row .bar { flex: 1; height: 14px; background: var(--accent); border-radius: 7px; overflow: hidden; }
.bar-row .bar > i { display: block; height: 100%; background: var(--theme); border-radius: 7px; }
.bar-row .bv { flex: 0 0 auto; font-weight: 700; font-size: 12.5px; }

/* ---------- progress graph ---------- */
.graph-wrap { overflow-x: auto; }
.subj-block { border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; }
.subj-block .subj-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.subj-block .subj-head b { font-size: 14.5px; }

/* ---------- fab ---------- */
.fab {
  position: fixed; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); z-index: 50;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--theme); color: #fff; font-size: 28px; border: none; cursor: pointer;
  box-shadow: 0 6px 16px color-mix(in srgb, var(--theme) 50%, transparent);
}
.fab-menu {
  position: fixed; right: 18px; bottom: calc(84px + env(safe-area-inset-bottom)); z-index: 50;
  display: flex; flex-direction: column; gap: 8px;
}
.fab-menu button {
  background: #fff; border: 1px solid var(--line); border-radius: 12px;
  padding: 10px 14px; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.15); text-align: left;
}
.fab-menu.hidden { display: none; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: rgba(35,45,55,.92); color: #fff; font-size: 13.5px;
  padding: 9px 18px; border-radius: 999px; z-index: 80; transition: opacity .3s;
  max-width: 90vw; text-align: center;
}
.toast.hidden { opacity: 0; pointer-events: none; }

.hidden { display: none !important; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; }
.tc { text-align: center; } .muted { color: var(--muted); }
.flex { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spread { justify-content: space-between; }
hr.sep { border: none; border-top: 1px solid var(--line); margin: 12px 0; }

/* settings list */
.set-item { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.set-item:last-child { border-bottom: none; }
.set-item .grow { flex: 1; }
.color-inputs input[type=color] { padding: 2px; width: 46px; height: 34px; }

/* 進度クイックボタン */
.qbtns { display: inline-flex; gap: 4px; }
.qbtns button {
  border: 1px solid var(--line); background: #fff; border-radius: 8px;
  padding: 6px 9px; font-size: 12.5px; font-weight: 700;
  color: var(--theme-dark); cursor: pointer;
}
.qbtns button:active { transform: scale(.96); }

/* ---------- スマホ：下部固定ナビ ---------- */
@media (max-width: 640px) {
  .tabs {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 45;
    margin: 0; padding: 6px 6px calc(6px + env(safe-area-inset-bottom));
    background: var(--card); border-top: 1px solid var(--line);
    justify-content: space-around; gap: 2px; overflow-x: visible;
    box-shadow: 0 -2px 10px rgba(0,0,0,.07);
  }
  .tab { flex: 1; min-width: 0; padding: 5px 2px; border: none; font-size: 10.5px; border-radius: 10px; }
  .tab-ic { font-size: 20px; }
  .container { padding-bottom: 170px; }
  .fab { bottom: calc(86px + env(safe-area-inset-bottom)); width: 52px; height: 52px; font-size: 26px; }
  .fab-menu { bottom: calc(146px + env(safe-area-inset-bottom)); }
  .toast { bottom: calc(150px + env(safe-area-inset-bottom)); }
  .attbtn { min-width: 46px; padding: 10px 0; }
}

/* welcome */
.welcome { text-align: center; padding: 30px 16px; }
.welcome h1 { font-size: 19px; margin: 8px 0; }
.welcome p { color: var(--muted); font-size: 13.5px; }
.welcome .btn { margin: 6px 4px; }
.wsvg { width: 200px; max-width: 72%; height: auto; display: block; margin: 0 auto 6px; }

/* ============ サイト風リデザイン ============ */
/* SVGアイコン共通 */
.ic { width: 1.15em; height: 1.15em; vertical-align: -0.22em; flex: 0 0 auto; }
button .ic { pointer-events: none; }

/* アプリバー：ロゴバッジ＋今日の日付 */
.appbar { background: linear-gradient(120deg, var(--theme), var(--theme-dark)); }
.applogo {
  display: flex; align-items: center; justify-content: center;
  width: 42px; height: 42px; font-size: 22px; flex: 0 0 auto;
  background: rgba(255,255,255,.18); border-radius: 13px;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.25);
  filter: none;
}
.appdate {
  margin-left: auto; font-size: 12px; white-space: nowrap;
  background: rgba(255,255,255,.15); padding: 5px 12px; border-radius: 999px;
}
.appdate b { font-size: 14px; margin-right: 1px; }

/* カード・見出し */
.card { box-shadow: 0 1px 2px rgba(20,45,75,.05); }
.card h2 { color: var(--ink); gap: 8px; }
.h2ic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 27px; border-radius: 8px; flex: 0 0 auto;
  background: color-mix(in srgb, var(--theme) 12%, #fff);
  color: var(--theme-dark);
}
.h2ic .ic { width: 15px; height: 15px; vertical-align: 0; }

/* タブのアイコン */
.tab-ic { display: flex; align-items: center; justify-content: center; }
.tab-ic .ic { width: 19px; height: 19px; vertical-align: 0; }

/* 統計タイル */
.stat { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 11px 4px 9px; }
.sic {
  display: inline-flex; align-items: center; justify-content: center;
  width: 27px; height: 27px; border-radius: 50%; margin-bottom: 2px;
  background: color-mix(in srgb, var(--theme) 11%, #fff);
  color: var(--theme-dark);
}
.sic .ic { width: 14px; height: 14px; vertical-align: 0; }

/* バッジ・チップ・ボタン内のアイコン */
.badge .ic { width: 12px; height: 12px; vertical-align: -0.14em; }
.chip .ic { width: 13px; height: 13px; vertical-align: -0.14em; }
.btn .ic { width: 1.05em; height: 1.05em; }

/* FAB・メニュー */
.fab { display: flex; align-items: center; justify-content: center; }
.fab .ic { width: 26px; height: 26px; }
.fab-menu button { display: flex; align-items: center; gap: 9px; }
.fab-menu .ic { width: 17px; height: 17px; color: var(--theme-dark); }

@media (max-width: 520px) {
  .appdate { display: none; }
}


/* ============ 脱テンプレ・デザイン刷新 ============ */
/* 白いアプリバー（カラーはロゴとアクセントに集約） */
.appbar {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 0 var(--line);
}
.apptitle { color: var(--ink); font-weight: 800; letter-spacing: .01em; }
.appsub { color: var(--muted); opacity: 1; }
.applogo {
  background: linear-gradient(135deg, var(--theme), var(--theme-dark));
  box-shadow: 0 3px 8px color-mix(in srgb, var(--theme) 35%, transparent);
}
.appdate {
  background: color-mix(in srgb, var(--theme) 9%, #fff);
  color: var(--theme-dark);
  font-weight: 700;
}

/* 丸み・影の統一 */
.card { border-radius: 18px; }
.card h2 { font-weight: 800; }
.btn { border-radius: 999px; box-shadow: 0 2px 6px color-mix(in srgb, var(--theme) 22%, transparent); }
.btn.ghost, .btn.danger { box-shadow: none; }
.btn.sm { border-radius: 999px; }
.stat { border-radius: 16px; }
.tab { border-radius: 14px; }
.scard { border-radius: 15px; }
.welcome h1, .intake-head h1 { font-weight: 800; }

/* 集計サマリーチップ */
.sumchips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.sumchip {
  background: var(--accent); border-radius: 12px; padding: 6px 12px;
  display: flex; flex-direction: column; line-height: 1.35;
}
.sumchip small { font-size: 10.5px; color: var(--muted); }
.sumchip b { font-size: 14.5px; }

/* ---------- カウンセリングシート ---------- */
.req { font-size: 10px; background: #fdeaea; color: var(--danger); border-radius: 6px; padding: 1px 6px; margin-left: 4px; vertical-align: middle; }
.linkbox {
  background: var(--accent); border: 1px dashed color-mix(in srgb, var(--theme) 35%, var(--line));
  border-radius: 10px; padding: 9px 11px; font-size: 12px; word-break: break-all;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; color: var(--theme-dark);
}
.setup-steps { margin: 8px 0; padding-left: 20px; font-size: 13px; }
.setup-steps li { margin-bottom: 8px; }
.setup-steps a { color: var(--theme-dark); }
.inbox-item {
  border: 1px solid var(--line); border-left: 4px solid var(--theme);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; background: #fff;
}
.intake-wrap { max-width: 560px; margin: 0 auto; padding: 20px 14px 70px; }
.intake-head { text-align: center; padding: 8px 0 14px; }
.intake-head h1 { font-size: 20px; margin: 8px 0 0; }
.intake-head p { margin: 4px 0; }
.intake-logo {
  margin: 0 auto; width: 54px; height: 54px; font-size: 28px; border-radius: 17px;
  display: flex; align-items: center; justify-content: center; color: #fff;
}
.ipad-sheet { position: fixed; inset: 0; background: var(--bg); overflow-y: auto; z-index: 70; }
.intake-done { text-align: center; padding: 70px 20px; }
.intake-done h1 { font-size: 21px; font-weight: 800; }
