/* Plangrida 웹앱 스타일 — 앱 레이아웃 그대로 (좌:목록 / 우:캔버스) */

* { box-sizing: border-box; }
:root {
    --sidebar-w: 280px;
    --bg: #f7f8fb;
    --panel: #ffffff;
    --border: #e3e6ec;
    --border-soft: #eef0f5;
    --text: #1d2230;
    --muted: #7a8499;
    --muted-soft: #aab1c1;
    --accent: #2f6dff;
    --accent-dark: #1f4dcc;
    --accent-soft: #eaf0ff;
    --danger: #d0363a;
    --warn: #ea8800;
    --postit: #fff5a8;
    --postit-border: #f0df79;
    --postit-shadow: rgba(20, 26, 38, .12);
}
html, body {
    margin: 0; padding: 0; height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Pretendard", "Noto Sans KR", Helvetica, Arial, sans-serif;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

/* ── Auth 공용 폼 ───────────────────────────────────── */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card {
    width: 100%; max-width: 420px;
    background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
    padding: 28px; box-shadow: 0 4px 24px rgba(0,0,0,.04);
}
.auth-card .brand {
    display: flex; justify-content: center; margin: 0 0 18px;
}
.auth-card .brand img { width: 220px; max-width: 100%; height: auto; display: block; }
.auth-card h1 { margin: 0 0 4px; font-size: 24px; text-align: center; }
.auth-card .subtitle { margin: 0 0 24px; color: var(--muted); font-size: 14px; text-align: center; }
.field { display: flex; flex-direction: column; margin-bottom: 12px; }
.field label { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input {
    padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; background: #fff;
}
.field input:focus { outline: 2px solid rgba(47,109,255,.25); border-color: var(--accent); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 8px 14px; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; cursor: pointer; font-size: 13px; color: var(--text);
    font-family: inherit;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.btn:hover { background: #f3f5fa; }
.btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn.block { width: 100%; }
.btn.danger { color: var(--danger); border-color: var(--border); }
.btn.danger:hover { background: #fef1f1; border-color: var(--danger); }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.divider { display: flex; align-items: center; gap: 10px; margin: 18px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ''; flex: 1; height: 1px; background: var(--border); }

.alert { padding: 10px 12px; border-radius: 8px; background: #fef1f1; color: var(--danger); font-size: 13px; margin-bottom: 12px; }
.muted { color: var(--muted); }
.link { color: var(--accent); text-decoration: none; }
.link:hover { text-decoration: underline; }

/* ── Splash ─────────────────────────────────────────── */
.splash { min-height: 100vh; display: grid; place-items: center; }
.splash-box { text-align: center; }
.splash-box h1 { font-size: 32px; margin: 0 0 4px; }
.spinner {
    width: 24px; height: 24px; margin: 16px auto 0;
    border: 3px solid var(--border); border-top-color: var(--accent);
    border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ═══════════════════════════════════════════════════════
   App 레이아웃
   ═══════════════════════════════════════════════════════ */
.app {
    display: grid; grid-template-columns: var(--sidebar-w) 1fr;
    height: 100vh;
    overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────── */
.sidebar {
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    min-height: 0;
}
.side-head {
    padding: 14px 16px 12px;
    border-bottom: 1px solid var(--border-soft);
}
.side-head .brand { display: flex; align-items: center; gap: 10px; }
.side-head .brand .mark { width: 28px; height: 28px; flex: 0 0 auto; display: block; }
.side-head .brand .name { display: flex; flex-direction: column; line-height: 1.1; }
.side-head .brand .name strong { font-size: 15px; font-weight: 800; letter-spacing: .02em; color: var(--text); }
.side-head .brand .name strong em { font-style: normal; color: var(--accent); }
.side-head .brand .name .tag { font-size: 10px; color: var(--muted); margin-top: 2px; letter-spacing: .03em; }
.side-head h2 { margin: 0; font-size: 17px; font-weight: 700; letter-spacing: -.01em; }
.side-head .sync-line { font-size: 11px; color: var(--muted); margin-top: 8px; }

.sidebar .section-title {
    font-size: 11px; color: var(--muted-soft);
    text-transform: uppercase; letter-spacing: .06em; font-weight: 600;
    padding: 14px 16px 6px;
}

.side-foot {
    margin-top: auto; padding: 12px 12px 14px;
    border-top: 1px solid var(--border-soft);
    font-size: 12px;
}
.side-foot .foot-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding: 0 4px;
}
.side-foot .email {
    flex: 1; min-width: 0; color: var(--muted);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* 알림 벨 */
.bell-btn {
    flex: 0 0 auto;
    position: relative;
    width: 28px; height: 28px; padding: 0;
    border: 1px solid var(--border); background: #fff;
    color: var(--muted);
    border-radius: 8px;
    display: grid; place-items: center;
    cursor: pointer;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
}
.bell-btn:hover { background: var(--accent-soft); border-color: rgba(47,109,255,.3); color: var(--accent); }
.bell-btn.has-unread { color: var(--accent); }
.bell-dot {
    position: absolute; top: 3px; right: 3px;
    min-width: 14px; height: 14px; padding: 0 4px;
    background: var(--danger); color: #fff;
    font-size: 9px; font-weight: 700; line-height: 14px;
    border-radius: 7px; text-align: center;
    box-shadow: 0 0 0 2px #fff;
}
.bell-popover {
    position: fixed; z-index: 9999;
    width: 340px; max-height: 440px;
    background: #fff; border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: 0 16px 40px rgba(15,22,38,.18), 0 2px 8px rgba(15,22,38,.08);
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: rowMenuIn .1s ease-out;
}
.bell-pop-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--border-soft);
}
.bell-pop-head strong { font-size: 13px; }
.bell-pop-head .mark-all {
    background: transparent; border: none; color: var(--accent);
    font-size: 12px; cursor: pointer; padding: 4px 6px; border-radius: 6px;
    font-family: inherit;
}
.bell-pop-head .mark-all:hover { background: var(--accent-soft); }
.bell-pop-list { overflow-y: auto; flex: 1; }
.bell-item {
    display: flex; gap: 10px; padding: 10px 12px;
    border-bottom: 1px solid var(--border-soft);
    cursor: pointer;
    transition: background .08s ease;
}
.bell-item:hover { background: var(--bg); }
.bell-item:last-child { border-bottom: none; }
.bell-item.unread { background: rgba(47,109,255,.04); }
.bell-item .ic {
    flex: 0 0 auto; width: 28px; height: 28px;
    background: var(--accent-soft); color: var(--accent);
    border-radius: 50%; display: grid; place-items: center; font-size: 14px;
}
.bell-item .body { flex: 1; min-width: 0; }
.bell-item .line1 { font-size: 13px; color: var(--text); line-height: 1.35; }
.bell-item .line2 { font-size: 11px; color: var(--muted); margin-top: 2px; }
.bell-item .line1 strong { font-weight: 600; }
.bell-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 13px; }

/* ── Sidebar 네비 (프로젝트 관리 / 팀원 구성) ────────── */
.side-nav { padding: 8px 8px 4px; display: flex; flex-direction: column; gap: 2px; }
.side-nav-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 8px 10px;
    background: transparent; border: none;
    border-radius: 8px;
    cursor: pointer;
    color: var(--text); font-size: 13px; text-align: left;
    font-family: inherit;
    transition: background .1s ease, color .1s ease;
}
.side-nav-item:hover { background: #f3f5fa; }
.side-nav-item.active { background: var(--accent-soft); color: var(--accent-dark); font-weight: 500; }
.side-nav-item .ic { font-size: 15px; flex: 0 0 18px; text-align: center; }
.side-nav-item .lbl { flex: 1; }

/* + 템플릿 추가 버튼 */
.add-tpl-btn {
    margin: 12px 12px 2px;
    padding: 10px 12px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    background: var(--accent-soft); border: 1px solid transparent;
    color: var(--accent); font-weight: 500; font-size: 13px;
    border-radius: 8px; cursor: pointer;
    font-family: inherit;
    transition: background .12s ease, border-color .12s ease;
}
.add-tpl-btn:hover { background: #dbe6ff; border-color: rgba(47,109,255,.25); }
.add-tpl-btn .plus { font-size: 15px; line-height: 1; font-weight: 600; }

/* 트리 */
.doc-tree {
    flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden;
    padding: 0 0 12px;
}
.doc-tree .tree-empty {
    padding: 18px 16px; font-size: 12px; color: var(--muted);
    white-space: pre-line; line-height: 1.6;
}

.tree-group { margin: 0; }
.tree-group-head {
    display: flex; align-items: center; gap: 6px;
    padding: 7px 14px 7px 12px;
    cursor: pointer; user-select: none;
    color: var(--text);
}
.tree-group-head:hover { background: #f3f5fa; }
.tree-group-head .chev {
    display: inline-block; width: 14px; height: 14px; flex: 0 0 14px;
    position: relative;
}
.tree-group-head .chev::before {
    content: ""; position: absolute; left: 3px; top: 3px;
    width: 6px; height: 6px;
    border-right: 1.5px solid var(--muted);
    border-bottom: 1.5px solid var(--muted);
    transform: rotate(45deg);             /* 펼침: ▾ */
    transition: transform .15s ease;
}
.tree-group.collapsed .tree-group-head .chev::before {
    transform: rotate(-45deg);            /* 접힘: ▸ */
    left: 5px; top: 1px;
}
.tree-group-head .name { flex: 1; font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tree-group-head .count {
    font-size: 11px; color: var(--muted);
    background: var(--border-soft); border-radius: 10px; padding: 1px 7px;
    font-weight: 500; line-height: 1.5;
}

/* 고정 그룹: 상단에 위치, 이름 색을 살짝 강조 */
.tree-group.pinned-group { padding-bottom: 4px; border-bottom: 1px solid var(--border-soft); margin-bottom: 6px; }
.tree-group.pinned-group .tree-group-head .name {
    font-weight: 600; color: var(--text);
    display: inline-flex; align-items: center; gap: 6px;
}
.tree-group.pinned-group .tree-group-head .name::before {
    content: "📌"; font-size: 11px; line-height: 1;
}

.tree-group-list { margin: 0; padding: 0; list-style: none; }
.tree-group.collapsed .tree-group-list { display: none; }

.tree-doc {
    position: relative;
    display: flex; align-items: center; gap: 6px;
    padding: 6px 10px 6px 30px;
    cursor: pointer;
    border-left: 3px solid transparent;
    font-size: 13px; color: var(--text);
    line-height: 1.4;
}
.tree-doc:hover { background: #f3f5fa; }
.tree-doc.active { background: var(--accent-soft); border-left-color: var(--accent); color: var(--accent-dark); font-weight: 500; }
.tree-doc .row-main {
    flex: 1; min-width: 0;
    display: flex; flex-direction: column; gap: 1px;
    overflow: hidden;
}
.tree-doc .title { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tree-doc .row-kind {
    font-size: 11px; color: var(--muted); font-weight: 400;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.tree-doc.active .row-kind { color: var(--accent); }
.tree-doc .dirty { font-size: 10px; color: var(--warn); }
.tree-doc .pin-mark { font-size: 11px; line-height: 1; flex: 0 0 auto; opacity: .9; }
/* 고정 그룹에서는 왼쪽 들여쓰기를 좀 줄여 📌가 눈에 띄게 */
.tree-doc.in-pinned { padding-left: 14px; }

/* 행의 점3개 버튼 — 호버 또는 활성 행에서만 보이도록 */
.tree-doc .row-more {
    flex: 0 0 auto;
    width: 22px; height: 22px;
    padding: 0; border: none; background: transparent;
    color: var(--muted); border-radius: 6px;
    display: grid; place-items: center;
    cursor: pointer;
    opacity: 0; transition: opacity .12s ease, background .12s ease, color .12s ease;
}
.tree-doc:hover .row-more,
.tree-doc.active .row-more,
.tree-doc .row-more:focus-visible { opacity: 1; }
.tree-doc .row-more:hover { background: rgba(15,22,38,.08); color: var(--text); }
.tree-doc.active .row-more:hover { background: rgba(47,109,255,.15); color: var(--accent-dark); }

/* ── 행 컨텍스트 메뉴 (고정 / 삭제) ─────────────── */
.row-menu {
    position: fixed; z-index: 9999;
    min-width: 160px;
    background: #fff; border: 1px solid var(--border);
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 8px 28px rgba(15,22,38,.14), 0 2px 6px rgba(15,22,38,.06);
    font-size: 13px;
    animation: rowMenuIn .08s ease-out;
}
@keyframes rowMenuIn {
    from { opacity: 0; transform: translateY(-2px); }
    to   { opacity: 1; transform: translateY(0); }
}
.row-menu-item {
    display: flex; align-items: center; gap: 10px;
    width: 100%;
    padding: 7px 10px;
    background: transparent; border: none; border-radius: 6px;
    color: var(--text); font-size: 13px; text-align: left;
    cursor: pointer;
    font-family: inherit;
}
.row-menu-item .ic { width: 16px; text-align: center; font-size: 13px; }
.row-menu-item:hover { background: var(--accent-soft); color: var(--accent-dark); }
.row-menu-item.danger { color: var(--danger); }
.row-menu-item.danger:hover { background: #fef1f1; color: var(--danger); }
.row-menu-sep {
    height: 1px; background: var(--border-soft); margin: 4px 2px;
}

/* ═══════════════════════════════════════════════════════
   Detail (우측)
   ═══════════════════════════════════════════════════════ */
.detail {
    display: flex; flex-direction: column;
    min-height: 0; min-width: 0;
    background: var(--bg);
    overflow: hidden;
    position: relative;
}
.view {
    display: flex; flex-direction: column;
    flex: 1; min-height: 0; min-width: 0;
    overflow: hidden;
}
.view[hidden] { display: none; }
.view-canvas { /* 기존 detail-bar + canvas-host */ }

/* 공용 뷰 헤더 바 */
.view-bar {
    flex: 0 0 auto;
    display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
    padding: 16px 22px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.view-title h2 { margin: 0 0 2px; font-size: 18px; font-weight: 700; letter-spacing: -.01em; }
.view-sub { font-size: 12px; color: var(--muted); }
.view-actions { display: flex; gap: 8px; flex-shrink: 0; }
.view-body {
    flex: 1; min-height: 0;
    overflow-y: auto;
    padding: 22px;
}
.view-loading, .view-empty {
    padding: 48px 20px; text-align: center; color: var(--muted); font-size: 13px;
}
.view-empty .icon { font-size: 36px; opacity: .5; margin-bottom: 8px; }

/* ── 프로젝트 리스트 ───────────────────────────── */
.project-list { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
.project-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px 18px;
    display: flex; flex-direction: column; gap: 8px;
    transition: border-color .12s ease, box-shadow .12s ease, transform .12s ease;
}
.project-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 20px rgba(47,109,255,.08);
    transform: translateY(-1px);
}
.project-card .pc-head {
    display: flex; align-items: center; justify-content: space-between; gap: 10px;
}
.project-card .pc-name { font-size: 15px; font-weight: 600; color: var(--text); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-card .pc-problem {
    font-size: 12px; color: var(--muted); line-height: 1.5;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    min-height: 2.6em;
}
.project-card .pc-meta { display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--muted); }
.project-card .pc-meta .sep { opacity: .4; }
.project-card .pc-actions { display: flex; gap: 6px; margin-top: 4px; }
.project-card .pc-actions .btn { padding: 5px 10px; font-size: 12px; }

.status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 2px 8px; border-radius: 10px;
    font-size: 11px; font-weight: 600;
    line-height: 1.5;
}
.status-badge::before {
    content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}
.status-badge.status-pending { background: rgba(234,136,0,.12); color: var(--warn); }
.status-badge.status-started { background: rgba(34,134,72,.12); color: #228648; }
.status-badge.status-stopped { background: rgba(122,132,153,.14); color: var(--muted); }
.role-owner { color: var(--accent); font-weight: 600; font-size: 10px; }

/* ── 프로젝트 편집 모달 ────────────────────────── */
.modal.project-edit { width: min(640px, 100%); }
.modal .form-row { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.modal .form-row label { font-size: 12px; color: var(--muted); font-weight: 500; }
.modal .form-row input[type="text"],
.modal .form-row input[type="email"],
.modal .form-row input[type="date"],
.modal .form-row select,
.modal .form-row textarea {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
    font-family: inherit; font-size: 13px; color: var(--text); background: #fff;
}
.modal .form-row textarea { min-height: 80px; resize: vertical; }
.modal .form-row input:focus,
.modal .form-row select:focus,
.modal .form-row textarea:focus {
    outline: 2px solid rgba(47,109,255,.25); border-color: var(--accent);
}
.modal .form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

/* ── 멤버 / 초대 섹션 ──────────────────────────── */
.member-section { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border-soft); }
.member-section h4 { margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--text); }
.member-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.member-row {
    display: flex; align-items: center; gap: 10px;
    padding: 6px 10px; border-radius: 8px; background: var(--bg);
    font-size: 12px;
}
.member-row .avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--accent-soft); color: var(--accent);
    display: grid; place-items: center; font-weight: 600; font-size: 11px;
    flex: 0 0 auto;
}
.member-row .name { font-weight: 500; color: var(--text); }
.member-row .email { color: var(--muted); margin-left: 6px; }
.member-row .role { margin-left: auto; font-size: 10px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.member-row.pending { background: rgba(234,136,0,.06); }
.member-row.pending .name { color: var(--warn); }

.invite-row { display: flex; gap: 6px; margin-top: 8px; }
.invite-row input { flex: 1; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; font-family: inherit; }
.invite-row input:focus { outline: 2px solid rgba(47,109,255,.25); border-color: var(--accent); }
.invite-row .btn { flex: 0 0 auto; }

/* ── 팀원 구성 테이블 ──────────────────────────── */
.team-table-wrap {
    background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
}
.team-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.team-table th, .team-table td {
    padding: 10px 14px; text-align: left;
    border-bottom: 1px solid var(--border-soft);
}
.team-table th {
    font-size: 11px; color: var(--muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: .04em;
    background: var(--bg);
}
.team-table tr:last-child td { border-bottom: none; }
.team-table td.tt-proj { font-weight: 500; color: var(--text); }
.team-table td.tt-email { color: var(--muted); }
.team-table .pending-pill {
    display: inline-block; margin-left: 6px;
    padding: 1px 6px; font-size: 10px; font-weight: 600;
    background: rgba(234,136,0,.14); color: var(--warn);
    border-radius: 8px;
}

/* ── 알림/초대 응답 모달 ───────────────────────── */
.modal.invite-modal h3 { margin-bottom: 4px; }
.invite-card {
    background: var(--bg); border: 1px solid var(--border);
    border-radius: 10px; padding: 14px; margin: 8px 0 4px;
    font-size: 13px; line-height: 1.5; color: var(--text);
}
.invite-card .prj-name { font-weight: 600; font-size: 14px; margin-bottom: 4px; }
.invite-card .from { color: var(--muted); font-size: 12px; }

/* 상단 바: 문서 정보 + 툴바 */
.detail-bar {
    flex: 0 0 auto;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 20px;
    background: var(--panel);
    border-bottom: 1px solid var(--border);
}
.detail-header { min-width: 0; flex: 1; }
.dh-kind {
    font-size: 11px; color: var(--muted);
    font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
    margin-bottom: 2px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dh-title-row {
    display: flex; align-items: center; gap: 4px;
    min-width: 0; max-width: 100%;
}
.dh-title {
    flex: 0 1 auto;
    min-width: 0;
    font-size: 17px; font-weight: 600; line-height: 1.25;
    color: var(--text);
    padding: 2px 6px; margin-left: -6px;
    border-radius: 5px;
    outline: none;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dh-title[contenteditable="true"] {
    background: #fff;
    box-shadow: 0 0 0 2px rgba(47,109,255,.35);
    overflow: visible;
    cursor: text;
}
.dh-title[data-empty="1"] { color: var(--muted); font-weight: 500; }

.dh-edit {
    flex: 0 0 auto;
    width: 28px; height: 28px;
    padding: 0;
    border: none; background: transparent;
    color: var(--muted); border-radius: 6px;
    cursor: pointer;
    display: grid; place-items: center;
    transition: background .12s ease, color .12s ease;
}
.dh-edit:hover { background: var(--accent-soft); color: var(--accent); }
.dh-edit:active { background: #dbe6ff; }
.dh-title[data-empty="1"] ~ .dh-edit { display: none; }

.toolbar {
    flex: 0 0 auto;
    display: flex; gap: 4px;
    background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 3px;
}
.toolbar .btn { padding: 6px 10px; font-size: 12px; border: none; }
.toolbar .btn:hover { background: #fff; }

/* 캔버스 호스트 */
.canvas-host {
    flex: 1; min-height: 0;
    position: relative; overflow: hidden;
    display: grid; place-items: center;
    cursor: grab;
    padding: 24px;
}
.canvas-host.panning { cursor: grabbing; }

.canvas {
    position: relative;
    background: #fff;
    border: 1px solid var(--border);
    box-shadow: 0 8px 32px rgba(15, 23, 42, .08);
    transform-origin: center center;
    transition: transform .06s linear;
}

/* 섹션 */
.canvas .section {
    position: absolute;
    border: 1px solid rgba(122,132,153,.3);
    padding: 8px 8px 6px;
    overflow: hidden;
    background: transparent;
    display: flex; flex-direction: column;
    transition: background .12s ease, border-color .12s ease;
}
.canvas .section:hover { background: rgba(47,109,255,.025); }
.canvas .section.drag-over {
    background: rgba(47,109,255,.08);
    border-color: var(--accent);
    box-shadow: inset 0 0 0 1px var(--accent);
}
.canvas .sec-title {
    font-size: 10px; color: var(--muted); font-weight: 700;
    text-transform: uppercase; letter-spacing: .04em;
}
.canvas .sec-sub { font-size: 9px; color: var(--muted-soft); margin-bottom: 6px; }

/* 노트(포스트잇) 영역 */
.canvas .notes {
    flex: 1; min-height: 0;
    display: flex; flex-wrap: wrap; gap: 4px;
    align-content: flex-start;
    overflow: hidden;
    padding: 2px 0;
}
.canvas .note {
    background: var(--postit);
    border: 1px solid var(--postit-border);
    border-radius: 3px;
    padding: 5px 7px;
    font-size: 10px; line-height: 1.35;
    color: #2a2419;
    max-width: 100%;
    min-width: 40px;
    cursor: grab;
    user-select: none;
    white-space: pre-wrap; word-break: break-word;
    box-shadow: 0 1px 2px var(--postit-shadow), 0 0 0 1px rgba(255,255,255,.3) inset;
    transition: transform .1s ease, box-shadow .1s ease;
}
.canvas .note:hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(20, 26, 38, .18), 0 0 0 1px rgba(255,255,255,.3) inset;
}
.canvas .note:active { cursor: grabbing; }
.canvas .note.dragging { opacity: .4; }

/* 드로잉 카드 (Apple Pencil — 읽기 전용) */
.canvas .note.note-drawing {
    background: #fff;
    border: 1px solid var(--border);
    padding: 2px;
    cursor: default;
}
.canvas .note.note-drawing:hover { transform: none; }
.canvas .note.note-drawing img {
    display: block;
    max-width: 120px; max-height: 80px;
    object-fit: contain;
}
.canvas .note.note-pending {
    background: var(--border-soft);
    border: 1px dashed var(--border);
    color: var(--muted);
    font-size: 9px;
    cursor: default;
}
.canvas .note.note-pending:hover { transform: none; }

.canvas .add-note {
    align-self: flex-start;
    margin-top: 4px;
    background: transparent;
    border: 1px dashed rgba(122,132,153,.4);
    color: var(--muted);
    font-size: 10px; font-family: inherit;
    padding: 2px 8px; border-radius: 3px;
    cursor: pointer;
    transition: border-color .12s ease, color .12s ease, background .12s ease;
}
.canvas .add-note:hover {
    border-color: var(--accent); color: var(--accent);
    background: rgba(47,109,255,.04);
    border-style: solid;
}

/* 빈 상태 */
.empty {
    position: absolute; inset: 0;
    display: grid; place-items: center;
    color: var(--muted); text-align: center; padding: 32px;
    pointer-events: none;
}
.empty p { margin: 8px 0 0; font-size: 14px; line-height: 1.6; }
.empty-icon { font-size: 40px; opacity: .6; }

/* ═══════════════════════════════════════════════════════
   Modal (공용)
   ═══════════════════════════════════════════════════════ */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(20, 26, 38, .48);
    display: grid; place-items: center; z-index: 100;
    padding: 20px;
    animation: fadeIn .12s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    width: min(520px, 100%);
    max-height: calc(100vh - 40px);
    background: #fff; border-radius: 14px;
    padding: 22px 22px 18px;
    box-shadow: 0 20px 60px rgba(0,0,0,.22);
    display: flex; flex-direction: column;
    overflow: hidden;
}
.modal h3 { margin: 0 0 2px; font-size: 18px; font-weight: 700; }
.modal .sub { color: var(--muted); font-size: 13px; margin-bottom: 14px; }
.modal textarea {
    width: 100%; min-height: 140px; padding: 10px 12px;
    border: 1px solid var(--border); border-radius: 8px;
    font-family: inherit; font-size: 14px; resize: vertical;
    color: var(--text); background: #fff;
}
.modal textarea:focus { outline: 2px solid rgba(47,109,255,.25); border-color: var(--accent); }
.modal .actions {
    display: flex; justify-content: flex-end; gap: 8px;
    margin-top: 14px;
    flex-wrap: wrap;
}

/* 템플릿 피커 (카드 그리드) */
.modal.picker { width: min(640px, 100%); }
.modal.picker .template-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    overflow-y: auto;
    padding: 2px;
}
.template-card {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    text-align: left;
    cursor: pointer;
    font-family: inherit; color: var(--text);
    display: flex; flex-direction: column; gap: 6px;
    transition: border-color .12s ease, transform .12s ease, box-shadow .12s ease;
}
.template-card:hover {
    border-color: var(--accent);
    box-shadow: 0 6px 18px rgba(47,109,255,.12);
    transform: translateY(-1px);
}
.template-card .tc-preview {
    position: relative;
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border-soft);
    border-radius: 5px;
    margin-bottom: 4px;
    overflow: hidden;
}
.template-card .tc-cell {
    position: absolute;
    border: 1px solid rgba(47,109,255,.3);
    background: rgba(47,109,255,.06);
}
.template-card .tc-name { font-size: 14px; font-weight: 600; }
.template-card .tc-en   { font-size: 11px; color: var(--muted); margin-top: -2px; }
.template-card .tc-desc {
    font-size: 12px; color: var(--muted); line-height: 1.5;
    margin-top: 4px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ═══════════════════════════════════════════════════════
   반응형
   ═══════════════════════════════════════════════════════ */
@media (max-width: 760px) {
    .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
    .sidebar { border-right: none; border-bottom: 1px solid var(--border); max-height: 48vh; }
    .detail-bar { padding: 10px 14px; gap: 10px; }
    .dh-title { font-size: 15px; }
}
