:root {
    color-scheme: light dark;

    --background:
        var(--tg-theme-bg-color, #f3f4f6);

    --card:
        var(--tg-theme-secondary-bg-color, #ffffff);

    --text:
        var(--tg-theme-text-color, #1f2937);

    --hint:
        var(--tg-theme-hint-color, #6b7280);

    --button:
        var(--tg-theme-button-color, #2481cc);

    --button-text:
        var(--tg-theme-button-text-color, #ffffff);

    --border: rgba(127, 127, 127, 0.25);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    background: var(--background);
    color: var(--text);

    font-family:
        -apple-system,
        BlinkMacSystemFont,
        "Segoe UI",
        sans-serif;
}

.container {
    width: min(760px, 100%);
    margin: 0 auto;
    padding: 18px;
}

header {
    display: flex;
    gap: 14px;
    align-items: center;
    margin-bottom: 18px;
}

.logo {
    display: grid;
    place-items: center;

    width: 52px;
    height: 52px;

    border-radius: 15px;
    background: var(--button);

    font-size: 26px;
}

h1,
h2,
p {
    margin-top: 0;
}

h1 {
    margin-bottom: 4px;
    font-size: 23px;
}

header p {
    margin-bottom: 0;
    color: var(--hint);
    font-size: 14px;
}

.card {
    margin-bottom: 16px;
    padding: 18px;

    border: 1px solid var(--border);
    border-radius: 16px;

    background: var(--card);
}

label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 600;
}

textarea,
select {
    width: 100%;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--background);
    color: var(--text);

    font: inherit;
}

textarea {
    min-height: 190px;
    padding: 14px;
    resize: vertical;
}

select {
    min-height: 44px;
    padding: 8px 10px;
}

.counter {
    margin-top: 6px;
    color: var(--hint);
    font-size: 12px;
    text-align: right;
}

.options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin: 16px 0;
}

button {
    width: 100%;
    min-height: 48px;

    border: 0;
    border-radius: 12px;

    background: var(--button);
    color: var(--button-text);

    font: inherit;
    font-weight: 700;

    cursor: pointer;
}

button:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

button.secondary {
    width: auto;
    min-height: 40px;
    padding: 0 18px;
}

.result-header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
}

.result-header h2 {
    margin-bottom: 0;
}

pre {
    margin: 16px 0 0;
    padding: 14px;

    border: 1px solid var(--border);
    border-radius: 12px;

    background: var(--background);
    color: var(--text);

    font-family: inherit;
    line-height: 1.5;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.message {
    margin-top: 12px;
    padding: 12px;
    border-radius: 10px;
    font-size: 14px;
}

.error {
    background: rgba(220, 38, 38, 0.12);
}

.hidden {
    display: none;
}

@media (max-width: 520px) {
    .options {
        grid-template-columns: 1fr;
    }
}
