:root {
    --bg-main: #141414;
    --bg-sidebar: #1e1e1e;
    --bg-header: #2a2a2a;
    --text-main: #e0e0e0;
    --text-muted: #888888;
    --accent-blue: #4a90e2;
    --accent-blue-glow: #4a90e280;
    --border-color: #333333;
    --btn-bg: #222222;
    --btn-hover: #3a3a3a;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body, html {
    width: 100%;
    height: 100%;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    overflow: hidden;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

/* Header / Top Navigation */
.top-nav {
    display: flex;
    align-items: center;
    background-color: var(--bg-header);
    height: 58px;
    border-bottom: 1px solid var(--border-color);
    padding-right: 15px;
}

.top-center-area {
    flex: 1;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
    padding: 0 20px;
}

.opacity-ruler-wrapper {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 6px 15px;
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,0.03);
}

.ruler-ticks {
    width: 100%;
    height: 5px;
    background-image: 
        linear-gradient(to right, rgba(255,255,255,0.2) 1px, transparent 1px),
        linear-gradient(to right, rgba(255,255,255,0.08) 1px, transparent 1px);
    background-size: 10% 100%, 2% 60%;
    background-position: 0 0, 0 100%;
    background-repeat: repeat-x;
    margin-bottom: 5px;
}

.opacity-ruler-wrapper input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    background: transparent;
    cursor: pointer;
    margin: 0;
}

.opacity-ruler-wrapper input[type="range"]::-webkit-slider-runnable-track {
    width: 100%;
    height: 2px;
    background: rgba(255,255,255,0.1);
    border-radius: 1px;
}

.opacity-ruler-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 12px;
    width: 12px;
    border-radius: 50%;
    background: #4a90e2;
    cursor: pointer;
    margin-top: -5px; /* Centers thumb on the 2px track */
    box-shadow: 0 0 10px rgba(74, 144, 226, 0.4);
    border: 2px solid #1a1a1a;
    transition: transform 0.15s ease;
}

.opacity-ruler-wrapper input[type="range"]:hover::-webkit-slider-thumb {
    transform: scale(1.2);
    background: #5fa8ff;
}

.ruler-label {
    font-size: 8px;
    font-weight: 700;
    letter-spacing: 0.15em;
    color: rgba(255,255,255,0.25);
    margin-top: 6px;
    text-transform: uppercase;
}

.logo {
    width: var(--sidebar-width, 280px);
    height: 100%;
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    font-size: 19px;
    background-color: #0c0c0c;
    flex-shrink: 0;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.brand-title {
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 0.03em;
    color: #f4f7fb;
}

.brand-subtitle {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #7e8ca0;
}

.tabs {
    display: flex;
    height: 100%;
}

.tab {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0 30px;
    height: 100%;
    font-size: 14px;
    cursor: pointer;
    position: relative;
    border-right: 1px solid var(--border-color);
    transition: all 0.2s;
}

.tab:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.tab.active {
    color: var(--accent-blue);
}

.tab.active::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background-color: var(--accent-blue);
    box-shadow: 0 -2px 10px var(--accent-blue-glow);
}

.top-actions {
    margin-left: auto;
    display: flex;
    padding-right: 18px;
    gap: 10px;
    align-items: center;
}

.session-badge {
    min-height: 34px;
    padding: 0 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
    color: #dce7f5;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    line-height: 1;
}

.session-badge strong {
    font-size: 11px;
    color: #ffffff;
}

.session-badge .badge-role {
    font-size: 9px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #8fbfff;
}

.icon-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
    color: #aeb8c5;
    font-size: 16px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s;
}

.icon-btn:hover {
    color: var(--text-main);
    background: rgba(74, 144, 226, 0.12);
    border-color: rgba(74, 144, 226, 0.35);
    transform: translateY(-1px);
}

.icon-btn.active {
    color: #d9ecff;
    background: rgba(74, 144, 226, 0.18);
    border-color: rgba(74, 144, 226, 0.58);
    box-shadow: 0 0 0 1px rgba(74, 144, 226, 0.18) inset;
}

/* Main Content Area */
.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Left Sidebar */
.left-sidebar {
    width: 220px;
    flex: 0 0 220px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

.planner-sidebar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 10px 10px 12px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0)),
        #1b1b1b;
    min-height: 100%;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-gutter: stable;
}

.sidebar-section {
    display: flex;
    flex-direction: column;
    min-height: 132px;
    position: relative;
    background: linear-gradient(180deg, rgba(255,255,255,0.02), rgba(255,255,255,0.01));
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.sidebar-section-layers {
    min-height: 190px;
}

.sidebar-section-primary {
    min-height: 148px;
    max-height: 29vh;
}

.sidebar-section-secondary,
.sidebar-section-tertiary {
    min-height: 126px;
    max-height: 17vh;
}

.sidebar-section-templates {
    min-height: 220px;
    max-height: 38vh;
    flex: 0 0 auto;
    overflow: hidden;
}

.sidebar-section-header {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 14px 11px;
    background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.015));
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.sidebar-section-header-action {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
}

.sidebar-section-header-controls {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}







.sidebar-collapse-btn {
    width: 28px;
    height: 28px;
    border-radius: 9px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.03);
    color: #b9c7d8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease, color 0.16s ease;
}

.sidebar-collapse-btn:hover {
    background: rgba(74, 144, 226, 0.12);
    border-color: rgba(74, 144, 226, 0.38);
    color: #ecf5ff;
    transform: translateY(-1px);
}

.sidebar-section.collapsed {
    min-height: auto !important;
    max-height: none !important;
    flex: 0 0 auto !important;
}

.sidebar-section.collapsed .sidebar-section-list,
.sidebar-section.collapsed .sidebar-templates-list,
.sidebar-section.collapsed .sidebar-section-resize-handle {
    display: none;
}

.sidebar-section.collapsed .sidebar-section-header {
    border-bottom: none;
}

.sidebar-section.collapsed .sidebar-collapse-btn i {
    transform: rotate(180deg);
}

.left-sidebar-resize-handle {
    width: 8px;
    flex: 0 0 8px;
    cursor: col-resize;
    position: relative;
    background: transparent;
}

.left-sidebar-resize-handle::before {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: 3px;
    width: 2px;
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
}

.left-sidebar-resize-handle:hover::before,
.left-sidebar-resize-handle.is-dragging::before {
    background: rgba(74, 144, 226, 0.45);
    box-shadow: 0 0 10px rgba(74, 144, 226, 0.24);
}

.sidebar-section-resize-handle {
    height: 18px;
    flex: 0 0 18px;
    border: none;
    background: transparent;
    cursor: ns-resize;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    touch-action: none;
    pointer-events: auto;
    user-select: none;
    -webkit-user-select: none;
}

.sidebar-section-resize-handle::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 7px;
    transform: translateX(-50%);
    width: 44px;
    height: 4px;
    border-radius: 999px;
    background: rgba(255,255,255,0.12);
}

.sidebar-section-resize-handle:hover::before,
.sidebar-section-resize-handle.is-dragging::before {
    background: rgba(74, 144, 226, 0.52);
    box-shadow: 0 0 12px rgba(74, 144, 226, 0.22);
}

.sidebar-section-kicker {
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #7f8a98;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: #f2f5f8;
}

.sidebar-section-title i {
    color: #86b8ff;
    font-size: 13px;
}

.sidebar-add-btn {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    border: 1px solid rgba(113, 178, 255, 0.4);
    background: linear-gradient(180deg, rgba(74, 144, 226, 0.95), rgba(53, 103, 176, 0.95));
    color: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
    box-shadow: 0 8px 18px rgba(44, 112, 194, 0.22);
}

.sidebar-add-btn:hover {
    transform: translateY(-1px);
    border-color: rgba(160, 210, 255, 0.65);
    box-shadow: 0 10px 22px rgba(44, 112, 194, 0.28);
}

.sidebar-section-list,
.sidebar-templates-list {
    flex: 1;
    overflow-y: auto;
    padding-bottom: 16px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.sidebar-search-wrap {
    padding: 10px 12px 8px;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.012);
}

.sidebar-search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 10px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(12, 14, 18, 0.72);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
}

.sidebar-search-field > i {
    color: #7f8ea0;
    font-size: 12px;
    flex-shrink: 0;
}

.sidebar-search-field input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: #eef5ff;
    font-size: 12px;
}

.sidebar-search-field input::placeholder {
    color: #758294;
}

.sidebar-search-clear {
    width: 22px;
    height: 22px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: #7f8ea0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex-shrink: 0;
}

.sidebar-search-clear:hover {
    background: rgba(255,255,255,0.06);
    color: #eef5ff;
}

.sidebar-empty-state {
    padding: 14px;
    color: #7e8794;
    font-style: italic;
    font-size: 11px;
    line-height: 1.45;
}

.help-modal-box {
    max-width: 520px;
}

.login-brand {
    margin-bottom: 10px;
    font-size: 11px;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #86b8ff;
}

.calib-modal-sub {
    margin: 0 0 14px;
    font-size: 12px;
    line-height: 1.5;
    color: #aeb8c5;
}

.onboarding-box {
    max-width: 620px;
}

.onboarding-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.onboarding-card {
    border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(180deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
    border-radius: 12px;
    padding: 14px;
    min-height: 118px;
}

.onboarding-card strong {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    color: #f4f7fb;
}

.onboarding-card span {
    display: block;
    font-size: 12px;
    line-height: 1.55;
    color: #aeb8c5;
}

.onboarding-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}


.admin-section-card {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 14px;
    padding: 14px;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
    margin-bottom: 12px;
}

.admin-section-head {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.admin-section-head strong {
    color: #f5f8ff;
    font-size: 15px;
}

.admin-section-head span {
    color: #9ba8ba;
    font-size: 12px;
    line-height: 1.45;
}

.admin-users-section .users-admin-list {
    max-height: 34vh;
}

.admin-summary-section .admin-summary-grid {
    margin-bottom: 0;
}

.admin-users-toolbar {
    margin-bottom: 12px;
}

.users-admin-box {
    max-width: 760px;
    max-height: min(88vh, 860px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.users-admin-toolbar {
    display: flex;
    gap: 10px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}

.users-admin-list {
    max-height: 42vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 12px;
}

.templates-admin-list {
    max-height: 26vh;
    margin-top: 10px;
    margin-bottom: 0;
}

.admin-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.admin-summary-card {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 10px 12px;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
}

.admin-summary-label {
    font-size: 10px;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #7f8fa3;
    margin-bottom: 6px;
}

.admin-summary-value {
    font-size: 20px;
    font-weight: 700;
    color: #f4f8fc;
}

.admin-ops-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 12px;
}

.admin-ops-card {
    border: 1px solid rgba(255,255,255,0.08);
    border-radius: 12px;
    padding: 12px;
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
}

.admin-ops-card strong {
    display: block;
    margin-bottom: 8px;
    color: #eef6ff;
    font-size: 13px;
}

.admin-ops-meta {
    font-size: 12px;
    line-height: 1.55;
    color: #aeb8c5;
    white-space: pre-line;
}

.user-admin-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.08);
    background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.015));
}

.user-admin-main {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.user-admin-name {
    font-size: 14px;
    font-weight: 700;
    color: #f5f8fb;
}

.user-admin-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 11px;
    color: #9aa7b8;
}

.user-role-pill {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 10px;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    background: rgba(74, 144, 226, 0.14);
    color: #8fc0ff;
    border: 1px solid rgba(74, 144, 226, 0.24);
}

.user-role-pill.user-role-admin {
    background: rgba(43, 183, 123, 0.14);
    color: #89e5bf;
    border-color: rgba(43, 183, 123, 0.24);
}

.user-admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: flex-end;
}

.user-admin-btn {
    border: 1px solid rgba(255,255,255,0.08);
    background: rgba(255,255,255,0.04);
    color: #dde7f4;
    border-radius: 10px;
    padding: 7px 10px;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
}

.user-admin-btn:hover {
    background: rgba(74, 144, 226, 0.14);
    border-color: rgba(74, 144, 226, 0.25);
}

.user-admin-btn.danger:hover {
    background: rgba(230, 57, 70, 0.14);
    border-color: rgba(230, 57, 70, 0.26);
}

.template-admin-box {
    width: min(560px, calc(100vw - 32px));
}

.template-admin-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.template-upload-label {
    font-size: 12px;
    font-weight: 700;
    color: #dce7f5;
}

.template-toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #b7c4d4;
}

.template-toggle input {
    accent-color: #4a90e2;
}

.help-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 4px;
}

.help-item {
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255,255,255,0.03);
    border: 1px solid rgba(255,255,255,0.06);
}

.help-item strong {
    display: block;
    margin-bottom: 4px;
    font-size: 12px;
    font-weight: 700;
    color: #f3f6fb;
}

.help-item span {
    display: block;
    font-size: 12px;
    line-height: 1.45;
    color: #a9b4c2;
}

.patient-info {
    padding: 15px 20px;
    font-size: 13px;
    color: #bbb;
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 1px;
}

.patient-info i {
    margin-right: 8px;
}

.search-container {
    padding: 15px;
    position: relative;
}

.search-container input {
    width: 100%;
    background-color: var(--bg-main);
    border: 1px solid var(--accent-blue);
    border-radius: 20px;
    padding: 8px 15px 8px 35px;
    color: var(--text-main);
    outline: none;
    box-shadow: 0 0 5px var(--accent-blue-glow);
}

.search-icon {
    position: absolute;
    left: 25px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--accent-blue);
    font-size: 14px;
}

.template-list {
    flex: 1;
    overflow-y: auto;
}

.template-item {
    display: flex;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    position: relative;
    transition: background 0.2s;
}

.template-actions-inline {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
}

.template-item:hover {
    background-color: rgba(255, 255, 255, 0.03);
}

.template-item.active {
    background-color: rgba(255, 255, 255, 0.05);
}

.template-item.active::before {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background-color: var(--accent-blue);
}

.template-icon {
    font-size: 20px;
    color: var(--text-muted);
    margin-right: 15px;
}

.template-details {
    display: flex;
    flex-direction: column;
    flex: 1;
}

.template-name {
    font-size: 13px;
    margin-bottom: 4px;
}

.template-brand {
    font-size: 11px;
    color: var(--accent-blue);
}

.expand-icon {
    color: var(--text-muted);
    font-size: 12px;
}

/* Canvas Area */
.canvas-container {
    flex: 1;
    position: relative;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    touch-action: none;
    -ms-touch-action: none;
    gap: 1px;
}

.canvas-container.dual-view-active {
    display: grid;
    grid-template-columns: 1fr 1fr;
    background-color: var(--border-color);
}

.canvas-container.dual-view-active .canvas-pane {
    border: 1px solid rgba(255,255,255,0.08);
    transition: box-shadow 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
    cursor: default;
}

.canvas-container.dual-view-active .canvas-pane.is-workspace-active {
    border-color: rgba(74, 144, 226, 0.8);
    box-shadow: inset 0 0 0 1px rgba(74, 144, 226, 0.9), 0 0 24px rgba(74, 144, 226, 0.18);
    z-index: 2;
}

.canvas-container.dual-view-active .canvas-pane:not(.is-workspace-active) {
    filter: saturate(0.92);
}

.canvas-pane {
    position: relative;
    width: 100%;
    height: 100%;
    background-color: #000;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.compare-pane-preview {
    position: absolute;
    inset: 0;
    display: none;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background:
        radial-gradient(circle at top, rgba(255,255,255,0.02), rgba(255,255,255,0) 45%),
        #000;
    z-index: 20;
}

.canvas-pane.compare-preview-active .compare-pane-preview {
    display: flex;
}

.canvas-pane.compare-preview-active canvas,
.canvas-pane.compare-preview-active .canvas-container,
.canvas-pane.compare-preview-active .upload-btn,
.canvas-pane.compare-preview-active .canvas-wrapper,
.canvas-pane.compare-preview-active .upper-canvas,
.canvas-pane.compare-preview-active .lower-canvas {
    display: none !important;
}

.compare-pane-header {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(74, 144, 226, 0.22);
    background: rgba(12, 18, 26, 0.72);
    backdrop-filter: blur(8px);
}

.compare-pane-kicker {
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #7e8da2;
}

.compare-pane-title {
    font-size: 16px;
    font-weight: 700;
    color: #f4f8ff;
}

.compare-pane-meta {
    font-size: 12px;
    color: #a9b7c8;
}

.compare-pane-body {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    border-radius: 16px;
    border: 1px solid rgba(255,255,255,0.06);
    background: rgba(255,255,255,0.02);
    overflow: hidden;
    padding: 16px;
}

.compare-pane-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 12px 24px rgba(0,0,0,0.34));
}

.compare-iframe-shell {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px;
    background:
        linear-gradient(180deg, rgba(255,255,255,0.03), rgba(255,255,255,0)),
        #000;
    z-index: 18;
}

.compare-iframe-bar {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(74, 144, 226, 0.2);
    background: rgba(10, 15, 24, 0.82);
    backdrop-filter: blur(8px);
    cursor: pointer;
}

.compare-iframe-kicker {
    font-size: 10px;
    line-height: 1;
    letter-spacing: 0.16em;
    text-transform: uppercase;
    color: #7f8da0;
}

.compare-iframe-title {
    font-size: 15px;
    font-weight: 700;
    color: #f5f8fd;
}

.compare-iframe-actions {
    position: absolute;
    top: 22px;
    right: 24px;
    z-index: 4;
    display: flex;
    gap: 8px;
}

.compare-pane-window-btn {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.12);
    background: rgba(20, 24, 30, 0.88);
    color: #f4f7fb;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
}

.compare-pane-window-btn:hover {
    background: rgba(34, 43, 56, 0.96);
    border-color: rgba(74, 144, 226, 0.46);
    transform: translateY(-1px);
}

.compare-pane-window-btn.is-close:hover {
    border-color: rgba(230, 57, 70, 0.55);
    background: rgba(56, 22, 28, 0.95);
}

.compare-iframe {
    flex: 1;
    width: 100%;
    min-height: 0;
    border: 1px solid rgba(255,255,255,0.06);
    border-radius: 16px;
    background: #0a0a0a;
}

body.embedded-mode .left-sidebar,
body.embedded-mode .left-sidebar-resize-handle {
    display: none !important;
}

body.embedded-mode .logo {
    width: auto;
    min-width: 0;
    padding: 0 12px;
    background: transparent;
}

body.embedded-mode .brand-copy {
    display: none;
}

body.embedded-mode .top-nav,
body.embedded-mode .right-sidebar {
    display: none !important;
}

body.embedded-mode #btnDualView,
body.embedded-mode #btnOnboarding,
body.embedded-mode #btnAddUser,
body.embedded-mode #btnLogout {
    display: none !important;
}

body.embedded-mode #legalNotice {
    display: none;
}

body.embedded-mode .main-content {
    height: 100vh;
}

body.embedded-mode .canvas-container,
body.embedded-mode .canvas-pane {
    width: 100vw;
    height: 100vh;
}

.canvas-container canvas,
.canvas-container .canvas-container,
.canvas-container .upper-canvas,
.canvas-container .lower-canvas {
    touch-action: none !important;
    -ms-touch-action: none !important;
}

.upload-btn {
    position: absolute;
    z-index: 10;
    padding: 12px 24px;
    background-color: var(--accent-blue);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    transition: background 0.2s;
}

.upload-btn:hover {
    background-color: #357ebd;
}

/* Right Sidebar (Toolbar) */
.right-sidebar {
    width: 100px;
    background-color: var(--bg-sidebar);
    border-left: 1px solid var(--border-color);
    display: flex;
    padding-top: 10px;
}

.sidebar-tabs {
    writing-mode: vertical-rl;
    transform: rotate(180deg);
    display: flex;
    align-items: center;
    border-right: 1px solid var(--border-color);
    width: 30px;
}

.sidebar-tab {
    padding: 20px 0;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    letter-spacing: 2px;
}

.sidebar-tab.active {
    color: #e4a834; /* Gold color from screenshot */
}

.toolbar {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    gap: 15px;
    overflow-y: auto;
}

.tool-btn {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--btn-bg);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s;
}

.tool-btn:hover, .tool-btn.active {
    background-color: var(--btn-hover);
    color: white;
    box-shadow: 0 0 10px rgba(255,255,255,0.1);
}

.tool-btn.text-btn {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.03em;
    border-radius: 14px;
    height: 32px;
    min-width: 58px;
    width: auto;
    padding: 0 10px;
    background: rgba(255,255,255,0.025);
}

.tool-btn.text-icon {
    font-size: 16px;
    font-weight: bold;
}

.spacer {
    flex: 1;
}

.delete-btn {
    background-color: #2a1111;
    color: #ff4444;
    border-color: #441111;
}

.delete-btn:hover {
    background-color: #ff4444;
    color: white;
}

/* Scale display badge */
.scale-display {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(8px);
    color: #4a90e2;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 1px;
    padding: 6px 16px;
    border-radius: 20px;
    border: 1px solid rgba(74, 144, 226, 0.4);
    opacity: 0.4;
    transition: opacity 0.3s;
    z-index: 100;
    pointer-events: none;
}

.legal-notice {
    position: fixed;
    left: 240px;
    bottom: 18px;
    max-width: 320px;
    padding: 7px 11px;
    border-radius: 12px;
    background: rgba(10, 10, 10, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.58);
    font-size: 10px;
    line-height: 1.35;
    backdrop-filter: blur(10px);
    z-index: 25;
    pointer-events: none;
}

/* Calibration Modal */
.calib-modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.calib-modal.open {
    display: flex;
}

.calib-modal-box {
    background: #1e1e1e;
    border: 1px solid #333;
    border-radius: 12px;
    padding: 30px;
    width: 360px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    display: flex;
    flex-direction: column;
    gap: 14px;
    animation: popIn 0.2s ease;
}

.plan-meta-display {
    position: fixed;
    left: 50%;
    top: 84px;
    bottom: auto;
    right: auto;
    transform: translateX(-50%);
    max-width: min(60vw, 760px);
    min-width: 320px;
    padding: 10px 18px;
    border-radius: 16px;
    border: 1px solid rgba(73, 139, 230, 0.35);
    background: rgba(25, 31, 42, 0.86);
    backdrop-filter: blur(8px);
    color: #9fc4ff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.25;
    letter-spacing: 0.01em;
    text-align: center;
    white-space: normal;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.28);
    z-index: 1100;
    opacity: 1;
    transition: opacity 0.18s ease, transform 0.18s ease;
}

.plan-meta-display.is-hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateX(-50%) translateY(-10px);
}

@keyframes popIn {
    from { transform: scale(0.9); opacity: 0; }
    to   { transform: scale(1);   opacity: 1; }
}

.calib-modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #4a90e2;
}

.calib-modal-sub {
    font-size: 13px;
    color: #aaa;
    margin: 0;
}

.calib-modal-box input[type="number"] {
    width: 100%;
    background: #111;
    border: 1px solid #4a90e2;
    border-radius: 6px;
    padding: 10px 14px;
    color: #fff;
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s;
}

.calib-modal-box input[type="number"]:focus {
    border-color: #80b8ff;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

.calib-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.calib-btn {
    padding: 9px 22px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    border: none;
    font-weight: 600;
    transition: all 0.2s;
}

.calib-cancel {
    background: #2a2a2a;
    color: #aaa;
    border: 1px solid #444;
}

.calib-cancel:hover {
    background: #333;
    color: #fff;
}

.calib-confirm {
    background: #4a90e2;
    color: #fff;
}

.calib-confirm:hover {
    background: #357ebd;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.4);
}

/* Active tool highlight */
.tool-btn.active {
    background: rgba(74, 144, 226, 0.25);
    border-color: #4a90e2;
    color: #4a90e2;
    box-shadow: 0 0 12px rgba(74, 144, 226, 0.3);
}

/* Canvas cursor crosshair via data attribute */
.canvas-container.drawing-mode canvas {
    cursor: crosshair !important;
}

/* Layer List Styling */
.layers-list {
    margin: 0;
    padding: 0;
    list-style: none;
}
.layer-item {
    display: grid;
    grid-template-columns: 12px minmax(0, 1fr) 20px 38px auto;
    align-items: center;
    column-gap: 7px;
    padding: 10px 12px;
    background: rgba(10, 10, 10, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}
.layer-item:hover {
    background: rgba(255, 255, 255, 0.05);
}
.layer-item.selected,
.layer-item.active {
    background: linear-gradient(90deg, rgba(74, 144, 226, 0.18), rgba(74, 144, 226, 0.03));
    border-color: rgba(74, 144, 226, 0.28);
}

.sidebar-record-item {
    display: block;
    padding: 12px 14px;
    background: rgba(10, 10, 10, 0.5);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.18s ease, border-color 0.18s ease;
}

.sidebar-record-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-record-item.selected,
.sidebar-record-item.active {
    background: linear-gradient(90deg, rgba(74, 144, 226, 0.18), rgba(74, 144, 226, 0.03));
    border-color: rgba(74, 144, 226, 0.28);
}
.layer-color-box {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    border: 1px solid rgba(255,255,255,0.45);
    box-shadow: 0 0 0 1px rgba(0,0,0,0.35) inset;
}
.layer-name {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.layer-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    justify-self: end;
    flex-shrink: 0;
}
.layer-action-btn {
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 11px;
    padding: 0;
    width: 14px;
    height: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}
.layer-action-btn:hover {
    color: #fff;
}
.layer-action-btn.active {
    color: #4a90e2;
}

.sidebar-item-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
    flex: 1 1 auto;
}

.sidebar-item-title {
    font-weight: 700;
    color: #f2f5f8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-item-order {
    color: #7faef2;
    font-weight: 800;
    margin-right: 4px;
}

.sidebar-item-subtitle {
    font-size: 11px;
    color: #8d97a6;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.duplicate-plan-btn {
    background: rgba(43, 57, 73, 0.78) !important;
    color: #8ec5ff !important;
    border: 1px solid rgba(74, 144, 226, 0.55) !important;
    width: 32px;
    height: 32px;
    padding: 0 !important;
    border-radius: 9px !important;
    cursor: pointer;
    font-size: 11px !important;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.duplicate-plan-btn:hover {
    background: rgba(54, 74, 95, 0.92) !important;
    border-color: rgba(120, 188, 255, 0.85) !important;
    transform: translateY(-1px);
}

.sidebar-item-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    width: 100%;
    min-width: 0;
}

.sidebar-item-actions {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.sidebar-mini-btn {
    background: rgba(43, 57, 73, 0.78) !important;
    color: #d7e4f5 !important;
    border: 1px solid rgba(255,255,255,0.12) !important;
    width: 32px;
    height: 32px;
    padding: 0 !important;
    border-radius: 9px !important;
    cursor: pointer;
    font-size: 11px !important;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, color 0.15s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.sidebar-mini-btn:hover {
    background: rgba(54, 74, 95, 0.92) !important;
    border-color: rgba(160, 188, 220, 0.42) !important;
    transform: translateY(-1px);
}

.sidebar-mini-btn-compare {
    color: #9fd0ff !important;
    border-color: rgba(108, 174, 255, 0.4) !important;
}

.sidebar-mini-btn-compare:hover {
    background: rgba(36, 62, 91, 0.92) !important;
    border-color: rgba(125, 194, 255, 0.7) !important;
}

.sidebar-mini-btn-main {
    background-color: rgba(52, 152, 219, 0.2);
    color: #3498db;
}
.sidebar-mini-btn-main:hover {
    background-color: #3498db;
    color: white;
}

.sidebar-mini-btn-ref {
    background-color: rgba(46, 204, 113, 0.2);
    color: #2ecc71;
    border-color: #2ecc71 !important;
}

.sidebar-mini-btn-ref:hover {
    background: rgba(46, 204, 113, 0.1) !important;
    border-color: #2ecc71 !important;
}

.sidebar-mini-btn-danger {
    color: #ffb3b3 !important;
    border-color: rgba(255, 107, 107, 0.35) !important;
}

.sidebar-mini-btn-danger:hover {
    background: rgba(87, 34, 34, 0.92) !important;
    border-color: rgba(255, 120, 120, 0.65) !important;
}

.plan-list-item .sidebar-item-actions {
    opacity: 0;
    transform: translateX(6px);
    pointer-events: none;
    transition: opacity 0.16s ease, transform 0.16s ease;
}

.plan-list-item:hover .sidebar-item-actions,
.plan-list-item.selected .sidebar-item-actions,
.plan-list-item:focus-within .sidebar-item-actions {
    opacity: 1;
    transform: translateX(0);
    pointer-events: auto;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .main-content {
        position: relative;
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
    }
    
    .left-sidebar {
        position: absolute; top: 0; left: 0; bottom: calc(72px + env(safe-area-inset-bottom, 0px));
        width: 85%; max-width: 320px; z-index: 1000;
        transform: translateX(-100%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none; border-right: 1px solid var(--border-color);
        overflow-y: auto;
    }

    .planner-sidebar {
        min-height: max-content;
        overflow: visible;
        gap: 8px;
        padding: 8px;
    }

    .sidebar-section-primary,
    .sidebar-section-secondary,
    .sidebar-section-tertiary {
        max-height: none;
    }

    .sidebar-section-templates {
        min-height: 220px;
        flex: 0 0 auto;
    }

    .left-sidebar-resize-handle {
        display: none;
    }

    .plan-list-item .sidebar-item-actions {
        opacity: 1;
        transform: none;
        pointer-events: auto;
    }

    .sidebar-section {
        border-radius: 12px;
    }

    .sidebar-section-header {
        padding: 11px 12px 10px;
    }

    .sidebar-section-title {
        font-size: 14px;
    }
    
    .left-sidebar.open {
        transform: translateX(0);
        box-shadow: 10px 0 30px rgba(0,0,0,0.8);
    }
    
    .right-sidebar {
        width: 100%; height: calc(72px + env(safe-area-inset-bottom, 0px)); position: fixed; bottom: 0; left: 0; right: 0;
        background: rgba(25, 25, 25, 0.95); backdrop-filter: blur(10px);
        border-left: none; border-top: 1px solid rgba(255, 255, 255, 0.1);
        padding: 0 10px env(safe-area-inset-bottom, 0px) 10px; flex-direction: row; align-items: center; z-index: 1200; overflow-x: auto;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.5);
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
    }
    
    .sidebar-tabs { display: none; }
    
    .toolbar {
        flex-direction: row; flex: 1; padding: 0; gap: 8px; align-items: center; justify-content: flex-start; overflow-x: auto;
        -webkit-overflow-scrolling: touch; height: 100%;
    }
    
    /* Disable spacer so items stay together and scroll properly */
    .toolbar .spacer { display: none; }
    
    .tool-btn {
        width: 42px; height: 42px; font-size: 16px; flex-shrink: 0;
    }
    
    .tool-btn.text-btn {
        width: auto; padding: 0 12px; height: 34px; font-size: 11px; flex-shrink: 0;
    }

    .template-admin-grid {
        grid-template-columns: 1fr;
    }
    
    .canvas-container {
        height: calc(100dvh - 50px - 72px - env(safe-area-inset-bottom, 0px)); width: 100%;
        min-height: calc(100vh - 50px - 72px);
    }
    
    /* Move scale display above the bottom toolbar */
    .scale-display {
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
        font-size: 11px;
        padding: 4px 12px;
    }

    .plan-meta-display {
        left: 50%;
        top: 72px;
        right: auto;
        bottom: auto;
        transform: translateX(-50%);
        min-width: 0;
        max-width: min(88vw, 420px);
        font-size: 10px;
        padding: 8px 12px;
    }
    
    .legal-notice {
        display: none;
    }
    
    .top-actions { padding-right: 8px; gap: 8px; }
    
    .top-actions .icon-btn { font-size: 17px; }
    
    .tab { padding: 0 12px; font-size: 12px; }
    
    #desktopLogo { display: none; }
    #btnMenuToggle { display: inline-flex !important; align-items: center; justify-content: center; font-size: 20px; width: 100%; height: 100%; }
    .upload-btn {
        z-index: 120;
        max-width: calc(100vw - 32px);
        text-align: center;
    }
}


.sidebar-section-height-controls,
.sidebar-height-controls,
.sidebar-resize-controls {
    display: none !important;
}

.sidebar-section-header-controls > *:not(.sidebar-collapse-btn) {
    display: none !important;
}
