:root {
  --ink: #3b3b40;
  --sub: #85858f;
  --line: #e6e6ec;
  --card: #fff;
  --tile: #f3f4f7;
  --blue: #2f7be0;
  --green: #2fa36b;
  --amber: #d98a1c;
  --shadow: 0 2px 14px rgba(70, 70, 110, .09);
  --r: 14px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body { display: flow-root; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, #ccd4e3 0%, #d9d9e5 42%, #ead9d4 78%, #f0d6c8 100%) fixed;
  min-height: 100vh;
  -webkit-user-select: none; user-select: none;
  letter-spacing: .02em;
}
button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; padding: 0; }
input, select { font: inherit; color: inherit; -webkit-user-select: text; user-select: text; }
[hidden] { display: none !important; }

/* ---------- ホーム ---------- */
.home { max-width: 1180px; margin: 0 auto; padding: 6vh 32px 24px; }
a.tile { color: inherit; text-decoration: none; }
.lead { text-align: center; font-weight: 500; font-size: clamp(20px, 2.4vw, 30px); line-height: 1.75; margin: 0 0 4vh; }
.tile {
  background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; padding: 12px;
  transition: transform .12s, box-shadow .12s;
}
.tile:active { transform: scale(.98); box-shadow: 0 1px 6px rgba(70, 70, 110, .12); }
.tile svg { width: 46px; height: 46px; stroke: #4a4a52; fill: none; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }
.tile b { font-size: 19px; font-weight: 600; letter-spacing: .08em; text-align: center; }
.tile small { color: var(--sub); font-size: 13px; letter-spacing: .1em; }

/* 見出し（教職員／ご用件） */
.sec { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin: 0 4px 12px; }
.sec b { font-size: 19px; font-weight: 600; letter-spacing: .08em; }
.sec i { font-style: normal; font-size: 11px; letter-spacing: .32em; color: rgba(40, 40, 50, .6); }
.sec small { color: var(--green); font-size: 13px; font-weight: 600; }
.sec span { margin-left: auto; color: rgba(40, 40, 50, .8); font-size: 12px; }

/* 使い方の切り替え：.k＝iPad だけ、.v＝閲覧（学生のスマホ・PC）だけ */
body.view .k, body:not(.view) .v { display: none !important; }

/* 顔写真（なければ頭文字の丸） */
.av { flex: none; width: 56px; height: 56px; border-radius: 50%; object-fit: cover; display: inline-grid; place-items: center; font-weight: 600; font-size: 22px; -webkit-touch-callout: none; pointer-events: none; }

/* 教職員：上に一列。右へスライド＝在室・左へ＝不在、タップ＝コメント。不在は半透明、在室は白＋緑 */
.st-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 3vh; }
/* どのカードも写真と名前は上端にそろえる（コメントの有無で位置がずれないように） */
.st {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; align-content: flex-start; gap: 12px; padding: 16px;
  background: rgba(255, 255, 255, .5); border-radius: var(--r); box-shadow: var(--shadow); border: 1.5px solid transparent;
  touch-action: pan-y; -webkit-touch-callout: none; cursor: pointer; transition: transform .2s, background .2s;
}
.st[style*="translate"] { transition: background .2s; }
.st.on { background: #fff; border-color: rgba(47, 163, 107, .45); }
.st > .nm { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.st b { font-size: 19px; font-weight: 600; }
.st em { font-style: normal; font-size: 12px; font-weight: 600; letter-spacing: .1em; padding: 2px 10px; border-radius: 10px; align-self: flex-start; background: rgba(0, 0, 0, .06); color: var(--sub); }
.st.on em { background: rgba(47, 163, 107, .12); color: var(--green); }
.st:not(.on) .av { filter: grayscale(.6); opacity: .8; }
.st[data-hint=in] { background: #e6f5ec; }
.st[data-hint=out] { background: #ececf0; }
.st[data-hint]::after { position: absolute; top: 10px; right: 14px; font-size: 12px; font-weight: 600; letter-spacing: .1em; }
.st[data-hint=in]::after { content: "在室にする"; color: var(--green); }
.st[data-hint=out]::after { content: "不在にする"; color: var(--sub); }
.st-row .empty, .sd-row .empty { padding: 10px 4px; color: rgba(40, 40, 50, .7); }

/* 在室中の学生：小さく並べる */
.sd-row { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 3vh; }
.sd { cursor: pointer; display: inline-flex; align-items: center; gap: 9px; padding: 5px 18px 5px 5px; background: #fff; border-radius: 30px; box-shadow: var(--shadow); }
.sd:active { transform: scale(.97); }
body.view .sd { cursor: default; transform: none; }
.sd .av { width: 34px; height: 34px; font-size: 14px; }
.sd b { font-size: 14px; font-weight: 600; }
.sd small { font-size: 11px; color: var(--sub); }

/* 機材の貸し出し状況（閲覧用） */
.eq-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 10px; }
.eq { background: rgba(255, 255, 255, .7); border-radius: 10px; padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; box-shadow: var(--shadow); }
.eq b { font-size: 15px; font-weight: 600; }
.eq small { font-size: 12px; color: var(--green); }
.eq.out { background: #fbf4ea; }
.eq.out small { color: var(--amber); }

/* 小さいボタン（スマホの機材編集・コメント欄） */
.sbtn { display: inline-flex; align-items: center; height: 36px; padding: 0 16px; border-radius: 18px; font-size: 14px; border: 1px solid var(--line); background: #fff; white-space: nowrap; cursor: pointer; }
.sbtn.pri { background: var(--blue); border-color: var(--blue); color: #fff; }
.sec .sbtn { margin-left: auto; height: 32px; font-size: 13px; }
.msg { color: var(--sub); font-size: 13px; }
.foot-link { text-align: center; margin: 2vh 0 0; }
.foot-link a { color: rgba(40, 40, 50, .75); font-size: 13px; }

/* 教職員の共有画像：カード内の小さな見本と、大きく表示する画面 */
.sh { flex: none; width: 64px; height: 46px; border-radius: 6px; overflow: hidden; background: #e4e5ea; box-shadow: 0 1px 3px rgba(0, 0, 0, .1); }
.sh img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.done > .viewer { width: min(900px, 94vw); padding: 20px 20px 18px; }
.viewer img { display: block; max-width: 100%; max-height: 68vh; margin: 0 auto 12px; border-radius: 10px; }
.viewer h2 { font-size: 18px; margin: 0; }

/* 教職員のスマホ：自分のコメント欄 */
.mine { background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; margin-bottom: 3vh; }
.mine-h { display: flex; align-items: center; gap: 12px; }
.mine-h .av { width: 48px; height: 48px; font-size: 18px; }
.mine-h > div { display: flex; flex-direction: column; gap: 2px; }
.mine-h b { font-size: 17px; }
.mine-h small { font-size: 12px; color: var(--sub); }
.mine .chips { justify-content: flex-start; margin: 14px 0 10px; }
.mine textarea { width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; font: inherit; font-size: 16px; resize: vertical; -webkit-user-select: text; user-select: text; }
.mine-img img { display: block; max-width: 100%; max-height: 240px; border-radius: 10px; margin-top: 10px; }
.mine-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.mine-row .btn { flex: 0 0 120px; margin-left: auto; }

/* 機材の登録・編集（スマホ・PC） */
.eqe { grid-column: 1 / -1; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--tile); border-radius: 10px; padding: 10px; }
.eqe input:not([type=checkbox]) { flex: 1 1 160px; height: 38px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; font-size: 15px; background: #fff; }
.eqe label { font-size: 13px; display: inline-flex; align-items: center; gap: 4px; }

/* スマホ：借りる／返す（QR 読み取り）と、出勤時のお知らせ */
.borrow { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-bottom: 3vh; }
.borrow .tile { height: 110px; }
.borrow .tile svg { width: 38px; height: 38px; }
.borrow .msg { grid-column: 1 / -1; margin: 0; color: rgba(40, 40, 50, .8); }
.eq { flex-direction: row !important; align-items: center; justify-content: space-between; }
.eq > div { display: flex; flex-direction: column; gap: 4px; }
.scan { position: fixed; inset: 0; z-index: 30; background: #111; color: #fff; display: flex; flex-direction: column; transition: box-shadow .2s; }
.scan.hit { box-shadow: inset 0 0 0 8px var(--green); }
.scan video { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.scan-top { position: relative; padding: 16px; text-align: center; background: linear-gradient(rgba(0, 0, 0, .55), transparent); }
.scan-top p { margin: 10px 0 0; font-size: 14px; }
.seg { display: inline-flex; background: rgba(255, 255, 255, .2); border-radius: 22px; padding: 3px; }
.seg button { color: #fff; padding: 8px 26px; border-radius: 19px; font-size: 15px; }
.seg button.on { background: #fff; color: var(--ink); font-weight: 600; }
.shot { position: relative; margin: auto 16px 0; background: #fff; color: var(--ink); border-radius: 14px; padding: 16px; text-align: center; }
.shot p { margin: 0 0 12px; font-size: 15px; line-height: 1.6; }
.shot .row { display: flex; gap: 10px; }
.shot .btn { height: 48px; }
.scan-log { position: relative; list-style: none; margin: auto 0 0; padding: 0 16px; max-height: 32vh; overflow: auto; }
.shot:not([hidden]) + .scan-log { margin-top: 10px; }
.scan-log li { background: rgba(255, 255, 255, .9); color: var(--ink); border-radius: 10px; padding: 9px 12px; margin-top: 6px; font-size: 14px; border-left: 5px solid var(--green); }
.scan-log li.ng { border-left-color: #d0563b; }
.scan .scan-end { flex: 1; height: 50px; }
.done > .wide { width: min(560px, 92vw); }
.notice { text-align: left; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; max-height: 40vh; overflow: auto; }
.notice h3 { font-size: 13px; color: var(--sub); font-weight: 500; letter-spacing: .1em; margin: 0 0 8px; }
.nt { display: flex; align-items: center; gap: 10px; padding: 8px 0; }
.nt .av { width: 40px; height: 40px; font-size: 15px; }
.nt > div { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.nt b { font-size: 14px; } .nt span { font-size: 14px; line-height: 1.5; }

/* iPad（アプリ）：ホーム画面は画面ぴったり。ページはスクロール・引っぱりで動かさず、学生の一覧と操作パネルの中だけ動く */
html.kiosk, html.kiosk body { height: 100%; overflow: hidden; overscroll-behavior: none; }
html.kiosk .home { height: 100dvh; display: flex; flex-direction: column; padding-top: max(4vh, env(safe-area-inset-top)); padding-bottom: max(2vh, env(safe-area-inset-bottom)); }
html.kiosk .top { flex: none; margin-bottom: 3vh; }
html.kiosk .home > .sec, html.kiosk .st-row, html.kiosk .clock { flex: none; }
html.kiosk .st-row { margin-bottom: 2.5vh; }
html.kiosk .sd-row { flex: 1 1 0; min-height: 46px; overflow-y: auto; align-content: flex-start; margin-bottom: 2.5vh; }
html.kiosk .cards { flex: 0 1 220px; min-height: 110px; height: auto; } /* 画面が低い iPad では下のカードが縮む */
html.kiosk .clock { margin-top: 2vh; }
html.kiosk .panel { height: calc(100dvh - 8vh); overflow-y: auto; overscroll-behavior: contain; }

/* iPad：持ち出し中の機材（ホーム）、機材の画面の「返す」と予備の一覧、カメラの切り替え */
.eo-row { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 2.5vh; }
.eo { cursor: pointer; display: inline-flex; align-items: baseline; gap: 8px; padding: 7px 14px; background: #fbf4ea; border-radius: 20px; box-shadow: var(--shadow); border: 1px solid rgba(217, 138, 28, .25); }
.eo b { font-size: 14px; font-weight: 600; } .eo small { font-size: 12px; color: var(--amber); }
.eo:active, .eq[data-out]:active { transform: scale(.97); }
.eq[data-out] { cursor: pointer; }
.eo-row .empty { padding: 4px; color: rgba(40, 40, 50, .7); }
html.kiosk .eo-row { flex: none; max-height: 20vh; overflow: hidden; }
.opt.ret { grid-column: 1 / -1; min-height: 80px; background: #eaf2fd; border-color: rgba(47, 123, 224, .35); }
.opt.ret::before { display: none; }
.opt.ret b { font-size: 20px; color: var(--blue); }
.scan-bar { position: relative; flex: none; display: flex; gap: 10px; margin: 12px 16px calc(16px + env(safe-area-inset-bottom)); }
.flip { flex: none; height: 50px; padding: 0 18px; border-radius: 25px; color: #fff; background: rgba(255, 255, 255, .22); font-size: 14px; }
.scan video.mirror { transform: scaleX(-1); }

/* iPad のコメント画面の画像欄 */
.cm-img { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.cm-img #cimg { flex: 1 1 100%; }
.cm-img #cimg img { display: block; max-width: 100%; max-height: 140px; border-radius: 8px; margin: 0 auto; }

/* 教職員カード内のコメント欄（画像の有無で高さが変わらないよう、見本 46px が入る高さにそろえる） */
.st .cm { flex-basis: 100%; display: flex; align-items: center; gap: 10px; min-height: 58px; margin: 0; font-size: 13px; line-height: 1.5;
  background: rgba(255, 255, 255, .75); border-radius: 8px; padding: 6px 10px; overflow-wrap: anywhere; }
.st.on .cm { background: var(--tile); }
.st .cm span { flex: 1; text-align: left; }

/* Teams ボタンとメンバー一覧（スマホ・PC） */
.teams { display: inline-flex; align-items: center; gap: 5px; margin-left: auto; padding: 6px 12px; border-radius: 16px; background: #5b5fc7; color: #fff; font-size: 13px; font-weight: 600; text-decoration: none; flex: none; }
.teams svg { width: 15px; height: 15px; fill: #fff; }
.members { display: grid; gap: 8px; margin-bottom: 3vh; }
.members h3 { margin: 10px 0 0; font-size: 12px; color: rgba(40, 40, 50, .7); font-weight: 500; letter-spacing: .12em; }
.mb { display: flex; align-items: center; gap: 10px; background: rgba(255, 255, 255, .75); border-radius: 12px; padding: 8px 10px; }
.mb .av { width: 36px; height: 36px; font-size: 14px; }
.mb b { font-size: 15px; font-weight: 600; }
.mb em { font-style: normal; font-size: 11px; color: var(--green); background: rgba(47, 163, 107, .12); padding: 1px 8px; border-radius: 9px; }
.mb small { margin-left: auto; font-size: 12px; color: var(--sub); }

/* 研究室のロゴ（ホームの左上。元の画像の大きさ＝高さ 36px、スマホは少し小さく） */
/* あいさつ文と同じ段に、左にロゴ・中央に文。両側の列を同じ幅にして文を画面の真ん中に保つ。ロゴは文の上下中央にそろえる */
.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; column-gap: 16px; margin-bottom: 4vh; }
.top .brand { grid-column: 1; justify-self: start; }
.top .lead { grid-column: 2; margin: 0; }
.logo { display: block; height: 36px; width: auto; }
@media (max-width: 700px) { .logo { height: 28px; } .top { margin-bottom: 24px; } }

/* ご用件：カードを横に並べる */
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; height: clamp(150px, 24vh, 240px); }
.clock { text-align: center; color: rgba(60, 60, 70, .65); margin-top: 3vh; font-size: 14px; letter-spacing: .14em; }

/* コメント入力 */
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: 18px 0 12px; }
.chip { padding: 9px 14px; border-radius: 18px; background: var(--tile); font-size: 14px; }
.chip:active { background: #e3e5ea; }
.done input { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; font-size: 16px; }

/* ---------- 操作パネル（スクショの「白いカード」） ---------- */
.panel {
  max-width: 1080px; margin: 4vh auto; background: var(--card); border-radius: var(--r); box-shadow: var(--shadow);
  padding: 26px 34px 36px; display: grid; grid-template-columns: 260px 1fr; gap: 10px 40px; min-height: 70vh; align-content: start;
}
.back {
  grid-column: 1 / -1; width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--line);
  display: grid; place-items: center; box-shadow: 0 1px 4px rgba(0, 0, 0, .06);
}
.back svg { width: 20px; height: 20px; stroke: #666; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.side h2 { font-size: 22px; font-weight: 600; margin: 22px 0 12px; line-height: 1.5; }
.side p { color: var(--sub); font-size: 14px; line-height: 1.8; margin: 0; white-space: pre-line; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 12px; align-content: start; margin-top: 22px; }
.grid h3 { grid-column: 1 / -1; margin: 10px 0 0; font-size: 12px; color: var(--sub); font-weight: 500; letter-spacing: .12em; }
.opt {
  position: relative; background: var(--tile); border-radius: 10px; min-height: 96px; padding: 18px 10px 12px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; text-align: center;
  border: 1.5px solid transparent; transition: transform .1s, background .1s;
}
.opt:active { transform: scale(.97); background: #e9ebf0; }
.opt .av { width: 44px; height: 44px; font-size: 17px; }
.opt b { font-size: 16px; font-weight: 600; word-break: keep-all; overflow-wrap: anywhere; }
.opt small { font-size: 12px; color: var(--sub); line-height: 1.4; }
.opt::before {
  content: ""; position: absolute; top: 10px; left: 10px; width: 14px; height: 14px; border-radius: 50%;
  border: 1.5px solid #c9cad2; background: #fff;
}
.opt.on { border-color: rgba(47, 163, 107, .35); background: #eef7f1; }
.opt.on::before { background: var(--green); border-color: var(--green); }
.opt.out { border-color: rgba(217, 138, 28, .3); background: #fbf4ea; }
.opt.out::before { background: var(--amber); border-color: var(--amber); }
.opt.plain::before { display: none; }
.empty { grid-column: 1 / -1; color: var(--sub); font-size: 14px; padding: 20px 0; }

/* ---------- 完了表示 ---------- */
.done { position: fixed; inset: 0; background: rgba(60, 60, 80, .18); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); display: grid; place-items: center; z-index: 10; }
.done > div { background: #fff; border-radius: 18px; box-shadow: 0 10px 40px rgba(60, 60, 90, .18); width: min(440px, 90vw); padding: 36px 32px 26px; text-align: center; position: relative; overflow: hidden; }
.done svg { width: 64px; height: 64px; stroke: var(--green); fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.done h2 { margin: 12px 0 4px; font-size: 24px; font-weight: 600; letter-spacing: .08em; }
.done p { margin: 0; color: var(--sub); font-size: 15px; line-height: 1.7; }
.done .row { display: flex; gap: 12px; margin-top: 26px; }
.done .bar { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--blue); width: 100%; transform-origin: left; }
.btn {
  flex: 1; height: 48px; border-radius: 24px; color: #fff; font-weight: 600; letter-spacing: .1em;
  background: linear-gradient(90deg, #2f7be0, #6ea8e6);
}
.btn.ghost { color: var(--ink); background: #fff; border: 1px solid var(--line); }
.btn:disabled { opacity: .5; }

/* ---------- 合言葉入力 ---------- */
.gate { max-width: 420px; margin: 18vh auto; background: #fff; border-radius: var(--r); box-shadow: var(--shadow); padding: 32px; text-align: center; }
.gate h2 { font-weight: 600; font-size: 20px; margin: 0 0 10px; }
.gate p { color: var(--sub); font-size: 14px; line-height: 1.7; }
.gate input { width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 10px; padding: 0 14px; margin: 14px 0; font-size: 16px; }

/* ---------- スマホ ---------- */
@media (max-width: 700px) {
  .home { padding: 28px 16px; }
  .lead { font-size: 17px; margin-bottom: 24px; }
  .st-row { grid-template-columns: 1fr; gap: 10px; }
  .st { padding: 12px; } .st .av { width: 46px; height: 46px; font-size: 18px; }
  .sec span { margin-left: 0; width: 100%; }
  .cards { height: auto; grid-auto-rows: 140px; gap: 14px; }
  .tile svg { width: 36px; height: 36px; } .tile b { font-size: 16px; }
  .panel { grid-template-columns: 1fr; margin: 0; border-radius: 0; min-height: 100vh; padding: 18px 16px 28px; }
  .side h2 { margin-top: 12px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
