/* LK 도면함 — 색·크기는 여기 맨 위 값만 쓴다 */
:root {
  --bg: #f5f6f8; --surface: #fff; --line: #e3e6eb; --line2: #d0d5dd;
  --text: #101828; --text2: #475467; --text3: #8a94a6;
  --brand: #1f2a44; --accent: #2457d6; --accent-h: #1c46b0; --accent-bg: #eef3fe;
  --danger: #c4320a; --ok: #087443; --warn: #b54708;
  --canvas: #dfe2e7; --r: 6px; --hd: 56px; --rail: 64px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }   /* display 값이 hidden 을 덮지 않게 */
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.55 "Pretendard", "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif; letter-spacing: -.005em; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; font-weight: 700; margin: 0; letter-spacing: -.02em; }
h2 { font-size: 15px; font-weight: 700; margin: 0 0 12px; display: flex; align-items: center; gap: 8px; }
h3 { font-size: 13px; font-weight: 700; color: var(--text2); margin: 20px 0 8px; }
small { color: var(--text3); font-weight: 400; }
.mono { font-family: "Cascadia Mono", Consolas, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; } .right { text-align: right; } .dim { color: var(--text3); } .mt { margin-top: 24px; }
.inline { display: inline; }
.ic { width: 18px; height: 18px; flex: none; }

/* 단추·입력 */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 1px solid var(--line2); border-radius: var(--r);
       background: var(--surface); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none; }
.btn:hover { background: #f9fafb; text-decoration: none; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.sm .ic { width: 15px; height: 15px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-h); }
.btn.danger { color: var(--danger); border-color: #f4b8a7; }
.btn.block { width: 100%; height: 42px; }
.ibtn { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; border: 0; border-radius: var(--r); background: transparent; color: var(--text2); cursor: pointer; }
.ibtn:hover { background: #f2f4f7; color: var(--text); }
input, select, textarea { font: inherit; width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--line2); border-radius: var(--r); background: #fff; color: var(--text); }
textarea { height: auto; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-bg); border-color: var(--accent); }
.form label, .mlabel { display: block; margin: 0 0 14px; font-weight: 600; font-size: 13px; color: var(--text2); }
.form label input, .form label select, .mlabel textarea { margin-top: 6px; }
.alert { background: #fef3f2; border: 1px solid #fecdca; color: var(--danger); padding: 10px 12px; border-radius: var(--r); font-weight: 600; }
.notice { background: var(--accent-bg); color: #1d3b8a; padding: 10px 12px; border-radius: var(--r); }
.hint { color: var(--text3); font-size: 13px; margin: 10px 0; }
.empty { color: var(--text3); padding: 28px 16px; text-align: center; }

/* 상태 표 */
.st { font-style: normal; display: inline-flex; align-items: center; height: 22px; padding: 0 8px; border-radius: 4px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.st-both { background: var(--accent-bg); color: var(--accent); }
.st-only { background: #f2f4f7; color: var(--text2); }
.st-new { background: #ecfdf3; color: var(--ok); }
.st-req { background: #fef3f2; color: var(--danger); }
.st-done { background: #ecfdf3; color: var(--ok); }
.st-file { background: #f2f4f7; color: var(--text2); }

/* 머리줄 */
.hd { position: sticky; top: 0; z-index: 10; height: var(--hd); display: flex; align-items: center; gap: 14px; padding: 0 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 800; font-size: 16px; text-decoration: none !important; }
.mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 800; letter-spacing: .02em; }
.hsep { width: 1px; height: 20px; background: var(--line); }
.proj { color: var(--text2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.hnav { margin-left: auto; display: flex; align-items: center; gap: 2px; }
.hnav a { display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: var(--r); color: var(--text2); font-weight: 600; text-decoration: none; }
.hnav a:hover { background: #f2f4f7; color: var(--text); }
.hnav a.on { color: var(--accent); background: var(--accent-bg); }
.hnav .who { margin-left: 8px; border-left: 1px solid var(--line); border-radius: 0; padding-left: 14px; }
.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 40px; }
.ft { color: var(--text3); font-size: 12px; text-align: center; padding: 24px 16px 32px; }

/* 쪽 머리 · 탭 · 도구줄 */
.phead { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.pmeta { margin: 4px 0 0; color: var(--text3); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tab { padding: 10px 14px; color: var(--text2); font-weight: 600; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none !important; }
.tab:hover { color: var(--text); }
.tab.on { color: var(--accent); border-color: var(--accent); }
.cnt { display: inline-block; min-width: 20px; padding: 0 6px; border-radius: 10px; background: #f2f4f7; color: var(--text2); font-size: 12px; font-weight: 600; text-align: center; }
.tab.on .cnt { background: var(--accent-bg); color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search { position: relative; flex: 1 1 280px; max-width: 420px; color: var(--text3); }
.search .ic { position: absolute; left: 11px; top: 11px; }
.search input { padding-left: 36px; }
.seg { display: inline-flex; background: #eceef2; border-radius: 8px; padding: 3px; gap: 2px; }
.seg button, .seg a { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text2); font: inherit; font-weight: 600; cursor: pointer; white-space: nowrap; text-decoration: none !important; }
.seg .on { background: #fff; color: var(--text); box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }

/* 도면 목록표 */
.register { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.rhead, .rrow { display: grid; grid-template-columns: 92px 128px minmax(200px, 1fr) 104px 96px 96px 72px; align-items: center; gap: 12px; padding: 0 16px; }
.rhead { height: 40px; background: #f9fafb; border-bottom: 1px solid var(--line); color: var(--text3); font-size: 12px; font-weight: 600; }
.gtitle { padding: 8px 16px; background: #fbfbfc; border-bottom: 1px solid var(--line); font-size: 12px; font-weight: 700; color: var(--text2); letter-spacing: .02em; }
.gtitle span { color: var(--text3); font-weight: 500; margin-left: 4px; }
.rrow { min-height: 72px; border-bottom: 1px solid var(--line); color: var(--text); text-decoration: none !important; }
.rrow:hover { background: #f8faff; }
.th { width: 92px; height: 60px; border: 1px solid var(--line); border-radius: 4px; background: #fff; overflow: hidden; display: grid; place-items: center; }
.th img { width: 100%; height: 100%; object-fit: contain; }
.th em { font-style: normal; font-size: 11px; color: var(--text3); }
.no { font-family: "Cascadia Mono", Consolas, monospace; font-weight: 700; font-size: 13px; color: var(--brand); }
.nm { font-weight: 600; } .nm small { margin-left: 4px; }
.dt { color: var(--text2); font-size: 13px; font-variant-numeric: tabular-nums; }

/* 표 · 판 */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 20px; margin-bottom: 16px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.cols .panel { margin: 0; }
.cols + .panel { margin-top: 16px; }
.tbl { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.panel .tbl { border: 0; }
.tbl table { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 12px; font-weight: 600; color: var(--text3); background: #f9fafb; padding: 10px 14px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.tbl td { padding: 11px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tr.off td { color: var(--text3); }
.props { display: grid; grid-template-columns: 88px 1fr; gap: 8px 12px; margin: 0; }
.props dt { color: var(--text3); } .props dd { margin: 0; font-weight: 600; }

/* 로그인 */
.authbg { background: linear-gradient(180deg, #eef1f6 0%, var(--bg) 60%); }
.auth { min-height: calc(100vh - 80px); display: grid; place-items: center; padding: 32px 16px; }
.authcard { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 32px 28px; box-shadow: 0 12px 32px rgba(16, 24, 40, .08); }
.authcard h1 { font-size: 20px; margin: 0 0 6px; }
.authlogo { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 16px; margin-bottom: 22px; }
.sub { color: var(--text2); margin: 0 0 20px; }
.pwbox { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; background: var(--bg); border: 1px solid var(--line); padding: 14px 16px; border-radius: 8px; margin: 0 0 16px; }
.pwbox dt { color: var(--text3); } .pwbox dd { margin: 0; font-weight: 700; font-size: 16px; }

/* ── 도면 보기 ── */
body.viewer { overflow: hidden; overscroll-behavior: none; background: var(--canvas); }
main.vw { display: grid; grid-template-rows: auto 1fr; height: 100vh; height: 100dvh; }
.vt { display: flex; align-items: center; gap: 10px; min-height: var(--hd); padding: 0 12px; padding-top: env(safe-area-inset-top); background: var(--surface); border-bottom: 1px solid var(--line); z-index: 3; }
.vbtn { position: relative; display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; border: 0; border-radius: var(--r); background: transparent; color: var(--text2); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none !important; white-space: nowrap; }
.vbtn:hover { background: #f2f4f7; color: var(--text); }
.vbtn.on { background: var(--accent-bg); color: var(--accent); }
.dot { position: absolute; top: 2px; right: 0; min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px; background: var(--danger); color: #fff; font-size: 11px; line-height: 17px; text-align: center; }
.vtitle { display: flex; align-items: baseline; gap: 10px; min-width: 0; flex: 1 1 auto; padding-left: 6px; border-left: 1px solid var(--line); }
.vno { font-family: "Cascadia Mono", Consolas, monospace; font-weight: 700; color: var(--brand); white-space: nowrap; }
.vnm { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vsite { color: var(--text3); font-size: 13px; white-space: nowrap; }
.modes { flex: none; }
.pager { display: flex; align-items: center; gap: 2px; color: var(--text2); font-weight: 600; font-variant-numeric: tabular-nums; }
.pager span { min-width: 52px; text-align: center; }
.vtools { display: flex; gap: 2px; flex: none; }
.stage { position: relative; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; background: var(--canvas); }
.pane { position: absolute; inset: 0; overflow: hidden; }
.stage.split .pane[data-pane="0"] { bottom: 50%; border-bottom: 1px solid var(--line2); }
.stage.split .pane[data-pane="1"] { top: 50%; }
.box { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 1px 3px rgba(16, 24, 40, .1), 0 8px 24px rgba(16, 24, 40, .1); }   /* will-change 를 쓰면 크롬이 확대 전 해상도로 굳혀 흐려짐 */
.box img { display: block; width: 100%; height: 100%; pointer-events: none; }
.box img.detail { position: absolute; display: block; pointer-events: none; image-rendering: auto; }   /* 확대 때 덮는 선명한 부분 그림 — 자리·크기는 app.js 가 % 로 */
.box svg.ink { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.plabel { position: absolute; left: 12px; top: 12px; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 10px; border-radius: 4px; pointer-events: none; }
.plabel:empty { display: none; }
.msg { position: absolute; left: 50%; top: 45%; transform: translate(-50%, -50%); background: var(--surface); color: var(--text); padding: 12px 18px; border-radius: 8px; box-shadow: 0 8px 24px rgba(16, 24, 40, .15); max-width: 86%; text-align: center; }
.dlegend { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 14px; background: var(--surface); border: 1px solid var(--line); padding: 6px 12px; border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--text2); pointer-events: none; }
.dlegend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }
.lg-r { background: #de2626; } .lg-b { background: #185ce6; } .lg-g { background: #a5a5a5; }
.viewing { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; max-width: 92%; background: var(--surface); border: 1px solid var(--line); border-left: 3px solid var(--danger); padding: 6px 6px 6px 12px; border-radius: 6px; font-weight: 600; box-shadow: 0 4px 12px rgba(16, 24, 40, .1); }
.viewing span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 마크업 판 */
.mk { position: fixed; right: 16px; top: calc(var(--hd) + 16px); width: 232px; z-index: 6; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 12px; box-shadow: 0 12px 32px rgba(16, 24, 40, .16); }
.mkhead { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mkrow { display: flex; gap: 6px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.colors { display: grid; grid-template-columns: repeat(6, 1fr); }
.sw { width: 30px; height: 30px; padding: 3px; border: 2px solid transparent; border-radius: 50%; background: none; cursor: pointer; }
.sw i { display: block; width: 100%; height: 100%; border-radius: 50%; }
.sw.on { border-color: var(--text); }
.c-red { background: #e02424; } .c-blue { background: #1a56db; } .c-green { background: #047857; }
.c-lime { background: #84cc16; } .c-pink { background: #ec4899; } .c-black { background: #111; }
.widths button { flex: 1; height: 32px; border: 1px solid var(--line2); border-radius: var(--r); background: #fff; cursor: pointer; display: grid; place-items: center; }
.widths button.on { border-color: var(--accent); background: var(--accent-bg); }
.widths i { display: block; width: 26px; background: var(--text); border-radius: 2px; }
.w1 { height: 2px; } .w2 { height: 4px; } .w3 { height: 7px; }
.acts { gap: 4px; }
.mksend { margin-top: 8px; }
.mkhint { margin: 8px 0 0; font-size: 11.5px; color: var(--text3); text-align: center; }

/* 대화창 · 옆판 */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: rgba(16, 24, 40, .45); }
.mcard { width: min(480px, 100%); background: var(--surface); border-radius: 12px; padding: 18px 20px 16px; box-shadow: 0 20px 48px rgba(16, 24, 40, .25); }
.mhead { display: flex; justify-content: space-between; align-items: center; font-size: 16px; }
.msub { color: var(--text3); margin: 2px 0 14px; font-size: 13px; }
.mfoot { display: flex; justify-content: flex-end; gap: 8px; }
.side { position: fixed; top: 0; right: 0; bottom: 0; width: min(400px, 100%); z-index: 12; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(16, 24, 40, .12); display: flex; flex-direction: column; }
.shead { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 16px 16px 12px; padding-top: max(16px, env(safe-area-inset-top)); }
.snm { font-weight: 700; font-size: 16px; margin-top: 2px; }
.stabs { display: flex; gap: 4px; padding: 0 16px; border-bottom: 1px solid var(--line); }
.stabs button { border: 0; background: none; padding: 10px 10px; font: inherit; font-weight: 600; color: var(--text2); border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; }
.stabs button.on { color: var(--accent); border-color: var(--accent); }
.stabs span { color: var(--text3); font-weight: 500; }
.side section { padding: 16px; overflow-y: auto; flex: 1; }
.files { border: 1px solid var(--line); border-radius: 8px; }
.frow { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.frow:last-child { border-bottom: 0; }
.frow small { display: block; }
.fbtns { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.rq { border: 1px solid var(--line); border-radius: 8px; padding: 12px; margin-bottom: 10px; }
.rq header { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 13px; }
.rq header span { color: var(--text3); }
.rqmemo { margin: 8px 0 4px; font-weight: 600; white-space: pre-wrap; }
.rqmeta { margin: 0; color: var(--text3); font-size: 12px; }
.rqdone { display: flex; align-items: center; gap: 4px; margin: 6px 0 0; color: var(--ok); font-size: 12.5px; }
.rqdone .ic { width: 14px; height: 14px; }
.rqacts, .rqform { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.rqform input { flex: 1 1 140px; height: 30px; font-size: 13px; }
.tl { list-style: none; margin: 0; padding: 0; }
.tl li { position: relative; padding: 0 0 14px 16px; border-left: 2px solid var(--line); margin-left: 4px; }
.tl li::before { content: ""; position: absolute; left: -6px; top: 5px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--line2); }
.tl time { display: block; color: var(--text3); font-size: 12px; }
.tl li > span { margin-left: 6px; font-weight: 600; }
.tl p { margin: 4px 0 0; color: var(--text2); font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 30; background: var(--text); color: #fff; padding: 10px 16px; border-radius: 8px; font-weight: 600; box-shadow: 0 8px 24px rgba(16, 24, 40, .25); }

/* 좁은 화면(폰 세로) */
@media (max-width: 760px) {
  .hd { padding: 0 12px; gap: 10px; }
  .proj, .hsep, .hnav span { display: none; }
  .hnav .who { margin-left: 0; border: 0; padding-left: 12px; }
  .page { padding: 18px 14px 32px; }
  .seg { overflow-x: auto; max-width: 100%; }
  .rhead { display: none; }
  .rrow { grid-template-columns: 76px 1fr auto; grid-template-areas: "th no rq" "th nm nm" "th kd kd"; gap: 2px 12px; padding: 10px 14px; }
  .rrow .th { grid-area: th; width: 76px; height: 54px; } .rrow .no { grid-area: no; } .rrow .nm { grid-area: nm; }
  .rrow .kd { grid-area: kd; } .rrow .rqc { grid-area: rq; } .rrow .dt { display: none; }
  .cols { grid-template-columns: 1fr; }
  .vt { flex-wrap: wrap; gap: 4px 6px; padding: 6px 8px; padding-top: max(6px, env(safe-area-inset-top)); }
  .vtitle { flex: 1 1 0; border: 0; padding-left: 0; }
  .vsite { display: none; }
  .vt .lb { display: none; }
  .vtools { order: 1; }
  .modes { order: 2; flex: 1 1 100%; }
  .pager { order: 3; flex: 1 1 100%; justify-content: center; }
  .modes button { flex: 1; justify-content: center; padding: 0 8px; }
  .modes .lb { display: inline !important; }
  .mk { left: 8px; right: 8px; top: auto; bottom: calc(8px + env(safe-area-inset-bottom)); width: auto; display: grid; grid-template-columns: 1fr auto; gap: 0 8px; padding: 8px 10px; }
  .mkhead { display: none; }
  .mk .colors { grid-column: 1 / -1; border: 0; padding-top: 2px; }
  .mk .widths { border-top: 1px solid var(--line); }
  .mk .acts { justify-content: flex-end; }
  .mksend { grid-column: 1 / -1; margin-top: 4px; }
  .mkhint { display: none; }
  .sw { width: 34px; height: 34px; justify-self: center; }
}

/* 가로 화면(폰·태블릿) — 도구는 왼쪽 세로 줄, 마크업 판은 오른쪽. 도면이 위아래를 꽉 채움 */
@media (orientation: landscape) and (max-height: 820px) and (pointer: coarse) {
  main.vw { grid-template-rows: 1fr; grid-template-columns: var(--rail) 1fr; }
  .vt { flex-direction: column; align-items: stretch; flex-wrap: nowrap; gap: 4px; min-height: 0; padding: 8px 6px; padding-left: max(6px, env(safe-area-inset-left));
        border-bottom: 0; border-right: 1px solid var(--line); overflow-y: auto; }
  .vt .vbtn, .vt .seg button { flex-direction: column; justify-content: center; gap: 1px; height: auto; min-height: 38px; padding: 3px 2px; font-size: 10px; }
  .vt .ic { width: 17px; height: 17px; }
  .vt .lb { display: block !important; line-height: 1.1; }
  .vtitle { display: block; order: 0; border: 0; padding: 2px 0 4px; text-align: center; border-bottom: 1px solid var(--line); flex: none; }
  .vno { display: block; font-size: 11px; }
  .vnm, .vsite { display: none; }
  .modes { flex-direction: column; padding: 3px; flex: none; }
  .pager { flex-direction: column; font-size: 11px; }
  .pager span { min-width: 0; }
  .vtools { flex-direction: column; margin-top: auto; }
  .dot { right: 4px; }
  .stage.split .pane[data-pane="0"] { bottom: 0; right: 50%; border-bottom: 0; border-right: 1px solid var(--line2); }
  .stage.split .pane[data-pane="1"] { top: 0; left: 50%; }
  .mk { left: auto; right: max(8px, env(safe-area-inset-right)); top: 8px; bottom: 8px; width: 120px; display: flex; flex-direction: column; gap: 0; padding: 8px; overflow-y: auto; }
  .mkhead { display: flex; } .mkhead b { font-size: 12px; }
  .mk .colors { grid-template-columns: repeat(2, 1fr); justify-items: center; gap: 4px; border-top: 0; }
  .mk .widths { flex-direction: column; } .mk .widths button { width: 100%; flex: none; }
  .mk .acts { justify-content: space-around; }
  .mksend { margin-top: auto; height: 40px; font-size: 13px; padding: 0 6px; }
  .mkhint { display: none; }
  .sw { width: 34px; height: 34px; }
  .dlegend { left: 8px; bottom: 8px; }
}

/* ══ 다크 — 위 값을 덮어씀. 도면 종이(.box·.th)는 흰색 그대로 ══ */
:root {
  --bg: #0e1116; --surface: #161a21; --surface2: #1c212a; --line: #262c37; --line2: #343b48;
  --text: #e8ebf0; --text2: #aab2c0; --text3: #6f7889;
  --brand: #e8ebf0; --accent: #4f8cff; --accent-h: #3b78ec; --accent-bg: rgba(79, 140, 255, .14);
  --danger: #ff6b57; --ok: #3ccf8e; --warn: #f5a524; --canvas: #0a0c10;
}
body { background: var(--bg); }
.hd, .vt { background: rgba(22, 26, 33, .92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }
.mark { background: linear-gradient(135deg, #4f8cff, #2b5fd9); color: #fff; }
.btn, input, select, textarea, .widths button { background: var(--surface2); color: var(--text); border-color: var(--line2); }
.btn:hover { background: #232935; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: var(--accent-h); }
.btn.danger { color: var(--danger); border-color: rgba(255, 107, 87, .45); background: transparent; }
input::placeholder, textarea::placeholder { color: var(--text3); }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(79, 140, 255, .35); }
.ibtn:hover, .vbtn:hover, .hnav a:hover { background: var(--surface2); color: var(--text); }
.hnav .who.guest { display: flex; align-items: center; gap: 6px; color: var(--text3); margin-left: 8px; border-left: 1px solid var(--line); padding-left: 14px; height: 36px; }
.seg { background: var(--bg); border: 1px solid var(--line); }
.seg .on { background: var(--surface2); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .4); }
.cnt { background: var(--surface2); color: var(--text2); }
.alert { background: rgba(255, 107, 87, .1); border-color: rgba(255, 107, 87, .35); }
.notice { background: var(--accent-bg); color: #b9d0ff; }
.st-both { background: rgba(79, 140, 255, .14); color: #8fb6ff; }
.st-only, .st-file { background: rgba(170, 178, 192, .12); color: var(--text2); }
.st-new, .st-done { background: rgba(60, 207, 142, .13); color: var(--ok); }
.st-req { background: rgba(255, 107, 87, .14); color: var(--danger); }
.register, .tbl, .panel, .files, .rq { background: var(--surface); border-color: var(--line); }
.rhead, .tbl th { background: var(--surface2); }
.gtitle { background: #12161c; }
.rrow:hover { background: #1a2030; }
.th { border-color: var(--line2); }
.no, .vno { color: #8fb6ff; }
.authbg { background: radial-gradient(1200px 600px at 50% -10%, #1b2740 0%, var(--bg) 60%); }
.authcard { background: var(--surface); border-color: var(--line); box-shadow: 0 24px 64px rgba(0, 0, 0, .5); }
.codein { height: 64px; text-align: center; font-size: 30px; letter-spacing: .5em; padding-left: .5em; font-family: "Cascadia Mono", Consolas, monospace; margin-bottom: 14px; }
.center { text-align: center; } .hint a { color: var(--text2); }
.bigcode { font-size: 44px; font-weight: 800; letter-spacing: .12em; text-align: center; padding: 18px; margin: 0 0 14px; border-radius: 10px; background: var(--bg); border: 1px solid var(--line2); color: #fff; }
.pwbox { background: var(--bg); border-color: var(--line2); }
.box { box-shadow: 0 0 0 1px rgba(255, 255, 255, .06), 0 18px 48px rgba(0, 0, 0, .6); }
.plabel { background: rgba(79, 140, 255, .9); }
.msg, .dlegend, .viewing, .mk, .mcard, .side { background: var(--surface); border-color: var(--line); color: var(--text); }
.mk { box-shadow: 0 18px 48px rgba(0, 0, 0, .55); }
.widths i { background: var(--text); }
.widths button.on { border-color: var(--accent); background: var(--accent-bg); }
.sw.on { border-color: #fff; }
.sw i { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }
.modal { background: rgba(0, 0, 0, .6); }
.side { box-shadow: -18px 0 48px rgba(0, 0, 0, .5); }
.tl li::before { background: var(--surface); border-color: var(--line2); }
.toast { background: #e8ebf0; color: #0e1116; }
.lg-g { background: #8a8f99; }
.dot { box-shadow: 0 0 0 2px var(--surface); }

/* 첫 화면 — 현장 머리 · 숫자 · 최근 변경 */
.hero { display: grid; grid-template-columns: 1fr auto; gap: 28px; align-items: end; padding: 28px; margin-bottom: 20px; border: 1px solid var(--line); border-radius: 14px;
        background: radial-gradient(900px 300px at 0% 0%, rgba(79, 140, 255, .16), transparent 60%), linear-gradient(180deg, #171c25, #12161c); }
.eyebrow { margin: 0 0 8px; color: var(--text3); font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.hero h1 { font-size: 28px; letter-spacing: -.03em; }
.lead { margin: 10px 0 0; color: var(--text2); max-width: 560px; }
.stats { display: grid; grid-template-columns: repeat(4, minmax(110px, 1fr)); gap: 10px; margin: 0; }
.stats div { background: rgba(255, 255, 255, .03); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; }
.stats dt { color: var(--text3); font-size: 12px; font-weight: 600; }
.stats dd { margin: 4px 0 0; font-size: 26px; font-weight: 800; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stats .hot dd { color: var(--danger); }
.recent { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 14px 18px 6px; margin-bottom: 24px; }
.rtitle { display: flex; justify-content: space-between; align-items: center; }
.rtitle h2 { margin: 0; }
.rtitle a { display: inline-flex; align-items: center; gap: 2px; font-size: 13px; color: var(--text2); }
.rtitle .ic { width: 15px; height: 15px; }
.recent ul { list-style: none; margin: 8px 0 0; padding: 0; }
.recent li a { display: grid; grid-template-columns: 90px minmax(0, 280px) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); color: var(--text); text-decoration: none; }
.recent li a:hover b { color: var(--accent); }
.recent b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recent span { color: var(--text2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.recent time { color: var(--text3); font-size: 12px; font-variant-numeric: tabular-nums; }
.lhead { display: flex; align-items: baseline; gap: 12px; margin-bottom: 4px; }
.lhead h2 { font-size: 18px; margin: 0; }
@media (max-width: 760px) {
  .hero { grid-template-columns: 1fr; padding: 20px; gap: 18px; }
  .hero h1 { font-size: 22px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .stats dd { font-size: 22px; }
  .recent li a { grid-template-columns: auto 1fr; gap: 4px 10px; }
  .recent li a span { grid-column: 1 / -1; }
  .recent time { display: none; }
}

/* 마크업 도구 셋(펜·화살표·글자) · 글자 넣기 판(폰 = 아래에서 올라옴, 키보드 위) */
.tools3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; border-top: 0; padding-top: 0; }
.tools3 button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 0; border: 1px solid var(--line2); border-radius: var(--r);
                 background: var(--surface2); color: var(--text2); font: inherit; font-size: 11.5px; font-weight: 600; cursor: pointer; }
.tools3 button.on { border-color: var(--accent); background: var(--accent-bg); color: var(--text); }
.sheet { position: fixed; inset: 0; z-index: 22; display: flex; align-items: flex-start; justify-content: center; background: rgba(0, 0, 0, .35);
         padding: max(8vh, env(safe-area-inset-top)) 10px 0; }   /* 위쪽에 — 폰 키보드가 올라와도 가리지 않게 */
.sheet .mcard { width: min(560px, 100%); }
.sheet textarea { margin: 10px 0 12px; font-size: 16px; }
.mfoot.spread { justify-content: space-between; align-items: center; }
.tsz button { height: 30px; font-size: 13px; }
@media (max-width: 760px) {
  .mk .tools3 { grid-column: 1 / -1; }
  .tools3 button { flex-direction: row; justify-content: center; gap: 6px; font-size: 13px; padding: 7px 0; }
  .tools3 .ic { width: 16px; height: 16px; }
}
@media (orientation: landscape) and (max-height: 820px) and (pointer: coarse) {
  .mk { width: 128px; }
  .tools3 { grid-template-columns: 1fr; }
  .tools3 button { flex-direction: row; justify-content: center; gap: 5px; padding: 5px 0; font-size: 11px; }
  .tools3 .ic { width: 15px; height: 15px; }
  .sheet { padding-top: 6px; }
  .sheet .mcard { width: min(560px, 80%); padding: 10px 14px; }
  .sheet textarea { margin: 6px 0 8px; }
}

/* 전체 도면 — 도면집 고르기 · 공종 칩 · 도면 카드 */
.setpick { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 10px; margin: 4px 0 16px; }
.setcard { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--text); text-decoration: none !important; }
.setcard b { font-size: 15px; } .setcard span { color: var(--text3); font-size: 12.5px; }
.setcard:hover { border-color: var(--line2); }
.setcard.on { border-color: var(--accent); background: linear-gradient(180deg, rgba(79, 140, 255, .14), rgba(79, 140, 255, .04)); }
.setcard.on b { color: #b9d0ff; }
.trades { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tchip { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border-radius: 16px; border: 1px solid var(--line2); background: var(--surface2); color: var(--text2); font-weight: 600; text-decoration: none !important; }
.tchip b { color: var(--text); font-size: 12px; background: var(--bg); border-radius: 9px; padding: 0 6px; }
.tchip:hover { border-color: var(--accent); color: var(--text); }
.tsec { margin: 8px 0 26px; scroll-margin-top: 70px; }
.ttitle { font-size: 17px; padding-bottom: 8px; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.dcard { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--surface); color: var(--text); text-decoration: none !important; transition: border-color .12s, transform .12s; }
.dcard:hover { border-color: var(--accent); transform: translateY(-1px); }
.dthumb { position: relative; aspect-ratio: 1.414; background: #fff; display: grid; place-items: center; border-bottom: 1px solid var(--line); }
.dthumb img { width: 100%; height: 100%; object-fit: contain; }
.dthumb i { position: absolute; font-style: normal; font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 4px; }
.dthumb .pg { right: 6px; bottom: 6px; background: rgba(14, 17, 22, .85); color: #fff; }
.dthumb .rqb { left: 6px; top: 6px; background: var(--danger); color: #fff; }
.dmeta { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px 12px; }
.dno { font-family: "Cascadia Mono", Consolas, monospace; font-weight: 700; font-size: 12.5px; color: #8fb6ff; }
.dnm { font-weight: 600; line-height: 1.35; word-break: keep-all; }
.drel { color: var(--text3); font-size: 12px; }
@media (max-width: 760px) {
  .setpick { grid-template-columns: 1fr; gap: 6px; }
  .setcard { flex-direction: row; justify-content: space-between; align-items: center; padding: 12px 14px; }
  .trades { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; }
  .tchip { flex: none; }
  .cards { grid-template-columns: 1fr 1fr; gap: 8px; }
  .dmeta { padding: 8px 9px 10px; } .dnm { font-size: 13px; }
}

/* 장 목록(합본) — 모든 장을 작은 그림으로 */
.pgrid { position: fixed; inset: 0; z-index: 15; background: rgba(10, 12, 16, .96); display: flex; flex-direction: column; }
.pghead { display: flex; align-items: center; gap: 10px; padding: 12px 16px; padding-top: max(12px, env(safe-area-inset-top)); border-bottom: 1px solid var(--line); }
.pghead .ibtn { margin-left: auto; }
.pgbody { flex: 1; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding: 14px 16px 24px; align-content: start; }
.pgcell { position: relative; display: block; border: 2px solid transparent; border-radius: 6px; background: #fff; padding: 0; cursor: pointer; overflow: hidden; }
.pgcell img { width: 100%; aspect-ratio: 1.414; height: auto; object-fit: contain; display: block; }
.pgcell span { position: absolute; left: 4px; bottom: 4px; background: rgba(14, 17, 22, .85); color: #fff; font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 4px; }
.pgcell.on { border-color: var(--accent); }
@media (max-width: 760px) { .pgbody { grid-template-columns: repeat(3, 1fr); gap: 6px; padding: 10px; } }
@media (orientation: landscape) and (max-height: 820px) and (pointer: coarse) { .pgbody { grid-template-columns: repeat(5, 1fr); } }


/* 변경 도면 / 전체 도면 전환 — 큰 두 칸. 폰은 머리줄 아래에 붙어 있음 */
.modebar { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 20px; }
.mb { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--text2); text-decoration: none !important; }
.mb .ic { width: 26px; height: 26px; }
.mbt { display: flex; flex-direction: column; line-height: 1.3; }
.mbt b { font-size: 16px; color: var(--text); }
.mbt small { font-size: 12.5px; }
.mb:hover { border-color: var(--line2); }
.mb.on { border-color: var(--accent); background: linear-gradient(180deg, rgba(79, 140, 255, .18), rgba(79, 140, 255, .05)); color: #b9d0ff; }
.mb.on b { color: #fff; }
@media (max-width: 760px) {
  .hnav .navmode { display: none; }          /* 폰은 아래 큰 두 칸으로 */
  .modebar { position: sticky; top: var(--hd); z-index: 9; margin: -18px -14px 16px; padding: 8px 14px; background: rgba(14, 17, 22, .94);
             backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid var(--line); gap: 6px; }
  .mb { padding: 10px 12px; gap: 8px; border-radius: 10px; }
  .mb .ic { width: 20px; height: 20px; }
  .mbt b { font-size: 15px; } .mbt small { font-size: 11.5px; }
}
