/* 勉強クエスト 親の確認ページ。スマホとPCのブラウザで見る。依存なし */
:root {
  color-scheme: light;
  --bg: #f4f3ef;
  --surface: #fcfcfb;
  --surface-2: #efeee9;
  --line: #dcdad3;
  --text: #0b0b0b;
  --text-2: #52514e;
  --muted: #7a7974;
  --accent: #2a78d6;
  --accent-soft: #d6e6fa;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --good: #1f7a3a;
  --good-bg: #e2f3e6;
  --warn: #9a5b00;
  --warn-bg: #fdf0d5;
  --bad: #b3261e;
  --bad-bg: #fbe3e1;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme='light']) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --line: #34332f;
    --text: #f0efec;
    --text-2: #c3c2b7;
    --muted: #8f8e88;
    --accent: #3987e5;
    --accent-soft: #1d3350;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --good: #6fcf8b;
    --good-bg: #173322;
    --warn: #f0b85a;
    --warn-bg: #3a2b10;
    --bad: #ff8a80;
    --bad-bg: #3d1916;
  }
}
:root[data-theme='dark'] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --line: #34332f;
  --text: #f0efec;
  --text-2: #c3c2b7;
  --muted: #8f8e88;
  --accent: #3987e5;
  --accent-soft: #1d3350;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --good: #6fcf8b;
  --good-bg: #173322;
  --warn: #f0b85a;
  --warn-bg: #3a2b10;
  --bad: #ff8a80;
  --bad-bg: #3d1916;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.6 system-ui, -apple-system, 'Hiragino Sans', 'Noto Sans JP', 'Yu Gothic UI', sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }

.wrap { max-width: 1080px; margin: 0 auto; padding: 0 16px 64px; }
header.top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
header.top .bar { display: flex; align-items: center; gap: 12px; max-width: 1080px; margin: 0 auto; padding: 10px 16px; }
header.top h1 { font-size: 17px; margin: 0; white-space: nowrap; }
header.top .sync { color: var(--muted); font-size: 12px; margin-left: auto; text-align: right; }
nav.tabs { display: flex; gap: 4px; overflow-x: auto; max-width: 1080px; margin: 0 auto; padding: 0 12px 8px; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs button {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 5px 13px; white-space: nowrap; cursor: pointer; font-size: 14px;
}
nav.tabs button[aria-selected='true'] { background: var(--text); color: var(--bg); border-color: var(--text); }

h2 { font-size: 16px; margin: 0 0 10px; }
h3 { font-size: 14px; margin: 16px 0 6px; color: var(--text-2); }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); margin-top: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; min-width: 0; }
.card.wide { grid-column: 1 / -1; }
.stat { font-size: 30px; font-weight: 700; line-height: 1.15; font-variant-numeric: tabular-nums; }
.stat small { font-size: 15px; font-weight: 500; color: var(--text-2); }
.sub { color: var(--text-2); font-size: 13px; }
.muted { color: var(--muted); }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

.meter { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.meter > i { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.meter.done > i { background: var(--good); }

.pill { display: inline-block; border-radius: 999px; padding: 0 8px; font-size: 12px; line-height: 20px; white-space: nowrap; background: var(--surface-2); color: var(--text-2); }
.pill.good { background: var(--good-bg); color: var(--good); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

.alert { border-radius: var(--radius); padding: 14px 16px; margin-top: 12px; border: 2px solid var(--bad); background: var(--bad-bg); }
.alert h2 { color: var(--bad); margin: 0 0 6px; }
.alert .quote { background: var(--surface); border-radius: 8px; padding: 8px 10px; margin: 6px 0; white-space: pre-wrap; }
.notice { border-radius: var(--radius); padding: 10px 14px; margin-top: 12px; background: var(--warn-bg); color: var(--warn); }

.tablewrap { overflow-x: auto; margin: 0 -4px; }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { text-align: left; padding: 6px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--text-2); font-weight: 600; white-space: nowrap; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
td.nowrap { white-space: nowrap; }
tr.flag td { background: color-mix(in srgb, var(--bad-bg) 55%, transparent); }

/* 間違いのカード（スマホで読みやすく） */
.items { display: grid; gap: 8px; }
.item { border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: var(--surface); }
.item .q { font-weight: 600; white-space: pre-wrap; word-break: break-word; }
.item .ans { display: grid; grid-template-columns: auto 1fr; gap: 2px 10px; margin-top: 6px; font-size: 14px; }
.item .ans dt { color: var(--muted); }
.item .ans dd { margin: 0; word-break: break-word; }

button.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 8px; padding: 6px 12px; cursor: pointer; }
button.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.btn.danger { color: var(--bad); }
button.btn:disabled { opacity: 0.5; cursor: default; }
label.field { display: grid; gap: 2px; font-size: 13px; color: var(--text-2); }
label.field input, label.field select, textarea {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 9px; background: var(--surface); min-width: 0; width: 100%;
}
.form { display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); }
details > summary { cursor: pointer; color: var(--text-2); margin: 8px 0; }

/* グラフ */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { fill: var(--text-2); font-size: 11px; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: var(--line); stroke-width: 1; stroke-dasharray: 2 3; }
.chart .goal { stroke: var(--text-2); stroke-width: 1.5; stroke-dasharray: 5 4; fill: none; }
.chart .bar { fill: var(--series-1); }
.chart .bar.done { fill: var(--series-3); }
.chart .bar:hover, .chart .pt:hover { opacity: 0.8; }
.chart .line { fill: none; stroke: var(--series-1); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.chart .line.alt { stroke: var(--muted); stroke-dasharray: 5 4; }
.chart .band { fill: var(--series-1); opacity: 0.15; }
.chart .pt { fill: var(--series-1); stroke: var(--surface); stroke-width: 2; }
.chart .pt.cal { fill: var(--series-2); }
.chart .radar-now { fill: color-mix(in srgb, var(--series-1) 22%, transparent); stroke: var(--series-1); stroke-width: 2; }
.chart .radar-prev { fill: none; stroke: var(--muted); stroke-width: 1.5; stroke-dasharray: 4 3; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--text-2); margin-top: 4px; }
.legend i { display: inline-block; width: 14px; height: 3px; vertical-align: middle; margin-right: 4px; background: var(--series-1); border-radius: 2px; }
.legend i.goal { background: none; border-top: 2px dashed var(--text-2); height: 0; }
.legend i.alt { background: none; border-top: 2px dashed var(--muted); height: 0; }
.legend i.cal { width: 9px; height: 9px; border-radius: 50%; background: var(--series-2); }
.legend i.done { background: var(--series-3); height: 9px; width: 9px; }
.legend i.bar { height: 9px; width: 9px; }
.tip { position: fixed; pointer-events: none; z-index: 20; background: var(--text); color: var(--bg); font-size: 12px; padding: 4px 8px; border-radius: 6px; white-space: nowrap; display: none; }

/* ログイン */
.login { max-width: 380px; margin: 12vh auto 0; }
.login .card { padding: 22px; }
.err { color: var(--bad); font-size: 13px; min-height: 1.4em; }
.loading { padding: 40px 0; text-align: center; color: var(--muted); }

@media (max-width: 520px) {
  .stat { font-size: 26px; }
  header.top h1 { font-size: 15px; }
  .hide-sm { display: none; }
}
table.kv td:first-child { white-space: nowrap; color: var(--text-2); }

/* 報告 */
.badge { display: inline-block; min-width: 18px; padding: 0 5px; border-radius: 999px; background: var(--bad); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 700; }
nav.tabs button[aria-selected='true'] .badge { background: var(--bad); color: #fff; }
.report-home { border-color: var(--bad); }
.item.report.open { border-left: 4px solid var(--bad); }
.item.report .q { margin: 4px 0; }
.report-edit { margin-top: 8px; }
.report-edit select, .report-edit input { border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; background: var(--surface); }
.report-edit input { flex: 1; min-width: 160px; }
label.pick { display: inline-flex; gap: 4px; align-items: center; cursor: pointer; }
.pre { white-space: pre-wrap; word-break: break-word; font-size: 12px; background: var(--surface-2); border-radius: 8px; padding: 6px 8px; margin: 4px 0 0; }

/* 教科の印（数・国・英・理・社）としぼり込み */
.pill.subj { font-weight: 600; min-width: 22px; text-align: center; padding: 0 6px; }
.pill.subj-math { background: #fbf1d0; color: #7a5b00; }
.pill.subj-ja { background: #fbe0ea; color: #9b2a56; }
.pill.subj-en { background: #dcf3e6; color: #1f7a48; }
.pill.subj-sci { background: #fdecc4; color: #8a5a00; }
.pill.subj-soc { background: #dce9fb; color: #1f5aa6; }
.subj-select { font: inherit; font-size: 14px; padding: 4px 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface, #fff); color: inherit; }
.subj-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; }
.paper-card details { margin-top: 8px; }
.paper-card td .btn { margin-left: 4px; }

/* 重要な操作の前の「もう一度ログイン」（Google をもう一度押してもらう画面）と、小さな文字のボタン */
.modal-back { position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, 0.45); }
.modal { width: 100%; max-width: 420px; max-height: calc(100vh - 32px); overflow-y: auto; margin: 0; }
.scan-video { display: block; width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 12px; background: #000; margin: 8px 0; }
button.linkbtn { border: 0; background: none; padding: 0; font: inherit; color: var(--accent); text-decoration: underline; cursor: pointer; }
