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

body {
    font-family: Arial, sans-serif;
    background: #fff;
}

.container {
    padding: 0;
}

.controls {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
    align-items: center;
    z-index: 100;
}

#loadImage {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
}

#downloadImages {
    padding: 10px 20px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    transition: background 0.2s;
}

#downloadImages:hover:not(:disabled) {
    background: #218838;
}

#downloadImages:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

#layoutMode,
#clipType {
    padding: 10px 15px;
    font-size: 16px;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    background: white;
    color: #333;
    outline: none;
}

#tileControls {
    display: flex;
    gap: 5px;
}

.tile-btn {
    padding: 8px 12px;
    background: white;
    color: #333;
    border: 1px solid #ccc;
    border-radius: 5px;
    cursor: pointer;
    font-size: 14px;
}

.tile-btn:hover:not(:disabled) {
    background: #f0f0f0;
}

.tile-btn:disabled {
    background: #e0e0e0;
    color: #999;
    cursor: not-allowed;
}

#imageContainer {
    position: relative;
    display: inline-block;
}

#image {
    display: block;
    max-width: 100vw;
    max-height: 100vh;
    width: auto;
    height: auto;
    object-fit: contain;
}

#regionsContainer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.region {
    position: absolute;
    box-sizing: border-box;
    pointer-events: auto;
    cursor: move;
    /* Borders are controlled by JavaScript based on layout mode */
}

.alignment-box {
    position: absolute;
    border: 1px dashed rgba(255, 255, 255, 0.5);
    box-sizing: border-box;
    pointer-events: none;
}

.content-box {
    position: absolute;
    border: 1px solid white;
    box-sizing: border-box;
    pointer-events: auto;
    cursor: move;
}

.region-btn {
    width: 25px;
    height: 25px;
    padding: 0;
    background: white;
    color: #333;
    border: 1px solid #333;
    border-radius: 3px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    position: absolute;
    display: none;
}

.region-btn:hover:not(:disabled) {
    background: #f0f0f0;
}

.region-overlay-btn {
    z-index: 10;
}

#removeRegion:disabled,
#addRegion:disabled {
    background: #ccc;
    color: #999;
    cursor: not-allowed;
}

#resizeHandle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border: 1px solid #000;
    cursor: nwse-resize;
    display: none;
    z-index: 10;
}

.resize-handle {
    position: absolute;
    width: 8px;
    height: 8px;
    background: white;
    border: 1px solid #000;
    display: none;
    z-index: 10;
}

#resizeHandleTopLeft {
    cursor: nwse-resize;
}

#resizeHandleTopRight {
    cursor: nesw-resize;
}

#resizeHandleBottomLeft {
    cursor: nesw-resize;
}

#infoPanel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 40px 50px;
    max-width: 700px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    z-index: 50;
}

#infoPanel h1 {
    font-size: 36px;
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

#infoPanel .subtitle {
    font-size: 18px;
    color: #666;
    text-align: center;
    margin-bottom: 30px;
}

#infoPanel .info-section {
    margin-bottom: 25px;
}

#infoPanel .follow-section {
    background: #f0f8ff;
    padding: 15px 20px;
    border-radius: 8px;
    border: 2px solid #007bff;
    text-align: center;
}

#infoPanel .follow-section p {
    font-size: 16px;
    color: #333;
    font-weight: 500;
    margin: 0;
}

#infoPanel .follow-section a {
    color: #007bff;
    text-decoration: none;
    font-weight: 700;
}

#infoPanel .follow-section a:hover {
    text-decoration: underline;
}

#infoPanel h2 {
    font-size: 20px;
    color: #007bff;
    margin-bottom: 10px;
}

#infoPanel .mode-info {
    margin-bottom: 15px;
}

#infoPanel .mode-info strong {
    color: #333;
    font-size: 16px;
}

#infoPanel .mode-info p {
    color: #666;
    margin-top: 5px;
    line-height: 1.5;
}

#infoPanel p {
    color: #666;
    line-height: 1.6;
}

#infoPanel ul {
    list-style: none;
    padding-left: 0;
}

#infoPanel ul li {
    color: #666;
    padding: 5px 0;
    padding-left: 20px;
    position: relative;
}

#infoPanel ul li:before {
    content: "•";
    position: absolute;
    left: 0;
    color: #007bff;
    font-weight: bold;
}

#infoPanel .disclaimer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

#infoPanel .disclaimer p {
    font-size: 14px;
    color: #888;
    margin-bottom: 10px;
}

#infoPanel .disclaimer a {
    color: #007bff;
    text-decoration: none;
    font-weight: 500;
}

#infoPanel .disclaimer a:hover {
    text-decoration: underline;
}

#infoPanel .follow-section .github-link {
    margin-top: 10px;
    margin-bottom: 0;
    font-size: 15px;
    color: #333;
}

#infoPanel .follow-section .github-link a {
    color: #007bff;
    font-weight: 600;
}
