* {
    box-sizing: border-box;
}

:root {
    font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif;
    line-height: 1.5;
    font-weight: 400;
    font-synthesis: none;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-text-size-adjust: 100%;

    /* Light theme (default) */
    --bg-primary: #ffffff;
    --bg-secondary: rgba(0, 0, 0, 0.05);
    --bg-tertiary: rgba(0, 0, 0, 0.05);
    --text-primary: #213547;
    --text-secondary: #213547;
    --text-error: #dc3545;
    --border-primary: #ddd;
    --border-secondary: #ccc;
    --border-focus: #0d0df2;
    --shadow-focus: rgba(100, 108, 255, 0.2);
    --shadow-error: rgba(220, 53, 69, 0.2);
    --link-hover: #0d0df2;
}

@media (prefers-color-scheme: dark) {
    :root {
        /* Dark theme (system preference) */
        --bg-primary: #242424;
        --bg-secondary: rgba(255, 255, 255, 0.05);
        --bg-tertiary: rgba(255, 255, 255, 0.1);
        --text-primary: rgba(255, 255, 255, 0.87);
        --text-secondary: rgba(255, 255, 255, 0.6);
        --text-error: #ff6b6b;
        --border-primary: #333;
        --border-secondary: #555;
        --border-focus: #4dabf7;
        --shadow-focus: rgba(77, 171, 247, 0.2);
        --shadow-error: rgba(255, 107, 107, 0.2);
        --link-hover: #4dabf7;
    }
}

[data-theme="dark"] {
    /* Dark theme (explicit) */
    --bg-primary: #242424;
    --bg-secondary: rgba(255, 255, 255, 0.05);
    --bg-tertiary: rgba(255, 255, 255, 0.1);
    --text-primary: rgba(255, 255, 255, 0.87);
    --text-secondary: rgba(255, 255, 255, 0.6);
    --text-error: #ff6b6b;
    --border-primary: #333;
    --border-secondary: #555;
    --border-focus: #4dabf7;
    --shadow-focus: rgba(77, 171, 247, 0.2);
    --shadow-error: rgba(255, 107, 107, 0.2);
    --link-hover: #4dabf7;
}

[data-theme="light"] {
    /* Light theme (explicit) */
    --bg-primary: #ffffff;
    --bg-secondary: rgba(0, 0, 0, 0.05);
    --bg-tertiary: rgba(0, 0, 0, 0.05);
    --text-primary: #213547;
    --text-secondary: #213547;
    --text-error: #dc3545;
    --border-primary: #ddd;
    --border-secondary: #ccc;
    --border-focus: #0d0df2;
    --shadow-focus: rgba(100, 108, 255, 0.2);
    --shadow-error: rgba(220, 53, 69, 0.2);
    --link-hover: #0d0df2;
}

a {
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: inherit;
}

a:hover {
    color: var(--link-hover);
}

body {
    margin: 0;
    padding: 0;
    display: flex;
    place-items: center;
    min-width: 320px;
    min-height: 100vh;
    height: 100vh;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
    overflow: hidden;
    max-width: 100vw;
    width: 100vw;
}

h1 {
    font-size: 1.5em;
    line-height: 1;
    margin-bottom: 1rem;
}

h1 a {
    color: inherit;
    text-decoration: none;
}

#app {
    max-width: 100%;
    width: 100%;
    margin: 0 auto;
    padding: 1rem;
    text-align: center;
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-sizing: border-box;
    max-width: 100vw;
    width: 100vw;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
    box-sizing: border-box;
    max-width: 100%;
}

.form-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
}

.fields-container {
    display: flex;
    gap: 1rem;
    flex: 1;
    min-height: 0;
    height: 100%;
    overflow: hidden;
    box-sizing: border-box;
    max-width: 100%;
    width: 100%;
}

.field-group {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-primary);
    border-radius: 8px;
    background: var(--bg-secondary);
    padding: 0.5em 1em;
    min-height: 0;
    transition: border-color 0.3s ease, background-color 0.3s ease;
    overflow: hidden;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    width: 100%;
}

.schema-field {
    flex: 2 1 0;
    min-width: 0;
}

.boc-field {
    flex: 1 1 0;
    min-width: 0;
}

.data-field {
    flex: 2 1 0;
    min-width: 0;
}

.field-group label {
    display: block;
    margin-bottom: 0.5em;
    font-weight: 500;
    text-align: left;
    flex-shrink: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    overflow: hidden;
}

.label-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5em;
    min-width: 0;
    max-width: 100%;
    overflow: hidden;
}

.label-row label {
    margin-bottom: 0;
    flex-shrink: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 60%;
    overflow: hidden;
}

.field-group textarea {
    flex: 1;
    border: 1px solid var(--border-secondary);
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
    resize: none;
    min-height: 0;
    height: 100%;
    transition: border-color 0.3s ease, background-color 0.3s ease, color 0.3s ease;
    overflow: auto;
    box-sizing: border-box;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    word-wrap: break-word;
    overflow-wrap: break-word;
    white-space: pre-wrap;
}

.field-group textarea:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--shadow-focus);
}

.field-group textarea.field-error-border {
    border-color: var(--text-error);
    box-shadow: 0 0 0 2px var(--shadow-error);
}

.field-error {
    display: inline-block;
    margin-left: 1em;
    color: var(--text-error);
    font-size: 0.9em;
    font-weight: 500;
    flex-shrink: 0;
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.logo {
    height: 1.42em;
    padding: 0.25em;
    will-change: filter;
    transition: filter 300ms;
    margin-top: 1rem;
    flex-shrink: 0;
}

.logo:hover {
    filter: drop-shadow(0 0 1em var(--link-hover));
}



@media (max-width: 768px) {
    .fields-container {
        flex-direction: column;
        gap: 0.5rem;
    }

    .schema-field,
    .boc-field,
    .data-field {
        flex: none;
        min-height: 200px;
        width: 100%;
    }

    .field-group textarea {
        min-height: 150px;
        width: 100%;
    }

    #app {
        padding: 0.5rem;
    }

    .field-error {
        max-width: 150px;
    }


}

@media (max-width: 1024px) and (min-width: 769px) {
    .schema-field { flex: 2 1 0; }
    .boc-field { flex: 1 1 0; }
    .data-field { flex: 2 1 0; }
}

@media (max-width: 900px) and (min-width: 769px) {
    .fields-container {
        gap: 0.5rem;
    }

    .field-group {
        padding: 0.3em 0.6em;
    }

    .schema-field {
        flex: 0 0 36%;
    }

    .boc-field {
        flex: 0 0 28%;
    }

    .data-field {
        flex: 0 0 36%;
    }
}

@media (max-width: 480px) {
    #app {
        padding: 0.25rem;
        max-width: 100vw;
        width: 100vw;
    }

    .app-container {
        max-width: 100vw;
        width: 100vw;
    }

    .form-container {
        max-width: 100vw;
        width: 100vw;
    }

    .fields-container {
        gap: 0.25rem;
        max-width: 100vw;
        width: 100vw;
    }

    .field-group {
        padding: 0.25em 0.5em;
        max-width: 100vw;
        width: 100vw;
    }

    .schema-field,
    .boc-field,
    .data-field {
        max-width: 100vw;
        width: 100vw;
    }

    .field-group textarea {
        max-width: 100vw;
        width: 100vw;
    }

    .field-error {
        max-width: 120px;
        font-size: 0.8em;
    }
}
