/* page-calendar: 달력(#page-calendar). 섹션에 class="page ui ps-page". 공통 토큰은 style.css, 머리·기준 줄은 page-sales.css.
   일정 줄 색: 글자색 1(경고 빨강)만 색이고 2~5 는 줄 앞 모양(● ◆ ■ ▲ ○)으로 구분. 배경색 1~6 은 연한 회색 6단(번호가 도구 상자에 보인다). */

#page-calendar.ui.ps-page .cal-nav { display: inline-flex; align-items: center; gap: 8px; }
#page-calendar.ui.ps-page .cal-title { min-width: 150px; text-align: center; font-size: 17px; font-weight: 500; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; white-space: nowrap; }
#page-calendar.ui.ps-page .searchwrap { position: relative; }
#page-calendar.ui.ps-page .searchwrap .ps-search { width: 220px; }
#page-calendar.ui.ps-page .cal-livebar { min-height: 40px; }
#page-calendar.ui.ps-page .cal-livebar .gchip { font-size: 12.5px; color: var(--ps-text2); text-decoration: none; white-space: nowrap; }
#page-calendar.ui.ps-page .cal-livebar a.gchip { text-decoration: underline; text-underline-offset: 3px; color: var(--ps-text); font-weight: 500; }
#page-calendar.ui.ps-page .cal-stat { min-width: 0; color: var(--ps-text2); }

/* 연차·입고 보이기 */
#page-calendar.ui.ps-page .tg { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ps-text); cursor: pointer; white-space: nowrap; }
#page-calendar.ui.ps-page .tg input { appearance: none; -webkit-appearance: none; width: 15px; height: 15px; margin: 0; border: 1px solid var(--ps-rule); border-radius: 0; background: transparent; cursor: pointer; display: grid; place-items: center; }
#page-calendar.ui.ps-page .tg input:checked { background: var(--ps-text); border-color: var(--ps-text); }
#page-calendar.ui.ps-page .tg input:checked::after { content: ""; width: 7px; height: 4px; border-left: 2px solid var(--ps-bg); border-bottom: 2px solid var(--ps-bg); transform: translateY(-1px) rotate(-45deg); }
#page-calendar.ui.ps-page .tg-m { order: 2; color: var(--ps-text2); font-size: 11px; }
#page-calendar.ui.ps-page .tg.leave .tg-m::before { content: "◇"; }
#page-calendar.ui.ps-page .tg.inbound .tg-m::before { content: "■"; }
#page-calendar.ui.ps-page .tg .meta { font-size: 12px; }

/* 월 격자: 요일 머리 = 네 면 굵은 박스, 격자 = 굵은 바깥 박스 + 가는 칸선 */
#page-calendar.ui.ps-page .cal { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
#page-calendar.ui.ps-page .cal-head, #page-calendar.ui.ps-page .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
#page-calendar.ui.ps-page .cal-head { flex: none; border: 2px solid var(--ps-box); }
#page-calendar.ui.ps-page .cal-head div { text-align: center; font-size: 13px; font-weight: 500; padding: 6px 0; color: var(--ps-text2); border-left: 1px solid var(--ps-hair); }
#page-calendar.ui.ps-page .cal-head div:first-child { border-left: 0; color: var(--t1); }
#page-calendar.ui.ps-page .cal-grid { flex: 1 1 auto; min-height: 0; grid-template-rows: repeat(var(--rows), minmax(0, 1fr)); border: 2px solid var(--ps-box); border-top: 0; }
#page-calendar.ui.ps-page .cell { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; padding: 3px 4px 4px; cursor: text; border-right: 1px solid var(--ps-hair); border-bottom: 1px solid var(--ps-hair); background: transparent; }
#page-calendar.ui.ps-page .cell:nth-child(7n) { border-right: 0; }
#page-calendar.ui.ps-page .cell:nth-last-child(-n+7) { border-bottom: 0; }
#page-calendar.ui.ps-page .cell.other { background: var(--ps-panel); }
#page-calendar.ui.ps-page .cell.other .dnum, #page-calendar.ui.ps-page .cell.other .lunar { color: var(--ps-muted); }
#page-calendar.ui.ps-page .cell.other.sun .dnum, #page-calendar.ui.ps-page .cell.other.hol .dnum { color: var(--t1); }
#page-calendar.ui.ps-page .cell:focus-within { outline: 2px solid var(--ps-text); outline-offset: -2px; }
#page-calendar.ui.ps-page .cell.today { box-shadow: inset 0 3px 0 var(--ps-text); }
#page-calendar.ui.ps-page .cell.today .dnum { font-weight: 500; }
#page-calendar.ui.ps-page .cell.flash::after { content: ""; position: absolute; inset: 0; border: 2px solid var(--ps-text); pointer-events: none; animation: cal-flash 1.4s ease-out forwards; }
@keyframes cal-flash { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { #page-calendar.ui.ps-page .cell.flash::after { animation: none; } }

#page-calendar.ui.ps-page .chead { display: flex; align-items: baseline; gap: 6px; padding: 0 2px; min-width: 0; flex: none; }
#page-calendar.ui.ps-page .dnum { font-size: 14px; font-weight: 400; color: var(--ps-text); white-space: nowrap; flex: none; font-variant-numeric: tabular-nums; }
#page-calendar.ui.ps-page .cell.sun .dnum, #page-calendar.ui.ps-page .cell.hol .dnum { color: var(--t1); }
#page-calendar.ui.ps-page .todaytag { font-size: 11px; font-weight: 500; color: var(--ps-text); white-space: nowrap; flex: none; border-bottom: 1px solid var(--ps-text); }
#page-calendar.ui.ps-page .lunar { font-size: 11px; color: var(--ps-muted); white-space: nowrap; flex: none; }
#page-calendar.ui.ps-page .hname { font-size: 11.5px; color: var(--t1); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
#page-calendar.ui.ps-page .cbg { flex: none; margin-left: 4px; height: 20px; font-size: 11px; line-height: 1; background: var(--ps-bg); border: 1px solid var(--ps-rule); border-radius: 2px; padding: 0 6px; color: var(--ps-text2); opacity: 0; white-space: nowrap; align-self: center; }
#page-calendar.ui.ps-page .cclr { margin-left: auto; }
#page-calendar.ui.ps-page .cell:hover .cbg, #page-calendar.ui.ps-page .cell:focus-within .cbg, #page-calendar.ui.ps-page .cbg:focus-visible { opacity: 1; }
#page-calendar.ui.ps-page .cbg:hover { border-color: var(--ps-text); color: var(--ps-text); }

/* 시트에서 가져온 읽기 전용 표시: 모양(◇ 연차 / ■ 입고) + 글자 */
#page-calendar.ui.ps-page .ros { display: flex; flex-direction: column; gap: 2px; margin-top: 2px; flex: none; }
#page-calendar.ui.ps-page .ro { position: relative; font-size: 12px; line-height: 1.3; padding: 1px 6px 1px 18px; background: var(--ps-raised); color: var(--ps-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: default; }
#page-calendar.ui.ps-page .ro::before { position: absolute; left: 5px; top: 1px; font-size: 9px; color: var(--ps-text2); }
#page-calendar.ui.ps-page .ro.leave::before { content: "◇"; }
#page-calendar.ui.ps-page .ro.inbound::before { content: "■"; }
#page-calendar.ui.ps-page .ro b { font-weight: 500; }
#page-calendar.ui.ps-page .ro .rosub { color: var(--ps-muted); font-size: 11.5px; }

/* 줄 */
#page-calendar.ui.ps-page .lines { counter-reset: ln; flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; margin-top: 2px; scrollbar-width: thin; scrollbar-color: var(--ps-rule) transparent; }
#page-calendar.ui.ps-page .ln { position: relative; counter-increment: ln; font-size: 13.5px; line-height: 1.35; padding: 1px 5px 1px 34px; border-radius: 0; min-height: 21px; outline: none; white-space: pre-wrap; overflow-wrap: anywhere; cursor: text; flex: none; color: var(--ps-text); }
#page-calendar.ui.ps-page .ln::before { content: counter(ln) "." attr(data-tm); position: absolute; left: 4px; top: 1px; width: 30px; line-height: 19px; font-size: 11px; color: var(--ps-muted); text-align: left; pointer-events: none; user-select: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
#page-calendar.ui.ps-page .ln[data-tm]::before { color: inherit; }
/* 배경색을 고른 줄: 오른쪽 끝에 작은 번호(1~6) */
#page-calendar.ui.ps-page .ln[data-b] { padding-right: 18px; }
#page-calendar.ui.ps-page .ln[data-b]::after { content: attr(data-b); position: absolute; right: 4px; top: 1px; line-height: 19px; font-size: 11px; color: var(--ps-muted); pointer-events: none; user-select: none; }
#page-calendar.ui.ps-page .ln:focus { box-shadow: 0 0 0 2px var(--ps-text); }
#page-calendar.ui.ps-page .ln.strike { text-decoration: line-through; }
#page-calendar.ui.ps-page .ln.picked { outline: 2px solid var(--ps-text); outline-offset: -1px; background: var(--ps-raised) !important; }

/* 찾기 결과 */
#page-calendar.ui.ps-page .results { position: absolute; right: 0; top: 44px; z-index: 40; width: 400px; max-height: 360px; overflow-y: auto; background: var(--ps-bg); border: 2px solid var(--ps-box); scrollbar-width: thin; }
#page-calendar.ui.ps-page .hit-n { padding: 6px 10px; color: var(--ps-text2); }
#page-calendar.ui.ps-page .hit { display: flex; gap: 10px; align-items: center; padding: 7px 10px; cursor: pointer; font-size: 13px; border-top: 1px solid var(--ps-hair); }
#page-calendar.ui.ps-page .hit:hover, #page-calendar.ui.ps-page .hit:focus-visible { background: var(--ps-raised); }
#page-calendar.ui.ps-page .hit-d { font-variant-numeric: tabular-nums; color: var(--ps-text2); flex: none; }
#page-calendar.ui.ps-page .hit .strike { text-decoration: line-through; }

/* 몸 전체에 붙는 도구(화면 바깥에 뜨는 것이라 .ui 범위 밖: 토큰만 쓴다) */
.lnpop { position: fixed; z-index: 50; background: var(--ps-bg); color: var(--ps-text); border: 2px solid var(--ps-box); padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.lnpop .prow { display: flex; align-items: center; gap: 8px; }
.lnpop .plabel { width: 52px; color: var(--ps-text2); font-size: 12px; flex: none; }
.lnpop .swatches { display: flex; gap: 6px; }
.lnpop .pbtn { background: transparent; border: 1px solid var(--ps-rule); border-radius: 2px; padding: 3px 10px; color: var(--ps-text); }
.lnpop .pbtn:hover { border-color: var(--ps-text); }
.lnpop .pbtn.on { border-color: var(--ps-text); background: var(--ps-raised); font-weight: 500; }
.lnpop .pbtn.danger { color: var(--t1); }
.lnpop .sw { width: 26px; height: 26px; padding: 0; border: 1px solid var(--ps-rule); border-radius: 0; background: transparent; color: var(--ps-text); font-size: 12px; line-height: 1; }
.lnpop .sw.none { border-style: dashed; color: var(--ps-text2); }
.lnpop .sw.on { outline: 2px solid var(--ps-text); outline-offset: 1px; }
.lnpop :focus-visible, .pickbar :focus-visible, .toast :focus-visible { outline: 2px solid var(--ps-text); outline-offset: 2px; }
.pickbar, .toast { position: fixed; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; align-items: center; gap: 10px; background: var(--ps-bg); color: var(--ps-text); border: 2px solid var(--ps-box); padding: 8px 14px; font-size: 13.5px; }
.pickbar { bottom: 22px; }
.toast { bottom: 22px; border-width: 1px; border-color: var(--ps-rule); }
.pickbar ~ .toast { bottom: 76px; }
.cal-btn { background: transparent; border: 1px solid var(--ps-rule); border-radius: 2px; padding: 5px 12px; color: var(--ps-text); font-weight: 500; }
.cal-btn:hover { border-color: var(--ps-text); background: var(--ps-raised); }
.cal-btn.danger { color: var(--t1); }
.band { position: fixed; z-index: 60; border: 1.5px solid var(--ps-text); background: color-mix(in srgb, var(--ps-text) 10%, transparent); pointer-events: none; }
body.banding, body.banding * { user-select: none !important; -webkit-user-select: none !important; cursor: crosshair !important; }
