* {
    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);
    /* Triangle extract modal — SVG label fill (theme-aware, set per-theme below) */
    --extract-label-fill: #1a2f42;
}

html[data-theme="dark"] {
    --canvas-bg: #606060;
    /* Triangle extract modal — SVG label fill on dark canvas */
    --extract-label-fill: #ffffff;
}

html,
body {
    width: 100%;
    height: 100%;
    height: var(--actual-vh, 100vh);
    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;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

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;
}

.title-goodie {
    width: min(50vw, 190px);
    display: flex;
    justify-content: center;
    margin-top: -4px;
    margin-bottom: -2px;
}

.title-goodie-svg {
    width: 100%;
    height: auto;
    transform: translateX(9px);
    overflow: visible;
    animation: goodie-post-cycle 12s linear infinite;
    animation-delay: 4s;
    animation-fill-mode: backwards;
}

.goodie-line-left,
.goodie-line-right {
    fill: none;
    stroke: url(#goodieLineGradient);
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 36;
    stroke-dashoffset: 36;
    filter: saturate(1.45) brightness(1.12) drop-shadow(0 0 7px rgba(0, 229, 255, 0.55));
    animation: goodie-line-draw 4s ease-in-out 1 forwards;
}

.goodie-sq-left,
.goodie-sq-right,
.goodie-sq-top {
    fill: none;
    stroke: url(#goodieLineGradient);
    stroke-width: 2.5;
    stroke-linecap: round;
    filter: saturate(1.45) brightness(1.12) drop-shadow(0 0 7px rgba(0, 229, 255, 0.55));
}

.goodie-sq-left {
    stroke-dasharray: 72;
    stroke-dashoffset: 72;
    animation: goodie-sq-side-draw 4s ease-in-out 1 forwards;
}

.goodie-sq-right {
    stroke-dasharray: 72;
    stroke-dashoffset: 72;
    animation: goodie-sq-side-draw 4s ease-in-out 1 forwards;
}

.goodie-sq-top {
    stroke-dasharray: 72;
    stroke-dashoffset: 72;
    animation: goodie-sq-top-draw 4s ease-in-out 1 forwards;
}

.goodie-cube {
    opacity: 0;
    animation: goodie-cube-visibility 4s ease-in-out 1 forwards;
}

.goodie-cube-back {
    fill: none;
    stroke: url(#goodieLineGradient);
    stroke-width: 2;
    filter: saturate(1.45) brightness(1.12) drop-shadow(0 0 7px rgba(0, 229, 255, 0.5));
    animation: goodie-cube-drag 4s ease-in-out 1 forwards;
}

.goodie-cube-connector {
    stroke: url(#goodieLineGradient);
    stroke-width: 2;
    stroke-linecap: butt;
    stroke-dasharray: 34;
    stroke-dashoffset: 34;
    filter: saturate(1.45) brightness(1.12) drop-shadow(0 0 7px rgba(0, 229, 255, 0.5));
    animation: goodie-cube-connectors 4s ease-in-out 1 forwards;
}


@keyframes goodie-line-draw {
    0%, 6% { stroke-dashoffset: 36; opacity: 1; }
    22%, 92% { stroke-dashoffset: 0; opacity: 1; }
    100% { stroke-dashoffset: 0; opacity: 1; }
}

@keyframes goodie-sq-side-draw {
    0%, 26% { stroke-dashoffset: 72; opacity: 0; }
    27% { stroke-dashoffset: 72; opacity: 1; }
    44%, 92% { stroke-dashoffset: 0; opacity: 1; }
    100% { stroke-dashoffset: 0; opacity: 1; }
}

@keyframes goodie-sq-top-draw {
    0%, 46% { stroke-dashoffset: 72; opacity: 0; }
    47% { stroke-dashoffset: 72; opacity: 1; }
    54%, 92% { stroke-dashoffset: 0; opacity: 1; }
    100% { stroke-dashoffset: 0; opacity: 1; }
}

@keyframes goodie-cube-visibility {
    0%, 61% { opacity: 0; }
    64%, 92% { opacity: 1; }
    100% { opacity: 1; }
}

@keyframes goodie-cube-drag {
    0%, 62% { transform: translate(-26px, 22px); }
    80%, 100% { transform: translate(0, 0); }
}

@keyframes goodie-cube-connectors {
    0%, 62% { stroke-dashoffset: 34; }
    80%, 100% { stroke-dashoffset: 0; }
}

@keyframes goodie-post-cycle {
    0% { filter: hue-rotate(0deg); }
    100% { filter: hue-rotate(360deg); }
}

.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 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 180px;
    padding: 8px 30px;
    border: 1px solid rgba(82, 218, 103, 0.9);
    border-radius: 8px;
    background: #198A42;
    color: #FFFFFF;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: 800;
    box-shadow: 0 8px 22px rgba(53, 224, 88, 0.18), 0 2px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s, filter 0.2s, box-shadow 0.2s;
}

.title-guide-link {
    color: #FFFFFF;
    font-size: 0.95rem;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.title-guide-link:hover {
    color: #B7DCFF;
}

.start-btn:hover {
    color: #FFFFFF;
    filter: brightness(1.05);
    transform: translateY(-1px);
    box-shadow: 0 10px 28px rgba(53, 224, 88, 0.28), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.start-btn:active {
    filter: brightness(1.1);
}

.start-btn:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.9);
    outline-offset: 3px;
}

.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;
}

@media (min-width: 1024px) {
    .copyright {
        font-size: 1em;
    }
}

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

.copyright .tool-link {
    white-space: nowrap;
}

.copyright .tools-row {
    display: block;
}

.copyright .tool-name {
    color: #ffe600;
    font-weight: 700;
}

.copyright .tool-description {
    display: none;
}

@media (max-width: 700px) {
    .copyright-separator,
    .tool-separator {
        display: none;
    }

    .copyright .tools-label {
        display: block;
        margin-top: 2px;
    }

    .copyright .tools-row > .tool-link:not(:last-child) {
        display: none;
    }

    .copyright .tool-link {
        display: inline-block;
        margin-top: 2px;
    }

}

.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;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(1),
.title-screen .copyright .tools-row > a.tool-link:nth-of-type(1):visited {
    color: #ff355e;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(1):hover {
    color: #ff5c7d;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(1):active {
    color: #ff2a52;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(2),
.title-screen .copyright .tools-row > a.tool-link:nth-of-type(2):visited {
    color: #39ff14;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(2):hover {
    color: #66ff47;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(2):active {
    color: #2eea0f;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(3),
.title-screen .copyright .tools-row > a.tool-link:nth-of-type(3):visited {
    color: #00c8ff;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(3):hover {
    color: #35d6ff;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(3):active {
    color: #00b8eb;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(4),
.title-screen .copyright .tools-row > a.tool-link:nth-of-type(4):visited {
    color: #ffe600;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(4):hover {
    color: #ffee4a;
}

.title-screen .copyright .tools-row > a.tool-link:nth-of-type(4):active {
    color: #e6cf00;
}

.title-screen .copyright .tools-row > a.tool-link {
    opacity: 1;
    transition: color 0.2s ease;
}

.title-screen .copyright .tools-row > a.tool-link .tool-name,
.title-screen .copyright .tools-row > a.tool-link .tool-description {
    color: inherit;
}

.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;
    gap: 8px;
}

.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;
    text-align: center;
}

.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,
.help-close-btn {
    width: 20px;
    height: 20px;
    padding: 0;
    border: 1px solid #555;
    border-radius: 5px;
    background: #2A3F5A;
    color: var(--text-primary);
    font-size: 0;
    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 {
        background: rgba(180, 60, 60, 0.7);
        border-color: #b43c3c;
    }
}

.card-remove-btn:active {
    background: rgba(180, 60, 60, 0.7);
}

.card-remove-btn svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2.6;
    fill: none;
    stroke-linecap: round;
}

.help-close-btn {
    font-size: 0;
}

@media (hover: hover) {
    .help-close-btn:hover {
        background: rgba(180, 60, 60, 0.7);
        border-color: #b43c3c;
    }
}

.help-close-btn:active {
    background: rgba(180, 60, 60, 0.7);
}

.help-close-btn svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2.6;
    fill: none;
    stroke-linecap: round;
}

.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 {
    display: flex;
    align-items: center;
    font-size: 12px;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.9);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    flex: 1;
}

.section-object-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.45em;
    margin-left: auto;
    padding: 1px 6px;
    border-radius: 6px;
    background: #ffcc00;
    color: #000000;
    font-weight: 700;
    line-height: 1.2;
}

.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-extract:hover,
    .object-label-edit: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-half-buttons {
    display: flex;
    gap: 4px;
    align-items: center;
    width: 100%;
}

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

.share-controls-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    margin-bottom: 0;
}

.share-link-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    letter-spacing: 0.08em;
    font-size: 11px;
    font-weight: 700;
}

.share-link-btn svg {
    flex: 0 0 auto;
}

.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;
    width: 20px;
    height: 20px;
    display: none;
}

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

.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);
}

.dropdown-divider {
    height: 1px;
    background: #3a4a5f;
    margin: 4px 0;
}

.add-dropdown .dropdown-accordion-header {
    width: 100%;
    border: none;
    -webkit-appearance: none;
    appearance: none;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s;
    background: rgba(255, 255, 255, 0.08);
    color: rgba(255, 255, 255, 0.92);
    font: inherit;
    font-size: inherit;
    line-height: 1.2;
    padding: 10px 12px;
}

@media (hover: hover) {
    .add-dropdown .dropdown-accordion-header:hover {
        background: rgba(255, 255, 255, 0.12);
    }
}

.add-dropdown .dropdown-accordion-arrow {
    font-size: 10px;
    color: rgba(255, 255, 255, 0.92);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 12px;
    min-width: 12px;
    height: 12px;
    line-height: 1;
    transition: transform 0.2s ease;
    transform-origin: center;
}

.add-dropdown .dropdown-accordion-header[aria-expanded="true"] .dropdown-accordion-arrow {
    transform: rotate(90deg);
}

.add-dropdown .dropdown-accordion-label {
    color: rgba(255, 255, 255, 0.92);
    flex: 1;
    line-height: 1.2;
}

.add-dropdown .dropdown-accordion-content {
    max-height: 420px;
    overflow: hidden;
    opacity: 1;
    transition: max-height 0.25s ease, opacity 0.2s ease;
}

.add-dropdown .dropdown-accordion-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.add-dropdown .dropdown-item-example {
    color: #c8d8e8;
    font-style: italic;
}

.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);
}

.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%;
    gap: 6px;
}

.object-extract {
    align-self: flex-start;
    margin-top: 5px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: #2A3F5A;
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s ease;
}

.object-extract:disabled {
    opacity: 0.38;
    cursor: not-allowed;
    pointer-events: none;
}

.object-label-edit {
    align-self: flex-start;
    margin-top: 4px;
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    background: #2A3F5A;
    color: var(--text-primary);
    font-size: 0.82rem;
    line-height: 1;
    white-space: nowrap;
    cursor: pointer;
    transition: background 0.2s ease;
}

.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: 0;
    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);
}

@media (hover: hover) {
    .object-delete:hover {
        background: rgba(180, 60, 60, 0.7);
        border-color: #b43c3c;
    }
}

.object-delete:active {
    background: rgba(180, 60, 60, 0.7);
}

.object-delete svg {
    width: 12px;
    height: 12px;
    stroke: currentColor;
    stroke-width: 2.6;
    fill: none;
    stroke-linecap: round;
}

.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;
}

@media (hover: hover) and (pointer: fine) {
    #three-canvas.can-pan {
        cursor: grab;
        cursor: -webkit-grab;
    }

    #three-canvas.can-pan.is-panning {
        cursor: grabbing;
        cursor: -webkit-grabbing;
    }
}

.canvas-empty-state {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    max-width: min(640px, calc(100vw - 48px));
    padding: 14px 18px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(26, 47, 66, 0.86);
    color: rgba(255, 255, 255, 0.95);
    text-align: center;
    font-size: 0.98rem;
    line-height: 1.4;
    z-index: 55;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

.canvas-empty-state.show {
    opacity: 1;
    visibility: visible;
}

.canvas-empty-state .inline-add-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.14);
    color: rgba(255, 255, 255, 0.98);
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    vertical-align: baseline;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.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-ratio-fields {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.custom-modal-ratio-fields[hidden] {
    display: none !important;
}

.custom-modal-ratio-input {
    width: 88px;
    text-align: center;
}

.custom-modal-ratio-separator {
    color: var(--text-primary);
    font-size: 1.2rem;
    font-weight: 700;
}

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

.custom-modal-symbols[hidden] {
    display: none !important;
}

.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);
    }
}

.export-svg-modal {
    width: min(440px, 100%);
}

.export-svg-modal-info {
    font-size: 0.82rem;
    color: var(--text-muted);
    font-style: italic;
    margin: -4px 0 6px;
}

.export-svg-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.export-svg-fieldset {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 8px 14px 12px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.export-svg-legend {
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0 4px;
}

.export-svg-option {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    user-select: none;
}

.export-svg-option input[type="checkbox"],
.export-svg-option input[type="radio"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--accent-color);
    flex-shrink: 0;
}

.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;
}

.crash-report-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(5, 12, 18, 0.86);
    z-index: 3300;
}

.crash-report-overlay.show {
    display: flex;
}

.crash-report-modal {
    width: min(980px, calc(100vw - 20px));
    max-height: min(90vh, calc(var(--actual-vh, 100vh) - 20px));
    border: 1px solid var(--border-color);
    border-radius: 12px;
    background: var(--bg-primary);
    box-shadow: 0 22px 44px rgba(0, 0, 0, 0.38);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.crash-report-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-color);
}

.crash-report-header h2 {
    margin: 0;
    font-size: 1.02rem;
    color: var(--text-primary);
}

.crash-report-actions {
    display: flex;
    gap: 8px;
}

.crash-report-btn {
    min-height: 34px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    padding: 0 12px;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    cursor: pointer;
}

.crash-report-content {
    margin: 0;
    padding: 12px 14px 16px;
    overflow: auto;
    color: var(--text-primary);
    font-size: 0.75rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
    background: var(--bg-secondary);
}

.triangle-extract-overlay {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    padding: clamp(18px, 4vw, 36px);
    background: rgba(5, 12, 18, 0);
    backdrop-filter: blur(0px);
    z-index: 2800;
    transition: background 0.34s ease, backdrop-filter 0.34s ease;
}

.triangle-extract-overlay.show {
    display: flex;
    background: rgba(5, 12, 18, 0.74);
    backdrop-filter: blur(3px);
}

.triangle-extract-flight-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    overflow: visible;
    pointer-events: none;
    z-index: 0;
}

.triangle-extract-flight-polygon {
    fill: rgba(110, 184, 255, 0.34);
}

.triangle-extract-flight-outline {
    fill: none;
    stroke: #9ed0ff;
    stroke-width: 3;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.triangle-extract-modal {
    position: relative;
    z-index: 1;
    width: min(880px, calc(100vw - 28px));
    max-height: min(92vh, calc(var(--actual-vh, 100vh) - 20px));
    border: 1px solid transparent;
    border-radius: 22px;
    background: transparent;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    gap: 0;
    padding: 0;
    overflow: hidden;
    transform: none;
    opacity: 0;
    pointer-events: none;
    transition:
        opacity 0.24s ease,
        background 0.24s ease,
        border-color 0.24s ease,
        box-shadow 0.24s ease,
        padding 0.24s ease,
        gap 0.24s ease;
}

.triangle-extract-overlay.pre-open .triangle-extract-modal {
    transition: none;
}

.triangle-extract-overlay.settled .triangle-extract-modal {
    opacity: 1;
    pointer-events: auto;
    border-color: var(--border-color);
    background: var(--bg-primary);
    box-shadow: 0 34px 72px rgba(0, 0, 0, 0.44);
    gap: 20px;
    padding: clamp(18px, 2.8vw, 28px);
}

.triangle-extract-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: translateY(10px);
    transition: opacity 0.22s ease, transform 0.22s ease, max-height 0.22s ease;
}

.triangle-extract-overlay.settled .triangle-extract-header {
    opacity: 1;
    max-height: 140px;
    transform: translateY(0);
}

.triangle-extract-copy {
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.triangle-extract-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

.triangle-extract-action-btn {
    min-height: 38px;
    padding: 0 14px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    font-size: 0.82rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    cursor: pointer;
    flex-shrink: 0;
}

.triangle-extract-action-btn[aria-pressed="true"] {
    border-color: rgba(255, 204, 0, 0.65);
    background: rgba(255, 204, 0, 0.14);
}

.triangle-extract-action-btn:disabled {
    opacity: 0.58;
    cursor: default;
}

.triangle-extract-kicker {
    margin: 0;
    color: var(--accent-color);
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.triangle-extract-header h2 {
    margin: 0;
    font-size: clamp(1.35rem, 2.6vw, 1.9rem);
    line-height: 1.1;
    color: var(--text-primary);
}

.triangle-extract-subtitle {
    margin: 0;
    color: var(--text-muted);
    line-height: 1.4;
    font-size: 0.92rem;
}

.triangle-extract-close {
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    cursor: pointer;
    flex-shrink: 0;
}

.triangle-extract-close svg {
    width: 16px;
    height: 16px;
    display: block;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
}

.triangle-extract-stage {
    min-height: min(62vh, 620px);
    border-radius: 18px;
    background: transparent;
    border: 1px solid transparent;
    padding: 0;
    contain: paint;
    transition: background 0.24s ease, border-color 0.24s ease, padding 0.24s ease;
}

.triangle-extract-overlay.settled .triangle-extract-stage {
    background: var(--canvas-bg);
    border-color: var(--border-color);
    padding: clamp(12px, 2vw, 18px);
}

.triangle-extract-svg {
    width: 100%;
    height: 100%;
    display: block;
    overflow: visible;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.triangle-extract-polygon {
    fill: transparent; /* overridden by JS with the triangle's 3D color */
}

.triangle-extract-outline {
    fill: none;
    /* stroke set dynamically via JS to match the triangle's 3D color */
    stroke-width: 8;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.triangle-extract-right-angle {
    fill: none;
    /* stroke set dynamically via JS to match the triangle's color */
    stroke-width: 7;
    stroke-linejoin: round;
    stroke-linecap: round;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.triangle-extract-overlay.settled .triangle-extract-right-angle {
    opacity: 1;
}

.triangle-extract-angle-arc {
    fill: none;
    /* stroke set dynamically via JS from the angle's color */
    stroke-width: 7;
    stroke-linecap: round;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.triangle-extract-angle-text {
    fill: var(--extract-label-fill);
    font-size: 28px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.triangle-extract-overlay.settled .triangle-extract-angle-arc,
.triangle-extract-overlay.settled .triangle-extract-angle-text {
    opacity: 1;
}

.triangle-extract-label {
    fill: var(--extract-label-fill);
    font-size: 40px;
    font-weight: 700;
    text-anchor: middle;
    dominant-baseline: middle;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.triangle-extract-side-label {
    fill: var(--extract-label-fill);
    font-size: 30px;
    font-weight: 600;
    text-anchor: middle;
    dominant-baseline: middle;
    opacity: 0;
    transition: opacity 0.18s ease;
}

.triangle-extract-overlay.settled .triangle-extract-label,
.triangle-extract-overlay.settled .triangle-extract-side-label {
    opacity: 1;
}

.triangle-extract-footer {
    display: flex;
    justify-content: flex-start;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    transform: translateY(10px);
    transition: opacity 0.22s ease, transform 0.22s ease, max-height 0.22s ease;
}

.triangle-extract-overlay.settled .triangle-extract-footer {
    opacity: 1;
    max-height: 80px;
    transform: translateY(0);
}

.triangle-extract-note {
    margin: 0;
    color: var(--text-muted);
    font-size: 0.86rem;
    line-height: 1.45;
}

@media (hover: hover) {
    .triangle-extract-action-btn:hover,
    .triangle-extract-close:hover {
        filter: brightness(1.12);
    }
}

.help-content {
    width: min(520px, 100%);
    max-height: min(88vh, calc(var(--actual-vh, 100vh) - 40px));
    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);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.help-body {
    overflow-y: auto;
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    scrollbar-width: thin;
}

.help-body::-webkit-scrollbar {
    width: 4px;
}

.help-body::-webkit-scrollbar-track {
    background: transparent;
}

.help-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 2px;
}

@media (max-width: 768px) {
    .help-body::-webkit-scrollbar {
        display: none;
    }

    .help-body {
        scrollbar-width: none;
    }
}

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

.help-section h3 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}

.help-section + .help-section {
    border-top: 1px solid var(--border-color, #e0e0e0);
    margin-top: 14px;
    padding-top: 14px;
}

@media (max-width: 768px) {
    .triangle-extract-modal {
        width: min(100vw - 16px, 760px);
        max-height: min(94vh, calc(var(--actual-vh, 100vh) - 12px));
        border-radius: 18px;
        padding: 18px;
        gap: 14px;
    }

    .triangle-extract-header {
        flex-wrap: wrap;
    }

    .triangle-extract-header-actions {
        order: 3;
        width: 100%;
        margin-left: 0;
    }

    .triangle-extract-action-btn {
        flex: 1 1 0;
    }

    .triangle-extract-stage {
        min-height: min(58vh, 560px);
    }

    .triangle-extract-label {
        font-size: clamp(42px, 6.8vw, 56px);
    }

    .triangle-extract-side-label {
        font-size: clamp(32px, 5.1vw, 42px);
    }

    .triangle-extract-angle-text {
        font-size: clamp(34px, 5.4vw, 44px);
    }

    .triangle-extract-angle-arc {
        stroke-width: 9;
    }

    .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-goodie {
        width: min(58vw, 165px);
        margin-top: -2px;
    }

    .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 (orientation: landscape) and (max-height: 520px) {
    .title-screen {
        align-items: flex-start;
    }

    .title-content {
        box-sizing: border-box;
        min-height: 100%;
        justify-content: flex-start;
        gap: 12px;
        padding-top: max(12px, calc(var(--safe-area-top) + 8px));
        padding-bottom: calc(8px + var(--safe-area-bottom, 0px));
    }

    .title-logo {
        max-height: 17vh;
    }

    .title-goodie {
        width: min(28vw, 108px);
        margin-top: -2px;
        margin-bottom: -2px;
    }

    .title-tagline {
        font-size: 0.95rem;
    }

    .start-btn {
        min-width: 156px;
        padding: 8px 20px;
    }

    .copyright {
        position: static;
        left: auto;
        bottom: auto;
        transform: none;
        margin-top: auto;
        font-size: 0.72em;
        max-width: 100%;
        padding-bottom: calc(8px + var(--safe-area-bottom, 0px));
    }
}

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

.app-toast {
    position: fixed;
    left: 50%;
    bottom: max(18px, calc(var(--safe-area-bottom) + 18px));
    transform: translate(-50%, 14px);
    z-index: 3200;
    padding: 10px 14px;
    border: 1px solid rgba(0, 0, 0, 0.28);
    border-radius: 10px;
    background: rgba(185, 241, 138, 0.97);
    color: #11233a;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.01em;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.26);
}

.app-toast.show {
    opacity: 1;
    transform: translate(-50%, 0);
}

@media (prefers-reduced-motion: reduce) {
    .triangle-extract-overlay,
    .triangle-extract-modal,
    .object-extract {
        transition: none !important;
    }
}

@media (min-width: 1100px) and (min-height: 700px) {
    .title-content {
        gap: 32px;
        padding: 60px 48px;
    }

    .title-logo {
        max-width: min(60vw, 740px);
    }

    .title-goodie {
        width: min(40vw, 280px);
    }

    .title-mark {
        width: 108px;
        height: 108px;
        border-radius: 28px;
        font-size: 52px;
    }

    .title-tagline {
        font-size: 1.35rem;
    }

    .goodie-line-left,
    .goodie-line-right {
        stroke-width: 4.5;
    }

    .goodie-sq-left,
    .goodie-sq-right,
    .goodie-sq-top {
        stroke-width: 3.5;
    }

    .goodie-cube-back {
        stroke-width: 3;
    }

    .goodie-cube-connector {
        stroke-width: 3;
    }
}