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

:root {
    --bg-primary: #1A2F42;
    --bg-secondary: #2A3F5A;
    --canvas-bg: #ffffff;
    --text-primary: #E8F4FD;
    --text-muted: rgba(232, 244, 253, 0.68);
    --accent-color: #4A90E2;
    --accent-hover: #6BA3E8;
    --panel-bg: rgba(26, 47, 66, 0.95);
    --border-color: rgba(255, 255, 255, 0.18);
    --input-bg: #3A4F6A;
    --success-color: #3BB273;
    --danger-color: #E76F51;
    --collapsible-content-gap: 8px;
    --objects-list-gap: 8px;
    --objects-list-trailing-gap: 10px;
    --safe-area-top: env(safe-area-inset-top);
    --safe-area-bottom: env(safe-area-inset-bottom);
    --safe-area-left: env(safe-area-inset-left);
    --safe-area-right: env(safe-area-inset-right);
}

html[data-theme="dark"] {
    --canvas-bg: #606060;
}

html,
body {
    width: 100%;
    height: 100%;
    min-height: 100vh;
    min-height: var(--actual-vh, 100vh);
    background: var(--bg-primary);
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    overscroll-behavior: none;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

button,
input,
select,
textarea {
    font: inherit;
}

.title-screen {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: var(--actual-vh, 100vh);
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1A2F42;
    z-index: 2000;
    transition: opacity 0.45s ease, visibility 0.45s ease;
}

.title-screen.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.title-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 22px;
    text-align: center;
    padding: 40px 24px;
}

.title-mark {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 88px;
    height: 88px;
    border-radius: 24px;
    background: linear-gradient(145deg, rgba(74, 144, 226, 0.95), rgba(42, 63, 90, 0.9));
    color: #fff;
    font-size: 42px;
    font-weight: 800;
    box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
    transform: perspective(1200px) rotateY(0deg) scale(1);
}

.title-copy {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.title-logo {
    max-width: min(78vw, 520px);
    max-height: 30vh;
    width: auto;
    height: auto;
    object-fit: contain;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: auto;
    image-rendering: smooth;
    -ms-interpolation-mode: bicubic;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
    -webkit-user-drag: none;
    pointer-events: auto;
}

.title-name {
    font-size: clamp(2.8rem, 8vw, 4.8rem);
    line-height: 0.95;
    letter-spacing: 0.02em;
}

.title-tagline {
    font-size: 1.1rem;
    color: var(--text-primary);
    font-style: italic;
}

.wip-banner {
    display: inline-flex;
    align-items: center;
    padding: 6px 18px;
    border-radius: 6px;
    background: repeating-linear-gradient(
        -45deg,
        #9a5f00,
        #9a5f00 7px,
        #c27a00 7px,
        #c27a00 14px
    );
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.35);
}

.title-actions {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.title-subline {
    max-width: 34rem;
    color: var(--text-muted);
    line-height: 1.45;
}

.start-btn {
    min-width: 180px;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 30px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.25);
    transition: transform 0.2s ease, filter 0.2s ease;
}

.start-btn:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
}

.contact-icon-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
    position: relative;
    top: -2px;
    color: #fff;
    transition: none;
}

.contact-icon-link:hover {
    color: #fff;
}

.contact-icon-link svg {
    width: 1.35em;
    height: 1.35em;
}

.copyright .contact-icon-link,
.copyright .contact-icon-link:hover,
.copyright .contact-icon-link:visited {
    color: #fff;
}

.contact-icon-link path {
    fill: currentColor;
}

.break-mobile {
    display: inline;
}

.space-desktop {
    display: none;
}

@media (min-width: 800px) {
    .break-mobile {
        display: none;
    }
    
    .space-desktop {
        display: inline;
    }
}

.copyright {
    position: absolute;
    bottom: calc(20px + var(--safe-area-bottom, 0px));
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.8em;
    color: #fff;
    margin: 0;
    text-align: center;
    line-height: 1.3;
    max-width: 90%;
    word-wrap: break-word;
    hyphens: auto;
}

.copyright a {
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
}

.copyright a:not(.contact-icon-link) {
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: opacity 0.2s;
}

.container {
    position: relative;
    width: 100vw;
    height: 100vh;
    height: var(--actual-vh, 100vh);
    min-height: var(--actual-vh, 100vh);
}

.main-app {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100vh;
    height: var(--actual-vh, 100vh);
    min-height: var(--actual-vh, 100vh);
}

.panel-toggle-btn {
    position: fixed;
    top: max(20px, calc(var(--safe-area-top) + 10px));
    right: max(20px, calc(var(--safe-area-right) + 20px));
    z-index: 1100;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 8px;
    background: rgba(42, 63, 90, 0.94);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.25s ease;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.copyright a:not(.contact-icon-link):hover {
    opacity: 0.85;
}

.panel-toggle-btn span {
    width: 20px;
    height: 2px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.9);
    transition: transform 0.25s ease, opacity 0.25s ease;
}

.panel-toggle-btn.active {
    background: rgba(231, 111, 81, 0.92);
}

.panel-toggle-btn.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

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

.panel-toggle-btn.active span:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.control-panel {
    position: absolute;
    left: 0;
    top: 0;
    width: 330px;
    min-width: 330px;
    max-width: 330px;
    box-sizing: border-box;
    height: 100vh;
    height: var(--actual-vh, 100vh);
    padding: 20px;
    padding-top: max(20px, calc(var(--safe-area-top) + 10px));
    padding-bottom: max(20px, calc(var(--safe-area-bottom) + 10px));
    background: var(--panel-bg);
    backdrop-filter: blur(5px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    overflow-x: hidden;
    transition: transform 0.3s ease;
    z-index: 1000;
    scrollbar-width: none;
    -ms-overflow-style: none;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-panel::-webkit-scrollbar {
    display: none;
}

.control-panel.closed {
    transform: translateX(-100%);
}

.panel-logo {
    visibility: visible;
    max-width: 239px;
    width: 100%;
    height: auto;
    margin: 0 auto 15px;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: auto;
    image-rendering: smooth;
    -ms-interpolation-mode: bicubic;
    backface-visibility: visible;
    -webkit-backface-visibility: visible;
    -webkit-user-drag: none;
    pointer-events: auto;
}

.panel-section {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 8px;
}

.section-heading-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.section-heading-row h3 {
    font-size: 0.98rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.section-note {
    color: var(--text-muted);
    font-size: 0.84rem;
    line-height: 1.35;
}

.field-label {
    font-size: 0.78rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.panel-input,
.slider-input {
    width: 100%;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--input-bg);
    color: var(--text-primary);
}

.panel-input {
    padding: 10px 12px;
    appearance: none;
}

.orientation-inline-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

.orientation-inline-label {
    margin: 0;
    white-space: nowrap;
}

.orientation-chip-row {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    align-items: center;
}

.orientation-chip-btn {
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    padding: 4px 8px;
    font-size: 0.75rem;
    line-height: 1.15;
    cursor: pointer;
}

.orientation-chip-btn.is-active {
    background: rgba(74, 144, 226, 0.22);
    border-color: rgba(74, 144, 226, 0.72);
}

@media (hover: hover) {
    .orientation-chip-btn:hover {
        background: rgba(255, 255, 255, 0.12);
    }
}

.slider-stack {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.slider-row {
    display: flex;
    align-items: center;
    gap: 5px;
    min-height: 22px;
}

.slider-name {
    width: 76px;
    flex-shrink: 0;
    font-size: 0.8rem;
    line-height: 1;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.slider-input-wrap {
    position: relative;
    flex: 1;
    min-width: 0;
    height: 18px;
}

.slider-input {
    width: 100%;
    height: 6px;
    margin: 0;
    position: absolute;
    top: 50%;
    left: 0;
    transform: translateY(-50%);
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.2);
    appearance: none;
    outline: none;
    cursor: pointer;
}

.slider-input::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 999px;
    background: linear-gradient(to right, var(--accent-color) 0%, var(--accent-color) var(--slider-fill, 0%), rgba(255, 255, 255, 0.2) var(--slider-fill, 0%), rgba(255, 255, 255, 0.2) 100%);
}

.slider-input::-webkit-slider-thumb {
    appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #d7e7fb;
    background: #4A90E2;
    margin-top: -3px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.slider-input::-moz-range-track {
    height: 6px;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.2);
}

.slider-input::-moz-range-progress {
    height: 6px;
    border-radius: 999px;
    background: var(--accent-color);
}

.slider-input::-moz-range-thumb {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 1px solid #d7e7fb;
    background: #4A90E2;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.panel-separator {
    display: none;
}

.panel-major-divider {
    border-top: 1px solid #555;
    margin: 8px 0;
}

/* Primitive cards */
.primitive-card {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-left: 3px solid #904AE2;
}

.primitive-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.primitive-card-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.card-remove-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid #555;
    border-radius: 5px;
    background: #2A3F5A;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .card-remove-btn:hover {
        filter: brightness(1.15);
        box-shadow: 0 3px 8px rgba(0, 0, 0, 0.3);
    }
}

.card-remove-btn:active {
    background: #E74C3C;
}

.card-cycle-btn {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #2A3F5A;
    color: var(--text-primary);
    font-size: 0.78rem;
    text-align: left;
    cursor: pointer;
}

@media (hover: hover) {
    .card-cycle-btn:hover {
        background: #354d6b;
    }
}

.card-face-info {
    font-size: 0.78rem;
    color: var(--text-muted);
    padding: 4px 0 2px;
}

.dropdown-item-disabled {
    color: var(--text-muted);
    cursor: default;
    font-style: italic;
}

.collapsible-section-header {
    cursor: pointer;
    user-select: none;
    padding: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    transition: background 0.2s ease;
}

@media (hover: hover) {
    .collapsible-section-header:hover {
        background: rgba(255, 255, 255, 0.12);
    }
}

.collapsible-section-header h3 {
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}

.collapsible-section-content {
    margin-top: var(--collapsible-content-gap);
    max-height: 1200px;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.2s ease, margin-top 0.3s ease;
    opacity: 1;
}

.collapsible-section-content > :first-child {
    margin-top: 0;
}

.collapsible-section-content.collapsed {
    max-height: 0;
    margin-top: 0;
    opacity: 0;
}

.points-list,
.actions-list,
.objects-list {
    display: flex;
    flex-direction: column;
    gap: var(--objects-list-gap);
}

.objects-list:not(:empty) {
    padding-bottom: var(--objects-list-trailing-gap);
}

.points-list {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    max-height: 250px;
    overflow-y: auto;
    padding-right: 4px;
    align-content: start;
}

.points-list .point-btn {
    flex: 0 0 28px;
    width: 28px;
}

.point-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    min-height: 28px;
    padding: 2px;
    border: 1px solid #555;
    border-radius: 4px;
    background: #2A3F5A;
    color: #e0e0e0;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.point-btn.is-selected {
    border-color: var(--accent-color);
    background: #354d6b;
    color: #ffffff;
}

.point-btn.is-derived {
    border-color: #555;
    background: #2A3F5A;
    color: #e0e0e0;
}

.point-btn.is-derived.is-selected {
    border-color: var(--accent-color);
    background: #354d6b;
    color: #ffffff;
}

@media (hover: hover) {
    .point-btn:not(.is-selected):hover {
        background: #354d6b;
    }

    .point-btn.is-derived:not(.is-selected):hover {
        background: #354d6b;
    }
}

.point-name {
    font-weight: 700;
    font-size: 0.74rem;
    line-height: 1;
}

.point-order {
    display: none;
}

.selection-summary {
    margin-top: 10px;
    min-height: 48px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.selection-summary.empty {
    display: none;
}

.selection-pill {
    display: inline-flex;
    align-items: center;
    padding: 0;
    border-radius: 0;
    background: transparent;
    color: var(--text-primary);
    font-weight: 600;
}

.selection-arrow {
    color: var(--text-muted);
}

.action-btn,
.mini-btn,
.object-delete {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: #2A3F5A;
    color: var(--text-primary);
    cursor: pointer;
}

.action-btn {
    width: auto;
    padding: 6px 10px;
    text-align: center;
    font-size: 0.82rem;
    line-height: 1;
    border-radius: 999px;
    white-space: nowrap;
}

.actions-list {
    margin-top: 10px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
}

.actions-list:empty {
    display: none;
}

@media (hover: hover) {
    .action-btn:hover,
    .mini-btn:hover,
    .object-delete:hover,
    .top-btn:hover {
        background: #354d6b;
    }
}

.mini-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
}

.top-button-row {
    display: grid;
    gap: 8px;
    margin-bottom: 8px;
    position: relative;
}

.top-button-row.two-col-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.top-button-row.three-col-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.top-btn {
    min-height: 40px;
    height: 40px;
    padding: 8px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background: #2A3F5A;
    color: var(--text-primary);
    cursor: pointer;
    line-height: 1.2;
    font-size: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    box-sizing: border-box;
}

.panel-top-controls {
    margin-bottom: 0;
}

.panel-top-controls-secondary {
    margin-bottom: 0;
}

.bottom-controls-row {
    align-items: center;
}

.bottom-half-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
    width: 100%;
}

.bottom-half-btn {
    flex: 1;
    min-width: 0;
}

.top-btn-spacer {
    min-height: 40px;
}

.grid-icon {
    color: #666;
    transition: color 0.2s;
    cursor: pointer;
}

.grid-icon.grid-active {
    color: #ffffff;
}

.label-badge-icon {
    color: #666;
    transition: color 0.2s;
    cursor: pointer;
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 12px;
}

.label-off-option {
    font-size: 11px;
    letter-spacing: 0.02em;
}

#label-badge-icon {
    background: #666;
    border: 1px solid #666;
    border-radius: 4px;
    padding: 2px 4px;
    min-width: 18px;
    color: #2A3F5A;
}

.label-badge-icon.label-badge-active {
    color: #ffffff;
}

#label-badge-icon.label-badge-active {
    background: #ffffff;
    border-color: #ffffff;
    color: #2A3F5A;
}

.label-badge-separator {
    color: #666;
    font-size: 14px;
    line-height: 1;
}

.ghost-icon {
    color: #666;
    transition: color 0.2s;
    cursor: pointer;
    width: 20px;
    height: 20px;
}

.ghost-icon.ghost-active {
    color: #ffffff;
}

.ghost-separator {
    color: #666;
    font-size: 14px;
    line-height: 1;
}

.point-marker-icon {
    color: #666;
    transition: color 0.2s;
    cursor: pointer;
    width: 20px;
    height: 20px;
}

.point-marker-icon.point-marker-active {
    color: #ffffff;
}

.theme-icon {
    color: #666;
    transition: color 0.2s;
}

.theme-icon.theme-active {
    color: #ffffff;
}

.theme-separator {
    color: #666;
}

.size-option {
    color: #666;
    transition: color 0.2s;
}

.size-option.size-active {
    color: #ffffff;
}

.size-separator {
    color: #666;
}

@media (hover: hover) {
    #grid-toggle-btn:hover {
        background: #354d6b !important;
    }
}

.add-button {
    position: relative;
    padding: 8px 12px;
    font-size: 14px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2A3F5A;
    border: 1px solid #555;
    border-radius: 4px;
    color: #e0e0e0;
    cursor: pointer;
    transition: background 0.2s;
}

.add-plus-icon {
    display: block;
    width: 12px;
    height: 12px;
    margin-right: 4px;
    flex-shrink: 0;
}

@media (hover: hover) {
    .add-button:hover {
        background: #354d6b;
    }
}

.add-dropdown {
    position: absolute;
    top: 42px;
    left: 0;
    background: #2A3F5A;
    border: 1px solid #555;
    border-radius: 4px;
    min-width: 200px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.add-dropdown .dropdown-item {
    padding: 10px 12px;
    color: #e0e0e0;
    cursor: pointer;
    border-bottom: 1px solid #3a4a5f;
    transition: background 0.2s;
}

.add-dropdown .dropdown-item:last-child {
    border-bottom: none;
}

@media (hover: hover) {
    .add-dropdown .dropdown-item:hover {
        background: #354d6b;
    }
}

.add-dropdown .dropdown-item strong {
    margin-right: 6px;
    color: rgba(255, 255, 255, 0.92);
}

.primitive-selector-hidden {
    display: none;
}

.empty-state {
    color: var(--text-muted);
    padding: 10px 0;
}

.group-arrow {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.7);
}

.section-count {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.object-item {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 8px;
    padding: 10px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.06);
    border-left: 3px solid var(--accent-color);
}

.object-item.disabled {
    opacity: 0.7;
}

.object-name {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.object-name strong {
    font-size: 0.92rem;
}

.object-name span {
    color: var(--text-muted);
    font-size: 0.8rem;
}

.object-controls {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    min-height: 100%;
}

.object-visibility-btn {
    width: 20px;
    height: 20px;
    border-radius: 5px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}

.object-delete {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid #555;
    border-radius: 5px;
    background: #2A3F5A;
    color: var(--text-primary);
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: all 0.2s ease;
}

@media (hover: hover) {
    .object-visibility-btn:hover {
        border-color: rgba(255, 255, 255, 0.5);
        transform: scale(1.1);
    }
}

.object-visibility-btn:active {
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.1);
}

.object-delete {
    background: #2A3F5A;
}

.canvas-container {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    background: var(--canvas-bg);
}

#three-canvas {
    width: 100%;
    height: 100%;
    display: block;
    touch-action: none;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

.canvas-chip {
    position: absolute;
    z-index: 50;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    padding: 8px 12px;
    background: rgba(26, 47, 66, 0.88);
    color: var(--text-primary);
    backdrop-filter: blur(8px);
    font-size: 0.88rem;
}

.canvas-chip.top-left {
    top: max(18px, calc(var(--safe-area-top) + 10px));
    left: max(18px, calc(var(--safe-area-left) + 18px));
}

.control-panel:not(.closed) + .canvas-container .canvas-chip.top-left {
    opacity: 0;
    visibility: hidden;
}

.canvas-chip.bottom-right {
    right: max(18px, calc(var(--safe-area-right) + 18px));
    bottom: max(18px, calc(var(--safe-area-bottom) + 18px));
    max-width: min(360px, calc(100vw - 40px));
}

.chip-separator {
    margin: 0 8px;
    color: var(--text-muted);
}

.custom-modal-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 12, 18, 0.72);
    z-index: 3000;
    padding: 20px;
}

.custom-modal-overlay.show {
    display: flex;
}

.custom-modal {
    width: min(380px, 100%);
    border: 1px solid var(--border-color);
    border-radius: 14px;
    background: rgba(26, 47, 66, 0.98);
    padding: 24px 22px 20px;
    box-shadow: 0 28px 56px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.custom-modal-message {
    color: var(--text-primary);
    font-size: 0.95rem;
    line-height: 1.4;
    margin: 0;
}

.custom-modal-input {
    width: 100%;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 9px 12px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    box-sizing: border-box;
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
}

.custom-modal-input:focus {
    border-color: var(--accent-color);
}

.custom-modal-symbols {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.custom-modal-symbol-btn {
    min-width: 34px;
    height: 30px;
    padding: 0 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-size: 1rem;
    line-height: 1;
    cursor: pointer;
}

.custom-modal-error {
    color: var(--danger-color);
    font-size: 0.82rem;
    min-height: 1.1em;
    margin: -6px 0 -4px;
}

.custom-modal-error:empty {
    display: none;
}

.custom-modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.custom-modal-btn {
    padding: 8px 20px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: filter 0.15s;
}

.custom-modal-btn-cancel {
    background: transparent;
    color: var(--text-muted);
}

.custom-modal-btn-confirm {
    background: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}

@media (hover: hover) {
    .custom-modal-btn:hover {
        filter: brightness(1.15);
    }

    .custom-modal-symbol-btn:hover {
        filter: brightness(1.15);
    }
}

.help-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(5, 12, 18, 0.7);
    z-index: 2500;
    padding: 20px;
}

.help-overlay.show {
    display: flex;
}

.help-content {
    width: min(520px, 100%);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    background: rgba(26, 47, 66, 0.96);
    padding: 22px;
    box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.help-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.help-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    cursor: pointer;
    font-size: 1.6rem;
    line-height: 1;
}

.help-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    color: var(--text-primary);
    line-height: 1.5;
}

@media (max-width: 768px) {
    .control-panel {
        width: 330px;
    }

    .canvas-chip.bottom-right {
        max-width: min(260px, calc(100vw - 36px));
        font-size: 0.8rem;
    }
}

@media (max-width: 560px) {
    .title-content {
        padding-left: 18px;
        padding-right: 18px;
    }

    .title-logo {
        max-width: min(86vw, 420px);
        max-height: 24vh;
    }

    .canvas-chip.top-left {
        left: 16px;
        max-width: calc(100vw - 86px);
    }

    #label-badge-toggle-btn > div {
        gap: 3px !important;
    }

    #label-badge-toggle-btn .label-badge-icon {
        font-size: 11px;
        min-width: 10px;
    }

    #label-badge-toggle-btn .label-off-option {
        font-size: 9px;
    }

    #label-badge-toggle-btn #label-badge-icon {
        min-width: 14px;
        padding: 1px 3px;
    }
}

@media (hover: none) and (pointer: coarse) {
    .canvas-chip.bottom-right {
        display: block;
    }
}