@import url('https://fonts.googleapis.com/css2?family=Noto+Sans+JP:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Zen+Maru+Gothic:wght@400;700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Kosugi+Maru&display=swap');
@import url('https://fonts.googleapis.com/css2?family=BIZ+UDMincho&display=swap');
@import url('https://fonts.googleapis.com/css?family=Sawarabi+Mincho');

html { 
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
.report-area, .editable {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

* {
  box-sizing: border-box;
}

html, body, .report-wrapper {
  touch-action: auto !important;
  overscroll-behavior: auto !important;
}

body {
  font-family: 'Noto Sans JP', 'Roboto', sans-serif;
  background-color: #f9f9f9;
  height: auto;
  overflow: auto;
  line-height: 1.7;
  padding-top: 70px;
}

nav.fixed-top {
  z-index: 1030;
}

#toast-container {
  pointer-events: none;
  z-index: 1200 !important;
}

#toast-container .toast {
  pointer-events: auto;
  color: #fff;
}

#confirmDeleteModal .modal-dialog {
  margin-top: 0 !important;
}

#saveModal{
  margin-top: 0 !important;
}

#saveModal td {
  padding-top: 5px !important;
  padding-bottom: 5px !important;
  line-height: 1.2;
}

/* ===== Save status (no border) ===== */
.save-status{
  display: inline-flex;
  align-items: center;
  gap: 6px;

  font-size: 11px;
  color: #6b7280;

  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1;
  user-select: none;
  margin-left: 8px;
}

.save-status__dot{
  width: 6px;
  height: 6px;
  border-radius: 9999px;

  /* デフォルト色（未保存） */
  background: #9ca3af;
  flex: 0 0 auto;
  box-shadow: 0 0 0 2px rgba(156,163,175,0.18);
}

.save-status__text{
  display: inline-block;
  transform: translateY(-0.5px);
}

.save-status.is-saving .save-status__dot{
  box-shadow: 0 0 0 2px rgba(245,158,11,0.18);
  animation: saveStatusPulse 1.1s ease-in-out infinite;
}
@keyframes saveStatusPulse{
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.25); opacity: 0.7; }
}

.modal-backdrop,
.modal-backdrop.fade,
.modal-backdrop.show {
  z-index: 1130 !important;
}

.modal,
.modal.fade,
.modal.show {
  z-index: 1140 !important;
}


.page-A4 { width: 794px;height: 1122px;}
.page-B5 { width: 689px; height: 971px; padding: 86px 50px; }
.page-Letter { width: 816px;height: 1056px;}

/* スクロール枠（左右の余白 + スクロール） */
.report-viewport{
  width: 100%;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  padding: 10px;
  background: #f2f4f6;
  border-radius: 8px;
}
#reportViewport {
  /*touch-action: pan-x pan-y;*/
  touch-action: auto !important;
  
  /* セーフエリア込みの左右余白（iPhone/Androidの端詰まり対策） */
  padding-left:  max(10px, env(safe-area-inset-left));
  padding-right: max(10px, env(safe-area-inset-right));
}

@media (hover: none) and (pointer: coarse) {
  #reportViewport{
    touch-action: auto !important;
  }
}

.viewport-pad{
  padding: 8px;
  min-width: 0;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

.report-sizer{
  position: relative;
  width: 794px;
  height: 1122px;
  transform-origin: top center;
  will-change: transform;
}

.report-sizer.page-A4     { width: 794px; height: 1122px; }
.report-sizer.page-B5     { width: 689px; height: 971px; }
.report-sizer.page-Letter { width: 816px; height: 1056px; }

.report-stage{
  transform: none !important;
  transform-origin: top center;
  margin: 0;
  position: relative;
  top: 0;
  left: 0%;
  display: flex;
  justify-content: center;
  align-items: flex-start;
}

@media (max-width: 720px) { .report-sizer { transform: scale(0.80); } }
@media (max-width: 630px) { .report-sizer { transform: scale(0.70); } }
@media (max-width: 497px) { .report-sizer { transform: scale(0.50); } }
@media (max-width: 417px) { .report-sizer { transform: scale(0.40); } }

@media (max-width: 576px) {
  .report-area:not(.pdf-mode) { zoom: 1 !important; }
}

.report-content {
  min-height: auto;
  max-height: none;
  overflow: hidden;
  position: relative;
}

.editable {
  min-height: 20px;
  cursor: pointer;
  font-size: 11pt;
  line-height: 1.6;
  user-select: none;
  border: 1px solid transparent;
  padding: 0 10px;
  transition: background-color 0.2s, border 0.2s;
}

.editable.selected {
  border: 1px solid #3399ff;
  background-color: #f0f8ff;
  cursor: text;
  user-select: text;
  padding: 0 10px;
}

.controls-area {
  margin:25px 30px 0 0;
  width: 270px;
  flex-shrink: 0;
  overflow-y: auto;
}

.editable-project-name {
  display: inline-block;
  position: relative;
  padding: 0 20px 0 15px;
  white-space: nowrap;
}

.text-center.d-flex .editable-project-name {
  margin-left: -108px;
}

.pdf-mode .pdf-underline {
  padding-bottom: 2px !important;
}

.pdf-underline {
  text-decoration: none !important;
  border-bottom: 1px solid currentColor !important;
  display: inline !important;
  box-decoration-break: clone !important;
  -webkit-box-decoration-break: clone !important;
}

.projectName.selected {
  border: 1px solid #3399ff;
  background-color: #f0f8ff;
  cursor: text;
  user-select: text;
  padding: 5px 15px;
}

.projectName {
  border-radius: 4px;
  transition: all 0.2s ease;
  outline: none;
  font-size: 110%;
  font-weight: bold;
  border: 1px solid #ccc;
  background-color: #f9f9f9;
  color: #333;
  white-space: nowrap;
  margin-top:16px;
}

.projectName.editable{
  padding: 3px 12px!important;
}

.editable-project-name:hover .edit-icon {
  display: inline;
}

.report-controls-mobile {
  display: none;
}

#toolbar {
  position: absolute;
  z-index: 9999;
  background: #ececf0;
  border: 1px solid #d1e0ef;
  padding: 1px 10px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  min-width: 400px;
  align-items: center;
  display: none;
  visibility: hidden;
  flex-wrap: wrap; 
}

#toolbar-drag-handle {
  cursor: grab;
  padding: 8px 12px;
  font-size: 20px;
  text-align: center;
  background: none;
  border-bottom: none;
  border-radius: 6px 0 0 8px;
  user-select: none;
  color: #6c757d;
  margin-right: 10px;
  touch-action: none;
}

.toolbar button:hover {
  background-color: #007bff;
  color: white;
  border-color: #007bff;
}

.toolbar select:focus {
  outline: none;
  border-color: #007bff;
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.toolbar button{
  background: none;
  border: 1px solid #f6f7f8;
  color: #495057;
  padding: 6px 8px;
  border-radius: 4px;
  cursor: pointer;
  margin-right: 3px;
  font-size: 14px;
  transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}
.toolbar select {
    border: 1px solid #ced4da;
    color: #495057;
    padding: 6px;
    border-radius: 4px;
    margin-right: 5px;
    font-size: 14px;
    min-width: 70px;
    max-width: 180px;
}

#underlineBtn:disabled {
  background-color: #ececf0 !important;
  border-color: #ececf0 !important;
  color: #fff !important;
  opacity: 1 !important;
  cursor: not-allowed !important;
}

#fontFamilySelect {
  min-width: 200px;
  max-width: 300px;
}

.toolbar button.active {
  background-color: #888;
  color: #fff;
}

font[size="0"] { font-size: 10px; }
font[size="1"] { font-size: 11px; }
font[size="2"] { font-size: 12px; }
font[size="3"] { font-size: 13px; }
font[size="4"] { font-size: 14px; }
font[size="5"] { font-size: 15px; }
font[size="6"] { font-size: 16px; }
font[size="7"] { font-size: 18px; }
font[size="8"] { font-size: 20px; }
font[size="9"] { font-size: 22px; }
font[size="10"] { font-size: 24px; }
font[size="11"] { font-size: 28px; }
font[size="12"] { font-size: 32px; }

.editable div,
.editable p {
  margin: 0;
  padding: 0;
}

.dimmed-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.35);
  z-index: 1040;
}

.big-checkbox {
  width: 1.3em;
  height: 1.3em;
  margin-left: 10px;
  margin-right: 8px;
  vertical-align: middle;
}

.label-mobile{
  display: none;
}

.text-mobile{
  display: none;
}

.btn-mobile{
  display: none;
}

.btnTop{
  width: 120px;
}

.btnTop #menuBtn{
  width: 108px;
}

.col-project   { width: 35%; }
.col-date      { width: 20%; }
.col-template  { width: 10%; }
.col-actions   { width: 35%; }

.th-opt{
  text-align: center;
}

.modalBtn{
  width: 70px;
  margin-bottom: 2px;
}

.header-list{
  margin: 0 0 0 20px;
}

.report-wrapper {
  background-color: #f4f4f4;
  text-align: left;
}

.report-area {
  display: inline-block;
  margin: 0 auto 100px;
  text-align: left;
} 

#saveModal .modal-dialog {
  max-width: 90vw;
}

#downloadBtn{
  font-weight: 600;
}

#previewBtn{
  opacity: 0.8;
}

@media screen and (max-width: 995px) {

  .report-wrapper {
    overflow-x: auto;
    width: 100%;
    text-align: left;
  }

  .report-area:not(.pdf-mode){
    display: inline-block;
    width: 794px;
    min-width: 794px;
    margin: 0 auto;
    text-align: left;
  }

  body.pdf-mode .report-area{
    zoom: 1 !important;
    transform: none !important;
  }  
}

@media (max-width: 995px){
  .report-area:not(.pdf-mode){
    transform: none;
  }
    .report-area.pdf-mode{
    transform: none !important;
    zoom: 1 !important;
    width: 794px !important;
    min-width: 794px !important;
  }
}

@media (max-width: 992px) {

  .report-wrapper {
    text-align: center;
  }

  .report-area:not(.pdf-mode) {
    text-align: left;
  }
}

@media (max-width: 768px) {

  .fixed-top{
    padding-left:15px;
  }

  .text-desktop{
    display: none;
  }

  .text-mobile{
    display: inline;
  }

  .px-3{
    padding-left:0!important;
    padding-right:0!important;
  }

  .gap-3{
    gap:7px!important;
  }

  .gap-2{
    gap:5px!important;
  }

  .projectNameWrapper{
    padding-left:2px!important;
  }

  .projectName{
    font-size: 90%;
  }

  .editable-project-name {
    padding: 0 10px;
  }

  .col-template,
  .th-tpl {
    display: none;
  }
}

@media (max-width: 740px) {

  #downloadBtn{
    display: none;
  }

  .col-project   { width: 50%; }
  .col-date      { width: 35%; }
  .col-actions   { width: 15%; }

  .fixed-top {
      padding-left: 5px;
  }

  .nav-actions{
    border:0!important;
    padding-right: 10px!important;
    padding-bottom:10px!important;
  }

  .projectNameWrapper {
      padding-left: 0px !important;
      /*padding-bottom: 13px!important;*/
  }

  .save-status__text{
    line-height: 1.3;
  }

}

@media (max-width: 600px) {
  .btnTop{
    width: 100px;
    font-size: 80%;
  }

  .label-desktop{
    display: none;
  }

  .label-mobile{
    display: inline;
  }

  .icon-desktop{
    display: none;
  }

  #previewBtn{
    display: none;
  }

  .button-wrapper {
    justify-content: flex-start !important;
    padding-left: 12px !important;
  }  
}

@media (max-width: 497px) {
  .toolbar{
    transform: scale(0.8);
    transform-origin: top left;
  }  
}

@media screen and (max-width: 431px) {
  .toolbar{
    transform: scale(0.6);
    transform-origin: top left;
  }
  .projectNameWrapper {
    padding-left: 0px !important;
    padding-top: 8px!important;
  }

  .nav-actions{
    padding-bottom: 0!important;
  }

  .save-status{
    display:inline-block!important;
  }

  .gap-2{
    gap:3px!important;
  }
}

@media screen and (max-width: 381px) {
  #helpBtn{
    display: none!important;
  }
  .gap-3{
    gap:3px!important;
  }

}

.projectNameWrapper .editable-project-name{
  display: flex !important;
  flex-direction: column !important;
  align-items: flex-start !important;
  white-space: normal !important;
}

.projectNameWrapper .save-status{
  margin-left: 5px !important;
  margin-top: 5px;
}

.projectNameWrapper #projectName{
  max-width: 44vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-actions{
  display: flex;
  align-items: center;
  gap: 10px;
  padding-left: 14px;
  padding-right:18px;
  border-left: 1px solid #a6b2cb;
}

.projectNameWrapper{
  min-width: 0;
  padding: 6px 12px;
  border-radius: 6px;
  background: #f9fafb;
}

@media (hover: none) and (pointer: coarse) {
  .pdf-mode .report-area {
    transform: scale(var(--pdfPreviewScale, 1)) !important;
    transform-origin: top center !important;
  }
}

/* ===== ヘルプメニュー（最小構成） ===== */
.help-menu{
  position:absolute;
  top: calc(100% + 8px);
  right: 0;
  width: min(420px, 92vw);
  background:#fff;
  border: 1px solid rgba(0,0,0,.12);
  border-radius: 12px;
  z-index: 1200;
}

.help-menu-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(0,0,0,.08);
}

.help-menu-title{
  font-weight:700;
  font-size: 14px;
  color:#111827;
}

.help-menu-close{
  border:0;
  background:transparent;
  padding: 6px 8px;
  border-radius: 8px;
  cursor:pointer;
}
.help-menu-close:hover{ background: rgba(0,0,0,.05); }
.help-menu-body{ padding: 10px 12px 12px; }
.help-mini-title{ font-weight:700; color:#111827; font-size: 13px; margin: 2px 0 6px; }
.help-mini-ol{ margin:0 0 0 18px; padding:0; font-size: 13px; color:#374151; }
.help-mini-ol li{ margin: 4px 0; }
.help-mini-faq{ margin-top: 6px; display:flex; flex-direction:column; gap: 6px; }
.help-mini-q{ font-weight:700; color:#111827; font-size: 13px; }
.help-mini-a{ color:#374151; font-size: 13px; line-height: 1.55; }

.help-mini-links{
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,.08);
  display:flex;
  justify-content:flex-end;
  gap: 12px;
}
.help-mini-link{
  font-size: 12px;
  color:#2563eb;
  font-weight:700;
  text-decoration:none;
}
.help-mini-link:hover{ text-decoration: underline; }

.bg-warning-soft {
  background-color: #fff7ed;
  border: 1px solid #fed7aa;
}