* {
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Comic Sans MS', Tahoma, Verdana, sans-serif;
    background: linear-gradient(135deg, #fdecf2 0%, #e9f2ff 50%, #e9fbe9 100%);
    margin: 0;
    padding: 20px;
    min-height: 100vh;
    color: #2b2b2b;
}

/* HEADER */
.app-header {
    max-width: 1200px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    padding: 14px 20px;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.10);
    border: 3px solid #fff;
    outline: 1px solid #ffd7ea;
}

.header-logos-container {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    width: 100%;
    gap: 12px;
}

.header-logo {
    max-height: 80px;
    height: auto;
    max-width: 180px;
    object-fit: contain;
    transition: transform 0.3s ease, filter 0.3s ease;
    user-select: none;
}

.header-logo:hover {
    transform: scale(1.05);
}

@media (max-width: 600px) {
    .header-logo {
        max-height: 60px;
        max-width: 160px;
    }

    .tagline {
        display: none;
    }

    .header-logos-container {
        grid-template-columns: auto 1fr auto;
        gap: 8px;
    }
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    justify-self: center;
}

.logo {
    font-size: 34px;
    background: #fff3f8;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 16px;
    box-shadow: inset 0 0 0 3px #fff, 0 4px 10px rgba(255, 100, 170, 0.25);
}

.app-header h1 {
    margin: 0;
    font-size: 24px;
    letter-spacing: 0.5px;
}

.grad {
    background: linear-gradient(90deg, #ff5fa2, #7a00ff);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
}

.tagline {
    margin: 2px 0 0;
    font-size: 12.5px;
    color: #888;
}

.language-selector select {
    padding: 8px 12px;
    border: 2px solid #0082ff;
    border-radius: 10px;
    background: #fff;
    color: #0082ff;
    font-weight: bold;
    cursor: pointer;
    font-size: 14px;
}

/* LAYOUT */
.layout {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 16px;
    align-items: stretch;
}

.card {
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.10);
    border: 1px solid #e8e8f0;
}

.controls {
    width: 350px;
    flex-shrink: 0;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-self: flex-start;
    position: sticky;
    top: 16px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.preview {
    flex: 1;
    padding: 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 520px;
}

/* LABELS */
label {
    font-weight: 600;
    color: #0072df;
    margin-bottom: 4px;
    display: block;
    font-size: 12.5px;
}

select, input[type="text"], input[type="password"], textarea {
    width: 100%;
    padding: 8px 10px;
    font-size: 13px;
    border: 1.5px solid #d5d9e2;
    border-radius: 10px;
    box-sizing: border-box;
    font-family: inherit;
    background: #fbfcff;
}

select:focus, input:focus, textarea:focus {
    outline: none;
    border-color: #0082ff;
    box-shadow: 0 0 0 3px rgba(0, 130, 255, 0.15);
}

textarea {
    resize: vertical;
    font-size: 12px;
    line-height: 1.5;
    color: #444;
}

/* API KEY */
.api-key-container {
    background: linear-gradient(180deg, #eef7ff, #eaf3fd);
    padding: 10px;
    border-radius: 12px;
    border: 1px solid #cce5ff;
}

.api-row {
    display: flex;
    gap: 6px;
    margin-top: 4px;
}

#getApiKeyBtn {
    background: #28a745;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 13px;
    white-space: nowrap;
    cursor: pointer;
    font-weight: bold;
}

#getApiKeyBtn:hover { filter: brightness(1.1); }

/* CONTROLS */
.control-block { display: flex; flex-direction: column; }

.status-msg {
    font-size: 12px;
    font-weight: bold;
    color: #28a745;
    margin-top: 5px;
}

/* BUTTONS */
button { cursor: pointer; transition: filter 0.2s, transform 0.15s; }
button:hover { filter: brightness(1.07); }
button:active { transform: scale(0.98); }
button:disabled { opacity: 0.6; cursor: not-allowed; }

.action-btn {
    color: #fff;
    padding: 12px;
    font-size: 15px;
    width: 100%;
    border: none;
    border-radius: 12px;
    font-weight: bold;
    letter-spacing: 0.4px;
}

.main-btn {
    background: linear-gradient(90deg, #ff5fa2, #ff8a3d, #a855f7);
    background-size: 200% 100%;
    box-shadow: 0 6px 16px rgba(255, 95, 162, 0.4);
}

.trash-btn {
    background: #dc3545;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 11px;
}

.secondary-btn {
    background: #7c3aed;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 600;
}

.secondary-btn.ghost {
    background: #ffffff;
    color: #7c3aed;
    border: 2px solid #d8c8ff;
}

/* DROP ZONE */
.drop-zone {
    border: 2.5px dashed #0082ff;
    background: #f0f7ff;
    padding: 16px 10px;
    text-align: center;
    border-radius: 14px;
    cursor: pointer;
    transition: 0.25s;
    color: #0072df;
    font-size: 13px;
    font-weight: 600;
}
.drop-zone:hover { background: #e1f0ff; border-color: #0058fe; }
.drop-zone.dragover { background: #0082ff; color: #fff; }

/* SECTION DIVIDER */
.section-divider {
    border-top: 2px dashed #ffc2dd;
    padding-top: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #ff5fa2;
    text-align: center;
}

.prompt-details summary {
    cursor: pointer;
    font-size: 12.5px;
    font-weight: 600;
    color: #7a5cff;
    padding: 6px 0;
}

.prompt-actions {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.mini-btn {
    background: #fff;
    color: #7a5cff;
    border: 2px solid #d8c8ff;
    border-radius: 10px;
    padding: 6px 12px;
    font-size: 12.5px;
    font-weight: 600;
    flex: 1;
    text-align: center;
}
.mini-btn:hover { background: #f3edff; border-color: #7a5cff; }

/* IMG CONTAINER */
.img-container {
    border: 6px solid #ffffff;
    border-radius: 18px;
    overflow: auto;
    background: #ffffff;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14), inset 0 0 0 2px #ffd7ea;
    width: 100%;
    max-width: 640px;
    height: 640px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-top: 6px;
    touch-action: none;
}

#resultCanvas, #img-preview {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transform-origin: center center;
    user-select: none;
    -webkit-user-drag: none;
}

#img-preview { width: 100%; height: 100%; object-fit: contain; }
#resultCanvas { position: absolute; top: 0; left: 0; }

.empty-state {
    text-align: center;
    color: #b9b9c9;
    padding: 20px;
}

.empty-sticker {
    font-size: 64px;
    animation: float 3s ease-in-out infinite;
    display: inline-block;
}

.empty-state p {
    font-size: 14px;
    line-height: 1.6;
    color: #9aa0b0;
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-12px); }
}

.zoom-control {
    width: 70%;
    margin-top: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

input[type=range] { width: 100%; cursor: pointer; accent-color: #ff5fa2; }

.row-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
}

/* LOADING */
.loading-text {
    font-size: 16px;
    font-weight: 600;
    color: #20303a;
    background: rgba(255, 255, 255, 0.94);
    padding: 10px 20px;
    border-radius: 12px;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12);
    margin: 10px 0;
}

/* DETECTION */
.detection-panel {
    margin-top: 10px;
    font-size: 12.5px;
    color: #28a745;
    background: #f0fff4;
    border: 1.5px solid #b2dfdb;
    border-radius: 10px;
    padding: 7px 14px;
    text-align: center;
    max-width: 90%;
}

.detection-panel.error {
    color: #c62828;
    background: #fff5f5;
    border-color: #f5c6cb;
}

/* TOAST */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: #7c3aed;
    color: #fff;
    padding: 12px 26px;
    border-radius: 30px;
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    z-index: 1000;
    display: none;
    font-weight: bold;
    font-size: 14px;
    animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
    from { bottom: -50px; opacity: 0; }
    to { bottom: 24px; opacity: 1; }
}

/* FOOTER */
.app-footer {
    max-width: 1200px;
    margin: 18px auto 0;
    text-align: center;
    padding: 14px;
    font-size: 13px;
    color: #666;
    background: #fafafa;
    border-radius: 14px;
    border: 1px solid #ececec;
}
.app-footer strong { color: #333; }

/* SCROLLBAR */
.controls::-webkit-scrollbar { width: 8px; }
.controls::-webkit-scrollbar-thumb { background: #ffc2dd; border-radius: 8px; }

/* RESPONSIVE */
@media (max-width: 900px) {
    .layout { flex-direction: column; }
    .controls { width: 100%; position: static; max-height: none; }
    .img-container { height: 460px; }
}