:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --surface-alt: #fafbfc;
    --border: #dfe3e8;
    --soft-border: #e8ecef;
    --text-primary: #1a202c;
    --text-secondary: #4a5568;
    --muted: #718096;
    --accent: #0891b2;
    --accent-hover: #0e7490;
    --accent-soft: #ecfeff;
    --success: #10b981;
    --danger: #ef4444;
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-sm: 6px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    padding: 40px 24px 48px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 28px;
}

header {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

header h1 {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--text-primary);
}

.subtitle {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 600px;
    font-weight: 400;
}

.controls {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    background: var(--surface);
    padding: 28px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

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

.control-group label {
    font-size: 0.8rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--text-secondary);
    font-weight: 600;
}

.control-group select,
.control-group input {
    appearance: none;
    padding: 11px 14px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    font-size: 0.95rem;
    background: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
    cursor: pointer;
}

.control-group select:hover,
.control-group input:hover {
    border-color: var(--accent);
    background: var(--surface-alt);
}

.control-group select:focus,
.control-group input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
    background: #fff;
}

.indent-group input {
    max-width: 120px;
    text-align: center;
}

.editor-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    align-items: stretch;
    height: calc(100vh - 380px);
    min-height: 500px;
}

.editor-container {
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s ease, transform 0.15s ease;
    height: 100%;
}

.editor-container:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
}

.editor-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--soft-border);
    background: var(--surface-alt);
    flex-shrink: 0;
}

.header-buttons {
    display: flex;
    gap: 12px;
    align-items: center;
}

.editor-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.status {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--muted);
    min-height: 1.4em;
}

.status.success {
    color: var(--success);
    font-weight: 600;
}

.status.error {
    color: var(--danger);
    font-weight: 600;
}

.CodeMirror {
    flex: 1;
    height: 100% !important;
    font-size: 0.95rem;
    line-height: 1.6;
    background: #ffffff;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
}

.CodeMirror-scroll {
    padding: 20px 24px;
    height: 100%;
}

.CodeMirror-gutters {
    display: none !important;
}

.CodeMirror-linenumber {
    display: none !important;
}

.CodeMirror-cursor {
    border-left: 2px solid var(--accent) !important;
}

.CodeMirror-selected {
    background: rgba(8, 145, 178, 0.15) !important;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 13px 28px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: 1px solid transparent;
    background: var(--surface);
    color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: all 0.15s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.btn:focus-visible {
    outline: 3px solid var(--accent-soft);
    outline-offset: 2px;
}

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

.btn-primary {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}

.btn-primary:hover {
    background: var(--accent-hover);
    border-color: var(--accent-hover);
}

.btn-success {
    background: #ffffff;
    border: 1px solid var(--success);
    color: var(--success);
}

.btn-success:hover {
    background: rgba(16, 185, 129, 0.1);
    border-color: var(--success);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    font-size: 0.875rem;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    box-shadow: none;
}

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
    background: var(--accent-soft);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.btn-primary {
    font-size: 0.875rem;
    padding: 9px 20px;
}

.btn-success {
    font-size: 0.875rem;
    padding: 9px 20px;
}

.examples {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.examples h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
}

.example-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.btn-example {
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, color 0.2s ease;
}

.btn-example:hover {
    border-color: var(--accent);
    background: var(--accent-soft);
    color: var(--accent);
}

::-webkit-scrollbar {
    width: 12px;
    height: 12px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 6px;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 6px;
    border: 3px solid #f1f5f9;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

::selection {
    background: rgba(8, 145, 178, 0.2);
    color: var(--text-primary);
}

textarea {
    font-family: inherit;
    min-height: 400px;
    height: 400px;
    padding: 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

@media (max-width: 1080px) {
    body {
        padding: 24px 18px 36px;
    }

    .editor-section {
        grid-template-columns: 1fr;
        height: auto;
        min-height: auto;
    }

    .editor-container {
        height: 450px;
    }
}

@media (max-width: 720px) {
    header h1 {
        font-size: 1.75rem;
    }

    .subtitle {
        font-size: 0.95rem;
    }

    .controls {
        grid-template-columns: 1fr;
        padding: 20px;
        gap: 16px;
    }

    .editor-section {
        gap: 16px;
    }

    .examples {
        padding: 20px;
    }
}

@media (max-width: 520px) {
    body {
        padding: 18px 14px 28px;
    }

    .btn {
        width: 100%;
    }

    .examples h3 {
        font-size: 0.98rem;
    }
}
