/* Japanese drills — one stylesheet, no framework. */

:root {
  --bg: #fbfaf8; --fg: #1a1a1a; --dim: #8a8580; --line: #e3ded7;
  --card: #ffffff; --sunk: #f3f0ec;
  --ok: #1f7a4d; --no: #b3261e; --accent: #3a5a8c;
  --heat0: #eae5de; --heat1: #c8dbc9; --heat2: #8fc09b; --heat3: #4f9a68; --heat4: #26663f;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1a19; --fg: #ece9e4; --dim: #8f8a84; --line: #35322e;
    --card: #232120; --sunk: #1f1d1c;
    --ok: #5bbd8a; --no: #e88a80; --accent: #8fb0e0;
    --heat0: #2a2825; --heat1: #2f4a38; --heat2: #3d6b4b; --heat3: #4f9a68; --heat4: #7ac48e;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--fg);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 15px; line-height: 1.5;
  display: flex; flex-direction: column; min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
.jp { font-family: "Hiragino Sans", "Yu Gothic", "Noto Sans JP", "Meiryo", sans-serif; }
kbd {
  font: inherit; font-size: 11px; border: 1px solid var(--line); border-bottom-width: 2px;
  border-radius: 4px; padding: 1px 5px; background: var(--card); color: var(--dim);
}

/* ---------- chrome ---------- */

.bar {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding: 12px 20px; border-bottom: 1px solid var(--line);
}
.brand { font-size: 15px; font-weight: 600; letter-spacing: .02em; }
.brand span { color: var(--dim); font-weight: 400; letter-spacing: .06em; font-size: 12px;
              text-transform: uppercase; }
.bar nav { display: flex; gap: 18px; font-size: 13px; color: var(--dim); }
.bar nav a.on { color: var(--fg); font-weight: 600; }
.foot { border-bottom: none; border-top: 1px solid var(--line); margin-top: auto;
        font-size: 11px; color: var(--dim); }

main { width: 100%; max-width: 720px; margin: 0 auto; padding: 26px 16px 40px; }
main.wide { max-width: 900px; }

h1 { font-size: 20px; font-weight: 600; margin: 0 0 4px; }
h2 { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em;
     color: var(--dim); margin: 30px 0 10px; }
p.lede { color: var(--dim); margin: 0 0 22px; }

.btn {
  font: inherit; font-size: 13px; padding: 7px 13px; cursor: pointer;
  background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 9px;
}
.btn:hover { border-color: var(--accent); }
.btn.quiet { background: none; border: none; color: var(--dim); text-decoration: underline;
             padding: 0; font-size: 11px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ---------- drill index ---------- */

.tiles { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
/* The index is grouped by what a drill asks of you; the heading and its line
   of prose sit closer to their tiles than to the group above. */
.group { margin-top: 30px; }
.group h2 { margin-bottom: 2px; }
.group .lede { margin-bottom: 14px; }
.tile {
  display: block; background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 18px 18px 16px;
}
.tile:hover { border-color: var(--accent); }
.tile h3 { margin: 0 0 4px; font-size: 16px; font-weight: 600; }
.tile .desc { font-size: 13px; color: var(--dim); }
.tile .bar-mini { display: flex; gap: 14px; margin-top: 14px; font-size: 11px; color: var(--dim); }
.tile .bar-mini b { font-weight: 600; font-size: 13px; color: var(--fg);
                    font-variant-numeric: tabular-nums; }
.tile.soon { opacity: .5; }

/* ---------- drill runtime ---------- */

.drill-head { display: flex; justify-content: space-between; align-items: baseline;
              gap: 12px; margin-bottom: 16px; }
.drill-head h1 { font-size: 13px; font-weight: 600; letter-spacing: .05em;
                 text-transform: uppercase; color: var(--dim); }
.metrics { display: flex; gap: 18px; }
.metric { text-align: right; }
.metric .v { font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.metric .k { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); }

.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 40px 28px 32px; text-align: center; min-height: 268px;
  display: flex; flex-direction: column; justify-content: center;
}
.q-main { font-size: 62px; line-height: 1.15; font-weight: 500; }
.q-sub  { font-size: 26px; margin-top: 10px; }
.q-en   { font-size: 15px; color: var(--dim); margin-top: 12px; }
.q-tag  { font-size: 11px; color: var(--dim); margin-top: 14px; letter-spacing: .06em; }
/* The form a production drill is asking for: the question, not decoration, so
   it reads at the same weight as the word itself. */
.q-ask  { font-size: 20px; margin-top: 18px; font-weight: 600; }
.q-ask small { display: block; font-size: 12px; font-weight: 400; color: var(--dim);
               letter-spacing: .04em; margin-top: 4px; }
/* A sentence prompt (particles) is read, not glanced at, so it stays at a
   line length that wraps sanely instead of the 62px headline size. */
.q-sent { font-size: 27px; line-height: 1.7; max-width: 560px; margin: 0 auto; }
.blank { color: var(--accent); border-bottom: 2px solid var(--accent);
         padding: 0 .5em; margin: 0 .1em; }
/* Two ways of singling out a chunk that is already there, rather than standing
   in for one that is missing: the predicate a transformation moves, and the
   chunk the correction drill says is wrong. */
.mark-span  { color: var(--accent); border-bottom: 2px solid var(--accent); }
.wrong-span { color: var(--no); border-bottom: 2px dotted var(--no); }
/* The sentence the form is asked in, blanked on the prompt and filled on the
   reveal. Set below the question and quieter than it: context, not the task. */
.q-ex { margin: 20px auto 0; padding-top: 16px; border-top: 1px solid var(--line);
        max-width: 520px; }
.q-ex .s { font-size: 21px; line-height: 1.7; }
.q-ex .s b { font-weight: 600; color: var(--accent); }
.q-ex .t { font-size: 13px; color: var(--dim); margin-top: 6px; }
/* Patterns shows the English alone — the Japanese would give the form
   away — so it carries the block by itself rather than captioning it. */
.q-ex.en-only .t { font-size: 15px; margin-top: 0; }

.answers { display: grid; gap: 12px; margin-top: 16px; grid-template-columns: repeat(2, 1fr); }
.answers.n3 { grid-template-columns: repeat(3, 1fr); }
.answers.n4 { grid-template-columns: repeat(4, 1fr); }
.answers.typed { grid-template-columns: 1fr auto; }
button.ans .sub { display: block; font-size: 13px; color: var(--dim); margin-top: 5px;
                  overflow-wrap: anywhere; }   /* よむ / よんだ / よまない on a phone */

/* Typed answers. Romaji is converted to kana in place, so the field shows
   what will be graded rather than what was pressed. */
input.type {
  font: inherit; font-size: 26px; text-align: center; width: 100%;
  padding: 14px 16px; background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 12px;
}
input.type::placeholder { font-size: 15px; color: var(--dim); }
input.type:focus { outline: none; border-color: var(--accent); }
input.type:disabled { color: var(--dim); background: var(--sunk); }
.btn.check {
  padding: 0 20px; border-radius: 12px; font-size: 14px;
  display: grid; grid-auto-flow: column; gap: 8px;
  align-content: center; align-items: baseline; justify-content: center;
}
.btn.check .key { font-size: 11px; color: var(--dim); letter-spacing: .08em; }
/* What was typed, echoed on the reveal next to what was wanted. */
.typed-back { font-size: 17px; color: var(--no); margin-top: 6px; }
button.ans {
  font: inherit; font-size: 17px; padding: 18px 10px; cursor: pointer;
  background: var(--card); color: var(--fg);
  border: 1px solid var(--line); border-radius: 12px;
}
button.ans:hover:not(:disabled) { border-color: var(--accent); }
button.ans:disabled { cursor: default; }
button.ans.was-right { border-color: var(--ok); color: var(--ok); }
button.ans.was-wrong { border-color: var(--no); color: var(--no); }
button.ans .key { display: block; font-size: 11px; color: var(--dim);
                  letter-spacing: .08em; margin-top: 6px; }

.verdict { font-size: 22px; font-weight: 600; }
.verdict.ok { color: var(--ok); }
.verdict.no { color: var(--no); }
.a-main { font-size: 34px; margin: 14px 0 6px; }
.why { font-size: 14px; color: var(--dim); max-width: 440px; margin: 8px auto 0; line-height: 1.5; }
.extra { font-size: 17px; margin-top: 16px; }
.extra + .extra { margin-top: 6px; }
.extra span { color: var(--dim); font-size: 13px; }

/* Always in flow, so revealing an answer doesn't shift the page under a click. */
.continue { display: flex; justify-content: center; align-items: center;
            min-height: 46px; margin-top: 14px; }
.btn.go { font-size: 14px; padding: 9px 22px; border-color: var(--accent);
          display: flex; align-items: baseline; gap: 8px; }
.btn.go .key { font-size: 11px; color: var(--dim); letter-spacing: .08em; }
.btn.go[hidden] { display: none; }

/* ---------- settings ---------- */

.opts { display: grid; gap: 10px; }
.opt {
  display: flex; gap: 12px; align-items: flex-start; cursor: pointer;
  background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 14px;
}
.opt:hover, .opt:has(input:checked) { border-color: var(--accent); }
.opt input { margin: 4px 0 0; accent-color: var(--accent); }
.opt .t { display: block; font-size: 14px; }
.opt .d { display: block; font-size: 12px; color: var(--dim); }
.hint { font-size: 12px; color: var(--dim); margin: 14px 0 0; max-width: 520px; }

/* ---------- stats ---------- */

.summary { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); }
.stat {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 14px 16px;
}
.stat .v { font-size: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
.stat .k { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim); }
.stat .sub { font-size: 11px; color: var(--dim); margin-top: 2px; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
th { font-size: 10px; text-transform: uppercase; letter-spacing: .07em; color: var(--dim);
     font-weight: 600; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; }
tr.weak td.err { color: var(--no); font-weight: 600; }
/* A grammar point currently pulling its other items forward. */
.hot { font-size: 10px; text-transform: uppercase; letter-spacing: .07em;
       color: var(--no); border: 1px solid var(--no); border-radius: 3px;
       padding: 0 3px; margin-left: 5px; vertical-align: 1px; }
.scroll { overflow-x: auto; }

.cal { display: flex; gap: 3px; overflow-x: auto; padding: 2px 0 6px; }
.cal .wk { display: grid; grid-template-rows: repeat(7, 11px); gap: 3px; }
.cal i { width: 11px; height: 11px; border-radius: 2px; background: var(--heat0); display: block; }
.cal i.l1 { background: var(--heat1); } .cal i.l2 { background: var(--heat2); }
.cal i.l3 { background: var(--heat3); } .cal i.l4 { background: var(--heat4); }
.legend { font-size: 10px; color: var(--dim); display: flex; align-items: center; gap: 4px; }
.legend i { width: 11px; height: 11px; border-radius: 2px; display: block; }

.empty { color: var(--dim); font-size: 13px; padding: 14px 0; }

/* ---------- modal ---------- */

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45);
         display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 10; }
.modal[hidden] { display: none; }
.sheet { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
         padding: 22px 24px; max-width: 380px; width: 100%; }
.sheet h2 { margin-top: 0; }
.sheet dl { display: grid; grid-template-columns: auto 1fr; gap: 8px 14px;
            font-size: 13px; margin: 0 0 18px; }
.sheet dt { text-align: right; }
.sheet dd { margin: 0; color: var(--dim); }

@media (max-width: 520px) {
  .answers.n4 { grid-template-columns: repeat(2, 1fr); }
  .answers.typed { grid-template-columns: 1fr; }
  .q-main { font-size: 50px; }
  .q-sent { font-size: 22px; }
  main { padding: 20px 14px 32px; }
}
