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

:root {
    --bg-color: rgb(255, 255, 255);
    --toolbar-bg: white;
    --toolbar-shadow: rgba(0, 0, 0, 0.1);
    --toolbar-border: #e0e0e0;
    --btn-color: #333;
    --btn-hover-bg: #f0f0f0;
    --node-bg: white;
    --node-shadow: rgba(0, 0, 0, 0.1);
    --node-text: #333;
    --placeholder-color: #999;
    --palette-bg: white;
    --collapse-btn: #999;
    --collapse-btn-hover: #666;
    --collapse-btn-collapsed: #ccc;
}

body.dark-theme {
    --bg-color: #141418;
    --toolbar-bg: #16213e;
    --toolbar-shadow: rgba(0, 0, 0, 0.3);
    --toolbar-border: #0f3460;
    --btn-color: #e0e0e0;
    --btn-hover-bg: #0f3460;
    --node-bg: #16213e;
    --node-shadow: rgba(0, 0, 0, 0.3);
    --node-text: #e0e0e0;
    --placeholder-color: #666;
    --palette-bg: #16213e;
    --collapse-btn: #666;
    --collapse-btn-hover: #888;
    --collapse-btn-collapsed: #444;
}

body {
    font-family: Figtree, "Noto Sans JP", Helvetica, system-ui, Arial, sans-serif;
    overflow: hidden;
    background: var(--bg-color);
    transition: background 0.3s;
}

.toolbar {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--toolbar-bg);
    border-radius: 12px;
    box-shadow: 0 4px 20px var(--toolbar-shadow);
    padding: 12px 20px;
    display: flex;
    gap: 20px;
    z-index: 1000;
    align-items: center;
    transition: background 0.3s, box-shadow 0.3s;
}

.toolbar-section {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 0 12px;
    border-right: 1px solid var(--toolbar-border);
}

.toolbar-section:last-child {
    border-right: none;
}

.toolbar-btn {
    background: transparent;
    border: none;
    padding: 8px;
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--btn-color);
}

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

.toolbar-btn:active {
    transform: scale(0.95);
}

.toolbar-btn.active {
    background: #e3f2fd;
    color: #1976d2;
}

.color-picker-wrapper {
    position: relative;
}

.color-palette {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-top: 8px;
    background: var(--palette-bg);
    border-radius: 8px;
    box-shadow: 0 4px 20px var(--toolbar-shadow);
    padding: 12px;
    display: none;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    z-index: 1001;
    transition: background 0.3s;
}

.color-palette.active {
    display: grid;
}

.color-option {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid transparent;
}

.color-option:hover {
    transform: scale(1.1);
    border-color: var(--btn-color);
}

.canvas-container {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
    cursor: grab;
}

.canvas-container.grabbing {
    cursor: grabbing;
}

.mind-map-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    transform-origin: 0 0;
}

.connections-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
    overflow: visible;
}

.node {
    position: absolute;
    background: var(--node-bg);
    border-radius: 8px;
    padding: 12px 20px;
    box-shadow: 0 2px 10px var(--node-shadow);
    cursor: move;
    min-width: 120px;
    max-width: 300px;
    z-index: 10;
    transition: box-shadow 0.2s, background 0.3s;
    border: 2px solid transparent;
    color: var(--node-text);
}

.node:hover {
    box-shadow: 0 4px 20px var(--node-shadow);
}

.node.selected {
    border-color: #1976d2;
    box-shadow: 0 4px 20px rgba(25, 118, 210, 0.3);
}

.node.root {
    background: var(--node-bg);
    color: var(--node-text);
    font-weight: bold;
    font-size: 18px;
    padding: 16px 28px;
    border-radius: 12px;
}

.node-content {
    outline: none;
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
    min-height: 20px;
    max-width: 100%;
}

.node-content:empty:before {
    content: 'New Node';
    color: var(--placeholder-color);
}

.node.root .node-content:empty:before {
    content: 'Main Idea';
    color: var(--placeholder-color);
}

.connection-line {
    fill: none;
    stroke-width: 3;
    stroke-linecap: round;
    transition: stroke 0.2s;
}

.connection-line.selected {
    stroke: #1976d2;
    stroke-width: 3;
}

.collapse-btn {    position: absolute;    right: -22px;    top: 50%;    transform: translateY(-50%);    width: 14px;    height: 14px;    background: transparent;    border: 2px solid currentColor;    border-radius: 50%;    cursor: pointer;    display: none;    align-items: center;    justify-content: center;    z-index: 25;    transition: all 0.2s;}.collapse-btn::after {    content: "";    width: 6px;    height: 6px;    background: currentColor;    border-radius: 50%;    opacity: 0;    transition: opacity 0.2s;}.collapse-btn.collapsed::after {    opacity: 1;}.collapse-btn:hover {    transform: translateY(-50%) scale(1.15);}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.node {
    animation: fadeIn 0.3s ease-out;
}

.bold {
    font-weight: bold;
}

.italic {
    font-style: italic;
}

.menu-btn {
    position: fixed;
    top: 24px;
    left: 20px;
    width: 44px;
    height: 44px;
    background: var(--toolbar-bg);
    border: none;
    border-radius: 10px;
    box-shadow: 0 4px 20px var(--toolbar-shadow);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--btn-color);
    z-index: 1000;
    transition: all 0.2s;
}

.menu-btn:hover {
    background: var(--btn-hover-bg);
    transform: scale(1.05);
}

.sidebar {
    position: fixed;
    top: 0;
    left: -320px;
    width: 320px;
    height: 100vh;
    background: var(--toolbar-bg);
    box-shadow: 4px 0 20px var(--toolbar-shadow);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    transition: left 0.3s ease;
}

.sidebar.open {
    left: 0;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid var(--toolbar-border);
}

.sidebar-header h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--btn-color);
    margin: 0;
}

.sidebar-close {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--btn-color);
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

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

.new-map-btn {
    margin: 16px;
    padding: 12px 16px;
    background: #1976d2;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.new-map-btn:hover {
    background: #1565c0;
}

.map-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.map-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s;
    margin-bottom: 4px;
}

.map-item:hover {
    background: var(--btn-hover-bg);
}

.map-item.active {
    background: rgba(25, 118, 210, 0.15);
}

.map-item-content {
    flex: 1;
    min-width: 0;
}

.map-item-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--btn-color);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.map-item-name-input {
    font-size: 14px;
    font-weight: 500;
    color: var(--btn-color);
    background: var(--btn-hover-bg);
    border: 1px solid #1976d2;
    border-radius: 4px;
    padding: 2px 6px;
    width: 100%;
    outline: none;
}

.map-item-date {
    font-size: 12px;
    color: var(--placeholder-color);
    margin-top: 2px;
}

.map-item-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.map-item:hover .map-item-actions {
    opacity: 1;
}

.map-item-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--placeholder-color);
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

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

.map-item-btn.delete:hover {
    color: #e53935;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--toolbar-border);
}

.save-status {
    font-size: 12px;
    color: var(--placeholder-color);
    display: flex;
    align-items: center;
    gap: 6px;
}

.save-status::before {
    content: '';
    width: 8px;
    height: 8px;
    background: #4caf50;
    border-radius: 50%;
}

.save-status.saving::before {
    background: #ff9800;
    animation: pulse 1s infinite;
}

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

.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.3);
    z-index: 1999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.sidebar-overlay.open {
    opacity: 1;
    visibility: visible;
}

.node-images {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.node-image {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 6px;
    cursor: pointer;
    transition: transform 0.2s;
    border: 2px solid transparent;
}

.node-image:hover {
    transform: scale(1.05);
    border-color: #1976d2;
}

.image-viewer-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    animation: fadeIn 0.2s ease-out;
}

.image-viewer-content {
    position: relative;
    width: 80%;
    height: 80%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-viewer-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.image-viewer-close {
    position: absolute;
    top: -40px;
    right: 0;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #333;
}

.image-viewer-close:hover {
    background: white;
    transform: scale(1.1);
}

body.dark-theme .image-viewer-close {
    background: rgba(22, 33, 62, 0.9);
    color: #e0e0e0;
}

body.dark-theme .image-viewer-close:hover {
    background: #16213e;
}


