/* 메인 칸 맨 위 한 줄(상단바) · 홈 화면 · 설정. 테마(white · dark · kakao) 모두 같은 토큰으로. */
:root {
  --h-card: var(--card);
  --h-line: var(--line);
  --doc-ic-bg: #e8e9ec;  /* 목록의 문서 아이콘: 회색 */
  --doc-ic: #5c6068;
  --pri-high: #e5484d;
  --pri-mid: #f59e0b;
  --pri-low: #3b82f6;
}
@media (prefers-color-scheme: dark) { :root:not([data-theme="white"]) { --doc-ic-bg: #2e3135; --doc-ic: #b3b8bf; } }
html[data-theme="dark"] { --doc-ic-bg: #333333; --doc-ic: #b4b4b4; }
html[data-theme="white"] { --doc-ic-bg: #ececec; --doc-ic: #5d5d5d; }

/* ── 목록의 문서 아이콘: 파랑 → 회색 */
#rooms .tr.top .tr-ic, #rooms .tr.top.on .tr-ic { background: var(--doc-ic-bg); color: var(--doc-ic); }

/* ── 상단바: 채팅방 이름 · 문서 위치(+ 나만 · ☆ · •••) · 홈 제목과 공지 · 가이드 · 할 일 · 예약 · 설정이 한 줄 */
.topbar { position: relative; z-index: 3; }
.tb-doc { display: none; flex: 1; min-width: 0; height: 100%; }
.tb-doc .pg-bar { flex: 1; min-width: 0; height: 100%; padding: 0; gap: 8px; border: 0; }
.tb-doc .pg-bar .dv-back { display: none !important; }
.tb-global { display: flex; align-items: center; gap: 2px; flex: none; }
.tb-dot { position: absolute; top: 7px; right: 7px; width: 8px; height: 8px; border-radius: 50%; background: #ff3b30; box-shadow: 0 0 0 2px var(--bg); }
.app.doc-mode .main > .topbar { display: flex !important; }
.app.doc-mode .topbar .room-title, .app.doc-mode .topbar .head-actions { display: none; }
.app.doc-mode .topbar .tb-doc { display: flex; }
.app.doc-mode .topbar .tb-global, .app.home-mode .topbar .tb-global { margin-left: 4px; }
.app.doc-mode .main { background: var(--bg); }
.app.doc-mode .topbar { padding-left: 28px; }
.app.home-mode .topbar .head-actions, .app.home-mode .pinned, .app.home-mode .messages, .app.home-mode .composer, .app.home-mode .sel-bar, .app.home-mode .doc-view { display: none !important; }
html:is([data-theme="white"], [data-theme="dark"]) .app.doc-mode .topbar, html:is([data-theme="white"], [data-theme="dark"]) .app.home-mode .topbar { border-bottom: 1px solid var(--line); }

/* ── 홈 화면 */
.home-view { flex: 1; min-height: 0; overflow-y: auto; }
.app.home-mode .main { background: var(--rail); }
html:is([data-theme="white"], [data-theme="dark"]) .app.home-mode .main { background: var(--bg); }
.hv-in { max-width: 1120px; margin: 0 auto; padding: 26px 32px 64px; }
.hv-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.hv-head h1 { margin: 0; font-size: 24px; font-weight: 800; letter-spacing: -.03em; }
.hv-head p { margin: 4px 0 0; font-size: 14px; color: var(--sub); }
.hv-edit { height: 32px; padding: 0 14px; border-radius: 9px; font-size: 13.5px; font-weight: 600; color: var(--sub); box-shadow: 0 0 0 1px var(--line) inset; background: var(--card); transition: background var(--t), color var(--t); }
.hv-edit:hover { color: var(--text); background: var(--hover); }
.hv-edit.on { background: var(--text); color: var(--bg); box-shadow: none; }
.hv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 16px; align-items: start; }
.hc { background: var(--h-card); border-radius: 16px; box-shadow: 0 0 0 1px var(--h-line); padding: 14px 16px 12px; min-width: 0; }
html[data-theme="kakao"] .hc { box-shadow: 0 1px 2px rgba(0, 0, 0, .04), 0 0 0 1px var(--h-line); }
.hc.wide { grid-column: 1 / -1; }
.hc.is-hidden { opacity: .45; }
.hv-grid.editing .hc { outline: 1.5px dashed var(--line); outline-offset: 3px; }
.hc-head { display: flex; align-items: center; gap: 8px; min-height: 30px; margin-bottom: 6px; }
.hc-head h2 { margin: 0; font-size: 15px; font-weight: 700; letter-spacing: -.02em; flex: 1; min-width: 0; }
.hc-act { display: inline-flex; align-items: center; gap: 5px; height: 30px; padding: 0 11px 0 8px; border-radius: 8px; font-size: 13px; font-weight: 600; color: var(--sub); }
.hc-act:hover { background: var(--hover); color: var(--text); }
.hc-act .ic { width: 16px; height: 16px; }
.hc-link { font-size: 13px; color: var(--sub); padding: 4px 6px; border-radius: 6px; }
.hc-link:hover { color: var(--text); background: var(--hover); }
.hc-tools { display: inline-flex; gap: 2px; }
.hc-tools button { width: 28px; height: 28px; border-radius: 7px; display: grid; place-items: center; color: var(--sub); }
.hc-tools button:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.hc-tools button:disabled { opacity: .3; cursor: default; }
.hc-tools .ic { width: 17px; height: 17px; }
.hc-empty { color: var(--dim); font-size: 13.5px; padding: 14px 4px; }

/* 목록 줄 (최근 채팅 · 최근 문서 · 할 일 · 예약 · 즐겨찾기 · 메일) */
.hl { display: flex; flex-direction: column; margin: 0 -8px; }
.hl-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 7px 8px; border-radius: 10px; text-align: left; color: inherit; text-decoration: none; cursor: pointer; min-width: 0; }
.hl-row:hover { background: var(--hover); }
.hl-row .av.xs { width: 30px; height: 30px; border-radius: 9px; }
.hl-ic { width: 30px; height: 30px; flex: none; border-radius: 9px; background: var(--doc-ic-bg); color: var(--doc-ic); display: grid; place-items: center; }
.hl-ic .ic { width: 16px; height: 16px; }
.hl-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.hl-main b { font-size: 14px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-main span { font-size: 12.5px; color: var(--sub); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hl-side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: 3px; }
.hl-side time { font-size: 11.5px; color: var(--dim); }
.hl-badge { font-style: normal; min-width: 18px; height: 18px; line-height: 18px; padding: 0 5px; border-radius: 9px; background: var(--badge); color: #fff; font-size: 11px; font-weight: 700; text-align: center; }
html:is([data-theme="white"], [data-theme="dark"]) .hl-badge { color: var(--bg); }
.hl-row.td { align-items: flex-start; }
.hl-row.td .todo-box { margin-top: 3px; }
.td-t { font-weight: 500 !important; }
.hl-row.td.done .todo-box { opacity: 1; background: var(--sub); border-color: var(--sub); color: var(--list, var(--bg)); }
.hl-row.td.done .td-t { color: var(--dim, var(--sub)); text-decoration: line-through; }
.pri { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin: 0 6px 1px 0; vertical-align: middle; }
.pri.p-high, .todo-box.p-high { color: var(--pri-high); background-color: transparent; }
.pri.p-high { background: var(--pri-high); }
.pri.p-mid { background: var(--pri-mid); }
.todo-box.p-mid { color: var(--pri-mid); }
.pri.p-low { background: var(--pri-low); }
.todo-box.p-low { color: var(--pri-low); }
.todo-box.p-high, .todo-box.p-mid, .todo-box.p-low { opacity: .9; }

/* 고정한 미리보기 */
.pins { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.pin { position: relative; border-radius: 12px; background: var(--field); padding: 10px 12px 12px; min-width: 0; display: flex; flex-direction: column; gap: 8px; max-height: 260px; overflow: hidden; }
html[data-theme="dark"] .pin { background: #262626; }
.pin-head { display: flex; align-items: center; gap: 8px; min-width: 0; text-align: left; padding-right: 22px; }
.pin-head b { font-size: 13.5px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pin-head small { font-size: 12px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.pin-head .av.xs { width: 22px; height: 22px; border-radius: 7px; }
.pin-ic { width: 22px; height: 22px; flex: none; border-radius: 7px; background: var(--doc-ic-bg); color: var(--doc-ic); display: grid; place-items: center; }
.pin-ic .ic { width: 13px; height: 13px; }
.pin-x { position: absolute; top: 8px; right: 8px; width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; color: var(--dim); opacity: 0; transition: opacity var(--t); }
.pin:hover .pin-x, .pin-x:focus-visible { opacity: 1; }
.pin-x:hover { background: var(--hover); color: var(--text); }
.pin-x .ic { width: 14px; height: 14px; }
@media (hover: none) { .pin-x { opacity: 1; } }
.pin-bubbles { display: flex; flex-direction: column; gap: 4px; cursor: pointer; }
.pb { display: flex; align-items: flex-end; gap: 6px; max-width: 100%; }
.pb.me { flex-direction: row-reverse; }
.pb span { padding: 5px 10px; border-radius: 12px; background: var(--card); font-size: 13px; line-height: 1.4; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; word-break: break-word; }
.pb.me span { background: var(--mine); color: var(--on-mine); }
html[data-theme="white"] .pb.me span { background: #e9e9e9; }
html[data-theme="dark"] .pb span { background: #303030; }
html[data-theme="dark"] .pb.me span { background: #3a3a3a; }
.pb time { flex: none; font-size: 10.5px; color: var(--dim); }
.pin-doc-body { font-size: 13px; line-height: 1.55; color: var(--text); cursor: pointer; overflow: hidden; -webkit-mask-image: linear-gradient(#000 80%, transparent); mask-image: linear-gradient(#000 80%, transparent); }
.pin-doc-body p { margin: 0 0 3px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.pin-doc-body .hp-h { font-weight: 700; }
.pin-doc-body .hp-li { display: flex; gap: 6px; -webkit-line-clamp: 1; }
.pin-doc-body .hp-li > span { flex: none; color: var(--sub); }
.pin-doc-body .hp-li.done { color: var(--dim); text-decoration: line-through; }
.hp-box { width: 13px; height: 13px; margin-top: 3px; border-radius: 4px; box-shadow: 0 0 0 1.4px var(--sub) inset; display: grid; place-items: center; }
.hp-box .ic { width: 11px; height: 11px; }
.pin-doc-body pre { margin: 0 0 4px; padding: 6px 8px; border-radius: 6px; background: var(--card); font-size: 12px; white-space: pre-wrap; overflow: hidden; }
.pin-doc-body .hp-dim { color: var(--dim); }
.pin-empty { width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px; padding: 22px; border-radius: 12px; box-shadow: 0 0 0 1.5px var(--line) inset; color: var(--sub); font-size: 14px; }
.pin-empty:hover { background: var(--hover); color: var(--text); }
.pin-empty .ic { width: 18px; height: 18px; }

/* 기기 제어 */
.dev + .dev { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.dev-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.dev-ic { width: 32px; height: 32px; border-radius: 9px; background: var(--field); color: var(--sub); display: grid; place-items: center; flex: none; }
.dev-ic .ic { width: 18px; height: 18px; }
.dev-name { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.dev-name b { font-size: 14px; font-weight: 600; }
.dev-name small { font-size: 12px; color: var(--dim); }
.dv-st { flex: none; font-size: 12px; font-weight: 600; padding: 3px 8px; border-radius: 999px; }
.dv-st.ok { color: #1a7f37; background: rgba(26, 127, 55, .1); }
.dv-st.wait { color: #b45309; background: rgba(245, 158, 11, .14); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="white"]) .dv-st.ok { color: #4ade80; } :root:not([data-theme="white"]) .dv-st.wait { color: #fbbf24; } }
html[data-theme="dark"] .dv-st.ok { color: #4ade80; }
html[data-theme="dark"] .dv-st.wait { color: #fbbf24; }
.dev-hint { margin: 2px 0 6px; font-size: 12.5px; color: #b45309; }
html[data-theme="dark"] .dev-hint { color: #fbbf24; }
.dev-rows { display: flex; flex-direction: column; }
.dv-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 40px; font-size: 14px; }
.dv-row + .dv-row { border-top: 1px solid var(--line); }
.dv-row.col { flex-direction: column; align-items: stretch; gap: 6px; padding: 8px 0; }
.dev-usage { display: flex; flex-wrap: wrap; gap: 4px 12px; margin-top: 6px; font-size: 12.5px; color: var(--sub); }
.dev-usage b { color: var(--text); font-weight: 600; }
.dev-empty, .mail-empty { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; padding: 14px 8px 8px; color: var(--sub); }
.dev-empty .ic, .mail-empty .ic { width: 28px; height: 28px; color: var(--dim); }
.dev-empty p, .mail-empty p { margin: 0; font-size: 13.5px; line-height: 1.5; }
/* 스위치 (iOS 처럼) */
input.sw { appearance: none; -webkit-appearance: none; flex: none; width: 42px; height: 25px; border-radius: 13px; background: var(--active); position: relative; cursor: pointer; transition: background var(--t) var(--ease); margin: 0; box-shadow: 0 0 0 1px var(--line) inset; }
input.sw::after { content: ''; position: absolute; top: 2.5px; left: 2.5px; width: 20px; height: 20px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .25); transition: transform var(--t) var(--ease); }
input.sw:checked { background: #34c759; box-shadow: none; }
input.sw:checked::after { transform: translateX(17px); }
input.sw:disabled { opacity: .45; cursor: default; }
/* 고르기 (나란히 버튼) */
.segm { display: flex; padding: 3px; border-radius: 10px; background: var(--field); gap: 2px; }
.segm button { flex: 1; height: 30px; border-radius: 8px; font-size: 13px; color: var(--sub); white-space: nowrap; padding: 0 8px; }
.segm button.on { background: var(--card); color: var(--text); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .12); }
html[data-theme="dark"] .segm button.on { background: #424242; }
.segm button:disabled { opacity: .45; cursor: default; }
.stepper { display: inline-flex; align-items: center; gap: 2px; border-radius: 9px; background: var(--field); padding: 2px; }
.stepper button { width: 28px; height: 28px; border-radius: 7px; font-size: 16px; color: var(--sub); }
.stepper button:hover:not(:disabled) { background: var(--card); color: var(--text); }
.stepper b { min-width: 52px; text-align: center; font-size: 13px; font-weight: 600; }

/* 메일 */
.hl-row.mail { align-items: flex-start; }
.mail-sub { color: var(--text) !important; font-size: 13px !important; }
.mail-foot { display: flex; justify-content: space-between; align-items: center; margin-top: 6px; font-size: 13px; }
.mail-foot a { color: var(--link); text-decoration: none; }
.btn-primary.sm { padding: 7px 14px; font-size: 13.5px; }
html:is([data-theme="white"], [data-theme="dark"]) .mail-empty .btn-primary { background: var(--text); color: var(--bg); }

/* 미리보기 고르기 */
.pick-card { width: min(460px, 100%); padding: 18px 0 8px; gap: 10px; }
.pick-card h3 { padding: 0 20px; }
.pick-field { margin: 0 14px; border: 0; border-radius: 10px; background: var(--field); padding: 0 12px; }
.ask-card .pick-field input { flex: 1; background: none; padding: 10px 0; box-shadow: none; }
.pick-list { max-height: min(56vh, 460px); overflow-y: auto; padding: 0 8px 6px; }
.pk-doc { display: flex; align-items: center; }
.pk { flex: 1; min-width: 0; width: 100%; display: flex; align-items: center; gap: 10px; padding: 7px 10px; border-radius: 9px; text-align: left; font-size: 14px; }
.pk:hover { background: var(--hover); }
.pk > span:not(.pk-ic):not(.pk-on):not(.av) { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pk .av.xs { width: 24px; height: 24px; border-radius: 7px; }
.pk-ic { width: 24px; height: 24px; flex: none; border-radius: 7px; background: var(--doc-ic-bg); color: var(--doc-ic); display: grid; place-items: center; }
.pk-ic .ic { width: 14px; height: 14px; }
.pk-h { padding-left: calc(18px + var(--lv, 1) * 14px); font-size: 13.5px; color: var(--sub); }
.pk-h .pk-ic { background: none; }
.pk-on { flex: none; color: #34c759; display: grid; }
.pk-on .ic { width: 18px; height: 18px; stroke-width: 2.4; }
.pk-fold { flex: none; display: inline-flex; align-items: center; gap: 2px; height: 28px; padding: 0 8px; border-radius: 7px; color: var(--dim); font-size: 12px; }
.pk-fold:hover { background: var(--hover); color: var(--text); }
.pk-fold .ic { width: 14px; height: 14px; transition: transform var(--t) var(--ease); }
.pk-fold.open .ic { transform: rotate(90deg); }

/* 설정 (iOS 그룹 카드처럼) */
.modal.set-drop { display: block; padding: 0; background: rgba(0, 0, 0, .12); }
.set-drop .set-card { width: min(400px, calc(100vw - 24px)); }
[data-me-av] { cursor: pointer; }
.hv-title-in, .hc-title-in { font: inherit; color: var(--text); background: var(--hover); border: 0; border-radius: 8px; padding: 2px 8px; margin-left: -8px; outline: none; min-width: 0; }
.hv-title-in { font-size: 24px; font-weight: 800; letter-spacing: -.03em; width: min(420px, 100%); }
.hc-title-in { font-size: 15px; font-weight: 700; letter-spacing: -.02em; flex: 1; }
.hv-title-in:focus, .hc-title-in:focus { box-shadow: 0 0 0 2px var(--line) inset; }
.hv-head-main { min-width: 0; flex: 1; }
.set-card { width: min(440px, 100%); gap: 6px; background: var(--rail); max-height: 84vh; overflow-y: auto; }
.set-card > * { flex-shrink: 0; } /* 길어지면 줄이 눌려 잘리지 않고 스크롤 */
html[data-theme="dark"] .set-card { background: #181818; }
.set-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.set-x { width: 32px; height: 32px; }
.set-sec { font-size: 12px; font-weight: 600; color: var(--dim); padding: 8px 4px 2px; }
.set-group { background: var(--card); border-radius: 12px; overflow: hidden; box-shadow: 0 0 0 1px var(--line); }
.set-links { margin-top: 12px; }
.set-group + .set-group { margin-top: 12px; }
.set-row { width: 100%; display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 14px; text-align: left; font-size: 14.5px; cursor: pointer; }
button.set-row:hover { background: var(--hover); }
.set-row + .set-row { border-top: 1px solid var(--line); }
.set-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.set-main b { font-weight: 500; }
.set-main small { font-size: 12.5px; color: var(--dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.set-av { width: 36px; height: 36px; border-radius: 50%; overflow: hidden; background: var(--mine); color: var(--on-mine); display: grid; place-items: center; font-weight: 700; flex: none; }
html:is([data-theme="white"], [data-theme="dark"]) .set-av { background: var(--text); color: var(--bg); }
.set-av img { width: 100%; height: 100%; object-fit: cover; }
.set-go { color: var(--dim); display: grid; }
.set-go .ic { width: 16px; height: 16px; }
.set-row.danger { color: var(--danger); justify-content: center; }
.set-row.danger .set-main { align-items: center; }
.segm.wide { flex: 1; }
.set-row select { border: 0; outline: none; background: var(--field); border-radius: 9px; padding: 7px 10px; font: inherit; font-size: 14px; color: var(--text); }

/* ── 좁은 창 */
@media (max-width: 899px) {
  .app.doc-mode .topbar { padding-left: 8px; }
  .hv-in { padding: 18px 16px 48px; }
  .hv-head h1 { font-size: 20px; }
  .hv-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .pins { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .tb-extra { display: none; } /* 공지 · 가이드는 설정 안에서 */
  .tb-doc .crumbs { display: none; }
  .tb-doc .pg-acts { margin-left: auto; }
  .head-big { width: 34px; }
}
/* 사진·파일: 채팅방 이름 바로 옆 (채팅방일 때만) */
.tb-media { flex: none; margin-left: 2px; }
.app.home-mode .tb-media, .app.doc-mode .tb-media { display: none; }
.topbar .room-title { flex: 0 1 auto; }
.topbar .head-actions { margin-left: auto; }
.app.home-mode .topbar .tb-global { margin-left: auto; }
.dv-feat { padding: 2px 0 6px; border-bottom: 1px solid var(--line); margin-bottom: 4px; }
.dv-feat:last-of-type { border-bottom: 0; }
.dv-row small { display: block; font-size: 12px; color: var(--sub); margin-top: 1px; }
.dv-sub { font-size: 12.5px; color: var(--sub); margin: 10px 0 2px; }
/* 문서 안 위젯 블록 */
.pg-prose .hw-box { position: relative; margin: 10px 0; border-radius: 16px; }
.pg-prose .hw { user-select: none; }
.pg-prose .doc-col > .hw-box:first-child { margin-top: 0; }
.pg-prose.ProseMirror-focused .hw-box.ProseMirror-selectednode { outline: 2px solid var(--doc-blue, #0C66E4); outline-offset: 2px; }
/* 배경색: 표 칸 색과 같은 엷은 색을 카드 위에 얹는다 */
.hw-box { --hw-gray: rgba(9, 30, 66, .07); --hw-blue: rgba(12, 102, 228, .13); --hw-green: rgba(31, 132, 90, .15); --hw-yellow: rgba(226, 178, 3, .2); --hw-red: rgba(201, 55, 44, .14); --hw-purple: rgba(110, 93, 198, .15); }
html[data-theme="dark"] .hw-box { --hw-gray: rgba(255, 255, 255, .08); --hw-blue: rgba(87, 157, 255, .18); --hw-green: rgba(75, 206, 151, .16); --hw-yellow: rgba(245, 205, 71, .16); --hw-red: rgba(248, 113, 104, .17); --hw-purple: rgba(159, 143, 239, .2); }
@media (prefers-color-scheme: dark) { :root:not([data-theme="white"]):not([data-theme="kakao"]) .hw-box { --hw-gray: rgba(255, 255, 255, .08); --hw-blue: rgba(87, 157, 255, .18); --hw-green: rgba(75, 206, 151, .16); --hw-yellow: rgba(245, 205, 71, .16); --hw-red: rgba(248, 113, 104, .17); --hw-purple: rgba(159, 143, 239, .2); } }
.hw-box[data-color] > .hc { background-image: linear-gradient(var(--hw-tint), var(--hw-tint)); }
.hw-box[data-color="gray"] { --hw-tint: var(--hw-gray); }
.hw-box[data-color="blue"] { --hw-tint: var(--hw-blue); }
.hw-box[data-color="green"] { --hw-tint: var(--hw-green); }
.hw-box[data-color="yellow"] { --hw-tint: var(--hw-yellow); }
.hw-box[data-color="red"] { --hw-tint: var(--hw-red); }
.hw-box[data-color="purple"] { --hw-tint: var(--hw-purple); }
/* 고르면: 테두리 + 손잡이 8개 + 위의 색 도구줄 (고칠 때 · 넓은 화면만) */
.hw-deco { display: none; }
.pg-prose.ProseMirror-focused .hw-box.ProseMirror-selectednode > .hw-deco:not([hidden]) { display: block; }
.hw-h { position: absolute; z-index: 4; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%; background: var(--card); box-shadow: 0 0 0 1.5px var(--doc-blue, #0C66E4), 0 1px 3px rgba(9, 30, 66, .2); }
.hw-h[data-d="nw"] { left: 0; top: 0; cursor: nwse-resize; }
.hw-h[data-d="n"] { left: 50%; top: 0; cursor: ns-resize; }
.hw-h[data-d="ne"] { left: 100%; top: 0; cursor: nesw-resize; }
.hw-h[data-d="e"] { left: 100%; top: 50%; cursor: ew-resize; }
.hw-h[data-d="se"] { left: 100%; top: 100%; cursor: nwse-resize; }
.hw-h[data-d="s"] { left: 50%; top: 100%; cursor: ns-resize; }
.hw-h[data-d="sw"] { left: 0; top: 100%; cursor: nesw-resize; }
.hw-h[data-d="w"] { left: 0; top: 50%; cursor: ew-resize; }
.hw-bar { position: absolute; z-index: 5; left: 0; bottom: calc(100% + 10px); display: flex; align-items: center; gap: 6px; padding: 6px 8px; border-radius: 10px; background: var(--card); box-shadow: 0 4px 16px rgba(9, 30, 66, .18), 0 0 0 1px var(--line); white-space: nowrap; }
.hw-c { width: 18px; height: 18px; border-radius: 50%; box-shadow: 0 0 0 1px rgba(0, 0, 0, .08) inset; }
/* 색 점은 진하게 (고르면 카드에는 엷게 깔림) */
.hw-c[data-c="gray"] { background: #8590a2; }
.hw-c[data-c="blue"] { background: #579dff; }
.hw-c[data-c="green"] { background: #4bce97; }
.hw-c[data-c="yellow"] { background: #f5cd47; }
.hw-c[data-c="red"] { background: #f87168; }
.hw-c[data-c="purple"] { background: #9f8fef; }
.hw-c.none { background: linear-gradient(135deg, transparent 45%, var(--dim) 45%, var(--dim) 55%, transparent 55%), var(--h-card); }
.hw-c:hover { transform: scale(1.12); }
.hw-c.on { box-shadow: 0 0 0 1px var(--line) inset, 0 0 0 2px var(--card), 0 0 0 3.5px var(--doc-blue, #0C66E4); }
.hw-sep { width: 1px; height: 16px; background: var(--line); }
.hw-auto { width: 24px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--sub); }
.hw-auto:hover { background: var(--hover); color: var(--text); }
.hw-auto .ic { width: 15px; height: 15px; }
.hw-sep[hidden], .hw-auto[hidden] { display: none; }
@media (min-width: 900px) {
  .pg-prose[contenteditable="true"] .hw-box > .hc { cursor: default; }
  .pg-prose[contenteditable="true"] .hw-box > .hc > .hc-head { cursor: move; }
  /* 자유 배치: 본문이 판이 되고 위젯은 x·y·w·h 자리에 */
  .pg-prose.hw-board { position: relative; }
  .pg-prose.hw-board .doc-cols-wrap, .pg-prose.hw-board .doc-cols, .pg-prose.hw-board .doc-col { position: static; }
  .pg-prose.hw-board .doc-cols-wrap:not(:has(.doc-col > :not(.hw-box.free))) { margin: 0; }
  .pg-prose.hw-board .doc-cols-wrap:not(:has(.doc-col > :not(.hw-box.free))) > .cols-btn { display: none; }
  .pg-prose.hw-board .doc-col:not(:has(> :not(.hw-box.free))) { outline: 0; }
  .pg-prose .hw-box.free { position: absolute; z-index: 1; margin: 0 !important; }
  .pg-prose .hw-box.free.ProseMirror-selectednode { z-index: 3; }
  .pg-prose .hw-box.free > .hc { height: 100%; display: flex; flex-direction: column; overflow: hidden; }
  .pg-prose .hw-box.free > .hc > .hc-body { flex: 1; min-height: 0; overflow-x: hidden; overflow-y: auto; scrollbar-width: thin; margin: 0 -8px; padding: 0 8px; }
  .pg-prose .hw-box.moving, .pg-prose .hw-box.moving .hc-head { cursor: grabbing; }
  .pg-prose .hw-box.moving > .hc { box-shadow: 0 12px 32px rgba(9, 30, 66, .18), 0 0 0 1px var(--h-line); }
}
/* 좁은 화면: 자리 무시, 위아래로 쌓기, 고치기 없음 */
@media (max-width: 899px) {
  .pg-prose.hw-board { min-height: 0 !important; }
  .pg-prose .hw-box { left: auto !important; top: auto !important; width: auto !important; height: auto !important; }
  .hw-deco { display: none !important; }
}

/* 문서 아이콘: 앱과 같은 그림 (avatars/doc.webp) */
#rooms .tr.top .tr-ic, #rooms .tr.top.on .tr-ic, .hl-ic { background: url(avatars/doc.webp) center / contain no-repeat; }
#rooms .tr.top .tr-ic .ic, .hl-ic .ic { visibility: hidden; }
.set-note { margin: 0; padding: 2px 16px 14px; font-size: 12.5px; line-height: 1.5; color: var(--dim); word-break: keep-all; }
