/* ===== 색상 / 기본 ===== */
:root {
  --bg: #ffffff;
  --bg-sidebar: #f7f7f5;
  --bg-hover: rgba(55, 53, 47, 0.07);
  --bg-active: rgba(55, 53, 47, 0.11);
  --bg-elevated: #ffffff;
  --bg-code: #f7f6f3;
  --bg-callout: #f1f1ef;
  --bg-inline-code: rgba(135, 131, 120, 0.15);
  --text: #37352f;
  --text-2: rgba(55, 53, 47, 0.65);
  --text-3: rgba(55, 53, 47, 0.42);
  --border: rgba(55, 53, 47, 0.12);
  --accent: #2383e2;
  --accent-bg: rgba(35, 131, 226, 0.12);
  --danger: #d44c47;
  --success: #448361;
  --warn: #cb912f;
  --inline-code: #eb5757;
  --shadow: 0 0 0 1px rgba(15, 15, 15, 0.05), 0 3px 6px rgba(15, 15, 15, 0.1), 0 9px 24px rgba(15, 15, 15, 0.2);
  --font: ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Apple SD Gothic Neo", "Pretendard", "Malgun Gothic", "Noto Sans KR", sans-serif;
  --mono: "SFMono-Regular", Menlo, Consolas, "D2Coding", "Liberation Mono", monospace;
  --sidebar-w: 260px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #191919;
    --bg-sidebar: #202020;
    --bg-hover: rgba(255, 255, 255, 0.055);
    --bg-active: rgba(255, 255, 255, 0.09);
    --bg-elevated: #252525;
    --bg-code: #262626;
    --bg-callout: #2a2a2a;
    --bg-inline-code: rgba(135, 131, 120, 0.25);
    --text: rgba(255, 255, 255, 0.84);
    --text-2: rgba(255, 255, 255, 0.55);
    --text-3: rgba(255, 255, 255, 0.32);
    --border: rgba(255, 255, 255, 0.1);
    --accent: #529cca;
    --accent-bg: rgba(82, 156, 202, 0.2);
    --danger: #e0706b;
    --inline-code: #ff7369;
    --shadow: 0 0 0 1px rgba(255, 255, 255, 0.06), 0 3px 6px rgba(0, 0, 0, 0.3), 0 9px 24px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
kbd {
  font-family: var(--font);
  font-size: 11px;
  color: var(--text-3);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 5px;
  white-space: nowrap;
}
.boot-loading { display: grid; place-items: center; height: 100vh; color: var(--text-2); gap: 12px; grid-auto-flow: column; }

/* ===== 버튼 ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--bg-elevated);
  font-size: 14px; font-weight: 500;
  transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: .45; cursor: default; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent); filter: brightness(1.08); }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: var(--danger); filter: brightness(1.08); }
.btn-block { width: 100%; height: 40px; font-size: 15px; }
.icon-btn {
  display: inline-grid; place-items: center;
  width: 28px; height: 28px; border: 0; border-radius: 5px;
  background: transparent; color: var(--text-2); font-size: 16px;
}
.icon-btn:hover { background: var(--bg-hover); color: var(--text); }
.ghost-btn {
  border: 0; background: transparent; color: var(--text-3);
  padding: 4px 8px; border-radius: 5px; font-size: 14px;
}
.ghost-btn:hover { background: var(--bg-hover); color: var(--text-2); }
.link-btn { border: 0; background: none; color: var(--text-2); font-size: 13px; padding: 2px 6px; border-radius: 4px; }
.link-btn:hover { background: var(--bg-hover); }

/* ===== 로그인 / 회원가입 ===== */
.auth-screen {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: var(--bg-sidebar);
}
.auth-card {
  width: 100%; max-width: 380px; background: var(--bg); border-radius: 14px;
  padding: 36px 32px 28px; box-shadow: 0 1px 2px rgba(0,0,0,.04), 0 8px 30px rgba(0,0,0,.06);
  border: 1px solid var(--border);
}
.auth-logo { color: var(--text); margin-bottom: 14px; }
.auth-card h1 { font-size: 24px; margin: 0 0 6px; letter-spacing: -0.02em; }
.auth-sub { margin: 0 0 24px; color: var(--text-2); font-size: 14px; }
.auth-form { display: flex; flex-direction: column; gap: 14px; }
.field label { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field input {
  width: 100%; height: 40px; padding: 0 12px;
  border: 1px solid var(--border); border-radius: 7px; background: var(--bg);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.field input.invalid { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 12.5px; margin-top: 5px; min-height: 0; }
.field-error:empty { display: none; }
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 64px; }
.pw-toggle {
  position: absolute; right: 6px; top: 6px; height: 28px; padding: 0 8px;
  border: 0; background: transparent; color: var(--text-2); font-size: 12.5px; border-radius: 5px;
}
.pw-toggle:hover { background: var(--bg-hover); }
.form-error { color: var(--danger); font-size: 13.5px; }
.form-error:empty { display: none; }
.auth-switch { text-align: center; font-size: 14px; color: var(--text-2); margin: 20px 0 0; }
.auth-switch a { color: var(--accent); text-decoration: none; font-weight: 600; }
.auth-switch a:hover { text-decoration: underline; }

/* ===== 앱 레이아웃 ===== */
.app-shell { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
  width: var(--sidebar-w); flex: none; background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; overflow: hidden;
  transition: margin-left .2s ease, transform .2s ease;
  font-size: 14px;
}
.app-shell.sb-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sb-backdrop { display: none; }

.sb-top { display: flex; align-items: center; gap: 4px; padding: 8px 8px 4px 8px; }
.sb-user {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  border: 0; background: transparent; padding: 6px 8px; border-radius: 6px; text-align: left;
  font-weight: 600; font-size: 14px;
}
.sb-user:hover { background: var(--bg-hover); }
.avatar {
  width: 22px; height: 22px; flex: none; border-radius: 5px;
  background: var(--text); color: var(--bg); display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.sb-user-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.caret { color: var(--text-3); font-size: 10px; }
.sb-collapse { opacity: 0; }
.sidebar:hover .sb-collapse { opacity: 1; }

.sb-actions { padding: 2px 8px 6px; display: flex; flex-direction: column; }
.sb-action {
  display: flex; align-items: center; gap: 8px; width: 100%;
  border: 0; background: transparent; color: var(--text-2);
  padding: 5px 10px; border-radius: 6px; text-align: left; font-size: 14px;
}
.sb-action:hover { background: var(--bg-hover); color: var(--text); }
.sb-action kbd { margin-left: auto; }
.sb-action-icon { width: 18px; text-align: center; font-size: 15px; }
.sb-section { padding: 12px 18px 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }

.sb-scroll { flex: 1; overflow-y: auto; min-height: 0; }
.tree { padding: 0 8px 8px; }
.fav-list { padding: 0 8px 4px; }
.tree.drop-end { box-shadow: inset 0 -2px 0 var(--accent); }
.tree-none { color: var(--text-3); padding: 6px 12px; font-size: 13px; }
.tree-item {
  position: relative; display: flex; align-items: center; gap: 4px;
  height: 30px; padding-left: calc(4px + var(--depth, 0) * 16px); padding-right: 4px;
  border-radius: 6px; color: var(--text-2); cursor: pointer; user-select: none;
}
.tree-item:hover { background: var(--bg-hover); }
.tree-item.active { background: var(--bg-active); color: var(--text); font-weight: 600; }
.tree-item.dragging { opacity: .4; }
.tree-item.drop-inside { background: var(--accent-bg); box-shadow: inset 0 0 0 1px var(--accent); }
.tree-item.drop-before::before, .tree-item.drop-after::after {
  content: ''; position: absolute; left: 8px; right: 8px; height: 2px; background: var(--accent); border-radius: 2px;
}
.tree-item.drop-before::before { top: -1px; }
.tree-item.drop-after::after { bottom: -1px; }
.tree-toggle {
  width: 20px; height: 20px; flex: none; border: 0; background: transparent; border-radius: 4px;
  color: var(--text-3); font-size: 8px; display: grid; place-items: center; transition: transform .12s;
}
.tree-toggle:hover { background: var(--bg-active); color: var(--text); }
.tree-toggle.open { transform: rotate(90deg); }
.tree-toggle.empty { opacity: .55; }
.tree-icon { width: 20px; flex: none; text-align: center; font-size: 15px; }
.tree-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-actions { display: none; gap: 2px; }
.tree-item:hover .tree-actions { display: flex; }
.tree-btn {
  width: 22px; height: 22px; border: 0; background: transparent; border-radius: 4px;
  color: var(--text-2); font-size: 15px; line-height: 1; display: grid; place-items: center;
}
.tree-btn:hover { background: var(--bg-active); color: var(--text); }
.tree-empty { padding-left: calc(30px + var(--depth, 0) * 16px); color: var(--text-3); font-size: 13px; height: 28px; line-height: 28px; }
.sb-add-bottom {
  border: 0; background: transparent; color: var(--text-3); text-align: left;
  padding: 10px 18px; font-size: 14px; border-top: 1px solid var(--border);
}
.sb-add-bottom:hover { background: var(--bg-hover); color: var(--text-2); }

/* 상단 바 */
.topbar {
  height: 46px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px;
}
.menu-btn { display: none; }
.app-shell.sb-collapsed .menu-btn { display: inline-grid; }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 2px; overflow: hidden; font-size: 14px; }
.crumb {
  display: inline-flex; align-items: center; gap: 5px; min-width: 0;
  padding: 2px 6px; border-radius: 5px; color: var(--text); text-decoration: none; white-space: nowrap;
}
.crumb:hover { background: var(--bg-hover); }
.crumb-title { overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.crumb-sep { color: var(--text-3); }
.top-right { display: flex; align-items: center; gap: 8px; flex: none; }
.save-status { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.save-status::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  margin-right: 6px; vertical-align: 1px; background: var(--success);
}
.save-status:empty::before { display: none; }
.save-status.st-dirty::before { background: var(--warn); }
.save-status.st-saving::before { background: var(--accent); animation: pulse 1s infinite; }
.save-status.st-error, .save-status.st-conflict { color: var(--danger); }
.save-status.st-error::before, .save-status.st-conflict::before { background: var(--danger); }
@keyframes pulse { 50% { opacity: .3; } }
.btn-save { height: 28px; padding: 0 12px; font-size: 13px; }
.btn-save.attention { border-color: var(--accent); color: var(--accent); }
.btn-save.done { border-color: var(--success); color: var(--success); }

/* ===== 페이지 ===== */
.scroller { flex: 1; overflow-y: auto; overflow-x: hidden; }
.page-wrap { padding: 0 96px 30vh; }
.page { max-width: 760px; margin: 0 auto; }
.page-header { padding-top: 72px; }
.page-header.has-icon { padding-top: 40px; }
.page-icon-row { display: flex; align-items: flex-end; gap: 4px; min-height: 28px; margin-left: -8px; }
.page-icon {
  display: none; border: 0; background: transparent; font-size: 64px; line-height: 1;
  padding: 6px; border-radius: 8px;
}
.page-icon:hover { background: var(--bg-hover); }
.has-icon .page-icon { display: block; }
.has-icon .add-icon { display: none; }
.add-icon { opacity: .55; transition: opacity .12s; }
.page-header:hover .add-icon, .add-icon:focus { opacity: 1; }
.page-title {
  font-size: 40px; font-weight: 700; line-height: 1.2; letter-spacing: -0.02em;
  margin: 8px 0 12px; outline: none; word-break: break-word; padding: 3px 2px;
}
.page-title:empty::before { content: attr(data-placeholder); color: var(--text-3); cursor: text; }

.empty-state { text-align: center; padding-top: 18vh; color: var(--text-2); }
.empty-state h2 { color: var(--text); margin: 12px 0 6px; font-size: 22px; }
.empty-state p { margin: 0 0 20px; }
.empty-emoji { font-size: 52px; }

/* ===== 블록 편집기 ===== */
.editor { position: relative; }
.blocks { display: flex; flex-direction: column; }
.block {
  position: relative; display: flex; align-items: flex-start;
  padding-left: calc(var(--indent, 0) * 24px);
  margin: 0; border-radius: 4px; outline: none;
}
.block[hidden] { display: none; }
.block-controls {
  position: absolute; left: calc(var(--indent, 0) * 24px - 50px); top: 0;
  display: flex; align-items: center; gap: 1px;
  opacity: 0; transition: opacity .1s; user-select: none;
}
.block:hover > .block-controls, .block:focus-within > .block-controls { opacity: 1; }
.blk-add, .blk-handle {
  width: 22px; height: 24px; border: 0; background: transparent; border-radius: 4px;
  color: var(--text-3); display: grid; place-items: center;
}
.blk-add { font-size: 19px; line-height: 1; font-weight: 300; }
.blk-handle { cursor: grab; width: 18px; }
.blk-add:hover, .blk-handle:hover { background: var(--bg-hover); color: var(--text-2); }
.blk-handle:active { cursor: grabbing; }
.block.dragging { opacity: .35; }
.drop-line {
  position: absolute; right: 0; height: 4px; border-radius: 2px;
  background: var(--accent); opacity: .7; pointer-events: none; display: none;
}
.drop-line.show { display: block; }

.block-body { flex: 1; min-width: 0; display: flex; align-items: flex-start; }
.text {
  flex: 1; min-width: 0; outline: none; padding: 0 2px;
  white-space: pre-wrap; word-break: break-word; caret-color: var(--text);
  min-height: 1.5em;
}
.text:empty::before { content: attr(data-placeholder); color: var(--text-3); pointer-events: none; }
.b-paragraph .text:empty:not(:focus)::before { content: ''; }
.text b { font-weight: 650; }
.text a { color: inherit; text-decoration: underline; text-decoration-color: var(--text-3); text-underline-offset: 2px; cursor: pointer; }
.text code {
  font-family: var(--mono); font-size: 85%; color: var(--inline-code);
  background: var(--bg-inline-code); border-radius: 4px; padding: 0.2em 0.4em;
}

.b-h1 { margin-top: 1.6em; }
.b-h2 { margin-top: 1.2em; }
.b-h3 { margin-top: 0.9em; }
.b-h1 .text { font-size: 1.875em; font-weight: 700; line-height: 1.3; }
.b-h2 .text { font-size: 1.5em; font-weight: 650; line-height: 1.3; }
.b-h3 .text { font-size: 1.25em; font-weight: 650; line-height: 1.3; }
.b-h1 .block-controls { top: 10px; }
.b-h2 .block-controls { top: 5px; }
.b-h3 .block-controls { top: 3px; }
.b-h1 .text, .b-h2 .text, .b-h3 .text { padding: 2px 2px; }

.marker {
  flex: none; width: 24px; min-height: 24px; display: flex; align-items: flex-start; justify-content: center;
  padding-top: 0; user-select: none;
}
.b-bullet .marker { font-size: 1.2em; line-height: 1.25; }
.marker.num { line-height: 1.5; }
.num { width: auto; min-width: 24px; padding-right: 4px; justify-content: flex-end; font-variant-numeric: tabular-nums; }
.todo-check { width: 16px; height: 16px; margin: 4px 0 0; accent-color: var(--accent); cursor: pointer; }
.b-todo.checked .text { text-decoration: line-through; color: var(--text-3); }

.toggle-arrow {
  flex: none; width: 24px; height: 24px; border: 0; background: transparent; border-radius: 4px;
  color: var(--text); font-size: 10px; display: grid; place-items: center; transition: transform .15s;
}
.toggle-arrow:hover { background: var(--bg-hover); }
.toggle-arrow.open { transform: rotate(90deg); }

.b-quote .block-body { border-left: 3px solid currentColor; padding-left: 14px; margin: 4px 0; }
.b-quote .text { font-size: 1.05em; }

.b-callout .block-body {
  background: var(--bg-callout); border-radius: 6px; padding: 12px 14px 12px 10px; gap: 8px; margin: 4px 0;
}
.callout-icon { flex: none; border: 0; background: transparent; font-size: 20px; line-height: 1; padding: 3px; border-radius: 5px; }
.callout-icon:hover { background: var(--bg-hover); }

.b-code .block-body { flex-direction: column; background: var(--bg-code); border-radius: 6px; padding: 8px 0 0; margin: 4px 0; }
.code-head { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 0 10px 4px; }
.code-lang {
  border: 0; background: transparent; color: var(--text-2); font-size: 12px; padding: 2px 4px; border-radius: 4px; cursor: pointer;
}
.code-lang:hover { background: var(--bg-hover); }
.code-copy { border: 0; background: transparent; color: var(--text-3); font-size: 12px; padding: 2px 8px; border-radius: 4px; opacity: 0; }
.b-code:hover .code-copy { opacity: 1; }
.code-copy:hover { background: var(--bg-hover); color: var(--text-2); }
.code-input {
  width: 100%; border: 0; outline: none; resize: none; background: transparent;
  font-family: var(--mono); font-size: 14px; line-height: 1.55; tab-size: 2;
  padding: 6px 16px 16px; white-space: pre; overflow-x: auto; overflow-y: hidden;
}
.code-input::placeholder { color: var(--text-3); }

.b-divider { padding-top: 6px; padding-bottom: 6px; cursor: pointer; }
.b-divider hr { flex: 1; border: 0; border-top: 1px solid var(--border); margin: 6px 2px; }
.b-divider:focus, .b-page:focus { background: var(--accent-bg); }
.b-page { cursor: pointer; }
.page-link {
  flex: 1; display: flex; align-items: center; gap: 6px; padding: 3px 4px; border-radius: 4px;
  color: var(--text); text-decoration: none; font-weight: 550;
}
.page-link:hover { background: var(--bg-hover); }
.page-link-title { text-decoration: underline; text-decoration-color: var(--border); text-underline-offset: 3px; }
.page-link.missing { color: var(--text-3); cursor: default; }

.editor-tail { min-height: 120px; cursor: text; }

/* ===== 팝오버 / 메뉴 ===== */
.popover {
  position: fixed; z-index: 2500; background: var(--bg-elevated); border-radius: 8px;
  box-shadow: var(--shadow); font-size: 14px;
}
.menu { min-width: 220px; max-height: 70vh; overflow-y: auto; padding: 6px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  border: 0; background: transparent; text-align: left; padding: 6px 8px; border-radius: 5px;
}
.menu-item:hover, .menu-item.active { background: var(--bg-hover); }
.menu-item.danger:hover { color: var(--danger); }
.menu-icon { width: 20px; text-align: center; color: var(--text-2); font-size: 13px; font-weight: 600; }
.menu-label { flex: 1; }
.menu-hint { color: var(--text-3); font-size: 12px; }
.menu-section { padding: 8px 8px 4px; font-size: 12px; color: var(--text-3); font-weight: 600; }
.menu-info { padding: 6px 8px; font-size: 12.5px; color: var(--text-3); }
.menu-divider { height: 1px; background: var(--border); margin: 5px 0; }

.slash-menu { width: 300px; max-height: 340px; overflow-y: auto; padding: 6px; }
.slash-item { display: flex; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 5px; cursor: pointer; }
.slash-item.active { background: var(--bg-hover); }
.slash-icon {
  width: 44px; height: 44px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 6px; background: var(--bg);
  font-weight: 700; font-size: 15px; color: var(--text-2);
}
.slash-text { display: flex; flex-direction: column; min-width: 0; }
.slash-label { font-size: 14px; }
.slash-desc { font-size: 12px; color: var(--text-3); }

.fmt-toolbar { display: flex; padding: 3px; }
.fmt-buttons { display: flex; gap: 1px; }
.fmt-btn {
  min-width: 30px; height: 30px; border: 0; background: transparent; border-radius: 5px; padding: 0 7px;
  font-size: 14px; color: var(--text);
}
.fmt-btn:hover { background: var(--bg-hover); }
.fmt-btn.on { color: var(--accent); background: var(--accent-bg); }
.fmt-b { font-weight: 800; }
.fmt-i { font-style: italic; font-family: Georgia, serif; }
.fmt-u { text-decoration: underline; }
.fmt-s { text-decoration: line-through; }
.fmt-code { font-family: var(--mono); font-size: 12px; }
.fmt-link { font-size: 13px; text-decoration: underline; }
.fmt-link-row { padding: 3px; }
.fmt-link-input {
  width: 300px; height: 30px; border: 1px solid var(--border); border-radius: 5px; padding: 0 8px; outline: none; background: var(--bg);
  font-size: 13.5px;
}
.fmt-link-input:focus { border-color: var(--accent); }

.emoji-picker { width: min(336px, calc(100vw - 16px)); padding: 8px; }
.emoji-head { display: flex; justify-content: space-between; align-items: center; padding: 0 4px 6px; font-size: 12px; color: var(--text-3); font-weight: 600; }
.emoji-tabs { display: flex; gap: 2px; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 6px; overflow-x: auto; }
.emoji-tab { flex: 1; min-width: 32px; height: 32px; border: 0; background: transparent; border-radius: 6px; font-size: 17px; opacity: .55; }
.emoji-tab:hover { background: var(--bg-hover); opacity: .9; }
.emoji-tab.on { background: var(--bg-active); opacity: 1; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; height: 248px; overflow-y: auto; align-content: start; }
.emoji-btn { border: 0; background: transparent; font-size: 22px; height: 38px; border-radius: 6px; padding: 0; line-height: 1; }
.emoji-btn:hover { background: var(--bg-hover); }

/* ===== 오버레이 / 대화상자 / 검색 ===== */
.overlay {
  position: fixed; inset: 0; z-index: 2000; background: rgba(15, 15, 15, 0.45);
  display: flex; align-items: flex-start; justify-content: center; padding: 16vh 16px 16px;
}
.dialog {
  width: 100%; max-width: 420px; background: var(--bg-elevated); border-radius: 12px;
  padding: 22px 22px 18px; box-shadow: var(--shadow);
}
.dialog h3 { margin: 0 0 8px; font-size: 17px; }
.dialog p { margin: 0 0 18px; color: var(--text-2); font-size: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.shortcuts { max-width: 480px; }
.shortcuts table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 14px; }
.shortcuts td { padding: 6px 0; border-bottom: 1px solid var(--border); }
.shortcuts td:last-child { text-align: right; }

.search-box {
  width: 100%; max-width: 620px; background: var(--bg-elevated); border-radius: 12px; box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column; max-height: 70vh;
}
.search-head { display: flex; align-items: center; gap: 10px; padding: 0 16px; border-bottom: 1px solid var(--border); }
.search-glyph { color: var(--text-3); font-size: 20px; }
.search-input { flex: 1; height: 52px; border: 0; outline: none; background: transparent; font-size: 17px; }
.search-results { overflow-y: auto; padding: 6px; }
.search-item { display: flex; gap: 10px; padding: 8px 10px; border-radius: 6px; cursor: pointer; }
.search-item.active { background: var(--bg-hover); }
.search-icon { width: 22px; text-align: center; flex: none; }
.search-body { display: flex; flex-direction: column; min-width: 0; }
.search-title { font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-path { font-weight: 400; color: var(--text-3); font-size: 13px; }
.search-snippet { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-empty { padding: 20px; text-align: center; color: var(--text-3); font-size: 14px; }
.search-foot { padding: 8px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--text-3); }

/* ===== 토스트 ===== */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); z-index: 3000; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
  background: #2f2f2f; color: #fff; padding: 9px 16px; border-radius: 8px; font-size: 14px;
  box-shadow: 0 4px 16px rgba(0,0,0,.2); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s;
}
.toast.show { opacity: 1; transform: none; }
.toast-error { background: var(--danger); }

/* ===== 모바일 ===== */
@media (max-width: 800px) {
  .sidebar {
    position: fixed; z-index: 1500; top: 0; bottom: 0; left: 0; width: min(300px, 86vw);
    transform: translateX(-100%); box-shadow: var(--shadow);
  }
  .app-shell.sb-collapsed .sidebar { margin-left: 0; }
  .app-shell.sb-open .sidebar { transform: none; }
  .app-shell.sb-open .sb-backdrop { display: block; position: fixed; inset: 0; z-index: 1400; background: rgba(0,0,0,.35); }
  .menu-btn, .app-shell.sb-collapsed .menu-btn { display: inline-grid; }
  .sb-collapse { opacity: 1; }
  .page-wrap { padding: 0 20px 40vh 30px; }
  .page-header { padding-top: 28px; }
  .page-title { font-size: 30px; }
  /* 휴대폰: 입력 중인 블록 왼쪽에 ⋮⋮ 손잡이만 보여 블록 메뉴(전환·이모티콘·삭제 등)를 열 수 있게 */
  .block-controls { left: calc(var(--indent, 0) * 24px - 26px); opacity: 0; pointer-events: none; }
  .block.is-current > .block-controls, .block:focus-within > .block-controls { opacity: 1; pointer-events: auto; }
  .blk-add { display: none; }
  .blk-handle { width: 22px; height: 28px; }
  .add-icon { opacity: .8; }
  .save-status { font-size: 0; }
  .save-status::before { margin-right: 0; }
  .crumb-title { max-width: 110px; }
  .tree-actions { display: flex; }
}

/* 문제 안내 화면 */
.problem-tips { margin: 0 0 20px; padding-left: 18px; color: var(--text-2); font-size: 14px; }
.problem-tips li { margin-bottom: 6px; }
a.btn { text-decoration: none; }
ol.problem-tips { padding-left: 20px; }

/* ===== v1.01: 버전 표시 / 보안코드 ===== */
.auth-version { margin: 18px 0 0; text-align: center; font-size: 12px; color: var(--text-3); }
.sb-version { padding: 0 18px 10px; font-size: 11.5px; color: var(--text-3); }
.field-hint { font-size: 12px; color: var(--text-3); margin-top: 5px; }
.captcha-box { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.captcha-img {
  width: 200px; height: 64px; border-radius: 7px; border: 1px solid var(--border);
  background: #f3f2ee; flex: none; max-width: calc(100% - 96px); object-fit: contain;
}
.captcha-refresh { height: 36px; padding: 0 10px; font-size: 13px; white-space: nowrap; }
.captcha-input { text-transform: uppercase; letter-spacing: 0.2em; font-weight: 600; }
.captcha-input::placeholder { text-transform: none; letter-spacing: normal; font-weight: 400; }
.dialog.auth-form { gap: 12px; }
.dialog.auth-form h3, .dialog.auth-form p { margin-bottom: 0; }

/* ===== 관리자 ===== */
.sb-action.active { background: var(--bg-active); color: var(--text); font-weight: 600; }
.admin { max-width: 1000px; margin: 0 auto; padding: 48px 0 40px; }
.admin-loading { color: var(--text-2); padding-top: 60px; text-align: center; }
.admin-head h1 { font-size: 32px; margin: 0 0 4px; letter-spacing: -0.02em; }
.admin-head p { margin: 0 0 24px; color: var(--text-2); }
.admin-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.admin-stat { border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; display: flex; flex-direction: column; gap: 2px; }
.admin-stat-label { font-size: 13px; color: var(--text-2); }
.admin-stat strong { font-size: 22px; font-variant-numeric: tabular-nums; }
.admin-card { border: 1px solid var(--border); border-radius: 10px; padding: 18px 20px; margin-bottom: 16px; }
.admin-card h2 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
.admin-card p { margin: 6px 0 0; color: var(--text-2); font-size: 14px; }
.admin-card-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.admin-search {
  height: 34px; min-width: 220px; padding: 0 10px; border: 1px solid var(--border); border-radius: 7px;
  background: var(--bg); outline: none; font-size: 14px;
}
.admin-search:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.table-scroll { overflow-x: auto; margin: 14px -20px -18px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: 14px; min-width: 760px; }
.admin-table th {
  text-align: left; font-size: 12.5px; font-weight: 600; color: var(--text-2);
  padding: 9px 12px; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); background: var(--bg-sidebar);
}
.admin-table th:first-child, .admin-table td:first-child { padding-left: 20px; }
.admin-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; white-space: nowrap; }
.admin-table tr:last-child td { border-bottom: 0; }
.admin-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.admin-table tr.is-suspended td { color: var(--text-3); }
.admin-user { display: flex; flex-direction: column; }
.admin-user span { font-size: 12.5px; color: var(--text-2); }
.admin-empty { text-align: center; color: var(--text-3); padding: 24px !important; }
.admin-actions { display: flex; gap: 6px; justify-content: flex-end; }
.admin-muted { color: var(--text-3); }
.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.btn-danger-ghost { color: var(--danger); }
.btn-danger-ghost:hover { background: rgba(212, 76, 71, 0.1); }
.pill { display: inline-block; font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; }
.pill-on { background: rgba(68, 131, 97, 0.14); color: var(--success); }
.pill-off { background: rgba(212, 76, 71, 0.12); color: var(--danger); }
.pill-admin { background: var(--accent-bg); color: var(--accent); }

.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: none; cursor: pointer; }
.switch-input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch-track { position: absolute; inset: 0; border-radius: 999px; background: var(--bg-active); transition: background .15s; }
.switch-track::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%;
  background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .15s;
}
.switch-input:checked + .switch-track { background: var(--accent); }
.switch-input:checked + .switch-track::after { transform: translateX(20px); }
.switch-input:focus-visible + .switch-track { box-shadow: 0 0 0 3px var(--accent-bg); }

@media (max-width: 800px) {
  .admin { padding-top: 24px; }
  .admin-stats { grid-template-columns: 1fr 1fr 1fr; gap: 8px; }
  .admin-stat { padding: 10px 12px; }
  .admin-stat strong { font-size: 18px; }
  .admin-search { min-width: 0; width: 100%; }
}

/* ===== v1.02: 글자색 / 배경색 ===== */
.text [data-c="gray"] { color: #787774; }   .text [data-c="brown"] { color: #9f6b53; }
.text [data-c="orange"] { color: #d9730d; } .text [data-c="yellow"] { color: #cb912f; }
.text [data-c="green"] { color: #448361; }  .text [data-c="blue"] { color: #337ea9; }
.text [data-c="purple"] { color: #9065b0; } .text [data-c="pink"] { color: #c14c8a; }
.text [data-c="red"] { color: #d44c47; }
.text [data-bg] { border-radius: 3px; padding: 0 1px; }
.text [data-bg="gray"] { background: #f1f1ef; }   .text [data-bg="brown"] { background: #f4eeee; }
.text [data-bg="orange"] { background: #fbecdd; } .text [data-bg="yellow"] { background: #fbf3db; }
.text [data-bg="green"] { background: #edf3ec; }  .text [data-bg="blue"] { background: #e7f3f8; }
.text [data-bg="purple"] { background: #f6f3f9; } .text [data-bg="pink"] { background: #faf1f5; }
.text [data-bg="red"] { background: #fdebec; }
@media (prefers-color-scheme: dark) {
  .text [data-c="gray"] { color: #9b9b9b; }   .text [data-c="brown"] { color: #ba856f; }
  .text [data-c="orange"] { color: #c77d48; } .text [data-c="yellow"] { color: #ca9849; }
  .text [data-c="green"] { color: #529e72; }  .text [data-c="blue"] { color: #5e87c9; }
  .text [data-c="purple"] { color: #9d68d3; } .text [data-c="pink"] { color: #d15796; }
  .text [data-c="red"] { color: #df5452; }
  .text [data-bg="gray"] { background: #2f2f2f; }   .text [data-bg="brown"] { background: #4a3228; }
  .text [data-bg="orange"] { background: #5c3b23; } .text [data-bg="yellow"] { background: #564328; }
  .text [data-bg="green"] { background: #243d30; }  .text [data-bg="blue"] { background: #143a4e; }
  .text [data-bg="purple"] { background: #3c2d49; } .text [data-bg="pink"] { background: #4e2c3c; }
  .text [data-bg="red"] { background: #522e2a; }
}

/* 우클릭 메뉴 */
.ctx-menu { width: 264px; }
.ctx-fmt { display: flex; gap: 2px; padding: 2px 2px 6px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.ctx-fmt .fmt-btn { flex: 1; }
.fmt-link2 { font-size: 14px; }
.ctx-sub { padding-left: 14px; }
.ctx-sub[hidden] { display: none; }
.color-rows { padding: 2px 4px 2px; }
.color-row { padding: 4px 4px; }
.color-title { font-size: 12px; color: var(--text-3); font-weight: 600; margin-bottom: 4px; }
.color-swatches { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.swatch {
  height: 22px; border: 1px solid var(--border); border-radius: 4px; background: var(--bg);
  font-size: 12px; font-weight: 700; padding: 0; line-height: 1; color: var(--text);
}
.swatch:hover { box-shadow: 0 0 0 2px var(--accent-bg); border-color: var(--accent); }
.sw-c[data-c="gray"] { color: #787774; }   .sw-c[data-c="brown"] { color: #9f6b53; }
.sw-c[data-c="orange"] { color: #d9730d; } .sw-c[data-c="yellow"] { color: #cb912f; }
.sw-c[data-c="green"] { color: #448361; }  .sw-c[data-c="blue"] { color: #337ea9; }
.sw-c[data-c="purple"] { color: #9065b0; } .sw-c[data-c="pink"] { color: #c14c8a; }
.sw-c[data-c="red"] { color: #d44c47; }
.sw-bg[data-bg="gray"] { background: #f1f1ef; }   .sw-bg[data-bg="brown"] { background: #f4eeee; }
.sw-bg[data-bg="orange"] { background: #fbecdd; } .sw-bg[data-bg="yellow"] { background: #fbf3db; }
.sw-bg[data-bg="green"] { background: #edf3ec; }  .sw-bg[data-bg="blue"] { background: #e7f3f8; }
.sw-bg[data-bg="purple"] { background: #f6f3f9; } .sw-bg[data-bg="pink"] { background: #faf1f5; }
.sw-bg[data-bg="red"] { background: #fdebec; }
.sw-bg { color: #37352f; }

/* 서식 도구: 색 / 이모티콘 */
.fmt-sep { width: 1px; background: var(--border); margin: 4px 3px; }
.fmt-color { font-weight: 700; text-decoration: underline; text-decoration-color: #d9730d; text-decoration-thickness: 2px; }
.fmt-emoji { font-size: 15px; }
.fmt-color-panel { width: 264px; }

/* 사이드바 아이콘 클릭으로 바꾸기 */
.tree-icon { border-radius: 4px; cursor: pointer; }
.tree-icon:hover { background: var(--bg-active); }

/* ===== v1.03: 엔터로 만든 줄 간격 = 일반 줄바꿈 간격 (24px) ===== */
.blk-add, .blk-handle { height: 24px; }
.page-link { padding: 0 4px; }
.b-divider { padding-top: 4px; padding-bottom: 4px; }

/* ===== v1.03: 상단 버튼 / 토스트 버튼 ===== */
.star-btn { font-size: 17px; }
.star-btn.on { color: #e0a800; }
.btn-ghost-top { border-color: transparent; background: transparent; }
.btn-ghost-top:hover { background: var(--bg-hover); }
.btn-ghost-top.on { color: var(--accent); }
.sb-trash.active { background: var(--bg-active); color: var(--text); }
.toast { display: flex; align-items: center; gap: 12px; pointer-events: auto; }
.toast-action { border: 0; background: rgba(255,255,255,.18); color: #fff; border-radius: 5px; padding: 3px 10px; font-size: 13px; font-weight: 600; }
.toast-action:hover { background: rgba(255,255,255,.3); }
.read-only .editor-tail { display: none; }

/* ===== 이미지 / 파일 ===== */
.b-image .block-body { justify-content: center; }
.img-wrap { position: relative; max-width: 100%; margin: 4px 0; border-radius: 4px; }
.img-wrap img { display: block; width: 100%; height: auto; border-radius: 4px; }
.img-wrap.broken img { display: none; }
.img-wrap.broken::after, .img-missing {
  content: '이미지를 불러올 수 없습니다'; display: block; padding: 24px; text-align: center;
  border: 1px dashed var(--border); border-radius: 6px; color: var(--text-3); font-size: 14px;
}
.img-resize {
  position: absolute; top: 50%; transform: translateY(-50%); width: 6px; height: 44px; border-radius: 4px;
  background: rgba(15, 15, 15, .55); border: 1px solid rgba(255, 255, 255, .85); opacity: 0; cursor: ew-resize; transition: opacity .12s;
}
.img-resize-r { right: 8px; }
.img-resize-l { left: 8px; }
.img-wrap:hover .img-resize, .img-wrap.resizing .img-resize { opacity: 1; }
.b-image:focus .img-wrap, .b-file:focus .file-card { box-shadow: 0 0 0 3px var(--accent-bg); }
.b-image:focus, .b-file:focus { background: transparent; }
.file-card {
  flex: 1; display: flex; align-items: center; gap: 10px; padding: 8px 10px; margin: 2px 0;
  border: 1px solid var(--border); border-radius: 6px; color: var(--text); text-decoration: none; min-width: 0;
}
.file-card:hover { background: var(--bg-hover); }
.file-icon { font-size: 20px; flex: none; }
.file-name { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file-size { color: var(--text-3); font-size: 13px; flex: none; }
.file-dl { margin-left: auto; color: var(--text-2); flex: none; }
.upload-box {
  flex: 1; padding: 10px 12px; margin: 2px 0; border: 1px dashed var(--border); border-radius: 6px;
  display: flex; flex-direction: column; gap: 8px; font-size: 14px; color: var(--text-2); min-width: 200px;
}
.upload-bar { display: block; height: 4px; background: var(--bg-active); border-radius: 2px; overflow: hidden; }
.upload-bar > span { display: block; height: 100%; background: var(--accent); width: 0; transition: width .2s; }

/* ===== 데이터베이스 (표·보드·캘린더) ===== */
.b-database .block-body { flex-direction: column; align-items: stretch; }
.db-view { width: 100%; margin: 8px 0 12px; }
.db-title { border: 0; background: transparent; font-size: 20px; font-weight: 700; width: 100%; outline: none; padding: 2px 0; color: var(--text); }
.db-title::placeholder { color: var(--text-3); }
.db-bar { display: flex; align-items: flex-end; justify-content: space-between; gap: 8px; border-bottom: 1px solid var(--border); margin-top: 4px; flex-wrap: wrap; }
.db-tabs { display: flex; gap: 2px; }
.db-tab {
  border: 0; background: transparent; padding: 6px 10px; font-size: 14px; color: var(--text-2);
  border-bottom: 2px solid transparent; display: flex; gap: 5px; align-items: center; margin-bottom: -1px;
}
.db-tab:hover { color: var(--text); }
.db-tab.on { color: var(--text); border-bottom-color: var(--text); font-weight: 600; }
.db-tab-icon { font-size: 13px; }
.db-actions { padding-bottom: 5px; }
.db-table-wrap { overflow-x: auto; }
.db-table { border-collapse: collapse; min-width: 100%; font-size: 14px; }
.db-th {
  text-align: left; font-weight: 500; color: var(--text-2); padding: 7px 8px; white-space: nowrap; cursor: pointer;
  border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); min-width: 140px; user-select: none;
}
.db-th:hover { background: var(--bg-hover); }
.db-th.t-title { min-width: 220px; }
.db-th.t-checkbox { min-width: 80px; }
.db-th-icon { margin-right: 6px; opacity: .7; font-size: 12px; }
.db-th-add { min-width: 40px !important; text-align: center; border-right: 0; font-size: 16px; }
.db-td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 0; vertical-align: middle; position: relative; height: 34px; }
.db-td-more { width: 34px; border-right: 0; }
.db-input {
  width: 100%; border: 0; background: transparent; padding: 7px 8px; font-size: 14px; outline: none; min-width: 100px; color: var(--text);
  font-family: inherit;
}
.db-input:focus { background: var(--bg); box-shadow: inset 0 0 0 2px var(--accent-bg); }
.db-input-title { font-weight: 500; }
.db-num { text-align: right; }
.db-date { min-width: 130px; }
.db-check { margin: 0 10px; width: 16px; height: 16px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.db-select-btn { border: 0; background: transparent; padding: 5px 8px; width: 100%; text-align: left; min-height: 34px; cursor: pointer; }
.db-select-btn:hover { background: var(--bg-hover); }
.db-placeholder { color: var(--text-3); font-size: 13px; }
.db-open {
  position: absolute; right: 6px; top: 50%; transform: translateY(-50%); display: none; font-size: 11.5px; padding: 2px 7px;
  border: 1px solid var(--border); border-radius: 4px; background: var(--bg-elevated); color: var(--text-2); box-shadow: 0 1px 2px rgba(0,0,0,.08);
}
tr:hover .db-open { display: block; }
.db-open:hover { color: var(--text); }
.db-row-more { opacity: 0; border: 0; background: transparent; width: 28px; height: 28px; border-radius: 4px; color: var(--text-2); }
tr:hover .db-row-more { opacity: 1; }
.db-row-more:hover { background: var(--bg-hover); }
.db-add-row, .db-board-add {
  border: 0; background: transparent; color: var(--text-3); padding: 7px 8px; width: 100%; text-align: left; font-size: 14px; border-radius: 4px;
}
.db-add-row:hover, .db-board-add:hover { background: var(--bg-hover); color: var(--text-2); }
.db-url { display: flex; align-items: center; }
.db-url-open { padding: 0 8px; text-decoration: none; color: var(--text-2); }
.db-static { padding: 7px 8px; display: block; }
.db-empty { padding: 16px 4px; color: var(--text-2); font-size: 14px; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.db-sub-bar { font-size: 13px; color: var(--text-2); padding: 8px 0 0; display: flex; align-items: center; gap: 6px; }
.db-group-select { border: 1px solid var(--border); border-radius: 5px; background: var(--bg); padding: 2px 6px; }
.db-sub-label { font-size: 13px; color: var(--text-2); margin-right: 4px; }

.db-pill {
  display: inline-block; padding: 1px 8px; border-radius: 4px; font-size: 13px; line-height: 1.5;
  white-space: nowrap; max-width: 100%; overflow: hidden; text-overflow: ellipsis; background: #e3e2e0; color: #32302c;
}
.db-pill[data-color="brown"], .db-cal-chip[data-color="brown"] { background: #eee0da; color: #442a1e; }
.db-pill[data-color="orange"], .db-cal-chip[data-color="orange"] { background: #fadec9; color: #49290e; }
.db-pill[data-color="yellow"], .db-cal-chip[data-color="yellow"] { background: #fdecc8; color: #402c1b; }
.db-pill[data-color="green"], .db-cal-chip[data-color="green"] { background: #dbeddb; color: #1c3829; }
.db-pill[data-color="blue"], .db-cal-chip[data-color="blue"] { background: #d3e5ef; color: #183347; }
.db-pill[data-color="purple"], .db-cal-chip[data-color="purple"] { background: #e8deee; color: #412454; }
.db-pill[data-color="pink"], .db-cal-chip[data-color="pink"] { background: #f5e0e9; color: #4c2337; }
.db-pill[data-color="red"], .db-cal-chip[data-color="red"] { background: #ffe2dd; color: #5d1715; }
.db-pill[data-color="none"] { background: transparent; color: var(--text-2); border: 1px dashed var(--border); }
@media (prefers-color-scheme: dark) {
  .db-pill { background: #373737; color: rgba(255,255,255,.85); }
  .db-pill[data-color="brown"], .db-cal-chip[data-color="brown"] { background: #4a3228; color: #fff; }
  .db-pill[data-color="orange"], .db-cal-chip[data-color="orange"] { background: #5c3b23; color: #fff; }
  .db-pill[data-color="yellow"], .db-cal-chip[data-color="yellow"] { background: #564328; color: #fff; }
  .db-pill[data-color="green"], .db-cal-chip[data-color="green"] { background: #243d30; color: #fff; }
  .db-pill[data-color="blue"], .db-cal-chip[data-color="blue"] { background: #143a4e; color: #fff; }
  .db-pill[data-color="purple"], .db-cal-chip[data-color="purple"] { background: #3c2d49; color: #fff; }
  .db-pill[data-color="pink"], .db-cal-chip[data-color="pink"] { background: #4e2c3c; color: #fff; }
  .db-pill[data-color="red"], .db-cal-chip[data-color="red"] { background: #522e2a; color: #fff; }
}

.db-select-menu { width: 260px; padding: 6px; }
.db-select-search, .db-col-name, .db-opt-name {
  width: 100%; height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: var(--bg); outline: none; font-size: 14px;
}
.db-select-search:focus, .db-col-name:focus, .db-opt-name:focus { border-color: var(--accent); }
.db-select-search { margin-bottom: 6px; }
.db-select-list { max-height: 260px; overflow: auto; display: flex; flex-direction: column; gap: 1px; }
.db-select-item { border: 0; background: transparent; text-align: left; padding: 5px 6px; border-radius: 5px; font-size: 14px; }
.db-select-item:hover { background: var(--bg-hover); }
.db-select-item.on { background: var(--bg-active); }
.db-select-clear { color: var(--text-2); font-size: 13px; }
.db-col-menu { width: 240px; }
.db-col-name-wrap { padding: 4px 4px 6px; }
.db-opt-dialog { max-width: 460px; }
.db-opt-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 50vh; overflow: auto; }
.db-opt-row { display: flex; gap: 8px; align-items: center; }
.db-opt-color { height: 32px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); padding: 0 6px; }

.db-board { display: flex; gap: 12px; overflow-x: auto; padding: 10px 0 6px; align-items: flex-start; }
.db-board-col { flex: 0 0 260px; background: var(--bg-sidebar); border-radius: 8px; padding: 8px; min-height: 80px; }
.db-board-col.drop-on { box-shadow: inset 0 0 0 2px var(--accent); }
.db-board-head { display: flex; align-items: center; gap: 8px; padding: 2px 2px 8px; }
.db-count { color: var(--text-3); font-size: 13px; }
.db-card {
  background: var(--bg-elevated); border-radius: 6px; padding: 8px 10px; margin-bottom: 6px; cursor: pointer;
  box-shadow: 0 1px 2px rgba(15,15,15,.1), 0 0 0 1px rgba(15,15,15,.06);
}
.db-card:hover { background: var(--bg-hover); }
.db-card-title { font-weight: 500; font-size: 14px; word-break: break-word; }
.db-card-props { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; font-size: 12px; color: var(--text-2); align-items: center; }
.db-card-prop { white-space: nowrap; }

.db-cal-bar { display: flex; justify-content: space-between; align-items: center; padding: 10px 0 6px; }
.db-cal-title { font-size: 16px; }
.db-cal-nav { display: flex; gap: 4px; align-items: center; }
.db-cal-wrap { overflow-x: auto; }
.db-cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); border-top: 1px solid var(--border); border-left: 1px solid var(--border); min-width: 560px; }
.db-cal-week { padding: 4px 6px; font-size: 12px; color: var(--text-2); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: center; }
.db-cal-week.sun, .db-cal-day.sun .db-cal-num { color: #d44c47; }
.db-cal-week.sat, .db-cal-day.sat .db-cal-num { color: #337ea9; }
.db-cal-day { min-height: 96px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 4px; position: relative; display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.db-cal-day.other { background: var(--bg-sidebar); }
.db-cal-day.other .db-cal-num { opacity: .45; }
.db-cal-day.drop-on { box-shadow: inset 0 0 0 2px var(--accent); }
.db-cal-num { font-size: 12px; text-align: right; padding: 2px 4px; }
.db-cal-day.today .db-cal-num { background: #eb5757; color: #fff !important; border-radius: 50%; width: 22px; height: 22px; line-height: 18px; text-align: center; align-self: flex-end; }
.db-cal-chip {
  font-size: 12px; padding: 2px 6px; border-radius: 4px; background: var(--bg-elevated); border: 0; text-align: left; color: var(--text);
  box-shadow: 0 1px 2px rgba(15,15,15,.1), 0 0 0 1px rgba(15,15,15,.08); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.db-cal-add {
  position: absolute; left: 4px; top: 4px; width: 22px; height: 22px; border: 0; border-radius: 4px; background: transparent;
  color: var(--text-2); opacity: 0; font-size: 16px; line-height: 1;
}
.db-cal-day:hover .db-cal-add { opacity: 1; }
.db-cal-add:hover { background: var(--bg-hover); }
.db-cal-nodate { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 10px 0 0; }
@media (hover: none) {
  .db-open { display: block; }
  .db-row-more { opacity: .7; }
  .db-cal-add { opacity: .5; }
  .img-resize { opacity: .8; }
}

.db-row-overlay { align-items: flex-start; padding-top: 8vh; }
.db-row-dialog { max-width: 620px; max-height: 84vh; overflow: auto; }
.db-row-title { font-size: 26px; font-weight: 700; border: 0; outline: none; width: 100%; background: transparent; margin: 0 0 12px; color: var(--text); padding: 0; font-family: inherit; }
.db-row-props { display: flex; flex-direction: column; gap: 2px; margin-bottom: 12px; }
.db-row-prop { display: grid; grid-template-columns: 140px 1fr; align-items: center; min-height: 34px; }
.db-row-label { color: var(--text-2); font-size: 14px; display: flex; gap: 6px; align-items: center; }
.db-row-value { border-radius: 5px; min-width: 0; }
.db-row-value:hover { background: var(--bg-hover); }
.db-row-note { width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px; background: var(--bg); resize: vertical; font: inherit; outline: none; margin-bottom: 14px; }
.db-row-note:focus { border-color: var(--accent); }
.db-row-note-ro { white-space: pre-wrap; padding: 10px; background: var(--bg-sidebar); border-radius: 8px; margin-bottom: 14px; }

/* ===== 공유 / 템플릿 / 버전 기록 / 휴지통 ===== */
.share-dialog { max-width: 500px; }
.share-toggle-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; margin: 8px 0 14px; }
.share-state { margin: 4px 0 0 !important; font-size: 13px; }
.share-row { display: flex; gap: 6px; margin-bottom: 14px; }
.share-row[hidden] { display: none; }
.share-link { flex: 1; min-width: 0; height: 32px; border: 1px solid var(--border); border-radius: 6px; padding: 0 8px; background: var(--bg-sidebar); font-size: 13px; }
a.btn-sm { height: 28px; padding: 0 10px; font-size: 13px; }
.tpl-dialog { max-width: 660px; max-height: 86vh; overflow: auto; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px; margin: 10px 0; }
.tpl-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; padding: 12px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--bg); width: 100%; height: 100%;
}
.tpl-card:hover, .tpl-card:focus { border-color: var(--accent); background: var(--bg-hover); outline: none; }
.tpl-icon { font-size: 24px; }
.tpl-title { font-weight: 600; }
.tpl-desc { font-size: 12.5px; color: var(--text-2); }
.tpl-wrap { position: relative; }
.tpl-del { position: absolute; top: 6px; right: 6px; border: 0; background: transparent; color: var(--text-3); border-radius: 4px; width: 24px; height: 24px; }
.tpl-del:hover { background: var(--bg-active); color: var(--danger); }
.tpl-sub { margin: 14px 0 0; font-size: 14px; }
.tpl-hint { font-size: 12.5px !important; color: var(--text-3) !important; margin: 10px 0 14px !important; }
.ver-overlay { padding: 5vh 16px; align-items: stretch; }
.ver-dialog { max-width: 1000px; width: 100%; height: 86vh; display: flex; flex-direction: column; padding: 18px 20px; margin: 0 auto; }
.ver-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ver-head h3 { margin: 0; }
.ver-note { font-size: 12.5px; color: var(--text-3); }
.ver-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 230px 1fr; gap: 14px; margin: 12px 0; }
.ver-list { overflow: auto; border-right: 1px solid var(--border); padding-right: 8px; display: flex; flex-direction: column; gap: 2px; }
.ver-item { border: 0; background: transparent; text-align: left; padding: 8px 10px; border-radius: 6px; display: flex; flex-direction: column; gap: 2px; font-size: 14px; }
.ver-item span { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.ver-item:hover { background: var(--bg-hover); }
.ver-item.on { background: var(--bg-active); }
.ver-current { opacity: .75; cursor: default; }
.ver-preview { overflow: auto; padding: 0 10px; }
.ver-title { font-size: 28px; margin: 4px 0 12px; }
.ver-empty { color: var(--text-2); }
.trash-card { padding-bottom: 0; }
.trash-list { display: flex; flex-direction: column; margin: 12px -20px 0; }
.trash-item { display: flex; gap: 12px; align-items: center; padding: 10px 20px; border-top: 1px solid var(--border); }
.trash-icon { font-size: 20px; flex: none; }
.trash-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.trash-info strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trash-info span { font-size: 12.5px; color: var(--text-2); }
.trash-actions { display: flex; gap: 6px; flex: none; }
.share-shell { display: flex; flex-direction: column; height: 100vh; }
.share-top { border-bottom: 1px solid var(--border); }
.share-badge { font-size: 12px; color: var(--text-2); background: var(--bg-hover); padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.share-foot { text-align: center; color: var(--text-3); font-size: 12.5px; margin-top: 60px; }
.share-shell .page-icon { display: block; }

@media (max-width: 800px) {
  .ver-body { grid-template-columns: 1fr; grid-template-rows: 150px 1fr; }
  .ver-list { border-right: 0; border-bottom: 1px solid var(--border); padding: 0 0 8px; }
  .db-row-prop { grid-template-columns: 100px 1fr; }
  .db-board-col { flex-basis: 230px; }
  .share-row { flex-wrap: wrap; }
  .share-link { flex-basis: 100%; }
  .trash-item { flex-wrap: wrap; }
  .trash-actions { width: 100%; justify-content: flex-end; }
  .btn-ghost-top { padding: 0 8px; }
  .top-right { gap: 4px; }
}
.btn-top { height: 28px; padding: 0 12px; font-size: 13px; }
@media (max-width: 800px) {
  .db-cal-grid { min-width: 0; }
  .db-cal-day { min-height: 64px; padding: 2px; }
  .db-cal-num { font-size: 11px; padding: 1px 2px; }
  .db-cal-day.today .db-cal-num { width: 18px; height: 18px; line-height: 16px; }
  .db-cal-chip { font-size: 10.5px; padding: 1px 3px; }
  .db-cal-add { display: none; }
  .db-title { font-size: 18px; }
}

/* ===== v1.04: 보안 ===== */
.auth-fields { display: flex; flex-direction: column; gap: 14px; }
.remember-row { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); cursor: pointer; user-select: none; }
.remember-row input { width: 16px; height: 16px; accent-color: var(--accent); margin: 0; }
.remember-hint { margin-left: auto; font-size: 12px; color: var(--text-3); }
.auth-logo:not(:has(svg)) { font-size: 32px; }

.check-list { display: flex; flex-direction: column; margin-top: 12px; }
.check-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--border); }
.check-icon { font-size: 18px; flex: none; width: 24px; text-align: center; }
.check-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.check-text span { font-size: 13px; color: var(--text-2); }
.check-bad .check-text strong { color: var(--danger); }
.check-warn .check-text strong { color: #b7791f; }
.log-table td { font-size: 13px; }
.log-event { font-weight: 600; }
.log-detail { color: var(--text-2); margin-left: 6px; }
.log-bad .log-event { color: var(--danger); }
.log-warn .log-event { color: #b7791f; }
.log-filter { min-width: 140px; }

.sec-dialog { max-width: 600px; max-height: 88vh; overflow: auto; }
.sec-head { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }
.sec-dialog h4 { margin: 0; font-size: 14px; }
.sec-sub { margin-top: 18px !important; }
.sec-note { font-size: 12.5px !important; margin: 4px 0 6px !important; }
.sec-list { display: flex; flex-direction: column; margin: 6px 0 4px; }
.sec-item { display: flex; align-items: center; gap: 10px; padding: 9px 0; border-top: 1px solid var(--border); }
.sec-icon { font-size: 20px; flex: none; }
.sec-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.sec-info strong { font-size: 14px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sec-info span { font-size: 12.5px; color: var(--text-2); }
.sec-badge { font-size: 11px; }
.sec-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex: none; margin: 0 6px; }
.sec-ok .sec-dot { background: var(--success); }
.sec-warn .sec-dot { background: #cb912f; }
.sec-bad .sec-dot { background: var(--danger); }
.sec-bad strong { color: var(--danger); }
.sec-empty { color: var(--text-3); font-size: 13px; }

/* ===== v1.05: 관리자 탭 · 회원 수정 · 사이트 설정 · 백업 · 공지 ===== */
.admin-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin: 0 0 20px; overflow-x: auto; scrollbar-width: none; }
.admin-tabs::-webkit-scrollbar { display: none; }
.admin-tab {
  flex: none; border: 0; background: none; padding: 9px 14px; font-size: 14.5px; font-weight: 600; color: var(--text-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer; border-radius: 6px 6px 0 0;
}
.admin-tab:hover { color: var(--text); background: var(--bg-hover); }
.admin-tab.active { color: var(--text); border-bottom-color: var(--text); }
.admin-stats-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.admin-badges { display: flex; gap: 4px; flex-wrap: wrap; }
.pill-plain { background: var(--bg-hover); color: var(--text-2); }
.pill-warn { background: rgba(203, 145, 47, 0.15); color: #a86d0b; }
.me-tag { font-size: 11px; font-weight: 600; margin-left: 6px; padding: 1px 6px; border-radius: 4px; background: var(--accent-bg); color: var(--accent); vertical-align: 1px; }

/* 입력 칸 공통 (대화상자·설정) */
.field select, .field textarea, .set-field input, .set-field select, .set-field textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border); border-radius: 7px; background: var(--bg);
  color: var(--text); font: inherit; font-size: 14.5px; outline: none; transition: border-color .12s, box-shadow .12s;
}
.field select, .set-field select, .set-field input { height: 40px; padding-top: 0; padding-bottom: 0; }
.field textarea, .set-field textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.field select:focus, .field textarea:focus, .set-field input:focus, .set-field select:focus, .set-field textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-bg); }
.set-field input.invalid, .set-field textarea.invalid, .field select.invalid { border-color: var(--danger); }
.field select:disabled { opacity: .6; }
.field-hint { font-size: 12.5px; color: var(--text-3); margin-top: 5px; line-height: 1.45; }
.field-check label { display: flex; align-items: center; gap: 8px; font-weight: 500; color: var(--text); cursor: pointer; margin: 0; }
.field-check input { width: 16px; height: 16px; margin: 0; flex: none; accent-color: var(--accent); }

.set-card { display: block; }
.set-head { margin-bottom: 14px; }
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 18px; }
.set-wide { grid-column: 1 / -1; }
.set-actions { display: flex; justify-content: flex-end; margin-top: 14px; }
.input-addon { display: flex; align-items: center; gap: 8px; }
.input-addon input { flex: 1; min-width: 0; }
.input-suffix { flex: none; font-size: 13.5px; color: var(--text-2); white-space: nowrap; }
.set-field .input-addon input[type=number] { max-width: 120px; }
.icon-pick { height: 40px; min-width: 44px; font-size: 20px; padding: 0 8px; }

/* 백업 */
.bk-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.bk-last { font-size: 13px !important; color: var(--text-3) !important; }
.bk-check { display: flex; align-items: center; gap: 8px; margin-top: 12px; font-size: 14px; cursor: pointer; }
.bk-check input { width: 16px; height: 16px; margin: 0; accent-color: var(--accent); }
.bk-inline { display: flex; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.bk-inline input { width: 72px; height: 32px; padding: 0 8px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); color: var(--text); font: inherit; }
.bk-auto-opts { display: flex; flex-direction: column; gap: 4px; margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.bk-warn { color: var(--danger) !important; }
.bk-progress { position: relative; margin-top: 14px; height: 26px; border-radius: 7px; background: var(--bg-hover); overflow: hidden; }
.bk-bar { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--accent-bg); transition: width .2s; }
.bk-progress span { position: relative; display: block; line-height: 26px; padding: 0 10px; font-size: 13px; color: var(--text-2); }
.backup-table td.bk-content { white-space: normal; min-width: 200px; color: var(--text-2); font-size: 13.5px; }
.bk-dialog { width: min(560px, calc(100vw - 32px)); }
.bk-summary { margin: 0 0 6px; color: var(--text-2); font-size: 14px; }
.bk-option { display: flex; align-items: center; gap: 14px; padding: 14px 0; border-top: 1px solid var(--border); }
.bk-option > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.bk-option span { font-size: 13px; color: var(--text-2); line-height: 1.5; }
.bk-option .btn { flex: none; }

/* 공지 띠 */
.notice-bar { display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 9px 14px; background: rgba(203, 145, 47, 0.12); border-bottom: 1px solid rgba(203, 145, 47, 0.25); font-size: 14px; }
.notice-bar[hidden] { display: none; }
.notice-icon { flex: none; }
.notice-text { flex: 1; min-width: 0; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.notice-close { flex: none; width: 24px; height: 24px; font-size: 13px; }

/* 로그인 화면 안내문 · 이모지 로고 */
.auth-message { margin: -10px 0 20px; padding: 10px 12px; border-radius: 8px; background: var(--bg-callout); font-size: 13.5px; color: var(--text); white-space: pre-wrap; word-break: break-word; line-height: 1.55; text-align: left; }
.auth-logo-emoji { font-size: 36px; line-height: 1; }

@media (max-width: 800px) {
  .admin-stats-4 { grid-template-columns: 1fr 1fr; }
  .set-grid { grid-template-columns: 1fr; }
  .admin-tab { padding: 8px 10px; font-size: 14px; }
  .bk-option { flex-direction: column; align-items: stretch; }
  .bk-buttons .btn { flex: 1; }
}
.overlay { overflow-y: auto; }
.dialog.bk-dialog { max-width: 560px; }
@media (max-height: 760px), (max-width: 800px) { .overlay { padding-top: 5vh; } }
.admin-table th { white-space: nowrap; }
.bk-buttons .btn { white-space: nowrap; }
@media (max-width: 800px) { .bk-buttons { width: 100%; } .bk-buttons .btn { flex: 1 1 140px; } }

/* ===== v1.06: 여러 블록 선택 (전체 선택 · 드래그) ===== */
.sel-sink {
  position: fixed; left: 0; top: 0; width: 1px; height: 1px; overflow: hidden; opacity: 0;
  pointer-events: none; user-select: text; -webkit-user-select: text; outline: none; white-space: pre;
}
.editor.block-selecting .blocks { user-select: none; -webkit-user-select: none; }
.editor.block-selecting .blocks .text { caret-color: transparent; }
.block.is-selected { background: rgba(35, 131, 226, 0.14); border-radius: 4px; }
@media (prefers-color-scheme: dark) { .block.is-selected { background: rgba(35, 131, 226, 0.28); } }
