:root {
  --ink: #172033;
  --muted: #667085;
  --line: #dfe5ec;
  --surface: #ffffff;
  --bg: #f3f6fa;
  --primary: #123a63;
  --primary2: #1f5b94;
  --good: #16794b;
  --warn: #a96107;
  --bad: #b42318;
  --soft-good: #edf9f3;
  --soft-bad: #fff1f0;
  --shadow: 0 12px 30px rgba(30, 50, 80, .08);
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: Inter, "Noto Sans JP", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.65;
}
.topbar {
  background: linear-gradient(135deg, #0c2948, #1c568d);
  color: white;
  padding: 28px max(20px, calc((100vw - 980px) / 2));
  display: flex;
  gap: 24px;
  justify-content: space-between;
  align-items: center;
}
.topbar h1 { margin: 2px 0 4px; font-size: clamp(26px, 4vw, 40px); line-height: 1.15; }
.topbar h1 span { font-size: .48em; opacity: .85; }
.eyebrow, .step { letter-spacing: .12em; font-size: 12px; font-weight: 800; margin: 0; }
.subtitle { margin: 0; opacity: .86; }
.badge { padding: 8px 13px; background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.25); border-radius: 999px; white-space: nowrap; font-weight: 700; }
.container { max-width: 980px; margin: 26px auto 60px; padding: 0 18px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; box-shadow: var(--shadow); padding: 24px; margin-bottom: 18px; }
.notice { border-left: 5px solid var(--primary2); }
.notice p { margin-bottom: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
h2 { margin: 2px 0 0; font-size: 22px; }
h3 { margin-top: 24px; }
.step { color: var(--primary2); }
label { font-size: 14px; font-weight: 700; }
textarea, input {
  width: 100%; border: 1px solid #cbd5e1; border-radius: 11px; padding: 11px 12px; font: inherit; color: var(--ink); background: #fff;
}
textarea { margin-top: 7px; resize: vertical; font-size: 17px; line-height: 1.75; }
input { width: 88px; margin-left: 8px; }
.settings-row { display: flex; flex-wrap: wrap; align-items: center; gap: 14px 24px; margin-top: 14px; }
.button { border: 0; border-radius: 11px; padding: 11px 16px; font: inherit; font-weight: 800; cursor: pointer; transition: transform .12s ease, opacity .12s ease; }
.button:hover { transform: translateY(-1px); }
.button:disabled { opacity: .45; cursor: not-allowed; transform: none; }
.primary { color: #fff; background: var(--primary); }
.secondary { color: #fff; background: var(--primary2); }
.ghost { color: var(--primary); background: #eef4fa; }
.record { color: #fff; background: #c52d25; margin-left: auto; }
.record.active { background: #7e1f1a; }
.muted { color: var(--muted); margin: 4px 0; }
.hint { font-size: 13px; color: var(--muted); }
.progress-wrap { margin-top: 16px; }
.progress-track { height: 10px; border-radius: 999px; background: #e6edf5; overflow: hidden; }
.progress-bar { height: 100%; width: 0%; background: var(--primary2); transition: width .15s; }
.progress-wrap p { font-size: 13px; color: var(--muted); }
.passage { font-family: Georgia, "Times New Roman", serif; font-size: clamp(20px, 3vw, 25px); line-height: 1.8; padding: 20px; border-radius: 14px; background: #f8fbfe; border: 1px solid #dbe7f1; }
.passage .sentence { display: inline; }
.passage .sentence::after { content: " "; }
.passage .num { font-family: system-ui, sans-serif; font-size: 11px; vertical-align: super; color: var(--primary2); font-weight: 900; margin-right: 3px; }
.record-panel { display: flex; align-items: center; gap: 14px; padding: 16px; margin-top: 18px; background: #fff7f6; border: 1px solid #f2d4d1; border-radius: 14px; }
.record-indicator { color: #d1d5db; font-size: 26px; }
.record-indicator.active { color: #d92d20; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .35; } }
.analysis-loading { display: flex; gap: 16px; align-items: center; background: #f8fbfe; border: 1px solid #dbe7f1; padding: 18px; border-radius: 14px; }
.spinner { width: 34px; height: 34px; border: 4px solid #dbe7f1; border-top-color: var(--primary2); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.score-hero { display: flex; align-items: center; gap: 20px; margin: 8px 0 20px; }
.score-ring { width: 112px; height: 112px; border-radius: 50%; display: grid; place-content: center; text-align: center; border: 9px solid #dce6ef; font-size: 35px; font-weight: 900; }
.score-ring.good { border-color: #55b889; color: var(--good); }
.score-ring.bad { border-color: #e88881; color: var(--bad); }
.score-ring small { font-size: 12px; display: block; font-weight: 600; }
.judge { font-size: 25px; font-weight: 900; margin: 0; }
.transcript-box { background: #f8fafc; border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.transcript-box summary { cursor: pointer; font-weight: 800; }
.sentence-results, .retry-list { display: grid; gap: 12px; }
.sentence-card { border: 1px solid var(--line); border-radius: 14px; padding: 15px; }
.sentence-card.good { background: var(--soft-good); border-color: #b6e3cc; }
.sentence-card.bad { background: var(--soft-bad); border-color: #f0b8b3; }
.sentence-top { display: flex; justify-content: space-between; gap: 12px; align-items: start; }
.sentence-text { font-family: Georgia, "Times New Roman", serif; font-size: 19px; }
.sentence-score { min-width: 67px; text-align: center; border-radius: 999px; padding: 5px 8px; background: #fff; font-weight: 900; }
.word-diff { margin-top: 10px; font-size: 14px; line-height: 2; }
.word { display: inline-block; margin-right: 5px; padding: 0 4px; border-radius: 5px; }
.word.ok { background: #d9f4e6; }
.word.ng { background: #ffd9d5; text-decoration: underline wavy #b42318; }
.retry-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.retry-status { margin-top: 9px; font-weight: 800; }
.retry-status.pass { color: var(--good); }
.retry-status.fail { color: var(--bad); }
.clear-banner { margin-top: 18px; padding: 18px; border-radius: 14px; background: #e9f8f0; color: var(--good); font-size: 18px; font-weight: 900; text-align: center; }
.history-item { display: grid; grid-template-columns: 1fr auto; gap: 8px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.history-item:last-child { border-bottom: 0; }
.history-score { font-weight: 900; }
.hidden { display: none !important; }
footer { text-align: center; color: #7b8797; padding: 20px; font-size: 12px; }
@media (max-width: 650px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .card { padding: 18px; border-radius: 14px; }
  .section-head { align-items: flex-start; }
  .record-panel { align-items: center; flex-wrap: wrap; }
  .record { width: 100%; margin-left: 0; }
  .score-hero { align-items: flex-start; }
  .score-ring { width: 92px; height: 92px; font-size: 29px; }
  .sentence-top { flex-direction: column; }
}

/* Ver.3.0 homework / teacher management additions */
a { color: var(--primary2); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 16px; }
.form-grid label { display: grid; gap: 6px; }
.wide-input { width: 100%; margin-left: 0; }
.teacher-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.button[href] { display: inline-flex; align-items: center; justify-content: center; text-decoration: none; }
.generated-link { margin-top: 20px; padding: 16px; background: #f8fbfe; border: 1px solid #dbe7f1; border-radius: 14px; }
.generated-link textarea { font-size: 12px; line-height: 1.45; word-break: break-all; }
.assignment-card { position: relative; overflow: hidden; background: linear-gradient(135deg, #f7fbff, #eef6ff); border-color: #bfd7ef; }
.assignment-card::after { content: ""; position: absolute; width: 160px; height: 160px; border-radius: 50%; background: rgba(31,91,148,.08); right: -45px; top: -65px; }
.assignment-kicker { color: var(--primary2); font-size: 12px; font-weight: 900; letter-spacing: .14em; }
.assignment-card h2 { font-size: 28px; margin-top: 4px; }
.assignment-meta { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.assignment-meta span { background: #fff; border: 1px solid #d7e5f2; border-radius: 999px; padding: 5px 10px; font-size: 13px; font-weight: 800; }
.student-id-row { display: grid; grid-template-columns: minmax(140px,1fr) minmax(120px,.7fr) auto; align-items: end; gap: 12px; }
.student-id-row label { display: grid; gap: 6px; }
.student-id-row input { width: 100%; margin-left: 0; }
.success-text { color: var(--good) !important; font-weight: 800; }
.error-text { color: var(--bad) !important; font-weight: 800; }
.submission-status { padding: 14px 16px; border-radius: 12px; border: 1px solid var(--line); font-weight: 800; }
.submission-status.waiting { background: #f8fafc; color: var(--muted); }
.submission-status.sending { background: #fff8e8; color: var(--warn); border-color: #efd9a0; }
.submission-status.sent { background: var(--soft-good); color: var(--good); border-color: #b6e3cc; }
.submission-status.error { background: var(--soft-bad); color: var(--bad); border-color: #f0b8b3; }
@media (max-width: 650px) {
  .form-grid { grid-template-columns: 1fr; }
  .student-id-row { grid-template-columns: 1fr 1fr; }
  .student-id-row .button { grid-column: 1 / -1; width: 100%; }
  .assignment-card h2 { font-size: 23px; }
}
