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

body {
    font-family: "Barlow", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: #0a0a1a url('/static/images/space-bg.svg') center top / cover no-repeat fixed;
    color: #e8e0f0;
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6,
.tab,
.toggle-btn,
.btn-primary,
.btn-secondary,
.btn-remove {
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.upload-hint,
.guideline-hint,
.save-status {
    font-family: "Barlow Semi Condensed", "Barlow", sans-serif;
}

.container {
    max-width: 820px;
    margin: 0 auto;
    padding: 2rem 1.5rem 3rem;
}

/* Header */
header {
    text-align: center;
    margin-bottom: 2.5rem;
    padding: 2rem 1.5rem;
    background: linear-gradient(135deg, rgba(97, 50, 205, 0.85) 0%, rgba(40, 146, 235, 0.85) 100%);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.4), 0 0 60px rgba(97, 50, 205, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.header-logo {
    height: 56px;
    width: auto;
    margin-bottom: 0.75rem;
    display: inline-block;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.15));
}

header h1 {
    font-size: 1.9rem;
    font-weight: 700;
    color: #fff;
    margin-bottom: 0.35rem;
    letter-spacing: -0.02em;
}

.subtitle {
    color: rgba(255, 255, 255, 0.85);
    font-size: 0.95rem;
    font-weight: 400;
    font-family: "Barlow", sans-serif;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.25rem;
    margin-bottom: 1.5rem;
    background: rgba(15, 15, 35, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 0.35rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.tab {
    flex: 1;
    padding: 0.7rem 1.5rem;
    border: none;
    background: transparent;
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    border-radius: 9px;
    transition: all 0.25s ease;
}

.tab:hover {
    color: #c9a0e8;
    background: rgba(97, 50, 205, 0.15);
}

.tab.active {
    color: #fff;
    background: linear-gradient(135deg, #6132CD, #9938C9);
    box-shadow: 0 2px 8px rgba(97, 50, 205, 0.4);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Input Section */
.input-section {
    background: rgba(15, 15, 35, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    padding: 1.75rem;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
    margin-bottom: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.input-section h2 {
    font-size: 1.1rem;
    margin-bottom: 1rem;
    color: #e8e0f0;
    font-weight: 600;
}

/* Toggle */
.input-toggle {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.toggle-btn {
    flex: 1;
    padding: 0.65rem 1rem;
    border: 2px solid rgba(255, 255, 255, 0.12);
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    border-color: #9938C9;
    color: #c9a0e8;
    background: rgba(97, 50, 205, 0.1);
}

.toggle-btn.active {
    border-color: #6132CD;
    background: linear-gradient(135deg, rgba(97, 50, 205, 0.2), rgba(153, 56, 201, 0.15));
    color: #c9a0e8;
    box-shadow: 0 0 0 1px rgba(97, 50, 205, 0.2);
}

/* Input modes */
.input-mode {
    display: none;
}

.input-mode.active {
    display: block;
}

textarea {
    width: 100%;
    padding: 1rem 1.15rem;
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.9rem;
    line-height: 1.6;
    resize: vertical;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: #e0d8ee;
    background: rgba(10, 10, 30, 0.5);
}

textarea:focus {
    outline: none;
    border-color: #6132CD;
    box-shadow: 0 0 0 3px rgba(97, 50, 205, 0.2);
    background: rgba(10, 10, 30, 0.7);
}

textarea::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Upload Area */
.upload-area {
    border: 2px dashed rgba(255, 255, 255, 0.15);
    border-radius: 14px;
    padding: 3rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.25s ease;
    background: rgba(10, 10, 30, 0.3);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: #6132CD;
    background: rgba(97, 50, 205, 0.1);
    box-shadow: 0 0 0 3px rgba(97, 50, 205, 0.1);
}

.upload-icon {
    font-size: 2.8rem;
    margin-bottom: 0.75rem;
    filter: grayscale(0.3);
}

.upload-area:hover .upload-icon {
    filter: grayscale(0);
}

.upload-area p {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.9rem;
    font-weight: 500;
}

.upload-hint {
    color: rgba(255, 255, 255, 0.35) !important;
    font-size: 0.8rem !important;
    font-weight: 400 !important;
    margin-top: 0.5rem;
}

/* Image Preview */
#preview-container {
    text-align: center;
}

#image-preview {
    max-width: 100%;
    max-height: 300px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
}

.btn-remove {
    padding: 0.45rem 1.2rem;
    border: 1.5px solid #e53935;
    background: rgba(229, 57, 53, 0.1);
    color: #ff6b6b;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-remove:hover {
    background: #e53935;
    color: #fff;
    box-shadow: 0 2px 8px rgba(229, 57, 53, 0.35);
}

/* Buttons */
.btn-primary {
    display: block;
    width: 100%;
    padding: 0.95rem;
    background: linear-gradient(135deg, #6132CD, #9938C9);
    color: #fff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.25s ease;
    box-shadow: 0 2px 12px rgba(97, 50, 205, 0.35);
    letter-spacing: 0.01em;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #5228b5, #8530b5);
    box-shadow: 0 4px 20px rgba(97, 50, 205, 0.5);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(97, 50, 205, 0.3);
}

.btn-primary:disabled {
    background: rgba(100, 100, 130, 0.4);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

.btn-secondary {
    padding: 0.6rem 1.4rem;
    border: 2px solid rgba(97, 50, 205, 0.6);
    background: rgba(97, 50, 205, 0.1);
    color: #c9a0e8;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #6132CD;
    color: #fff;
    border-color: #6132CD;
    box-shadow: 0 2px 12px rgba(97, 50, 205, 0.35);
    transform: translateY(-1px);
}

.btn-secondary:active {
    transform: translateY(0);
}

/* Loading */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    vertical-align: middle;
}

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

/* Results */
#results {
    margin-top: 1.5rem;
}

.result-section {
    background: rgba(15, 15, 35, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    padding: 1.75rem;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
    margin-bottom: 1.25rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    animation: slideUp 0.35s ease;
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
}

.result-section h2 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: #e8e0f0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.result-box {
    background: rgba(10, 10, 30, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 10px;
    padding: 1.15rem;
    font-size: 0.9rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: #d0c8e0;
}

.response-box {
    background: linear-gradient(135deg, rgba(97, 50, 205, 0.12), rgba(40, 146, 235, 0.08));
    border-color: rgba(97, 50, 205, 0.2);
}

.result-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.15rem;
}

/* Guideline */
.guideline-section {
    background: rgba(15, 15, 35, 0.65);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    padding: 1.75rem;
    box-shadow: 0 2px 16px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.guideline-header {
    margin-bottom: 1.25rem;
}

.guideline-header h2 {
    font-size: 1.1rem;
    color: #e8e0f0;
    margin-bottom: 0.35rem;
    font-weight: 600;
}

.guideline-hint {
    font-size: 0.85rem;
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.5;
}

.guideline-hint code {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.15rem 0.45rem;
    border-radius: 5px;
    font-size: 0.82rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #c9a0e8;
}

#guideline-editor {
    font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
    font-size: 0.85rem;
    line-height: 1.55;
    min-height: 500px;
    background: rgba(10, 10, 30, 0.5);
}

#guideline-editor:focus {
    background: rgba(10, 10, 30, 0.7);
}

.guideline-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 1.25rem;
}

.guideline-actions .btn-primary {
    width: auto;
    padding: 0.7rem 2rem;
}

.save-status {
    font-size: 0.85rem;
    color: #c9a0e8;
    font-weight: 600;
}

/* Utility */
.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 600px) {
    .container {
        padding: 1rem 1rem 2rem;
    }

    header {
        padding: 1.5rem 1rem;
        border-radius: 12px;
    }

    header h1 {
        font-size: 1.4rem;
    }

    .header-logo {
        height: 44px;
        margin-bottom: 0.5rem;
    }

    .input-section,
    .result-section,
    .guideline-section {
        padding: 1.25rem;
        border-radius: 12px;
    }

    .result-actions {
        flex-direction: column;
    }

    .btn-secondary {
        width: 100%;
        text-align: center;
    }

    .tabs {
        border-radius: 10px;
    }

    .tab {
        border-radius: 7px;
        font-size: 0.88rem;
        padding: 0.6rem 1rem;
    }
}
