:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --primary: #1d4ed8;
  --danger: #dc2626;
  --sun: #dc2626;
  --sat: #2563eb;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Apple SD Gothic Neo', 'Malgun Gothic', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  padding-bottom: calc(64px + env(safe-area-inset-bottom));
  padding-top: env(safe-area-inset-top);
}
a { color: var(--primary); text-decoration: none; }
h2 { font-size: 20px; margin: 0; }
h3 { font-size: 16px; margin: 20px 0 8px; }
input, select, textarea {
  font: inherit; font-size: 16px; width: 100%;
  padding: 9px 10px; border: 1px solid #d1d5db; border-radius: 10px; background: #fff; color: var(--text);
}
textarea { resize: vertical; }
label { display: block; font-size: 13px; color: #374151; }
label > input, label > select, label > textarea { margin-top: 4px; }
label.check { display: flex; gap: 8px; align-items: center; font-size: 14px; }
label.check input { width: auto; margin: 0; }
pre { margin: 0; }

.page { max-width: 760px; margin: 0 auto; padding: 14px 16px 24px; }
.page-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; min-height: 32px; }
.stack > * + * { margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.row > label { flex: 1; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border-radius: 14px; padding: 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); }
.card + .card, .card + h3 { margin-top: 12px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.center { text-align: center; }
.err { color: var(--danger); }
.warn { color: #b45309; background: #fffbeb; padding: 6px 8px; border-radius: 8px; }
.list > * + * { margin-top: 8px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  font: inherit; font-size: 15px; padding: 10px 14px; border-radius: 10px;
  border: 1px solid #d1d5db; background: #fff; color: var(--text); cursor: pointer;
}
.btn.sm { padding: 6px 10px; font-size: 13px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.danger { color: var(--danger); border-color: #fecaca; }
.btn:disabled { opacity: .5; }
.file-btn { position: relative; }
.icon-btn { border: 0; background: none; font-size: 18px; padding: 6px 10px; cursor: pointer; color: var(--text); }

.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: rgba(255,255,255,.96);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); z-index: 20;
  backdrop-filter: blur(8px);
}
.tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; font-size: 11px; color: var(--muted); padding: 7px 0 6px; }
.tabbar a span { font-size: 20px; line-height: 26px; }
.tabbar a.on { color: var(--primary); font-weight: 600; }

/* 캘린더 */
.cal-top { display: flex; align-items: center; gap: 4px; margin-bottom: 8px; }
.cal-title { font-size: 19px; min-width: 120px; text-align: center; }
.cal-top .btn { margin-left: auto; }
.seg { display: inline-flex; border: 1px solid #d1d5db; border-radius: 10px; overflow: hidden; }
.seg button { font: inherit; font-size: 13px; border: 0; background: #fff; padding: 8px 10px; color: var(--text); }
.seg button.on { background: var(--text); color: #fff; }
.row.wrap select { width: auto; flex: 1; min-width: 140px; }
.cal-head { display: grid; grid-template-columns: repeat(7, 1fr); margin-top: 10px; font-size: 12px; text-align: center; color: var(--muted); }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 1px; background: var(--line); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.cal-cell {
  background: #fff; min-height: 86px; padding: 3px 2px; border: 0; text-align: left; display: flex; flex-direction: column; gap: 2px;
  font: inherit; color: inherit; cursor: pointer; min-width: 0;
}
.cal-cell.dim { background: #fafafa; }
.cal-cell.dim .cal-num { opacity: .4; }
.cal-num { font-size: 12px; padding-left: 2px; }
.cal-cell.today .cal-num { background: var(--primary); color: #fff; border-radius: 9px; padding: 0 6px; align-self: flex-start; }
.wd0, .wd0 .cal-num { color: var(--sun); }
.wd6, .wd6 .cal-num { color: var(--sat); }
.chip { display: block; font-size: 10px; line-height: 15px; color: #fff; border-radius: 4px; padding: 0 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.more { font-size: 10px; color: var(--muted); padding-left: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin: 10px 2px; font-size: 12px; }
.lg { display: inline-flex; align-items: center; gap: 4px; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.dot.lg { width: 14px; height: 14px; margin-right: 6px; vertical-align: -1px; }
.actions { margin-top: 6px; }
.actions .btn { flex: 1; }

.ev-row { display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; font: inherit; color: inherit; cursor: pointer; }
.ev-row .dot { margin-top: 5px; }
.chev { color: #9ca3af; font-size: 22px; align-self: center; }

/* 현장 */
.site-card { display: flex; gap: 12px; align-items: center; background: #fff; border-radius: 14px; padding: 12px 14px; color: inherit; }
.site-card .bar { width: 5px; align-self: stretch; border-radius: 3px; }
.back { font-size: 15px; }
.site-title { display: flex; align-items: center; margin: 0 0 10px; }
.tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 12px; padding-bottom: 2px; }
.tabs a { white-space: nowrap; padding: 7px 12px; border-radius: 18px; background: #fff; color: var(--text); font-size: 14px; border: 1px solid var(--line); }
.tabs a.on { background: var(--text); color: #fff; border-color: var(--text); }
.tabs a:last-child { margin-left: auto; color: var(--primary); }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.sw { width: 30px; height: 30px; border-radius: 50%; border: 3px solid transparent; cursor: pointer; }
.sw.on { border-color: #111; }
.chat-text { white-space: pre-wrap; word-break: break-all; font-family: inherit; font-size: 13px; background: #f9fafb; border-radius: 8px; padding: 8px; max-height: 240px; overflow: auto; margin: 8px 0; }

.table-scroll { overflow-x: auto; background: #fff; border-radius: 12px; }
table.est, table.sch { border-collapse: collapse; width: 100%; font-size: 13px; }
.est th, .est td, .sch th, .sch td { border-bottom: 1px solid var(--line); padding: 7px 8px; text-align: left; vertical-align: top; }
.est th, .sch th { background: #f8fafc; font-weight: 600; white-space: nowrap; }
.est td.num { text-align: right; white-space: nowrap; }
.table-scroll .est { min-width: 640px; }
.table-scroll .est td:nth-child(2) { min-width: 150px; }
.est tfoot td { font-weight: 700; border-bottom: 0; }
.est tfoot tr.sum-note td { font-weight: 400; color: var(--muted); font-size: 0.9em; }
del { color: #9ca3af; }
ins { text-decoration: none; color: #b91c1c; font-weight: 600; }
tr.st-removed td { color: #9ca3af; text-decoration: line-through; }
tr.st-added td { background: #f0fdf4; }
.badge { font-size: 10px; border-radius: 4px; padding: 1px 4px; font-weight: 600; text-decoration: none; display: inline-block; }
.badge.new { background: #dcfce7; color: #15803d; }
.badge.del { background: #fee2e2; color: #b91c1c; }
.est-row { display: grid; grid-template-columns: 1fr 2fr 0.8fr 0.7fr 1.3fr 1.4fr auto; gap: 4px; margin-bottom: 6px; align-items: center; }
.est-row input { padding: 7px 6px; font-size: 14px; }
@media (max-width: 600px) {
  .est-row { grid-template-columns: 1fr 1fr 1fr auto; padding: 8px; background: #f9fafb; border-radius: 10px; }
  .est-row [data-f="name"] { grid-column: span 3; }
  .est-row [data-f="memo"] { grid-column: span 3; }
}

/* 카톡 → AI 변경 */
.change-rec { background: #f0fdf4; border: 1px solid #bbf7d0; border-radius: 10px; padding: 8px 10px; margin: 8px 0; }
.change-rec.reverted { background: #f9fafb; border-color: var(--line); color: var(--muted); }
.change-rec ul { margin: 4px 0 0; padding-left: 18px; }
.prop { display: flex; gap: 10px; align-items: flex-start; border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; }
.prop input { width: 20px; height: 20px; margin: 2px 0 0; flex: none; }
.prop .quote { color: #475569; font-style: italic; margin-top: 2px; }

/* 공정표 불러오기 미리보기 */
.preview-list { max-height: 300px; overflow: auto; border: 1px solid var(--line); border-radius: 10px; }
.pv { display: flex; align-items: center; gap: 8px; padding: 6px 10px; font-size: 13px; border-bottom: 1px solid #f3f4f6; }
.pv-date { width: 120px; flex: none; color: var(--muted); }
.pv-title { flex: 1; }
.tag { font-size: 11px; background: #f3f4f6; border-radius: 6px; padding: 1px 6px; color: #374151; }
.proc-colors { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; }
.pc { display: flex; align-items: center; gap: 6px; font-size: 13px; }
.pc input { width: 34px; height: 28px; padding: 0; border: 0; margin: 0; }

/* 자료 */
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumb { position: relative; width: 76px; height: 76px; border-radius: 10px; background: #eee center/cover; }
.thumb span { position: absolute; left: 4px; bottom: 4px; font-size: 11px; background: rgba(0,0,0,.6); color: #fff; border-radius: 6px; padding: 0 5px; }
.thumb button { position: absolute; top: -6px; right: -6px; width: 22px; height: 22px; border-radius: 50%; border: 0; background: #111; color: #fff; font-size: 11px; }
.thumb.pick input { position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; margin: 0; }
details summary { cursor: pointer; padding: 4px 0; }
.slides > * + * { margin-top: 12px; }
.slide-frame { position: relative; width: 100%; overflow: hidden; border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.15); cursor: pointer; background: #fff; }
.slide-scale { transform-origin: 0 0; width: 1280px; height: 720px; position: absolute; left: 0; top: 0; }
.render-stage { position: fixed; left: -99999px; top: 0; width: 1280px; height: 720px; }

/* 모달 */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.modal { background: #fff; width: 100%; max-width: 620px; max-height: 92vh; border-radius: 16px 16px 0 0; display: flex; flex-direction: column; padding-bottom: env(safe-area-inset-bottom); }
.modal.wide { max-width: 960px; }
@media (min-width: 700px) { .modal-back { align-items: center; } .modal { border-radius: 16px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.modal-body { padding: 14px 16px; overflow: auto; flex: 1; }
.modal-foot { display: flex; gap: 8px; padding: 10px 16px 14px; border-top: 1px solid var(--line); }
.modal-foot .btn { flex: 1; }
.toast { position: fixed; left: 50%; bottom: calc(80px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(20px); background: rgba(17,24,39,.92); color: #fff; padding: 10px 16px; border-radius: 20px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 60; max-width: 90vw; }
.toast.show { opacity: 1; transform: translateX(-50%); }

/* ───── 슬라이드 (1280×720 고정, PDF/JPG 렌더 공통) ───── */
.slide { position: relative; width: 1280px; height: 720px; background: #fff; color: #0f172a; padding: 40px 60px 0; overflow: hidden; font-family: 'Apple SD Gothic Neo', 'Malgun Gothic', -apple-system, sans-serif; }
.slide h2 { font-size: 38px; font-weight: 800; margin: 0 0 22px; padding-bottom: 16px; border-bottom: 2px solid #e2e8f0; letter-spacing: -0.5px; }
.slide ul { margin: 0; padding-left: 30px; }
.slide li { font-size: 27px; line-height: 1.5; margin-bottom: 12px; }
.slide .pic { width: 100%; height: 100%; background: #f1f5f9 center/cover no-repeat; border-radius: 10px; }
.slide .s-foot { position: absolute; left: 60px; right: 60px; bottom: 18px; display: flex; justify-content: space-between; font-size: 15px; color: #94a3b8; }
.slide .s-note { position: absolute; left: 60px; right: 60px; bottom: 46px; font-size: 16px; color: #64748b; }
.s-cover { display: flex; padding: 0; background: #f8fafc; }
.s-cover .cover-text { flex: 1; padding: 150px 60px 0 80px; }
.s-cover .cover-site { font-size: 24px; color: #64748b; margin-bottom: 16px; }
.s-cover h1 { font-size: 54px; line-height: 1.25; margin: 0 0 22px; letter-spacing: -1px; }
.s-cover p { font-size: 26px; color: #334155; margin: 0; }
.s-cover .cover-date, .s-closing .cover-date { margin-top: 70px; font-size: 20px; color: #64748b; }
.s-cover .cover-pic { width: 560px; padding: 50px 50px 50px 0; }
.s-closing .closing { text-align: center; padding-top: 170px; }
.s-closing h1 { font-size: 50px; margin: 0 0 30px; }
.s-closing ul { list-style: none; padding: 0; }
.s-closing li { font-size: 26px; color: #334155; }
.slide .pics { display: grid; gap: 16px; height: 470px; }
.slide .pics.n1 { grid-template-columns: 1fr; }
.slide .pics.n2 { grid-template-columns: 1fr 1fr; }
.slide .pics.n3, .slide .pics.n4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.slide .pics-cap { margin-top: 14px; }
.slide .pics-cap li { font-size: 21px; margin-bottom: 4px; }
.s-image .pics:has(+ .pics-cap) { height: 390px; }
.slide .split { display: flex; gap: 40px; height: 500px; }
.slide .split-pics { width: 560px; display: grid; gap: 16px; }
.slide .split-pics.n0 { display: none; }
.slide .split-text { flex: 1; }
.slide .tbl table { font-size: 19px; }
.slide .tbl th, .slide .tbl td { padding: 9px 12px; border-bottom: 1px solid #e2e8f0; }
.slide .tbl th { background: #f1f5f9; text-align: left; }
.slide .tbl td.num { text-align: right; }
.slide .tbl-cap { margin-top: 14px; }
.slide .tbl-cap li { font-size: 19px; margin-bottom: 4px; }
.slide .sch .dot { width: 12px; height: 12px; }
