/* ═══ 일정관리 (22-schedule.js) ═══
   색은 app.css 의 토큰만 쓴다 → [data-theme="dark"] 에서 자동으로 바뀐다.
   분류 색은 각 요소의 인라인 --c 로 받는다. */
.sched-wrap{display:flex;flex-direction:column;gap:10px}
.sched-wrap button:focus-visible,.sched-wrap input:focus-visible,.sched-wrap select:focus-visible,
.sched-pop button:focus-visible{outline:2px solid var(--primary);outline-offset:1px}
.sched-sr{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0,0,0,0);white-space:nowrap;border:0}

/* ── 툴바 ── */
.sched-toolbar{display:flex;flex-direction:column;gap:10px;background:var(--surface);border-radius:var(--radius);box-shadow:var(--shadow);padding:10px 14px}
.sched-bar{display:flex;align-items:center;gap:8px 10px;flex-wrap:wrap}
.sched-views{display:flex;gap:6px}
.sched-nav{display:flex;align-items:center;justify-content:center;gap:8px;flex:1 1 auto;min-width:0}
.sched-title{margin:0;min-width:120px;font-size:calc(16px*var(--fs,1));font-weight:700;color:var(--text);text-align:center;white-space:nowrap}
.sched-add-btn{margin-left:auto;white-space:nowrap}
.sched-staff{display:flex;gap:6px;flex-wrap:wrap}
.sched-field{display:inline-flex}
.sched-field select,.sched-field input{padding:6px 10px;border:1px solid var(--border);border-radius:6px;font-size:calc(13px*var(--fs,1));font-family:inherit;background:var(--bg);color:var(--text);outline:none}
.sched-field select:focus,.sched-field input:focus{border-color:var(--primary);background:var(--surface)}
.sched-search{flex:1 1 220px}
.sched-search input{width:100%}
.sched-overlay-toggle{display:inline-flex;align-items:center;gap:6px;font-size:calc(13px*var(--fs,1));font-weight:500;color:var(--text);cursor:pointer;white-space:nowrap}
.sched-overlay-toggle input{width:16px;height:16px;margin:0;accent-color:var(--primary)}
.sched-legend{display:flex;flex-wrap:wrap;gap:4px 12px;font-size:calc(11px*var(--fs,1));color:var(--muted)}
.sched-legend-item{display:inline-flex;align-items:center;gap:4px}
.sched-legend-dot{width:10px;height:10px;border-radius:3px;background:var(--c)}
.sched-legend-dot.is-order{background:transparent;border:1.5px dashed #f97316}

.sched-body{position:relative}   /* '+N' 팝오버 위치 기준 (offsetTop/Left) */
.sched-empty{padding:60px 20px;text-align:center;color:var(--muted);background:var(--surface);border-radius:var(--radius);box-shadow:var(--shadow)}
.sched-empty-sm{margin:0;padding:14px;font-size:calc(12px*var(--fs,1));color:var(--muted);text-align:center}
.sched-error{margin-bottom:10px;padding:10px 14px;border:1px solid rgba(239,68,68,.4);border-radius:8px;background:rgba(239,68,68,.1);color:#dc2626;font-size:calc(13px*var(--fs,1))}

/* ── 일정 칩 (월간·주간 종일·팝오버 공용) ── */
.sched-chip{display:flex;align-items:center;gap:4px;width:100%;min-width:0;height:calc(20px*var(--fs,1));padding:0 6px;border:none;border-radius:5px;font-family:inherit;font-size:calc(11px*var(--fs,1));line-height:calc(20px*var(--fs,1));text-align:left;white-space:nowrap;overflow:hidden;cursor:pointer;flex-shrink:0}
.sched-chip-title{min-width:0;overflow:hidden;text-overflow:ellipsis}
.sched-chip-time{flex-shrink:0;font-weight:700;font-variant-numeric:tabular-nums}
.sched-chip.is-bar{background:var(--c);color:#fff}
.sched-chip.is-bar:hover{filter:brightness(1.1)}
.sched-chip.is-timed{background:transparent;color:var(--text)}
.sched-chip.is-timed::before{content:'';flex-shrink:0;width:7px;height:7px;border-radius:50%;background:var(--c)}
.sched-chip.is-timed:hover{background:var(--bg)}
.sched-chip.is-done{opacity:.55}
.sched-chip.is-done .sched-chip-title{text-decoration:line-through}
/* 여러 날 일정: 이어지는 쪽 모서리를 펴서 칸을 건너 이어져 보이게 */
.sched-day .sched-chip.cont-l{margin-left:-4px;width:calc(100% + 4px);border-top-left-radius:0;border-bottom-left-radius:0}
.sched-day .sched-chip.cont-r{margin-right:-4px;width:calc(100% + 4px);border-top-right-radius:0;border-bottom-right-radius:0}
.sched-day .sched-chip.cont-l.cont-r{width:calc(100% + 8px)}
.sched-chip.sched-order-chip{--c:#f97316;background:var(--surface);color:var(--text);border:1px dashed #f97316;line-height:calc(18px*var(--fs,1))}
.sched-chip.sched-order-chip:hover{background:var(--bg)}

/* ── 월간 ── */
.sched-month{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:1px;background:var(--border);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;box-shadow:var(--shadow)}
.sched-head{padding:8px 4px;background:var(--bg);color:var(--muted);font-size:calc(12px*var(--fs,1));font-weight:700;text-align:center}
.sched-head.sun{color:#ef4444}.sched-head.sat{color:#3b82f6}
.sched-day{display:flex;flex-direction:column;gap:2px;min-width:0;min-height:112px;padding:4px 4px 6px;background:var(--surface);cursor:pointer}
.sched-day:hover{box-shadow:inset 0 0 0 1px var(--primary)}
.sched-day.other{background:var(--bg)}
.sched-day.other>*{opacity:.45}
.sched-day.today{background:var(--primary-light)}
.sched-day-num{align-self:flex-start;min-width:calc(24px*var(--fs,1));height:calc(24px*var(--fs,1));padding:0 5px;border:none;border-radius:12px;background:none;color:var(--text);font-family:inherit;font-size:calc(12px*var(--fs,1));font-weight:700;cursor:pointer}
.sched-day-num:hover{background:var(--bg)}
.sched-day.sun .sched-day-num{color:#ef4444}
.sched-day.sat .sched-day-num{color:#3b82f6}
.sched-day.today .sched-day-num{background:var(--primary);color:#fff}
.sched-day-items{display:flex;flex-direction:column;gap:2px;min-width:0}
.sched-more{align-self:flex-start;height:calc(18px*var(--fs,1));padding:0 6px;border:none;border-radius:4px;background:none;color:var(--muted);font-family:inherit;font-size:calc(11px*var(--fs,1));font-weight:700;cursor:pointer}
.sched-more:hover{background:var(--bg);color:var(--primary)}

/* '+N' 팝오버 */
.sched-pop{position:absolute;z-index:60;display:flex;flex-direction:column;gap:8px;width:280px;max-width:calc(100% - 8px);padding:10px;background:var(--surface);border:1px solid var(--border);border-radius:var(--radius);box-shadow:var(--shadow-lg)}
.sched-pop-head{display:flex;align-items:center;justify-content:space-between;font-size:calc(13px*var(--fs,1));color:var(--text)}
.sched-pop-list{display:flex;flex-direction:column;gap:3px;max-height:300px;overflow-y:auto;padding:3px;margin:-3px}   /* 포커스 테두리가 잘리지 않게 */
.sched-pop .sched-chip{height:calc(26px*var(--fs,1));line-height:calc(26px*var(--fs,1));font-size:calc(12px*var(--fs,1))}
.sched-pop .sched-chip.sched-order-chip{line-height:calc(24px*var(--fs,1))}
.sched-pop-add{align-self:stretch;justify-content:center}

/* ── 주간 ── (8열: 라벨 + 일~토 / 3행: 날짜·종일·시간) */
.sched-week{display:grid;grid-template-columns:calc(48px*var(--fs,1)) repeat(7,minmax(0,1fr));gap:1px;background:var(--border);border:1px solid var(--border);border-radius:var(--radius);overflow:hidden;box-shadow:var(--shadow)}
.sched-wk-label{display:flex;align-items:flex-start;justify-content:center;padding:8px 2px;background:var(--bg);color:var(--muted);font-size:calc(11px*var(--fs,1));font-weight:600}
.sched-wk-head{display:flex;justify-content:center;padding:6px 4px;background:var(--bg);min-width:0}
.sched-wk-date{display:inline-flex;flex-direction:column;align-items:center;gap:2px;padding:3px 10px;border:none;border-radius:8px;background:none;color:var(--text);font-family:inherit;cursor:pointer}
.sched-wk-date:hover{background:var(--primary-light)}
.sched-wk-date .dow{font-size:calc(11px*var(--fs,1));font-weight:600;color:var(--muted)}
.sched-wk-date .num{display:flex;align-items:center;justify-content:center;min-width:calc(30px*var(--fs,1));height:calc(30px*var(--fs,1));border-radius:15px;font-size:calc(17px*var(--fs,1));font-weight:700}
.sched-wk-head.sun .dow,.sched-wk-head.sun .num{color:#ef4444}
.sched-wk-head.sat .dow,.sched-wk-head.sat .num{color:#3b82f6}
.sched-wk-head.today .num{background:var(--primary);color:#fff}
.sched-wk-allday{display:flex;flex-direction:column;gap:2px;min-width:0;min-height:34px;padding:4px;background:var(--surface);cursor:pointer}
.sched-wk-timed{display:flex;flex-direction:column;gap:4px;min-width:0;min-height:320px;padding:4px;background:var(--surface);cursor:pointer}
.sched-wk-allday.today,.sched-wk-timed.today{background:var(--primary-light)}
.sched-wk-allday:hover,.sched-wk-timed:hover{box-shadow:inset 0 0 0 1px var(--primary)}
.sched-card{display:flex;flex-direction:column;align-items:stretch;gap:1px;width:100%;min-width:0;padding:5px 7px;border:none;border-left:3px solid var(--c);border-radius:6px;background:var(--bg);color:var(--text);font-family:inherit;font-size:calc(12px*var(--fs,1));text-align:left;cursor:pointer}
.sched-card:hover{box-shadow:var(--shadow)}
.sched-card-time{font-size:calc(11px*var(--fs,1));font-weight:700;color:var(--muted);font-variant-numeric:tabular-nums}
.sched-card-title{font-weight:600;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sched-card-meta{font-size:calc(11px*var(--fs,1));color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.sched-card.is-done{opacity:.55}
.sched-card.is-done .sched-card-title{text-decoration:line-through}

/* ── 목록 ── */
.sched-list{display:flex;flex-direction:column;gap:12px}
.sched-sec{background:var(--surface);border-radius:var(--radius);box-shadow:var(--shadow);overflow:hidden}
.sched-sec-title{display:flex;align-items:center;gap:8px;margin:0;padding:10px 14px;border-bottom:1px solid var(--border);color:var(--text);font-size:calc(14px*var(--fs,1));font-weight:700}
.sched-sec-over .sched-sec-title{color:#dc2626}
.sched-sec-count{padding:1px 8px;border-radius:10px;background:var(--bg);color:var(--muted);font-size:calc(11px*var(--fs,1));font-weight:700}
.sched-rows{margin:0;padding:0;list-style:none}
.sched-row{display:grid;grid-template-columns:20px calc(62px*var(--fs,1)) calc(150px*var(--fs,1)) calc(58px*var(--fs,1)) minmax(0,1fr) minmax(0,auto) calc(28px*var(--fs,1));grid-template-areas:"chk dday when cat title meta link";align-items:center;gap:10px;padding:8px 14px;border-bottom:1px solid var(--border)}
.sched-row:last-child{border-bottom:none}
.sched-row:hover{background:var(--bg)}
.sched-row-check{grid-area:chk;width:16px;height:16px;margin:0;accent-color:var(--primary);cursor:pointer}
.sched-row-icon{display:flex;align-items:center;justify-content:center;width:auto;font-size:calc(14px*var(--fs,1));cursor:default}
.sched-dday{grid-area:dday;justify-self:start;padding:2px 8px;border:1px solid var(--border);border-radius:10px;background:var(--bg);color:var(--muted);font-size:calc(11px*var(--fs,1));font-weight:700;white-space:nowrap;font-variant-numeric:tabular-nums}
.sched-dday.over{border-color:rgba(239,68,68,.45);background:rgba(239,68,68,.1);color:#dc2626}
.sched-dday.today{border-color:var(--primary);background:var(--primary-light);color:var(--primary)}
.sched-dday.soon{border-color:rgba(245,158,11,.5);background:rgba(245,158,11,.12);color:#b45309}
.sched-row-when{grid-area:when;display:flex;flex-direction:column;min-width:0;font-size:calc(12px*var(--fs,1));line-height:1.35}
.sched-row-when .d{color:var(--text);font-weight:600;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sched-row-when .t{color:var(--muted);font-variant-numeric:tabular-nums}
.sched-row-cat{grid-area:cat;justify-self:start}
.sched-row-cat-order{background:transparent;border:1px dashed #f97316;color:#ea580c}
.sched-row-title{grid-area:title;min-width:0;padding:2px 0;border:none;background:none;color:var(--text);font-family:inherit;font-size:calc(13px*var(--fs,1));font-weight:600;text-align:left;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer}
.sched-row-title:hover{color:var(--primary);text-decoration:underline}
.sched-row-meta{grid-area:meta;min-width:0;color:var(--muted);font-size:calc(12px*var(--fs,1));white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
.sched-row-meta .sep{margin:0 5px;opacity:.6}
.sched-row-link{grid-area:link;width:calc(28px*var(--fs,1));height:calc(28px*var(--fs,1));padding:0;border:none;border-radius:6px;background:none;font-size:calc(14px*var(--fs,1));cursor:pointer}
button.sched-row-link:hover{background:var(--primary-light)}
.sched-row.is-done .sched-row-title{text-decoration:line-through;color:var(--muted)}
.sched-row.is-done .sched-row-cat{opacity:.6}

/* ── 등록/수정 모달 ── (.modal / .form-group 등은 app.css 것을 그대로 쓴다) */
.sched-modal{max-width:580px}
.sched-modal [hidden]{display:none!important}   /* .form-group / .btn 의 display 보다 우선 */
.sched-modal .form-group textarea{min-height:90px}
.sched-modal .form-group input[aria-invalid="true"]{border-color:#ef4444}
.sched-req{color:#ef4444}
.sched-err{font-size:calc(11px*var(--fs,1));color:#dc2626}
.sched-err:empty{display:none}
.sched-check-row{display:flex;align-items:center}
.sched-check{display:inline-flex;align-items:center;gap:6px;color:var(--text);font-size:calc(13px*var(--fs,1));font-weight:500;cursor:pointer}
.sched-check input{width:16px;height:16px;margin:0;accent-color:var(--primary)}
.sched-form-error{margin-top:12px;padding:8px 12px;border:1px solid rgba(239,68,68,.4);border-radius:6px;background:rgba(239,68,68,.1);color:#dc2626;font-size:calc(12px*var(--fs,1))}
.sched-form-error:empty{display:none}
.sched-meta{margin:12px 0 0;color:var(--muted);font-size:calc(11px*var(--fs,1))}
.sched-meta:empty{display:none}
.sched-foot-main,.sched-foot-confirm{display:flex;align-items:center;gap:8px;width:100%;justify-content:flex-end}
.sched-del-btn{margin-right:auto}
.sched-confirm-msg{margin-right:auto;color:#dc2626;font-size:calc(13px*var(--fs,1));font-weight:600}

/* ── 다크 모드: 밝은 배경 전제로 고른 글자색만 보정 ── */
[data-theme="dark"] .sched-dday.over,[data-theme="dark"] .sched-error,[data-theme="dark"] .sched-form-error,
[data-theme="dark"] .sched-err,[data-theme="dark"] .sched-confirm-msg,[data-theme="dark"] .sched-sec-over .sched-sec-title{color:#fca5a5}
[data-theme="dark"] .sched-dday.soon{color:#fcd34d}
[data-theme="dark"] .sched-dday.today{color:#93c5fd}
[data-theme="dark"] .sched-row-cat-order{color:#fdba74}

/* ── 태블릿 ── */
@media (max-width:900px){
  .sched-row{grid-template-columns:20px calc(62px*var(--fs,1)) calc(130px*var(--fs,1)) calc(58px*var(--fs,1)) minmax(0,1fr) calc(28px*var(--fs,1));grid-template-areas:"chk dday when cat title link" "chk . . . meta meta"}
  .sched-row-meta{white-space:normal}
}

/* ── 모바일 (22-schedule.js 의 SCHED_NARROW_MQ 와 같은 기준) ── */
@media (max-width:600px){
  .sched-toolbar{gap:8px;padding:8px 10px}
  .sched-bar{gap:6px}
  .sched-nav{order:-1;flex-basis:100%;justify-content:space-between}
  .sched-title{min-width:0;font-size:calc(15px*var(--fs,1));flex:1}
  .sched-views .view-tab{padding:5px 12px;font-size:calc(12px*var(--fs,1))}
  .sched-add-btn{padding:6px 10px;font-size:calc(12px*var(--fs,1));min-height:40px}
  .sched-staff{flex-basis:100%;flex-wrap:nowrap;overflow-x:auto;padding-bottom:2px}
  .sched-field select{font-size:calc(12px*var(--fs,1));padding:5px 8px}
  .sched-search{flex-basis:100%}
  .sched-overlay-toggle{font-size:calc(12px*var(--fs,1))}
  .sched-legend{gap:3px 8px;font-size:calc(10px*var(--fs,1))}

  /* 월간: 제목 대신 색 점만 — 칸을 누르면 그 날 목록이 뜬다 */
  .sched-head{padding:6px 2px;font-size:calc(11px*var(--fs,1))}
  .sched-day{min-height:58px;padding:2px 2px 4px}
  .sched-day-num{min-width:calc(20px*var(--fs,1));height:calc(20px*var(--fs,1));padding:0 3px;font-size:calc(11px*var(--fs,1))}
  .sched-day-items{flex-direction:row;flex-wrap:wrap;align-items:center;gap:3px;padding:0 3px}
  .sched-day .sched-chip,.sched-day .sched-chip.cont-l,.sched-day .sched-chip.cont-r{flex:none;width:7px;height:7px;margin:0;padding:0;border-radius:50%;background:var(--c);pointer-events:none}
  .sched-day .sched-chip>*,.sched-day .sched-chip::before{display:none}
  .sched-day .sched-chip.sched-order-chip{background:transparent;border:1.5px solid #f97316}
  .sched-more{height:auto;padding:0;font-size:calc(10px*var(--fs,1));line-height:1;pointer-events:none}
  .sched-pop{position:fixed;top:auto!important;left:8px!important;right:8px;bottom:calc(var(--bnav-h,0px) + 8px);width:auto;max-width:none;z-index:90;max-height:70vh}

  /* 주간: 날짜별로 세로로 쌓는다 (--mo = 요일*3 + 행) */
  .sched-week{display:flex;flex-direction:column}
  .sched-week>*{order:var(--mo)}
  .sched-wk-label{display:none}
  .sched-wk-head{justify-content:flex-start;padding:4px 8px}
  .sched-wk-date{flex-direction:row;align-items:center;gap:8px;padding:2px 6px}
  .sched-wk-date .num{min-width:calc(26px*var(--fs,1));height:calc(26px*var(--fs,1));font-size:calc(14px*var(--fs,1))}
  .sched-wk-allday{min-height:0}
  .sched-wk-allday:empty{display:none}
  .sched-wk-timed{min-height:0}
  .sched-wk-timed:empty:not(.is-empty-day){display:none}   /* 종일 일정만 있는 날 */
  .sched-wk-timed.is-empty-day::after{content:'일정 없음';padding:2px 4px;color:var(--muted);font-size:calc(12px*var(--fs,1))}

  /* 목록: 3줄 카드 */
  .sched-row{grid-template-columns:20px auto minmax(0,1fr) calc(28px*var(--fs,1));grid-template-areas:"chk dday when link" "chk cat title title" "chk meta meta meta";gap:4px 8px;padding:8px 10px}
  .sched-row-when{flex-direction:row;gap:6px}
  .sched-row-title{white-space:normal}
}
