* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: Arial, Helvetica, sans-serif;
    background: #eceff2;
    color: #222;
}

button,
input,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

#app {
    display: grid;
    grid-template-columns: 150px minmax(500px, 1fr) 280px;
    min-height: 100vh;
}

#templatesPanel,
#propertiesPanel {
    background: #fff;
    padding: 16px;
}

#templatesPanel {
    border-right: 1px solid #d7dce0;
}

#propertiesPanel {
    border-left: 1px solid #d7dce0;
}

.panel-title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 14px;
}

#templateList {
    display: grid;
    gap: 12px;
}

.template-button {
    width: 100%;
    padding: 7px;
    border: 2px solid transparent;
    border-radius: 6px;
    background: #f4f6f8;
}

.template-button.active {
    border-color: #222;
}

.template-button object {
    display: block;
    width: 100%;
    height: 125px;
    margin-bottom: 5px;
    background: white;
}

.template-button span {
    font-size: 12px;
}

#workspace {
    min-width: 0;
}

#toolbar {
    height: 60px;
    display: flex;
    align-items: center;
    gap: 18px;
    padding: 0 20px;
    background: #fff;
    border-bottom: 1px solid #d7dce0;
    position: sticky;
    top: 0;
    z-index: 10;
}

#printButton,
#applyText {
    border: 0;
    border-radius: 5px;
    padding: 10px 14px;
    background: #222;
    color: white;
}

#status {
    font-size: 13px;
    color: #666;
}

#canvasArea {
    min-height: calc(100vh - 60px);
    padding: 32px;
    overflow: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

#page {
    background: white;
    box-shadow: 0 4px 22px rgba(0, 0, 0, .16);
    line-height: 0;
}

#svgCanvas,
#svgCanvas > svg {
    display: block;
}

#svgCanvas > svg {
    width: min(612px, calc(100vw - 500px));
    height: auto;
    max-width: 100%;
}

/* These do not modify the stored template; they exist only while editing. */
#svgCanvas .folium-editable {
    cursor: pointer;
}

#svgCanvas .folium-selected {
    outline: 2px dashed #111;
    outline-offset: 2px;
}

.property-state label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
}

#textValue {
    display: block;
    width: 100%;
    resize: vertical;
    padding: 9px;
    margin-bottom: 10px;
}

#imageFile {
    width: 100%;
}

.hint,
#nothingSelected {
    font-size: 13px;
    line-height: 1.5;
    color: #666;
}

code {
    font-family: Menlo, Consolas, monospace;
    font-size: 12px;
}

@media (max-width: 900px) {
    #app {
        grid-template-columns: 110px 1fr;
    }

    #propertiesPanel {
        grid-column: 1 / -1;
        border-left: 0;
        border-top: 1px solid #d7dce0;
    }

    #svgCanvas > svg {
        width: min(612px, calc(100vw - 180px));
    }
}

@page {
    size: Letter portrait;
    margin: 0;
}

@media print {
    /*
     * The browser editor visually gives the sheet 32px of breathing room.
     * Use the print-equivalent (~1/3 inch) above the flyer as well, while
     * shrinking proportionally so nothing is pushed off the bottom edge.
     */
    :root {
        --folium-print-top-margin: 0.63in;
        --folium-print-height: 10.67in;
        --folium-print-width: 8.245in;
    }

    html,
    body {
        width: 8.5in !important;
        height: 11in !important;
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        overflow: hidden !important;
    }

    .no-print,
    #templatesPanel,
    #propertiesPanel,
    #toolbar {
        display: none !important;
    }

    #app,
    #workspace,
    #canvasArea,
    #page,
    #svgCanvas {
        display: block !important;
        min-width: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        box-shadow: none !important;
        background: #fff !important;
        overflow: visible !important;
    }

    #app,
    #workspace,
    #canvasArea {
        width: 8.5in !important;
        height: 11in !important;
    }

    #page,
    #svgCanvas {
        width: var(--folium-print-width) !important;
        height: var(--folium-print-height) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    #page {
        padding-top: var(--folium-print-top-margin) !important;
        height: 11in !important;
    }

    #svgCanvas > svg {
        display: block !important;
        width: var(--folium-print-width) !important;
        height: var(--folium-print-height) !important;
        max-width: none !important;
        max-height: none !important;
        margin: 0 !important;
        padding: 0 !important;
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    #svgCanvas .folium-selected {
        outline: none !important;
    }
}
