/* hoiku-haichi tool styles (loaded after base.css). No inline styles (CSP). */

.h1-sub { display: block; font-size: 1rem; font-weight: 600; color: var(--text-muted); margin-top: var(--space-1); }

#tool-form > fieldset, #tool-form > details, #tool-form > .field, #mode-day > fieldset, #mode-slots > fieldset, #mode-slots > details { margin-bottom: var(--space-3); }
.verified { font-size: 0.875rem; color: var(--text-muted); margin: 0 0 var(--space-2); }
.verified .badge { border-color: var(--ok); color: var(--ok); }
.label-sub { font-weight: 400; font-size: 0.85em; }
.ratio-line { font-size: 0.95rem; }
.quick-result { font-weight: 700; color: var(--accent); margin: 0; min-height: 1.5em; }
.save-line { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; }
.btn-link { font: inherit; background: none; border: 0; padding: 0.5rem 0; min-height: 2.75rem; color: var(--accent); text-decoration: underline; cursor: pointer; }
.print-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(12rem, 1fr)); gap: var(--space-2); margin-bottom: var(--space-2); }
.band-row { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: center; margin-bottom: var(--space-2); }
.example-label { display: inline-block; font-size: 0.875rem; font-weight: 600; background: var(--mark-bg); color: var(--mark-text); padding: 0 var(--space-2); border-radius: 4px; margin-bottom: var(--space-2); }
.result-plain { margin-bottom: var(--space-2); }
.notes-more summary { cursor: pointer; font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }
.hayami { min-width: 30rem; }
.hayami td.num, .hayami th.num { text-align: right; }
.choice { display: flex; align-items: center; gap: var(--space-2); font-weight: 400 !important; min-height: 2.75rem; }
.choice input { width: 1.2rem; height: 1.2rem; flex: none; }
.mode-switch .choice { font-weight: 600 !important; }

.ratio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(6.5rem, 1fr)); gap: var(--space-2); margin-bottom: var(--space-2); }
.ratio-grid input { max-width: 8rem; }
details.options { margin-top: var(--space-2); }
details.options summary, details.fill-helper summary, details.slot-details summary { cursor: pointer; font-weight: 600; min-height: 2.75rem; display: flex; align-items: center; }

.time-range { display: flex; flex-wrap: wrap; gap: var(--space-3); }
.time-range select { width: 8rem; }

.fill-helper { border: 1px solid var(--border); border-radius: var(--radius); padding: 0 var(--space-3); background: var(--bg-alt); }
.fill-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(5.5rem, 1fr)); gap: var(--space-2); }
.fill-grid input, .fill-grid select { max-width: 8rem; }
.fill-grid select { min-width: 6.5rem; padding-left: 0.4rem; padding-right: 0.4rem; }

.slot-fieldset[aria-invalid="true"] { border-color: var(--danger); border-width: 2px; }
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; max-width: 100%; position: relative; }
/* The input table scrolls inside its own box so the header row and the time column stay visible. */
.slot-input-wrap { max-height: 70vh; overflow: auto; }
/* Sticky time column (left) for the slot tables; header cells above it stay on top. */
table.slot-input th.time, .slots th.time, .slots-detail th.time { position: sticky; left: 0; background: var(--surface); z-index: 1; }
table.slot-input thead th.time { z-index: 3; }
table.slot-input { border-collapse: collapse; font-variant-numeric: tabular-nums; margin: 0; }
table.slot-input th, table.slot-input td { padding: 2px 3px; border-bottom: 1px solid var(--border); text-align: center; white-space: nowrap; }
table.slot-input thead th { font-size: 0.8rem; position: sticky; top: 0; background: var(--surface); z-index: 2; }
.th-sub { display: block; font-weight: 400; font-size: 0.7rem; }
table.slot-input input.cell {
  width: 3.4rem; min-width: 3.4rem; max-width: 3.4rem; min-height: 2.5rem;
  padding: 0.25rem 0.35rem; text-align: right;
}
table.slot-input input.cell-plan { border-color: var(--accent); }
.btn-mini { min-height: 2.5rem; padding: 0.25rem 0.6rem; font-size: 0.9rem; }
th.time { font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- Results ---------- */
.settings { display: grid; grid-template-columns: max-content 1fr; gap: 0 var(--space-2); font-size: 0.875rem; margin-bottom: var(--space-3); }
.settings dt { font-weight: 600; color: var(--text-muted); }
.settings dd { margin: 0; }
.result-table caption { text-align: left; font-weight: 700; padding: var(--space-2) 0; }
.result-table th.num, .result-table td.num { text-align: right; }
.result-table .strong { font-weight: 700; }
.result-table td.calc { font-family: var(--font-mono); font-size: 0.9rem; white-space: nowrap; }
.breakdown tr.sum th, .breakdown tr.sum td { border-top: 2px solid var(--text); }
.breakdown tr.total th, .breakdown tr.total td { background: var(--accent-soft); font-size: 1.05rem; }
.compare { max-width: 24rem; margin-top: var(--space-3); }
.compare tr.is-current th, .compare tr.is-current td { font-weight: 700; }

.plan-line { font-weight: 700; }
.plan-line.is-short { color: var(--danger); }
.plan-line.is-ok { color: var(--ok); }

.slots { min-width: 40rem; }
.slots th, .slots td { white-space: nowrap; }
.slots tr.is-peak th.time::after { content: " ▲"; color: var(--accent); font-size: 0.75rem; }
.slots tr.is-short th, .slots tr.is-short td { background: color-mix(in srgb, var(--danger) 14%, var(--surface)); }
.slots tr.is-short td.diff { color: var(--danger); font-weight: 700; }
.slots tr.is-empty td { color: var(--text-muted); }
.slots .mark { color: var(--accent); font-weight: 700; margin-left: 2px; }
.bar-cell { width: 30%; min-width: 7rem; }
svg.bar { display: block; width: 100%; height: 0.9rem; }
.bar-req { fill: var(--accent); }
.bar-plan { fill: var(--text); }
.slots tr.is-short .bar-plan { fill: var(--danger); }
.slots-detail { min-width: 28rem; }
.slot-details { margin: var(--space-3) 0; }

.result-notes { margin-top: var(--space-3); }
.note-info, .note-warn {
  border-left: 4px solid var(--accent); background: var(--accent-soft);
  padding: var(--space-2) var(--space-3); border-radius: 4px; font-size: 0.9rem;
}
.note-warn { border-left-color: var(--danger); }

.rule-table { margin-bottom: var(--space-3); }
.sources li { margin-bottom: var(--space-1); }

@media print {
  .no-print { display: none !important; }
  details[data-print="closed"] { display: none !important; }
  .slot-input-wrap { max-height: none; overflow: visible; }
  thead { display: table-header-group; }
  /* Long time-slot results may span pages; only the short day result is kept together. */
  .results.is-slots { break-inside: auto; }
  .print-header { margin-bottom: 6pt; }
  .print-title { font-size: 14pt; font-weight: 700; margin: 0 0 4pt; }
  .print-meta { display: grid; grid-template-columns: repeat(3, max-content 1fr); gap: 2pt 6pt; margin: 0; font-size: 10pt; }
  .print-meta dt { font-weight: 700; }
  .print-meta dd { margin: 0; border-bottom: 1px solid #000; min-width: 6em; }
  .print-meta dd.sign { min-height: 2.2em; }
  .bar-cell { min-width: 4rem; width: 20%; }
  .notes-more summary { display: none; }
  .table-scroll { overflow: visible; }
  .slots { min-width: 0; font-size: 9pt; }
  .slots th, .slots td { padding: 1px 4px; }
  .slots tr.is-short th, .slots tr.is-short td { background: #eee; }
  .bar-req { fill: #555; }
  .bar-plan { fill: #000; }
  .slots tr { break-inside: avoid; }
}
.crosslink { margin: var(--space-3) 0; }

/* ---------- 類型 (小規模保育・家庭的保育・事業所内) ---------- */
#facility-extra { margin-bottom: var(--space-3); }
#facility-extra > .field, #facility-extra > fieldset { margin-bottom: var(--space-2); }
#capacity { max-width: 8rem; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: var(--space-2); }
.plan-grid input { max-width: 8rem; }
#katei-rule { margin: 0 0 var(--space-3); }
.katei-options { max-width: 32rem; }
.katei-slots { min-width: 40rem; }

/* 「いまの結果」 right under 条件を入力 (same as the other tools), so phones see the answer before the long form. */
.top-summary { display: flex; flex-wrap: wrap; gap: var(--space-2); align-items: baseline; border: 1px solid var(--border); border-radius: var(--radius); padding: var(--space-2) var(--space-3); margin-bottom: var(--space-3); }
.top-summary .quick-result { flex: 1 1 14rem; }
.top-summary .quick-result::before { content: "いまの結果: "; }
.top-summary #prefill-status { flex: 1 1 100%; margin: 0; }
.kodomoen-link { display: inline-flex; align-items: center; min-height: 2.75rem; }
