body {
    font-family: sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0;
    padding: 20px;
    background-color: #f0f0f0;
    overflow-x: hidden; /* Prevent horizontal scroll on body */
}
.main-container {
    display: flex;
    flex-direction: row;
    gap: 0;
    width: 95%;
    max-width: 1600px;
}
.left-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex-grow: 3;
    min-width: 0; /* Allow left panel to shrink */
}
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 15px;
    width: 320px;
    min-width: 280px;
    flex-shrink: 0; /* Prevent right panel from shrinking too much */
    transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
    position: relative;
}
.controls {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
    padding: 10px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    align-items: center;
    width: 100%;
    box-sizing: border-box;
    max-width: 100%;
}
.control-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
label {
    font-size: 0.85em;
    color: #333;
    margin-bottom: 2px;
}
input[type="file"],
input[type="range"],
input[type="number"],
select,
button,
textarea {
    padding: 7px;
    border-radius: 4px;
    border: 1px solid #ccc;
    font-size: 0.9em;
    box-sizing: border-box;
}
input[type="number"] {
    width: 60px;
}
button {
    background-color: #007bff;
    color: white;
    cursor: pointer;
    transition: background-color 0.2s;
}
button:hover {
    background-color: #0056b3;
}
button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}
#canvasContainerWrapper {
    width: 100%;
    height: 95vh;
    max-width: 100%;
    resize: both;
    overflow: hidden;
    border: 1px dashed #999;
    min-width: 300px;
    min-height: 200px;
    margin-bottom: 5px;
    touch-action: none;
    position: relative;
    box-sizing: border-box;
}
canvas#mainCanvas {
    border: 1px solid #000;
    background-color: #fff;
    display: block;
}
.info {
    margin-top: 10px;
    font-size: 0.8em;
    color: #555;
    text-align: center;
    width: 100%;
}
#pathListContainer {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 10px;
}
#pathListHeader {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}
#clearPaths {
    background: #e53935;
    color: #fff;
    border: none;
    border-radius: 5px;
    padding: 6px 16px;
    font-size: 1em;
    font-weight: 500;
    margin-left: 10px;
    margin-right: 0;
    cursor: pointer;
    transition: background 0.2s;
}
#clearPaths:hover {
    background: #b71c1c;
}
#pathListContainer h3 {
    margin: 0;
    font-size: 1.1em;
    color: #333;
    border: none;
    padding: 0;
}
#pathList {
     max-height: 280px;
     overflow-y: auto;
}
.path-item {
    padding: 8px 5px;
    border-bottom: 1px solid #eee;
    font-size: 0.9em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.1s;
}
.path-item:hover {
    background-color: #e9ecef;
}
.path-item.selected {
    background-color: #cce5ff;
    font-weight: bold;
}
.path-item button {
    padding: 3px 6px;
    font-size: 0.8em;
    background-color: #6c757d;
}
.path-item button:hover {
    background-color: #5a6268;
}
#jsonTextArea {
    width: 100%;
    min-height: 200px;
    font-family: monospace;
    font-size: 0.85em;
    resize: vertical;
    border: 1px solid #ccc;
}
#jsonTextArea.invalid {
    border-color: red;
    box-shadow: 0 0 3px red;
}
#savedPathsSidebar {
    width: 100%;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    padding: 10px;
    margin-top: 0;
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    gap: 0;
    max-width: 100%;
    box-sizing: border-box;
    resize: vertical;
    min-height: 80px;
    overflow: hidden;
}
#savedPathsSidebar h3 {
    margin-top: 0;
    margin-bottom: 8px;
    font-size: 1.1em;
    color: #333;
    border-bottom: 1px solid #eee;
    padding-bottom: 5px;
    background: inherit;
    position: sticky;
    top: 0;
    z-index: 1;
}
#savedPathsList {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 2px;
    min-height: 0;
}
#savePathBtn {
    margin-top: 10px;
    width: 100%;
    font-size: 1em;
    padding: 10px 0;
}
.saved-path-item {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #fff;
    border: 1px solid #eee;
    border-radius: 6px;
    padding: 6px 4px;
    transition: background 0.15s;
    cursor: pointer;
    position: relative;
}
.saved-path-item.selected {
    background: #e3f2fd;
    border-color: #90caf9;
}
.saved-path-preview {
    width: 48px;
    height: 48px;
    border-radius: 4px;
    border: 1px solid #ccc;
    object-fit: cover;
    background: #fafafa;
}
.saved-path-meta {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.saved-path-name {
    font-weight: bold;
    font-size: 1em;
    display: flex;
    align-items: center;
    gap: 4px;
}
.saved-path-name input {
    font-size: 1em;
    border: 1px solid #bbb;
    border-radius: 3px;
    padding: 1px 3px;
    width: 90px;
}
.saved-path-timestamp {
    font-size: 0.8em;
    color: #888;
}
.star-btn {
    background: none;
    border: none;
    font-size: 1.3em;
    color: #ffd600;
    cursor: pointer;
    margin-left: 4px;
    transition: color 0.2s, background 0.2s;
}
.star-btn.filled {
    color: #ffc107;
}
.star-btn:not(.filled) {
    color: #bbb;
}
.star-btn:hover, .star-btn:focus {
    color: #ffd600;
    background: none;
}
.collapsible {
    width: 100%;
    max-width: 480px;
    margin-bottom: 10px;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border: 1px solid #ddd;
    overflow: hidden;
}
.collapsible-header {
    cursor: pointer;
    padding: 8px 10px;
    font-weight: 500;
    font-size: 1em;
    color: #222;
    background: none;
    border-bottom: 1px solid #eee;
    display: flex;
    align-items: center;
    user-select: none;
    box-shadow: none;
}
.collapsible-header::before {
    content: '\25B6';
    display: inline-block;
    margin-right: 8px;
    font-size: 1em;
    transition: transform 0.2s;
    color: #888;
}
.collapsible.open .collapsible-header::before {
    transform: rotate(90deg);
}
.collapsible-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s cubic-bezier(0.4,0,0.2,1);
    padding: 0;
    margin: 0;
    border: none;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.collapsible.open .collapsible-content {
    padding: 12px 10px 14px 10px;
    max-height: 500px;
    transition: max-height 0.4s cubic-bezier(0.4,0,0.2,1);
}
.collapsible-content .control-group,
.collapsible-content button,
.collapsible-content select,
.collapsible-content input[type="range"],
.collapsible-content input[type="number"] {
    margin-bottom: 6px;
}
.collapsible-content .control-group {
    display: flex;
    flex-direction: column;
    gap: 3px;
}
.collapsible-content button {
    width: fit-content;
    min-width: 90px;
    margin-right: 8px;
    margin-top: 2px;
    margin-bottom: 2px;
}
.collapsible-content button:last-child {
    margin-right: 0;
}
.collapsible-content input,
.collapsible-content select {
    width: 100%;
    max-width: 220px;
}
.collapsible-content button,
.collapsible-content input,
.collapsible-content select {
    outline: none;
    transition: box-shadow 0.15s, border-color 0.15s;
}
.collapsible-content button:focus,
.collapsible-content input:focus,
.collapsible-content select:focus {
    box-shadow: 0 0 0 2px #1976d233;
    border-color: #1976d2;
}
.collapsible-content button:hover {
    filter: brightness(0.95);
}
.button-row {
    display: flex;
    flex-direction: row;
    gap: 10px;
    width: 100%;
    margin-bottom: 6px;
}
.button-row button {
    flex: 1 1 0;
    min-width: 0;
}
.wide-btn {
    width: 100%;
    margin-top: 0;
    margin-bottom: 6px;
    box-sizing: border-box;
}
.right-panel.collapsed {
    width: 0 !important;
    min-width: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: none !important;
    box-shadow: none !important;
    transition: width 0.3s cubic-bezier(0.4,0,0.2,1);
    position: relative;
}
#toggleRightPanelBtn {
    background: #eee;
    color: #333;
    border: 1px solid #bbb;
    border-radius: 50%;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}
#toggleRightPanelBtn:hover {
    background: #ccc;
    color: #222;
}
.main-container.full-width .left-panel {
    flex-grow: 1;
    width: 100%;
    max-width: 100%;
}
.main-container.full-width .right-panel {
    display: none !important;
}
#collapseHandle {
    width: 18px;
    min-width: 18px;
    height: 100vh;
    background: #f5f5f5;
    border-left: 1px solid #ddd;
    border-right: 1px solid #ddd;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    z-index: 20;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
    box-shadow: 0 0 4px 0 rgba(0,0,0,0.03);
    margin: 0;
    padding: 0;
}
#collapseHandle:hover {
    background: #e0e0e0;
    border-color: #bbb;
}
#collapseHandle::after {
    content: '\25B6'; /* ▶ (right) when expanded */
    color: #888;
    font-size: 1.3em;
    transition: transform 0.2s;
    display: block;
}
.right-panel.collapsed + #collapseHandle::after,
.main-container.full-width #collapseHandle::after {
    content: '\25C0'; /* ◀ (left) when collapsed */
}
.canvas-touch-buttons {
    position: absolute;
    top: 12px;
    right: 16px;
    display: flex;
    flex-direction: row;
    gap: 30px;
    z-index: 10;
    background: rgba(255,255,255,0.85);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    padding: 6px 10px;
    pointer-events: auto;
}
.canvas-touch-group {
    display: flex;
    flex-direction: row;
    gap: 4px;
}
.canvas-touch-buttons button {
    background: none;
    border: none;
    padding: 8px;
    border-radius: 50%;
    font-size: 1.6em;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #1976d2;
    transition: background 0.2s, color 0.2s, box-shadow 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.07);
    outline: none;
}
.canvas-touch-buttons button:active {
    background: #e3f2fd;
    color: #0d47a1;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.10);
}
.canvas-touch-buttons button:focus {
    outline: none;
    /* No box-shadow or border-color here */
}
.canvas-touch-buttons button:focus-visible {
    box-shadow: 0 0 0 2px #1976d233;
    border-color: #1976d2;
}
.canvas-touch-buttons button:hover {
    background: #e3f2fd;
    color: #0d47a1;
}
.canvas-touch-buttons button.active {
    background: #1976d2;
    color: #fff;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.15);
}
.canvas-touch-buttons button.active svg path {
    stroke: #fff;
}
.delete-btn {
    background: none;
    border: none;
    color: #d32f2f;
    font-size: 1.1em;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: background 0.15s;
    margin-left: 2px;
}
.delete-btn:hover {
    background: #ffd6d6;
} 