/* Phase UI — AutoCAD-like shell (theme sáng, layout 5 vùng) */

body.phase-ui {
    --bg-main: #F4F6F8;
    --bg-sidebar: #FFFFFF;
    --bg-card: #FFFFFF;
    --bg-canvas: #EEF1F4;
    --accent: #0969DA;
    --accent-hover: #0550AE;
    --accent-soft: #DDF4FF;
    --primary: #0969DA;
    --primary-hover: #0550AE;
    --text-main: #1F2328;
    --text-dim: #656D76;
    --border: #D0D7DE;
    --shadow: 0 1px 3px rgba(31, 35, 40, 0.08);

    --shell-header-h: 50px;
    --ribbon-h: 72px;
    --project-bar-h: 40px;
    --command-h: 36px;
    --status-h: 28px;
    --sidebar-width: 260px;
    --left-width: 260px;
    --header-height: var(--shell-header-h);
}

html[data-theme="dark"] body.phase-ui {
    color-scheme: dark;
    --bg-main: #0F172A;
    --bg-sidebar: #111827;
    --bg-card: #1E293B;
    --bg-canvas: #0B1220;
    --accent: #60A5FA;
    --accent-hover: #93C5FD;
    --accent-soft: #172554;
    --primary: #3B82F6;
    --primary-hover: #60A5FA;
    --text-main: #E5E7EB;
    --text-dim: #94A3B8;
    --border: #334155;
    --bg-hover: rgba(148, 163, 184, 0.14);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.45);
}

body.phase-ui .header-pref-select {
    height: 28px;
    max-width: 92px;
    padding: 0 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: var(--bg-sidebar);
    color: var(--text-main);
    font-size: 12px;
}

body.phase-ui {
    background: var(--bg-main);
    color: var(--text-main);
}

body.phase-ui ::-webkit-scrollbar-thumb {
    background: #c8d1da;
}

body.phase-ui .app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* --- Compact single-row header --- */
body.phase-ui .shell-header {
    min-height: var(--shell-header-h);
    height: var(--shell-header-h);
    padding: 0 14px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    z-index: 100;
}

body.phase-ui .shell-header .header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 auto;
    min-width: 0;
}

body.phase-ui .shell-header .header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

body.phase-ui .shell-header .brand {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex: 0 0 auto;
}

body.phase-ui .shell-header .brand-logo {
    width: 28px;
    height: 28px;
    object-fit: contain;
    border-radius: 7px;
    flex-shrink: 0;
    display: block;
}

body.phase-ui .shell-header .brand-name {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    white-space: nowrap;
}

/* Breadcrumb ngay trên header */
body.phase-ui .header-crumb {
    display: flex;
    align-items: center;
    gap: 5px;
    padding-left: 12px;
    margin-left: 2px;
    border-left: 1px solid var(--border);
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 12px;
    color: var(--text-dim);
}

body.phase-ui .header-crumb .crumb-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

body.phase-ui .header-crumb .crumb-sep {
    color: #afb8c1;
    margin: 0 1px;
}

body.phase-ui .header-crumb strong {
    color: var(--text-main);
    font-weight: 600;
    font-size: 12.5px;
    max-width: 160px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Autosave "Đã lưu ✓" gọn trên header */
body.phase-ui .header-autosave {
    font-size: 11.5px;
    color: var(--text-dim);
    white-space: nowrap;
    min-width: 0;
}

/* Đường kẻ dọc phân nhóm */
body.phase-ui .hdr-divider {
    width: 1px;
    height: 22px;
    background: var(--border);
    flex: 0 0 auto;
}

/* Menu Tệp (details/summary) */
body.phase-ui .hdr-menu {
    position: relative;
    flex: 0 0 auto;
}

body.phase-ui .hdr-menu-btn {
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.78rem;
    padding: 5px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    cursor: pointer;
    user-select: none;
}

body.phase-ui .hdr-menu-btn::-webkit-details-marker { display: none; }
body.phase-ui .hdr-menu[open] .hdr-menu-btn {
    border-color: var(--primary);
    background: var(--accent-soft);
    color: var(--primary);
}

body.phase-ui .hdr-menu-pop {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(31, 35, 40, 0.16);
    padding: 6px;
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

body.phase-ui .hdr-menu-pop button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    text-align: left;
    padding: 7px 10px;
    border: none;
    background: transparent;
    color: var(--text-main);
    font-size: 0.8rem;
    border-radius: 6px;
    cursor: pointer;
    font-family: inherit;
}

body.phase-ui .hdr-menu-pop button:hover {
    background: var(--accent-soft);
    color: var(--primary);
}

body.phase-ui .hdr-menu-pop button i {
    width: 15px;
    height: 15px;
}

body.phase-ui .hdr-menu-sep {
    height: 1px;
    background: var(--border);
    margin: 3px 2px;
}

/* Nút Khóa dạng icon vuông */
body.phase-ui .btn-lock.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 6px;
    background: var(--accent-soft);
    color: var(--primary);
    border: 1px solid #9cd7ff;
    cursor: pointer;
}

body.phase-ui .btn-lock.btn-icon i { width: 16px; height: 16px; }

body.phase-ui .btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

/* --- Presence indicator (kiểu Figma / M365) --- */
body.phase-ui .header-user-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex: 0 0 auto;
}

body.phase-ui .presence {
    position: relative;
    width: 30px;
    height: 30px;
    flex: 0 0 auto;
    cursor: default;
    outline: none;
}

body.phase-ui .presence-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, var(--primary), #6366f1);
    text-transform: uppercase;
    user-select: none;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

body.phase-ui .presence-avatar--lg {
    width: 34px;
    height: 34px;
    font-size: 13px;
}

/* Chấm trạng thái góc dưới-phải */
body.phase-ui .presence-dot {
    position: absolute;
    right: -1px;
    bottom: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    border: 2px solid var(--bg-sidebar);
    background: #9ca3af;
}

body.phase-ui .presence-row .presence-dot,
body.phase-ui .presence-pop .presence-dot {
    position: static;
    border-color: #fff;
}

body.phase-ui .presence-dot--online {
    background: #22c55e;
    animation: presencePulse 2.4s ease-in-out infinite;
}

body.phase-ui .presence-dot--viewing {
    background: #f59e0b;
    animation: none;
}

body.phase-ui .presence-dot--offline {
    background: #9ca3af;
    animation: none;
}

@keyframes presencePulse {
    0% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(34, 197, 94, 0); }
    100% { box-shadow: 0 0 0 0 rgba(34, 197, 94, 0); }
}

/* Tooltip popup */
body.phase-ui .presence-pop {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 220px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(31, 35, 40, 0.18);
    padding: 12px;
    z-index: 320;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-4px);
    transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s;
}

body.phase-ui .presence:hover .presence-pop,
body.phase-ui .presence:focus .presence-pop,
body.phase-ui .presence:focus-within .presence-pop {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

body.phase-ui .presence-pop-head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

body.phase-ui .presence-pop-id {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

body.phase-ui .presence-pop-id strong {
    font-size: 13px;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.phase-ui .presence-sub {
    font-size: 11.5px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

body.phase-ui .presence-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12px;
    color: var(--text-main);
    margin-top: 4px;
}

body.phase-ui .presence-row.presence-meta {
    color: var(--text-dim);
    font-size: 11.5px;
}

body.phase-ui .presence-sep { color: #c4ccd4; }

/* Trạng thái người dùng dưới footer */
body.phase-ui .shell-status-bar .status-user {
    color: var(--text-dim);
    white-space: nowrap;
}
body.phase-ui .shell-status-bar .status-user strong { color: var(--text-main); }

/* --- Ribbon --- */
body.phase-ui .shell-ribbon {
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: var(--ribbon-h);
    transition: min-height 0.2s ease;
}

body.phase-ui.ribbon-collapsed .shell-ribbon {
    min-height: 32px;
}

body.phase-ui.ribbon-collapsed .ribbon-body {
    display: none;
}

body.phase-ui .ribbon-tabs {
    display: flex;
    gap: 2px;
    padding: 4px 8px 0;
    flex-shrink: 0;
}

body.phase-ui .ribbon-tab {
    border: none;
    background: transparent;
    color: var(--text-dim);
    padding: 6px 12px;
    border-radius: 6px 6px 0 0;
    font-size: 0.78rem;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
}

body.phase-ui .ribbon-tab:hover {
    background: var(--bg-main);
    color: var(--text-main);
}

body.phase-ui .ribbon-tab.active {
    background: var(--accent-soft);
    color: var(--primary);
    font-weight: 600;
}

body.phase-ui .ribbon-body {
    flex: 1;
    padding: 6px 10px 8px;
    overflow-x: auto;
    overflow-y: hidden;
}

body.phase-ui .ribbon-panel {
    display: none;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
}

body.phase-ui .ribbon-panel.active {
    display: flex;
}

body.phase-ui .ribbon-panel .tool-btn {
    width: auto;
    min-width: auto;
    padding: 6px 10px;
    font-size: 0.75rem;
    border-radius: 6px;
    border: 1px solid transparent;
    white-space: nowrap;
}

body.phase-ui .ribbon-panel .tool-btn:hover {
    background: var(--bg-main);
    border-color: var(--border);
    color: var(--text-main);
}

body.phase-ui .ribbon-panel .tool-btn.active {
    background: var(--accent-soft);
    color: var(--primary);
    border-color: #9cd7ff;
    box-shadow: none;
}

body.phase-ui .ribbon-hint {
    font-size: 0.72rem;
    color: var(--text-dim);
    padding: 4px 8px;
}

/* --- Project bar --- */
body.phase-ui .project-bar,
body.phase-ui #editorBuildingBar.project-bar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px 16px;
    padding: 6px 12px;
    min-height: var(--project-bar-h);
    background: #fff;
    border-bottom: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-dim);
}

body.phase-ui .project-crumb {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 6px;
}

body.phase-ui .crumb-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

body.phase-ui .crumb-sep {
    color: #afb8c1;
    margin: 0 2px;
}

body.phase-ui .project-crumb strong,
body.phase-ui #editorBuildingName {
    color: var(--text-main);
    font-weight: 600;
    font-size: 13px;
}

body.phase-ui .project-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

body.phase-ui .btn-project {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 10px;
    font-size: 11.5px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
}

body.phase-ui .btn-project i {
    width: 14px;
    height: 14px;
}

body.phase-ui .btn-project.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

body.phase-ui .btn-project.btn-slot {
    opacity: 0.55;
    cursor: not-allowed;
}

body.phase-ui .editor-status-badge {
    font-size: 11px;
}

body.phase-ui .editor-status-draft {
    background: #fff8c5;
    color: #7d4e00;
    border: 1px solid #d4a72c;
}

body.phase-ui .editor-status-published {
    background: #dafbe1;
    color: #116329;
    border: 1px solid #4ac26b;
}

body.phase-ui .editor-status-publishing {
    background: #ddf4ff;
    color: #0550ae;
    border: 1px solid #54aeff;
}

body.phase-ui .editor-status-publish-failed {
    background: #ffebe9;
    color: #cf222e;
    border: 1px solid #ff8182;
}

/* --- WE5 Validation panel --- */
body.phase-ui .validation-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 16px;
    height: 16px;
    margin-left: 4px;
    padding: 0 4px;
    border-radius: 8px;
    font-size: 10px;
    font-weight: 700;
    background: #d0d7de;
    color: #24292f;
}

body.phase-ui .validation-badge--error {
    background: #cf222e;
    color: #fff;
}

body.phase-ui .validation-badge--warn {
    background: #bf8700;
    color: #fff;
}

body.phase-ui .validation-badge--ok {
    background: #1a7f37;
    color: #fff;
}

body.phase-ui .validation-panel .validation-summary {
    margin: 8px 0;
    padding: 8px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    background: #f6f8fa;
    border: 1px solid var(--border);
}

body.phase-ui .validation-summary--error {
    background: #ffebe9;
    border-color: #ff8182;
    color: #82071e;
}

body.phase-ui .validation-summary--warn {
    background: #fff8c5;
    border-color: #d4a72c;
    color: #7d4e00;
}

body.phase-ui .validation-summary--ok {
    background: #dafbe1;
    border-color: #4ac26b;
    color: #116329;
}

body.phase-ui .validation-actions {
    display: flex;
    gap: 6px;
    margin-bottom: 10px;
}

body.phase-ui .validation-heading {
    margin: 12px 0 6px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-dim);
}

body.phase-ui .validation-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 220px;
    overflow-y: auto;
}

body.phase-ui .validation-item {
    padding: 8px 10px;
    margin-bottom: 6px;
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 0.78rem;
    line-height: 1.35;
    background: #fff;
}

body.phase-ui .validation-item--error {
    border-color: #ff8182;
    background: #fff8f8;
}

body.phase-ui .validation-item--warning {
    border-color: #d4a72c;
    background: #fffdf5;
}

body.phase-ui .validation-code {
    display: inline-block;
    font-family: ui-monospace, Consolas, monospace;
    font-size: 0.68rem;
    padding: 1px 5px;
    border-radius: 4px;
    background: #eaeef2;
    color: #57606a;
    margin-right: 4px;
}

body.phase-ui .editor-publish-hint {
    display: none;
}

body.phase-ui .version-history-panel {
    margin: 0 12px 6px;
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-main);
}

/* --- Workspace --- */
body.phase-ui .shell-workspace {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
    background: var(--bg-main);
}

body.phase-ui .shell-left {
    flex: 0 0 var(--left-width);
    width: var(--left-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border);
    display: flex;
    position: relative;
    flex-direction: column;
    min-height: 0;
    transition: width 0.2s ease, opacity 0.2s ease, border 0.2s ease, flex-basis 0.2s ease;
    overflow: hidden;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
}

body.phase-ui .shell-right {
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: none;
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    min-height: 0;
    transition: width 0.2s ease, opacity 0.2s ease, border 0.2s ease, flex-basis 0.2s ease;
    overflow: hidden;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
}

/* Tay kéo đổi rộng panel trái */
body.phase-ui .shell-left-resizer {
    position: absolute;
    top: 0;
    right: -3px;
    width: 7px;
    height: 100%;
    cursor: col-resize;
    z-index: 25;
    background: transparent;
    transition: background 0.15s;
}
body.phase-ui .shell-left-resizer:hover,
body.phase-ui .shell-left-resizer.dragging {
    background: var(--primary, #2563eb);
    opacity: 0.35;
}
body.phase-ui.left-collapsed .shell-left-resizer,
body.phase-ui.focus-mode .shell-left-resizer { display: none; }

body.phase-ui.left-collapsed .shell-left {
    flex: 0 0 0;
    width: 0;
    opacity: 0;
    border: none;
    pointer-events: none;
}

body.phase-ui.right-collapsed .shell-right,
body.phase-ui.right-collapsed .shell-right.properties-panel {
    flex: 0 0 0;
    width: 0;
    min-width: 0;
    max-width: 0;
    opacity: 0;
    border: none;
    pointer-events: none;
}

body.phase-ui .sidebar-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

body.phase-ui .sidebar-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 0.7rem;
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
    border-bottom: 2px solid transparent;
}

body.phase-ui .sidebar-tab:hover {
    color: var(--text-main);
    background: var(--bg-main);
}

body.phase-ui .sidebar-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

body.phase-ui .sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    min-height: 0;
}

body.phase-ui .sidebar-panel {
    display: none;
}

body.phase-ui .sidebar-panel.active {
    display: block;
}

body.phase-ui .explorer-tree .tree-item {
    padding: 6px 8px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 0.78rem;
    color: var(--text-dim);
    background: var(--bg-main);
}

body.phase-ui .explorer-tree .tree-item strong {
    color: var(--text-main);
}

/* --- Canvas --- */
body.phase-ui .shell-workspace .canvas-container {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    padding: 0;
    gap: 0;
    height: auto;
    overflow: hidden;
    position: relative;
    order: 0;
}

body.phase-ui .canvas-chrome {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--bg-sidebar);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

body.phase-ui .canvas-chrome button {
    font-size: 0.72rem;
    padding: 4px 8px;
    border-radius: 5px;
    border: 1px solid var(--border);
    background: var(--bg-main);
    color: var(--text-main);
    cursor: pointer;
    font-family: inherit;
}

body.phase-ui .canvas-chrome button.active,
body.phase-ui .canvas-chrome button:focus-visible {
    border-color: var(--primary);
    background: var(--accent-soft);
    color: var(--primary);
    outline: none;
}

body.phase-ui .canvas-chrome .spacer {
    flex: 1;
}

body.phase-ui .canvas-wrapper {
    flex: 1;
    background: var(--bg-canvas);
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--border);
    min-height: 120px;
    position: relative;
}

body.phase-ui .canvas-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    background-image:
        linear-gradient(rgba(31, 35, 40, 0.04) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31, 35, 40, 0.04) 1px, transparent 1px);
    background-size: 40px 40px;
    opacity: 0.6;
}

body.phase-ui #mapCanvas {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
}

body.phase-ui .edge-collapse-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 5;
    width: 20px;
    height: 44px;
    border: 1px solid var(--border);
    background: #fff;
    color: var(--primary);
    cursor: pointer;
    border-radius: 4px;
    font-size: 12px;
    padding: 0;
    box-shadow: var(--shadow);
}

body.phase-ui .edge-collapse-btn.left-edge {
    left: 4px;
}

body.phase-ui .edge-collapse-btn.right-edge {
    right: 4px;
}

/* --- Command + Status (tách hàng) --- */
body.phase-ui .shell-command-row {
    height: var(--command-h);
    background: var(--bg-sidebar);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 10px;
    gap: 10px;
    flex-shrink: 0;
}

body.phase-ui .shell-command-row .command-bar-wrap {
    flex: 1;
    max-width: none;
    border-right: none;
    margin: 0;
    padding: 0;
}

body.phase-ui .shell-command-row .command-bar-field,
body.phase-ui .shell-command-row .dynamic-input-field {
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
}

body.phase-ui .shell-status-bar {
    height: var(--status-h);
    background: #eaeef2;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 10px;
    font-size: 0.68rem;
    color: var(--text-dim);
    flex-shrink: 0;
}

body.phase-ui .shell-status-bar .status-pill {
    border: 1px solid var(--border);
    padding: 1px 7px;
    border-radius: 4px;
    background: #fff;
    white-space: nowrap;
}

body.phase-ui .shell-status-bar .status-pill.on {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--accent-soft);
}

body.phase-ui .shell-status-bar .status-grow {
    flex: 1;
}

body.phase-ui .shell-status-bar #autosaveStatus {
    margin-left: 0;
}

/* --- Right panel --- */
body.phase-ui .properties-panel,
body.phase-ui .shell-right.properties-panel {
    flex: 0 0 var(--sidebar-width);
    width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    backdrop-filter: none;
    overflow: hidden;
}

body.phase-ui .right-tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
}

body.phase-ui .right-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 4px;
    font-size: 0.72rem;
    color: var(--text-dim);
    cursor: pointer;
    font-family: inherit;
    border-bottom: 2px solid transparent;
}

body.phase-ui .right-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

body.phase-ui .right-body {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    min-height: 0;
}

body.phase-ui .right-panel {
    display: none;
}

body.phase-ui .right-panel.active {
    display: block;
}

body.phase-ui .panel-section h3 {
    color: var(--text-main);
    font-size: 0.82rem;
}

body.phase-ui .prop-group {
    background: var(--bg-main);
    border: 1px solid var(--border);
}

body.phase-ui .prop-group-title {
    color: var(--primary);
}

body.phase-ui .prop-row input,
body.phase-ui .prop-row select {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-main);
}

body.phase-ui .obj-item {
    background: var(--bg-main);
    border: 1px solid var(--border);
}

body.phase-ui .obj-item:hover {
    background: var(--accent-soft);
}

body.phase-ui .obj-item.selected {
    background: var(--accent-soft);
    border-color: var(--primary);
    color: var(--primary);
}

/* --- Layers in sidebar --- */
body.phase-ui .layer-row {
    background: var(--bg-main);
    border: 1px solid var(--border);
}

body.phase-ui .layer-row.is-active {
    border-color: var(--primary);
    background: var(--accent-soft);
}

body.phase-ui .layer-row__btn {
    background: #fff;
    border: 1px solid var(--border);
}

body.phase-ui .layer-color {
    width: 18px;
    height: 18px;
    padding: 0;
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    flex-shrink: 0;
    background: none;
}

/* --- Focus mode: ẩn panel hai bên + nhường hết chỗ cho bản vẽ --- */
body.phase-ui.focus-mode .shell-left,
body.phase-ui.focus-mode .shell-right {
    flex: 0 0 0 !important;
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    opacity: 0;
    border: none;
    pointer-events: none;
    overflow: hidden;
}

body.phase-ui.focus-mode .shell-workspace .canvas-container {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
}

body.phase-ui.focus-mode .shell-ribbon {
    min-height: 32px;
}

body.phase-ui.focus-mode .ribbon-body {
    display: none;
}

body.phase-ui.focus-mode .project-bar {
    display: none;
}

body.phase-ui.focus-mode .canvas-chrome {
    background: #1f2328;
    border-color: #30363d;
}

body.phase-ui.focus-mode .canvas-chrome button {
    background: #21262d;
    border-color: #30363d;
    color: #e6edf3;
}

/* --- Banners --- */
body.phase-ui .editor-access-banner {
    background: #fff5f5;
    border-bottom: 1px solid #ffc1c1;
    color: #82071e;
}

body.phase-ui .editor-floor-lock-banner {
    background: #fff8c5;
    border-bottom: 1px solid #d4a72c;
    color: #7d4e00;
}

body.phase-ui .editor-floor-lock-status {
    font-size: 11px;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 4px;
    margin-left: 4px;
}

body.phase-ui .editor-floor-lock-status--write {
    background: #e8f5e9;
    color: #2e7d32;
}

body.phase-ui .editor-floor-lock-status--readonly {
    background: #fff3cd;
    color: #856404;
}

body.phase-ui.editor-floor-readonly .ribbon-panel .tool-btn.tool-readonly-disabled,
body.phase-ui.editor-floor-readonly .tool-palette .tool-btn:disabled {
    opacity: 0.45;
    pointer-events: none;
}

body.phase-ui.editor-floor-readonly .project-actions .btn-project:disabled {
    opacity: 0.55;
}

/* Hide old toolbar layout */
body.phase-ui .toolbar.legacy-hidden {
    display: none !important;
}

body.phase-ui .main-content.legacy-layout {
    display: none !important;
}

/* Config panel in sidebar */
body.phase-ui .config-panel .prop-row {
    margin-bottom: 8px;
}

body.phase-ui .config-section-title {
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-dim);
    margin: 12px 0 6px;
    padding-top: 4px;
    border-top: 1px solid var(--border);
}

body.phase-ui .config-panel .config-section-title:first-child {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
}

body.phase-ui .config-bg-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 8px;
}

body.phase-ui .config-bg-actions .config-bg-trash {
    flex: 0 0 40px;
}

/* Checkbox: tránh chữ «Hiện kích thước» xuống dòng / input width 120px */
body.phase-ui .config-panel .prop-row-check {
    justify-content: flex-start;
}

body.phase-ui .config-panel .prop-row-check label {
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
    width: 100%;
    color: var(--text-dim);
}

body.phase-ui .config-panel .prop-row-check input[type="checkbox"] {
    width: auto;
    min-width: 16px;
    flex-shrink: 0;
    margin: 0;
}

body.phase-ui .tool-kbd {
    font-size: 0.65rem;
    opacity: 0.65;
    margin-left: 2px;
    font-weight: 600;
}

body.phase-ui #loadingOverlay {
    background: rgba(244, 246, 248, 0.92);
    color: var(--text-main);
}

body.phase-ui .hint-text {
    color: var(--text-dim);
    font-size: 0.78rem;
}

body.phase-ui .secure-lock-modal {
    background: #fff;
    border: 1px solid var(--border);
    color: var(--text-main);
}

body.phase-ui .secure-lock-subtitle {
    color: var(--text-dim);
}

body.phase-ui .secure-lock-input {
    background: var(--bg-main);
    border: 1px solid var(--border);
    color: var(--text-main);
}

@media (max-width: 1100px) {
    body.phase-ui {
        --sidebar-width: 220px;
        --ribbon-h: 64px;
    }
}

/* ===== Explorer (Dự án): cây tòa/tầng + nhật ký xuất bản ===== */
body.phase-ui .explorer-root {
    display: flex;
    flex-direction: column;
    gap: 10px;
    font-size: 0.8rem;
}

body.phase-ui .explorer-building {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-weight: 600;
}
body.phase-ui .explorer-building i { width: 15px; height: 15px; flex-shrink: 0; }
body.phase-ui .explorer-building-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Khối thông tin dự án trong tab Dự án */
body.phase-ui .explorer-info {
    margin: 8px 0 4px;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-main);
}
body.phase-ui .explorer-info-row {
    display: flex;
    gap: 8px;
    font-size: 0.76rem;
    padding: 2px 0;
    align-items: baseline;
}
body.phase-ui .explorer-info-label {
    color: var(--text-dim);
    flex: 0 0 58px;
}
body.phase-ui .explorer-info-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 500;
}
body.phase-ui .explorer-info-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
body.phase-ui .explorer-info-stat {
    flex: 1 1 auto;
    min-width: 46px;
    text-align: center;
    padding: 5px 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-sidebar);
}
body.phase-ui .explorer-info-stat-num {
    display: block;
    font-weight: 700;
    font-size: 0.92rem;
    color: var(--text-main);
}
body.phase-ui .explorer-info-stat-label {
    display: block;
    font-size: 0.66rem;
    color: var(--text-dim);
    margin-top: 1px;
}

body.phase-ui .explorer-floors {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
body.phase-ui .explorer-floor-manager {
    margin-top: 4px;
}
body.phase-ui .explorer-floor-actions {
    display: flex;
    gap: 6px;
    margin: 2px 0 6px;
}
body.phase-ui .explorer-floor-action-btn {
    flex: 1;
    padding: 4px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    border: 1px solid var(--border-color, rgba(0,0,0,.15));
    border-radius: 6px;
    background: transparent;
    color: var(--text-main);
    cursor: pointer;
    transition: background .12s, border-color .12s;
}
body.phase-ui .explorer-floor-action-btn:hover {
    background: var(--bg-hover, rgba(0,0,0,.05));
    border-color: var(--accent, #2563eb);
}
body.phase-ui .explorer-floor {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    width: 100%;
    padding: 7px 8px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    color: var(--text-main);
    cursor: pointer;
    text-align: left;
    transition: background .12s, border-color .12s;
}
body.phase-ui .explorer-floor.has-thumb {
    flex-direction: row;
    align-items: center;
    gap: 8px;
}
body.phase-ui .explorer-floor-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
body.phase-ui .explorer-floor-thumb {
    width: 46px;
    height: 34px;
    flex-shrink: 0;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color, rgba(0,0,0,.12));
    background: var(--bg-hover, rgba(0,0,0,.05));
}
body.phase-ui .explorer-floor-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
body.phase-ui .explorer-floor-main {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}
body.phase-ui .explorer-floor:hover { background: var(--bg-hover, rgba(0,0,0,.05)); }
body.phase-ui .explorer-floor.active {
    background: var(--accent-soft, rgba(37,99,235,.12));
    border-color: var(--accent, #2563eb);
}
body.phase-ui .explorer-floor i { width: 14px; height: 14px; opacity: .7; flex-shrink: 0; }
body.phase-ui .explorer-floor-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
body.phase-ui .explorer-floor-badges { display: flex; gap: 4px; flex-shrink: 0; align-items: center; }
body.phase-ui .explorer-floor-dup {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    color: var(--text-dim);
    cursor: pointer;
    transition: background .12s, color .12s;
}
body.phase-ui .explorer-floor-dup:hover {
    background: var(--accent-soft, rgba(37,99,235,.12));
    color: var(--accent, #2563eb);
}
body.phase-ui .explorer-floor-dup i { width: 13px; height: 13px; }
body.phase-ui .explorer-floor-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-left: 20px;
    font-size: 0.68rem;
    color: var(--text-dim);
}
body.phase-ui .explorer-badge.badge-current {
    background: var(--accent, #2563eb);
    color: #fff;
}

body.phase-ui .explorer-badge {
    font-size: 0.66rem;
    font-weight: 600;
    padding: 1px 6px;
    border-radius: 999px;
    line-height: 1.5;
    white-space: nowrap;
}
body.phase-ui .badge-pub { background: #dcfce7; color: #15803d; }
body.phase-ui .badge-draft { background: #fef9c3; color: #a16207; }
body.phase-ui .badge-empty { background: #f1f5f9; color: #64748b; }

body.phase-ui .explorer-section-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 0.76rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: .03em;
    margin-top: 4px;
    padding-top: 8px;
    border-top: 1px solid var(--border);
}
body.phase-ui .explorer-audit-count {
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 0 7px;
    font-size: 0.7rem;
    color: var(--text-main);
}
body.phase-ui .explorer-audit-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-height: 260px;
    overflow-y: auto;
}
body.phase-ui .explorer-audit-row {
    padding: 6px 8px;
    background: var(--bg-main);
    border: 1px solid var(--border);
    border-radius: 6px;
}
body.phase-ui .explorer-audit-top {
    display: flex;
    justify-content: space-between;
    gap: 6px;
    font-weight: 600;
}
body.phase-ui .explorer-audit-when { color: var(--text-dim); font-weight: 400; font-size: 0.72rem; }
body.phase-ui .explorer-audit-who { color: var(--text-dim); font-size: 0.74rem; margin-top: 2px; }
body.phase-ui .explorer-audit-counts { color: var(--text-dim); font-size: 0.72rem; margin-top: 2px; }

body.phase-ui #statusLastPublish { color: var(--text-dim); font-size: 0.72rem; }

/* ---- Block palette (thư viện block) ---- */
.block-palette-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}
.block-palette-panel {
    width: min(420px, 92vw);
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    background: var(--panel, #fff);
    color: var(--text, #0f172a);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 10px;
    box-shadow: 0 12px 40px rgba(15, 23, 42, 0.25);
    overflow: hidden;
}
.block-palette-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    font-weight: 600;
    border-bottom: 1px solid var(--border, #e2e8f0);
}
.block-palette-close {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    color: var(--text-dim, #64748b);
}
.block-palette-list {
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.block-palette-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
}
.block-palette-item:hover { background: var(--hover, #f1f5f9); }
.block-palette-info { display: flex; flex-direction: column; }
.block-palette-name { font-weight: 600; }
.block-palette-count { color: var(--text-dim, #64748b); font-size: 0.74rem; }
.block-palette-actions { display: flex; gap: 6px; }
.block-palette-empty { padding: 18px; color: var(--text-dim, #64748b); text-align: center; }
.block-palette-panel .hint-text { padding: 8px 14px; margin: 0; border-top: 1px solid var(--border, #e2e8f0); }
