/* =======================================================
   Sticky Board — 스타일
   ======================================================= */
:root {
  --bg: #eef0f4;
  --bg-dot: #d5d9e0;
  --surface: #ffffff;
  --surface-2: #f4f6f9;
  --surface-3: #e9ecf2;
  --border: #dfe3ea;
  --border-strong: #c7cdd8;
  --text: #1c2026;
  --text-dim: #6b7280;
  --accent: #3b6cff;
  --accent-soft: #e7edff;
  --danger: #e5484d;
  --ok: #22a06b;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .07), 0 1px 3px rgba(16, 24, 40, .1);
  --shadow-md: 0 6px 16px rgba(16, 24, 40, .12);
  --shadow-lg: 0 16px 36px rgba(16, 24, 40, .2), 0 2px 6px rgba(16, 24, 40, .1);
  --r: 9px;
  --card-r: 12px;
  --tint: 7%;              /* 아이템 강조색을 배경에 섞는 비율 */
  --topbar-h: 54px;
  --side-w: 216px;
}
html[data-theme="dark"] {
  --bg: #14161b;
  --bg-dot: #292d36;
  --surface: #1d2027;
  --surface-2: #23262e;
  --surface-3: #2b2f38;
  --border: #32363f;
  --border-strong: #464c58;
  --text: #e7e9ec;
  --text-dim: #99a0ab;
  --accent: #7093ff;
  --accent-soft: #23304f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .45);
  --shadow-md: 0 6px 18px rgba(0, 0, 0, .5);
  --shadow-lg: 0 18px 40px rgba(0, 0, 0, .6);
  --tint: 16%;             /* 어두운 배경에서는 색을 조금 더 섞어야 구분됩니다 */
}
body.side-collapsed { --side-w: 46px; }

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body {
  font-family: Pretendard, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo",
               "Malgun Gothic", sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: none; cursor: pointer; }
.ico { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================== 상단 바 ===================== */
.topbar {
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative; z-index: 100;
}
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 14.5px; white-space: nowrap; }
.logo {
  width: 24px; height: 24px; border-radius: 7px; flex: none;
  background: linear-gradient(140deg, var(--accent), #7c5cff);
  box-shadow: var(--shadow-sm);
  position: relative;
}
.logo::after {
  content: ""; position: absolute; left: 6px; right: 6px; top: 7px; height: 2px;
  background: rgba(255, 255, 255, .85); border-radius: 1px;
  box-shadow: 0 4px 0 rgba(255, 255, 255, .85), 0 8px 0 rgba(255, 255, 255, .55);
}
.title-input {
  width: 170px; min-width: 90px;
  padding: 5px 8px; border-radius: 7px;
  border: 1px solid transparent; background: transparent;
  font-weight: 600; font-size: 13.5px;
}
.title-input:hover { background: var(--surface-2); }
.title-input:focus { outline: none; background: var(--surface); border-color: var(--accent); }

.spacer { flex: 1 1 auto; }
.divider { width: 1px; height: 22px; background: var(--border); flex: none; }

.btn {
  height: 32px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface);
  font-size: 12.5px; font-weight: 600;
  display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn.icon { width: 32px; padding: 0; justify-content: center; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { filter: brightness(1.08); }
.btn.toggle.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }

.seg {
  display: flex; gap: 2px; padding: 2px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 9px;
}
.seg button { width: 30px; height: 26px; border-radius: 6px; display: grid; place-items: center; color: var(--text-dim); }
.seg button:hover { background: var(--surface-3); color: var(--text); }
.seg button.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }
.seg .ico { width: 18px; height: 18px; }

.field {
  display: flex; align-items: center; gap: 6px; height: 32px; padding: 0 9px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px;
}
.field:focus-within { border-color: var(--accent); background: var(--surface); }
.field .ico { opacity: .5; width: 14px; height: 14px; }
.field input { border: none; outline: none; background: transparent; width: 130px; font-size: 12.5px; }

.conn {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--text-dim);
  padding: 0 8px; height: 32px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2);
  white-space: nowrap;
}
.conn .pulse { width: 7px; height: 7px; border-radius: 50%; background: var(--text-dim); }
.conn.on .pulse { background: var(--ok); box-shadow: 0 0 0 0 rgba(34, 160, 107, .6); animation: pulse 2.2s infinite; }
.conn.off .pulse { background: var(--danger); }
@keyframes pulse { 70% { box-shadow: 0 0 0 6px rgba(34, 160, 107, 0); } 100% { box-shadow: 0 0 0 0 rgba(34, 160, 107, 0); } }

/* 아바타 */
.avatar {
  width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center;
  font-size: 10.5px; font-weight: 700; color: #fff;
  border: 2px solid var(--surface); user-select: none; flex: none;
}
.avatar.sm { width: 19px; height: 19px; font-size: 9px; border: none; }
.members { display: flex; align-items: center; }
.members .avatar { margin-left: -7px; cursor: pointer; transition: transform .12s, opacity .12s; }
.members .avatar:first-child { margin-left: 0; }
.members .avatar:hover { transform: translateY(-2px); z-index: 3; }
.members .avatar.off { opacity: .3; filter: grayscale(.6); }
.members .avatar.me { box-shadow: 0 0 0 2px var(--accent); }

/* ===================== 사이드바 ===================== */
.sidebar {
  position: absolute; left: 0; top: var(--topbar-h); bottom: 0; width: var(--side-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 90;
  transition: width .14s ease;
}
.side-head {
  display: flex; align-items: center; gap: 6px;
  height: 38px; padding: 0 8px 0 6px; flex: none;
  border-bottom: 1px solid var(--border);
}
.side-toggle, .side-add {
  width: 28px; height: 26px; border-radius: 6px;
  display: grid; place-items: center; color: var(--text-dim); flex: none;
}
.side-toggle:hover, .side-add:hover { background: var(--surface-2); color: var(--text); }
.side-title { font-size: 11.5px; font-weight: 700; color: var(--text-dim); flex: 1; letter-spacing: .3px; }

.side-list { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 6px; }
.side-item {
  display: flex; align-items: center; gap: 7px;
  height: 32px; padding: 0 4px 0 7px; margin-bottom: 2px;
  border-radius: 7px; cursor: pointer; position: relative;
  border: 1px solid transparent;
}
.side-item:hover { background: var(--surface-2); }
.side-item.active { background: var(--accent-soft); border-color: var(--accent); }
.side-item.active .side-name { font-weight: 700; color: var(--accent); }
.side-ico { color: var(--text-dim); display: grid; place-items: center; flex: none; }
.side-item.active .side-ico { color: var(--accent); }
.side-ico .ico { width: 14px; height: 14px; }
.side-name { flex: 1; font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-more {
  width: 20px; height: 20px; border-radius: 5px; flex: none;
  color: var(--text-dim); opacity: 0; line-height: 1;
}
.side-item:hover .side-more { opacity: 1; }
.side-more:hover { background: var(--surface-3); color: var(--text); }
.side-rename {
  flex: 1; min-width: 0; height: 24px; padding: 0 6px;
  border: 1px solid var(--accent); border-radius: 5px;
  background: var(--surface); font-size: 12.5px; outline: none;
}
.side-item.dragging { opacity: .4; }
.side-item.drop-before::before,
.side-item.drop-after::after {
  content: ""; position: absolute; left: 4px; right: 4px; height: 2px;
  background: var(--accent); border-radius: 1px;
}
.side-item.drop-before::before { top: -2px; }
.side-item.drop-after::after { bottom: -2px; }

.side-foot {
  flex: none; padding: 8px 10px; border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim);
}

.sidebar.collapsed .side-title,
.sidebar.collapsed .side-add,
.sidebar.collapsed .side-name,
.sidebar.collapsed .side-more,
.sidebar.collapsed .side-foot { display: none; }
.sidebar.collapsed .side-item { justify-content: center; padding: 0; }
.sidebar.collapsed .side-head { justify-content: center; padding: 0; }

.side-menu { position: fixed; }

/* ===================== 분할 스테이지 ===================== */
#stage {
  position: absolute; inset: var(--topbar-h) 0 0 var(--side-w);
  background: var(--border);
  transition: left .14s ease;
}

.pane {
  position: absolute; overflow: hidden;
  background-color: var(--board-bg, var(--bg));
  background-image: radial-gradient(var(--board-dot, var(--bg-dot)) 1.4px, transparent 1.4px);
  background-size: 24px 24px;
  cursor: grab; touch-action: none;
  contain: strict;
}
.pane.no-grid { background-image: none; }
.pane.panning { cursor: grabbing; }
.pane.active-pane { box-shadow: inset 0 0 0 2px var(--accent); }
.pane-canvas { position: absolute; top: 0; left: 0; width: 0; height: 0; transform-origin: 0 0; }

.pane-hud {
  position: absolute; left: 8px; bottom: 8px; z-index: 40;
  display: flex; align-items: center; gap: 1px; padding: 3px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 9px; box-shadow: var(--shadow-sm);
  opacity: .45; transition: opacity .15s;
}
.pane:hover .pane-hud, .pane.active-pane .pane-hud { opacity: 1; }
.pane-hud button { width: 26px; height: 24px; border-radius: 6px; display: grid; place-items: center; color: var(--text-dim); }
.pane-hud button:hover { background: var(--surface-2); color: var(--text); }
.pane-hud .zoom { min-width: 44px; text-align: center; font-size: 11px; font-variant-numeric: tabular-nums; color: var(--text-dim); cursor: pointer; }
.pane-hud .zoom:hover { color: var(--text); }
.pane-hud .ico { width: 14px; height: 14px; }

.pane-tag {
  position: absolute; right: 8px; top: 8px; z-index: 40;
  font-size: 10.5px; font-weight: 700; color: var(--text-dim);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 6px; padding: 2px 7px; opacity: .5; pointer-events: none;
}
.pane:hover .pane-tag { opacity: 1; }
.split-none .pane-tag { display: none; }

.pane-empty {
  position: absolute; inset: 0; display: grid; place-content: center; justify-items: center;
  gap: 5px; text-align: center; color: var(--text-dim); pointer-events: none; padding: 20px;
}
.pane-empty .big { font-size: 15px; font-weight: 600; color: var(--text); }
.pane-empty .emoji { font-size: 30px; }
/* 작성자 스타일의 display 가 UA 의 [hidden] 규칙을 이기므로 명시적으로 눌러 줍니다. */
.pane-empty[hidden] { display: none; }

.splitter { position: absolute; z-index: 60; background: var(--border-strong); }
.splitter::before { content: ""; position: absolute; inset: -3px; }
.splitter::after {
  content: ""; position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%); border-radius: 3px; background: var(--surface); opacity: .8;
}
.splitter.v { width: 4px; top: 0; bottom: 0; cursor: col-resize; }
.splitter.v::after { width: 2px; height: 26px; }
.splitter.h { height: 4px; left: 0; right: 0; cursor: row-resize; }
.splitter.h::after { width: 26px; height: 2px; }
.splitter:hover, .splitter.dragging { background: var(--accent); }

/* ===================== 아이템 (모던 카드) ===================== */
.item {
  position: absolute;
  display: flex; flex-direction: column;
  --item-accent: #64748b;
  border-radius: var(--card-r);
  color: var(--text);
  transition: box-shadow .15s ease, border-color .15s ease, opacity .15s;
}

/* 메모 — 파스텔 종이 대신 옅은 배경 + 얇은 테두리 + 왼쪽 강조 띠 */
.item[data-type="note"] {
  background: color-mix(in srgb, var(--item-accent) var(--tint), var(--surface));
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
/* overflow:hidden 을 쓰지 않습니다 — 선택 테두리·핀·떠 있는 도구가 카드 밖에 그려지므로. */
.item[data-type="note"]::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 3px;
  background: var(--item-accent); pointer-events: none;
  border-radius: var(--card-r) 0 0 var(--card-r);
}
.item[data-type="note"]:hover { box-shadow: var(--shadow-md); }
.item[data-type="note"].active { border-color: var(--item-accent); }

.item.dragging, .item.sizing { box-shadow: var(--shadow-lg); }
.item.dimmed { opacity: .16; }
.item.hit { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft), var(--shadow-md); }

/* --- 선택 테두리 --- */
.item-ring {
  position: absolute; inset: -3px; border-radius: calc(var(--card-r) + 3px);
  pointer-events: none; display: none;
}
.item.selected > .item-ring {
  display: block;
  box-shadow: 0 0 0 2px var(--accent);
}
/* 남이 고른 것은 그 사람 색으로, 점선으로 구분합니다 */
.item.peer-selected > .item-ring {
  display: block;
  outline: 2px dashed var(--peer-color, var(--text-dim));
  outline-offset: 1px;
}
.item.selected.peer-selected > .item-ring {
  box-shadow: 0 0 0 2px var(--accent);
  outline-offset: 4px;
}
.item-owner {
  position: absolute; left: -3px; bottom: calc(100% + 6px);
  max-width: 140px; padding: 1px 7px;
  font-size: 10.5px; font-weight: 700; line-height: 1.6;
  color: #fff; background: var(--peer-color, var(--text-dim));
  border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: none; pointer-events: none;
}
.item.peer-selected > .item-owner { display: block; }

/* --- 머리줄 --- */
.note-bar {
  height: 30px; flex: none;
  display: flex; align-items: center; gap: 6px;
  padding: 0 6px 0 11px;
  cursor: grab;
}
.item.dragging .note-bar { cursor: grabbing; }
.note-bar .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.note-bar .who {
  font-size: 11.5px; font-weight: 600; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 45%;
}

.palette { margin-left: auto; display: flex; gap: 4px; opacity: 0; transition: opacity .12s; }
.item:hover .palette, .item:focus-within .palette { opacity: 1; }
.palette i {
  width: 10px; height: 10px; border-radius: 3px; cursor: pointer; display: block;
  transition: transform .1s;
}
.palette i:hover { transform: scale(1.4); }

.note-acts { display: flex; gap: 1px; opacity: 0; transition: opacity .12s; flex: none; }
.item:hover .note-acts, .item:focus-within .note-acts { opacity: 1; }
.note-acts button {
  width: 21px; height: 21px; border-radius: 6px;
  display: grid; place-items: center; color: var(--text-dim);
}
.note-acts button:hover { background: var(--surface-3); color: var(--text); }
.note-acts button.del:hover { background: var(--danger); color: #fff; }
.note-acts button.pin.on { background: var(--accent-soft); color: var(--accent); }
.note-acts .ico { width: 12px; height: 12px; }

.note-title {
  flex: none; width: 100%;
  padding: 2px 12px 4px; border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 15px; font-weight: 700; color: var(--text);
  letter-spacing: -.2px;
}
.note-title::placeholder { color: var(--text-dim); opacity: .6; }

.note-body {
  flex: 1; width: 100%; min-height: 0;
  padding: 2px 12px 8px;
  border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 13.5px; line-height: 1.6; color: var(--text);
  overflow: auto; word-break: break-word; cursor: text;
}
.item.empty-body .note-body::before {
  content: attr(data-placeholder);
  color: var(--text-dim); opacity: .65;
  pointer-events: none; position: absolute;
}

/* --- 본문 안 서식 --- */
.note-body a {
  color: var(--accent); text-decoration: underline; text-underline-offset: 2px;
  cursor: pointer; word-break: break-all;
}
.note-body a:hover { background: var(--accent-soft); border-radius: 3px; }
.note-body ul, .note-body ol { margin: 4px 0; padding-left: 20px; }
.note-body li { margin: 2px 0; }
.note-body code {
  background: var(--surface-3); border-radius: 4px; padding: 1px 4px;
  font-family: Consolas, "D2Coding", monospace; font-size: .9em;
}

/* --- 체크리스트 --- */
.note-body ul[data-list="check"] { list-style: none; padding-left: 1px; }
.note-body ul[data-list="check"] > li {
  position: relative; padding-left: 23px; list-style: none;
}
.note-body ul[data-list="check"] > li::before {
  content: ""; position: absolute; left: 0; top: .3em;
  width: 14px; height: 14px; border-radius: 4px;
  border: 1.6px solid var(--border-strong);
  background: var(--surface);
  cursor: pointer; transition: background .12s, border-color .12s;
}
.note-body ul[data-list="check"] > li:hover::before { border-color: var(--accent); }
.note-body ul[data-list="check"] > li[data-checked="true"]::before {
  background: var(--ok); border-color: var(--ok);
}
.note-body ul[data-list="check"] > li[data-checked="true"]::after {
  content: ""; position: absolute; left: 4.6px; top: calc(.3em + 3.4px);
  width: 4px; height: 7px;
  border-right: 2px solid #fff; border-bottom: 2px solid #fff;
  transform: rotate(42deg); pointer-events: none;
}
.note-body ul[data-list="check"] > li[data-checked="true"] {
  color: var(--text-dim); text-decoration: line-through;
}

.note-foot {
  height: 22px; flex: none;
  display: flex; align-items: center; gap: 6px;
  padding: 0 11px 5px; font-size: 10.5px; color: var(--text-dim);
  user-select: none; cursor: grab;
}
.note-foot .size { margin-left: auto; font-variant-numeric: tabular-nums; opacity: 0; transition: opacity .12s; }
.item.sizing .note-foot .size, .item:hover .note-foot .size { opacity: 1; }

/* --- 종류별 --- */
.item[data-variant="author"] .note-title { display: none; }
.item[data-variant="titled"] .note-bar .who { display: none; }
.item[data-variant="titled"] .note-bar { height: 26px; }

/* 그냥 네모 — 머리줄 없이 사각형만, 도구는 호버할 때 위에 떠오릅니다 */
.item[data-variant="plain"] .note-title,
.item[data-variant="plain"] .note-foot,
.item[data-variant="plain"] .note-bar .who,
.item[data-variant="plain"] .note-bar .dot { display: none; }
.item[data-variant="plain"] .note-bar {
  position: absolute; left: -1px; right: -1px; top: -34px; height: 30px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 9px;
  box-shadow: var(--shadow-md);
  opacity: 0; pointer-events: none; padding: 0 6px;
  z-index: 7;
}
.item[data-variant="plain"]:hover .note-bar,
.item[data-variant="plain"]:focus-within .note-bar { opacity: 1; pointer-events: auto; }
.item[data-variant="plain"] .note-acts { opacity: 1; margin-left: auto; }
.item[data-variant="plain"] .palette { opacity: 1; margin-left: 0; }
.item[data-variant="plain"] .note-body { padding: 10px 12px; }

/* --- 핀 고정 --- */
.pinned {
  position: absolute; top: -8px; right: -6px; font-size: 14px;
  display: none; pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .25));
}
.item.locked .pinned { display: block; }
.item.locked .rz { display: none; }
.item.locked .note-bar, .item.locked .note-foot { cursor: not-allowed; }
.item.shake { animation: shake .34s ease; }
@keyframes shake {
  20% { transform: translateX(-4px); } 45% { transform: translateX(4px); }
  70% { transform: translateX(-2px); } 100% { transform: translateX(0); }
}

/* ===================== 사진 ===================== */
.item[data-type="image"] { box-shadow: var(--shadow-sm); }
.item[data-type="image"]:hover { box-shadow: var(--shadow-md); }
.item-img {
  width: 100%; height: 100%; display: block;
  border-radius: var(--card-r);
  object-fit: contain; user-select: none; -webkit-user-drag: none;
  background: var(--surface-2);
}
.item-broken {
  position: absolute; inset: 0;
  display: grid; place-content: center; justify-items: center; gap: 6px;
  font-size: 26px; color: var(--text-dim);
  background: var(--surface-2); border: 1px dashed var(--border);
  border-radius: var(--card-r);
}
.item-broken span { font-size: 11.5px; }
.item-broken[hidden] { display: none; }

/* ===================== 도형 ===================== */
/* 도형은 모양 자체가 테두리라, 선택 테두리만 바짝 붙게 반경을 줄입니다. */
.item[data-type="shape"] { border-radius: 0; --card-r: 3px; }
.item-shape { position: absolute; inset: 0; }
.item-shape svg { width: 100%; height: 100%; display: block; overflow: visible; }
.shape-label {
  position: absolute; inset: 0;
  display: grid; place-content: center; text-align: center;
  padding: 8px; font-size: 13.5px; font-weight: 600; line-height: 1.35;
  outline: none; word-break: break-word; pointer-events: none;
  white-space: pre-line;   /* 라벨의 줄바꿈을 그대로 보여 줍니다 */
  text-shadow: 0 1px 2px rgba(0, 0, 0, .18);
}
.shape-label[contenteditable="plaintext-only"] {
  pointer-events: auto; cursor: text;
  background: rgba(255, 255, 255, .18); border-radius: 3px;
}

/* 링크가 걸린 아이템 */
.item-link {
  position: absolute; top: -10px; left: -10px; z-index: 6;
  width: 20px; height: 20px; border-radius: 50%;
  display: none; place-items: center;
  font-size: 10px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.item.has-link .item-link { display: grid; }
.item.has-link[data-type="image"] { cursor: pointer; }
.item.has-link[data-type="shape"] { cursor: pointer; }
.item-link:hover { border-color: var(--accent); transform: scale(1.12); }

/* --- 8방향 리사이즈 핸들 --- */
.rz { position: absolute; z-index: 5; }
.rz.n  { top: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.rz.s  { bottom: -4px; left: 8px; right: 8px; height: 8px; cursor: ns-resize; }
.rz.w  { left: -4px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.rz.e  { right: -4px; top: 8px; bottom: 8px; width: 8px; cursor: ew-resize; }
.rz.nw { top: -4px; left: -4px; width: 14px; height: 14px; cursor: nwse-resize; }
.rz.ne { top: -4px; right: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
.rz.sw { bottom: -4px; left: -4px; width: 14px; height: 14px; cursor: nesw-resize; }
.rz.se { bottom: -2px; right: -2px; width: 18px; height: 18px; cursor: nwse-resize; }
.rz.se::after {
  content: ""; position: absolute; right: 4px; bottom: 4px; width: 7px; height: 7px;
  border-right: 2px solid rgba(0, 0, 0, .25); border-bottom: 2px solid rgba(0, 0, 0, .25);
  border-radius: 0 0 2px 0;
}

/* ===================== 팝오버 ===================== */
.pop {
  position: absolute; top: calc(var(--topbar-h) - 4px); right: 12px;
  min-width: 230px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 11px; box-shadow: var(--shadow-lg); z-index: 200;
}
.pop[hidden] { display: none; }
.pop .row {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 7px 9px; border-radius: 7px; font-size: 13px; text-align: left;
}
.pop .row:hover { background: var(--surface-2); }
.pop .row.danger { color: var(--danger); }
.pop .row .check { flex: none; color: var(--accent); font-weight: 700; }
.pop .row .plus { font-size: 15px; color: var(--accent); width: 19px; text-align: center; }
.pop .sep { height: 1px; background: var(--border); margin: 4px 3px; }
.pop .label { font-size: 11px; font-weight: 700; color: var(--text-dim); padding: 5px 9px; }
.pop .member-row { cursor: pointer; }
.pop .member-row.current { background: var(--accent-soft); }
.pop .mini {
  width: 22px; height: 22px; border-radius: 6px; flex: none;
  color: var(--text-dim); font-size: 12px; opacity: 0;
}
.pop .member-row:hover .mini { opacity: 1; }
.pop .mini:hover { background: var(--surface-3); color: var(--text); }
.pop .mini.remove:hover { background: var(--danger); color: #fff; }
.pop .mini.ok { width: auto; padding: 0 9px; opacity: 1; background: var(--accent); color: #fff; font-weight: 700; }
.pop .member-row.editing { flex-wrap: wrap; background: var(--surface-2); }
.inline-input {
  flex: 1 1 100%; height: 28px; padding: 0 8px; margin-bottom: 6px;
  border: 1px solid var(--accent); border-radius: 6px; background: var(--surface); outline: none; font-size: 13px;
}
kbd {
  font: inherit; font-size: 10px; color: var(--text-dim);
  background: var(--surface-2); border: 1px solid var(--border); border-bottom-width: 2px;
  border-radius: 4px; padding: 0 4px; flex: none;
}

/* ===================== 로그인 · 가입 ===================== */
.auth-dialog { width: min(400px, 100%); }
.auth-tabs {
  display: flex; gap: 3px; padding: 3px; margin-bottom: 16px;
  background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px;
}
.auth-tab {
  flex: 1; height: 32px; border-radius: 7px;
  font-size: 13px; font-weight: 700; color: var(--text-dim);
}
.auth-tab:hover { color: var(--text); }
.auth-tab.on { background: var(--surface); color: var(--accent); box-shadow: var(--shadow-sm); }

.auth-form { display: flex; flex-direction: column; gap: 11px; }
.auth-form[hidden] { display: none; }
.field-row { display: flex; flex-direction: column; gap: 5px; }
.field-row > span:first-child { font-size: 11.5px; font-weight: 700; color: var(--text-dim); }
.field-row input {
  height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); color: var(--text); outline: none; font-size: 13.5px;
}
.field-row input:focus { border-color: var(--accent); background: var(--surface); }
.name-row { display: grid; grid-template-columns: 1fr 1.6fr; gap: 9px; }
.btn.block { width: 100%; height: 40px; justify-content: center; font-size: 13.5px; margin-top: 3px; }
.auth-hint { margin: 0; font-size: 11.5px; color: var(--text-dim); line-height: 1.5; }
.auth-hint.tight { margin-top: -4px; }

/* 계정 메뉴 */
.acc-head {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 9px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px;
}
.acc-who { display: flex; flex-direction: column; min-width: 0; }
.acc-who b { font-size: 13.5px; }
.acc-who small { font-size: 11px; color: var(--text-dim); }
.acc-form { display: flex; flex-direction: column; gap: 8px; padding: 4px 6px 6px; }
.acc-form .field-row input { height: 32px; font-size: 12.5px; }
.acc-actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 4px; }
.acc-actions .btn { height: 30px; }

/* ===================== 시작 화면 (이름 고르기) ===================== */
.overlay {
  position: fixed; inset: 0; z-index: 500;
  background: rgba(12, 15, 22, .55);
  backdrop-filter: blur(3px);
  display: grid; place-items: center; padding: 20px;
  animation: fade .16s ease-out;
}
@keyframes fade { from { opacity: 0; } }
.dialog {
  width: min(480px, 100%);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; box-shadow: var(--shadow-lg);
  padding: 22px; animation: pop .18s ease-out;
}
@keyframes pop { from { opacity: 0; transform: translateY(10px) scale(.98); } }
.dialog-head { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 18px; }
.dialog-head .logo { width: 34px; height: 34px; border-radius: 10px; }
.dialog h2 { margin: 0 0 3px; font-size: 17px; }
.dialog p { margin: 0; font-size: 12.5px; color: var(--text-dim); line-height: 1.5; }
.dialog-section + .dialog-section { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.dialog-label { font-size: 11.5px; font-weight: 700; color: var(--text-dim); margin-bottom: 8px; }
.dialog-empty { font-size: 12.5px; color: var(--text-dim); padding: 6px 2px; }
.dialog-error { margin-top: 9px; font-size: 12.5px; color: var(--danger); }

.member-grid { display: flex; flex-wrap: wrap; gap: 7px; }
.member-card {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px 7px 7px;
  border: 1px solid var(--border); border-radius: 999px;
  background: var(--surface-2); font-size: 13px; font-weight: 600;
  transition: border-color .12s, transform .1s;
}
.member-card:hover { border-color: var(--accent); transform: translateY(-1px); }
.member-card .avatar { border: none; }

.new-member { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.new-member input {
  flex: 1 1 180px; height: 36px; padding: 0 11px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); outline: none; font-size: 13.5px;
}
.new-member input:focus { border-color: var(--accent); background: var(--surface); }
.new-member .btn { height: 36px; }

.swatches { display: flex; gap: 5px; flex-wrap: wrap; }
.swatches.tight { gap: 4px; }
.swatch {
  width: 20px; height: 20px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .15); transition: transform .1s;
}
.swatches.tight .swatch { width: 16px; height: 16px; }
.swatch:hover { transform: scale(1.15); }
.swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* ===================== 조회 모드 ===================== */
/* 기본값이 조회 모드입니다 — 상단바와 사이드바를 걷어내고 보드만 남깁니다. */
html[data-mode="view"] .topbar,
html[data-mode="view"] .sidebar { display: none; }
html[data-mode="view"] #stage { inset: 0; }
html[data-mode="view"] #toasts { left: 50%; }

/* 편집을 암시하는 장식도 모두 숨깁니다. */
html[data-mode="view"] .note-acts,
html[data-mode="view"] .palette,
html[data-mode="view"] .rz,
html[data-mode="view"] .note-foot .size,
html[data-mode="view"] .pane-tag { display: none !important; }
html[data-mode="view"] .note-bar { cursor: default; }
html[data-mode="view"] .note-foot { cursor: default; }
html[data-mode="view"] .item[data-variant="plain"] .note-bar { display: none; }
html[data-mode="view"] .item:hover { box-shadow: var(--shadow-sm); }
html[data-mode="view"] .item[data-type="image"]:hover::after,
html[data-mode="view"] .item[data-type="shape"]:hover::after { box-shadow: none; }
html[data-mode="view"] .note-body { cursor: default; }
/* 체크박스와 링크는 조회 모드에서도 눌립니다 — 유일하게 허용된 상호작용입니다. */
html[data-mode="view"] .note-body ul[data-list="check"] > li::before { cursor: pointer; }
html[data-mode="view"] .note-body a { cursor: pointer; }
html[data-mode="view"] .pane-hud { opacity: 0; }
html[data-mode="view"] .pane:hover .pane-hud { opacity: .85; }
html[data-mode="view"] .pane-hud [data-act="only"] { display: none; }

/* 조회 모드에서 상단바 대신 남는 유일한 버튼 */
.edit-fab {
  position: fixed; right: 18px; bottom: 18px; z-index: 320;
  display: none; align-items: center; gap: 7px;
  height: 40px; padding: 0 16px 0 14px;
  border-radius: 999px;
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  font-size: 13px; font-weight: 700;
  opacity: .55;
  transition: opacity .15s, transform .12s;
}
html[data-mode="view"] .edit-fab { display: inline-flex; }
.edit-fab:hover { opacity: 1; transform: translateY(-1px); }
.edit-fab .ico { width: 15px; height: 15px; }

html[data-mode="edit"] .edit-fab { display: none; }

/* ===================== 보드 배경색 ===================== */
.pane[data-bg="default"]  { --board-bg: var(--bg);      --board-dot: var(--bg-dot); }
.pane[data-bg="paper"]    { --board-bg: #f7f5f0;        --board-dot: #ddd8cd; }
.pane[data-bg="warm"]     { --board-bg: #fdf3ec;        --board-dot: #e8d5c6; }
.pane[data-bg="mint"]     { --board-bg: #eef7f2;        --board-dot: #cbe4d7; }
.pane[data-bg="sky"]      { --board-bg: #eef3fb;        --board-dot: #cddcf0; }
.pane[data-bg="lavender"] { --board-bg: #f3f0fb;        --board-dot: #d9d1f0; }
.pane[data-bg="rose"]     { --board-bg: #fdf0f3;        --board-dot: #f0cfd8; }
.pane[data-bg="slate"]    { --board-bg: #eceef1;        --board-dot: #d0d5dc; }
.pane[data-bg="ink"]      { --board-bg: #1f2937;        --board-dot: #37455a; }

html[data-theme="dark"] .pane[data-bg="paper"]    { --board-bg: #1b1a17; --board-dot: #302d27; }
html[data-theme="dark"] .pane[data-bg="warm"]     { --board-bg: #1e1815; --board-dot: #362b25; }
html[data-theme="dark"] .pane[data-bg="mint"]     { --board-bg: #141d19; --board-dot: #24352d; }
html[data-theme="dark"] .pane[data-bg="sky"]      { --board-bg: #141a24; --board-dot: #24303f; }
html[data-theme="dark"] .pane[data-bg="lavender"] { --board-bg: #1a1724; --board-dot: #2e2840; }
html[data-theme="dark"] .pane[data-bg="rose"]     { --board-bg: #211519; --board-dot: #3a252c; }
html[data-theme="dark"] .pane[data-bg="slate"]    { --board-bg: #16181c; --board-dot: #292d34; }
html[data-theme="dark"] .pane[data-bg="ink"]      { --board-bg: #101722; --board-dot: #1f2c3d; }

/* 어두운 배경(ink · 직접 고른 어두운 색) 위에서는 카드 색을 더 섞어 구분되게 합니다. */
.pane.dark-board .item[data-type="note"] { --tint: 12%; }

/* ===================== 자유색 ===================== */
/* 프리셋 옆에 붙는 무지개 버튼 — 누르면 브라우저 색 선택기가 열립니다. */
.custom-color {
  position: relative; flex: none;
  width: 18px; height: 18px; border-radius: 50%;
  cursor: pointer; overflow: hidden;
  background: conic-gradient(#ef4444, #eab308, #22c55e, #06b6d4, #3b82f6, #a855f7, #ec4899, #ef4444);
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .45);
  transition: transform .1s;
}
.custom-color.compact { width: 11px; height: 11px; border-radius: 3px; }
.custom-color:hover { transform: scale(1.2); }
.custom-color.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--accent); }
.custom-color.on::after {
  content: ""; position: absolute; inset: 2px; border-radius: inherit;
  background: var(--picked, transparent);
}
.custom-color.compact.on::after { inset: 1.5px; }
/* 실제 input 은 보이지 않게 덮어 둡니다 (클릭 영역은 유지). */
.custom-color input[type="color"] {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: none; padding: 0; cursor: pointer; background: none;
}
.recent-colors { display: flex; gap: 3px; align-items: center; }
.fb-colors .custom-color.compact { width: 15px; height: 15px; border-radius: 50%; }

.bg-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; padding: 4px 6px 7px; }
.bg-swatch {
  height: 46px; border-radius: 8px;
  border: 1.5px solid var(--border);
  display: grid; align-items: end; justify-items: center;
  padding-bottom: 3px; overflow: hidden;
  background-color: var(--board-bg, var(--bg));
  background-image: radial-gradient(var(--board-dot, var(--bg-dot)) 1.3px, transparent 1.3px);
  background-size: 9px 9px;
  transition: transform .1s, border-color .12s;
}
.bg-swatch:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.bg-swatch.on { border-color: var(--accent); border-width: 2px; }
.bg-name {
  font-size: 10px; font-weight: 700; color: var(--text);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  border-radius: 4px; padding: 0 4px;
}
.bg-swatch[data-bg="ink"] .bg-name { color: #fff; background: rgba(0, 0, 0, .45); }

/* ===================== 우클릭 메뉴 ===================== */
.ctxmenu {
  position: fixed; z-index: 450;
  min-width: 210px; max-width: 280px; padding: 5px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  animation: pop .12s ease-out;
}
.ctx-title {
  font-size: 10.5px; font-weight: 700; color: var(--text-dim);
  padding: 5px 9px 3px; letter-spacing: .3px;
}
.ctx-row {
  width: 100%; display: flex; align-items: center; gap: 8px;
  padding: 6px 9px; border-radius: 7px; font-size: 12.5px; text-align: left;
}
.ctx-row:hover:not(.disabled) { background: var(--surface-2); }
.ctx-row.danger { color: var(--danger); }
.ctx-row.disabled { opacity: .4; cursor: default; }
.ctx-icon { width: 16px; text-align: center; flex: none; font-size: 12px; }
.ctx-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ctx-hint { font-size: 10.5px; color: var(--text-dim); flex: none; }
.ctx-sep { height: 1px; background: var(--border); margin: 4px 3px; }

.ctx-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px; padding: 3px 6px 6px; }
.ctx-grid.wide { grid-template-columns: repeat(4, 34px); }
.ctx-shape {
  aspect-ratio: 1; border-radius: 6px; padding: 5px;
  border: 1px solid transparent; color: var(--text-dim);
}
.ctx-shape svg { width: 100%; height: 100%; display: block; }
.ctx-shape:hover { background: var(--surface-2); }
.ctx-shape.on { border-color: var(--accent); background: var(--accent-soft); }

.ctx-paint { display: flex; align-items: center; gap: 3px; flex-wrap: wrap; padding: 3px 6px 6px; }
.ctx-paint-label { font-size: 11px; color: var(--text-dim); width: 42px; flex: none; }
.ctx-swatch {
  width: 16px; height: 16px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(127, 127, 127, .5); transition: transform .1s;
}
.ctx-swatch:hover { transform: scale(1.2); }
.ctx-swatch.on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 3.5px var(--accent); }
.ctx-swatch.none {
  background-image: linear-gradient(45deg, transparent 44%, var(--danger) 44%, var(--danger) 56%, transparent 56%);
}

/* 사진 끌어다 놓기 */
#stage.drop-target::after {
  content: "여기에 놓으면 사진이 들어갑니다";
  position: absolute; inset: 6px; z-index: 200;
  display: grid; place-content: center;
  font-size: 14px; font-weight: 700; color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
  border: 2.5px dashed var(--accent); border-radius: 12px;
  pointer-events: none;
}

/* 하이퍼링크 창 */
.link-dialog { width: min(430px, 100%); }
.link-emoji { font-size: 26px; line-height: 1; }
.link-dialog input {
  width: 100%; height: 38px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 9px;
  background: var(--surface-2); outline: none; font-size: 13.5px;
}
.link-dialog input:focus { border-color: var(--accent); background: var(--surface); }
.link-dialog input.bad { border-color: var(--danger); }
.dialog-hint { margin-top: 7px; font-size: 11.5px; color: var(--text-dim); }
.dialog-actions { display: flex; align-items: center; gap: 8px; margin-top: 18px; }

/* ===================== 서식 막대 ===================== */
.formatbar {
  position: fixed; z-index: 400;
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px;
  padding: 4px; max-width: min(560px, 96vw);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  user-select: none;
}
.formatbar[hidden] { display: none; }
.fb-btn {
  min-width: 26px; height: 26px; padding: 0 5px;
  border-radius: 6px; color: var(--text-dim);
  display: inline-grid; place-items: center; font-size: 13px;
}
.fb-btn:hover { background: var(--surface-2); color: var(--text); }
.fb-btn b, .fb-btn i, .fb-btn u, .fb-btn s { font-size: 13px; line-height: 1; color: var(--text); }
.fb-btn .ico { width: 15px; height: 15px; }
.fb-btn.ok { background: var(--accent); color: #fff; font-weight: 700; padding: 0 10px; }
.fb-sep { width: 1px; height: 18px; background: var(--border); margin: 0 3px; flex: none; }
.fb-select {
  height: 26px; padding: 0 4px; font-size: 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2); color: var(--text); outline: none; cursor: pointer;
}
.fb-select.size { width: 62px; }
.fb-colors { display: flex; gap: 3px; padding: 0 2px; }
.fb-color {
  width: 15px; height: 15px; border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, .2); transition: transform .1s;
}
.fb-color:hover { transform: scale(1.25); }
.fb-linkrow { display: flex; gap: 4px; width: 100%; padding: 4px 2px 2px; }
.fb-linkrow[hidden] { display: none; }
.fb-linkrow input {
  flex: 1; height: 28px; padding: 0 9px; font-size: 12.5px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface-2); color: var(--text); outline: none;
}
.fb-linkrow input:focus { border-color: var(--accent); background: var(--surface); }
.fb-linkrow input.bad { border-color: var(--danger); }

/* ===================== 토스트 ===================== */
#toasts {
  position: absolute; left: calc(50% + var(--side-w) / 2); bottom: 20px; transform: translateX(-50%);
  display: flex; flex-direction: column-reverse; gap: 8px; align-items: center; z-index: 300;
}
.toast {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 13px; font-size: 13px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg);
  animation: rise .18s ease-out;
}
.toast button { color: var(--accent); font-weight: 700; font-size: 13px; }
.toast.err { border-color: var(--danger); color: var(--danger); }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } }

@media (max-width: 1280px) {
  .btn .lbl, .brand-name { display: none; }
  .title-input { width: 120px; }
  .field input { width: 90px; }
  .conn #connText { display: none; }
}
