:root {
  --bg: #f4f6f8; --card: #fff; --text: #1b2430; --muted: #5b6676; --line: #dde3ea;
  --brand: #17405f; --brand-2: #e7eef5;
  --y: #fff3c4; --y-line: #e8c547; --y-t: #7a5a00;
  --g: #e6f4ea; --g-t: #1d6b35; --ng-t: #b3261e;
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  font-size: 15px; line-height: 1.7;
  word-break: auto-phrase; line-break: strict; overflow-wrap: anywhere;
}
.in { max-width: 1180px; margin: 0 auto; padding: 0 16px; }
header { background: var(--brand); color: #fff; padding: 16px 0 14px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; }
header h1 { margin: 0; font-size: 22px; }
header p { margin: 4px 0 0; opacity: .88; font-size: 13.5px; }
.month { display: flex; gap: 6px; margin: 0; }
.month div { background: rgba(255,255,255,.12); border-radius: 8px; padding: 4px 10px; text-align: center; }
.month dt { font-size: 11.5px; opacity: .85; }
.month dd { margin: 0; font-size: 13px; }
.month b { font-size: 20px; margin-right: 2px; }
main { padding-top: 18px; padding-bottom: 24px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 10px; padding: 18px; margin-bottom: 18px; }
h2 { font-size: 17px; margin: 0 0 10px; color: var(--brand); }
h2.inline { display: inline; }
.step { display: inline-block; width: 24px; height: 24px; line-height: 24px; text-align: center; border-radius: 50%; background: var(--brand); color: #fff; font-size: 13px; margin-right: 8px; vertical-align: 2px; }
.muted { color: var(--muted); } .small { font-size: 12.5px; }
.ng-t { color: var(--ng-t); }

button { font: inherit; border: 1px solid var(--brand); color: var(--brand); background: #fff; border-radius: 6px; padding: 7px 14px; cursor: pointer; }
button.primary { background: var(--brand); color: #fff; }
button.y { border-color: #b08a00; color: #5c4300; background: #fff; }
button:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: none; padding: 0; color: var(--muted); text-decoration: underline; font-size: inherit; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
input, select { font: inherit; border: 1px solid var(--line); border-radius: 6px; padding: 5px 8px; background: #fff; max-width: 100%; }

/* 1. 書類を選ぶ */
.samples { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.sample { border: 1px solid var(--line); border-radius: 10px; overflow: hidden; display: flex; flex-direction: column; background: #fff; }
.sample .thumb { height: 170px; overflow: hidden; background: #eef1f4; border-bottom: 1px solid var(--line); }
.sample .thumb img { width: 100%; display: block; }
.sample .thumb pre { margin: 0; padding: 10px; font-size: 10.5px; line-height: 1.5; white-space: pre-wrap; color: #333; font-family: inherit; }
.sample .body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 8px; flex: 1; }
.sample h3 { margin: 0; font-size: 16px; }
.sample p { margin: 0; font-size: 12.5px; color: var(--muted); }
.sample button { margin-top: auto; }
.sample.on { outline: 3px solid var(--brand); }
.drop { display: block; margin-top: 14px; border: 2px dashed var(--line); border-radius: 10px; padding: 16px; text-align: center; cursor: pointer; }
.drop input { display: block; margin: 0 auto 6px; }
@media (max-width: 760px) { .samples { grid-template-columns: 1fr; } .sample .thumb { height: 110px; } }

/* 読み取りの数 */
.stat { display: flex; flex-wrap: wrap; gap: 8px 22px; align-items: baseline; }
.stat .n { font-size: 26px; font-weight: bold; margin: 0 2px; }
.stat .yel { color: var(--y-t); } .stat .grn { color: var(--g-t); }
.stat .note { flex-basis: 100%; font-size: 13px; color: var(--muted); }
.stat .learned { flex-basis: 100%; background: var(--g); color: var(--g-t); border-radius: 6px; padding: 6px 10px; font-size: 14px; }
.stat.loading { color: var(--muted); }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.grid > * { min-width: 0; }
@media (max-width: 860px) { .grid { grid-template-columns: 1fr; gap: 0; } }
.doc summary { cursor: pointer; }
#orig-body { margin-top: 10px; max-height: 520px; overflow: auto; border: 1px solid var(--line); border-radius: 6px; }
#orig-body img { width: 100%; display: block; }
#orig-body pre { margin: 0; padding: 12px; white-space: pre-wrap; font-family: inherit; font-size: 13.5px; }
.asks { border-color: var(--y-line); background: #fffdf3; }
.asks ul { margin: 0; padding-left: 20px; }
.asks li { margin: 2px 0; }
.asks .none { list-style: none; margin-left: -20px; color: var(--g-t); }
.who { margin: -6px 0 18px; font-size: 13px; color: var(--muted); text-align: right; }
.who input { width: 9em; }

/* 3. 表 */
.legend { margin: -4px 0 8px; color: var(--muted); }
.dot { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin: 0 4px 0 10px; }
.dot:first-child { margin-left: 0; }
.dot.y { background: var(--y); border: 1px solid var(--y-line); } .dot.g { background: var(--g); border: 1px solid #a9d4b5; }
table.rows { width: 100%; border-collapse: collapse; font-size: 14px; }
.rows th { text-align: left; font-size: 12.5px; color: var(--muted); font-weight: normal; border-bottom: 2px solid var(--line); padding: 6px 8px; white-space: nowrap; }
.rows td { border-bottom: 1px solid var(--line); padding: 8px; vertical-align: top; }
.rows td.num { text-align: right; white-space: nowrap; }
.rows tr.yellow > td { background: var(--y); }
.rows tr.yellow > td:first-child { box-shadow: inset 4px 0 0 var(--y-line); }
.rows tr.ok > td:first-child { box-shadow: inset 4px 0 0 #7cc292; }
.badge { display: inline-block; font-size: 12px; border-radius: 4px; padding: 0 6px; white-space: nowrap; }
.badge.y { background: var(--y-line); color: #3d2d00; } .badge.g { background: var(--g); color: var(--g-t); } .badge.l { background: #dfeaf6; color: var(--brand); }
.raw { font-size: 12.5px; color: var(--muted); }
.reasons { margin: 6px 0 0; padding: 0; list-style: none; }
.reasons li { margin: 6px 0 0; color: var(--y-t); font-weight: bold; font-size: 13.5px; }
.reasons li::before { content: "▲ "; }
.fix { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 4px 0 2px; font-weight: normal; }
.fix select { max-width: 100%; }
.fix input[type="number"] { width: 7em; }
td.reasons-cell { min-width: 280px; }

/* スマホ: 行をカードにする */
@media (max-width: 720px) {
  table.rows, .rows tbody, .rows tr, .rows td { display: block; width: 100%; }
  .rows thead { display: none; }
  .rows tr { border: 1px solid var(--line); border-radius: 8px; margin-bottom: 10px; overflow: hidden; }
  .rows tr.yellow { border-color: var(--y-line); }
  .rows td { border: 0; padding: 3px 12px; }
  .rows td:first-child { padding-top: 10px; }
  .rows td:last-child { padding-bottom: 10px; }
  .rows td.num { text-align: left; }
  .rows td[data-l]::before { content: attr(data-l) " "; color: var(--muted); font-size: 12px; }
  .rows tr > td:first-child { box-shadow: none !important; }
  td.reasons-cell { min-width: 0; }
}

table.mini { width: 100%; border-collapse: collapse; font-size: 13px; }
.mini th, .mini td { text-align: left; border-bottom: 1px solid var(--line); padding: 5px 6px; vertical-align: top; }
.mini th { color: var(--muted); font-weight: normal; }
.scroll { overflow-x: auto; }
.foot { text-align: center; }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: #1b2430; color: #fff; padding: 10px 16px; border-radius: 8px; max-width: calc(100% - 32px); font-size: 14px; box-shadow: 0 4px 16px rgba(0,0,0,.2); z-index: 10; }
.spin { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: s 0.8s linear infinite; vertical-align: -2px; margin-right: 6px; }
@keyframes s { to { transform: rotate(360deg); } }
.nw { white-space: nowrap; }

/* 4. 書き出す */
.ex-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ex-row label { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
#fmt { min-width: 16em; }
#fmt-note { margin: 8px 0 0; }
#fmt-warn { margin: 6px 0 0; color: var(--y-t); background: #fffdf3; border: 1px solid var(--y-line); border-radius: 6px; padding: 6px 10px; }
.pv-label { margin: 10px 0 4px; }
.preview { margin: 0; background: #f7f9fb; border: 1px solid var(--line); border-radius: 6px; padding: 10px; font-size: 12.5px; line-height: 1.6; overflow-x: auto; white-space: pre; font-family: "BIZ UDGothic", Consolas, monospace; }
.editor { margin-top: 16px; border-top: 1px dashed var(--line); padding-top: 14px; }
.editor h3 { margin: 0 0 10px; font-size: 15.5px; color: var(--brand); }
.ed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px 16px; }
.ed-grid label { display: flex; flex-direction: column; gap: 2px; font-size: 13px; color: var(--muted); }
.ed-grid label.chk { flex-direction: row; align-items: center; gap: 6px; color: var(--text); }
.cols { margin: 6px 0 10px; padding-left: 26px; }
.cols li { margin: 4px 0; }
.cols .c { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.cols .f { min-width: 8.5em; font-size: 13px; color: var(--muted); }
.cols input { width: 11em; }
.cols button { padding: 2px 9px; }
