:root {
  --main: #1f6fb2;
  --main-dark: #17578c;
  --accent: #f39c12;
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #22303c;
  --muted: #6b7a88;
  --line: #dde4ec;
  --ok: #2e9e5b;
  --warn: #d9534f;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  background: var(--bg); color: var(--text); line-height: 1.7; font-size: 16px;
  -webkit-text-size-adjust: 100%;
}
header.top {
  background: var(--main); color: #fff; padding: 10px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  position: sticky; top: 0; z-index: 5;
}
header.top h1 { font-size: 17px; margin: 0; font-weight: 700; letter-spacing: .02em; }
header.top small { display: block; font-size: 11px; opacity: .85; font-weight: 400; }
header.top button { background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 999px; padding: 6px 12px; font-size: 13px; }
main { max-width: 640px; margin: 0 auto; padding: 16px; }
main.wide { max-width: 1100px; }
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 3px rgba(20,40,60,.08); margin-bottom: 14px; }
h2 { font-size: 18px; margin: 4px 0 12px; }
label { display: block; font-weight: 600; font-size: 14px; margin: 12px 0 4px; }
input[type=text], input[type=password], select, textarea {
  width: 100%; font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
textarea { min-height: 72px; resize: vertical; }
button { font: inherit; cursor: pointer; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 0; border-radius: 12px; padding: 12px 18px; font-weight: 700; background: var(--main); color: #fff; }
.btn:disabled { opacity: .5; cursor: default; }
.btn.big { width: 100%; padding: 16px; font-size: 18px; }
.btn.sub { background: #e8eff7; color: var(--main-dark); }
.btn.ok { background: var(--ok); }
.btn.accent { background: var(--accent); }
.btn.small { padding: 6px 12px; font-size: 13px; border-radius: 9px; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row > * { flex: 1; }
.muted { color: var(--muted); font-size: 13px; }
.err { color: var(--warn); font-size: 14px; min-height: 1.2em; margin-top: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.chip.on { background: var(--main); border-color: var(--main); color: #fff; }
.photo-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.photo-pick label { margin: 0; }
.photo-pick .btn { width: 100%; }
.preview { width: 100%; border-radius: 10px; border: 1px solid var(--line); margin-top: 10px; background: #fff; }
.qimg { width: 100%; max-height: 420px; object-fit: contain; border-radius: 10px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; }
.hint { border-left: 5px solid var(--accent); background: #fff8ec; border-radius: 10px; padding: 12px 14px; margin: 12px 0; white-space: pre-wrap; }
.hint .ttl { font-weight: 700; color: #b06d00; font-size: 14px; margin-bottom: 4px; }
.hint.info { border-left-color: var(--muted); background: #f1f4f7; }
.hint.info .ttl { color: var(--muted); }
.mine { text-align: right; margin: 8px 0; }
.mine span { display: inline-block; background: #e3eefa; border-radius: 12px 12px 2px 12px; padding: 6px 12px; font-size: 14px; white-space: pre-wrap; text-align: left; }
.steps { display: flex; gap: 6px; margin: 4px 0 8px; }
.steps i { flex: 1; height: 6px; border-radius: 3px; background: var(--line); }
.steps i.on { background: var(--accent); }
.qlist { list-style: none; padding: 0; margin: 0; }
.qlist li { display: flex; gap: 12px; align-items: center; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.qlist li:last-child { border-bottom: 0; }
.qlist img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; }
.qlist .t { flex: 1; min-width: 0; }
.qlist .t div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { display: inline-block; font-size: 12px; padding: 1px 8px; border-radius: 999px; background: #eef2f6; color: var(--muted); white-space: nowrap; }
.badge.solved { background: #e3f5ea; color: var(--ok); }
.badge.ask_teacher { background: #fdeaea; color: var(--warn); }
.badge.followed { background: #e3f5ea; color: var(--ok); }
.thinking { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 12px 0; }
.thinking::before { content: ""; width: 18px; height: 18px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px); background: #22303c; color: #fff; padding: 10px 18px; border-radius: 999px; opacity: 0; transition: .25s; pointer-events: none; z-index: 50; font-size: 14px; }
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.zoom { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: flex; align-items: center; justify-content: center; z-index: 40; }
.zoom img { max-width: 96vw; max-height: 94vh; background: #fff; }
.demo-band { background: #fff3cd; color: #7a5b00; text-align: center; font-size: 12px; padding: 4px; }

/* スタッフ画面 */
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs button { border: 0; background: #e8eff7; color: var(--main-dark); padding: 8px 16px; border-radius: 999px; font-weight: 600; }
.tabs button.on { background: var(--main); color: #fff; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters select { width: auto; }
.sq { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
@media (max-width: 760px) { .sq { grid-template-columns: 1fr; } }
.sq h3 { margin: 0 0 4px; font-size: 16px; }
details.ai { background: #f1f4f7; border-radius: 10px; padding: 8px 12px; margin: 10px 0; font-size: 14px; }
details.ai summary { cursor: pointer; font-weight: 600; color: var(--muted); }
details.ai div { white-space: pre-wrap; margin-top: 6px; }
.alert { background: #fdeaea; color: #8a2c2a; border-radius: 10px; padding: 8px 12px; font-size: 14px; margin: 8px 0; }
table.users { width: 100%; border-collapse: collapse; font-size: 14px; }
table.users th, table.users td { border-bottom: 1px solid var(--line); padding: 8px 6px; text-align: left; }
table.users tr.off td { color: var(--muted); text-decoration: line-through; }
table.users td.act { text-decoration: none; white-space: nowrap; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.form-grid label { margin: 0 0 4px; }

/* 会話 */
.chat-head { display: flex; gap: 12px; align-items: center; position: sticky; top: 58px; z-index: 4; }
.qthumb { width: 72px; height: 56px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); background: #fff; cursor: zoom-in; }
.chat { display: flex; flex-direction: column; gap: 10px; padding: 4px 0 16px; }
.bubble { max-width: 86%; padding: 10px 14px; border-radius: 16px; white-space: pre-wrap; word-break: break-word; font-size: 15px; }
.bubble.ai { align-self: flex-start; background: #fff; border: 1px solid var(--line); border-top-left-radius: 4px; }
.bubble.ai .who { font-size: 12px; font-weight: 700; color: #b06d00; margin-bottom: 2px; }
.bubble.me { align-self: flex-end; background: #dcebfa; border-top-right-radius: 4px; }
.bubble.sm { font-size: 14px; }
.msgimg { display: block; max-width: 220px; max-height: 220px; border-radius: 10px; margin-bottom: 6px; background: #fff; }
.composer { position: sticky; bottom: 0; background: var(--bg); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.keys { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 6px; scrollbar-width: none; }
.keys button { flex: 0 0 auto; min-width: 38px; height: 34px; border: 1px solid var(--line); background: #fff; border-radius: 8px; font-size: 16px; font-family: "Times New Roman", serif; }
.send-row { display: flex; gap: 8px; align-items: flex-end; }
.send-row textarea { min-height: 44px; max-height: 140px; resize: none; flex: 1; }
.send-row .btn { padding: 11px 16px; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 12px; background: #e8eff7; font-size: 20px; cursor: pointer; margin: 0; flex: 0 0 auto; }
.attach { position: relative; display: inline-block; margin-bottom: 6px; }
.attach img { height: 72px; border-radius: 8px; border: 1px solid var(--line); }
.attach button { position: absolute; top: -8px; right: -8px; width: 24px; height: 24px; border-radius: 50%; border: 0; background: #22303c; color: #fff; font-size: 12px; }
.solved-banner { background: #e3f5ea; color: #1d6b3d; font-weight: 700; border-radius: 12px; padding: 10px 12px; margin-bottom: 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.solved-banner.hidden { display: none; }
.solved-banner .btn { background: var(--ok); }
.link-btn { background: none; border: 0; color: var(--main-dark); font-size: 13px; padding: 6px 0 0; text-decoration: underline; }
.staff-chat { max-height: 520px; overflow-y: auto; background: var(--bg); border-radius: 10px; padding: 10px; margin: 8px 0; }

/* ログインカード（印刷用） */
#printArea { display: none; }
.print-queue { border: 2px solid var(--accent); }
@media print {
  body > *:not(#printArea) { display: none !important; }
  #printArea { display: block; }
  @page { size: A4; margin: 12mm; }
  .login-card { height: 128mm; box-sizing: border-box; border: 1px dashed #999; padding: 10mm 12mm; margin: 0 0 6mm; page-break-inside: avoid; font-size: 11pt; color: #000; }
  .login-card:nth-child(2n) { page-break-after: always; }
  .lc-title { font-size: 15pt; font-weight: 700; border-bottom: 2px solid #000; padding-bottom: 2mm; margin-bottom: 4mm; }
  .lc-name { font-size: 14pt; font-weight: 700; margin-bottom: 3mm; }
  .lc-table { border-collapse: collapse; width: 100%; margin-bottom: 4mm; }
  .lc-table th, .lc-table td { border: 1px solid #000; padding: 2.5mm 4mm; text-align: left; }
  .lc-table th { width: 38%; background: #eee; font-weight: 600; }
  .lc-big { font-family: "Consolas", "Menlo", monospace; font-size: 16pt; font-weight: 700; letter-spacing: .08em; }
  .lc-steps { margin: 0 0 3mm; padding-left: 6mm; line-height: 1.7; }
  .lc-note { font-size: 9pt; color: #333; }
}
