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

:root {
    --bg: #0a0a0f;
    --bg-elevated: #12121a;
    --bg-card: #181825;
    --bg-hover: #1e1e2e;
    --border: #2a2a3d;
    --border-focus: #2563eb;
    --text: #e4e4ef;
    --text-secondary: #9494a8;
    --text-muted: #6c6c85;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-glow: rgba(59, 130, 246, 0.15);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --warning: #f59e0b;
    --radius: 10px;
    --radius-sm: 6px;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

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

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.3px;
}

.nav-brand svg {
    color: var(--primary);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 100px;
    background: var(--primary-glow);
    color: var(--primary);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-sm {
    padding: 2px 10px;
    font-size: 11px;
    background: var(--bg-hover);
    color: var(--text-secondary);
    border-color: var(--border);
}

.main {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 24px 80px;
}

.container {
    display: flex;
    flex-direction: column;
    gap: 32px;
}

.header {
    text-align: center;
    padding: 32px 0 8px;
}

.header h1 {
    font-size: 32px;
    font-weight: 700;
    letter-spacing: -0.5px;
    line-height: 1.2;
    margin-bottom: 8px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 15px;
    line-height: 1.5;
    max-width: 520px;
    margin: 0 auto;
}

.form-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group-full {
    grid-column: 1 / -1;
}

label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.optional {
    font-weight: 400;
    color: var(--text-muted);
    text-transform: none;
    letter-spacing: 0;
}

select, input[type="text"], textarea {
    width: 100%;
    padding: 12px 14px;
    font-size: 14px;
    font-family: var(--font-sans);
    color: var(--text);
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

select:focus, input:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.select-wrapper {
    position: relative;
}

.select-wrapper::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    width: 8px;
    height: 8px;
    border-right: 2px solid var(--text-muted);
    border-bottom: 2px solid var(--text-muted);
    transform: translateY(-70%) rotate(45deg);
    pointer-events: none;
}

.select-wrapper select {
    padding-right: 36px;
}

input[type="range"] {
    -webkit-appearance: none;
    width: 100%;
    height: 6px;
    background: var(--bg-hover);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: var(--primary);
    border-radius: 50%;
    border: 3px solid var(--bg-card);
    cursor: pointer;
    box-shadow: 0 0 0 2px var(--primary), 0 0 12px var(--primary-glow);
}

.range-labels {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--text-muted);
    padding: 0 2px;
    margin-top: -4px;
}

.range-value {
    color: var(--primary);
    font-weight: 700;
}

.char-count {
    text-align: right;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: -4px;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding-top: 8px;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-sans);
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

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

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-hover);
    box-shadow: 0 4px 20px var(--primary-glow);
}

.btn-secondary {
    background: var(--bg-hover);
    color: var(--text);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--border);
    border-color: var(--text-muted);
}

.btn-danger {
    background: transparent;
    color: var(--danger);
    border: 1px solid transparent;
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: rgba(239, 68, 68, 0.2);
}

.btn-sm {
    padding: 6px 14px;
    font-size: 12px;
}

.hidden {
    display: none !important;
}

.loading-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 48px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.loading-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
}

.loading-status {
    font-size: 14px;
    color: var(--text-secondary);
}

.loading-progress {
    width: 280px;
    height: 3px;
    background: var(--bg-hover);
    border-radius: 2px;
    overflow: hidden;
}

.loading-bar {
    width: 30%;
    height: 100%;
    background: var(--primary);
    border-radius: 2px;
    animation: progress 2s ease-in-out infinite;
}

@keyframes progress {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(400%); }
}

.results-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 24px;
}

.results-header h2 {
    font-size: 20px;
    font-weight: 700;
}

.results-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.analyse-toggle {
    width: 100%;
    padding: 14px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    font-family: var(--font-sans);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.2s;
    margin-bottom: 24px;
}

.analyse-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.toggle-icon {
    font-size: 10px;
    transition: transform 0.2s;
}

.analyse-toggle.open .toggle-icon {
    transform: rotate(180deg);
}

.analyse-content {
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 20px;
    margin-bottom: 24px;
    margin-top: -16px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.7;
}

.script-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
    transition: border-color 0.2s;
}

.script-card:hover {
    border-color: var(--text-muted);
}

.script-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.szene-item {
    padding: 14px 0 14px 16px;
    border-left: 2px solid var(--border);
    margin-bottom: 0;
    position: relative;
}

.szene-item:last-child {
    margin-bottom: 0;
}

.szene-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.szene-nr {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    background: var(--bg-hover);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: var(--font-mono);
}

.szene-typ {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.szene-beschreibung {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    margin-bottom: 4px;
    line-height: 1.6;
}

.szene-dialog {
    font-size: 13px;
    color: var(--text);
    font-weight: 600;
    line-height: 1.6;
}

.hashtags-block {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
    font-family: var(--font-mono);
}

.results-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    padding: 32px 0 16px;
}

.mt-32 {
    margin-top: 32px;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.history-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 18px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 13px;
    transition: all 0.2s;
}

.history-item:hover {
    background: var(--bg-hover);
    border-color: var(--text-muted);
}

.history-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.history-clickable {
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.15s;
}

.history-clickable:hover {
    background: rgba(59, 130, 246, 0.08);
}

.history-load-hint {
    color: var(--primary);
    font-size: 11px;
    font-weight: 600;
    opacity: 0;
    transform: translateX(-4px);
    transition: all 0.2s;
}

.history-clickable:hover .history-load-hint {
    opacity: 1;
    transform: translateX(0);
}

.history-date {
    color: var(--text-muted);
    font-size: 12px;
    font-family: var(--font-mono);
}

.history-category {
    font-weight: 600;
}

.history-meta {
    display: flex;
    gap: 6px;
}

.history-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 13px;
}

.notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 14px 24px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    color: white;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
    max-width: 400px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

.notification.success {
    background: #065f46;
    border: 1px solid #059669;
}

.notification.error {
    background: #7f1d1d;
    border: 1px solid #dc2626;
}

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

@media (max-width: 640px) {
    .nav {
        padding: 12px 16px;
    }
    .main {
        padding: 24px 16px 60px;
    }
    .form-card {
        padding: 20px;
    }
    .form-grid {
        grid-template-columns: 1fr;
    }
    .header h1 {
        font-size: 24px;
    }
    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }
    .history-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}
