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

:root {
    --bg: #0a0a0f;
    --bg-card: #12121a;
    --bg-card-hover: #1a1a25;
    --bg-input: #0e0e16;
    --border: #1e1e2e;
    --border-focus: #7c3aed;
    --text: #f0f0f5;
    --text-muted: #8888a0;
    --text-dim: #555570;
    --accent: #7c3aed;
    --accent-light: #a78bfa;
    --accent-glow: rgba(124, 58, 237, 0.25);
    --success: #22c55e;
    --success-bg: rgba(34, 197, 94, 0.1);
    --warning: #f59e0b;
    --warning-bg: rgba(245, 158, 11, 0.1);
    --error: #ef4444;
    --error-bg: rgba(239, 68, 68, 0.1);
    --radius: 10px;
    --radius-sm: 6px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --mono: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
}

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 20px 60px;
}

/* === HEADER === */
.header {
    text-align: center;
    padding: 40px 0 32px;
}

.header h1 {
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-light), var(--accent));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.header p {
    color: var(--text-muted);
    font-size: 0.95rem;
    max-width: 520px;
    margin: 0 auto;
}

/* === CARDS === */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title .badge {
    font-size: 0.75rem;
    background: var(--accent-glow);
    color: var(--accent-light);
    padding: 2px 10px;
    border-radius: 20px;
    font-weight: 500;
}

/* === TABS === */
.tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.tab-btn {
    padding: 8px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
    white-space: nowrap;
}

.tab-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}

.tab-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.format-hint {
    font-size: 0.82rem;
    color: var(--text-dim);
    margin-bottom: 12px;
}

.format-hint code {
    background: var(--bg-input);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: var(--mono);
    font-size: 0.78rem;
    color: var(--accent-light);
}

/* === FORM ELEMENTS === */
textarea {
    width: 100%;
    min-height: 180px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-family: var(--mono);
    font-size: 0.85rem;
    padding: 14px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s;
    line-height: 1.5;
}

textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

textarea::placeholder {
    color: var(--text-dim);
}

.mtp-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.mtp-grid label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-muted);
}

/* === BUTTONS === */
.btn-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font);
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent), #6d28d9);
    color: #fff;
    box-shadow: 0 2px 12px var(--accent-glow);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-outline:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

.btn-success {
    background: var(--success);
    color: #fff;
}

.btn-success:hover { opacity: 0.9; }

.btn-sm {
    padding: 7px 14px;
    font-size: 0.8rem;
}

/* === STATS BAR === */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-item {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-light);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* === RESULTS === */
.results-section { display: none; }
.results-section.visible { display: block; }

.blocks-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 14px;
}

.block-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: border-color 0.2s;
}

.block-card:hover {
    border-color: var(--accent);
}

.block-card.processed {
    opacity: 0.5;
    border-color: var(--success);
}

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

.block-header h4 {
    font-size: 0.9rem;
    font-weight: 600;
}

.block-header .count {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 12px;
}

.block-preview {
    background: var(--bg);
    border-radius: 4px;
    padding: 10px;
    max-height: 120px;
    overflow-y: auto;
    margin-bottom: 12px;
    font-family: var(--mono);
    font-size: 0.72rem;
    line-height: 1.4;
    color: var(--text-muted);
    white-space: pre-wrap;
    word-break: break-all;
}

.block-actions {
    display: flex;
    gap: 8px;
}

.block-actions .btn { flex: 1; justify-content: center; }

/* === METRICS DASHBOARD === */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 14px;
}

.metric-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 18px;
    text-align: center;
}

.metric-card .icon {
    font-size: 1.5rem;
    margin-bottom: 6px;
}

.metric-card .value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--accent-light);
}

.metric-card .label {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* === TOAST === */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    max-width: 380px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
}

.toast-success { background: var(--success); color: #fff; }
.toast-error { background: var(--error); color: #fff; }
.toast-warning { background: var(--warning); color: #000; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

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

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

/* === PROCESSED SECTION === */
.processed-section { display: none; }
.processed-section.visible { display: block; }

.processed-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.processed-card {
    background: var(--bg-input);
    border: 1px solid var(--success);
    border-radius: var(--radius-sm);
    padding: 14px;
    text-align: center;
    opacity: 0.6;
}

.processed-card .check {
    color: var(--success);
    font-size: 1.2rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .container { padding: 16px 12px 40px; }
    .header h1 { font-size: 1.5rem; }
    .header { padding: 24px 0 20px; }
    .tabs { gap: 4px; }
    .tab-btn { padding: 6px 10px; font-size: 0.72rem; }
    .mtp-grid { grid-template-columns: 1fr; }
    .blocks-grid { grid-template-columns: 1fr; }
    .stats-bar { grid-template-columns: repeat(2, 1fr); }
    .metrics-grid { grid-template-columns: repeat(2, 1fr); }
    .card { padding: 16px; }
    .btn-row { flex-direction: column; }
    .btn-row .btn { width: 100%; justify-content: center; }
    .processed-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
    .stats-bar { grid-template-columns: 1fr 1fr; }
    .metrics-grid { grid-template-columns: 1fr 1fr; }
    textarea { min-height: 140px; font-size: 0.78rem; }
}

/* === SCROLLBAR === */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }
