:root {
  color-scheme: light;
  --navy: #111c31;
  --navy-deep: #080f1e;
  --navy-light: #203554;
  --ink: #18263a;
  --muted: #515d6c;
  --accent: #8a5d20;
  --accent-dark: #6e4818;
  --gold: #c39954;
  --gold-light: #f6dfaa;
  --line: #ddd8ce;
  --paper: #fffefa;
  --ivory: #f8f5ed;
  --bg: #f3f1eb;
  --danger: #9c3043;
  --gold-button: linear-gradient(115deg,#fae7b8 4%,#e7c583 58%,#f4dcab 100%);
  --shadow: 0 12px 34px #1723350b, 0 2px 8px #17233508;
  --sans: "Yu Gothic UI","Hiragino Sans",Meiryo,system-ui,sans-serif;
  --serif: "Yu Mincho","Hiragino Mincho ProN","Noto Serif CJK JP",Georgia,serif;
  font-family: var(--sans);
}

*,*::before,*::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(ellipse at 88% 2%,#e9dcc16b,transparent 40rem),
    linear-gradient(160deg,#f7f6f2 20%,var(--bg) 60%,#eceff1 100%);
  min-height: 100vh;
  line-height: 1.6;
}
button,input,select,textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .56; }
:focus-visible { outline: 3px solid #3478a2; outline-offset: 3px; }
h1,h2,h3,p { margin: 0; }
h1,h2,h3 { line-height: 1.35; }
.wrap { width: min(1180px,calc(100% - 64px)); margin-inline: auto; }

header {
  color: #f9f7f0;
  background: linear-gradient(105deg,var(--navy-deep),var(--navy) 65%,#1c2a41);
  border-bottom: 1px solid #a57f43;
  box-shadow: 0 6px 24px #080f1e19;
}
.topbar { min-height: 74px; display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font: 700 1.17rem/1.3 var(--serif);
  letter-spacing: .06em;
}
.logo {
  display: inline-flex;
  flex: none;
  align-items: flex-end;
  justify-content: center;
  gap: 4px;
  width: 37px;
  height: 37px;
  padding-bottom: 8px;
  border: 1px solid #d8b879;
  border-radius: 11px 11px 14px 14px;
  background: linear-gradient(145deg,#273950,#0d172a);
  color: #f6dc9e;
  box-shadow: inset 0 0 0 3px #f0ca781f;
}
.logo i { width: 3px; height: 6px; border-radius: 1px; background: currentColor; }
.logo i:nth-child(2) { height: 11px; }
.logo i:nth-child(3) { height: 17px; }
.button,.ghost,.plain {
  min-height: 43px;
  padding: 9px 15px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-size: .9rem;
  font-weight: 750;
  line-height: 1.5;
  transition: background-color .18s ease,border-color .18s ease,box-shadow .18s ease;
}
.button {
  background: var(--gold-button);
  color: #2b210f;
  border-color: #cba76b;
  box-shadow: inset 0 1px #fff6df,0 3px 8px #552e171a;
}
.button:not(:disabled):hover { border-color: #a77638; box-shadow: inset 0 1px #fff6df,0 5px 14px #663e2338; }
.ghost { background: #fffbf1; color: #63431b; border-color: #d7be91; }
.plain { background: #fffdf8; color: var(--ink); border-color: #d7d3cb; }
.ghost:not(:disabled):hover,.plain:not(:disabled):hover { background: #f4ebd8; border-color: #a77a42; }
.danger { color: var(--danger); }
.text-button {
  padding: 5px 4px;
  border: 0;
  background: none;
  color: var(--accent-dark);
  font-size: .875rem;
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
}
main { padding-block: 33px 37px; }

.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  min-height: 227px;
  padding: 37px 43px;
  border: 1px solid #a5844d;
  border-radius: 22px;
  background:
    radial-gradient(ellipse at 91% 30%,#6486b539,transparent 56%),
    linear-gradient(112deg,#0b1426 5%,#15233a 56%,#233c59 100%);
  color: #fffdf8;
  box-shadow: 0 21px 35px #14213523,0 3px 8px #14213519;
}
.hero::before,.hero::after {
  content: "";
  position: absolute;
  z-index: -1;
  pointer-events: none;
}
.hero::before {
  inset: 0;
  background:
    radial-gradient(ellipse at 87% 15%,#e5bc704d,transparent 36%),
    repeating-radial-gradient(ellipse at 90% 60%,transparent 0 27px,#dcb87734 28px,#dcb87734 29px,transparent 30px 49px),
    linear-gradient(139deg,transparent 68%,#eac37c32 68.2%,transparent 68.5%,transparent 79%,#d1a76135 79.2%,transparent 79.5%);
  mask-image: linear-gradient(90deg,transparent 22%,#000 80%);
}
.hero::after { inset: 8px; border: 1px solid #dcc08b66; border-radius: 15px; }
.hero-copy { max-width: 44rem; min-width: 0; }
h1 {
  margin-bottom: 12px;
  font: 700 clamp(1.84rem,3.25vw,2.8rem)/1.33 var(--serif);
  letter-spacing: .035em;
  text-wrap: balance;
}
.hero p { max-width: 43rem; color: #e0e8f3; font-size: .95rem; line-height: 1.75; }
.hero-action {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-height: 48px;
  padding-inline: 17px;
  white-space: nowrap;
}
.camera-icon {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 17px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}
.camera-icon::before { content: ""; width: 6px; height: 6px; border: 1.5px solid currentColor; border-radius: 50%; }
.camera-icon::after { content: ""; position: absolute; top: -4px; left: 3px; width: 6px; height: 3px; border: 1.5px solid currentColor; border-radius: 2px 2px 0 0; }
header :focus-visible,.hero :focus-visible,.dialog-top :focus-visible { outline-color: #fff0bc; }

.controls {
  display: flex;
  align-items: end;
  gap: 14px;
  margin-block: 22px 16px;
}
.controls label { min-width: 176px; }
label { display: grid; gap: 5px; color: var(--muted); font-size: .875rem; font-weight: 720; }
input,select,textarea {
  width: 100%;
  min-width: 0;
  min-height: 43px;
  padding: 8px 11px;
  border: 1px solid #d7d2c9;
  border-radius: 8px;
  background-color: #fffefa;
  color: var(--ink);
}
input::placeholder,textarea::placeholder { color: #66717d; opacity: 1; }
input[type="number"] { font-variant-numeric: tabular-nums; }
textarea { resize: vertical; }
select {
  appearance: none;
  padding-right: 32px;
  background-image: linear-gradient(45deg,transparent 50%,#706148 50%),linear-gradient(135deg,#706148 50%,transparent 50%);
  background-position: calc(100% - 17px) 51%,calc(100% - 12px) 51%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}

.summary { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 16px; margin-bottom: 18px; }
.card { border: 1px solid var(--line); border-radius: 17px; background: var(--paper); box-shadow: var(--shadow); }
.stat {
  position: relative;
  overflow: hidden;
  min-height: 115px;
  padding: 17px 20px 13px;
  background: linear-gradient(143deg,#fffdf7,var(--paper) 62%);
}
.stat::before { content: ""; position: absolute; inset: 0 0 auto; height: 3px; background: linear-gradient(90deg,#93612d,#d7b572 65%,#e7cf9e); }
.stat::after {
  content: "";
  position: absolute;
  top: 16px;
  right: 20px;
  width: 16px;
  height: 16px;
  transform: rotate(45deg);
  border: 1px solid #caa26574;
  box-shadow: 0 0 0 4px #caa26516;
  pointer-events: none;
}
.stat h2 { position: relative; z-index: 1; color: var(--muted); font-size: .88rem; font-weight: 720; }
.stat p {
  margin-top: 6px;
  color: #182d49;
  font: 700 clamp(1.55rem,3.1vw,2.5rem)/1.12 var(--serif);
  font-variant-numeric: lining-nums tabular-nums;
}
.stat:nth-child(2) {
  border-color: #93774b;
  background: radial-gradient(ellipse at 95% 7%,#55749442,transparent 65%),linear-gradient(115deg,#101f36,#192b45);
}
.stat:nth-child(2) h2 { color: #e0e8f3; }
.stat .rate { color: #f7dfa8; }
.stat:nth-child(2)::after { border-color: #deb8799c; }

.panels { display: grid; grid-template-columns: minmax(0,1.36fr) minmax(0,1fr); gap: 18px; align-items: stretch; }
.panel { padding: 22px 23px; }
.panel h2 { font: 700 1.22rem/1.35 var(--serif); letter-spacing: .022em; }
.panel h2::before {
  content: "";
  display: inline-block;
  vertical-align: .13em;
  width: .38em;
  height: .38em;
  margin-right: .48em;
  border: 1px solid #9c722e;
  transform: rotate(45deg);
}
.hint { margin-top: 5px; color: var(--muted); font-size: .85rem; }
.panels .panel { min-height: 322px; }
.chart-scroll { margin-top: 15px; overflow-x: auto; }
.chart {
  position: relative;
  height: 223px;
  border: 1px solid #eee7d8;
  border-radius: 11px;
  background: linear-gradient(180deg,#fffdf7,#f8f7f1);
}
canvas { display: block; width: 100%; height: 100%; }
.chart-key { margin-top: 7px; min-height: 1.35em; color: var(--muted); font-size: .83rem; font-variant-numeric: tabular-nums; }
.weak-toolbar { display: flex; justify-content: space-between; align-items: start; gap: 11px; }
.weak-toolbar h2 { padding-top: 6px; }
.weak-toolbar select { width: auto; min-height: 36px; font-size: .84rem; }
.coverage { margin-top: 9px; padding: 6px 8px; border-left: 2px solid var(--gold); background: #f8f4e8; color: var(--muted); font-size: .81rem; }
.weak-list { display: grid; gap: 12px; margin: 14px 0 0; padding: 0; list-style: none; }
.weak-list li + li { padding-top: 10px; border-top: 1px solid #eeeae0; }
.weak-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; font-size: .94rem; font-weight: 750; }
.weak-head span:first-child { overflow-wrap: anywhere; }
.weak-head span:last-child { color: #253953; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bar { height: 7px; margin: 6px 0; border-radius: 9px; background: #e9e6df; }
.bar span { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#1c3b63,#526f96); }
.bar .low { background: linear-gradient(90deg,#864759,#ad6770); }
.small { color: var(--muted); font-size: .8rem; }
.small .few,.warning-text { color: #834c1e; }
.empty { margin-top: 14px; padding: 16px; border: 1px solid #eee8dc; border-radius: 10px; background: var(--ivory); color: var(--muted); font-size: .94rem; }
details { margin-top: 9px; font-size: .875rem; }
summary { width: fit-content; cursor: pointer; color: var(--accent-dark); font-weight: 750; }
details[open] summary { margin-bottom: 9px; }

.history { margin-top: 18px; }
.history .panel-title { margin-bottom: 15px; }
.table-scroll { overflow: auto; border: 1px solid #e7e0d3; border-radius: 10px; }
table { width: 100%; border-collapse: separate; border-spacing: 0; text-align: left; font-size: .9rem; }
th,td { padding: 11px 12px; border-bottom: 1px solid #eae4d8; vertical-align: middle; }
th { background: #eae4d5; color: #414954; font-size: .82rem; font-weight: 750; white-space: nowrap; }
tbody tr:nth-child(even) td { background: #fcf9f0; }
tbody tr:last-child td { border-bottom: 0; }
.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.name { min-width: 130px; font-weight: 740; overflow-wrap: anywhere; }
.action { white-space: nowrap; }
.action button { min-height: 34px; padding: 4px 9px; }
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid #d9d2c3;
  color: var(--muted);
  font-size: .84rem;
}
.tools { display: flex; flex-wrap: wrap; gap: 8px; }

dialog {
  width: min(740px,calc(100% - 22px));
  max-height: calc(100% - 26px);
  padding: 0;
  overflow: auto;
  border: 1px solid #b18a51;
  border-radius: 18px;
  background: #fffdf7;
  color: var(--ink);
  box-shadow: 0 28px 100px #080f1e7a;
}
dialog::backdrop { background: #0911229e; backdrop-filter: blur(3px); }
.form-shell { --form-pad: 23px; padding: var(--form-pad); }
.dialog-top,.dialog-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.dialog-top {
  margin: calc(-1 * var(--form-pad)) calc(-1 * var(--form-pad)) var(--form-pad);
  padding: 15px var(--form-pad);
  border-bottom: 1px solid #ac8957;
  background: linear-gradient(105deg,#121f34,#273d58);
  color: #fffdf8;
}
.dialog-top h2 { font: 700 1.32rem/1.35 var(--serif); }
.dialog-top .plain { border-color: #d4bb8b; }
.fields { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 11px 13px; margin: 17px 0 14px; }
.wide { grid-column: 1/-1; }
.field-hint { margin-top: -5px; }
fieldset { min-width: 0; margin: 0 0 14px; padding: 10px 13px 13px; border: 1px solid #ddd3be; border-radius: 10px; }
legend { padding-inline: 5px; color: #38455a; font-weight: 750; }
.areas { display: grid; gap: 8px; margin-top: 8px; }
.area-row { display: grid; grid-template-columns: minmax(0,1.5fr) minmax(0,2.35fr) minmax(0,1fr) minmax(0,1fr) auto; align-items: end; gap: 7px; }
.area-row button { padding-inline: 8px; }
.error { margin: 8px 0; color: var(--danger); font-size: .91rem; }
.dialog-actions { justify-content: flex-end; flex-wrap: wrap; margin-top: 15px; }
.dialog-actions .danger { margin-right: auto; }

.image-drop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 13px;
  padding: 12px;
  border: 1px dashed #ab8751;
  border-radius: 10px;
  background: #faf2df;
}
.image-drop p { color: var(--muted); font-size: .86rem; }
.image-drop strong { color: var(--accent-dark); font-size: .95rem; }
.image-status { margin-top: 6px; color: var(--accent-dark); font-size: .88rem; font-weight: 650; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; z-index: 1; }
.gunma-tool { display: grid; gap: 9px; padding: 14px; border: 1px solid var(--line); border-radius: 12px; }
.gunma-tool h3,.gunma-tool p { margin: 0; }
.gunma-tool .image-actions { flex-wrap: wrap; }
.gunma-options { display: grid; grid-template-columns: repeat(auto-fit,minmax(145px,1fr)); gap: 8px; }
.geometry-results { grid-column: 1 / -1; padding: .8rem 1rem; border: 1px solid #b7cbbd; border-radius: .65rem; background: #f4f9f5; color: #18372c; }
.geometry-results h4 { margin: 0 0 .6rem; }
.geometry-results ul { margin: .3rem 0 .6rem; padding-inline-start: 1.4rem; }
.geometry-results p { margin: .3rem 0; }
.geometry-answer { font-weight: 700; }
.gunma-preview { display: block; max-width: 100%; max-height: 460px; margin-inline: auto; object-fit: contain; }
.gunma-evidence-list { display: grid; gap: 7px; padding-inline-start: 1.5em; max-height: 340px; overflow: auto; }
.image-pages { display: grid; gap: 7px; margin-top: 8px; }
.image-card { margin: 0; padding: 6px 10px; border: 1px solid var(--line); border-radius: 9px; }
.image-card-body,.backup-comparison { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 10px; align-items: start; }
.image-card-body img { width: 100%; max-height: 380px; border-radius: 8px; background: #f2efe7; object-fit: contain; cursor: zoom-in; }
.image-card-body:has(img[data-expanded]) img { grid-column: 1/-1; max-height: none; cursor: zoom-out; }
.image-card-body .ocr-text { max-height: 350px; }
.image-card-body .plain { justify-self: start; }
.image-card-actions { display: flex; flex-wrap: wrap; gap: 6px 12px; grid-column: 1/-1; }
.ocr-text { max-height: 180px; margin: 0; padding: 9px; overflow: auto; border-radius: 7px; background: var(--ivory); overflow-wrap: anywhere; white-space: pre-wrap; }
.image-review { margin: 12px 0; padding: 12px; border: 1px solid #d8c19b; border-radius: 10px; background: #fcf6ea; }
.image-review h3 { font-size: .98rem; }
.evidence-list { display: grid; gap: 6px; margin: 8px 0; padding: 0; list-style: none; }
.evidence,.backup-column { min-width: 0; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); }
.evidence-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.evidence-actions .plain { min-height: 33px; margin-left: auto; padding: 3px 8px; }
.evidence-text { margin-top: 3px; overflow-wrap: anywhere; }
.evidence-groups { display: grid; gap: 12px; }
.evidence-group { padding-bottom: 3px; border-bottom: 1px solid var(--line); }
.warning-text { font-size: .87rem; font-weight: 750; }
.review-confirm { display: flex; align-items: center; gap: 9px; margin-top: 12px; padding: 7px 0; color: var(--ink); }
.review-confirm input { flex: none; width: 19px; height: 19px; min-height: 0; accent-color: var(--accent); }
.backup-comparison { margin-bottom: 12px; }
#backup-conflicts { margin-top: 15px; }
.backup-column { background: var(--ivory); }
.toast {
  position: fixed;
  z-index: 5;
  right: 18px;
  bottom: 18px;
  max-width: min(440px,calc(100% - 36px));
  padding: 10px 16px;
  border: 1px solid #b69765;
  border-radius: 10px;
  background: #14233a;
  color: #fffdf8;
  box-shadow: 0 6px 23px #111c3155;
}

@media (max-width: 880px) {
  .wrap { width: calc(100% - 36px); }
  .hero { min-height: 198px; padding: 29px 30px; gap: 18px; }
  .panels { grid-template-columns: 1fr; }
  .panels .panel { min-height: 0; }
}

@media (max-width: 560px) {
  .wrap { width: calc(100% - 24px); }
  .topbar { min-height: 62px; gap: 8px; }
  .brand { gap: 8px; font-size: 1rem; }
  .logo { width: 31px; height: 31px; padding-bottom: 6px; }
  header .button { padding-inline: 9px; font-size: .82rem; white-space: nowrap; }
  main { padding-top: 19px; }
  .hero { min-height: 0; flex-direction: column; align-items: start; gap: 14px; padding: 24px 20px; border-radius: 17px; }
  .hero::after { inset: 6px; border-radius: 12px; }
  .hero p { font-size: .87rem; }
  .hero-action { min-height: 41px; }
  .controls { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: 7px; }
  .controls label { min-width: 0; }
  .summary { gap: 7px; margin-bottom: 12px; }
  .stat { min-height: 84px; padding: 11px 8px 9px; border-radius: 12px; }
  .stat::after { display: none; }
  .stat h2 { font-size: .75rem; }
  .stat p { margin-top: 8px; font-size: clamp(1.16rem,5vw,1.6rem); }
  .panels { gap: 12px; }
  .panel { padding: 15px; }
  .panel h2 { font-size: 1.1rem; }
  .history { margin-top: 12px; }
  .history table { min-width: 520px; }
  .chart { height: 186px; }
  .weak-toolbar { flex-wrap: wrap; gap: 5px; }
  .form-shell { --form-pad: 14px; }
  .image-card-body,.backup-comparison { grid-template-columns: 1fr; }
  .area-row { grid-template-columns: minmax(0,1fr) minmax(0,1fr) auto; gap: 5px; }
  .area-row .topic { grid-column: 2/-1; }
  .area-row .q { grid-column: 1; }
  .fields { gap: 9px; }
  .image-drop { flex-direction: column; align-items: start; }
}

@media (prefers-reduced-motion: reduce) {
  .button,.ghost,.plain { transition: none; }
}

.study-launch {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 17px;
  padding: 12px;
  border: 1px solid #dfcba2;
  border-radius: 10px;
  background: linear-gradient(130deg,#fffaf0,#f5ead3);
}
.study-launch strong { color: #43341e; }
.study-launch .hint { margin-top: 1px; }
.study-launch .button { flex-shrink: 0; }
.topic-meta { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 1px 8px; }
.topic-meta .text-button { flex-shrink: 0; font-size: .79rem; }
#study-dialog { width: min(860px,calc(100% - 22px)); }
.study-intro { margin-bottom: 10px; }
.study-filter { width: min(100%,230px); margin-bottom: 9px; }
.study-topics {
  display: grid;
  grid-template-columns: repeat(2,minmax(0,1fr));
  gap: 8px;
  max-height: min(34vh,350px);
  overflow: auto;
  padding: 4px;
  margin: 0 -4px;
}
.study-choice {
  grid-template-columns: 20px minmax(0,1fr);
  align-items: start;
  gap: 8px;
  padding: 8px;
  border: 1px solid #ded5c1;
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.study-choice:has(input:checked) { border-color: #ad8246; background: #fcf3dd; }
.study-choice input { width: 16px; height: 16px; min-height: 0; margin: 4px 0 0; accent-color: var(--accent); }
.study-choice-detail { display: block; color: var(--muted); font-size: .79rem; font-weight: 500; }
.study-create-actions { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.study-status { min-height: 1.3em; margin-block: 6px; color: var(--accent-dark); font-size: .87rem; }
.study-output { margin-top: 18px; padding-top: 14px; border-top: 1px solid #dfd6c4; }
.study-output h2 { font: 700 1.28rem/1.3 var(--serif); }
.study-tools { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 7px; margin: 12px 0; }
.study-tools [aria-pressed="true"] { color: #fff8e9; background: var(--navy); border-color: #9e7942; }
.study-papers { display: grid; gap: 14px; margin-top: 11px; }
.study-paper { min-width: 0; padding: 13px; border: 1px solid #dfd6c4; border-radius: 10px; background: var(--paper); }
.study-paper-header { padding-bottom: 8px; margin-bottom: 9px; color: var(--ink); background: none; box-shadow: none; border-color: #dfd6c4; }
.study-paper-header h3 { font-size: 1.1rem; }
.study-paper h4 { margin: 0 0 4px; font-size: .92rem; }
.study-points,.study-questions { margin: 7px 0 0; padding-left: 1.4em; }
.study-points li,.study-questions li { margin: 7px 0 0; }
.study-questions li + li { border-top: 1px solid #ede6d8; padding-top: 9px; }
.study-points li { line-height: 1.9; }
.study-paper > p + h4 { margin-top: 10px; }
.study-word,.study-ink { color: #bd3330; font-weight: 750; }
.study-word {
  max-width: 100%;
  padding: 0 4px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  overflow-wrap: anywhere;
  line-height: 1.35;
}
.study-word:disabled { opacity: 1; }
.study-word:not(:disabled) { border-color: #bd3330; }
.study-word.study-masked { background: #a73537; }
.study-masked span { visibility: hidden; }
.study-question,.study-answer p { white-space: pre-wrap; overflow-wrap: anywhere; }
.study-answer { margin-top: 6px; padding: 7px 9px; border-left: 2px solid var(--gold); background: var(--ivory); }
.study-answer p + p { margin-top: 4px; }
.practice-response { display: block; margin: 10px 0; font-size: .88rem; font-weight: 700; }
.practice-response textarea { display: block; width: 100%; margin-top: 4px; padding: 8px; resize: vertical; font-size: max(16px, 1rem); }

@media (max-width: 560px) {
  .study-launch { flex-direction: column; align-items: start; }
  .study-topics { grid-template-columns: 1fr; }
  .study-tools { justify-content: start; }
  .study-tools .plain,.study-tools .button { padding-inline: 9px; font-size: .81rem; }
}

.study-options { display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:8px; max-width:390px; margin-top:12px; }
.study-option-tag { font-size:.84rem; color:var(--accent-dark); font-weight:750; }
.study-fixed-examples { margin-top:12px; }
@media (max-width:380px) { .study-options { grid-template-columns:1fr; } }

.practice-panel { border:1px solid var(--line); border-radius:10px; padding:10px; margin-bottom:13px; background:var(--ivory); }
.practice-tools { display:flex; align-items:end; flex-wrap:wrap; gap:8px; margin-top:7px; }
.practice-tools label { min-width:min(100%,230px); flex:1; }
.practice-progress { margin-top:6px; font-size:.85rem; font-weight:750; color:var(--accent-dark); }
.practice-grade { margin:9px 0 3px; width:min(100%,215px); }
.study-table-scroll { overflow-x:auto; margin:8px 0; }
.study-data-table { width:auto; min-width:min(100%,310px); }
.study-data-table caption { font-weight:750; font-size:.86rem; text-align:left; padding:3px 0; }
.study-data-table th,.study-data-table td { padding:5px 9px; border:1px solid #eae4d8; }
.study-audio-script { color:var(--muted); font-size:.89rem; }
.study-question + .plain { margin-top:8px; }
@media print { .study-table-scroll { overflow:visible; } }
.image-actions { display:flex; flex-shrink:0; flex-wrap:wrap; gap:8px; }
@media (hover:none) and (pointer:coarse) {
  input,select,textarea { font-size:1rem; }
  .weak-toolbar select { font-size:1rem; }
  .image-actions button { min-height:44px; }
}
#score-crop { width: min(640px,calc(100% - 18px)); }
#score-crop .fields { margin-block: 10px; }
.crop-photo { position:relative; width:fit-content; max-width:100%; margin:8px auto; line-height:0; }
.crop-photo img { display:block; max-width:100%; max-height:45vh; width:auto; height:auto; cursor:crosshair; }
.crop-outline { position:absolute; pointer-events:none; border:2px solid #006a74; outline:1px solid white; background:#147e8020; }
.crop-sample { display:block; max-width:100%; max-height:160px; margin:8px auto; object-fit:contain; border:1px solid var(--line); }
.crop-source { font-weight:700; text-decoration:underline; text-underline-offset:.16em; }
#crop-controls { margin-block:8px; }
#crop-controls summary { cursor:pointer; }
#crop-sliders { display:grid; grid-template-columns:1fr 1fr; gap:4px 12px; }
#crop-sliders input { width:100%; padding:0; }
#crop-status { margin-top:8px; overflow-wrap:anywhere; }


/* v10 enhancements */
.local-warning {
  margin-bottom: 16px;
  padding: 12px 16px;
  border: 1px solid #d59a3f;
  border-radius: 12px;
  background: #fff7e6;
  color: #5d3a0c;
  font-size: .88rem;
}
.controls { flex-wrap: wrap; }
.target-control { min-width: 148px; }
.target-input-row { display: flex; align-items: center; gap: 6px; }
.target-input-row input { width: 88px; }
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  font-size: .81rem;
  color: var(--muted);
}
.chart-legend-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.chart-legend-swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex: none;
}
.chart-legend-target {
  width: 14px;
  height: 0;
  border-top: 2px dashed #b48232;
  flex: none;
}
.history-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 14px;
}
.history-header .panel-title { margin-bottom: 0; }
.history-filters {
  display: flex;
  align-items: end;
  flex-wrap: wrap;
  gap: 10px;
}
.history-filters label { min-width: 160px; }
.history-note {
  margin-top: 3px;
  color: var(--muted);
  font-size: .79rem;
  font-weight: 450;
  max-width: 34ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.action { display: flex; gap: 6px; align-items: center; }
.gunma-sub-box {
  padding: 10px 12px;
  border: 1px dashed #cdb484;
  border-radius: 10px;
  background: #fbf7ee;
}
.gunma-sub-box summary { font-size: .88rem; }
.gunma-sub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.gunma-sub-note {
  margin-top: 6px;
  font-size: .8rem;
  color: var(--muted);
}
.study-figure {
  margin: 10px 0;
  padding: 10px;
  border: 1px solid #e7e0d2;
  border-radius: 9px;
  background: #fffefa;
  text-align: center;
}
.study-figure svg {
  display: block;
  margin-inline: auto;
  max-width: 100%;
  height: auto;
  max-height: 230px;
}
.storage-meta {
  font-size: .79rem;
  color: var(--muted);
}
@media (max-width: 560px) {
  .history-filters { width: 100%; }
  .history-filters label { flex: 1 1 130px; min-width: 0; }
}

/* AI OCR (Cloudflare Pages Functions + Gemini) */
.ocr-mode-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 8px 12px;
  margin-top: 10px;
}
.ai-mode-hint {
  margin-top: 5px;
  color: var(--muted);
}
.ai-summary-card {
  padding: 11px 13px;
  border: 1px solid #cdb484;
  border-radius: 10px;
  background: var(--paper);
}
.ai-summary-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.ai-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 750;
}
.ai-badge-high { background: #e3f3ea; color: #195e3a; }
.ai-badge-medium { background: #fdf1d6; color: #7a4f12; }
.ai-badge-low { background: #fae4e8; color: #8c2638; }
.ai-summary-body {
  margin-top: 6px;
  font-size: .88rem;
  line-height: 1.55;
}
.ai-summary-note {
  margin-top: 6px;
  padding: 6px 8px;
  border-left: 2px solid var(--gold);
  background: var(--ivory);
  font-size: .82rem;
  color: var(--muted);
}
