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

body {
    overflow: hidden;
    background: #1a1a2e;
    font-family: system-ui, sans-serif;
    color: #eee;
    touch-action: none;
}

#toolbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: #16213e;
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 6px;
    z-index: 10;
    border-bottom: 1px solid #0f3460;
    white-space: nowrap;
}

#toolbar > button {
    flex-shrink: 0;
}

#plants-toolbar,
#layout-toolbar,
#diary-toolbar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

#toolbar button {
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #0f3460;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
}

#toolbar button:hover { background: #0f3460; }
#toolbar button.active { background: #0f3460; border-color: #88ccff; }

.hidden { display: none !important; }

#canvas {
    display: block;
    position: fixed;
    top: 40px;
    left: 0;
    width: 100vw;
    height: calc(100vh - 40px);
}

#context-menu {
    position: fixed;
    background: #16213e;
    border: 1px solid #0f3460;
    border-radius: 6px;
    padding: 4px 0;
    min-width: 160px;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

#context-menu.hidden { display: none; }

#context-menu .menu-item {
    padding: 8px 16px;
    cursor: pointer;
    font-size: 14px;
}

#context-menu .menu-item:hover {
    background: #0f3460;
}

#context-menu .menu-item.active {
    color: #88ccff;
}

#context-menu .menu-back {
    color: #88ccff;
}

#context-menu .menu-header {
    padding: 6px 16px 4px;
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

#toast-container {
    position: fixed;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: center;
    pointer-events: none;
}

.toast {
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 13px;
    max-width: 400px;
    pointer-events: auto;
    animation: toast-in 0.2s ease-out;
}

.toast.error { background: #882222; color: #fcc; border: 1px solid #aa3333; }
.toast.warn { background: #886622; color: #fec; border: 1px solid #aa8833; }
.toast.info { background: #16213e; color: #ccc; border: 1px solid #0f3460; }

@keyframes toast-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#layer-panel {
    position: fixed;
    top: 44px;
    right: 0;
    width: 240px;
    max-height: calc(100vh - 48px);
    background: #16213e;
    border-left: 1px solid #0f3460;
    padding: 8px;
    overflow-y: auto;
    z-index: 20;
    font-size: 13px;
}

#layer-panel .layer-item {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 0;
    border-bottom: 1px solid #0f3460;
}

#layer-panel .layer-item .layer-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#layer-panel .layer-controls {
    display: flex;
    gap: 2px;
    align-items: center;
}

#layer-panel button {
    background: #1a1a2e;
    color: #eee;
    border: 1px solid #0f3460;
    border-radius: 3px;
    padding: 2px 5px;
    cursor: pointer;
    font-size: 12px;
}

#layer-panel button:hover { background: #0f3460; }

#layer-panel input[type="range"] {
    width: 50px;
    accent-color: #0f3460;
}

#debug-hud {
    position: fixed;
    top: 48px;
    left: 8px;
    background: rgba(0, 0, 0, 0.75);
    color: #44ff44;
    font-family: monospace;
    font-size: 11px;
    padding: 6px 10px;
    border-radius: 4px;
    white-space: pre;
    z-index: 15;
    pointer-events: none;
    max-width: 400px;
}

#toolbar input[type="range"] {
    width: 60px;
    accent-color: #0f3460;
}

#toolbar label {
    font-size: 12px;
    color: #888;
}

/* Diary panel */

#diary-panel {
    position: fixed;
    top: 40px;
    left: 0;
    right: 0;
    bottom: 0;
    background: #1a1a2e;
    overflow-y: auto;
    padding: 16px;
    z-index: 5;
}

.diary-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.diary-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid #0f3460;
    color: #aaa;
    font-weight: normal;
    position: sticky;
    top: 0;
    background: #1a1a2e;
}

.diary-table td {
    padding: 8px 12px;
    border-bottom: 1px solid #0f3460;
    vertical-align: top;
}

.diary-table tr:hover {
    background: #16213e;
    cursor: pointer;
}

.diary-thumb {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 3px;
    border: 1px solid #0f3460;
}

.diary-text-preview {
    max-width: 400px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.diary-link-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    background: #0f3460;
    color: #ccc;
}

@media (max-width: 600px) {
    .diary-table th:nth-child(2),
    .diary-table td:nth-child(2) {
        display: none;
    }
    .diary-text-preview {
        max-width: 180px;
    }
}
