/* ===== デザイントークン（兄弟アプリ共通・暖色の紙トーン） ===== */
:root {
  --color-paper: oklch(97.5% 0.012 88);
  --color-paper-2: oklch(94.5% 0.016 88);
  --color-paper-3: oklch(90.5% 0.019 86);
  --color-surface: oklch(99% 0.007 88);
  --color-ink: oklch(22% 0.018 64);
  --color-ink-2: oklch(34% 0.018 68);
  --color-muted: oklch(40% 0.016 72);
  --color-rule: oklch(78% 0.018 84);
  --color-rule-2: oklch(61% 0.021 78);
  --color-accent: oklch(43% 0.12 248);
  --color-accent-soft: oklch(91% 0.035 248);
  --color-success: oklch(42% 0.11 147);
  --color-success-soft: oklch(93% 0.035 147);
  --color-error: oklch(48% 0.17 28);
  --color-error-soft: oklch(94% 0.035 28);
  --color-focus: oklch(49% 0.17 248);

  --font-display: "Shippori Mincho", "Yu Mincho", serif;
  --font-body: "Noto Sans JP", "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  --font-sheet: "Klee One", "BIZ UDPGothic", "Yu Gothic", serif;

  --radius-card: 0.5rem;
  --radius-input: 0.4rem;
  --radius-control: 0.35rem;
  --rule-hair: 1px;
  --shadow-whisper: 0 1px 2px rgba(30, 20, 10, .08);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--color-paper-2);
  color: var(--color-ink);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; }

/* ===== ヘッダー ===== */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 4.75rem;
  padding: .9rem clamp(1rem, 3vw, 2.5rem);
  background: var(--color-surface);
  border-bottom: var(--rule-hair) solid var(--color-rule-2);
  gap: 1rem;
}
.logo-container { display: flex; align-items: center; gap: .85rem; }
.logo-icon {
  width: 2.5rem; height: 2.5rem; flex: 0 0 2.5rem;
  display: flex; align-items: center; justify-content: center;
  background: var(--color-paper);
  border: var(--rule-hair) solid var(--color-ink);
  border-radius: var(--radius-control);
  font-family: var(--font-display);
  font-size: 1.25rem; font-weight: 700;
}
.app-title {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem; font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--color-ink);
}
.app-subtitle { margin: .1rem 0 0; font-size: .85rem; color: var(--color-muted); }
.header-status { display: flex; align-items: center; gap: .75rem; }
.hole-badge {
  display: inline-flex; align-items: baseline; gap: .3rem;
  padding: .35rem .7rem;
  font-size: .8rem; color: var(--color-ink-2);
  background: var(--color-paper);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: 999px;
  white-space: nowrap;
}
.hole-badge strong { font-size: 1rem; color: var(--color-accent); }

/* ===== レイアウト ===== */
.main-container {
  display: grid;
  grid-template-columns: minmax(20rem, 24rem) minmax(0, 1fr);
  align-items: start;
  gap: clamp(1rem, 3vw, 2rem);
  width: 100%;
  max-width: 90rem;
  margin: 0 auto;
  padding: clamp(1rem, 3vw, 1.75rem);
}
@media (max-width: 1000px) {
  .main-container { display: flex; flex-direction: column; align-items: stretch; }
  .control-panel { max-width: 40rem; margin-inline: auto; width: 100%; }
  .preview-container { width: 100%; }
}

/* ===== コントロールパネル ===== */
.control-panel {
  display: flex; flex-direction: column;
  background: var(--color-surface);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-whisper);
  overflow: hidden;
}
.card {
  padding: 1.35rem 1.5rem;
  border-bottom: var(--rule-hair) solid var(--color-rule);
}
.card:last-of-type { border-bottom: 0; }
.card-title {
  display: flex; align-items: center; gap: .5rem;
  margin: 0 0 1.1rem;
  font-family: var(--font-display);
  font-size: 1.02rem; font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--color-ink);
}
.card-title::before {
  content: "";
  width: .5rem; height: .5rem; flex: 0 0 .5rem;
  background: var(--color-accent);
}
details.card { padding: 0; }
details.card > summary.card-title {
  padding: 1.35rem 1.5rem 1.1rem;
  margin: 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
details.card > summary.card-title::-webkit-details-marker { display: none; }
details.card > summary.card-title::after {
  content: "";
  width: .55rem; height: .55rem;
  margin-left: auto;
  border-right: 2px solid var(--color-muted);
  border-bottom: 2px solid var(--color-muted);
  transform: rotate(45deg);
  transition: transform .15s ease;
}
details.card[open] > summary.card-title::after { transform: rotate(-135deg); }
details.card > .card-body { padding: 0 1.5rem 1.35rem; }

.form-group { margin-bottom: 1.1rem; }
.form-group:last-child { margin-bottom: 0; }
.form-row { display: flex; gap: .8rem; align-items: flex-start; }
.form-row > .form-group { flex: 1 1 0; min-width: 0; }
label { display: block; font-size: .85rem; font-weight: 500; color: var(--color-ink-2); margin-bottom: .4rem; }

select, input[type="text"], input[type="number"] {
  width: 100%;
  min-height: 2.6rem;
  padding: .5rem .7rem;
  color: var(--color-ink);
  background: var(--color-surface);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-input);
  outline: 2px solid transparent;
  outline-offset: 1px;
}
select:disabled, input:disabled {
  opacity: .55;
  cursor: not-allowed;
}
select:focus, input:focus-visible {
  border-color: var(--color-ink-2);
  outline: 2px solid var(--color-focus);
}

.option-grid { display: grid; gap: .55rem; margin-bottom: 1.1rem; }
.option-grid:last-child { margin-bottom: 0; }
.check-row {
  display: flex; align-items: center; gap: .55rem;
  min-height: 1.8rem; margin: 0; cursor: pointer;
  font-size: .9rem; font-weight: 400; color: var(--color-ink-2);
}
.check-row input { width: 1.1rem; height: 1.1rem; flex: 0 0 1.1rem; accent-color: var(--color-accent); cursor: pointer; }
.help-text { font-size: .78rem; color: var(--color-muted); line-height: 1.55; margin-top: .5rem; }
.panel-lead { margin: 0 0 .9rem; font-size: .82rem; color: var(--color-muted); line-height: 1.6; }
.list-heading { margin: 1.1rem 0 .5rem; font-size: .78rem; font-weight: 700; color: var(--color-ink-2); }

/* ===== タブ ===== */
.tab-container {
  display: flex;
  gap: .25rem;
  padding: .25rem;
  margin-bottom: 1rem;
  background: var(--color-paper);
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-control);
}
.tab-btn {
  flex: 1 1 0;
  min-height: 2.1rem;
  padding: .3rem .4rem;
  font-size: .82rem; font-weight: 600;
  color: var(--color-muted);
  background: transparent;
  border: 0;
  border-radius: calc(var(--radius-control) - 1px);
  cursor: pointer;
}
.tab-btn:hover { color: var(--color-ink); }
.tab-btn.active {
  color: var(--color-accent-ink, #fff);
  background: var(--color-accent);
}
.mode-panel { margin-bottom: 1rem; }
.hole-count-row { margin-top: .2rem; }

/* ===== パターン ===== */
.pattern-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: .45rem; }
.pattern-btn {
  min-height: 2.35rem;
  padding: .35rem .3rem;
  font-size: .76rem; font-weight: 500;
  color: var(--color-ink-2);
  background: var(--color-surface);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-control);
  cursor: pointer;
}
.pattern-btn:hover { background: var(--color-paper-3); }
.pattern-btn.active { border-color: var(--color-accent); color: var(--color-accent); background: var(--color-accent-soft); }

/* ===== ボタン ===== */
.btn-row { display: flex; flex-direction: column; gap: .65rem; padding: 1.35rem 1.5rem 1.5rem; }
.btn {
  display: flex; align-items: center; justify-content: center; gap: .5rem;
  min-height: 2.85rem;
  padding: .7rem 1rem;
  color: var(--color-paper);
  background: var(--color-ink);
  border: var(--rule-hair) solid var(--color-ink);
  border-radius: var(--radius-control);
  font-size: .92rem; font-weight: 700;
  cursor: pointer;
  transition: background-color .15s ease, transform .1s ease;
}
.btn:hover { background: var(--color-ink-2); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn-secondary { color: var(--color-ink); background: var(--color-surface); border-color: var(--color-rule-2); }
.btn-secondary:hover { background: var(--color-paper-3); }
.btn-print { color: #fff; background: var(--color-success); border-color: var(--color-success); }
.btn-print:hover { background: oklch(from var(--color-success) calc(l - 0.06) c h); }
.btn-small { min-height: 2.15rem; padding: .4rem .7rem; font-size: .8rem; }
.btn-small:not(.btn) {
  color: var(--color-ink-2);
  background: var(--color-surface);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-control);
  cursor: pointer;
}
.btn-small:not(.btn):hover { background: var(--color-paper-3); }
.inline-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.inline-input { display: flex; gap: .5rem; }
.inline-input input { flex: 1 1 auto; min-width: 0; }
.inline-input .btn { flex: 0 0 auto; }

/* ===== リスト ===== */
.list-stack { display: flex; flex-direction: column; gap: .4rem; }
.list-empty { margin: 0; font-size: .8rem; color: var(--color-muted); }
.list-row {
  display: flex; align-items: center; justify-content: space-between; gap: .5rem;
  padding: .5rem .6rem;
  border: var(--rule-hair) solid var(--color-rule);
  border-radius: var(--radius-input);
  font-size: .82rem;
}
.list-row-main { display: flex; flex-direction: column; gap: .1rem; min-width: 0; }
.list-row-title { font-weight: 600; color: var(--color-ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list-row-meta { font-size: .72rem; color: var(--color-muted); }
.list-row-actions { display: flex; gap: .3rem; flex: 0 0 auto; }
.list-row-actions button {
  min-height: 1.9rem; padding: .25rem .5rem;
  font-size: .74rem; font-weight: 600;
  color: var(--color-ink-2);
  background: var(--color-surface);
  border: var(--rule-hair) solid var(--color-rule-2);
  border-radius: var(--radius-control);
  cursor: pointer;
}
.list-row-actions button:hover { background: var(--color-paper-3); }
.text-danger { color: var(--color-error) !important; }

/* ===== プレビュー ===== */
.preview-container { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
.preview-header {
  display: flex; align-items: center; justify-content: space-between; gap: .75rem;
  padding-bottom: .65rem;
  border-bottom: var(--rule-hair) solid var(--color-rule-2);
  flex-wrap: wrap;
}
.preview-title { font-family: var(--font-display); font-size: 1rem; font-weight: 700; display: inline-flex; align-items: center; gap: .5rem; }
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  padding: .1rem .55rem;
  font-family: var(--font-body);
  font-size: .72rem; font-weight: 700;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: 999px;
}
.preview-tools { display: flex; align-items: center; justify-content: flex-end; gap: .85rem; flex-wrap: wrap; }
.preview-hint { font-size: .78rem; color: var(--color-muted); }
.preview-fit {
  display: inline-flex; align-items: center; gap: .4rem;
  margin: 0; white-space: nowrap; cursor: pointer;
  font-size: .78rem; font-weight: 500; color: var(--color-ink-2);
}
.preview-fit input { width: 1.05rem; height: 1.05rem; flex: 0 0 1.05rem; accent-color: var(--color-accent); cursor: pointer; }

.app-alert {
  padding: .6rem .8rem;
  font-size: .8rem;
  color: var(--color-warning, #8a5a12);
  background: #fbf3e2;
  border: var(--rule-hair) solid #e3cf9d;
  border-radius: var(--radius-control);
}

.a4-wrapper {
  width: 100%;
  display: flex;
  justify-content: center;
  overflow: auto;
  padding-bottom: 1rem;
}
.sheet-frame {
  --preview-scale: 1;
  width: calc(210mm * var(--preview-scale));
  height: calc(297mm * var(--preview-scale));
  flex: 0 0 auto;
  position: relative;
}
.sheet-frame.is-pending { opacity: .35; }

/* ===== A4用紙 ===== */
.sheet {
  --cell: 17mm;
  --num: 18pt;
  --font-scale: 1;
  width: 210mm;
  height: 297mm;
  padding: 12mm;
  background: #fff;
  color: #1a1a1a;
  font-family: var(--font-sheet);
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  transform: scale(var(--preview-scale, 1));
  transform-origin: top left;
  box-shadow: 0 12px 28px rgba(40, 28, 10, .18);
  border: 1px solid rgba(0, 0, 0, .05);
}
.sheet[data-size="9"][data-layout="one"] { --cell: 17mm; --num: 18pt; }
.sheet[data-size="12"][data-layout="one"] { --cell: 12.5mm; --num: 13pt; }
.sheet[data-size="9"][data-layout="two"] { --cell: 9.6mm; --num: 11pt; }
.sheet[data-size="12"][data-layout="two"] { --cell: 7.6mm; --num: 8.5pt; }
.sheet[data-layout="table-bara"][data-bara="few"] { --cell: 13.5mm; --num: 14pt; }
.sheet[data-layout="table-bara"][data-bara="mid"] { --cell: 12mm; --num: 12pt; }
.sheet[data-layout="table-bara"][data-bara="many"] { --cell: 10mm; --num: 10pt; }
.sheet[data-layout="table-bara"][data-bara="ultra"] { --cell: 11mm; --num: 9pt; }
.sheet[data-size="12"][data-layout="table-bara"][data-bara="few"] { --cell: 10mm; --num: 10pt; }
.sheet[data-size="12"][data-layout="table-bara"][data-bara="mid"] { --cell: 9mm; --num: 9pt; }
.sheet[data-size="12"][data-layout="table-bara"][data-bara="many"] { --cell: 8mm; --num: 8pt; }
.sheet[data-size="12"][data-layout="table-bara"][data-bara="ultra"] { --cell: 7mm; --num: 7pt; }
.sheet[data-font="small"] { --font-scale: .88; }
.sheet[data-font="large"] { --font-scale: 1.14; }

.sheet-head {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 6mm;
  padding-bottom: 2mm;
  border-bottom: 2px solid #1a1a1a;
  flex: 0 0 auto;
}
.sheet-title-wrap { display: flex; align-items: baseline; gap: 3mm; min-width: 0; }
.sheet-title {
  margin: 0;
  font-size: 18pt;
  font-weight: 700;
  font-family: var(--font-sheet);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sheet-badge {
  padding: 0 2mm;
  font-size: 9pt; font-weight: 700;
  color: #b3401f;
  border: 1px solid #b3401f;
  border-radius: 1mm;
}
.sheet-score { font-size: 11pt; display: flex; align-items: center; gap: 2mm; white-space: nowrap; }
.score-box {
  display: inline-block;
  width: 22mm; height: 8mm;
  border: 1.2px solid #1a1a1a;
  border-radius: 1mm;
}
.score-max { font-size: 9pt; color: #444; }

.sheet-meta {
  display: flex; align-items: flex-end; gap: 7mm; flex-wrap: nowrap;
  margin: 4mm 0 3mm;
  font-size: 10pt;
  flex: 0 0 auto;
  white-space: nowrap;
}
.meta-slot { display: inline-flex; align-items: flex-end; gap: 1.5mm; }
.meta-label { font-size: 9pt; color: #333; }
.meta-line { display: inline-block; min-width: 32mm; height: 5mm; border-bottom: 1px solid #444; }
.meta-line--short { min-width: 8mm; }
.meta-date { display: inline-flex; align-items: flex-end; gap: 1mm; font-size: 9pt; }

.sheet-body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5mm;
}
.table-block { display: flex; flex-direction: column; align-items: center; gap: 1.5mm; }
.table-label { font-size: 9pt; font-weight: 700; color: #333; }

/* ===== 九九表 ===== */
.kuku-table {
  display: grid;
  grid-template-columns: var(--cell) repeat(var(--size), var(--cell));
  width: max-content;
  border-top: 1.4pt solid #1a1a1a;
  border-left: 1.4pt solid #1a1a1a;
  background: #fff;
}
.kuku-corner,
.kuku-head,
.kuku-cell {
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  border-right: .6pt solid #444;
  border-bottom: .6pt solid #444;
  border-top: 0;
  border-left: 0;
  font-family: var(--font-sheet);
  font-size: calc(var(--num) * var(--font-scale));
  font-variant-numeric: tabular-nums;
  line-height: 1;
  color: #1a1a1a;
  background: #fff;
  border-radius: 0;
  appearance: none;
}
.kuku-head,
.kuku-corner {
  background: #e9e3d4;
  font-weight: 700;
}
/* 見出しの行・列と本体の境目は太線にする */
.kuku-head--col,
.kuku-corner { border-bottom: 1.4pt solid #1a1a1a; }
.kuku-head--row,
.kuku-corner { border-right: 1.4pt solid #1a1a1a; }
.kuku-head { flex-direction: column; gap: .15em; }
.kuku-head-num { font-weight: 700; }
.kuku-head-dan {
  font-family: var(--font-body);
  font-size: max(calc(var(--cell) * .17), 4pt);
  font-weight: 700;
  line-height: 1;
  color: #555;
  letter-spacing: -.02em;
  white-space: nowrap;
}
/* 左上のマスは斜線で「かける」と「だん」の向きを示す */
.kuku-corner {
  position: relative;
  background:
    linear-gradient(to top right, transparent calc(50% - .4pt), #555 calc(50% - .4pt), #555 calc(50% + .4pt), transparent calc(50% + .4pt)),
    #e9e3d4;
}
.kuku-corner-col,
.kuku-corner-row {
  position: absolute;
  font-family: var(--font-body);
  font-size: max(calc(var(--cell) * .17), 4pt);
  font-weight: 700;
  line-height: 1;
  color: #555;
  white-space: nowrap;
}
.kuku-corner-col { top: 8%; right: 8%; }
.kuku-corner-row { bottom: 8%; left: 8%; }
.kuku-cell.is-five { background: #faf7ef; }
.kuku-cell.is-hole {
  background: repeating-linear-gradient(135deg, #f0ebdf 0 1.6mm, #fff 1.6mm 3.2mm);
  color: transparent;
}
.kuku-cell.is-answer-red { color: #c0392b; font-weight: 700; }
.kuku-cell.is-answer-gray { color: #b9b6ae; font-weight: 700; }
.kuku-cell.is-wrong {
  outline: 2px solid var(--color-error);
  outline-offset: -2px;
  background: var(--color-error-soft);
}
button.kuku-cell,
button.kuku-head { cursor: pointer; }
button.kuku-head:hover { background: #e9e4d7; }
@media (hover: hover) {
  .table-block button.kuku-cell:hover { background: #f6f1e4; }
  .table-block button.kuku-cell.is-hole:hover { background: #ece5d6; }
}

/* ===== ばら九九 ===== */
.bara-block { width: 100%; flex: 0 0 auto; }
.bara-title { font-size: 9pt; font-weight: 700; margin-bottom: 2mm; color: #333; }
.bara-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2.5mm 6mm;
}
.sheet[data-bara="mid"] .bara-list { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2mm 4mm; }
.sheet[data-bara="many"] .bara-list { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1.4mm 3mm; }
.sheet[data-bara="ultra"] .bara-list { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 1mm 2.5mm; }
.sheet[data-bara="many"] .bara-item { font-size: 9pt; gap: 1mm; }
.sheet[data-bara="ultra"] .bara-item { font-size: 7.5pt; gap: .8mm; }
.sheet[data-bara="many"] .bara-box { height: 4.8mm; max-width: 20mm; }
.sheet[data-bara="ultra"] .bara-box { height: 4mm; max-width: 8mm; }
.sheet[data-bara="ultra"] .bara-no { width: 4mm; font-size: 6pt; }
.sheet[data-bara="many"] .bara-title,
.sheet[data-bara="ultra"] .bara-title { font-size: 8pt; margin-bottom: 1.2mm; }
.sheet[data-size="12"][data-bara="ultra"] .bara-item { font-size: 6.5pt; }
.sheet[data-size="12"][data-bara="ultra"] .bara-box { max-width: 11mm; height: 4mm; }
.sheet[data-size="12"][data-bara="ultra"] .bara-list { gap: .5mm 2mm; }
.sheet[data-size="12"][data-bara="ultra"] .bara-no { width: 3mm; font-size: 5.5pt; }
.sheet[data-size="12"][data-bara="many"] .bara-item { font-size: 8pt; }
.sheet[data-size="12"][data-bara="many"] .bara-box { max-width: 12mm; }
.bara-item {
  display: flex; align-items: center; gap: 1.5mm;
  font-size: 12pt;
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.bara-no {
  flex: 0 0 auto;
  width: 6mm;
  font-size: 8pt;
  color: #555;
  text-align: right;
}
.bara-expr { white-space: nowrap; }
.bara-box {
  flex: 1 1 auto;
  max-width: 24mm;
  height: 7mm;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: inherit;
  border: 1px solid #555;
  border-radius: 1mm;
}

.sheet-foot {
  display: flex; align-items: flex-end; justify-content: space-between; gap: 4mm;
  padding-top: 2mm;
  border-top: 1px solid #c9c4b8;
  font-size: 8.5pt;
  color: #444;
  flex: 0 0 auto;
}
.sheet-page { font-size: 8pt; color: #666; white-space: nowrap; }

/* ===== レスポンシブ ===== */
@media (max-width: 760px), (max-width: 950px) and (max-height: 480px) and (orientation: landscape) {
  body { padding-bottom: calc(4.6rem + env(safe-area-inset-bottom, 0px)); }
  .app-header { min-height: 0; padding: .7rem 1rem; gap: .6rem; }
  .logo-container { gap: .6rem; }
  .logo-icon { width: 2.1rem; height: 2.1rem; flex: 0 0 2.1rem; font-size: 1.05rem; }
  .app-title { font-size: 1rem; line-height: 1.35; }
  .app-subtitle { font-size: .76rem; }
  .hole-badge { padding: .25rem .55rem; font-size: .72rem; }

  .main-container { padding: .85rem .75rem 1rem; gap: .9rem; }
  details.card > summary.card-title { padding: 1.05rem 1.1rem; }
  details.card > .card-body { padding: 0 1.1rem 1.15rem; }
  .card { padding: 1.15rem 1.1rem; }

  select, input[type="text"], input[type="number"] { min-height: 2.75rem; font-size: 1rem; }
  .check-row { min-height: 2.5rem; font-size: .95rem; }
  .check-row input { width: 1.25rem; height: 1.25rem; flex: 0 0 1.25rem; }
  .option-grid { gap: .15rem; }
  .tab-btn { min-height: 2.6rem; font-size: .86rem; }
  .pattern-btn { min-height: 2.7rem; font-size: .8rem; }
  .btn-small { min-height: 2.5rem; }

  .btn-row {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 50;
    flex-direction: row;
    gap: .5rem;
    padding: .55rem .75rem calc(.55rem + env(safe-area-inset-bottom, 0px));
    background: var(--color-surface);
    border-top: var(--rule-hair) solid var(--color-rule-2);
    box-shadow: 0 -2px 10px rgba(30, 20, 10, .1);
  }
  .btn-row .btn { flex: 1 1 0; min-height: 3rem; }
  .btn-row .btn:hover { transform: none; }

  .preview-container { gap: .75rem; }
  .preview-header { flex-direction: column; align-items: flex-start; gap: .35rem; }
  .preview-tools { width: 100%; justify-content: space-between; }
  .a4-wrapper { justify-content: flex-start; }
}
@media (max-width: 420px) {
  .app-subtitle { display: none; }
  .app-title { font-size: .95rem; }
  .header-status { margin-left: auto; }
  .hole-badge .hole-total { display: none; }
  .pattern-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* ===== 印刷 ===== */
#print-batch { display: none; }

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

@media print {
  html, body {
    background: #fff !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  .app-header,
  .control-panel,
  .preview-header,
  .app-alert,
  .preview-container,
  .main-container {
    display: none !important;
  }
  #print-batch { display: block !important; }
  #print-batch .sheet {
    width: 210mm !important;
    height: 296mm !important;
    margin: 0 !important;
    padding: 12mm !important;
    border: 0 !important;
    box-shadow: none !important;
    transform: none !important;
    page-break-after: always;
    break-after: page;
    page-break-inside: avoid;
    break-inside: avoid;
    overflow: hidden;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  #print-batch .sheet:last-child {
    page-break-after: auto;
    break-after: auto;
  }
  #print-batch .kuku-cell,
  #print-batch .bara-box {
    background: #fff !important;
  }
  #print-batch .kuku-head { background: #ececec !important; }
  #print-batch .kuku-corner {
    background:
      linear-gradient(to top right, transparent calc(50% - .4pt), #555 calc(50% - .4pt), #555 calc(50% + .4pt), transparent calc(50% + .4pt)),
      #ececec !important;
  }
  #print-batch .kuku-cell.is-hole,
  #print-batch .kuku-cell.is-five {
    background: #fff !important;
  }
  #print-batch .kuku-cell.is-wrong {
    outline: none !important;
    background: #fff !important;
  }
  #print-batch button.kuku-cell { cursor: default; }
}
