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

html,
body,
#app {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #0f0f17;
    color: #f5f5f5;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

.center-overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(14, 14, 20, 0.92);
    z-index: 100;
}

.overlay-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding: 32px 40px;
    border-radius: 18px;
    background: rgba(27, 27, 39, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.spinner {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 4px solid rgba(255, 255, 255, 0.16);
    border-top-color: #4c82ff;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.app {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1280px;
    margin: 0 auto;
    padding: 32px 40px 48px;
    gap: 32px;
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
}

.app-header-text h1 {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
}

.app-header-text p {
    color: rgba(245, 245, 245, 0.65);
    font-size: 15px;
}

.upload-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 20px;
    height: 44px;
    font-size: 15px;
    border-radius: 12px;
    background: rgba(76, 130, 255, 0.16);
    border: 1px solid rgba(76, 130, 255, 0.5);
    color: #dbe7ff;
    cursor: pointer;
    transition: background 0.2s ease, border 0.2s ease;
}

.upload-btn:hover {
    background: rgba(76, 130, 255, 0.26);
    border-color: rgba(76, 130, 255, 0.7);
}

.upload-btn input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

.app-main {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 32px;
    flex: 1;
}

.preview-card,
.form-card {
    background: rgba(26, 26, 36, 0.88);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 18px;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.badge {
    padding: 2px 10px;
    border-radius: 999px;
    background: rgba(76, 130, 255, 0.18);
    border: 1px solid rgba(76, 130, 255, 0.35);
    font-size: 13px;
    color: #dbe7ff;
}

.preview-frame {
    position: relative;
    width: 100%;
    aspect-ratio: 3 / 4;
    border-radius: 14px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(12, 12, 18, 0.86);
    overflow: hidden;
}

.preview-placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 16px;
    color: rgba(245, 245, 245, 0.55);
    font-size: 14px;
}

.preview-image {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.preview-edit-button {
    position: absolute;
    inset: auto 16px 16px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(0, 0, 0, 0.6);
    color: #f5f5f5;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease, border 0.2s ease;
}

.preview-edit-button:hover:not(:disabled) {
    background: rgba(76, 130, 255, 0.26);
    border-color: rgba(76, 130, 255, 0.6);
}

.preview-edit-button:disabled {
    cursor: not-allowed;
    opacity: 0.45;
}

.preview-actions {
    display: flex;
    gap: 12px;
    margin-top: 12px;
}

.action-btn {
    flex: 1;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.18);
    background: rgba(255, 255, 255, 0.08);
    color: #f5f5f5;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, border 0.2s ease, transform 0.15s ease;
}

.action-btn:hover:not(:disabled) {
    background: rgba(76, 130, 255, 0.22);
    border-color: rgba(76, 130, 255, 0.5);
}

.action-btn:active:not(:disabled) {
    transform: scale(0.97);
}

.action-btn:disabled {
    cursor: not-allowed;
    opacity: 0.5;
}

.action-btn.primary {
    background: #4c82ff;
    border-color: transparent;
    color: #ffffff;
}

.action-btn.primary:hover:not(:disabled) {
    background: #6898ff;
}

.hint {
    font-size: 13px;
    color: rgba(245, 245, 245, 0.5);
}

.form-card h2 {
    font-size: 20px;
    font-weight: 600;
}

.form-field {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.form-field span {
    font-size: 14px;
    color: rgba(245, 245, 245, 0.75);
}

textarea {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(15, 15, 25, 0.86);
    color: #f5f5f5;
    resize: vertical;
    font-size: 14px;
}

textarea::placeholder {
    color: rgba(245, 245, 245, 0.4);
}

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

.offset-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px;
    border-radius: 12px;
    background: rgba(15, 15, 25, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.offset-field span {
    font-size: 13px;
    color: rgba(245, 245, 245, 0.7);
}

.offset-field input {
    width: 100%;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(9, 9, 16, 0.9);
    color: #f5f5f5;
    font-size: 14px;
}

.offset-field input:focus {
    outline: none;
    border-color: rgba(76, 130, 255, 0.6);
    box-shadow: 0 0 0 2px rgba(76, 130, 255, 0.18);
}

.form-hint {
    font-size: 12px;
    color: rgba(245, 245, 245, 0.45);
}

.editor-overlay {
    position: fixed;
    inset: 0;
    background: rgba(9, 12, 20, 0.92);
    backdrop-filter: blur(6px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    z-index: 200;
}

.editor-wrapper {
    display: flex;
    flex-direction: column;
    width: min(1100px, 100%);
    height: min(94vh, 100%);
    background: rgba(18, 18, 28, 0.98);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 18px;
    overflow: hidden;
}

.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: rgba(24, 24, 35, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    flex-wrap: wrap;
}

.toolbar-group {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.tool-btn {
    min-width: 44px;
    height: 42px;
    padding: 0 14px;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.05);
    color: #f5f5f5;
    font-size: 15px;
    cursor: pointer;
    transition: transform 0.15s ease, background 0.2s ease, border 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.tool-btn:active {
    transform: scale(0.96);
}

.tool-btn.active {
    background: #4c82ff;
    border-color: transparent;
    color: #ffffff;
}

.tool-btn.primary {
    background: #4c82ff;
    border-color: transparent;
    color: #ffffff;
}

.tool-btn.primary:hover {
    background: #6898ff;
}

.divider {
    width: 1px;
    height: 26px;
    background: rgba(255, 255, 255, 0.14);
}

.slider {
    width: 160px;
    height: 4px;
    appearance: none;
    background: rgba(255, 255, 255, 0.18);
    border-radius: 999px;
    outline: none;
}

.slider::-webkit-slider-thumb {
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4c82ff;
    border: none;
    box-shadow: 0 0 10px rgba(76, 130, 255, 0.35);
    cursor: pointer;
}

.slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #4c82ff;
    border: none;
    box-shadow: 0 0 10px rgba(76, 130, 255, 0.35);
    cursor: pointer;
}

.size-label {
    min-width: 54px;
    text-align: center;
    font-size: 13px;
    color: rgba(245, 245, 245, 0.62);
}

#doodleControls {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

#doodleColorInput {
    appearance: none;
    -webkit-appearance: none;
    width: 44px;
    height: 42px;
    padding: 0;
    border-radius: 11px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    background: rgba(255, 255, 255, 0.05);
    cursor: pointer;
}

#doodleColorInput::-webkit-color-swatch-wrapper {
    padding: 4px;
    border-radius: 11px;
}

#doodleColorInput::-webkit-color-swatch,
#doodleColorInput::-moz-color-swatch {
    border: none;
    border-radius: 9px;
}

.editor-stage {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.stage {
    position: relative;
    width: min(90vw, 72vh);
    aspect-ratio: 3 / 4;
    background-color: rgba(28, 28, 40, 1);
    background-image:
        linear-gradient(45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(255, 255, 255, 0.04) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.04) 75%);
    background-size: 40px 40px;
    background-position: 0 0, 0 20px, 20px -20px, -20px 0;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    overflow: hidden;
}

#editorCanvas {
    width: 100%;
    height: 100%;
    touch-action: none;
}

@media (max-width: 960px) {
    .app {
        padding: 24px 20px 32px;
    }

    .app-main {
        grid-template-columns: 1fr;
    }
}
