/* 塾授業進捗確認アプリ の見た目。スマホは下のタブ、パソコンは左のメニュー。 */
:root {
  --ink: #1f2328;
  --ink2: #52514e;
  --muted: #6b6a66;
  --line: #d9d8d0;
  --bg: #f6f6f3;
  --surface: #ffffff;
  --brand: #1f6f8b;
  --brand-dark: #17566c;
  --brand-soft: #e3f0f4;
  --ok: #1b7a4f;
  --ok-soft: #e2f3ea;
  --warn: #8a5a00;
  --warn-soft: #fff3d6;
  --bad: #b3261e;
  --bad-soft: #fde7e5;
  --info: #22568f;
  --info-soft: #e5eefa;
  --radius: 10px;
  --tap: 44px;
  --nav-w: 220px;
  --bottom-h: 60px;
  font-size: 16px;
}
html[data-font="large"] { font-size: 18px; }
html[data-font="xlarge"] { font-size: 20px; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", Meiryo, sans-serif;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
  /* 文字は文節で折り返す（対応していないブラウザは、行頭の禁則を守って折り返す） */
  word-break: auto-phrase;
  line-break: strict;
  overflow-wrap: anywhere;
}
img, svg { max-width: 100%; }
a { color: var(--brand-dark); text-underline-offset: 2px; }
a:hover { color: var(--brand); }
h1 { font-size: 1.5rem; line-height: 1.4; margin: 0; }
h2 { font-size: 1.15rem; line-height: 1.4; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
p { margin: .5rem 0; }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.break { word-break: break-all; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.center { text-align: center; }
[hidden] { display: none !important; }

:focus-visible { outline: 3px solid #f0a500; outline-offset: 2px; }
.skip { position: absolute; left: -9999px; top: 0; background: var(--surface); padding: .5rem 1rem; z-index: 100; }
.skip:focus { left: .5rem; top: .5rem; }
.noscript { padding: 2rem; text-align: center; }

/* ---- 上の帯 ---- */
.top {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; gap: .5rem;
  padding: .25rem .75rem; padding-top: max(.25rem, env(safe-area-inset-top));
  padding-left: max(.75rem, env(safe-area-inset-left)); padding-right: max(.75rem, env(safe-area-inset-right));
  background: var(--surface); border-bottom: 1px solid var(--line);
  min-height: 56px;
}
.brand { display: flex; align-items: center; gap: .5rem; color: var(--ink); text-decoration: none; font-weight: 700; min-height: var(--tap); min-width: 0; }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tools { margin-left: auto; display: flex; align-items: center; gap: .25rem; flex-wrap: wrap; justify-content: flex-end; }
.hbtn {
  display: inline-flex; align-items: center; justify-content: center; gap: .25rem;
  min-height: var(--tap); min-width: var(--tap); padding: 0 .6rem;
  border: 1px solid transparent; border-radius: 8px; background: none; color: var(--ink2);
  font: inherit; font-size: .875rem; cursor: pointer; text-decoration: none; white-space: nowrap;
}
.hbtn:hover { background: var(--bg); border-color: var(--line); color: var(--ink); }
.hbtn.menu { display: none; }
.count { display: inline-block; min-width: 1.4em; padding: 0 .35em; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; line-height: 1.4em; text-align: center; }
.who { max-width: 10em; overflow: hidden; text-overflow: ellipsis; }

/* ---- 知らせの帯 ---- */
.banners:empty { display: none; }
.banner { padding: .6rem 1rem; border-bottom: 1px solid var(--line); font-size: .9375rem; }
.banner.info { background: var(--info-soft); }
.banner.warn { background: var(--warn-soft); }
.banner.staging { background: #5b2a86; color: #fff; text-align: center; font-weight: 700; }
.banner a, .banner .linkbtn { margin-left: .25rem; }

/* ---- 枠 ---- */
.layout { display: grid; grid-template-columns: var(--nav-w) minmax(0, 1fr); min-height: calc(100vh - 56px); }
.layout.guest { grid-template-columns: minmax(0, 1fr); }
.side { background: var(--surface); border-right: 1px solid var(--line); padding: .75rem .5rem; }
.side ul { list-style: none; margin: 0; padding: 0; position: sticky; top: 64px; }
.side a {
  display: flex; align-items: center; min-height: var(--tap); padding: 0 .75rem; border-radius: 8px;
  color: var(--ink); text-decoration: none;
}
.side a:hover { background: var(--bg); }
.side a[aria-current="page"] { background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; box-shadow: inset 4px 0 0 var(--brand); }
.main { padding: 1.25rem; max-width: 1100px; width: 100%; }
.layout.guest .main { margin: 0 auto; max-width: 760px; }
.foot {
  display: flex; flex-wrap: wrap; gap: .25rem 1rem; justify-content: center; align-items: center;
  padding: 1.5rem 1rem 2rem; border-top: 1px solid var(--line); background: var(--surface); font-size: .875rem;
}
.foot a { min-height: var(--tap); display: inline-flex; align-items: center; }

/* ---- ページ ---- */
.page > * + * { margin-top: 1rem; }
.crumbs ol { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem; margin: 0; padding: 0; font-size: .875rem; color: var(--muted); }
.crumbs li + li::before { content: "›"; margin-right: .25rem; }
.crumbs a { display: inline-flex; min-height: 32px; align-items: center; }
.titlebar { display: flex; align-items: center; gap: .75rem; flex-wrap: wrap; }
.titlebar h1 { flex: 1 1 auto; min-width: 0; }
.titlebar h1:focus { outline: none; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem 1.25rem; }
.card.narrow, details.narrow { max-width: 560px; }
.card.center { text-align: center; margin: 2rem auto; max-width: 520px; }
details.card > summary { cursor: pointer; font-weight: 700; min-height: var(--tap); display: flex; align-items: center; }
.notice { background: var(--info-soft); border-radius: 8px; padding: .6rem .9rem; }
.notice.warn { background: var(--warn-soft); }
.notice.bad { background: var(--bad-soft); }
.empty { text-align: center; padding: 1.25rem .5rem; color: var(--ink2); }
.empty p { margin: 0 0 .75rem; }
.loading { color: var(--muted); padding: 1rem 0; }
.errorpage { max-width: 560px; margin: 3rem auto; padding: 1.5rem; background: var(--surface); border-radius: var(--radius); }
.eid { color: var(--muted); }

/* ---- ボタン ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .35rem;
  min-height: var(--tap); padding: .4rem 1rem; border-radius: 8px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; text-align: center; line-height: 1.3;
}
.btn:hover { border-color: var(--brand); color: var(--brand-dark); }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-dark); color: #fff; }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.danger:hover { background: #8f1d17; color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { min-height: 36px; padding: .2rem .7rem; font-size: .875rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.linkbtn { background: none; border: 0; padding: 0 .25rem; color: var(--brand-dark); text-decoration: underline; font: inherit; cursor: pointer; min-height: var(--tap); }
.row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.wrap { flex-wrap: wrap; }
.row.center { justify-content: center; }
.row.actions { margin-top: .75rem; }
.links { margin-top: 1rem; }
.links a { display: inline-flex; min-height: var(--tap); align-items: center; }

/* ---- フォーム ---- */
.form .field { margin: 0 0 .9rem; }
.form label { display: block; font-weight: 600; margin-bottom: .25rem; }
.form .check label { display: flex; gap: .5rem; align-items: flex-start; font-weight: 400; min-height: var(--tap); padding-top: .55rem; cursor: pointer; }
.form .check input { width: 1.25rem; height: 1.25rem; margin-top: .2rem; flex: none; }
.req { color: var(--bad); font-weight: 400; font-size: .8125rem; margin-left: .25rem; }
input[type=text], input[type=email], input[type=password], input[type=search], input[type=date], input[type=time],
input[type=number], input[type=tel], input[type=url], input:not([type]), select, textarea {
  width: 100%; max-width: 100%; min-height: var(--tap);
  /* 16px より小さいと、iPhone で入力のたびに画面が拡大される */
  font: inherit; font-size: max(16px, 1rem);
  padding: .45rem .65rem; border: 1px solid #a9a89f; border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { min-height: 6rem; resize: vertical; }
input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--bad); box-shadow: 0 0 0 2px var(--bad-soft); }
.help { color: var(--muted); font-size: .875rem; margin: .25rem 0 0; }
.err { color: var(--bad); font-size: .9rem; margin: .25rem 0 0; }
.err:empty { display: none; }
.err.general { background: var(--bad-soft); padding: .5rem .75rem; border-radius: 8px; margin-bottom: .75rem; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.pwwrap { display: flex; gap: .4rem; }
.pwwrap input { flex: 1 1 auto; min-width: 0; }
.pwwrap .showpw { flex: none; min-height: var(--tap); }
.form.inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.form.inline .field { margin: 0; flex: 1 1 10rem; }
.form.inline .row.actions { margin: 0; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(14rem, 1fr)); gap: 0 1rem; }
.search { display: flex; gap: .4rem; flex: 1 1 18rem; max-width: 30rem; }
.search input { flex: 1 1 auto; min-width: 0; }
.filters { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.filters select { width: auto; }

/* ---- 一覧 ---- */
.list { list-style: none; margin: 0; padding: 0; }
.list > li { padding: .65rem 0; border-bottom: 1px solid var(--line); }
.list > li:last-child { border-bottom: 0; }
.list > li.unread { font-weight: 700; }
.list .line { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; justify-content: space-between; }
.list a.rowlink { display: block; text-decoration: none; color: inherit; min-height: var(--tap); }
.list a.rowlink:hover strong { text-decoration: underline; }
.badge { display: inline-block; padding: .05rem .55rem; border-radius: 999px; font-size: .8125rem; font-weight: 600; background: var(--bg); color: var(--ink2); border: 1px solid var(--line); white-space: nowrap; vertical-align: middle; }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: #b7dfc9; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: #f0d79c; }
.badge.bad { background: var(--bad-soft); color: var(--bad); border-color: #f2b8b3; }
.badge.info { background: var(--info-soft); color: var(--info); border-color: #bcd0ec; }
.pager { display: flex; gap: .75rem; align-items: center; justify-content: center; margin-top: 1rem; flex-wrap: wrap; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { border-collapse: collapse; width: 100%; font-size: .9375rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; margin: 0 0 1rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; }
.tabs { display: flex; gap: .25rem; overflow-x: auto; border-bottom: 1px solid var(--line); -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.tabs a { flex: none; display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 .9rem; text-decoration: none; color: var(--ink2); border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs a[aria-current="page"] { color: var(--brand-dark); border-bottom-color: var(--brand); font-weight: 700; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr)); gap: .6rem; }
.tile { display: flex; flex-direction: column; padding: .75rem; border: 1px solid var(--line); border-radius: var(--radius); text-decoration: none; color: var(--ink2); background: var(--surface); min-height: var(--tap); }
.tile .n { font-size: 1.6rem; font-weight: 700; color: var(--ink); line-height: 1.2; }
.tile.has { border-color: var(--brand); background: var(--brand-soft); }
.progress { height: 10px; border-radius: 999px; background: var(--bg); border: 1px solid var(--line); overflow: hidden; margin-bottom: .5rem; }
.progress span { display: block; height: 100%; background: var(--brand); }
.steps { margin: 0; padding-left: 1.4rem; }
.steps li { padding: .2rem 0; }
.steps li.done { color: var(--muted); }
.codes { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); gap: .35rem; }
.codes code { font-size: 1.05rem; }
.qr { width: 220px; max-width: 100%; background: #fff; padding: .5rem; border: 1px solid var(--line); border-radius: 8px; }
.qr svg { display: block; width: 100%; height: auto; }
.faq details { margin-bottom: .5rem; }
.doc h2 { margin-top: 1.25rem; }
.doc ul, .doc ol { padding-left: 1.4rem; }
.rich p { margin: 0 0 .5rem; }

/* ---- 出欠 ---- */
.roster { list-style: none; margin: 0; padding: 0; }
.roster > li { padding: .75rem 0; border-bottom: 1px solid var(--line); }
.roster .who-line { display: flex; gap: .5rem; align-items: baseline; flex-wrap: wrap; margin-bottom: .35rem; }
.choices { display: flex; flex-wrap: wrap; gap: .35rem; border: 0; margin: 0; padding: 0; }
.choices legend { position: absolute; left: -10000px; }
.choices label {
  display: inline-flex; align-items: center; justify-content: center; min-height: var(--tap); min-width: 4.2rem;
  padding: 0 .75rem; border: 1px solid var(--line); border-radius: 999px; cursor: pointer; background: var(--surface); font-weight: 600;
}
.choices input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.choices input:focus-visible + span { outline: 3px solid #f0a500; outline-offset: 4px; border-radius: 4px; }
.choices input:checked + span::before { content: "✓ "; }
.choices label:has(input:checked) { background: var(--brand); border-color: var(--brand); color: #fff; }
.choices label.st-absent:has(input:checked) { background: var(--bad); border-color: var(--bad); }
.choices label.st-late:has(input:checked), .choices label.st-early:has(input:checked) { background: #b07800; border-color: #b07800; }
.choices label.st-absent_notice:has(input:checked) { background: var(--info); border-color: var(--info); }
.choices label.st-none:has(input:checked) { background: var(--bg); color: var(--ink2); border-color: var(--line); }
.roster .notes { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; margin-top: .4rem; }
.roster .notes input { min-height: 40px; }
.stickybar { position: sticky; bottom: 0; background: var(--surface); padding: .6rem 0; border-top: 1px solid var(--line); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; z-index: 5; }
.summary { display: flex; flex-wrap: wrap; gap: .4rem; }

/* ---- お問い合わせのやり取り ---- */
.thread { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .6rem; }
.thread li { max-width: 85%; padding: .6rem .85rem; border-radius: 12px; background: var(--bg); border: 1px solid var(--line); }
.thread li.mine { align-self: flex-end; background: var(--brand-soft); border-color: #b9d8e2; }
.thread .meta { font-size: .8125rem; color: var(--muted); }

/* ---- 知らせ（トースト） ---- */
.toasts { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: 1rem; display: flex; flex-direction: column; gap: .5rem; width: min(560px, calc(100vw - 1.5rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: .5rem; align-items: center; padding: .6rem .5rem .6rem 1rem; border-radius: 10px; background: #1f2328; color: #fff; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.toast span { flex: 1 1 auto; }
.toast.error { background: var(--bad); }
.toast.info { background: #22405c; }
.toast .linkbtn { color: #fff; font-weight: 700; }
.toast .x { background: none; border: 0; color: #fff; font-size: 1.25rem; min-width: var(--tap); min-height: var(--tap); cursor: pointer; }

/* ---- 確認の窓 ---- */
.dialog { border: 0; border-radius: 12px; padding: 1.25rem; width: min(480px, calc(100vw - 1.5rem)); box-shadow: 0 12px 40px rgba(0,0,0,.25); }
.dialog::backdrop { background: rgba(20, 24, 28, .45); }
.dialog h2 { margin-top: 0; }
.dialog label { display: block; font-weight: 600; margin: .75rem 0 .25rem; }
.dialog .row.end { margin-top: 1rem; }

/* ---- グラフ ---- */
.figure { margin: 0; }
.figure figcaption { font-weight: 600; margin-bottom: .4rem; }
.chartbox { position: relative; }
.chart { width: 100%; height: auto; display: block; border-radius: 8px; }
.chart-tip { position: absolute; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: .35rem .6rem; font-size: .8125rem; box-shadow: 0 4px 14px rgba(0,0,0,.12); pointer-events: none; max-width: 180px; }
.legend { list-style: none; display: flex; flex-wrap: wrap; gap: .25rem 1rem; padding: 0; margin: 0 0 .4rem; font-size: .875rem; color: var(--ink2); }
.swatch { display: inline-block; width: .8rem; height: .8rem; border-radius: 3px; margin-right: .35rem; vertical-align: -1px; }
.tableview { margin-top: .5rem; }
.tableview summary { cursor: pointer; min-height: var(--tap); display: flex; align-items: center; color: var(--brand-dark); }

/* ---- 止めている間 ---- */
.gate { padding: 1rem; }

/* ---- スマホ: 下のタブ・メニューを折りたたむ ---- */
@media (max-width: 760px) {
  .layout { display: block; min-height: 0; }
  .main { padding: 1rem max(.85rem, env(safe-area-inset-left)) calc(var(--bottom-h) + 1.5rem + env(safe-area-inset-bottom)); }
  .layout.guest .main { padding-bottom: 1.5rem; }
  .side {
    position: fixed; z-index: 40; left: 0; right: 0; bottom: 0; top: auto;
    border-right: 0; border-top: 1px solid var(--line); padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    box-shadow: 0 -2px 12px rgba(0,0,0,.06);
  }
  .side ul { position: static; display: flex; overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none; scroll-snap-type: x proximity; }
  .side ul::-webkit-scrollbar { display: none; }
  .side li { flex: none; scroll-snap-align: start; }
  .side a { min-height: var(--bottom-h); padding: 0 .9rem; border-radius: 0; font-size: .875rem; }
  .side a[aria-current="page"] { box-shadow: inset 0 3px 0 var(--brand); }
  body.navopen .side { top: 56px; overflow-y: auto; }
  body.navopen .side ul { display: grid; grid-template-columns: 1fr 1fr; overflow: visible; padding: .5rem; gap: .25rem; }
  body.navopen .side a { min-height: 52px; border-radius: 8px; font-size: 1rem; }
  .hbtn.menu { display: inline-flex; }
  .tools .hbtn { padding: 0 .45rem; font-size: .8125rem; }
  .who { display: none !important; }
  .foot { padding-bottom: calc(var(--bottom-h) + 1.5rem + env(safe-area-inset-bottom)); }
  .layout.guest + .foot { padding-bottom: 2rem; }
  .card { padding: .9rem; }
  h1 { font-size: 1.3rem; }
  .roster .notes { grid-template-columns: 1fr; }
  .toasts { bottom: calc(var(--bottom-h) + .75rem + env(safe-area-inset-bottom)); }
  .thread li { max-width: 100%; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: .5rem; }
}
@media (max-width: 420px) {
  .brand span { max-width: 9em; }
}

/* ---- 動きを減らす ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
@media print {
  .top, .side, .foot, .banners, .toasts, .btn, .pager { display: none !important; }
  .layout { display: block; }
  body { background: #fff; }
}
