/* 時数計算・週案ジェネレーター（sup/jisuu） */
:root {
  --main-blue: #4A90E2; --blue-dark: #2f6fb8; --bg-color: #F8F9FA; --card-bg: #FFFFFF;
  --text-main: #333333; --border-color: #D1E3F8;
  --weekend-color: #FF9800; --edit-color: #2fa89f; --morning-color: #FF8A65;
  --font-ui: 'M PLUS Rounded 1c', 'Gowun Dodum', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'BIZ UDPGothic', 'Meiryo', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  --font-kyokasho: 'Klee One', 'M PLUS Rounded 1c', 'Gowun Dodum', 'UD Digi Kyokasho N-R', 'Hiragino Maru Gothic ProN', 'Hiragino Sans', 'BIZ UDPGothic', 'Meiryo', 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
}
*, *::before, *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: var(--font-ui); background: var(--bg-color); color: var(--text-main);
  padding: calc(72px + env(safe-area-inset-top, 0px)) 16px calc(30px + env(safe-area-inset-bottom, 0px));
  font-size: 16px; position: relative;
}

/* UI要塞化（スクロールする ページなので 高さも 0 に） */
.hidden {
  opacity: 0 !important; pointer-events: none !important; visibility: hidden !important;
  z-index: -1 !important; position: absolute !important; max-height: 0 !important; max-width: 0 !important; overflow: hidden !important;
}

.lang-slot { position: absolute; top: calc(10px + env(safe-area-inset-top, 0px)); right: calc(10px + env(safe-area-inset-right, 0px)); z-index: 100; }

.container { max-width: 1100px; margin: 0 auto; background: var(--card-bg); padding: 26px; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.05); position: relative; }
.header-area { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px dashed var(--main-blue); padding-bottom: 10px; margin-bottom: 10px; flex-wrap: wrap; gap: 10px; }
h1 { color: var(--main-blue); margin: 0; font-size: 1.5em; }
.privacy { font-size: 0.85rem; color: #666; margin: 0 0 16px; }
.hint { font-size: 0.88rem; color: #666; margin: 4px 0 10px; }
.red { color: #d32f2f; } .blue { color: var(--main-blue); }

.data-controls { display: flex; gap: 10px; background: #FFF3E0; padding: 8px; border-radius: 10px; border: 2px dashed #FFB74D; }
.btn-sys { font-family: inherit; font-weight: 700; min-height: 44px; padding: 8px 16px; border-radius: 8px; cursor: pointer; border: none; font-size: 1em; }
.btn-sys:active { transform: translateY(3px); box-shadow: none !important; }
.btn-sys:focus-visible { outline: 3px solid var(--blue-dark); outline-offset: 2px; }
.btn-save-data { background: #FF9800; color: #fff; box-shadow: 0 3px 0 #d07a00; }
.btn-load-data { background: #8D6E63; color: #fff; box-shadow: 0 3px 0 #6D4C41; }
.btn-sort { background: #8e44ad; color: #fff; box-shadow: 0 3px 0 #6c3483; font-size: 0.95em; }
.btn-plain { background: #e0e0e0; color: #333; }
.btn-orange { background: #FF9800; color: #fff; }
.btn-blue { background: var(--main-blue); color: #fff; }
.btn-teal { background: var(--edit-color); color: #fff; }
.btn-cyan { background: #0097a7; color: #fff; }
.btn-excel { background: #fff; color: #1e7b45; border: 2px solid #1e7b45; }
.btn-excel-main { background: #1e7b45; color: #fff; box-shadow: 0 3px 0 #145a32; }

.btn-print-main { display: block; width: 100%; max-width: 520px; margin: 0 auto 26px; background: #48C774; color: #fff; box-shadow: 0 5px 0 #3EA662; font-size: 1.2em; font-weight: 700; min-height: 56px; padding: 12px 20px; border-radius: 30px; border: none; cursor: pointer; font-family: inherit; }
.btn-print-main:active { box-shadow: none; transform: translateY(5px); }
.btn-list { background: #00a5bb; box-shadow: 0 5px 0 #007f90; margin-top: 20px; }

.step-section { background: #EBF3FC; padding: 18px; border-radius: 12px; border: 1px solid var(--border-color); margin-bottom: 22px; }
.step-title { font-weight: 700; font-size: 1.15em; color: var(--main-blue); margin: 0 0 6px; border-left: 5px solid var(--main-blue); padding-left: 10px; }
.step3-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 10px; }
input[type="date"], input[type="text"], input[type="number"], select { font-family: inherit; min-height: 44px; padding: 6px 8px; border: 2px solid #ccc; border-radius: 6px; outline: none; font-size: 1em; background: #fff; color: var(--text-main); }
input:focus, select:focus { border-color: var(--main-blue); }
input[type="number"] { width: 72px; }
.full { width: 100%; }
.input-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; flex-wrap: wrap; }
.input-row > label:first-child { min-width: 9em; font-weight: 700; }
.split-mode label { min-width: 0 !important; display: inline-flex; align-items: center; gap: 4px; }
.rest-row { background: #FFF3CD; padding: 8px; border-radius: 6px; }

.layout-grid { display: flex; gap: 18px; align-items: flex-start; }
.tt-wrap { flex: 1 1 auto; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.tt, .report-table { width: 100%; border-collapse: collapse; background: #fff; table-layout: fixed; margin-bottom: 14px; }
.tt th, .tt td { border: 1px solid var(--border-color); text-align: center; vertical-align: middle; padding: 4px; height: 54px; }
.tt th { background-color: var(--main-blue); color: #fff; }
.tt th.ph { width: 52px; background: #D1E3F8; color: #333; }
.tt tr.morning-row th.ph { background: var(--morning-color); color: #fff; }
.tt td { cursor: pointer; }
.tt td:hover { background-color: #f0f8ff; }
.tt tr.morning-row td { background-color: #FFF9C4; }
.week-table { min-width: 640px; }

.palette { width: 230px; flex: 0 0 230px; background: #fff; padding: 12px; border-radius: 8px; border: 2px solid var(--border-color); position: sticky; top: 10px; }
.palette-head { font-weight: 700; text-align: center; color: var(--main-blue); }
.palette-title { font-weight: 700; font-size: 0.9em; color: #666; margin: 10px 0 5px; border-bottom: 1px solid #eee; }
.palette-btns { display: flex; flex-wrap: wrap; justify-content: space-between; }
.subj-btn { width: 48.5%; min-height: 44px; padding: 6px 4px; margin-bottom: 5px; background: #fff; border: 2px solid #ccc; border-radius: 6px; cursor: pointer; font-weight: 700; font-size: 0.9em; font-family: inherit; color: #333; }
.subj-btn.active { border-color: var(--weekend-color); background: #FFF3E0; color: #b34700; }
.erase-btn { width: 100%; border-color: #ff5252; color: #d32f2f; margin-top: 12px; }

.tag { background: #EBF3FC; border: 2px solid var(--main-blue); border-radius: 6px; padding: 3px 4px; font-weight: 700; display: inline-block; font-size: 0.9em; line-height: 1.2; word-break: break-all; }
.tag.edited { border-color: var(--edit-color); background: #E0F2F1; color: #00695C; }
.tag.morning { border-color: var(--morning-color); background: #FBE9E7; color: #BF360C; }
.tag.event-tag { border-color: #9E9E9E; background: #E0E0E0; color: #424242; }
.tag.holiday { color: #c62828; background: #ffebee; border-color: #ef9a9a; }
.tag.subhol { color: #b34700; background: #fff3e0; border-color: #ffcc80; }
.tag.split-now { background: #FFF9C4; border-color: #FBC02D; }
.tag.small { font-size: 0.78em; padding: 2px; }
.split-cell { display: flex; flex-direction: column; gap: 2px; align-items: center; }

.excel-box { background: #eef8f1; border: 2px dashed #1e7b45; border-radius: 10px; padding: 12px 14px; margin-bottom: 14px; }
.excel-title { margin: 0; font-weight: 700; color: #1e7b45; }
.excel-btns { display: flex; flex-wrap: wrap; gap: 10px; }

.event-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 14px; }
.event-card { background: #fff; border: 2px solid #ccc; border-radius: 8px; padding: 14px 48px 14px 14px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; position: relative; border-left: 6px solid var(--weekend-color); scroll-margin-top: 100px; transition: background-color .5s; }
.event-card.flash { background: #FFF9C4; }
.event-card.is-weekend { border-left-color: #8e44ad; }
.card-del { position: absolute; right: 6px; top: 6px; width: 44px; height: 44px; background: none; border: none; color: #e53935; font-weight: 700; font-size: 1.1rem; cursor: pointer; }
.period-note { flex-basis: 100%; font-size: 0.85em; color: #c62828; font-weight: 700; margin: 2px 0 -4px; }
.event-card.is-weekend .period-note { color: #6c3483; }
.chk-group { display: flex; gap: 4px 6px; flex-wrap: wrap; background: #f0f0f0; padding: 4px 8px; border-radius: 6px; border: 1px solid #ddd; align-items: center; }
.chk-label { display: inline-flex; align-items: center; gap: 3px; cursor: pointer; min-height: 40px; padding: 0 2px; }
.chk-label input[type="checkbox"] { width: 22px; height: 22px; }
.chk-group .ev-duration { min-height: 36px; padding: 2px 4px; }
.sep { color: #bbb; }
.reason-group { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.ev-reason { max-width: 200px; }
.ev-reason-other { width: 170px; }
.substitute-area { color: #b34700; font-weight: 700; }
.btn-add { display: block; width: 100%; min-height: 52px; background: #fff; color: var(--main-blue); border: 2px dashed var(--main-blue); padding: 10px; font-weight: 700; border-radius: 8px; cursor: pointer; font-family: inherit; font-size: 1em; }

.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.btn-week-nav { background: #fff; color: var(--main-blue); border: 2px solid var(--main-blue); min-height: 44px; padding: 6px 12px; border-radius: 6px; font-weight: 700; cursor: pointer; font-family: inherit; }

.accordion-container { margin-bottom: 22px; border: 2px solid var(--border-color); border-radius: 12px; overflow: hidden; background: #fff; }
.report-acc { margin-top: 26px; }
.accordion-header { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 56px; padding: 12px 18px; background: #fff; border: none; cursor: pointer; font-family: inherit; font-size: 1.05em; font-weight: 700; color: var(--main-blue); text-align: left; }
.header-icon { transition: transform 0.3s ease; }
.accordion-header.is-open .header-icon { transform: rotate(180deg); }
.accordion-content { display: grid; grid-template-rows: 0fr; transition: grid-template-rows 0.3s ease-out; }
.accordion-content.is-open { grid-template-rows: 1fr; border-top: 2px dashed var(--border-color); }
.accordion-inner { overflow: hidden; padding: 0 18px; }
.accordion-inner > div { margin: 18px 0; }
.accordion-content:not(.is-open) .accordion-inner { visibility: hidden; }

.klee-font { font-family: var(--font-kyokasho); font-size: 1.05em; }
.report-h { color: var(--main-blue); text-align: center; border-bottom: 2px solid var(--main-blue); padding-bottom: 10px; margin-top: 0; }
.report-table { min-width: 860px; }
.report-table th, .report-table td { padding: 7px 3px; border: 1px solid #ccc; text-align: center; }
.report-table th { background: #EBF3FC; color: var(--main-blue); font-weight: 700; }
.deficit { color: #c62828; font-weight: 700; } .surplus { color: #2e7d32; font-weight: 700; }

.event-print-table { width: 100%; border-collapse: collapse; margin-bottom: 18px; font-size: 0.95em; table-layout: fixed; word-wrap: break-word; }
.event-print-table th, .event-print-table td { border: 1px solid #ccc; padding: 6px; text-align: center; vertical-align: middle; }
.event-print-table th { background-color: #EBF3FC; color: var(--main-blue); font-weight: 700; }
.event-print-table td.left { text-align: left; }
.event-print-table .btn-sys { min-height: 40px; padding: 4px 10px; font-size: 0.85em; }
.total-row { font-weight: 700; background: #f9f9f9; }

/* 小窓 */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.55); display: flex; justify-content: center; align-items: center; z-index: 8000; padding: calc(70px + env(safe-area-inset-top, 0px)) 14px 14px; }
.modal-content { background: #fff; padding: 22px; border-radius: 14px; width: 100%; max-width: 470px; box-shadow: 0 5px 20px rgba(0,0,0,0.2); max-height: 100%; display: flex; flex-direction: column; }
.modal-wide { max-width: 820px; }
.modal-scroll { overflow-y: auto; flex: 1; margin-bottom: 12px; padding-right: 8px; -webkit-overflow-scrolling: touch; }
.modal-header { font-weight: 700; color: var(--main-blue); margin-bottom: 14px; font-size: 1.15em; border-bottom: 2px solid var(--border-color); padding-bottom: 6px; }
.btn-group { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; flex-wrap: wrap; }

/* 取りこみの確認（DejiDialog の中） */
.imp-summary { font-weight: 700; margin: 0 0 8px; }
.imp-ok { color: #2e7d32; } .imp-ng { color: #c62828; }
.imp-scroll { max-height: 46vh; overflow: auto; border: 1px solid #ddd; border-radius: 8px; -webkit-overflow-scrolling: touch; }
.imp-table { border-collapse: collapse; width: 100%; font-size: 0.9rem; min-width: 640px; }
.imp-table th, .imp-table td { border: 1px solid #e0e0e0; padding: 5px 6px; text-align: left; vertical-align: top; }
.imp-table th { background: #EBF3FC; position: sticky; top: 0; }
.imp-note { color: #b34700; font-size: 0.85em; }
.imp-errors { margin: 10px 0 0; padding: 10px 12px 10px 28px; background: #ffebee; border-radius: 8px; color: #b71c1c; font-size: 0.92rem; }
.imp-replace-note { font-size: 0.85rem; color: #666; margin: 10px 0 0; }

@media (max-width: 900px) {
  .layout-grid { flex-direction: column; }
  .palette { width: 100%; flex: 0 0 auto; position: static; }
  .subj-btn { width: 32%; }
}
@media (max-width: 700px) {
  body { padding-top: calc(120px + env(safe-area-inset-top, 0px)); padding-left: 6px; padding-right: 6px; }
  .lang-slot { top: calc(66px + env(safe-area-inset-top, 0px)); }
  .container { padding: 14px 10px; }
  .input-row > label:first-child { min-width: 0; width: 100%; }
}

@media screen { .print-only { display: none !important; } }
@media print {
  @page { size: A4 portrait; margin: 0; }
  body { background: #fff; color: #000; padding: 0; margin: 0; font-size: 11pt; }
  #screen-container, .modal-overlay, .no-print, .lang-slot, .dd-overlay, .dd-toast-wrap { display: none !important; }
  body[data-print-mode="main"] #print-main-container { display: block !important; padding: 15mm; }
  body[data-print-mode="main"] #print-event-container { display: none !important; }
  body[data-print-mode="event"] #print-main-container { display: none !important; }
  body[data-print-mode="event"] #print-event-container { display: block !important; padding: 15mm; }
  table { width: 100% !important; min-width: 0 !important; border-collapse: collapse; table-layout: fixed; margin-bottom: 18px; }
  th, td { border: 1px solid #333 !important; padding: 4px !important; text-align: center; color: #333 !important; font-size: 12px !important; vertical-align: middle; overflow-wrap: anywhere; }
  th { background: #eee !important; font-weight: 700; }
  .tag { border: none; background: none !important; color: #333 !important; font-weight: 700; font-size: 1em; padding: 0; display: block; }
  .week-table th, .week-table td { height: 58px !important; }
  tr { page-break-inside: avoid; }
  .page-break { break-before: page; }
  .print-h { text-align: center; margin: 0 0 12px; }
  .print-note { font-size: 0.85em; text-align: right; }
}
