:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface-2: #f8f9fa;
    --canvas-area: #e9ecef;
    --canvas-bg: #ffffff;
    --text: #333333;
    --text-muted: #6c757d;
    --border: #dddddd;
    --border-soft: #e0e0e0;
    --border-faint: #eeeeee;
    --accent: #0078d4;
    --accent-hover: #005a9e;
    --header-bg: #0078d4;
    --header-text: #ffffff;
    --shadow: rgba(0, 0, 0, 0.1);
    --overlay: rgba(0, 0, 0, 0.4);
}

:root[data-theme="dark"] {
    --bg: #121212;
    --surface: #1e1e1e;
    --surface-2: #2a2a2a;
    --canvas-area: #0f0f0f;
    --canvas-bg: #1e1e1e;
    --text: #e6e6e6;
    --text-muted: #a0a0a0;
    --border: #3a3a3a;
    --border-soft: #333333;
    --border-faint: #2a2a2a;
    --accent: #3b9eff;
    --accent-hover: #66b3ff;
    --header-bg: #12263a;
    --header-text: #ffffff;
    --shadow: rgba(0, 0, 0, 0.5);
    --overlay: rgba(0, 0, 0, 0.6);
}

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

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

.container {
    max-width: 100%;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

header {
    background: var(--header-bg);
    color: var(--header-text);
    padding: 16px 20px;
    box-shadow: 0 2px 4px var(--shadow);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.header-title {
    text-align: left;
}

header h1 {
    font-size: 28px;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 14px;
    opacity: 0.9;
}

.header-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
}

.header-credit {
    opacity: 0.95;
    white-space: nowrap;
}

.github-link {
    color: var(--header-text);
    display: inline-flex;
    align-items: center;
    opacity: 0.9;
    transition: opacity 0.2s;
}

.github-link:hover {
    opacity: 1;
}

.theme-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.12);
    color: var(--header-text);
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.22);
}

.theme-toggle-icon {
    font-size: 15px;
    line-height: 1;
}

.main-content {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.sidebar {
    width: 300px;
    background: var(--surface);
    padding: 20px;
    overflow-y: auto;
    border-right: 1px solid var(--border);
}

.sidebar-right {
    width: 280px;
    background: var(--surface);
    padding: 20px;
    overflow-y: auto;
    border-left: 1px solid var(--border);
}

.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--canvas-area);
    padding: 10px;
}

.canvas-controls {
    background: var(--surface);
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 4px;
    display: flex;
    gap: 10px;
    align-items: center;
}

.canvas-container {
    flex: 1;
    background: var(--canvas-bg);
    border-radius: 4px;
    overflow: hidden;
    position: relative;
}

#mainCanvas {
    display: block;
}

.panel {
    background: var(--surface);
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 4px;
    border: 1px solid var(--border-soft);
}

.panel h2 {
    font-size: 16px;
    margin-bottom: 15px;
    color: var(--accent);
    border-bottom: 2px solid var(--accent);
    padding-bottom: 5px;
}

.form-group {
    margin-bottom: 15px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 14px;
    background: var(--surface);
    color: var(--text);
}

.form-group input[type="file"] {
    padding: 5px;
}

.button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
}

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

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-success {
    background: #28a745;
    color: white;
    width: 100%;
    padding: 15px;
    font-size: 16px;
}

.btn-success:hover {
    background: #218838;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn-tool {
    background: var(--surface-2);
    color: var(--text);
    border: 2px solid var(--border);
    width: 100%;
    margin-bottom: 5px;
}

.btn-tool:hover {
    background: var(--canvas-area);
}

.btn-tool.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
}

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

.tool-buttons {
    display: flex;
    flex-direction: column;
}

.items-list {
    margin-top: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.level-item {
    padding: 8px;
    background: var(--surface-2);
    margin-bottom: 5px;
    border-radius: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
}

.level-item:hover {
    background: var(--canvas-area);
}

.level-item.active {
    background: var(--accent);
    color: white;
}

.level-item button {
    padding: 2px 8px;
    font-size: 12px;
}

.summary-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border-faint);
}

.summary-item span:last-child {
    font-weight: bold;
    color: var(--accent);
}

.export-info {
    margin-bottom: 15px;
    padding: 10px;
    background: var(--surface-2);
    border-radius: 4px;
    font-size: 13px;
}

.help-text {
    font-size: 13px;
    line-height: 1.6;
}

.help-text ol {
    margin-left: 20px;
    margin-top: 10px;
}

.help-text li {
    margin-bottom: 5px;
}

.hint {
    color: var(--text-muted);
    font-size: 13px;
    font-style: italic;
}

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

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: var(--overlay);
}

.modal-content {
    background-color: var(--surface);
    margin: 10% auto;
    padding: 20px;
    border-radius: 8px;
    width: 80%;
    max-width: 600px;
    box-shadow: 0 4px 6px var(--shadow);
}

.close {
    color: var(--text-muted);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
}

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

#projectsList {
    margin-top: 20px;
}

.project-item {
    padding: 15px;
    background: var(--surface-2);
    margin-bottom: 10px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
}

.project-item:hover {
    background: var(--canvas-area);
    border-color: var(--accent);
}

.project-item h3 {
    margin-bottom: 5px;
}

.project-item p {
    font-size: 12px;
    color: var(--text-muted);
}

.property-field {
    margin-bottom: 10px;
}

.property-field label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    margin-bottom: 3px;
}

.property-field input,
.property-field select {
    width: 100%;
    padding: 6px;
    font-size: 12px;
    border: 1px solid var(--border);
    border-radius: 3px;
    background: var(--surface);
    color: var(--text);
}

/* Loading indicator */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, .1);
    border-radius: 50%;
    border-top-color: var(--accent);
    animation: spin 1s ease-in-out infinite;
}

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