/* ----------------------------------------------------------------------
 * M Plus Round 1c
 * ---------------------------------------------------------------------- */
@font-face {
  font-family: "MPR";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src:
    url("../fonts/MPLUSRounded1c-Regular_Subset.woff2") format("woff2"),
    url("../fonts/MPLUSRounded1c-Regular_Subset.woff") format("woff");
}

@font-face {
  font-family: "MPR";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src:
    url("../fonts/MPLUSRounded1c-Bold_Subset.woff2") format("woff2"),
    url("../fonts/MPLUSRounded1c-Bold_Subset.woff") format("woff");
}

/* ---------------------------------------
 * SN Pro (only for specific pages)
 * --------------------------------------- */
@font-face {
  font-family: "SNPro";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src:
    local("SN Pro"),
    local("SNPro-Regular"),
    url("../fonts/SNPro-Regular.woff2") format("woff2"),
    url("../fonts/SNPro-Regular.woff") format("woff");
}

@font-face {
  font-family: "SNPro";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src:
    local("SN Pro"),
    local("SNPro-Bold"),
    url("../fonts/SNPro-Bold.woff2") format("woff2"),
    url("../fonts/SNPro-Bold.woff") format("woff");
}

/* ---------------------------------------
 * for MASUME
 * --------------------------------------- */

@font-face {
  font-family: "Klee One Regular Local";
  src:
    url("../fonts/KleeOne-Regular.woff2") format("woff2"),
    url("../fonts/KleeOne-Regular.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Klee One SemiBold Local";
  src:
    url("../fonts/KleeOne-SemiBold.woff2") format("woff2"),
    url("../fonts/KleeOne-SemiBold.woff") format("woff");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "AnzumojiHajime Local";
  src:
    url("../fonts/APJapanesefontHT.woff2") format("woff2"),
    url("../fonts/APJapanesefontHT.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --site-key: #ff8400;
  --title: #333333;
  --text: #1f2937;
  --muted: #6b7280;
  --panel: #ffffff;
  --page: #ffffff;
  --control-bg: #f5f7fb;

  --line-major: #8c8c8c;
  --line-minor: #d9d9d9;
  --line-rule: #9d9d9d;
  --sample-gray: #9b9b9b;

  --font-ui:
    "UD デジタル 教科書体 NK-R", "UD Digi Kyokasho NK-R", "UDDigiKyokashoNK-R",
    "UD Digi Kyokasho NK Regular", "UD デジタル 教科書体 NK Regular",
    "UD Digi Kyokasho NK", "UD デジタル 教科書体 NK",
    "UD デジタル 教科書体 N-R", "UD Digi Kyokasho N-R", "YuKyokasho",
    "Yu Kyokasho", "YuKyokasho Medium", "游教科書体", "YuKyokasho Yoko Medium",
    "YuKyokasho Yoko", "SNPro", "MPR", "Klee One SemiBold Local",
    "Klee One Regular Local", "Klee One", "AnzumojiHajime Local",
    "あんずもじ始等幅", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;

  --font-practice:
    "UD デジタル 教科書体 NK-R", "UD Digi Kyokasho NK-R", "UDDigiKyokashoNK-R",
    "UD Digi Kyokasho NK Regular", "UD デジタル 教科書体 NK Regular",
    "UD Digi Kyokasho NK", "UD デジタル 教科書体 NK",
    "UD デジタル 教科書体 N-R", "UD Digi Kyokasho N-R", "YuKyokasho",
    "Yu Kyokasho", "YuKyokasho Medium", "游教科書体", "YuKyokasho Yoko Medium",
    "YuKyokasho Yoko", "Klee One SemiBold Local", "Klee One Regular Local",
    "Klee One", "AnzumojiHajime Local", "あんずもじ始等幅", "Hiragino Sans",
    "Yu Gothic UI", "Yu Gothic", sans-serif;

  --font-btn:
    "SNPro", "MPR", "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;

  --practice-font-size: 58.244px;
  --practice-font-y-adjust: -2px;
  --display-name-size: 32.213px;
  --display-name-y-adjust: 4px;
  --practice-font-weight: 400;

  --practice-input-max-width: 22rem;
}

.kcode-practice-app,
.kcode-practice-app * {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--text);
  background: var(--control-bg);
  font-family: var(--font-ui);
}

.kcode-practice-app.app-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 20px 24px 24px;
  align-items: stretch;
  background: var(--control-bg);
  color: var(--text);
  font-family: var(--font-ui);
}

/* =========================================
   App breadcrumb navigation
========================================= */

.kcode-practice-app .app-top-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  align-items: stretch;
}

.kcode-practice-app .app-breadcrumb {
  width: min(100%, 140mm);
  margin-left: max(0px, calc((100% - 297mm) / 2));
  align-self: flex-start;
  padding: 0 2px;
  color: #6b7280;
  font-family: var(--font-ui);
}

.kcode-practice-app .app-breadcrumb__list {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.5;
}

.kcode-practice-app .app-breadcrumb__item {
  display: inline-flex;
  align-items: center;
  min-width: 0;
}

/* ホームアイコン付きパンくずリンク */
.kcode-practice-app .app-breadcrumb__link--home {
  display: inline-flex;
  align-items: center;
  gap: 0.28em;
}

.kcode-practice-app .app-breadcrumb__home-icon {
  display: inline-block;
  width: 1.35em;
  height: 1.35em;
  flex: 0 0 1.35em;
  fill: currentColor;
  color: currentColor;
  transform: translateY(-0.15em);
}

.kcode-practice-app .app-breadcrumb__item + .app-breadcrumb__item::before {
  content: "/";
  margin: 0 0.55em;
  color: #c4c9d1;
  font-weight: 700;
}

.kcode-practice-app .app-breadcrumb__link {
  color: #6b7280;
  text-decoration: none;
  text-underline-offset: 0.18em;
  transition: color 0.18s ease;
}

.kcode-practice-app .app-breadcrumb__link:hover,
.kcode-practice-app .app-breadcrumb__link:focus-visible {
  color: var(--site-key);
  text-decoration: underline;
}

.kcode-practice-app .app-breadcrumb__current {
  color: #8b95a1;
  overflow-wrap: anywhere;
}

.kcode-practice-app .control-panel {
  /* 上部エリアは小さめにし、下部A4用紙エリアの左端に合わせます。 */
  width: min(100%, 140mm);
  margin-left: max(0px, calc((100% - 297mm) / 2));
  align-self: flex-start;
  background: var(--panel);
  border-radius: 18px;
  box-shadow: 0 12px 32px rgb(15 23 42 / 10%);
  padding: 20px 24px 18px;
}

.kcode-practice-app .control-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 16px;
  min-height: 44px;
  margin-bottom: 16px;
  padding-right: 172px;
}

.kcode-practice-app .control-heading {
  min-width: 0;
}

.kcode-practice-app .app-actions {
  position: absolute;
  top: 50%;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  transform: translateY(-50%);
}

.kcode-practice-app .eyebrow {
  margin: 0 0 6px;
  color: var(--site-key);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.kcode-practice-app .control-panel h1 {
  margin: 0;
  color: var(--title);
  font-size: 22px;
  line-height: 1.35;
}

.kcode-practice-app .control-layout {
  display: block;
}

.kcode-practice-app .control-main {
  min-width: 0;
}

.kcode-practice-app .form-row {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.kcode-practice-app .form-row label {
  font-size: 14px;
  font-weight: 700;
}

/* 練習文字入力欄：アイコン付き入力バー */
.kcode-practice-app .form-row--practice-input {
  width: 100%;
  max-width: var(--practice-input-max-width);
  min-width: 0;
  margin-bottom: 12px;
}

/* 画面上は非表示。ただしスクリーンリーダー用にlabelは残す */
.kcode-practice-app .visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.kcode-practice-app textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 14px;
  background: #fff;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 20px;
  line-height: 24px;
  height: 54px;
  min-height: 54px;
  resize: none;
  overflow: hidden;
}

.kcode-practice-app textarea:focus,
.kcode-practice-app button:focus-visible {
  outline: 3px solid rgb(255 132 0 / 28%);
  outline-offset: 2px;
  border-color: var(--site-key);
}

/* =========================================
   Practice input: icon + grid flow
========================================= */

.kcode-practice-app .practice-input-shell {
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 58px;
  padding: 0 10px;
  border: 1px solid #d1d5db;
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 2px 8px rgb(15 23 42 / 4%);
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    background-color 0.18s ease;
}

.kcode-practice-app .practice-input-shell:focus-within {
  border-color: var(--site-key);
  box-shadow: 0 0 0 4px rgb(255 132 0 / 16%);
}

.kcode-practice-app .practice-input-shell__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-right: 8px;
  border-radius: 50%;
  background: #fff7ed;
  color: var(--site-key);
  flex: 0 0 34px;
}

.kcode-practice-app .practice-input-shell__icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.kcode-practice-app .practice-input-shell textarea {
  flex: 1 1 auto;
  width: auto;
  height: 40px;
  min-height: 40px;
  padding: 8px 4px;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 20px;
  line-height: 24px;
  resize: none;
  overflow: hidden;
  min-width: 0;
}

.kcode-practice-app .practice-input-shell textarea:focus {
  outline: none;
  border-color: transparent;
}

.kcode-practice-app .practice-input-shell textarea::placeholder {
  color: #9ca3af;
  opacity: 1;
  font-family:
    system-ui,
    -apple-system,
    "Segoe UI",
    sans-serif;
  font-size: 0.9em;
  letter-spacing: 0.01em;
}

.kcode-practice-app .practice-input-shell__flow {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 8px;
  color: #9ca3af;
  flex: 0 0 auto;
  pointer-events: none;
}

.kcode-practice-app .practice-input-shell__arrow {
  font-size: 15px;
  line-height: 1;
}

.kcode-practice-app .practice-input-shell__flow svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.kcode-practice-app .notice {
  min-height: 24px;
  margin: 0 0 12px;
  color: #b45309;
  font-size: 13px;
  line-height: 1.6;
}

.kcode-practice-app .button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 0;
}

.kcode-practice-app .preview-wrap {
  width: 100%;
  overflow: auto;
  padding-bottom: 16px;
}

.kcode-practice-app .preview-wrap .print-page {
  margin: 0 auto;
}

.kcode-practice-app .print-page {
  width: 297mm;
  height: 210mm;
  padding: 18mm 12mm 14mm 28mm;
  background: var(--page);
  box-shadow: 0 16px 42px rgb(15 23 42 / 18%);
  color: #111;
}

.kcode-practice-app .practice-sheet {
  position: relative;
  width: 246mm;
  height: 137.5mm;
  overflow: visible;
}

.kcode-practice-app .romaji-layer {
  position: relative;
  width: 246mm;
  height: 7.5mm;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  align-items: center;
  pointer-events: none;
  color: #4b5563;
  font-family: var(--font-ui);
  font-size: 13px;
  line-height: 1;
  text-align: center;
  z-index: 3;
}

.kcode-practice-app .romaji-cell {
  min-width: 0;
  overflow: visible;
  white-space: nowrap;
  text-align: center;
  letter-spacing: 0.01em;
}

.kcode-practice-app .grid-area {
  position: relative;
  width: 246mm;
  height: 130mm;
  overflow: visible;
}

.kcode-practice-app .grid-svg,
.kcode-practice-app .text-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.kcode-practice-app .grid-svg {
  display: block;
  overflow: visible;
  shape-rendering: geometricPrecision;
}

.kcode-practice-app .grid-svg .minor-line {
  stroke: var(--line-minor);
  stroke-width: 0.22;
  stroke-linecap: square;
  fill: none;
}

.kcode-practice-app .grid-svg .major-line {
  stroke: var(--line-major);
  stroke-width: 0.32;
  stroke-linecap: square;
  fill: none;
}

.kcode-practice-app .text-layer {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(6, 1fr);
  pointer-events: none;
  font-family: var(--font-practice);
  font-weight: var(--practice-font-weight);
}

.kcode-practice-app .text-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  line-height: 1;
  overflow: visible;
  white-space: pre;
}

.kcode-practice-app .text-glyph {
  display: inline-block;
  font-size: var(--practice-font-size);
  line-height: 1;
  transform: translateY(var(--practice-font-y-adjust));
  transform-origin: center center;
}

.kcode-practice-app .text-cell.row-sample {
  color: #111;
}

.kcode-practice-app .text-cell.row-trace {
  color: var(--sample-gray);
}

.kcode-practice-app .text-cell.empty-row {
  color: transparent;
}

.kcode-practice-app .writing-lines {
  width: 276mm;
  margin-top: 7.5mm;
  margin-left: -19mm;
}

.kcode-practice-app .display-name {
  min-height: 13mm;
  padding-left: 2mm;
  font-family: var(--font-practice);
  font-weight: var(--practice-font-weight);
  font-size: var(--display-name-size);
  line-height: 1.15;
  white-space: pre;
  transform: translateY(var(--display-name-y-adjust));
}

.kcode-practice-app .rule-line {
  height: 12mm;
  border-top: 0.35mm solid var(--line-rule);
}

.kcode-practice-app .rule-line.second {
  margin-top: 0;
}

@media (max-width: 960px) {
  .kcode-practice-app.app-shell {
    padding: 16px;
  }

  .kcode-practice-app .control-panel {
    width: min(100%, 140mm);
    margin-left: 0;
    padding: 18px;
    border-radius: 14px;
  }
  .kcode-practice-app .app-breadcrumb {
    width: min(100%, 140mm);
    margin-left: 0;
  }
}

@media (max-width: 991.98px) {
  .kcode-practice-app .control-header {
    padding-right: 76px;
  }

  .kcode-practice-app .app-actions {
    gap: 4px;
  }
}

@media (max-width: 420px) {
  .kcode-practice-app .control-header {
    min-height: 36px;
    padding-right: 64px;
  }

  .kcode-practice-app .app-actions {
    gap: 2px;
  }
}

@media (max-width: 520px) {
  .kcode-practice-app .practice-input-shell {
    min-height: 54px;
    padding: 0 8px;
    border-radius: 14px;
  }

  .kcode-practice-app .practice-input-shell__icon {
    width: 30px;
    height: 30px;
    margin-right: 6px;
    flex-basis: 30px;
  }

  .kcode-practice-app .practice-input-shell__icon svg {
    width: 16px;
    height: 16px;
  }

  .kcode-practice-app .practice-input-shell textarea {
    font-size: 18px;
  }

  .kcode-practice-app .practice-input-shell__flow {
    gap: 3px;
    margin-left: 5px;
  }

  .kcode-practice-app .practice-input-shell__flow svg {
    width: 19px;
    height: 19px;
  }
  .kcode-practice-app .app-top-stack {
    gap: 7px;
  }

  .kcode-practice-app .app-breadcrumb__list {
    font-size: 12px;
    line-height: 1.65;
  }

  .kcode-practice-app .app-breadcrumb__item + .app-breadcrumb__item::before {
    margin: 0 0.42em;
  }
}

@media (max-width: 360px) {
  .kcode-practice-app.app-shell {
    padding: 12px;
  }

  .kcode-practice-app .control-panel {
    padding: 16px 14px;
  }

  .kcode-practice-app .practice-input-shell {
    padding: 0 7px;
  }

  .kcode-practice-app .practice-input-shell__icon {
    width: 28px;
    height: 28px;
    margin-right: 5px;
    flex-basis: 28px;
  }

  .kcode-practice-app .practice-input-shell__flow {
    gap: 2px;
    margin-left: 4px;
  }

  .kcode-practice-app .practice-input-shell__flow svg {
    width: 18px;
    height: 18px;
  }

  .kcode-practice-app .practice-input-shell textarea {
    min-width: 0;
    font-size: 17px;
  }
}

/* =========================================
   Help / About modal
========================================= */
.kcode-practice-app .info-modal[hidden] {
  display: none !important;
}

.kcode-practice-app .info-modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.kcode-practice-app .info-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgb(15 23 42 / 54%);
}

.kcode-practice-app .info-modal__panel {
  position: relative;
  width: min(100%, 560px);
  max-height: min(82vh, 680px);
  overflow: auto;
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 24px 80px rgb(15 23 42 / 30%);
}

.kcode-practice-app .info-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0.6em 0.8em;
  border-bottom: 1px solid #f3f4f6;
}

.kcode-practice-app .info-modal__header h2 {
  margin: 0;
  color: var(--site-key);
  font-size: 20px;
  line-height: 1.35;
}

.kcode-practice-app .info-modal__close {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;

  /* 見た目は×だけ。ただし押しやすいクリック領域は残します。 */
  width: 34px;
  height: 34px;
  padding: 0;

  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #6b7280;
  box-shadow: none;

  font-family: Arial, Helvetica, sans-serif;
  font-size: 30px;
  font-weight: 400;
  line-height: 1;

  cursor: pointer;
  transition:
    color 0.18s ease,
    background-color 0.18s ease;
}

.kcode-practice-app .info-modal__close:hover,
.kcode-practice-app .info-modal__close:focus-visible {
  background: transparent;
  color: var(--site-key);
}

.info-modal__title-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25em;
  height: 1.25em;
  margin-right: 0.45em;
  border-radius: 999px;
  background: #ff8400;
  color: #fff;
  font-family: var(--font-btn);
  font-size: 0.9em;
  font-weight: 700;
  line-height: 1;
  vertical-align: middle;
}

.info-modal__title-text {
  vertical-align: middle;
}

.kcode-practice-app .info-modal__body {
  padding: 16px 20px 22px;
  color: var(--text);
  font-size: 15px;
  line-height: 1.75;
}

.kcode-practice-app .info-modal__body p {
  margin: 0 0 12px;
}

.kcode-practice-app .info-modal__body ol,
.kcode-practice-app .info-modal__body ul {
  margin: 0 0 14px;
  padding-left: 1.35em;
}

.kcode-practice-app .info-modal__body li + li {
  margin-top: 6px;
}

.kcode-practice-app .info-modal__note {
  margin-top: 14px;
  padding: 10px 12px;
  border-left: 4px solid var(--site-key);
  border-radius: 10px;
  background: #fff7ed;
  color: #7c2d12;
  font-size: 13px;
  line-height: 1.65;
}

/* 初期値：補正なし */
.kcode-practice-app {
  --app-button-label-y-adjust: 0px;
}

.kcode-practice-app.is-windows-ui-font {
  --app-button-label-y-adjust: 1px;
}

/* Windows + UD系フォント想定時だけ、ボタン文字を少し下げる */
.kcode-practice-app.is-windows-ui-font .kc-btn--app [data-btn-label] {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  transform: translateY(var(--app-button-label-y-adjust));
}

@page {
  size: A4 landscape;
  margin: 0;
}

@media print {
  html,
  body {
    width: 297mm;
    height: 210mm;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #fff !important;
  }

  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  body * {
    visibility: hidden !important;
  }

  .kcode-practice-app,
  .kcode-practice-app * {
    visibility: visible !important;
  }

  .kcode-practice-app.app-shell {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    display: block !important;
    width: 297mm !important;
    height: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: #fff !important;
  }

  .kcode-practice-app .app-top-stack,
  .kcode-practice-app .control-panel {
    display: none !important;
  }

  .kcode-practice-app .preview-wrap {
    display: block !important;
    width: 297mm !important;
    height: 210mm !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
  }

  .kcode-practice-app .print-page {
    width: 297mm !important;
    height: 210mm !important;
    margin: 0 !important;
    padding: 18mm 12mm 14mm 28mm !important;
    box-shadow: none !important;
    overflow: hidden !important;
    break-before: avoid;
    break-after: auto;
    break-inside: avoid;
    page-break-before: avoid;
    page-break-after: auto;
    page-break-inside: avoid;
  }

  .kcode-practice-app .practice-sheet {
    width: 246mm !important;
    height: 137.5mm !important;
    overflow: visible !important;
  }

  .kcode-practice-app .romaji-layer {
    display: grid !important;
    width: 246mm !important;
    height: 7.5mm !important;
    grid-template-columns: repeat(12, minmax(0, 1fr)) !important;
    align-items: center !important;
    visibility: visible !important;
    overflow: visible !important;
  }

  .kcode-practice-app .romaji-cell {
    visibility: visible !important;
    white-space: nowrap !important;
  }

  .kcode-practice-app .grid-area {
    position: relative !important;
    width: 246mm !important;
    height: 130mm !important;
    overflow: visible !important;
  }
}
