/* Free Mini-Quiz & Printable Worksheet styles (wakumana.com/free.html & /free/*.html) */
body {
  word-break: normal;
  word-break: auto-phrase;
}

.crumb {
  font-size: 0.86rem;
  color: var(--soft);
  padding: 14px 0 0;
}
.crumb ol {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0;
  padding: 0;
}
.crumb li + li::before {
  content: "›";
  margin-right: 6px;
  color: var(--soft);
}
.crumb a {
  color: var(--soft);
  text-decoration: none;
}
.crumb a:hover {
  color: var(--green-d);
  text-decoration: underline;
}

/* Free Hero */
.free-hero {
  background: linear-gradient(180deg, var(--sky) 0%, var(--bg) 100%);
  padding: 24px 0 36px;
}
.free-hero h1 {
  font-size: clamp(1.55rem, 3.4vw, 2.25rem);
  margin: 8px 0 12px;
}
.free-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 10px;
}
.pill {
  display: inline-block;
  font-size: 0.82rem;
  font-weight: 800;
  padding: 3px 12px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--edge);
  color: var(--ink);
}
.pill-eigo { background: #e8f1ff; border-color: #93c5fd; color: #1e40af; }
.pill-sansuu { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.pill-kokugo { background: #fee2e2; border-color: #fca5a5; color: #991b1b; }
.pill-rika { background: #dcfce7; border-color: #86efac; color: #166534; }
.pill-shakai { background: #f3e8ff; border-color: #d8b4fe; color: #5b21b6; }
.pill-seikatsu { background: #ccfbf1; border-color: #5eead4; color: #115e59; }
.pill-chugokugo { background: #ffe4e6; border-color: #fda4af; color: #9f1239; }
.pill-audio { background: #fff3db; border-color: var(--orange); color: #9a5b00; }
.pill-reading { background: #ede9fe; border-color: #c4b5fd; color: #5b21b6; }
.pill-img { background: #ecfdf5; border-color: #6ee7b7; color: #065f46; }

/* Action toolbar */
.quiz-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  margin: 18px 0 0;
}
.btn-sm {
  padding: 10px 18px;
  font-size: 0.92rem;
  cursor: pointer;
  border: 0;
  font-family: inherit;
}
.btn-print {
  background: #fff;
  color: var(--ink);
  border: 2px solid var(--green);
  border-radius: 999px;
  font-weight: 800;
}
.btn-print:hover {
  background: #f1faf2;
}
.btn-ghost {
  background: transparent;
  color: var(--soft);
  border: 2px solid var(--edge);
  border-radius: 999px;
  font-weight: 700;
}
.btn-ghost:hover {
  background: #fff;
  color: var(--ink);
}
.print-color-opt {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--edge);
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--ink);
  cursor: pointer;
  user-select: none;
}
.print-color-opt input {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
  margin: 0;
}

/* Hub filter tabs & subject sections */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 0 28px;
}
.filter-btn {
  padding: 8px 16px;
  border-radius: 999px;
  border: 2px solid var(--edge);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
}
.filter-btn.is-active {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

/* Knowledge tree search & branches */
.tree-search-wrap {
  max-width: 560px;
  margin: 0 auto 20px;
}
.tree-search {
  width: 100%;
  padding: 12px 18px;
  border-radius: 999px;
  border: 2px solid var(--edge);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
}
.tree-search:focus {
  outline: none;
  border-color: var(--green);
}
.tree-branch {
  max-width: none;
  background: #fff;
  border: 2px solid var(--edge);
  border-radius: 18px;
  padding: 12px 16px;
  margin: 0 0 12px;
}
.tree-branch.is-hidden {
  display: none;
}
.tree-branch summary {
  cursor: pointer;
  font-weight: 900;
  font-size: 1.04rem;
  color: var(--ink);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  list-style: none;
}
.tree-branch summary::-webkit-details-marker {
  display: none;
}
.tree-branch summary::after {
  content: "＋";
  font-size: 1.1rem;
  color: var(--green-d);
}
.tree-branch[open] summary::after {
  content: "－";
}
.tree-branch-meta {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--soft);
  margin-left: auto;
  margin-right: 8px;
}
.leaf-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(235px, 1fr));
  gap: 8px;
  margin-top: 12px;
}
.leaf-link {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 4px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1.5px solid var(--edge);
  background: #fffdf9;
  text-decoration: none;
  color: var(--ink);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.leaf-link.is-hidden {
  display: none;
}
.leaf-link:hover {
  border-color: var(--green);
  background: #f5fbf6;
}
.leaf-link-title {
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.4;
}
.leaf-link-sub {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--soft);
}
.leaf-badge-audio { color: #9a5b00; }
.leaf-badge-read { color: #5b21b6; }
.leaf-badge-img { color: #065f46; }
.leaf-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 0 0;
}
.leaf-topic-chip {
  font-size: 0.78rem;
  font-weight: 700;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.85);
  border: 1px solid var(--edge);
  color: var(--soft);
}
.leaf-prev-next {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 10px;
  max-width: 840px;
  margin: 24px auto 0;
}
.leaf-prev-next a {
  display: inline-block;
  padding: 10px 16px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--edge);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--ink);
}
.leaf-prev-next a:hover {
  border-color: var(--green);
  color: var(--green-d);
}
.subj-block {
  margin-bottom: 42px;
}
.subj-block.is-hidden {
  display: none;
}
.subj-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  border-bottom: 3px solid var(--edge);
  padding-bottom: 8px;
  margin-bottom: 18px;
}
.subj-head h2 {
  text-align: left;
  margin: 0;
  font-size: 1.4rem;
}
.subj-head p {
  margin: 0;
  font-size: 0.9rem;
  color: var(--soft);
}
.free-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 14px;
}
.free-card {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--card);
  border: 2px solid var(--edge);
  border-radius: 18px;
  padding: 15px 17px;
  text-decoration: none;
  color: var(--ink);
  box-shadow: 0 3px 10px rgba(59, 47, 42, 0.05);
  transition: transform 0.12s ease, border-color 0.12s ease;
}
.free-card:hover {
  transform: translateY(-2px);
  border-color: var(--green);
}
.free-card h3 {
  margin: 6px 0 6px;
  font-size: 1.02rem;
  color: var(--ink);
  line-height: 1.42;
}
.free-card p {
  margin: 0 0 10px;
  font-size: 0.86rem;
  color: var(--soft);
  line-height: 1.5;
}
.free-card-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 800;
  color: var(--green-d);
}
.free-card.is-featured {
  border-color: #93c5fd;
  background: linear-gradient(180deg, #f8fbff 0%, #ffffff 100%);
}

/* Score sticky bar */
.score-bar {
  position: sticky;
  top: 64px;
  z-index: 8;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 2px solid var(--edge);
  padding: 10px 0;
}
.score-bar-in {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.score-status {
  font-weight: 900;
  font-size: 0.96rem;
}
.score-status b {
  color: var(--green-d);
  font-size: 1.1rem;
}

/* Question cards */
.quiz-list {
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-width: 840px;
  margin: 26px auto;
}
.q-card {
  background: #fff;
  border: 2px solid var(--edge);
  border-radius: 20px;
  padding: 20px 22px;
  box-shadow: 0 4px 12px rgba(59, 47, 42, 0.05);
}
.q-card.is-correct {
  border-color: var(--green);
  background: #f7fdf8;
}
.q-card.is-wrong {
  border-color: #e57373;
  background: #fff9f9;
}
.q-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.q-num {
  display: inline-block;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  font-size: 0.84rem;
  padding: 2px 11px;
  border-radius: 999px;
}
.q-tag {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--soft);
}
.q-passage {
  background: #faf6ee;
  border-left: 4px solid var(--orange);
  border-radius: 10px;
  padding: 12px 16px;
  margin: 0 0 12px;
  font-size: 0.95rem;
  line-height: 1.75;
  white-space: pre-line;
}
.q-figure {
  margin: 0 0 12px;
  text-align: center;
  background: #fff;
  border: 1.5px solid var(--edge);
  border-radius: 12px;
  padding: 10px;
}
.q-figure img {
  margin: 0 auto;
  max-height: 260px;
  width: auto;
  border-radius: 6px;
}
.q-stem {
  font-size: 1.06rem;
  font-weight: 800;
  margin: 0 0 12px;
  line-height: 1.7;
  white-space: pre-line;
}
.q-audio {
  background: #eef6ff;
  border: 2px solid #bfdbfe;
  border-radius: 14px;
  padding: 10px 14px;
  margin: 0 0 12px;
}
.q-audio-label {
  font-size: 0.85rem;
  font-weight: 800;
  color: #1e40af;
  margin: 0 0 6px;
}
.q-audio audio {
  width: 100%;
  height: 38px;
}
.q-choices {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
}
.q-choice-btn {
  width: 100%;
  text-align: left;
  padding: 11px 13px;
  border-radius: 14px;
  border: 2px solid var(--edge);
  background: #fff;
  color: var(--ink);
  font-family: inherit;
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.48;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.q-choice-btn:hover:not(:disabled) {
  border-color: var(--green);
  background: #f5fbf6;
}
.q-choice-btn:disabled {
  cursor: default;
}
.q-choice-btn.is-right {
  border-color: var(--green);
  background: #dcfce7;
  color: #14532d;
}
.q-choice-btn.is-picked-wrong {
  border-color: #dc2626;
  background: #fee2e2;
  color: #7f1d1d;
}
.q-choice-mark {
  flex: 0 0 auto;
  font-weight: 900;
  color: var(--green-d);
}
.q-hint {
  margin-top: 10px;
  border: 1px dashed var(--edge);
  background: #fffdf8;
  padding: 7px 13px;
  max-width: none;
}
.q-hint summary {
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--soft);
  cursor: pointer;
}
.q-hint p {
  margin: 6px 0 0;
  font-size: 0.88rem;
}
.q-exp {
  display: none;
  margin-top: 12px;
  padding: 12px 15px;
  border-radius: 14px;
  background: #f1faf2;
  border: 1px solid #bbf7d0;
  font-size: 0.92rem;
}
.q-exp.is-open {
  display: block;
}
.q-exp-judge {
  font-weight: 900;
  margin: 0 0 4px;
}
.q-exp-judge.is-ok { color: var(--green-d); }
.q-exp-judge.is-ng { color: #b91c1c; }
.q-exp p {
  margin: 4px 0 0;
}
.q-transcript {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #bbf7d0;
  font-size: 0.86rem;
  color: var(--soft);
}

/* Result summary card */
.quiz-result {
  display: none;
  max-width: 840px;
  margin: 26px auto;
  background: linear-gradient(180deg, #fffdf6 0%, #f1faf2 100%);
  border: 3px solid var(--green);
  border-radius: 24px;
  padding: 24px;
  text-align: center;
}
.quiz-result.is-open {
  display: block;
}
.quiz-result img {
  width: 90px;
  margin: 0 auto 8px;
}
.quiz-result h2 {
  margin: 0 0 8px;
}
.quiz-result-score {
  font-size: 2.1rem;
  font-weight: 900;
  color: var(--green-d);
  margin: 4px 0 10px;
}
.quiz-result .quiz-toolbar {
  justify-content: center;
}

/* App CTA Banner */
.app-banner {
  max-width: 840px;
  margin: 30px auto;
  background: #fff;
  border: 3px solid var(--orange);
  border-radius: 24px;
  padding: 22px;
  display: grid;
  grid-template-columns: 1.4fr auto;
  gap: 20px;
  align-items: center;
}
.app-banner h2 {
  text-align: left;
  font-size: 1.32rem;
  margin: 0 0 8px;
}
.app-banner p {
  margin: 0 0 10px;
  font-size: 0.94rem;
  color: var(--soft);
}
.app-banner-cta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Related links */
.related-box {
  max-width: 840px;
  margin: 28px auto 0;
}
.related-box h2 {
  text-align: left;
  font-size: 1.2rem;
  margin: 0 0 12px;
}
.related-links {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.related-links a {
  display: inline-block;
  padding: 7px 13px;
  border-radius: 999px;
  background: #fff;
  border: 2px solid var(--edge);
  text-decoration: none;
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--ink);
}
.related-links a:hover {
  border-color: var(--green);
  color: var(--green-d);
}

/* Print-only elements hidden on screen */
.print-header,
.print-footer,
.print-answer-sheet,
.print-audio-note {
  display: none;
}

@media (max-width: 700px) {
  .q-choices {
    grid-template-columns: 1fr;
  }
  .q-card {
    padding: 15px;
  }
  .app-banner {
    grid-template-columns: 1fr;
    text-align: center;
  }
  .app-banner h2 {
    text-align: center;
  }
}

/* ===== DENSE A4 PRINT WORKSHEET (B&W ink-saving default + optional Color mode) ===== */
@media print {
  @page {
    size: A4 portrait;
    margin: 8mm 10mm;
  }
  body {
    background: #fff;
    color: #111;
    font-size: 8.6pt;
    line-height: 1.38;
    letter-spacing: 0.01em;
  }
  .top,
  .crumb,
  .free-hero,
  .score-bar,
  .quiz-toolbar,
  .q-hint,
  .q-exp,
  .q-audio audio,
  .quiz-result,
  .app-banner,
  .related-box,
  .leaf-prev-next,
  .sec-faq,
  .foot {
    display: none !important;
  }
  .wrap {
    max-width: none;
    padding: 0;
  }

  /* Compact A4 Header */
  .print-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 1.5px solid #222;
    padding-bottom: 4px;
    margin-bottom: 8px;
  }
  .print-header h1 {
    font-size: 12pt;
    margin: 0;
    line-height: 1.25;
  }
  .print-header .print-brand {
    font-size: 7.5pt;
    color: #555;
    margin: 0 0 1px;
  }
  .print-name-box {
    font-size: 8.8pt;
    white-space: nowrap;
  }

  /* Dense 2-column question grid; passage questions span full width */
  .quiz-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 5px 8px;
    margin: 0;
    max-width: none;
  }
  .q-card {
    border: 0.8px solid #bbb;
    border-radius: 5px;
    padding: 5px 7px;
    box-shadow: none;
    background: #fff !important;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .q-card.has-passage {
    grid-column: 1 / -1;
  }
  .q-head {
    margin-bottom: 2px;
  }
  .q-num {
    background: #222;
    color: #fff;
    font-size: 7.5pt;
    padding: 0 6px;
    border-radius: 3px;
  }
  .q-tag {
    font-size: 7pt;
    color: #555;
  }
  .q-passage {
    background: #fff;
    border-left: 2px solid #666;
    border-radius: 2px;
    padding: 3px 7px;
    margin: 2px 0 4px;
    font-size: 8.2pt;
    line-height: 1.38;
  }
  .q-figure {
    margin: 2px 0 4px;
    padding: 3px;
    border: 0.6px solid #ccc;
    border-radius: 4px;
  }
  .q-figure img {
    max-height: 105px;
    width: auto;
  }
  .q-stem {
    font-size: 8.6pt;
    font-weight: 700;
    margin: 2px 0 4px;
    line-height: 1.35;
  }
  .q-audio {
    background: #fff;
    border: 0.8px dashed #777;
    border-radius: 3px;
    padding: 2px 6px;
    margin: 2px 0 4px;
  }
  .q-audio-label {
    display: none;
  }
  .print-audio-note {
    display: block;
    font-size: 7.2pt;
    color: #444;
    margin: 0;
  }
  .q-choices {
    grid-template-columns: repeat(2, 1fr);
    gap: 3px 5px;
  }
  .q-choice-btn {
    border: 0.7px solid #bbb !important;
    background: #fff !important;
    color: #111 !important;
    border-radius: 3px;
    padding: 2px 5px;
    font-size: 8.2pt;
    font-weight: 600;
    line-height: 1.3;
    gap: 4px;
  }
  .q-choice-mark {
    color: #222;
  }

  /* Compact A4 Footer */
  .print-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border-top: 0.8px solid #bbb;
    margin-top: 8px;
    padding-top: 5px;
    font-size: 7.5pt;
    color: #444;
    break-inside: avoid;
  }
  .print-footer img {
    width: 36px;
    height: 36px;
  }

  /* Compact 2-column Answer Sheet on Page 2 */
  body.print-with-answers .print-answer-sheet {
    display: block;
    page-break-before: always;
    break-before: page;
  }
  .print-answer-sheet h2 {
    font-size: 11pt;
    text-align: left;
    border-bottom: 1.5px solid #222;
    padding-bottom: 3px;
    margin: 0 0 7px;
  }
  .print-ans-list {
    list-style: none;
    padding: 0;
    margin: 0;
    column-count: 2;
    column-gap: 14px;
  }
  .print-ans-list li {
    padding: 3px 0;
    border-bottom: 0.6px dashed #ccc;
    font-size: 8pt;
    line-height: 1.35;
    break-inside: avoid;
  }

  /* Optional Color Print Mode (toggled by user checkbox) */
  body.print-color {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  body.print-color .print-header {
    border-bottom-color: #23913f;
    background: #f1faf2;
    padding: 6px 10px;
    border-radius: 6px;
  }
  body.print-color .print-header h1 {
    color: #17692c;
  }
  body.print-color .q-card {
    border-color: #e5d5b7;
    background: #fffdf9 !important;
  }
  body.print-color .q-num {
    background: #23913f;
    color: #fff;
  }
  body.print-color .q-passage {
    background: #fff8ec;
    border-left-color: #ffb02e;
  }
  body.print-color .q-audio {
    background: #eef6ff;
    border-color: #93c5fd;
  }
  body.print-color .print-audio-note {
    color: #1e40af;
  }
  body.print-color .q-choice-mark {
    color: #17692c;
  }
  body.print-color .print-answer-sheet h2 {
    color: #17692c;
    border-bottom-color: #23913f;
  }
}
