/* KY をエクセルの形のプレビューの上で直す (2026-11-05、課題 Orca-Setup-h41)。部品は frontend/js/ky-sheet.js */
/* KY 詳細の欄は幅が狭い (約 700px) ので、エクセルの形の箱だけ画面の幅いっぱい (最大 1400px) に広げる。
   親の欄はまん中寄せなので、親の 50% から箱の半分を引くと、画面のまん中にそろう */
.kys-panel { margin: 12px 0; width: min(1400px, calc(100vw - 24px)); margin-left: calc(50% - min(700px, 50vw - 12px)); box-sizing: border-box; }
.kys-panel[hidden], .kys-body[hidden] { display: none !important; }
.kys-seg { display: inline-flex; border: 1px solid #0D7377; border-radius: 8px; overflow: hidden; margin-bottom: 8px; }
.kys-seg button { border: 0; background: #fff; color: #0D7377; padding: 9px 14px; font-size: 14px; font-weight: 600; cursor: pointer; min-height: 40px; }
.kys-seg button.on { background: #0D7377; color: #fff; }
.kys-role { font-size: 13px; color: #44515a; margin: 2px 0 6px; line-height: 1.5; }
.kys-note { font-size: 13px; color: #7a5a00; background: #fff8e1; border-radius: 6px; padding: 6px 10px; margin: 4px 0 8px; }
.kys-tools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 4px 0 8px; }
.kys-legend { font-size: 13px; color: #44515a; display: flex; gap: 12px; flex-wrap: wrap; }
.kys-legend i { display: inline-block; width: 14px; height: 14px; vertical-align: -2px; margin-right: 4px; border-radius: 2px; }
.kys-legend .lg-edit { background: rgba(20,145,155,.18); box-shadow: inset 0 0 0 1.5px rgba(13,115,119,.6); }
.kys-legend .lg-auto { background: repeating-linear-gradient(135deg, rgba(120,120,120,.25) 0 3px, transparent 3px 6px); border: 1px solid #bbb; }
.kys-legend .lg-chg { background: #E8A317; border-radius: 50%; }
.kys-zoom { display: inline-flex; gap: 4px; margin-left: auto; align-items: center; }
.kys-zoom button { border: 1px solid #b7c2c8; background: #fff; border-radius: 6px; min-width: 44px; height: 40px; font-size: 18px; cursor: pointer; }
.kys-zoom .kys-zfit { font-size: 13px; padding: 0 8px; }
.kys-zl { font-size: 13px; color: #555; min-width: 44px; text-align: center; }

.kys-wrap { background: #e9edf0; border: 1px solid #c9d1d6; border-radius: 8px; overflow: auto; position: relative; -webkit-overflow-scrolling: touch; touch-action: pan-x pan-y pinch-zoom; max-height: 80vh; }
.kys-pad { padding: 6px; display: inline-block; }
.kys-box { position: relative; overflow: hidden; }
.kys-bg { position: absolute; }
.kys-img { position: absolute; background: #f4f6f7; display: flex; align-items: center; justify-content: center; font-size: 14px; color: #6b7a82; }
.kys-img img { width: 100%; height: 100%; display: block; }
.kys-right { border: 1px solid #0D7377; background: #fff; color: #0D7377; border-radius: 6px; min-height: 40px; padding: 0 12px; font-size: 13px; font-weight: 600; cursor: pointer; }
.kys-right[aria-pressed="true"] { background: #e3f4f4; }
.kys-root { position: relative; background: #fff; color: #000; transform-origin: 0 0; box-shadow: 0 1px 4px rgba(0,0,0,.18); }
.kys-lines { position: absolute; left: 0; top: 0; pointer-events: none; overflow: visible; }
.kys-hit { position: absolute; background: transparent; border: 0; padding: 0; margin: 0; cursor: pointer; z-index: 3; outline: none; }
.kys-wrap.show-hints .kys-hit:not(.kys-locked) { background: rgba(20,145,155,.10); box-shadow: inset 0 0 0 1.5px rgba(13,115,119,.55); }
.kys-wrap.show-hints .kys-hit.kys-locked { background: repeating-linear-gradient(135deg, rgba(120,120,120,.10) 0 4px, rgba(120,120,120,.02) 4px 8px); }
.kys-hit:hover:not(.kys-locked), .kys-hit:focus-visible { background: rgba(20,145,155,.18); }
.kys-hit.is-active { box-shadow: inset 0 0 0 3px #0D7377 !important; background: rgba(20,145,155,.16) !important; }
.kys-hit.is-changed::after { content: ''; position: absolute; right: 2px; top: 2px; width: 8px; height: 8px; border-radius: 50%; background: #E8A317; }

/* 直した跡: 消した文字は赤の二重線 (エクセルは一本線)、足した文字は赤の下線。様式の元からの赤い文字 (様式A の作業場所など)
   と見分けるため、下線と、直したマスの赤い点線の枠と、直した人の札を付ける (2026-11-05 h41 の差し戻し) */
.kys-text del.kd { color: #d00; text-decoration: line-through double #d00; }
.kys-text ins.ki { color: #d00; text-decoration: underline solid #d00; text-underline-offset: 2px; }
.kys-cell.has-trail { outline: 1.5px dashed #d00; outline-offset: -2px; }
.kys-who { position: absolute; z-index: 4; transform: translate(-100%, -55%); font-size: 12px; font-weight: 700; line-height: 1.3;
  background: #fff3f3; color: #b00; border: 1px solid #e6a; border-radius: 4px; padding: 0 4px; white-space: nowrap; pointer-events: none; }

.kys-bar { position: sticky; bottom: 0; background: #fff; border-top: 1px solid #dde3e6; padding: 10px 0; display: flex; gap: 8px; justify-content: flex-end; align-items: center; z-index: 5; }
.kys-bar.hidden { display: none; }
.kys-bar .btn { white-space: nowrap; padding: 10px 18px; }
.kys-state { margin-right: auto; font-size: 13px; color: #7a5a00; }

/* 直し窓 (パソコンはマスの横、スマホは下から) */
.kys-editor { position: fixed; z-index: 100001; background: #fff; border-radius: 12px; box-shadow: 0 8px 28px rgba(0,0,0,.28); padding: 14px 16px 16px; width: 440px; max-width: calc(100vw - 24px); overflow: auto; box-sizing: border-box; }
.kys-editor.sheet { left: 0; right: 0; bottom: 0; top: auto; width: auto; max-width: none; max-height: 75vh; border-radius: 16px 16px 0 0; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }
.kys-editor.sheet::before { content: ''; display: block; width: 44px; height: 5px; border-radius: 3px; background: #ccd3d8; margin: -4px auto 10px; }
.kys-editor h4 { margin: 0 0 2px; font-size: 13px; color: #5b6b74; font-weight: 600; }
.kys-editor .ed-title { font-size: 17px; font-weight: 700; margin-bottom: 10px; color: #12343b; }
.kys-editor textarea, .kys-editor input[type=text], .kys-editor input[type=date] { width: 100%; box-sizing: border-box; font-size: 16px; padding: 10px; border: 1px solid #b7c2c8; border-radius: 8px; font-family: inherit; }
.kys-editor textarea { min-height: 96px; resize: vertical; }
.kys-editor .ed-picks { display: flex; gap: 8px; }
.kys-editor .ed-picks.ed-col { flex-direction: column; }
.kys-editor .ed-picks button { flex: 1; min-height: 52px; font-size: 20px; font-weight: 700; border-radius: 10px; border: 2px solid #b7c2c8; background: #fff; cursor: pointer; }
.kys-editor .ed-picks.ed-col button { font-size: 16px; }
.kys-editor .ed-picks button.on { border-color: #0D7377; background: #e3f4f4; color: #0D7377; }
.kys-editor .ed-picks button:disabled { opacity: .35; cursor: not-allowed; }
.kys-editor .ed-hint { font-size: 13px; color: #5b6b74; margin: 8px 0 0; }
.kys-editor .ed-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.kys-editor .ed-actions .btn { padding: 10px 18px; font-size: 15px; }
.kys-editor .ed-tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.kys-editor .ed-tabs button { flex: 1; padding: 9px 6px; border: 1px solid #c33; background: #fff; color: #c33; border-radius: 8px; font-size: 14px; font-weight: 700; cursor: pointer; min-height: 40px; }
.kys-editor .ed-tabs button.on { background: #c33; color: #fff; }
.kys-editor [hidden] { display: none !important; }
.kys-editor .ed-trace { font-size: 20px; line-height: 1.9; padding: 10px 8px; border: 1px dashed #c9a; border-radius: 8px; user-select: none; -webkit-user-select: none; touch-action: none; background: #fffafa; cursor: text; }
.kys-editor .ed-trace span { padding: 2px 0; }
.kys-editor .ed-trace span.sel { background: rgba(220,40,40,.18); }
.kys-editor .ed-trace span.del { color: #d00; text-decoration: line-through double #d00; }
.kys-editor .ed-clear { margin-top: 10px; background: none; border: 0; color: #5b6b74; text-decoration: underline; font-size: 13px; cursor: pointer; padding: 4px 0; }
.kys-tip { position: fixed; z-index: 100002; background: #263238; color: #fff; font-size: 14px; padding: 8px 12px; border-radius: 8px; max-width: 280px; }

@media (max-width: 699px) {
  .kys-legend { font-size: 12px; gap: 8px; }
  .kys-zoom { margin-left: 0; }
}

/* 右下に固定の「元に戻す・やり直す」(#undo-floating-buttons、z-index 99999) が保存の帯のボタンに重ならないよう、
   エクセルの形で直している間は帯の上へ上げる (style.css の工事内容一覧の帯と同じやり方)。直し窓はその上に出す */
body:has(#ky-detail-view:not(.hidden) #kys-detail-panel:not([hidden]) .kys-body:not([hidden]) .kys-bar:not(.hidden)) #undo-floating-buttons,
body:has(#main-view:not(.hidden) #kys-result-panel:not([hidden]) .kys-body:not([hidden]) .kys-bar:not(.hidden)) #undo-floating-buttons { bottom: 84px !important; }

/* 複数の KY を続けて見る (11-05 利用者の足し)。前へ・次へは上に置く (右下の「元に戻す」と重ならないように) */
.kys-multi { position: fixed; inset: 0; z-index: 900; background: #f4f6f7; overflow: auto; padding: 0 12px 24px; box-sizing: border-box; }
body.kys-multi-open { overflow: hidden; }
.kym-head { position: sticky; top: 0; z-index: 10; background: #0D7377; color: #fff; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 10px 12px; margin: 0 -12px 8px; }
.kym-head .btn { padding: 8px 14px; font-size: 15px; white-space: nowrap; }
.kym-nav { display: flex; align-items: center; gap: 10px; margin-left: auto; }
.kym-pos { font-weight: 700; min-width: 64px; text-align: center; font-size: 16px; }
.kym-note { font-size: 13px; color: #7a5a00; background: #fff8e1; border-radius: 6px; padding: 6px 10px; margin: 4px 0 8px; }
.kym-info { font-size: 15px; margin: 6px 0; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.kym-review { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; margin: 6px 0; }
.kym-review .btn { padding: 9px 18px; }
.kym-reason { display: flex; gap: 8px; flex-wrap: wrap; width: 100%; }
.kym-reason textarea { flex: 1 1 260px; font-size: 16px; padding: 8px; border: 1px solid #b7c2c8; border-radius: 8px; font-family: inherit; }
.kym-review[hidden], .kym-reason[hidden], .kym-note[hidden] { display: none !important; }
.kym-msg { min-height: 1.4em; margin: 4px 0; font-size: 14px; color: #1f6b3a; }
.kym-msg.bad { color: #b00020; }
.kys-multi .kys-panel, .kys-multi .kys-body { width: auto; margin-left: 0; }
@media (max-width: 699px) { .kym-head { gap: 6px; } .kym-head .btn { padding: 8px 10px; font-size: 14px; } .kym-nav { margin-left: 0; width: 100%; justify-content: space-between; } }
/* 続けて見る画面では右下の「元に戻す・やり直す」を出さない (この画面の直しは「やめる」で戻す。保存の帯とも重なるため) */
body.kys-multi-open #undo-floating-buttons { display: none !important; }
.kym-status { display: inline-block; font-size: 12px; font-weight: 700; color: #fff; border-radius: 999px; padding: 3px 10px; background: #78909c; }
.kym-status:empty { display: none; }
.kym-st-completed { background: #2e9e5b; }
.kym-st-pending_review { background: #ef8f00; }
.kym-st-approved, .kym-st-final { background: #1976d2; }
.kym-st-printed { background: #5e35b1; }
