/* ===== CSS Variables & Reset ===== */
:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(18, 18, 30, 0.8);
    --bg-card-hover: rgba(25, 25, 42, 0.9);
    --border: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.12);
    --text-primary: #e8e8ed;
    --text-secondary: #8a8a9a;
    --text-muted: #55556a;
    --accent-1: #6c5ce7;
    --accent-2: #a29bfe;
    --accent-3: #fd79a8;
    --gradient-1: linear-gradient(135deg, #6c5ce7, #a29bfe, #fd79a8);
    --gradient-2: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    --red: #ff6b6b;
    --yellow: #feca57;
    --blue: #54a0ff;
    --green: #5cd85c;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
    --shadow-md: 0 8px 32px rgba(0,0,0,0.4);
    --shadow-glow: 0 0 40px rgba(108, 92, 231, 0.15);
    --font-sans: 'Inter', 'Noto Sans SC', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

html { scroll-behavior: smooth; font-size: 16px; scrollbar-width: thin; scrollbar-color: var(--accent-1) var(--bg-secondary); }

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-secondary); }
::-webkit-scrollbar-thumb { background: var(--accent-1); border-radius: 3px; }

#particleCanvas {
    position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0; pointer-events: none; opacity: 0.3;
}

/* ===== Navbar ===== */
.navbar {
    position: fixed; top: 0; left: 0; right: 0;
    z-index: 100;
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 2rem; height: 56px;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
}

.nav-brand { display: flex; align-items: center; gap: 10px; }

.brand-icon {
    width: 32px; height: 32px;
    display: flex; align-items: center; justify-content: center;
    background: var(--gradient-1);
    border-radius: var(--radius-sm);
    color: white;
}

.brand-text {
    font-size: 1.1rem; font-weight: 700;
    background: var(--gradient-1);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
}

.brand-sub { font-size: 0.75rem; color: var(--text-muted); margin-left: 4px; }

.nav-right { display: flex; align-items: center; gap: 1rem; }

.nav-status { display: flex; align-items: center; gap: 6px; font-size: 0.8rem; color: var(--text-secondary); }

.status-dot {
    width: 8px; height: 8px;
    background: var(--text-muted);
    border-radius: 50%;
}
.status-dot.ready { background: var(--green); animation: pulse-dot 2s infinite; }

@keyframes pulse-dot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(92, 216, 92, 0.4); }
    50% { box-shadow: 0 0 0 6px rgba(92, 216, 92, 0); }
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: var(--radius-md);
    font-family: var(--font-sans); font-size: 0.9rem; font-weight: 600;
    cursor: pointer; transition: var(--transition);
    border: none; text-decoration: none; white-space: nowrap;
}
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-lg { padding: 14px 32px; font-size: 1rem; }

.btn-primary {
    background: var(--gradient-2); color: white;
    box-shadow: 0 4px 20px rgba(108, 92, 231, 0.3);
}
.btn-primary:hover { transform: translateY(-2px); box-shadow: 0 8px 30px rgba(108, 92, 231, 0.5); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none !important; }

.select-sm {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 4px 8px;
    font-size: 0.8rem;
    font-family: var(--font-sans);
    outline: none;
    cursor: pointer;
    transition: var(--transition);
}
.select-sm:hover { border-color: rgba(255,255,255,0.2); }
.select-sm option { background: var(--bg-card); color: var(--text-primary); }

.btn-ghost {
    background: transparent; color: var(--text-secondary);
    border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text-primary); border-color: var(--border-hover); background: rgba(255,255,255,0.03); }

/* ===== Config Drawer ===== */
.config-drawer {
    position: fixed; top: 56px; left: 0; right: 0;
    z-index: 99;
    background: rgba(12, 12, 20, 0.95);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 1rem 2rem;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.drawer-content { max-width: 1000px; margin: 0 auto; }

.drawer-row {
    display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
    margin-bottom: 0.5rem;
}

.drawer-row .input-group { flex: 1; min-width: 200px; }

.input-label { font-size: 0.7rem; color: var(--text-muted); font-weight: 500; margin-bottom: 2px; display: block; }

.config-input {
    width: 100%; padding: 8px 10px;
    background: rgba(255,255,255,0.04); border: 1px solid var(--border);
    border-radius: var(--radius-sm); color: var(--text-primary);
    font-family: var(--font-mono); font-size: 0.8rem;
    outline: none; transition: var(--transition);
}
.config-input:focus { border-color: var(--accent-1); box-shadow: 0 0 0 2px rgba(108, 92, 231, 0.1); }
.config-input::placeholder { color: var(--text-muted); font-family: var(--font-sans); }

.input-with-toggle { position: relative; display: flex; }
.input-with-toggle .config-input { padding-right: 36px; }

.btn-eye {
    position: absolute; right: 4px; top: 50%; transform: translateY(-50%);
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 4px; border-radius: 4px; display: flex; align-items: center;
}
.btn-eye:hover { color: var(--accent-2); }

.preset-btn {
    padding: 5px 12px;
    background: rgba(108, 92, 231, 0.08); border: 1px solid rgba(108, 92, 231, 0.15);
    border-radius: 100px; color: var(--accent-2);
    font-family: var(--font-sans); font-size: 0.75rem; font-weight: 500;
    cursor: pointer; transition: var(--transition);
}
.preset-btn:hover { background: rgba(108, 92, 231, 0.2); border-color: var(--accent-1); }

.preset-mine { background: rgba(253, 121, 168, 0.12); border-color: rgba(253, 121, 168, 0.3); color: var(--accent-3); }
.preset-mine:hover { background: rgba(253, 121, 168, 0.25); border-color: var(--accent-3); }

/* ===== Workflow ===== */
.workflow {
    position: relative; z-index: 1;
    max-width: 960px; margin: 0 auto;
    padding: 80px 2rem 4rem;
}

/* ===== Step ===== */
.step {
    margin-bottom: 2rem;
    position: relative;
}

.step::before {
    content: '';
    position: absolute; top: 48px; left: 19px;
    width: 2px; height: calc(100% - 48px);
    background: var(--border);
}
.step:last-child::before { display: none; }

.step-header {
    display: flex; align-items: center; gap: 1rem;
    margin-bottom: 1rem;
}

.step-badge {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.05);
    border: 2px solid var(--border);
    font-size: 1rem; font-weight: 800;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: var(--transition);
    position: relative; z-index: 1;
}

.step-badge.active {
    background: var(--gradient-2);
    border-color: var(--accent-1);
    color: white;
    box-shadow: 0 0 20px rgba(108, 92, 231, 0.3);
}

.step-badge.done {
    background: var(--green);
    border-color: var(--green);
    color: white;
}

.step-info h2 { font-size: 1.2rem; font-weight: 700; }
.step-info p { font-size: 0.85rem; color: var(--text-muted); }

.step-body {
    margin-left: 56px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    transition: var(--transition);
}

.step-actions {
    display: flex; gap: 0.75rem; margin-top: 1rem;
    justify-content: flex-end; align-items: center; flex-wrap: wrap;
}

/* ===== Step 1: Script Input ===== */
.script-input-area { position: relative; }

.input-toolbar {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 0.75rem; flex-wrap: wrap; gap: 0.5rem;
}

.toolbar-left, .toolbar-right { display: flex; align-items: center; gap: 0.5rem; }

.upload-btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border-radius: var(--radius-sm);
    background: rgba(108, 92, 231, 0.1);
    border: 1px solid rgba(108, 92, 231, 0.2);
    color: var(--accent-2); font-size: 0.8rem; font-weight: 500;
    cursor: pointer; transition: var(--transition);
}
.upload-btn:hover { background: rgba(108, 92, 231, 0.2); }

.char-count { font-size: 0.8rem; color: var(--text-muted); font-family: var(--font-mono); }

.script-textarea {
    width: 100%; min-height: 280px; padding: 1rem;
    background: rgba(0,0,0,0.3); border: 1px solid var(--border);
    border-radius: var(--radius-md); color: var(--text-primary);
    font-family: var(--font-sans); font-size: 0.95rem;
    line-height: 1.8; resize: vertical;
    transition: var(--transition); outline: none;
}
.script-textarea:focus { border-color: var(--accent-1); box-shadow: 0 0 0 3px rgba(108, 92, 231, 0.1); }
.script-textarea::placeholder { color: var(--text-muted); }

/* Options Panel */
.options-panel {
    margin-top: 0.75rem; border-radius: var(--radius-md);
    background: rgba(0,0,0,0.15); border: 1px solid var(--border);
    overflow: hidden;
}

.options-panel summary {
    padding: 10px 14px; cursor: pointer;
    font-size: 0.85rem; font-weight: 600; color: var(--text-secondary);
    user-select: none;
}
.options-panel summary:hover { color: var(--text-primary); }

.options-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.5rem; padding: 0 14px 14px;
}

.check-item {
    display: flex; align-items: center; gap: 8px;
    padding: 8px 10px; border-radius: var(--radius-sm);
    background: rgba(255,255,255,0.02); border: 1px solid var(--border);
    cursor: pointer; transition: var(--transition); font-size: 0.82rem;
    color: var(--text-secondary);
}
.check-item:hover { background: rgba(255,255,255,0.04); }
.check-item.highlight { border-color: rgba(253, 121, 168, 0.2); background: rgba(253, 121, 168, 0.05); }
.check-item input { accent-color: var(--accent-1); }

/* ===== Step 2: Report ===== */
.report-stream-box {
    background: rgba(0,0,0,0.25);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    max-height: 500px; overflow-y: auto;
}

.stream-content {
    padding: 1.5rem;
    font-size: 0.9rem; line-height: 1.9;
    color: var(--text-secondary);
    white-space: pre-wrap; word-break: break-all;
}

/* ===== Step 3 (Inline Diff) ===== */
.diff-editor {
    overflow-y: auto; padding: 0.5rem 0;
    background: rgba(0,0,0,0.4);
    position: relative;
}

.diff-chunk-ctx { padding: 0 1rem; color: var(--text-secondary); }

.diff-chunk-change {
    margin: 8px 1rem;
    border: 1px solid var(--border); border-radius: 6px;
    overflow: hidden; background: var(--bg-card);
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.diff-chunk-toolbar {
    display: flex; gap: 8px; padding: 6px 10px;
    background: rgba(255,255,255,0.03);
    border-bottom: 1px solid var(--border);
}

.diff-chunk-btn {
    background: none; border: 1px solid var(--border);
    color: var(--text-secondary); cursor: pointer;
    border-radius: 4px; padding: 2px 8px; font-size: 0.75rem;
    display: flex; align-items: center; gap: 4px;
    transition: var(--transition);
}
.diff-chunk-btn.accept:hover { background: rgba(92, 216, 92, 0.15); color: var(--green); border-color: var(--green); }
.diff-chunk-btn.reject:hover { background: rgba(255, 107, 107, 0.15); color: var(--red); border-color: var(--red); }

.diff-line { display: flex; padding: 2px 0; font-family: var(--font-mono); font-size: 0.85rem; }
.diff-line-sign { width: 24px; text-align: center; flex-shrink: 0; font-weight: 700; user-select: none; }
.diff-line-content { flex: 1; padding-right: 10px; white-space: pre-wrap; word-break: break-all; }

.diff-line.del { background: rgba(255, 107, 107, 0.08); }
.diff-line.del .diff-line-sign { color: var(--red); }
.diff-line.del .diff-line-content { color: var(--red); text-decoration: line-through; opacity: 0.7; }

.diff-line.add { background: rgba(92, 216, 92, 0.08); }
.diff-line.add .diff-line-sign { color: var(--green); }
.diff-line.add .diff-line-content { color: var(--green); }

.hl-del { background: rgba(255, 107, 107, 0.3); padding: 1px 3px; border-radius: 3px; text-decoration: line-through; }
.hl-add { background: rgba(92, 216, 92, 0.3); padding: 1px 3px; border-radius: 3px; font-weight: 600; }

/* ===== Toast ===== */
.toast-container {
    position: fixed; bottom: 2rem; right: 2rem; z-index: 1000;
    display: flex; flex-direction: column; gap: 0.5rem;
}

.toast {
    padding: 12px 20px;
    background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius-md); backdrop-filter: blur(20px);
    font-size: 0.9rem; color: var(--text-primary);
    box-shadow: var(--shadow-md);
    animation: toastIn 0.3s ease-out;
    display: flex; align-items: center; gap: 8px;
}
.toast.success { border-left: 3px solid var(--green); }
.toast.error { border-left: 3px solid var(--red); }
.toast.info { border-left: 3px solid var(--blue); }

@keyframes toastIn {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

/* Spinner */
@keyframes spin { to { transform: rotate(360deg); } }
.spinner {
    display: inline-block; width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white; border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .navbar { padding: 0 1rem; }
    .workflow { padding: 72px 1rem 3rem; }
    .step-body { margin-left: 0; margin-top: 0.5rem; }
    .step::before { display: none; }
    .drawer-row { flex-direction: column; align-items: stretch; }
    .options-grid { grid-template-columns: 1fr 1fr; }
}
