/* ==========================================
   ГЛОБАЛЬНЫЕ СБРОСЫ И ФИКСЫ РАЗМЕРОВ
   ========================================== */

*, *::before, *::after {
    box-sizing: border-box;
}

/* ==========================================
   ОСНОВНЫЕ НАСТРОЙКИ
   ========================================== */

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    background: #ffffff;
}

html, body {
    overscroll-behavior-y: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
        Roboto, Helvetica, Arial, sans-serif;

    margin: 32px 32px;
    background: #ffffff;
    color: #111111;
}

.container {
    width: 100%;
    max-width: 800px;
    margin: 0 auto;
}

/* ==========================================
   СТАТУС ЗАГРУЗКИ
   ========================================== */

#status {
    padding: 12px;
    background: #f4f4f5;
    color: #8ecae6;

    border-radius: 6px;
    margin-bottom: 16px;

    font-size: 14px;
    font-weight: bold;
    text-align: center;

    border: 1px solid #8ecae6;
    overflow-wrap: anywhere;
}

/* ==========================================
   ПАНЕЛЬ УПРАВЛЕНИЯ
   ========================================== */

.action-bar {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 8px;
}

/* ==========================================
   ПОЛЕ ВВОДА R-СКРИПТА
   ========================================== */

#code {
    display: block;
    width: 100%;

    height: 240px;
    min-height: 240px;
    max-height: none;

    padding: 14px;

    font-family: ui-monospace, SFMono-Regular, SF Mono,
        Menlo, Monaco, Consolas, monospace;

    font-size: 16px;
    line-height: 1.5;

    color: #111111;
    background: #ffffff;

    border: 1px solid #e4e4e7;
    border-radius: 6px;

    outline: none;

    resize: vertical;
    overflow: auto;

    -webkit-appearance: none;
    appearance: none;

    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

#code:focus {
    font-size: 16px;
    border-color: #a1a1aa;
    outline: none;
}

/* ==========================================
   КНОПКА ЗАПУСКА
   ========================================== */

button {
    width: 100%;
    padding: 14px;

    font-family: inherit;
    font-size: 16px;

    background: #18181b;
    color: #ffffff;

    border: none;
    border-radius: 6px;

    margin-top: 12px;

    cursor: pointer;
    font-weight: 500;

    -webkit-tap-highlight-color: transparent;
}

button:active:not(:disabled) {
    background: #27272a;
}

button:disabled {
    background: #e4e4e7;
    color: #a1a1aa;
    cursor: not-allowed;
}

/* ==========================================
   ВСПОМОГАТЕЛЬНЫЕ КНОПКИ
   ========================================== */

.btn-action {
    width: auto;
    padding: 6px 12px;
    margin: 0;

    font-family: inherit;
    font-size: 13px;

    background: #f4f4f5;
    color: #3f3f46;

    border: 1px solid #e4e4e7;
    border-radius: 6px;

    cursor: pointer;
    font-weight: 500;

    -webkit-tap-highlight-color: transparent;
}

.btn-action:active:not(:disabled) {
    background: #e4e4e7;
}

/* ==========================================
   ОБЛАСТЬ РЕЗУЛЬТАТОВ
   ========================================== */

.output-box {
    margin-top: 24px;
    padding: 16px 0;

    background: #ffffff;
    color: #18181b;

    border-top: 1px solid #e4e4e7;

    font-family: ui-monospace, SFMono-Regular, SF Mono,
        Menlo, Monaco, Consolas, monospace;

    font-size: 15px;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.output-title {
    font-weight: 600;
    color: #71717a;

    margin-bottom: 12px;

    font-family: -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 12px;

    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ==========================================
   ГРАФИКИ
   ========================================== */

.plot-container {
    width: 100%;
    margin-top: 16px;
    padding: 4px;

    background: #ffffff;

    border: 1px solid #e4e4e7;
    border-radius: 6px;

    text-align: center;
    overflow: hidden;
}

.plot-container img {
    display: block;
    width: auto;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

/* ==========================================
   СМАРТФОНЫ И ПЛАНШЕТЫ
   ========================================== */

@media screen and (max-width: 768px) {
    body {
        margin: 12px 16px;
    }

    .container {
        width: 100%;
        max-width: 100%;
    }

    #code,
    #code:focus {
        width: 100%;

        height: 280px;
        min-height: 280px;
        max-height: none;

        padding: 12px;

        font-family: ui-monospace, SFMono-Regular, SF Mono,
            Menlo, Monaco, Consolas, monospace;

        font-size: 16px !important;
        line-height: 1.5;

        resize: vertical;
        overflow: auto;

        -webkit-appearance: none;
        appearance: none;
    }

    button {
        font-size: 18px;
        padding: 16px;
    }

    .btn-action {
        font-size: 14px;
        padding: 8px 12px;
    }

    .output-box {
        font-size: 15px;
    }

    #status {
        font-size: 14px;
        padding: 10px;
    }

    .plot-container img {
        max-width: 100%;
        height: auto;
    }
}

/* ==========================================
   УЗКИЕ ЭКРАНЫ
   ========================================== */

@media screen and (max-width: 360px) {
    body {
        margin: 8px 12px;
    }

    .action-bar {
        gap: 5px;
    }

    .btn-action {
        padding: 8px 9px;
        font-size: 12px;
    }

    #code,
    #code:focus {
        height: 280px;
        min-height: 280px;
        max-height: none;

        padding: 10px;
        font-size: 16px !important;
    }
}

/* Фикс автозума на iOS для моноширинного поля ввода */
@media screen and (max-width: 768px) {
    #code,
    #code:focus {
        -webkit-text-size-adjust: none !important;
        text-size-adjust: none !important;
    }
}

.site-footer {
    margin-top: 48px;
    padding: 20px 0;
    border-top: 1px solid #e4e4e7;
    text-align: center;
    font-size: 13px;
    color: #71717a;
}

.footer-credit {
    margin: 0;
}

.footer-credit a {
    color: #18181b;
    text-decoration: none;
    font-weight: 500;
}

.footer-credit a:hover {
    text-decoration: underline;
}


/* ==========================================
   Подсветка R в редакторе — своя палитра
   ========================================== */

#code .hljs {
    background: transparent;
    color: #18181b;
}

#code .hljs-keyword,
#code .hljs-built_in,
#code .hljs-function {
    color: #7c3aed;              /* ключевые слова: function, if, for */
}

#code .hljs-string {
    color: #15803d;              /* строки: "текст в кавычках" */
}

#code .hljs-number,
#code .hljs-literal {
    color: #b45309;              /* числа, TRUE/FALSE, NULL */
}

#code .hljs-comment {
    color: #a1a1aa;              /* комментарии: # вот такой */
    font-style: italic;
}

#code .hljs-attribute,
#code .hljs-variable {
    color: #0e7490;              /* имена и параметры */
}

#code .hljs-operator,
#code .hljs-punctuation {
    color: #52525b;              /* <-, скобки, запятые */
}
