/* TYNCAD Design Studio. Selectors repeat .tc-ds so the theme's button and field styles cannot leak in. */

html.tc-ds-open,
html.tc-ds-open body {
    overflow: hidden;
    overscroll-behavior: none;
}

.tc-ds {
    position: fixed;
    inset: 0;
    height: 100dvh;
    z-index: 2147483000;
    display: grid;
    grid-template-columns: 84px auto minmax(0, 1fr) 300px;
    grid-template-rows: 64px minmax(0, 1fr);
    grid-template-areas: "top top top top" "rail panel main props";
    background: #E8ECF4;
    color: #0A1128;
    font: 500 14px/1.45 'DM Sans', 'Segoe UI', sans-serif;
    animation: tc-ds-in 0.28s ease;
}

@keyframes tc-ds-in {
    from {
        opacity: 0;
        transform: scale(0.985);
    }
}

.tc-ds[hidden],
.tc-ds [hidden] {
    display: none !important;
}

.tc-ds * {
    box-sizing: border-box;
}

.tc-ds h2,
.tc-ds h3,
.tc-ds p,
.tc-ds figure,
.tc-ds ol,
.tc-ds ul {
    margin: 0;
    padding: 0;
    color: inherit;
    font-family: Outfit, 'DM Sans', sans-serif;
}

.tc-ds p,
.tc-ds ul {
    font-family: 'DM Sans', 'Segoe UI', sans-serif;
}

.tc-ds h2 {
    font-size: 18px;
    font-weight: 700;
}

.tc-ds h3 {
    margin: 8px 0 0;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #5B6B88;
}

.tc-ds.tc-ds button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: auto;
    min-height: 40px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid #DDE4F0;
    border-radius: 10px;
    background: #fff;
    color: #0A1128;
    font: 600 13px/1.2 'DM Sans', 'Segoe UI', sans-serif;
    letter-spacing: normal;
    text-transform: none;
    white-space: nowrap;
    box-shadow: none;
    cursor: pointer;
    transition: border-color 0.18s, background-color 0.18s, transform 0.18s;
}

.tc-ds.tc-ds button:hover {
    border-color: #9DBBF0;
    background: #F0F6FF;
    color: #0A1128;
}

.tc-ds.tc-ds button:focus-visible,
.tc-ds input:focus-visible,
.tc-ds select:focus-visible {
    outline: 3px solid #FF7F00;
    outline-offset: 2px;
}

.tc-ds.tc-ds button[aria-pressed="true"] {
    border-color: #004AAD;
    background: #E7F0FF;
    color: #004AAD;
}

.tc-ds.tc-ds button:disabled {
    opacity: 0.35;
    cursor: default;
}

.tc-ds svg {
    flex: 0 0 auto;
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tc-ds input[type="text"],
.tc-ds input[type="number"],
.tc-ds select {
    width: 100%;
    min-height: 40px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid #DDE4F0;
    border-radius: 10px;
    background: #F9FBFF;
    color: #0A1128;
    font: 500 16px 'DM Sans', 'Segoe UI', sans-serif;
}

.tc-ds input[type="range"] {
    width: 100%;
    accent-color: #004AAD;
}

/* ---------- Top bar ---------- */

.tc-ds-top {
    grid-area: top;
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0 14px;
    background: linear-gradient(135deg, #004AAD, #060C1D);
    color: #fff;
}

.tc-ds-title {
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin-right: auto;
}

.tc-ds-title strong {
    overflow: hidden;
    font: 700 16px Outfit, sans-serif;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tc-ds-title small {
    overflow: hidden;
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.tc-ds-top-tools {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ---------- Page size ---------- */

.tc-ds.tc-ds .tc-ds-top button.tc-ds-size {
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: 100%;
    min-height: 0;
    padding: 2px 0;
    border: 0;
    background: none;
}

.tc-ds-size small {
    min-width: 0;
}

.tc-ds-size span {
    flex: none;
    padding: 2px 9px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.tc-ds-sizer {
    position: absolute;
    top: 62px;
    left: 12px;
    z-index: 20;
    display: flex;
    flex-direction: column;
    width: min(360px, calc(100% - 24px));
    max-height: calc(100% - 80px);
    overflow-y: auto;
    border-radius: 16px;
    background: #fff;
    color: #0A1128;
    box-shadow: 0 30px 60px -20px rgba(6, 12, 29, 0.5);
}

.tc-ds-sizer .tc-ds-body {
    flex: none;
    overflow: visible;
}

.tc-ds-sizer .tc-size {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
}

.tc-ds-sizer .tc-size-field {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 13px;
    font-weight: 700;
}

.tc-ds-sizer .tc-size-field[hidden] {
    display: none;
}

.tc-ds-sizer .tc-size .tc-size-hint {
    grid-column: 1 / -1;
}

.tc-ds-sizer p {
    margin: 10px 0 0;
    font-size: 13px;
}

.tc-ds-sizer .tc-size p {
    margin: 0;
}

.tc-ds-sizer .tc-size-hint {
    color: #6B7280;
}

.tc-ds-sizer .tc-size-problem {
    color: #B91C1C;
    font-weight: 700;
}

.tc-ds-sizer .tc-size-price {
    font-weight: 800;
}

.tc-ds-sizer .tc-size-choices {
    display: grid;
    gap: 6px;
    margin-top: 12px;
}

.tc-ds.tc-ds .tc-ds-sizer button.tc-size-choice[aria-pressed="true"] {
    border-color: #004AAD;
    background: #F0F6FF;
}

.tc-ds.tc-ds .tc-ds-sizer button.tc-ds-primary {
    width: 100%;
    margin-top: 12px;
}

.tc-ds.tc-ds .tc-ds-top button {
    border-color: rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.tc-ds.tc-ds .tc-ds-top button:hover {
    background: rgba(255, 255, 255, 0.18);
}

.tc-ds.tc-ds .tc-ds-top button[aria-pressed="true"] {
    background: #fff;
    color: #004AAD;
}

.tc-ds.tc-ds .tc-ds-top button.tc-ds-done {
    padding: 10px 24px;
    border-color: #FF7F00;
    border-radius: 999px;
    background: #FF7F00;
    color: #1A0E00;
    font-size: 15px;
}

.tc-ds-seg {
    display: inline-flex;
    gap: 4px;
}

/* ---------- Tool rail and panels ---------- */

.tc-ds-rail {
    grid-area: rail;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 10px 6px;
    overflow-y: auto;
    background: #0A1128;
}

.tc-ds.tc-ds .tc-ds-rail button {
    flex-direction: column;
    gap: 5px;
    min-height: 66px;
    padding: 8px 2px;
    border-color: transparent;
    background: transparent;
    color: #B9C5DD;
    font-size: 11px;
}

.tc-ds.tc-ds .tc-ds-rail button:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.tc-ds.tc-ds .tc-ds-rail button[aria-pressed="true"] {
    background: #fff;
    color: #004AAD;
}

.tc-ds-panel,
.tc-ds-props {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
}

.tc-ds-panel {
    grid-area: panel;
    width: 0;
    overflow: hidden;
    border-right: 1px solid #DDE4F0;
    visibility: hidden;
    transition: width 0.24s ease, visibility 0.24s;
}

.tc-ds.has-panel .tc-ds-panel {
    width: 316px;
    visibility: visible;
}

.tc-ds-props {
    grid-area: props;
    border-left: 1px solid #DDE4F0;
}

.tc-ds-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px 6px;
}

.tc-ds.tc-ds .tc-ds-head button {
    min-height: 34px;
    padding: 6px;
    border-color: transparent;
}

.tc-ds.tc-ds .tc-ds-props .tc-ds-head button {
    display: none;
}

.tc-ds-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 12px;
    min-height: 0;
    padding: 8px 16px 24px;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.tc-ds-panel .tc-ds-body {
    width: 316px;
}

.tc-ds-body > * {
    flex: 0 0 auto;
}

.tc-ds-hint {
    color: #5B6B88;
    font-size: 13px;
}

.tc-ds-keys {
    display: flex;
    flex-direction: column;
    gap: 8px;
    color: #5B6B88;
    font-size: 13px;
    list-style-position: inside;
}

.tc-ds.tc-ds button.tc-ds-primary {
    border-color: #004AAD;
    background: #004AAD;
    color: #fff;
}

.tc-ds.tc-ds button.tc-ds-primary:hover {
    background: #003B8A;
    color: #fff;
}

.tc-ds.tc-ds button.is-quiet {
    background: transparent;
}

.tc-ds-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.tc-ds-grid > p {
    grid-column: 1 / -1;
}

.tc-ds.tc-ds button.tc-ds-thumb {
    flex-direction: column;
    justify-content: flex-start;
    padding: 6px;
}

.tc-ds.tc-ds button.tc-ds-thumb:hover {
    transform: translateY(-3px);
}

.tc-ds-thumb i {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 1;
    overflow: hidden;
    border-radius: 8px;
    background: #EEF2FA;
}

.tc-ds-thumb canvas,
.tc-ds-thumb img {
    display: block;
    max-width: 92%;
    max-height: 92%;
    width: auto;
    height: auto;
    box-shadow: 0 6px 16px -8px rgba(10, 17, 40, 0.5);
}

.tc-ds-thumb span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.tc-ds-themes,
.tc-ds-colours > div:not(.tc-ds-custom) {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tc-ds.tc-ds button.tc-ds-swatch {
    width: 32px;
    min-height: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid #CBD5E8;
    border-radius: 50%;
}

.tc-ds.tc-ds button.tc-ds-swatch:hover {
    transform: scale(1.12);
}

.tc-ds.tc-ds button.tc-ds-swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #004AAD;
}

.tc-ds.tc-ds button.tc-ds-swatch.is-none {
    background: linear-gradient(135deg, #fff 46%, #DC2626 46% 54%, #fff 54%);
}

.tc-ds-colours {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tc-ds-custom {
    display: flex;
    gap: 8px;
}

.tc-ds .tc-ds-custom input[type="color"] {
    flex: 0 0 48px;
    height: 40px;
    padding: 3px;
    border: 1px solid #DDE4F0;
    border-radius: 10px;
    background: #fff;
}

.tc-ds-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 700;
    color: #39476B;
}

.tc-ds-slider {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin: 0;
}

.tc-ds-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tc-ds-row > button {
    flex: 1 1 0;
}

.tc-ds-row.is-size {
    align-items: center;
    flex-wrap: nowrap;
}

.tc-ds-row.is-size > button {
    flex: 0 0 44px;
}

.tc-ds-unit {
    color: #5B6B88;
}

.tc-ds-row.is-thirds,
.tc-ds-row.is-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tc-ds-row.is-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.tc-ds.tc-ds button.tc-ds-toggle {
    padding: 8px 6px;
    font-size: 14px;
}

.tc-ds.tc-ds button.is-word {
    font-size: 12px;
    white-space: normal;
}

.tc-ds.tc-ds button.is-bold {
    font-weight: 800;
}

.tc-ds.tc-ds button.is-italic {
    font-style: italic;
}

.tc-ds.tc-ds button.is-underline {
    text-decoration: underline;
}

.tc-ds.tc-ds button.is-danger {
    color: #B91C1C;
}

.tc-ds.tc-ds button.tc-ds-add {
    justify-content: flex-start;
    padding: 14px 16px;
    font-size: 14px;
}

.tc-ds.tc-ds button.is-h1 {
    font: 800 24px Outfit, sans-serif;
}

.tc-ds.tc-ds button.is-h2 {
    font-size: 18px;
}

.tc-ds-fonts {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.tc-ds.tc-ds .tc-ds-fonts button {
    min-height: 52px;
    font-size: 16px;
    overflow: hidden;
}

.tc-ds-tiles {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.tc-ds.tc-ds .tc-ds-tiles button {
    flex-direction: column;
    min-height: 66px;
    padding: 6px 2px;
    font-size: 11px;
}

.tc-ds-tiles:not(.is-icons) button::before {
    content: "";
    width: 28px;
    height: 28px;
    background: #004AAD;
}

.tc-ds .tc-ds-tiles .is-rounded::before { height: 18px; margin: 5px 0; border-radius: 6px; }
.tc-ds .tc-ds-tiles .is-circle::before { border-radius: 50%; }
.tc-ds .tc-ds-tiles .is-triangle::before { clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.tc-ds .tc-ds-tiles .is-hexagon::before { clip-path: polygon(50% 0, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%); }
.tc-ds .tc-ds-tiles .is-star::before { clip-path: polygon(50% 0, 61% 36%, 98% 35%, 68% 57%, 79% 92%, 50% 70%, 21% 92%, 32% 57%, 2% 35%, 39% 36%); }
.tc-ds .tc-ds-tiles .is-burst::before { clip-path: polygon(50% 0, 61% 18%, 82% 12%, 82% 33%, 100% 50%, 82% 66%, 88% 88%, 66% 82%, 50% 100%, 34% 82%, 12% 88%, 18% 66%, 0 50%, 18% 33%, 15% 15%, 38% 18%); }
.tc-ds .tc-ds-tiles .is-line::before { height: 4px; margin: 12px 0; }

.tc-ds.tc-ds .tc-ds-tiles.is-icons button {
    min-height: 52px;
}

.tc-ds .tc-ds-tiles.is-icons svg {
    width: 26px;
    height: 26px;
}

.tc-ds-admin {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
    padding: 14px;
    border: 1px dashed #FF7F00;
    border-radius: 12px;
    background: #FFF8F0;
}

.tc-ds-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
}

.tc-ds-layers {
    display: flex;
    flex-direction: column;
    gap: 6px;
    list-style: none;
}

.tc-ds-layers li {
    display: flex;
    gap: 4px;
}

.tc-ds.tc-ds .tc-ds-layers button {
    flex: 0 0 38px;
    padding: 6px;
}

.tc-ds.tc-ds .tc-ds-layers button.tc-ds-layer {
    flex: 1;
    justify-content: flex-start;
    min-width: 0;
    overflow: hidden;
}

.tc-ds.tc-ds .tc-ds-layers .is-active .tc-ds-layer {
    border-color: #004AAD;
    background: #E7F0FF;
}

/* ---------- Work area ---------- */

.tc-ds-main {
    grid-area: main;
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
}

.tc-ds-stage {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: none;
}

.tc-ds-empty {
    position: absolute;
    left: 50%;
    top: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 18px 22px;
    border: 1px solid #DDE4F0;
    border-radius: 16px;
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 20px 40px -24px rgba(10, 17, 40, 0.45);
    transform: translate(-50%, -50%);
    text-align: center;
}

.tc-ds-empty p {
    font-weight: 700;
}

.tc-ds-zoom {
    position: absolute;
    right: 14px;
    bottom: 14px;
    display: flex;
    gap: 4px;
    padding: 4px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 12px 28px -18px rgba(10, 17, 40, 0.5);
}

.tc-ds.tc-ds .tc-ds-zoom button {
    min-width: 40px;
    border-color: transparent;
}

.tc-ds-quick {
    display: none;
}

.tc-ds-toast {
    position: absolute;
    left: 50%;
    top: 14px;
    max-width: min(440px, 92%);
    padding: 10px 18px;
    border-radius: 999px;
    background: #0A1128;
    color: #fff;
    opacity: 0;
    transform: translate(-50%, -12px);
    pointer-events: none;
    transition: opacity 0.25s, transform 0.25s;
    text-align: center;
}

.tc-ds .tc-ds-toast {
    color: #fff;
}

.tc-ds-toast.is-on {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* ---------- Dialogs ---------- */

.tc-ds-modal {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(6, 12, 29, 0.72);
    animation: tc-ds-in 0.2s ease;
}

.tc-ds-modal > div {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: min(720px, 100%);
    max-height: 100%;
    padding: 24px;
    border-radius: 20px;
    background: #fff;
}

.tc-ds-modal-body {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 18px;
    min-height: 0;
    overflow-y: auto;
}

.tc-ds .tc-ds-modal-body ul {
    width: 100%;
    padding-left: 20px;
}

.tc-ds-modal-body li {
    margin: 6px 0;
}

.tc-ds-modal-body figure {
    flex: 1 1 240px;
    text-align: center;
}

.tc-ds-modal-body canvas {
    max-width: 100%;
    max-height: 56vh;
    width: auto;
    height: auto;
    box-shadow: 0 18px 40px -20px rgba(10, 17, 40, 0.55);
}

.tc-ds-modal-body figcaption {
    margin-top: 8px;
    color: #5B6B88;
}

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

/* ---------- Smaller screens ---------- */

@media (max-width: 1180px) {
    .tc-ds {
        grid-template-columns: 76px auto minmax(0, 1fr) 260px;
    }

    .tc-ds.has-panel .tc-ds-panel,
    .tc-ds-panel .tc-ds-body {
        width: 270px;
    }
}

@media (max-width: 900px) {
    .tc-ds {
        display: flex;
        flex-direction: column;
    }

    .tc-ds-top {
        flex: 0 0 auto;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 10px;
    }

    .tc-ds-top-tools {
        order: 3;
        width: 100%;
        overflow-x: auto;
    }

    .tc-ds-title {
        flex: 1;
    }

    .tc-ds.tc-ds .tc-ds-top button.tc-ds-done {
        padding: 9px 18px;
    }

    .tc-ds .tc-ds-preview span,
    .tc-ds .tc-ds-guides {
        display: none;
    }

    .tc-ds.tc-ds .tc-ds-top .tc-ds-guides {
        display: none;
    }

    .tc-ds-main {
        flex: 1 1 auto;
    }

    .tc-ds-rail {
        order: 5;
        flex: 0 0 auto;
        flex-direction: row;
        justify-content: space-between;
        padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
        overflow-x: auto;
    }

    .tc-ds.tc-ds .tc-ds-rail button {
        flex: 1 0 58px;
        min-height: 54px;
        font-size: 10px;
    }

    /* Panels and properties become sheets above the tool bar, leaving the design in view. */
    .tc-ds-panel,
    .tc-ds-props {
        order: 4;
        flex: 0 0 auto;
        width: 100%;
        height: 46%;
        border: 0;
        border-radius: 18px 18px 0 0;
        box-shadow: 0 -18px 40px -26px rgba(10, 17, 40, 0.6);
    }

    .tc-ds-panel,
    .tc-ds.has-panel .tc-ds-panel {
        width: 100%;
        transition: none;
    }

    .tc-ds-panel,
    .tc-ds-props {
        display: none;
    }

    .tc-ds.has-panel .tc-ds-panel,
    .tc-ds.has-props .tc-ds-props {
        display: flex;
        animation: tc-ds-sheet 0.26s ease;
    }

    .tc-ds .tc-ds-panel .tc-ds-body,
    .tc-ds.has-panel .tc-ds-panel .tc-ds-body {
        width: 100%;
    }

    .tc-ds.tc-ds .tc-ds-props .tc-ds-head button {
        display: inline-flex;
    }

    .tc-ds-grid {
        grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    }

    .tc-ds-tiles {
        grid-template-columns: repeat(auto-fill, minmax(68px, 1fr));
    }

    .tc-ds.has-selection:not(.has-panel):not(.has-props) .tc-ds-quick {
        position: absolute;
        left: 50%;
        bottom: 10px;
        display: flex;
        gap: 4px;
        padding: 4px;
        border-radius: 14px;
        background: #fff;
        box-shadow: 0 12px 28px -14px rgba(10, 17, 40, 0.55);
        transform: translateX(-50%);
    }

    .tc-ds.has-selection .tc-ds-zoom {
        display: none;
    }
}

@keyframes tc-ds-sheet {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
}

@media (prefers-reduced-motion: reduce) {
    .tc-ds,
    .tc-ds * {
        animation: none !important;
        transition: none !important;
    }
}
