/* ===== RESET & BASE ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: #0b0b1a;
    color: #e8e8f0;
    min-height: 100vh;
    padding: 20px;
}
.container {
    max-width: 1100px;
    margin: 0 auto;
}

/* ===== HEADER ===== */
.header {
    text-align: center;
    padding: 30px 0 20px;
    border-bottom: 2px solid #f5b342;
    margin-bottom: 30px;
}
.header h1 {
    color: #f5b342;
    font-size: 36px;
    font-weight: 700;
}
.header p {
    color: #9999aa;
    font-size: 18px;
    margin-top: 6px;
}

/* ===== CARD ===== */
.card {
    background: #14142e;
    padding: 28px 30px;
    border-radius: 16px;
    margin-bottom: 28px;
    border: 1px solid #2a2a4e;
    box-shadow: 0 8px 30px rgba(0,0,0,0.4);
}
.card h2 {
    color: #f5b342;
    margin-bottom: 16px;
    font-size: 24px;
}
.card h3 {
    color: #ffd966;
    margin: 18px 0 8px;
    font-size: 20px;
}

/* ===== FORM ===== */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px 24px;
}
.form-group {
    display: flex;
    flex-direction: column;
}
.form-group label {
    font-size: 14px;
    color: #bbbbc8;
    margin-bottom: 4px;
    font-weight: 500;
}
.form-group input {
    padding: 12px 14px;
    border-radius: 10px;
    border: 1px solid #2e2e52;
    background: #1c1c3a;
    color: #fff;
    font-size: 15px;
    transition: 0.2s;
}
.form-group input:focus {
    outline: none;
    border-color: #f5b342;
    box-shadow: 0 0 0 3px rgba(245,179,66,0.15);
}
.form-group input::placeholder {
    color: #666688;
}

/* ===== BUTTONS ===== */
.btn {
    padding: 12px 32px;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.25s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}
.btn-gold {
    background: #f5b342;
    color: #0b0b1a;
}
.btn-gold:hover {
    background: #ffc75f;
    transform: scale(1.02);
}
.btn-outline {
    background: transparent;
    color: #bbbbc8;
    border: 1.5px solid #3a3a5e;
}
.btn-outline:hover {
    border-color: #f5b342;
    color: #f5b342;
}
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== RESULT BOX ===== */
.result-box {
    margin-top: 16px;
    padding: 16px;
    background: #0d0d22;
    border-radius: 10px;
    border: 1px solid #2a2a4e;
    font-size: 13px;
    font-family: 'Courier New', monospace;
    max-height: 260px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
    display: none;
}
.result-box.show {
    display: block;
}

/* ===== MODE TOGGLE ===== */
.mode-toggle {
    display: flex;
    gap: 14px;
    margin-bottom: 22px;
}
.mode-btn {
    padding: 12px 28px;
    background: #1a1a3a;
    color: #9999aa;
    border: 2px solid #2e2e52;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.25s;
}
.mode-btn.active {
    background: #f5b342;
    color: #0b0b1a;
    border-color: #f5b342;
}
.mode-btn:hover:not(.active) {
    border-color: #f5b342;
}
.mode-panel {
    display: none;
}
.mode-panel.active {
    display: block;
}

/* ===== TITLE CONTAINER ===== */
.title-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin: 12px 0 16px;
    padding: 14px;
    background: #0d0d22;
    border-radius: 10px;
    border: 1px solid #2a2a4e;
    max-height: 180px;
    overflow-y: auto;
}
.title-item {
    background: #1a1a3a;
    padding: 8px 16px;
    border-radius: 8px;
    border: 2px solid #2e2e52;
    cursor: pointer;
    transition: 0.2s;
    font-size: 14px;
    user-select: none;
}
.title-item:hover {
    border-color: #f5b342;
}
.title-item.selected {
    border-color: #f5b342;
    background: #2a2a4e;
}
.title-item.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}
.hint {
    color: #8888aa;
    font-size: 14px;
    margin-bottom: 8px;
}

/* ===== OPTIONS ===== */
.options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 28px;
    margin: 16px 0 20px;
    padding: 16px 20px;
    background: #0d0d22;
    border-radius: 10px;
    border: 1px solid #2a2a4e;
}
.options-grid label {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #cccce0;
    font-size: 14px;
    cursor: pointer;
}
.options-grid input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #f5b342;
}

/* ===== PROGRESS LOG ===== */
.progress-log {
    background: #0d0d22;
    padding: 14px;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    max-height: 180px;
    overflow-y: auto;
    border: 1px solid #2a2a4e;
    margin: 12px 0;
    display: none;
}
.progress-log.show {
    display: block;
}
.progress-log .log-line {
    padding: 4px 0;
    border-bottom: 1px solid #1a1a34;
}
.progress-log .log-line.done {
    color: #6fcf97;
}
.progress-log .log-line.process {
    color: #f5b342;
}
.progress-log .log-line.error {
    color: #f28b82;
}

/* ===== HISTORY ===== */
#historyContainer {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 16px;
}
.history-card {
    background: #1a1a3a;
    padding: 16px 18px;
    border-radius: 12px;
    border-left: 4px solid #f5b342;
}
.history-card .mode {
    font-weight: 700;
    color: #f5b342;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.history-card .title-text {
    color: #fff;
    font-size: 15px;
    margin: 6px 0 4px;
    font-weight: 500;
}
.history-card .date {
    color: #666688;
    font-size: 12px;
}
.history-card .actions {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.history-card .actions button {
    padding: 5px 14px;
    font-size: 12px;
    background: #2a2a4e;
    color: #cccce0;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: 0.2s;
}
.history-card .actions button:hover {
    background: #f5b342;
    color: #0b0b1a;
}

/* ===== UPLOAD AREA ===== */
.upload-area {
    display: flex;
    gap: 14px;
    align-items: center;
    flex-wrap: wrap;
    margin-top: 6px;
}
.upload-area input[type="file"] {
    flex: 1;
    min-width: 180px;
    padding: 10px;
    background: #1a1a3a;
    border: 1px solid #2e2e52;
    border-radius: 8px;
    color: #cccce0;
}
.upload-area input[type="file"]::file-selector-button {
    background: #2a2a4e;
    color: #fff;
    border: none;
    padding: 6px 16px;
    border-radius: 6px;
    cursor: pointer;
}
.title-list {
    margin-top: 12px;
    font-size: 13px;
    color: #8888aa;
}

/* ===== MODAL ===== */
.modal {
    display: none;
    position: fixed;
    z-index: 999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.8);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
}
.modal.show {
    display: flex;
}
.modal-content {
    background: #14142e;
    padding: 28px 30px;
    border-radius: 18px;
    border: 2px solid #f5b342;
    width: 92%;
    max-width: 1200px;
    max-height: 92vh;
    position: relative;
    overflow: hidden;
}
.close-btn {
    position: absolute;
    top: 12px;
    right: 22px;
    font-size: 32px;
    color: #aaaacc;
    cursor: pointer;
    transition: 0.2s;
}
.close-btn:hover {
    color: #f5b342;
}
.preview-actions {
    display: flex;
    gap: 12px;
    margin: 12px 0 16px;
}
.preview-frame {
    width: 100%;
    height: 68vh;
    border: 1px solid #2a2a4e;
    border-radius: 10px;
    background: #fff;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    .header h1 {
        font-size: 26px;
    }
    .card {
        padding: 18px 16px;
    }
    .options-grid {
        flex-direction: column;
        gap: 10px;
    }
    #historyContainer {
        grid-template-columns: 1fr;
    }
    .mode-toggle {
        flex-direction: column;
    }
    .upload-area {
        flex-direction: column;
        align-items: stretch;
    }
    .modal-content {
        padding: 16px;
        width: 98%;
    }
    .preview-frame {
        height: 50vh;
    }
}