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

/* Z-Index Layer System
 * =====================
 * Base Layout (1-99):
 *   - canvas-section: 1
 *   - editor-section: 10
 *   - resizer: 11
 *
 * Overlays (100-999):
 *   - canvas-loading-overlay: 500
 *
 * Popups/Dropdowns (1000-1999):
 *   - dropdown-menu: 1050
 *   - tooltips: 1100 (if needed)
 *
 * Modals (2000-9999):
 *   - modal: 2000
 *
 * Notifications (10000+):
 *   - toast-container: 10000
 */

:root {
    --primary-color: #4285f4;
    --secondary-color: #34a853;
    --error-color: #ea4335;
}

/* Light Mode (default) */
:root, [data-theme="light"] {
    --bg-color: #f5f5f5;
    --header-bg: #ffffff;
    --border-color: #e0e0e0;
    --text-color: #333333;
    --canvas-bg: #fafafa;
    --editor-bg: #ffffff;
    --gutter-bg: #f5f5f5;
    --gutter-border: #ddd;
    --active-line: #f8f9fa;
    --selection-bg: #d3e3fd;
    --error-bg: #fef2f2;
    --error-border: #fecaca;
    --scrollbar-bg: #f5f5f5;
    --scrollbar-thumb: #c0c0c0;
    --scrollbar-thumb-hover: #999999;
}

/* Dark Mode */
[data-theme="dark"] {
    --bg-color: #1e1e1e;
    --header-bg: #2d2d2d;
    --border-color: #404040;
    --text-color: #e0e0e0;
    --canvas-bg: #252525;
    --editor-bg: #252525;
    --gutter-bg: #2d2d2d;
    --gutter-border: #404040;
    --active-line: #2a2a2a;
    --selection-bg: #264f78;
    --error-bg: #3d1f1f;
    --error-border: #5c2a2a;
    --scrollbar-bg: #2d2d2d;
    --scrollbar-thumb: #555555;
    --scrollbar-thumb-hover: #777777;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
}

/* Custom Scrollbar Styles */
/* WebKit browsers (Chrome, Safari, Edge) */
::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: var(--scrollbar-bg);
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 6px;
    border: 2px solid var(--scrollbar-bg);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

::-webkit-scrollbar-corner {
    background: var(--scrollbar-bg);
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) var(--scrollbar-bg);
}

/* CodeMirror specific scrollbar */
.cm-editor ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.cm-editor ::-webkit-scrollbar-track {
    background: var(--editor-bg);
}

.cm-editor ::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 5px;
}

.cm-editor ::-webkit-scrollbar-thumb:hover {
    background: var(--scrollbar-thumb-hover);
}

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

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 2rem;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    height: 52px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.logo-container {
    display: flex;
    align-items: flex-start;
    gap: 0;
}

.logo-img {
    height: 32px;
    width: auto;
    transition: opacity 0.2s ease;
}

/* 라이트 모드에서 white 로고가 안 보이지 않도록 색반전 */
[data-theme="light"] .logo-img {
    filter: invert(1);
}

.beta-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 12px;
    padding: 1px 4px;
    margin-top: 5px;
    font-size: 8px;
    font-weight: 400;
    color: #FFFFFF;
    background-color: #000000;
    border-radius: 99px;
    text-transform: uppercase;
    line-height: 1;
}

[data-theme="dark"] .beta-badge {
    color: #000000;
    background-color: #FFFFFF;
}

.mobile-diagram-title {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: calc(100vw - 120px); /* 햄버거 + 테마 버튼 + 여백 고려 */
}

.header-right {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

/* Navigation */
.main-nav {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-btn {
    padding: 0 8px;
    height: 30px;
    background-color: transparent;
    color: var(--text-color);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.nav-btn:hover {
    background-color: var(--bg-color);
}

/* Dropdown */
.nav-item.dropdown {
    position: relative;
}

.dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.dropdown-toggle .arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.dropdown-toggle .arrow img {
    width: 14px;
    height: 14px;
    display: block;
    opacity: 0.7;
    transition: opacity 0.2s;
}

/* Light mode - 화살표 아이콘 어둡게 */
:root .dropdown-toggle .arrow img,
[data-theme="light"] .dropdown-toggle .arrow img {
    filter: brightness(0) saturate(100%) invert(20%);
}

/* Dark mode - 화살표 아이콘 밝게 */
[data-theme="dark"] .dropdown-toggle .arrow img {
    filter: brightness(0) saturate(100%) invert(80%);
}

.dropdown-toggle.active .arrow {
    transform: rotate(180deg);
}

.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 0.5rem;
    padding: 8px 0;
    background-color: var(--header-bg);
    border: 1px solid #E5E7EB;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    min-width: 180px;
    z-index: 1050; /* Above editor-section */
    overflow: hidden;
}

.dropdown-menu.show {
    display: block;
}

.dropdown-menu-right {
    left: auto;
    right: 0;
}

.dropdown-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 8px;
    padding: 6px 8px;
    color: #475569;
    text-decoration: none;
    font-size: 14px;
    transition: background-color 0.2s;
    cursor: pointer;
    gap: 16px;
    border-radius: 6px;
}

.dropdown-item:hover {
    background-color: var(--bg-color);
}

.dropdown-item.danger {
    color: var(--error-color);
}

.dropdown-item.danger:hover {
    background-color: var(--error-bg);
}

.dropdown-divider {
    height: 1px;
    background-color: #E5E7EB;
    margin-top: 7px;
    margin-bottom: 8px;
}

.dropdown-category {
    margin: 0 8px;
    padding: 6px 8px;
    color: #94A3B8;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Dark mode - Dropdown Menu */
[data-theme="dark"] .dropdown-menu {
    border-color: #374151;
}

[data-theme="dark"] .dropdown-item {
    color: #E5E7EB;
}

[data-theme="dark"] .dropdown-divider {
    background-color: #374151;
}

[data-theme="dark"] .dropdown-category {
    color: #9CA3AF;
}

/* Keyboard Shortcut Hint */
.shortcut-hint {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-left: auto;
    white-space: nowrap;
}

.shortcut-hint kbd {
    display: inline-block;
    padding: 4px 5px;
    font-size: 11px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, monospace;
    font-weight: 500;
    color: var(--text-color);
    background-color: var(--bg-color);
    border: none;
    border-radius: 3px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
    line-height: 1;
}

.shortcut-hint .shortcut-plus {
    font-size: 10px;
    opacity: 0.5;
    padding: 0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    position: relative;
}

.user-info span {
    font-size: 14px;
}

/* User Menu Button */
.user-menu-btn {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 6px 12px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.user-menu-btn:hover {
    background-color: var(--bg-color);
    border-color: var(--text-secondary);
}

.user-menu-btn .arrow {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
}

.user-menu-btn .arrow img {
    width: 14px;
    height: 14px;
    display: block;
}

/* Light mode - 화살표 아이콘 어둡게 */
:root .user-menu-btn .arrow img,
[data-theme="light"] .user-menu-btn .arrow img {
    filter: brightness(0) saturate(100%) invert(20%);
}

/* Dark mode - 화살표 아이콘 밝게 */
[data-theme="dark"] .user-menu-btn .arrow img {
    filter: brightness(0) saturate(100%) invert(80%);
}

.user-menu-btn.active .arrow {
    transform: rotate(180deg);
}

/* Mobile Nav User Header */
.nav-user-header {
    padding: 8px 12px;
    font-weight: 500;
    color: var(--text-color);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 8px;
}

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

/* Editor Section */
.editor-section {
    display: flex;
    flex-direction: column;
    background-color: var(--editor-bg);
    border-right: 1px solid var(--border-color);
    width: 400px;
    min-width: 250px;
    max-width: 800px;
    transition: width 0.3s ease;
    position: relative;
    z-index: 10;
}

.editor-section.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    border-right: none;
    overflow: hidden;
}

.editor-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(0.375rem, 1vw, 0.5rem) 1rem; /* 6px ~ 8px vertical padding */
    border-bottom: 1px solid var(--border-color);
    min-height: clamp(48px, 10vw, 52px);
}

.editor-header h2 {
    font-size: 16px;
    font-weight: 500;
    flex: 1;
}

/* Editor Tabs */
.editor-tabs {
    display: flex;
    gap: 0;
    flex: 1;
}

.editor-tab {
    padding: 6px 16px;
    font-size: 14px;
    font-weight: 500;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}

.editor-tab:hover {
    color: var(--text-color);
}

.editor-tab.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Filter Panel */
.filter-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: var(--editor-bg);
}

.filter-search {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.filter-search input {
    width: 100%;
    padding: 8px 12px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
}

.filter-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Filter Selector */
.filter-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.filter-selector label {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
}

.filter-selector select {
    flex: 1;
    padding: 6px 8px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--bg-color);
    color: var(--text-color);
    cursor: pointer;
    min-width: 0;
}

.filter-selector select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.filter-selector .btn-icon {
    padding: 4px;
    flex-shrink: 0;
}

.filter-selector .btn-icon img {
    width: 16px;
    height: 16px;
}

.filter-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.table-tree {
    font-size: 13px;
}

/* Table Tree Actions */
.table-tree-actions {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.new-group-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: none;
    border: 1px dashed var(--border-color);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 12px;
    cursor: pointer;
    transition: all 0.15s;
    width: 100%;
    justify-content: center;
}

.new-group-action-btn:hover {
    background-color: var(--hover-bg);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.new-group-action-btn img {
    width: 14px;
    height: 14px;
    opacity: 0.7;
}

[data-theme="dark"] .new-group-action-btn img {
    filter: invert(1);
}

.new-group-action-btn:hover img {
    opacity: 1;
}

/* Table Tree Group */
.table-group {
    margin-bottom: 4px;
}

.table-group-header {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    font-weight: 500;
}

.table-group-header:hover {
    background-color: var(--hover-bg);
}

.table-group-header .group-checkbox {
    margin-right: 6px;
    cursor: pointer;
}

.table-group-header .group-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    transition: transform 0.15s;
    filter: var(--icon-filter, none);
}

[data-theme="dark"] .table-group-header .group-icon {
    filter: invert(1);
}

.table-group-header.collapsed .group-icon {
    transform: rotate(-90deg);
}

.table-group-header .group-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 8px;
}

.table-group-header .group-name {
    flex: 1;
}

.table-group-header .group-count {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
}

.table-group-items {
    display: block;
}

.table-group-header.collapsed + .table-group-items {
    display: none;
}

/* Table Item */
.table-item {
    display: flex;
    align-items: center;
    padding: 5px 12px 5px 32px;
    cursor: pointer;
    user-select: none;
}

.table-item:hover {
    background-color: var(--hover-bg);
}

.table-item input[type="checkbox"] {
    margin-right: 8px;
    cursor: pointer;
}

.table-item .table-name {
    flex: 1;
    color: var(--text-color);
}

.table-item.hidden .table-name {
    color: var(--text-muted);
    text-decoration: line-through;
}

.table-item .table-columns {
    font-size: 11px;
    color: var(--text-muted);
}

/* Drag Handle */
.table-item .drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: 4px;
    cursor: grab;
    opacity: 0.4;
    transition: opacity 0.15s;
}

.table-item .drag-handle:active {
    cursor: grabbing;
}

.table-item:hover .drag-handle {
    opacity: 0.8;
}

.table-item .drag-handle img {
    width: 12px;
    height: 12px;
}

[data-theme="dark"] .table-item .drag-handle img {
    filter: invert(1);
}

/* Drag and Drop States */
.table-item.dragging {
    opacity: 0.5;
    background-color: var(--hover-bg);
}

.table-group-header.drop-target {
    background-color: var(--primary-color);
    color: white;
}

.table-group-header.drop-target .group-icon,
.table-group-header.drop-target .group-checkbox {
    filter: invert(1) !important;
}

[data-theme="dark"] .table-group-header.drop-target .group-icon {
    filter: none !important;
}

/* ========================================
   Groups Panel (Groups Tab)
   ======================================== */

.groups-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.groups-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.groups-search input {
    width: 100%;
    padding: 6px 10px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-color);
    transition: border-color 0.2s;
}

.groups-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.groups-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.group-tree {
    font-size: 13px;
}

/* Group Tree Actions */
.group-tree-actions {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

/* Group Item */
.group-item {
    margin-bottom: 4px;
}

.group-item-header {
    display: flex;
    align-items: center;
    padding: 6px 12px;
    cursor: pointer;
    user-select: none;
    color: var(--text-secondary);
    font-weight: 500;
}

.group-item-header:hover {
    background-color: var(--hover-bg);
}

.group-item-header .group-icon {
    width: 16px;
    height: 16px;
    margin-right: 6px;
    transition: transform 0.15s;
    filter: var(--icon-filter, none);
}

[data-theme="dark"] .group-item-header .group-icon {
    filter: invert(1);
}

.group-item-header.collapsed .group-icon {
    transform: rotate(-90deg);
}

.group-item-header .group-color {
    width: 10px;
    height: 10px;
    border-radius: 2px;
    margin-right: 8px;
}

.group-item-header .group-name {
    flex: 1;
}

.group-item-header .group-count {
    font-size: 11px;
    color: var(--text-muted);
    margin-left: 8px;
}

.group-item-tables {
    display: block;
}

.group-item-header.collapsed + .group-item-tables {
    display: none;
}

/* Group Table Item (in Groups tab) */
.group-table-item {
    display: flex;
    align-items: center;
    padding: 5px 12px 5px 32px;
    cursor: pointer;
    user-select: none;
}

.group-table-item:hover {
    background-color: var(--hover-bg);
}

.group-table-item .table-name {
    flex: 1;
    color: var(--text-color);
}

.group-table-item .table-columns {
    font-size: 11px;
    color: var(--text-muted);
}

/* Group Table Item Drag Handle */
.group-table-item .drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    cursor: grab;
    opacity: 0.4;
    transition: opacity 0.15s;
}

.group-table-item .drag-handle:active {
    cursor: grabbing;
}

.group-table-item:hover .drag-handle {
    opacity: 0.8;
}

.group-table-item .drag-handle img {
    width: 12px;
    height: 12px;
}

[data-theme="dark"] .group-table-item .drag-handle img {
    filter: invert(1);
}

/* Group Table Item Drag and Drop States */
.group-table-item.dragging {
    opacity: 0.5;
    background-color: var(--hover-bg);
}

/* Group drag-over state */
.group-item.drag-over {
    background-color: rgba(74, 144, 226, 0.1);
    border-radius: 6px;
    outline: 2px dashed var(--primary-color);
    outline-offset: -2px;
}

.group-item.drag-over .group-item-header {
    background-color: var(--primary-color);
    color: white;
}

.group-item.drag-over .group-item-header .group-icon {
    filter: invert(1) !important;
}

[data-theme="dark"] .group-item.drag-over .group-item-header .group-icon {
    filter: none !important;
}

.group-item-header.drop-target {
    background-color: var(--primary-color);
    color: white;
}

.group-item-header.drop-target .group-icon {
    filter: invert(1) !important;
}

[data-theme="dark"] .group-item-header.drop-target .group-icon {
    filter: none !important;
}

/* Group Menu Button (Groups Tab) */
.group-item-header .group-menu-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 4px;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background-color 0.15s;
}

.group-item-header:hover .group-menu-btn {
    opacity: 0.7;
}

.group-item-header .group-menu-btn:hover {
    opacity: 1;
    background-color: var(--hover-bg);
}

.group-item-header .group-menu-btn img {
    width: 16px;
    height: 16px;
}

[data-theme="dark"] .group-item-header .group-menu-btn img {
    filter: invert(1);
}

/* Group Menu Button */
.table-group-header .group-menu-btn,
.table-group-header .new-group-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    margin-left: 4px;
    background: none;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s, background-color 0.15s;
}

.table-group-header:hover .group-menu-btn,
.table-group-header:hover .new-group-btn {
    opacity: 0.7;
}

.table-group-header .group-menu-btn:hover,
.table-group-header .new-group-btn:hover {
    opacity: 1;
    background-color: var(--hover-bg);
}

.table-group-header .group-menu-btn img,
.table-group-header .new-group-btn img {
    width: 16px;
    height: 16px;
}

[data-theme="dark"] .table-group-header .group-menu-btn img,
[data-theme="dark"] .table-group-header .new-group-btn img {
    filter: invert(1);
}

/* Group Context Menu */
.group-context-menu {
    position: absolute;
    z-index: 1100;
    min-width: 160px;
    background-color: var(--editor-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 4px;
    overflow: hidden;
}

.context-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    border-radius: 4px;
    color: var(--text-color);
    font-size: 13px;
    cursor: pointer;
    text-align: left;
    transition: background-color 0.15s;
}

.context-menu-item:hover {
    background-color: var(--hover-bg);
}

.context-menu-item.danger {
    color: var(--error-color);
}

.context-menu-item.danger:hover {
    background-color: rgba(234, 67, 53, 0.1);
}

.context-menu-item img {
    width: 16px;
    height: 16px;
}

[data-theme="dark"] .context-menu-item img {
    filter: invert(1);
}

.context-menu-item.danger img {
    filter: none;
}

[data-theme="dark"] .context-menu-item.danger img {
    filter: invert(27%) sepia(77%) saturate(1815%) hue-rotate(341deg) brightness(92%) contrast(97%);
}

/* Resizer */
.resizer {
    width: 4px;
    background-color: var(--border-color);
    cursor: col-resize;
    flex-shrink: 0;
    position: relative;
    z-index: 11;
}

.resizer:hover {
    background-color: var(--primary-color);
}

.resizer.resizing {
    background-color: var(--primary-color);
}

.dbml-editor {
    flex: 1;
    width: 100%;
    overflow: auto;
    background-color: var(--editor-bg);
}

/* CodeMirror overrides */
.dbml-editor .cm-editor {
    height: 100%;
}

.dbml-editor .cm-scroller {
    overflow: auto;
}

/* AI Prompt Container */
.ai-prompt-container {
    padding: 8px 10px;
    background-color: var(--editor-bg);
    border-top: 1px solid var(--border-color);
}

.ai-prompt-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-prompt-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background-color: var(--bg-color);
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    line-height: 1.4;
}

.ai-prompt-input:focus {
    border-color: var(--primary-color);
}

.ai-prompt-input:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-prompt-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    background-color: var(--primary-color);
    cursor: pointer;
    transition: background-color 0.2s, opacity 0.2s;
}

.ai-prompt-submit:hover:not(:disabled) {
    background-color: #3367d6;
}

.ai-prompt-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-prompt-submit img {
    width: 16px;
    height: 16px;
    filter: brightness(0) invert(1);
}

.ai-prompt-status {
    margin-top: 6px;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.ai-prompt-status.loading {
    background-color: #e3f2fd;
    color: #1976d2;
}

.ai-prompt-status.success {
    background-color: #e8f5e9;
    color: #388e3c;
}

.ai-prompt-status.error {
    background-color: var(--error-bg);
    color: var(--error-color);
}

/* Dark mode */
[data-theme="dark"] .ai-prompt-input {
    background-color: #2d2d2d;
    border-color: #404040;
}

[data-theme="dark"] .ai-prompt-status.loading {
    background-color: #1e3a5f;
    color: #90caf9;
}

[data-theme="dark"] .ai-prompt-status.success {
    background-color: #1b4332;
    color: #81c784;
}

/* AI Prompt - Info status */
.ai-prompt-status.info {
    background-color: #f5f5f5;
    color: #666;
}

[data-theme="dark"] .ai-prompt-status.info {
    background-color: #333;
    color: #aaa;
}

/* AI Prompt - Free tier note */
.ai-prompt-free-note {
    font-size: 11px;
    opacity: 0.7;
    font-style: italic;
}

/* AI Prompt - Cancel button */
.ai-prompt-cancel-btn {
    margin-left: auto;
    padding: 3px 10px;
    font-size: 11px;
    border: 1px solid currentColor;
    border-radius: 4px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s, background-color 0.2s;
}

.ai-prompt-cancel-btn:hover {
    opacity: 1;
    background-color: rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .ai-prompt-cancel-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.error-message {
    padding: 0.75rem 1rem;
    background-color: var(--error-bg);
    color: var(--error-color);
    border-top: 1px solid var(--error-border);
    font-size: 0.875rem;
    font-family: 'Monaco, monospace';
    line-height: 1.5;
    display: none;
}

.error-message:empty {
    display: none !important;
}

/* Canvas Section */
.canvas-section {
    display: flex;
    flex-direction: column;
    background-color: var(--canvas-bg);
    flex: 1;
    min-width: 0;
    position: relative;
    z-index: 1;
}

.canvas-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: clamp(0.375rem, 1vw, 0.5rem) 1rem; /* 6px ~ 8px vertical padding */
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    gap: 1rem;
    min-height: clamp(48px, 10vw, 52px);
    position: relative;
    z-index: 100; /* Above canvas */
}

.canvas-header h2 {
    font-size: 16px;
    font-weight: 500;
    flex: 1;
}

.filter-name {
    font-size: 11px;
    font-weight: 500;
    color: var(--text-color);
    background-color: var(--gutter-bg);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 10px;
    margin-left: 8px;
    vertical-align: middle;
}

.filter-name:empty {
    display: none;
}

.expand-editor-btn {
    margin-right: auto;
}

.canvas-controls {
    display: flex;
    gap: 0.5rem;
    position: relative;
    z-index: 101; /* Above canvas-header */
}

.canvas-controls .dropdown-menu {
    z-index: 1100; /* Above everything in canvas */
    min-width: 120px;
}

.canvas-controls .nav-item.dropdown {
    position: relative;
}

.canvas-controls .dropdown-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================
   Canvas Search Bar
   ======================================== */

.canvas-search-bar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    background: var(--editor-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.canvas-search-bar input {
    width: 150px;
    padding: 3px 8px;
    font-size: 13px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: var(--bg-color);
    color: var(--text-color);
    outline: none;
    transition: border-color 0.2s;
}

.canvas-search-bar input:focus {
    border-color: var(--primary-color);
}

.search-count {
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.6;
    white-space: nowrap;
    min-width: 32px;
    text-align: center;
}

.btn-icon-sm {
    width: 24px;
    height: 24px;
    padding: 0;
    background: transparent;
    border: none;
    border-radius: 4px;
    font-size: 10px;
    line-height: 24px;
    text-align: center;
    cursor: pointer;
    color: var(--text-color);
    opacity: 0.6;
    transition: all 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-sm:hover {
    opacity: 1;
    background-color: var(--bg-color);
}

/* Dark mode search bar adjustments */
[data-theme="dark"] .canvas-search-bar {
    border-color: #374151;
}

[data-theme="dark"] .canvas-search-bar input {
    border-color: #374151;
    background: #1e1e1e;
}

[data-theme="dark"] .btn-icon-sm:hover {
    background-color: rgba(55, 65, 81, 0.3);
}

/* Responsive: collapse search input on small screens */
@media (max-width: 768px) {
    .canvas-search-bar input {
        width: 100px;
    }
}

.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.canvas-container canvas {
    cursor: default;
    /* Prevent events from penetrating through overlapping elements */
    position: relative;
    z-index: 1;
}

/* Buttons */
.btn-primary {
    padding: 0 8px;
    height: 30px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-primary:hover {
    background-color: #3367d6;
}

.btn-secondary {
    padding: 0 8px;
    height: 30px;
    background-color: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-secondary:hover {
    background-color: var(--bg-color);
    border-color: var(--text-color);
}

.btn-danger {
    padding: 0 8px;
    height: 30px;
    background-color: transparent;
    color: var(--error-color);
    border: 1px solid var(--error-color);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-danger:hover {
    background-color: var(--error-bg);
    border-color: var(--error-color);
}

.btn-icon {
    width: 30px;
    height: 30px;
    padding: 0;
    background-color: transparent;
    color: var(--text-color);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon img {
    width: 14px;
    height: 14px;
    display: block;
    opacity: 0.7;
    transition: opacity 0.2s;
}

/* Light mode - 아이콘 어둡게 */
:root .btn-icon img,
[data-theme="light"] .btn-icon img {
    filter: brightness(0) saturate(100%) invert(20%);
}

/* Dark mode - 아이콘 밝게 */
[data-theme="dark"] .btn-icon img {
    filter: brightness(0) saturate(100%) invert(80%);
}

.btn-icon:hover {
    background-color: var(--bg-color);
}

.btn-icon:hover img {
    opacity: 1;
}

/* Canvas Header Icon Buttons - GitHub Style Border */
.canvas-controls .btn-icon {
    border: 1px solid #E5E7EB;
    border-radius: 6px;
    background-color: #ffffff;
}

.canvas-controls .btn-icon img {
    filter: brightness(0) saturate(100%) invert(15%) sepia(8%) saturate(600%) hue-rotate(180deg) brightness(98%) contrast(92%);
    /* #334155 색상 적용 */
    opacity: 1;
}

.canvas-controls .btn-icon:hover {
    background-color: #F3F4F6;
    border-color: #D1D5DB;
}

/* Grid Toggle Active State */
.canvas-controls .btn-icon.active {
    background-color: #DBEAFE;
    border-color: #3B82F6;
}

.canvas-controls .btn-icon.active img {
    filter: brightness(0) saturate(100%) invert(30%) sepia(98%) saturate(1500%) hue-rotate(207deg) brightness(98%) contrast(96%);
}

/* Dark mode - Canvas Header Buttons */
[data-theme="dark"] .canvas-controls .btn-icon {
    border: 1px solid #374151;
    background-color: transparent;
}

[data-theme="dark"] .canvas-controls .btn-icon img {
    filter: brightness(0) saturate(100%) invert(80%);
}

[data-theme="dark"] .canvas-controls .btn-icon:hover {
    background-color: rgba(55, 65, 81, 0.3);
    border-color: #4B5563;
}

/* Dark mode - Grid Toggle Active State */
[data-theme="dark"] .canvas-controls .btn-icon.active {
    background-color: rgba(59, 130, 246, 0.2);
    border-color: #3B82F6;
}

[data-theme="dark"] .canvas-controls .btn-icon.active img {
    filter: brightness(0) saturate(100%) invert(50%) sepia(98%) saturate(1500%) hue-rotate(207deg) brightness(98%) contrast(96%);
}

.btn-icon.btn-danger {
    color: var(--error-color);
    border: none;
}

.btn-icon.btn-danger:hover {
    background-color: transparent;
}

/* Login Button - Custom Style */
#login-btn,
#mobile-login-btn {
    padding: 0 8px;
    height: 30px;
    background-color: transparent !important;
    color: var(--text-color);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

#login-btn:hover,
#mobile-login-btn:hover {
    background-color: var(--bg-color) !important;
}

/* Diagram Select */
.diagram-select {
    padding: 6px 12px;
    background-color: var(--editor-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    max-width: 200px;
    transition: all 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diagram-select option {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diagram-select:hover {
    border-color: var(--primary-color);
}

.diagram-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1);
}

/* Mobile Edit Button - 데스크톱에서는 숨김 */
.mobile-edit-btn {
    display: none;
}

/* Hamburger Button - 데스크톱에서는 숨김 */
.hamburger-btn {
    display: none;
}

/* Mobile Auth Section - 데스크톱에서는 숨김 */
.nav-auth-section {
    display: none;
}

.nav-user-details {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.hamburger-icon {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: 20px;
    height: 16px;
}

.hamburger-icon span {
    display: block;
    width: 100%;
    height: 2px;
    background-color: var(--text-color);
    transition: all 0.3s ease;
}

.hamburger-btn.active .hamburger-icon span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
}

.hamburger-btn.active .hamburger-icon span:nth-child(2) {
    opacity: 0;
}

.hamburger-btn.active .hamburger-icon span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
}

/* Responsive */
@media (max-width: 1024px) {
    .editor-section {
        width: 300px;
        min-width: 200px;
        max-width: 600px;
    }
}

@media (max-width: 768px) {
    .main-content {
        flex-direction: row;
    }

    /* 햄버거 버튼 표시 */
    .hamburger-btn {
        display: flex !important;
        margin-right: 0.5rem;
    }

    /* 네비게이션 기본 숨김 */
    .main-nav {
        display: none;
        position: fixed;
        top: 52px;
        left: 0;
        width: 100%;
        background-color: var(--header-bg);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
        flex-direction: column;
        padding: 1rem;
        gap: 0;
        z-index: 1500;
        max-height: calc(100vh - 52px);
        overflow-y: auto;
    }

    .main-nav.show {
        display: flex !important;
    }

    .main-nav .nav-item {
        width: 100%;
    }

    .main-nav .nav-btn {
        width: 100%;
        justify-content: space-between;
        padding: 0.8rem 1rem;
        border-bottom: 1px solid var(--border-color);
    }

    /* Share button (non-dropdown) - align left */
    .main-nav #nav-share-btn {
        display: flex !important;
        justify-content: flex-start;
    }

    .main-nav .nav-item:last-child .nav-btn {
        border-bottom: none;
    }

    /* 드롭다운 메뉴 모바일 조정 */
    .main-nav .dropdown-menu {
        position: static;
        box-shadow: none;
        border: none;
        border-top: 1px solid var(--border-color);
        margin-top: 0;
        padding-left: 1rem;
    }

    /* 모바일 인증 섹션 표시 */
    .nav-auth-section {
        display: block !important;
        padding-top: 1rem;
        margin-top: 1rem;
    }

    .nav-auth-section .nav-btn {
        width: 100%;
        border-bottom: none;
        margin-bottom: 0.5rem;
    }

    /* 모바일 사용자 메뉴 - 다른 드롭다운과 동일한 스타일 */
    .nav-auth-section .nav-item.dropdown {
        width: 100%;
    }

    .nav-auth-section .nav-btn.dropdown-toggle {
        width: 100%;
        justify-content: space-between;
    }

    .nav-auth-section .dropdown-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        border: none;
        background: transparent;
        padding-left: 1rem;
    }

    /* 헤더의 로그인/사용자 정보 숨김 (테마 버튼은 유지) */
    .header-right #login-btn,
    .header-right #user-info {
        display: none !important;
    }

    /* 모바일에서는 에디터 기본 숨김 */
    .editor-section {
        display: none;
    }

    /* 모바일 에디터 모달 */
    .editor-section.mobile-modal {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100%;
        min-width: 100%;
        z-index: 2500; /* 모달보다 높게 */
        border: none;
        border-radius: 0;
    }

    .resizer {
        display: none;
    }

    /* 캔버스 섹션 전체 화면 */
    .canvas-section {
        width: 100%;
    }

    /* 캔버스 헤더 제목 숨김 */
    .canvas-header h2 {
        display: none;
    }

    /* 모바일 Edit 버튼 표시 */
    .mobile-edit-btn {
        display: flex !important;
    }

    /* 모바일에서 다이어그램 로딩 시 로고/베타 숨기고 제목 표시 */
    .logo-container.has-diagram .logo-img,
    .logo-container.has-diagram .beta-badge {
        display: none;
    }

    .logo-container.has-diagram .mobile-diagram-title {
        display: block !important;
    }

    /* 헤더 반응형 개선 */
    .header {
        padding: 0 1rem;
        height: 52px;
    }

    .header-left {
        gap: 0.75rem;
    }

    /* 네비게이션 간격 조정 */
    .main-nav {
        gap: 0.25rem;
    }

    .nav-btn {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    /* 모바일 에디터 헤더 */
    .editor-section.mobile-modal .editor-header {
        background-color: var(--header-bg);
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    /* 모바일 에디터 닫기 버튼 강조 */
    .editor-section.mobile-modal .btn-icon {
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    /* 터치 타겟 크기 - 패딩으로 조정 */
    .btn-icon {
        min-width: 44px;
        min-height: 44px;
    }

    .btn-primary,
    .btn-secondary {
        height: 44px;
        padding: 0 12px;
        font-size: 14px;
    }

    .mobile-edit-btn {
        height: 44px;
        padding: 0 12px;
        font-size: 14px;
    }

    /* 로고 크기 조정 */
    .logo-img {
        height: 32px;
    }

    /* 모달 전체 화면 */
    .modal-content {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        margin: 0 !important;
    }

    .modal-large,
    .modal-medium {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }

    /* 모달 바디 스크롤 활성화 */
    .modal-body {
        max-height: calc(100vh - 200px);
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    /* 모달 내부 스크롤 가능 영역 높이 조정 */
    .diagrams-list {
        max-height: calc(100vh - 300px);
    }

    .export-textarea {
        height: auto;
        max-height: calc(100vh - 300px);
        min-height: 200px;
    }

    /* 폰트 크기 가독성 향상 */
    body {
        font-size: 16px;
    }

    .diagram-item-name {
        font-size: 1.05rem;
    }

    .diagram-item-meta {
        font-size: 0.85rem;
    }

    .toast-message {
        font-size: 0.95rem;
    }

    .help-section p,
    .help-section li {
        font-size: 0.95rem;
        line-height: 1.7;
    }

    /* 드롭다운 메뉴 아이템 크기 증가 */
    .dropdown-item {
        padding: 0 12px;
        font-size: 14px;
        min-height: 44px;
        display: flex;
        align-items: center;
    }

    .dropdown-menu {
        min-width: 200px;
    }

    /* 캔버스 헤더의 드롭다운 화면 안에 위치하도록 제한 */
    .canvas-header .dropdown-menu {
        position: absolute !important;
        left: 10px !important;
        right: 10px !important;
        width: auto !important;
        max-width: none !important;
    }

    /* 캔버스 컨트롤 영역 가로 스크롤 */
    .canvas-controls {
        overflow-x: auto;
        overflow-y: hidden;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none; /* Firefox */
    }

    .canvas-controls::-webkit-scrollbar {
        display: none; /* Chrome, Safari */
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000; /* Above dropdowns */
}

.modal-content {
    background-color: var(--editor-bg);
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-color);
    background-color: var(--editor-bg);
}

/* Share Form */
.share-form {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
}

.share-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--editor-bg);
    color: var(--text-color);
    font-size: 0.9rem;
}

.share-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(66, 133, 244, 0.1);
}

.share-select {
    padding: 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--editor-bg);
    color: var(--text-color);
    font-size: 0.9rem;
    cursor: pointer;
}

.share-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Share List */
.share-list h4 {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-color);
}

.shares-container {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.share-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.share-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.share-item-email {
    font-size: 0.9rem;
    color: var(--text-color);
}

.share-item-permission {
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.7;
}

.share-item-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.share-permission-select {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--editor-bg);
    color: var(--text-color);
    font-size: 0.8rem;
    cursor: pointer;
}

.empty-shares {
    text-align: center;
    padding: 2rem;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 0.9rem;
}

/* Diagrams List */
.diagrams-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

.diagram-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

.diagram-item:hover {
    border-color: var(--primary-color);
    background-color: var(--editor-bg);
}

.diagram-item.selected {
    border-color: var(--primary-color);
    background-color: rgba(66, 133, 244, 0.1);
}

.diagram-checkbox {
    margin-right: 12px;
    width: 18px;
    height: 18px;
    cursor: pointer;
    flex-shrink: 0;
}

.diagram-item-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    flex: 1;
}

.diagram-item-name {
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-color);
}

.diagram-item-meta {
    font-size: 0.8rem;
    color: var(--text-color);
    opacity: 0.7;
}

.empty-diagrams {
    text-align: center;
    padding: 3rem;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 0.9rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    background-color: var(--header-bg);
    color: var(--text-color);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    min-width: 300px;
    max-width: 500px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: auto;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid var(--primary-color);
}

.toast.toast-success {
    border-left-color: var(--secondary-color);
}

.toast.toast-error {
    border-left-color: var(--error-color);
}

.toast.toast-warning {
    border-left-color: #fbbc04;
}

.toast.toast-info {
    border-left-color: var(--primary-color);
}

.toast-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 0.9rem;
    line-height: 1.4;
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.toast-close:hover {
    opacity: 1;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.toast-hiding {
    animation: slideOut 0.3s ease-in forwards;
}

/* Canvas Container */
.canvas-container {
    position: relative;
    flex: 1;
    overflow: hidden;
}

/* Canvas Loading Overlay */
.canvas-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    z-index: 500; /* Above editor-section but below modals */
}

.canvas-loading-overlay.show {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #4285f4;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* 모달용 작은 인라인 스피너 */
.version-stats .loading-spinner,
.modal-body .loading-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(66, 133, 244, 0.2);
    border-top-color: #4285f4;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
    vertical-align: middle;
}

.loading-text {
    color: white;
    margin-top: 20px;
    font-size: 16px;
    font-weight: 500;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Help Modal */
.modal-medium {
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 800px;
    max-height: 90vh;
    overflow-y: auto;
}

.help-content {
    padding: 20px;
}

.help-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.help-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.help-section h4 {
    margin-bottom: 15px;
    color: var(--primary-color);
    font-size: 18px;
    font-weight: 600;
}

.help-section h5 {
    margin-top: 15px;
    margin-bottom: 10px;
    font-size: 16px;
    font-weight: 600;
}

.help-section p {
    margin-bottom: 12px;
    line-height: 1.6;
}

.help-section ul, .help-section ol {
    margin-left: 25px;
    margin-bottom: 12px;
}

.help-section li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.help-section pre {
    background: var(--editor-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 12px;
    margin: 10px 0;
    overflow-x: auto;
}

.help-section code {
    font-family: 'Courier New', monospace;
    font-size: 14px;
    background: var(--editor-bg);
    padding: 2px 6px;
    border-radius: 3px;
}

.help-section pre code {
    padding: 0;
    background: none;
}

.help-section a {
    color: var(--primary-color);
    text-decoration: none;
}

.help-section a:hover {
    text-decoration: underline;
}

/* Export Modal */
.export-preview {
    width: 100%;
    height: 100%;
}

.export-textarea {
    width: 100%;
    height: 400px;
    padding: 12px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.6;
    background-color: var(--editor-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    resize: vertical;
}

.export-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ========== Version Management ========== */

/* Version Header Container */
.version-header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    gap: 15px;
}

/* Version Stats */
.version-stats {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: var(--text-color);
    flex-wrap: wrap;
}

.version-stats span {
    padding: 5px 12px;
    background-color: var(--canvas-bg);
    border-radius: 4px;
    border: 1px solid var(--border-color);
    white-space: nowrap;
}

/* Version List */
#version-list {
    padding: 0;
}

.version-item {
    padding: 15px;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}

.version-item:hover {
    background-color: var(--canvas-bg);
}

.version-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.version-item-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.version-number {
    font-weight: 600;
    font-size: 15px;
    color: var(--text-color);
}

.version-number i {
    margin-right: 5px;
    opacity: 0.7;
}

.version-name {
    font-weight: 500;
    color: var(--text-color);
}

.version-item-date {
    font-size: 13px;
    color: #999;
}

.version-description {
    margin: 8px 0;
    padding: 8px 12px;
    background-color: var(--canvas-bg);
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
    font-size: 13px;
    line-height: 1.5;
    color: var(--text-color);
}

.version-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
}

.version-author {
    font-size: 12px;
    color: #999;
}

/* Version Badges */
.version-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
}

.version-badge-manual {
    background-color: #4285f4;
    color: white;
}

.version-badge-auto {
    background-color: #999;
    color: white;
}

.version-badge-claude {
    background-color: #34a853;
    color: white;
}

/* Version Actions */
.version-actions {
    display: flex;
    gap: 8px;
}

.version-actions button {
    width: auto; /* 버튼이 내용만큼만 차지 */
}

.btn-sm {
    padding: 5px 12px;
    font-size: 13px;
}

/* Empty State */
.empty-versions {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* Version Button */
#version-btn {
    /* nav-btn 스타일을 따라감 */
}

/* Form Groups in Version Modal */
.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-color);
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    font-size: 14px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--editor-bg);
    color: var(--text-color);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
}

textarea.form-control {
    resize: vertical;
    font-family: inherit;
}

/* Version Help */
.help-icon {
    margin-left: auto;
    margin-right: 10px;
    font-weight: bold;
    font-size: 16px;
    opacity: 0.6;
    cursor: pointer;
}

.help-icon:hover {
    opacity: 1;
}

.help-section {
    margin-bottom: 20px;
}

.help-section h4 {
    margin-bottom: 10px;
    color: var(--primary-color);
    font-size: 15px;
}

.help-section ul {
    list-style: none;
    padding-left: 0;
}

.help-section li {
    padding: 6px 0;
    line-height: 1.6;
    color: var(--text-color);
}

.help-section li strong {
    color: var(--primary-color);
    font-weight: 600;
}

/* ============================================
   Version Diff Viewer Styles
   ============================================ */

/* Version header actions container */
.version-header-actions {
    display: flex;
    gap: 8px;
}

/* Diff Header */
.diff-header {
    padding: 16px 20px;
    background-color: var(--editor-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.diff-version-info {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.diff-version-label {
    font-size: 14px;
    color: var(--text-color);
}

.diff-version-label strong {
    color: var(--primary-color);
    margin-right: 8px;
}

.diff-date {
    font-size: 12px;
    color: #888;
    margin-left: 8px;
}

/* Diff Stats */
.diff-stats {
    display: flex;
    gap: 16px;
    font-size: 14px;
    font-weight: 600;
}

.diff-stat-added {
    color: #22863a;
}

[data-theme="dark"] .diff-stat-added {
    color: #2ea043;
}

.diff-stat-removed {
    color: #cb2431;
}

[data-theme="dark"] .diff-stat-removed {
    color: #f85149;
}

/* Diff Content Container */
.diff-content-container {
    padding: 0;
    overflow-y: auto;
    max-height: calc(90vh - 200px);
    background-color: var(--canvas-bg);
    text-align: left;
}

/* diff2html 테마 커스터마이징 */
.diff-content-container .d2h-wrapper {
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
}

/* 다크 테마 지원 */
[data-theme="dark"] .diff-content-container .d2h-wrapper {
    background-color: var(--editor-bg) !important;
}

[data-theme="dark"] .diff-content-container .d2h-file-wrapper {
    border-color: var(--border-color) !important;
    background-color: var(--editor-bg) !important;
}

[data-theme="dark"] .diff-content-container .d2h-file-header {
    background-color: var(--editor-bg) !important;
    border-color: var(--border-color) !important;
    color: var(--text-color) !important;
}

[data-theme="dark"] .diff-content-container .d2h-file-name-wrapper {
    color: var(--text-color) !important;
}

[data-theme="dark"] .diff-content-container .d2h-code-side-linenumber,
[data-theme="dark"] .diff-content-container .d2h-code-linenumber {
    background-color: #1e1e1e !important;
    border-color: var(--border-color) !important;
    color: #888 !important;
}

[data-theme="dark"] .diff-content-container .d2h-code-side-line,
[data-theme="dark"] .diff-content-container .d2h-code-line {
    background-color: var(--editor-bg) !important;
    color: var(--text-color) !important;
}

[data-theme="dark"] .diff-content-container .d2h-code-side-emptyplaceholder,
[data-theme="dark"] .diff-content-container .d2h-emptyplaceholder {
    background-color: #2a2a2a !important;
    border-color: var(--border-color) !important;
}

[data-theme="dark"] .diff-content-container .d2h-ins,
[data-theme="dark"] .diff-content-container .d2h-code-line-ins,
[data-theme="dark"] .diff-content-container .d2h-code-side-line.d2h-ins {
    background-color: #033a16 !important;
}

[data-theme="dark"] .diff-content-container .d2h-del,
[data-theme="dark"] .diff-content-container .d2h-code-line-del,
[data-theme="dark"] .diff-content-container .d2h-code-side-line.d2h-del {
    background-color: #3d0a0f !important;
}

[data-theme="dark"] .diff-content-container .d2h-ins .d2h-code-line-ctn,
[data-theme="dark"] .diff-content-container .d2h-code-line-ins .d2h-code-line-ctn {
    background-color: transparent !important;
    color: #2ea043 !important;
}

[data-theme="dark"] .diff-content-container .d2h-del .d2h-code-line-ctn,
[data-theme="dark"] .diff-content-container .d2h-code-line-del .d2h-code-line-ctn {
    background-color: transparent !important;
    color: #f85149 !important;
}

[data-theme="dark"] .diff-content-container .d2h-info {
    background-color: var(--editor-bg) !important;
    border-color: var(--border-color) !important;
    color: #888 !important;
}

[data-theme="dark"] .diff-content-container .d2h-file-diff {
    background-color: var(--editor-bg) !important;
}

[data-theme="dark"] .diff-content-container td {
    background-color: transparent !important;
}

[data-theme="dark"] .diff-content-container .d2h-moved-tag {
    background-color: var(--primary-color) !important;
    color: white !important;
}

/* Version Checkbox */
.version-checkbox {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

/* Version Item Header - 클릭 가능 영역 */
.version-item-header {
    cursor: pointer;
    transition: background-color 0.15s ease;
}

.version-item-header:hover {
    background-color: var(--active-line);
}

/* Version Item - 버튼 영역은 클릭 효과 제외 */
.version-actions {
    pointer-events: all;
}

.version-actions button {
    pointer-events: all;
}

/* ============================================
   Realtime Notifications (SSE)
   ============================================ */

#notification-container {
    position: fixed;
    top: clamp(60px, 12vw, 70px);
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
    pointer-events: none;
}

.notification {
    background: var(--background);
    color: var(--foreground);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
    pointer-events: all;
    font-size: 14px;
    line-height: 1.5;
    min-width: 300px;
    word-wrap: break-word;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-info {
    border-left: 4px solid var(--primary);
}

.notification-success {
    border-left: 4px solid var(--success);
}

.notification-warning {
    border-left: 4px solid var(--warning);
}

.notification-error {
    border-left: 4px solid var(--danger);
}

.notification-version {
    background: var(--header-bg);
    border: 3px solid var(--primary-color);
    border-radius: 10px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    box-shadow: 0 12px 40px rgba(66, 133, 244, 0.5);
    animation: slideInBounce 0.5s ease-out;
    min-width: 320px;
}

[data-theme="light"] .notification-version {
    background: linear-gradient(135deg, #e3f2fd 0%, #f0f7ff 100%);
    box-shadow: 0 12px 40px rgba(66, 133, 244, 0.4);
}

[data-theme="dark"] .notification-version {
    background: linear-gradient(135deg, #1e3a5f 0%, #2d4a6f 100%);
    box-shadow: 0 12px 40px rgba(66, 133, 244, 0.6);
}

@keyframes slideInBounce {
    0% {
        transform: translateX(400px) scale(0.8);
        opacity: 0;
    }
    60% {
        transform: translateX(-10px) scale(1.02);
        opacity: 1;
    }
    100% {
        transform: translateX(0) scale(1);
        opacity: 1;
    }
}

.notification-message {
    font-size: 14px;
    line-height: 1.5;
}

.notification-buttons {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.notification-btn {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-weight: 500;
}

.notification-btn-primary {
    background: var(--primary);
    color: white;
}

.notification-btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.notification-btn-close {
    background: transparent;
    color: var(--foreground);
    border: 1px solid var(--border);
}

.notification-btn-close:hover {
    background: var(--hover-bg);
}

/* ===========================================
   Status Bar
   =========================================== */
.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 24px;
    padding: 0 12px;
    background: var(--header-bg);
    border-top: 1px solid var(--border-color);
    font-size: 12px;
    color: var(--text-secondary, #666);
    flex-shrink: 0;
}

.status-bar-left,
.status-bar-center,
.status-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-bar-center {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.status-link {
    color: var(--text-secondary, #666);
    text-decoration: none;
    transition: color 0.2s;
}

.status-link:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.status-separator {
    color: var(--border-color);
    margin: 0 4px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 4px;
}

.status-divider {
    color: var(--border-color);
    margin: 0 4px;
}

/* SSE Status Indicator */
.status-sse .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fbbf24; /* yellow - connecting */
    transition: background-color 0.3s ease;
}

.status-sse.connected .status-dot {
    background: #22c55e; /* green - connected */
}

.status-sse.disconnected .status-dot {
    background: #ef4444; /* red - disconnected */
}

.status-sse.reconnecting .status-dot {
    background: #fbbf24; /* yellow - reconnecting */
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Hide status bar on mobile */
@media (max-width: 768px) {
    .status-bar {
        display: none;
    }
}

/* ============================================
   Golden Layout Styles
   ============================================ */

/* GL 컨테이너 */
.gl-container {
    flex: 1;
    width: 100%;
    height: 100%;
    position: relative;
}

/* GL 컴포넌트 래퍼 */
.gl-component-wrapper {
    display: flex;
    width: 100%;
    height: 100%;
    background: var(--bg-color);
    position: relative; /* 로딩 오버레이 위치 기준 */
}

/* GL 에디터 섹션 */
.gl-editor-section {
    width: 350px;
    min-width: 200px;
    max-width: 60%;
    display: flex;
    flex-direction: column;
    background: var(--editor-bg);
    border-right: 1px solid var(--border-color);
}

.gl-editor-container {
    flex: 1;
    overflow: hidden;
}

.gl-editor-container .dbml-editor {
    height: 100% !important;
}

.gl-editor-container .cm-editor {
    height: 100% !important;
}

/* GL 리사이저 */
.gl-resizer {
    width: 6px;
    cursor: col-resize;
    background: var(--border-color);
    transition: background 0.2s;
}

.gl-resizer:hover {
    background: var(--primary-color);
}

/* GL 캔버스 섹션 */
.gl-canvas-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--canvas-bg);
    min-width: 300px;
}

.gl-canvas-header {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 4px 8px;
    background: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
}

.gl-canvas-controls {
    display: flex;
    gap: 4px;
}

.gl-canvas-controls .btn-icon {
    width: 28px;
    height: 28px;
    font-size: 14px;
}

.gl-canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

/* GL 테마 오버라이드 - 다크 테마 */
.component-theme-dark .gl-editor-section {
    background: var(--editor-bg);
}

.component-theme-dark .gl-canvas-section {
    background: var(--canvas-bg);
}

/* GL 테마 오버라이드 - 라이트 테마 */
.component-theme-light .gl-editor-section {
    background: #ffffff;
}

.component-theme-light .gl-canvas-section {
    background: #fafafa;
}

/* Golden Layout 기본 스타일 오버라이드 */
.lm_goldenlayout {
    background: var(--bg-color) !important;
}

.lm_header {
    background: var(--header-bg) !important;
    border-bottom: 1px solid var(--border-color) !important;
}

.lm_tab {
    background: var(--bg-color) !important;
    color: var(--text-color) !important;
    border: 1px solid var(--border-color) !important;
    margin-right: 2px !important;
}

.lm_tab.lm_active {
    background: var(--editor-bg) !important;
    border-bottom-color: var(--editor-bg) !important;
}

.lm_content {
    background: var(--bg-color) !important;
    border: none !important;
}

.lm_splitter {
    background: var(--border-color) !important;
}

.lm_splitter:hover {
    background: var(--primary-color) !important;
}

/* GL 탭 닫기 버튼 */
.lm_close_tab {
    color: var(--text-color) !important;
}

.lm_close_tab:hover {
    color: var(--error-color) !important;
}

/* Main 탭 스타일 */
.lm_tab.main-tab {
    border-top: 2px solid var(--primary-color) !important;
    border-left: 2px solid var(--primary-color) !important;
    border-right: 2px solid var(--primary-color) !important;
}

/* ========================================
   Cookie Consent Banner & Modal Styles
   ======================================== */

/* Cookie Consent Banner */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--header-bg);
    border-top: 1px solid var(--border-color);
    padding: 16px 24px;
    z-index: 10001;
    box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15);
    display: flex;
    justify-content: center;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.cookie-banner-content {
    max-width: 1200px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}

.cookie-banner-text h4 {
    margin: 0 0 8px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.cookie-banner-text p {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--text-secondary, #666);
    line-height: 1.5;
}

.cookie-banner-links {
    display: flex;
    gap: 16px;
}

.cookie-banner-links a {
    font-size: 13px;
    color: var(--primary-color);
    text-decoration: none;
}

.cookie-banner-links a:hover {
    text-decoration: underline;
}

.cookie-banner-actions {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.cookie-banner-actions button {
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.cookie-banner-actions .btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
}

.cookie-banner-actions .btn-primary:hover {
    background: #3367d6;
}

.cookie-banner-actions .btn-secondary {
    background: transparent;
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.cookie-banner-actions .btn-secondary:hover {
    background: var(--bg-color);
    border-color: var(--text-color);
}

.cookie-banner-actions .btn-text {
    background: transparent;
    color: var(--primary-color);
    border: none;
    padding: 10px 12px;
}

.cookie-banner-actions .btn-text:hover {
    text-decoration: underline;
}

/* Cookie Settings Modal */
.cookie-modal .modal-content {
    max-width: 520px;
}

.cookie-modal-description {
    margin-bottom: 20px;
    font-size: 14px;
    color: var(--text-secondary, #666);
    line-height: 1.5;
}

.cookie-category {
    padding: 16px;
    background: var(--bg-color);
    border-radius: 8px;
    margin-bottom: 12px;
}

.cookie-category:last-of-type {
    margin-bottom: 0;
}

.cookie-category-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.cookie-category-info h4 {
    margin: 0 0 6px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
}

.cookie-category-info p {
    margin: 0;
    font-size: 13px;
    color: var(--text-secondary, #666);
    line-height: 1.4;
}

.cookie-toggle {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.toggle-status {
    font-size: 11px;
    color: var(--text-secondary, #666);
    text-transform: uppercase;
    font-weight: 500;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border-color);
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

.toggle-switch.disabled {
    opacity: 0.6;
}

.toggle-switch.disabled .toggle-slider {
    cursor: not-allowed;
    background-color: var(--secondary-color);
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .cookie-banner {
        padding: 16px;
    }

    .cookie-banner-content {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
    }

    .cookie-banner-text h4 {
        font-size: 15px;
    }

    .cookie-banner-text p {
        font-size: 13px;
    }

    .cookie-banner-links {
        gap: 12px;
    }

    .cookie-banner-actions {
        flex-direction: column;
    }

    .cookie-banner-actions button {
        width: 100%;
        justify-content: center;
    }

    .cookie-modal .modal-content {
        max-width: 100%;
        margin: 16px;
    }

    .cookie-category-header {
        flex-direction: column;
        gap: 12px;
    }

    .cookie-toggle {
        flex-direction: row;
        justify-content: space-between;
        width: 100%;
    }
}

/* ========================================
   Nodes Panel (Left Panel)
   ======================================== */

.nodes-panel {
    display: flex;
    flex-direction: column;
    width: 280px;
    min-width: 200px;
    max-width: 500px;
    height: 100%;
    background-color: var(--editor-bg);
    border-right: 1px solid var(--border-color);
    z-index: 10;
    transition: width 0.3s ease, min-width 0.3s ease, opacity 0.3s ease;
    overflow: hidden;
}

.nodes-panel.collapsed {
    width: 0;
    min-width: 0;
    overflow: hidden;
    border-right: none;
    opacity: 0;
}

.nodes-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border-color);
    min-height: 42px;
    padding: 0 8px;
}

.nodes-panel-tabs {
    display: flex;
    gap: 0;
}

.nodes-panel-tab {
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-color);
    opacity: 0.6;
    cursor: pointer;
    transition: opacity 0.2s, border-color 0.2s;
}

.nodes-panel-tab:hover {
    opacity: 0.8;
}

.nodes-panel-tab.active {
    opacity: 1;
    border-bottom-color: var(--primary-color);
    color: var(--primary-color);
}

.nodes-panel-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.nodes-panel-search input {
    width: 100%;
    padding: 6px 10px;
    background: var(--canvas-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text-color);
    transition: border-color 0.2s;
}

.nodes-panel-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.nodes-panel-content {
    flex: 1;
    overflow-y: auto;
    font-size: 13px;
}

.panel-empty {
    padding: 20px 16px;
    text-align: center;
    color: var(--text-color);
    opacity: 0.5;
    font-size: 13px;
}

/* ========================================
   Group Tree (inside Nodes Panel)
   ======================================== */

.group-tree-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
}

.group-item {
    border-bottom: 1px solid var(--border-color);
}

.group-item-header {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    cursor: pointer;
    transition: background 0.15s;
}

.group-item-header:hover {
    background: var(--canvas-bg);
}

.group-icon-arrow {
    font-size: 10px;
    opacity: 0.5;
    width: 14px;
    flex-shrink: 0;
}

.group-color {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    flex-shrink: 0;
}

.group-name {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.group-count {
    font-size: 11px;
    opacity: 0.5;
    flex-shrink: 0;
}

.group-item-tables {
    padding: 0;
}

.group-table-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px 6px 20px;
    cursor: pointer;
    transition: background 0.15s;
    user-select: none;
}

.group-table-item:hover {
    background: var(--canvas-bg);
}

/* Drag Handle (Nodes Panel) */
.group-table-item .drag-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    cursor: grab;
    opacity: 0;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.group-table-item .drag-handle:active {
    cursor: grabbing;
}

.group-table-item:hover .drag-handle {
    opacity: 0.5;
}

.group-table-item .drag-handle img {
    width: 12px;
    height: 12px;
    pointer-events: none;
    filter: var(--icon-filter, none);
}

[data-theme="dark"] .group-table-item .drag-handle img {
    filter: invert(1);
}

/* Drag and Drop States (Nodes Panel) */
.group-table-item.dragging {
    opacity: 0.4;
    background: var(--hover-bg);
}

.group-item.drag-over {
    background: rgba(66, 133, 244, 0.08);
    border-radius: 6px;
    outline: 2px dashed var(--primary-color);
    outline-offset: -2px;
}

.group-item.drag-over > .group-item-header {
    background: var(--primary-color);
    color: white;
    border-radius: 6px 6px 0 0;
}

.group-item.drag-over > .group-item-header .group-icon-arrow {
    color: white;
}

.node-shape-badge {
    font-size: 14px;
    opacity: 0.5;
    width: 18px;
    text-align: center;
    flex-shrink: 0;
}

.table-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========================================
   Ref / Edge Items
   ======================================== */

.ref-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.ref-item:hover {
    background: var(--canvas-bg);
}

.ref-item-body {
    flex: 1;
    min-width: 0;
}

.ref-item-row {
    display: flex;
    align-items: baseline;
}

.ref-item-arrow {
    padding: 2px 0 2px 4px;
}

.ref-table {
    font-size: 13px;
    font-weight: 500;
    color: var(--text-color);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ref-col-sep {
    font-size: 12px;
    opacity: 0.5;
    margin: 0 4px;
}

.ref-from .ref-table {
    color: #ca8a04;
}

.ref-to .ref-table {
    color: #3b82f6;
}

/* ========================================
   Group Manage Items (Groups Tab)
   ======================================== */

.group-manage-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s;
}

.group-manage-item:hover {
    background: var(--canvas-bg);
}

.group-manage-name {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ========================================
   Edit Panel (Right Panel)
   ======================================== */

.canvas-content {
    position: relative;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.edit-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 320px;
    min-width: 280px;
    max-width: 500px;
    background-color: var(--editor-bg);
    border-left: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 99;
    transform: translateX(100%);
    visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
    box-shadow: -2px 0 8px rgba(0, 0, 0, 0.08);
}

.edit-panel.open {
    transform: translateX(0);
    visibility: visible;
}

.edit-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    min-height: 48px;
    min-width: 0;
    gap: 8px;
}

.edit-panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    flex: 1;
    overflow: hidden;
}

.edit-panel-badge {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: var(--primary-color);
    color: white;
    flex-shrink: 0;
}

.edit-panel-name {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-color);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.edit-panel-dirty {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--primary-color);
    flex-shrink: 0;
}

.edit-panel-body {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
}

.edit-panel-footer {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
}

.edit-panel-footer button {
    display: flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    height: 30px;
    box-sizing: border-box;
}

/* ========================================
   Edit Form Fields
   ======================================== */

.edit-form {
    display: flex;
    flex-direction: column;
    gap: 14px;
    max-width: 100%;
    overflow: hidden;
}

.edit-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.edit-field label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-color);
    opacity: 0.7;
}

.edit-field input,
.edit-field select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 13px;
    background: var(--canvas-bg);
    color: var(--text-color);
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

.edit-field input:focus,
.edit-field select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.edit-field-row {
    display: flex;
    gap: 10px;
}

.edit-field-row .edit-field {
    flex: 1;
}

.color-palette {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.palette-row {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.palette-swatch {
    display: flex;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border-color);
    cursor: pointer;
    padding: 0;
    background: none;
    transition: transform 0.1s, box-shadow 0.1s;
}

.palette-swatch:hover {
    transform: scale(1.2);
    box-shadow: 0 0 0 2px var(--primary-color);
}

.swatch-fill {
    flex: 1;
}

.swatch-stroke {
    width: 6px;
}

.color-field-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.color-field-row input[type="color"] {
    width: 36px;
    height: 30px;
    padding: 2px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--canvas-bg);
    cursor: pointer;
}

.color-text-input {
    flex: 1;
}

/* ========================================
   Button Spinner
   ======================================== */

.btn-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: edit-spin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes edit-spin {
    to { transform: rotate(360deg); }
}

/* ========================================
   Edit Panel Dark Theme
   ======================================== */

[data-theme="dark"] .edit-panel-header .btn-icon img {
    filter: brightness(0) saturate(100%) invert(80%);
}

/* ========================================
   AI Chat Panel
   ======================================== */

.ai-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.ai-chat-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Messages Area */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Welcome Screen */
.ai-chat-welcome {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 32px 16px;
    text-align: center;
    flex: 1;
}

.ai-chat-welcome-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--primary-color);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 12px;
}

.ai-chat-welcome-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 6px;
}

.ai-chat-welcome-desc {
    font-size: 13px;
    color: var(--text-color);
    opacity: 0.6;
    line-height: 1.5;
    max-width: 220px;
}

/* Message Bubble */
.ai-chat-message {
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.5;
    max-width: 90%;
    word-wrap: break-word;
    white-space: pre-wrap;
}

.ai-chat-message.user {
    align-self: flex-end;
    background-color: var(--primary-color);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-chat-message.assistant {
    align-self: flex-start;
    background-color: var(--canvas-bg);
    color: var(--text-color);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.ai-chat-message-content {
    white-space: pre-wrap;
    word-break: break-word;
}

/* Typing Indicator (3 dots) */
.ai-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 10px 14px;
}

.ai-typing-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--text-color);
    opacity: 0.4;
    animation: ai-dot-bounce 1.4s infinite ease-in-out both;
}

.ai-typing-indicator .dot:nth-child(1) { animation-delay: 0s; }
.ai-typing-indicator .dot:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-indicator .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-dot-bounce {
    0%, 80%, 100% { opacity: 0.2; transform: scale(0.8); }
    40% { opacity: 1; transform: scale(1); }
}

/* Action Results (inline in assistant message) */
.ai-chat-actions {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.ai-chat-action-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-color);
    opacity: 0.8;
}

.ai-chat-action-item .action-icon {
    font-size: 12px;
    flex-shrink: 0;
}

.ai-chat-action-item.success .action-icon {
    color: var(--secondary-color);
}

.ai-chat-action-item.error .action-icon {
    color: var(--error-color);
}

/* Input Area */
.ai-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    padding: 8px 12px;
    border-top: 1px solid var(--border-color);
    background-color: var(--editor-bg);
}

.ai-chat-input {
    flex: 1;
    padding: 8px 10px;
    background: var(--canvas-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    color: var(--text-color);
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 96px; /* ~4 lines */
    transition: border-color 0.2s;
}

.ai-chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.ai-chat-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-chat-input::placeholder {
    color: var(--text-color);
    opacity: 0.4;
}

.ai-chat-send-btn {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background-color: var(--primary-color);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.15s, opacity 0.15s;
}

.ai-chat-send-btn:hover:not(:disabled) {
    background-color: #3367d6;
}

.ai-chat-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-chat-send-btn svg {
    width: 14px;
    height: 14px;
}

/* Dark theme adjustments */
[data-theme="dark"] .ai-chat-message.assistant {
    background-color: #2d2d2d;
    border-color: #404040;
}

[data-theme="dark"] .ai-chat-input {
    background-color: #2d2d2d;
    border-color: #404040;
}

[data-theme="dark"] .ai-chat-send-btn:hover:not(:disabled) {
    background-color: #5a9bff;
}

/* ========================================
   Edit Panel Toggle Button (Floating)
   ======================================== */

.edit-panel-toggle-btn {
    position: absolute;
    top: clamp(56px, 10vw, 60px);
    right: 12px;
    z-index: 150;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    background-color: var(--editor-bg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.15s, box-shadow 0.15s;
}

.edit-panel-toggle-btn:hover {
    background-color: var(--bg-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.edit-panel-toggle-btn img {
    width: 18px;
    height: 18px;
}

[data-theme="dark"] .edit-panel-toggle-btn {
    border-color: #374151;
    background-color: #2d2d2d;
}

[data-theme="dark"] .edit-panel-toggle-btn:hover {
    background-color: rgba(55, 65, 81, 0.5);
    border-color: #4B5563;
}

[data-theme="dark"] .edit-panel-toggle-btn img {
    filter: brightness(0) saturate(100%) invert(80%);
}

.edit-panel-toggle-btn.pulse {
    animation: toggle-pulse 0.7s ease;
}

.edit-panel-toggle-btn.pulse img {
    animation: toggle-pulse-icon 0.7s ease;
}

@keyframes toggle-pulse {
    0% { border-color: var(--border-color); }
    30% { border-color: #3B82F6; box-shadow: 0 0 10px rgba(59, 130, 246, 0.4); }
    100% { border-color: var(--border-color); box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1); }
}

@keyframes toggle-pulse-icon {
    0% { filter: none; }
    30% { filter: brightness(0) saturate(100%) invert(45%) sepia(98%) saturate(1500%) hue-rotate(207deg) brightness(100%); }
    100% { filter: none; }
}

[data-theme="dark"] .edit-panel-toggle-btn.pulse img {
    animation: toggle-pulse-icon-dark 0.7s ease;
}

@keyframes toggle-pulse-icon-dark {
    0% { filter: brightness(0) saturate(100%) invert(80%); }
    30% { filter: brightness(0) saturate(100%) invert(45%) sepia(98%) saturate(1500%) hue-rotate(207deg) brightness(100%); }
    100% { filter: brightness(0) saturate(100%) invert(80%); }
}

/* ========================================
   Button Ghost
   ======================================== */

.btn-ghost {
    padding: 0 8px;
    height: 30px;
    background-color: transparent;
    color: var(--text-color);
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0.7;
}

.btn-ghost:hover {
    opacity: 1;
    background-color: var(--bg-color);
}

/* ========================================
   Confirm Modal (Unsaved Changes)
   ======================================== */

.confirm-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 3000;
    animation: confirmFadeIn 0.15s ease;
}

@keyframes confirmFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.confirm-modal {
    background-color: var(--editor-bg);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 360px;
    overflow: hidden;
    animation: confirmSlideIn 0.15s ease;
}

@keyframes confirmSlideIn {
    from { transform: scale(0.95) translateY(-10px); opacity: 0; }
    to { transform: scale(1) translateY(0); opacity: 1; }
}

.confirm-modal-content {
    padding: 24px;
    text-align: center;
}

.confirm-modal-content p {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-color);
    margin-bottom: 20px;
    line-height: 1.5;
}

.confirm-modal-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.confirm-modal-buttons .btn {
    min-width: 80px;
    height: 34px;
    font-size: 13px;
    font-weight: 500;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
}

/* ========================================
   Nodes Panel Mobile
   ======================================== */

@media (max-width: 768px) {
    .nodes-panel {
        position: absolute;
        z-index: 50;
        width: 100%;
        max-width: 100%;
    }

    .edit-panel {
        width: 100%;
        max-width: 100%;
    }

    .confirm-modal {
        max-width: calc(100% - 32px);
    }
}

