:root {
    --bg: #ffffff;
    --bg-page: #f7f8fa;
    --bg-muted: #f1f3f5;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff4ff;
    --text: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-focus: #2563eb;
    --success: #059669;
    --success-light: #ecfdf5;
    --error: #dc2626;
    --error-light: #fef2f2;
    --orange: #ea580c;
    --orange-light: #fff7ed;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-page);
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3rem 1.5rem;
    color: var(--text);
    -webkit-font-smoothing: antialiased;
}

.container { max-width: 560px; width: 100%; }

/* Header */
.header { text-align: center; margin-bottom: 1.5rem; }
.header h1 { font-size: 1.5rem; font-weight: 700; color: var(--text); letter-spacing: -0.025em; }
.header p { color: var(--text-secondary); font-size: 0.875rem; margin-top: 0.25rem; }

/* Card */
.card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 1.75rem;
    box-shadow: var(--shadow);
}

/* Tabs */
.tab-bar {
    display: flex; gap: 0; margin-bottom: 1.5rem;
    border-radius: 8px; background: var(--bg-muted); padding: 3px;
}
.tab-btn {
    flex: 1; padding: 0.5rem 0.75rem; background: transparent; border: none;
    color: var(--text-secondary); font-family: inherit; font-size: 0.8125rem;
    font-weight: 500; cursor: pointer; transition: all 0.15s; border-radius: 6px;
    display: flex; align-items: center; justify-content: center; gap: 0.375rem;
}
.tab-btn.active {
    background: var(--bg); color: var(--text);
    box-shadow: 0 1px 2px rgba(0,0,0,0.06);
}
.tab-btn svg { width: 15px; height: 15px; }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Error message */
.message {
    padding: 0.75rem 1rem; border-radius: 8px; font-size: 0.8125rem;
    display: flex; align-items: center; gap: 0.5rem; margin-bottom: 1rem;
}
.message.error {
    background: var(--error-light); border: 1px solid #fecaca; color: var(--error);
}

.hidden { display: none !important; }

/* Upload area */
.upload-area {
    border: 1.5px dashed var(--border); border-radius: var(--radius);
    padding: 2rem 1.5rem; text-align: center; cursor: pointer; transition: all 0.15s;
}
.upload-area:hover, .upload-area.dragover {
    border-color: var(--accent); background: var(--accent-light);
}
.upload-icon {
    width: 40px; height: 40px; background: var(--bg-muted); border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; margin-bottom: 0.5rem;
}
.upload-icon svg { width: 20px; height: 20px; color: var(--text-secondary); }
.upload-text { font-size: 0.875rem; font-weight: 500; color: var(--text); }
.upload-hint { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.125rem; }

.file-input { display: none; }

/* Selected file */
.selected-file {
    display: none; margin-top: 0.75rem; padding: 0.625rem 0.75rem;
    background: var(--bg-muted); border-radius: 8px;
}
.selected-file.show { display: flex; align-items: center; gap: 0.625rem; }
.file-icon {
    width: 32px; height: 32px; background: var(--accent); border-radius: 6px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.file-icon.excel-file { background: var(--success); }
.file-icon.word-file { background: var(--accent); }
.file-icon svg { width: 16px; height: 16px; color: white; }
.file-info { flex: 1; min-width: 0; }
.file-name { font-size: 0.8125rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 0.6875rem; color: var(--text-muted); }
.remove-file {
    background: none; border: none; color: var(--text-muted);
    cursor: pointer; padding: 0.25rem; border-radius: 4px; transition: color 0.15s;
}
.remove-file:hover { color: var(--error); }
.remove-file svg { width: 16px; height: 16px; }

/* Textarea */
.or-divider {
    display: flex; align-items: center; gap: 0.75rem;
    margin: 0.875rem 0; color: var(--text-muted); font-size: 0.75rem;
}
.or-divider::before, .or-divider::after {
    content: ''; flex: 1; height: 1px; background: var(--border);
}
.md-textarea {
    width: 100%; min-height: 160px; background: var(--bg);
    border: 1.5px solid var(--border); border-radius: var(--radius);
    padding: 0.75rem 1rem; color: var(--text);
    font-family: 'SF Mono', 'Consolas', 'Monaco', monospace;
    font-size: 0.8125rem; line-height: 1.6; resize: vertical;
    transition: border-color 0.15s;
}
.md-textarea:focus { outline: none; border-color: var(--border-focus); }
.md-textarea::placeholder { color: var(--text-muted); }

/* Options */
.options-title {
    font-size: 0.6875rem; font-weight: 600; color: var(--text-muted);
    text-transform: uppercase; letter-spacing: 0.5px;
    margin-top: 1rem; margin-bottom: 0.375rem;
}
.options-group { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; }
.option-row {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.625rem 0.875rem; border-bottom: 1px solid var(--border); font-size: 0.8125rem;
}
.option-row:last-child { border-bottom: none; }
.option-row > label:first-child { color: var(--text); font-weight: 500; flex: 1; }
.option-row.stacked-option { align-items: stretch; flex-direction: column; gap: 0.375rem; }
.option-row.stacked-option > label:first-child { flex: none; }
.option-hint { font-size: 0.6875rem; color: var(--text-muted); font-weight: 400; }
.style-select {
    width: 100%; padding: 0.45rem 0.55rem; background: var(--bg);
    border: 1px solid var(--border); border-radius: 6px; color: var(--text);
    font-family: inherit; font-size: 0.8125rem;
}
.style-select:focus { outline: none; border-color: var(--border-focus); }
.option-row input[type="number"] {
    width: 64px; padding: 0.25rem 0.5rem; background: var(--bg);
    border: 1px solid var(--border); border-radius: 6px; color: var(--text);
    font-family: 'SF Mono', 'Consolas', monospace; font-size: 0.8125rem; text-align: center;
}
.option-row input[type="number"]:focus { outline: none; border-color: var(--border-focus); }

/* Toggle */
.toggle-switch { position: relative; width: 36px; height: 20px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
    background: var(--border); border-radius: 20px; transition: 0.2s;
}
.toggle-slider::before {
    content: ''; position: absolute; height: 14px; width: 14px;
    left: 3px; bottom: 3px; background: white; border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--accent); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(16px); }

/* Submit button */
.submit-btn {
    width: 100%; margin-top: 1rem; padding: 0.625rem 1rem;
    background: var(--accent); border: none; border-radius: 8px;
    color: white; font-family: inherit; font-size: 0.875rem; font-weight: 600;
    cursor: pointer; transition: background 0.15s;
    display: flex; align-items: center; justify-content: center; gap: 0.375rem;
}
.submit-btn:hover:not(:disabled) { background: var(--accent-hover); }
.submit-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.submit-btn svg { width: 16px; height: 16px; }
.spinner {
    display: none; width: 16px; height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white; border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
.submit-btn.loading .spinner { display: block; }
.submit-btn.loading .btn-text, .submit-btn.loading .btn-icon { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Result section */
.result-section { text-align: center; }
.success-badge {
    display: inline-flex; align-items: center; gap: 0.375rem;
    background: var(--success-light); color: var(--success);
    padding: 0.375rem 0.875rem; border-radius: 20px;
    font-size: 0.8125rem; font-weight: 600; margin-bottom: 1rem;
}
.success-badge svg { width: 16px; height: 16px; }
.result-title { font-size: 1rem; font-weight: 600; margin-bottom: 0.25rem; }
.result-subtitle { color: var(--text-secondary); font-size: 0.8125rem; margin-bottom: 1.25rem; }

/* Action buttons */
.preview-btn {
    display: flex; align-items: center; justify-content: center; gap: 0.375rem;
    width: 100%; padding: 0.5rem 0.75rem; background: var(--bg);
    border: 1px solid var(--border); border-radius: 8px; color: var(--text-secondary);
    font-family: inherit; font-size: 0.8125rem; font-weight: 500;
    cursor: pointer; text-decoration: none; transition: all 0.15s; margin-bottom: 0.5rem;
}
.preview-btn:hover { border-color: var(--accent); color: var(--accent); }
.preview-btn svg { width: 16px; height: 16px; }
.download-buttons { display: flex; gap: 0.5rem; margin-bottom: 1rem; }
.download-btn {
    flex: 1; padding: 0.5rem 0.75rem; border: none; border-radius: 8px;
    font-family: inherit; font-size: 0.8125rem; font-weight: 600; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 0.375rem;
    text-decoration: none; color: white; transition: opacity 0.15s;
}
.download-btn:hover { opacity: 0.9; }
.download-btn svg { width: 16px; height: 16px; }
.download-btn.html { background: var(--orange); }
.download-btn.docx { background: var(--accent); }

/* Output cards */
.result-cards { display: flex; flex-direction: column; gap: 0.5rem; margin-bottom: 1rem; text-align: left; }
.result-card { background: var(--bg-muted); border-radius: 8px; padding: 0.875rem 1rem; }
.result-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 0.375rem; }
.result-card-title { font-size: 0.8125rem; font-weight: 600; }
.result-card-badge {
    font-size: 0.6875rem; font-weight: 600; padding: 0.125rem 0.5rem;
    border-radius: 12px; background: var(--accent-light); color: var(--accent);
}
.result-card-badge.truncated { background: var(--orange-light); color: var(--orange); }
.result-card-info { font-size: 0.75rem; color: var(--text-muted); margin-bottom: 0.5rem; }
.card-actions { display: flex; gap: 0.375rem; }
.card-action-btn {
    flex: 1; padding: 0.375rem 0.625rem; border-radius: 6px;
    font-family: inherit; font-size: 0.75rem; font-weight: 500; cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 0.25rem;
    text-decoration: none; border: 1px solid var(--border);
    background: var(--bg); color: var(--text-secondary); transition: all 0.15s;
}
.card-action-btn:hover { border-color: var(--accent); color: var(--accent); }
.card-action-btn svg { width: 13px; height: 13px; }
.card-action-btn.copy-btn.copied { border-color: var(--success); color: var(--success); }
.new-file-btn {
    background: transparent; border: 1px solid var(--border); color: var(--text-secondary);
    padding: 0.5rem 1rem; border-radius: 8px; font-family: inherit;
    font-size: 0.8125rem; font-weight: 500; cursor: pointer; transition: all 0.15s;
}
.new-file-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Footer */
.footer { text-align: center; margin-top: 1.25rem; color: var(--text-muted); font-size: 0.6875rem; }

/* Formats bar */
.formats-bar {
    display: flex; justify-content: center; gap: 1.5rem;
    margin-top: 1.25rem; padding-top: 1rem; border-top: 1px solid var(--border);
}
.format-item {
    display: flex; align-items: center; gap: 0.25rem;
    font-size: 0.6875rem; color: var(--text-muted); font-weight: 500;
}
.format-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.format-dot.orange { background: var(--orange); }
.format-dot.green { background: var(--success); }

@media (max-width: 480px) {
    body { padding: 1.5rem 1rem; }
    .card { padding: 1.25rem; }
    .download-buttons { flex-direction: column; }
    .card-actions { flex-direction: column; }
}
