.page {
  flex: 1;
  max-width: var(--w-base);
  width: 100%;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ---------- Tool card ---------- */
.tool {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

/* ---------- Input blocks ---------- */
.block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
}
.block-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.block-label .count {
  font-size: 12px;
  color: var(--muted);
}

.hint {
  font-size: 12.5px;
  color: var(--muted);
  line-height: 1.6;
  margin: 12px 0 0;
}
.hint.is-hidden { display: none; }

/* ---------- 行・列 ---------- */
.size-row {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px 12px;
}
.size-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.size-label {
  font-size: 12px;
  color: var(--muted);
}
.size-sep {
  font-size: 16px;
  color: var(--muted);
  padding-bottom: 8px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}
.stepper button {
  appearance: none;
  border: none;
  background: transparent;
  width: 36px;
  height: 36px;
  font-family: "JetBrains Mono", monospace;
  font-size: 18px;
  color: var(--sub);
  cursor: pointer;
  transition: background 140ms ease;
  display: grid;
  place-items: center;
  line-height: 1;
}
.stepper button:hover:not(:disabled) { background: var(--bg); }
.stepper button:disabled { color: var(--muted); cursor: not-allowed; }
.stepper input {
  width: 40px;
  border: none;
  outline: none;
  text-align: center;
  background: transparent;
  font-family: "JetBrains Mono", monospace;
  font-weight: 600;
  font-size: 15px;
  color: var(--ink);
  -moz-appearance: textfield;
}
.stepper input:disabled { color: var(--muted); }
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.link-btn {
  appearance: none;
  border: none;
  background: none;
  padding: 0 0 8px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 12.5px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.link-btn:hover:not(:disabled) { color: var(--accent-deep); }
.link-btn:disabled { color: var(--muted); cursor: not-allowed; }

.front-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 14px;
}
.text-input {
  width: 100%;
  max-width: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 9px 12px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
}
.text-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.text-input::placeholder { color: var(--muted); }

/* ---------- 座席表 ---------- */
.board-wrap { margin-bottom: 10px; }
.result-hint {
  display: none;
  margin: 0 0 10px;
}
.result-hint.visible { display: block; }

/* マスは画面の幅に合わせて縮む。最小の幅でも収まらないときだけ、座席表を横にスクロールさせる */
.board-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.board {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: min-content;
  padding: 2px;
}
.board.is-flipped { flex-direction: column-reverse; }

.board-front {
  text-align: center;
  font-size: 12px;
  font-weight: 500;
  color: var(--sub);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 12px;
}

.seat-grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 6), minmax(52px, 88px));
  justify-content: center;
  gap: 6px;
  user-select: none;
  -webkit-user-select: none;
}

.seat-cell {
  appearance: none;
  min-height: 48px;
  padding: 4px;
  border-radius: 8px;
  font-family: "Noto Sans JP", sans-serif;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease;
}
.seat-cell.is-seat {
  background: var(--surface);
  border: 1px solid #cbd5e1;
  box-shadow: 0 1px 0 #cbd5e1;
}
.seat-cell.is-aisle {
  background: transparent;
  border: 1px dashed var(--border);
}
.board:not(.is-result) .seat-cell.is-seat:hover { border-color: var(--accent); }
.board:not(.is-result) .seat-cell.is-aisle:hover { border-color: var(--muted); }
.board.is-result .seat-cell.is-aisle { cursor: default; }

.seat-name {
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.3;
  color: var(--ink);
  text-align: center;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.board.is-result .seat-cell.is-seat {
  background: var(--accent-soft);
  border-color: var(--accent);
  box-shadow: none;
}
.board.is-result .seat-cell.is-empty {
  background: var(--surface);
  border: 1px dashed var(--accent);
}
.board.is-result .seat-cell.is-empty .seat-name::before {
  content: "空席";
  color: var(--muted);
  font-size: 11px;
}
.board.is-result .seat-cell.is-selected {
  background: var(--accent);
  border-color: var(--accent);
}
.board.is-result .seat-cell.is-selected .seat-name { color: #fff; }
.board.is-result .seat-cell.is-selected.is-empty .seat-name::before { color: #fff; }

/* 演出中は、空席になる席も含めてすべて同じ見た目にする（どこが空くかを先に見せない） */
.seat-grid.is-spinning .seat-cell.is-seat {
  background: var(--bg);
  border: 1px solid var(--border);
}
.seat-grid.is-spinning .seat-cell.is-empty .seat-name::before { content: none; }
.seat-grid.is-spinning .seat-name { color: var(--muted); }

.seat-grid.is-revealed .seat-cell.is-seat {
  animation: seatPop 360ms cubic-bezier(.2,.8,.3,1.35);
}
@keyframes seatPop {
  0%   { transform: scale(0.85); }
  65%  { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* ---------- Textarea ---------- */
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: "Noto Sans JP", sans-serif;
  font-size: 14px;
  background: var(--surface);
  color: var(--ink);
  resize: vertical;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease;
  line-height: 1.7;
}
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
textarea::placeholder { color: var(--muted); }

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  font-size: 13.5px;
  color: var(--sub);
  cursor: pointer;
  line-height: 1.5;
}
.check-row input {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.check-hint {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
}

/* ---------- Draw button ---------- */
.draw-btn {
  appearance: none;
  width: 100%;
  border: none;
  background: var(--accent);
  color: white;
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.04em;
  padding: 14px 20px;
  border-radius: var(--radius);
  cursor: pointer;
  margin-top: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 140ms ease, transform 140ms ease;
}
.draw-btn:hover:not(:disabled) {
  background: var(--accent-deep);
  transform: translateY(-1px);
}
.draw-btn:active:not(:disabled) { transform: translateY(0); }
.draw-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* ---------- Save button ---------- */
.save-btn {
  appearance: none;
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--sub);
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 500;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  margin-top: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 140ms ease;
}
.save-btn:hover { background: var(--bg); }

/* ---------- Error ---------- */
.error-msg {
  margin-top: 10px;
  padding: 10px 14px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 500;
  background: var(--danger-soft);
  border-radius: var(--radius);
  display: none;
}
.error-msg.visible { display: block; }

/* ---------- 決まったあとの操作 ---------- */
.result-actions {
  display: none;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.result-actions.visible { display: flex; }
.sub-btn {
  appearance: none;
  flex: 1 1 auto;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--sub);
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 500;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 140ms ease;
}
.sub-btn:hover { background: var(--bg); }

.tool-foot {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 4px 16px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}
.tool-foot .check-row { margin-top: 0; }
/* 名簿の保存データまで消すボタン。取り消せない操作なので文字を赤にする */
.reset-btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--danger);
  font-family: "Noto Sans JP", sans-serif;
  font-weight: 500;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease;
}
/* 狭い画面では「、」のところで折り返す */
.reset-btn .nowrap { white-space: nowrap; }
.reset-btn:hover {
  background: var(--danger-soft);
  border-color: var(--danger-soft);
}

@media (max-width: 900px) {
  .tool { padding: 20px 16px; }
  .seat-grid {
    grid-template-columns: repeat(var(--cols, 6), minmax(44px, 72px));
    gap: 4px;
  }
  .seat-cell { min-height: 44px; padding: 3px; }
  .seat-name { font-size: 11.5px; }
}

/* ---------- 印刷 ---------- */
/* 座席表だけを印刷する。サイドバー・広告・説明・ボタンはすべて外す */
@media print {
  .sidebar, .mob-header, .mob-switch-menu, .mob-overlay,
  .ad-slot, .accordion, .related-columns, .toast,
  .howto-link, .page-desc, .no-print {
    display: none !important;
  }
  .app { margin-left: 0 !important; padding-top: 0 !important; }
  body { background: #fff !important; }
  .content { padding: 0 !important; }
  .page { max-width: none; }
  .tool { border: none; padding: 0; }
  .board-scroll { overflow: visible; }
  .board { width: 100%; }
  .seat-grid { grid-template-columns: repeat(var(--cols, 6), minmax(0, 1fr)); }
  .seat-cell { min-height: 56px; }
  .seat-name { font-size: 13px; }
  .board.is-result .seat-cell.is-seat,
  .board.is-result .seat-cell.is-selected {
    background: #fff;
    border: 1px solid #111;
  }
  .board.is-result .seat-cell.is-selected .seat-name { color: var(--ink); }
  .board-front { border-color: #111; }
}
