:root {
  /* MD3 Color Tokens */
  --md-sys-color-primary: #6750A4;
  --md-sys-color-on-primary: #FFFFFF;
  --md-sys-color-primary-container: #EADDFF;
  --md-sys-color-on-primary-container: #21005D;
  --md-sys-color-secondary: #625B71;
  --md-sys-color-on-secondary: #FFFFFF;
  --md-sys-color-secondary-container: #E8DEF8;
  --md-sys-color-on-secondary-container: #1D192B;
  --md-sys-color-surface: #FFFBFE;
  --md-sys-color-surface-variant: #E7E0EC;
  --md-sys-color-on-surface: #1C1B1F;
  --md-sys-color-outline: #79747E;
  --md-sys-color-error: #B3261E;
  --md-sys-color-on-error: #FFFFFF;
  --md-sys-color-error-container: #F9DEDC;
  
  /* Elevation */
  --md-elevation-level-1: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 1px 3px 1px rgba(0, 0, 0, 0.15);
  --md-elevation-level-2: 0 1px 2px 0 rgba(0, 0, 0, 0.3), 0 2px 6px 2px rgba(0, 0, 0, 0.15);
  
  /* Shape */
  --md-shape-corner-extra-small: 4px;
  --md-shape-corner-small: 8px;
  --md-shape-corner-medium: 12px;
  --md-shape-corner-large: 16px;
  
  /* Typography */
  --md-sys-typescale-body-large-font: 'Roboto', sans-serif;
  --md-sys-typescale-body-large-weight: 400;
  --md-sys-typescale-body-large-size: 16px;
  --md-sys-typescale-body-large-line-height: 24px;
  
  --md-sys-typescale-headline-small-font: 'Roboto', sans-serif;
  --md-sys-typescale-headline-small-weight: 400;
  --md-sys-typescale-headline-small-size: 24px;
  --md-sys-typescale-headline-small-line-height: 32px;

  /* Spacing */
  --md-sys-spacing-small: 8px;
  --md-sys-spacing-medium: 16px;
  --md-sys-spacing-large: 24px;
}

/* Базовые стили */
body {
    font-family: var(--md-sys-typescale-body-large-font);
    font-weight: var(--md-sys-typescale-body-large-weight);
    font-size: var(--md-sys-typescale-body-large-size);
    line-height: var(--md-sys-typescale-body-large-line-height);
    background-color: var(--md-sys-color-surface-variant);
    color: var(--md-sys-color-on-surface);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: var(--md-sys-spacing-medium);
    margin: 0;
    min-height: 100vh;
    box-sizing: border-box;
}

#app-container {
    background-color: var(--md-sys-color-surface);
    padding: var(--md-sys-spacing-large);
    border-radius: var(--md-shape-corner-large);
    box-shadow: var(--md-elevation-level-2);
    width: 100%;
    max-width: 840px;
    margin: var(--md-sys-spacing-medium) 0;
}

/* Заголовки */
h1, h2 {
    font-family: var(--md-sys-typescale-headline-small-font);
    font-weight: var(--md-sys-typescale-headline-small-weight);
    font-size: var(--md-sys-typescale-headline-small-size);
    line-height: var(--md-sys-typescale-headline-small-line-height);
    color: var(--md-sys-color-on-surface);
    border-bottom: 1px solid var(--md-sys-color-outline);
    padding-bottom: var(--md-sys-spacing-medium);
    margin: 0 0 var(--md-sys-spacing-large) 0;
}

/* Секции */
.control-section {
    margin-bottom: var(--md-sys-spacing-large);
}

.input-group {
    margin-bottom: var(--md-sys-spacing-medium);
}

/* Формы */
label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--md-sys-spacing-small);
    color: var(--md-sys-color-on-surface);
}

input[type="file"] {
    width: 94%;
    padding: 12px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-shape-corner-small);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-size: 16px;
    transition: border-color 0.2s;
}

input[type="file"]:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 2px rgba(103, 80, 164, 0.2);
}

/* Кнопки */
button {
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 500;
    border-radius: var(--md-shape-corner-large);
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    height: 48px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

button:hover:not(:disabled) {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 100%, black 8%);
    box-shadow: var(--md-elevation-level-1);
}

button:active:not(:disabled) {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 100%, black 12%);
}

button:disabled {
    background-color: color-mix(in srgb, var(--md-sys-color-on-surface) 12%, transparent);
    color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
    cursor: not-allowed;
}

/* Статус и результаты */
#status {
    margin: var(--md-sys-spacing-large) 0;
    padding: var(--md-sys-spacing-medium);
    background-color: var(--md-sys-color-secondary-container);
    color: var(--md-sys-color-on-secondary-container);
    border-radius: var(--md-shape-corner-small);
    font-style: italic;
}

#results-container {
    margin-top: var(--md-sys-spacing-large);
    display: none;
}

#visual-output {
    margin-bottom: var(--md-sys-spacing-large);
    text-align: center;
    border: 1px dashed var(--md-sys-color-outline);
    padding: var(--md-sys-spacing-medium);
    border-radius: var(--md-shape-corner-medium);
}

#outputCanvas {
    max-width: 100%;
    height: auto;
    border-radius: var(--md-shape-corner-small);
}

#report {
    background-color: var(--md-sys-color-surface-variant);
    padding: var(--md-sys-spacing-medium);
    border-radius: var(--md-shape-corner-medium);
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: 'Roboto Mono', monospace;
    font-size: 14px;
    border: 1px solid var(--md-sys-color-outline);
    color: var(--md-sys-color-on-surface);
    overflow-x: auto;
}

/* Выпадающие списки */
.input-row {
    display: flex;
    flex-direction: column;
    gap: var(--md-sys-spacing-medium);
}

.input-row .input-group {
    flex: 1;
    width: 100%;
}

select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--md-sys-color-outline);
    border-radius: var(--md-shape-corner-small);
    background-color: var(--md-sys-color-surface);
    color: var(--md-sys-color-on-surface);
    font-size: 16px;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%2379747E'%3e%3cpath d='M7 10l5 5 5-5z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 24px;
}

select:focus {
    outline: none;
    border-color: var(--md-sys-color-primary);
    box-shadow: 0 0 0 2px rgba(103, 80, 164, 0.2);
}

select:disabled {
    background-color: var(--md-sys-color-surface-variant);
    color: color-mix(in srgb, var(--md-sys-color-on-surface) 38%, transparent);
}

/* Анимации */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

#results-container[style*="display: block"] {
    animation: fadeIn 0.3s ease-out;
}

/* Медиа-запросы для мобильных устройств */
@media (max-width: 600px) {
    .file-upload-button {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .file-name {
        max-width: 100%;
        margin-left: 0;
    }
    
    .md-icon-button {
        width: 90%;
        justify-content: center;
    }
}


@media (max-width: 400px) {
    :root {
        --md-sys-spacing-small: 4px;
        --md-sys-spacing-medium: 4px;
        --md-sys-spacing-large: 12px;
    }

    h1, h2 {
        font-size: 18px;
        line-height: 24px;
        padding-bottom: var(--md-sys-spacing-small);
        margin-bottom: var(--md-sys-spacing-medium);
    }

    button {
        height: 40px;
    }
}

.md-icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: var(--md-sys-color-primary);
    color: var(--md-sys-color-on-primary);
    border: none;
    padding: 12px 16px;
    font-size: 14px;
    font-weight: 500;
    border-radius: var(--md-shape-corner-large);
    cursor: pointer;
    transition: all 0.2s;
    gap: 8px;
    box-shadow: var(--md-elevation-level-1);
}

.md-icon-button:hover {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 100%, black 8%);
    box-shadow: var(--md-elevation-level-2);
}

.md-icon-button:active {
    background-color: color-mix(in srgb, var(--md-sys-color-primary) 100%, black 12%);
}

.md-icon-button .material-icons {
    font-size: 20px;
}

/* Стили для контейнера кнопки загрузки */
.file-upload-button {
    display: flex;
    align-items: center;
}

.file-name {
    font-size: 14px;
    color: var(--md-sys-color-outline);
    margin-left: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
}

#processButton {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}