input[type=number] {
    font-size: 0.8rem;
    width: 52px;
    padding: 2px 4px;
}

#layout-label {
    margin-left: 10px;
    font-size: 0.8rem;
    color: #888;
}

#spacing-row {
    margin-top: 14px;
}

.ar-btn-group {
    display: inline-flex;
    border: 1px solid #bbb;
    border-radius: 4px;
    overflow: hidden;
    vertical-align: middle;
}

.ar-btn {
    border: none;
    border-right: 1px solid #bbb;
    border-radius: 0;
    padding: 4px 10px;
    font-size: 0.72rem;
    background: transparent;
    color: inherit;
    cursor: pointer;
}

.ar-btn:last-child {
    border-right: none;
}

.ar-btn:hover:not(.active) {
    background: rgba(0,0,0,0.06);
}

.ar-btn.active {
    background: #333;
    color: #fff;
}

#canvas-wrapper {
    display: block;
    max-width: 100%;
    margin-top: 16px;
}

#preview-canvas {
    border: 1px solid #ddd;
}

#result-overlay .nav {
    display: flex;
    align-items: center;
    gap: 12px;
}

#result-overlay .nav .nav-action-btn {
    color: #fff;
    border: 1px solid rgba(255,255,255,0.4);
    background: transparent;
    border-radius: 4px;
    padding: 6px 14px;
    font-size: 0.8rem;
    font-family: inherit;
    cursor: pointer;
    text-decoration: none;
    display: inline-block;
}

#result-overlay .share-link-row {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 16px;
    background: #1a1a1a;
    border-top: 1px solid #333;
    color: #fff;
    font-size: 13px;
}

#result-overlay .share-link-row a {
    color: #4af;
    word-break: break-all;
    font-size: 0.75rem;
}

#result-overlay .img-area {
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222;
    padding: 12px;
}

#result-overlay .img-area img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
}

/* Layout picker modal */
#layout-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(0, 0, 0, 0.5);
    align-items: center;
    justify-content: center;
}

#layout-modal.open {
    display: flex;
}

#modal-content {
    background: #fff;
    border-radius: 12px;
    padding: 24px;
    max-width: 560px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

#modal-content h2 {
    margin: 0 0 20px;
    font-size: 1.2rem;
    font-weight: 600;
}

#layout-cards {
    display: flex;
    flex-wrap: wrap;
    gap: 14px;
}

.layout-subheader {
    flex: 0 0 100%;
    font-size: 0.7rem;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: #999;
    margin-top: 8px;
}

.layout-subheader:first-child {
    margin-top: 0;
}

.layout-card {
    flex: 1 1 140px;
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 16px 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    transition: border-color 0.15s;
    user-select: none;
}

.layout-card:hover {
    border-color: #555;
}

.layout-card svg {
    width: 52px;
    height: auto;
    display: block;
}

.layout-card .card-label {
    font-size: 0.72rem;
    text-align: center;
    line-height: 1.5;
    color: #444;
}

.layout-card .card-count {
    font-weight: 600;
}

@media (prefers-color-scheme: dark) {
    dt {
        font-weight: 600;
    }

    #preview-canvas {
        border-color: #444;
    }

    #modal-content {
        background: #252525;
        color: #e0e0e0;
    }

    .layout-card {
        border-color: #555;
    }

    .layout-card:hover {
        border-color: #bbb;
    }

    .layout-card .card-label {
        color: #bbb;
    }

    .layout-card svg .cell-shape {
        fill: #666;
    }

    .layout-subheader {
        color: #666;
    }

    #layout-label {
        color: #888;
    }

    .ar-btn-group {
        border-color: #555;
    }

    .ar-btn {
        border-right-color: #555;
    }

    .ar-btn:hover:not(.active) {
        background: rgba(255,255,255,0.08);
    }

    .ar-btn.active {
        background: #ddd;
        color: #111;
    }
}
