@font-face {
    font-family: "TheSerifPreview";
    src: url("TheSerifLight-Plain.ttf") format("truetype");
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

:root {
    --bg: #10100f;
    --surface: #ffffff;
    --surface-soft: #f4f4ef;
    --text: #151515;
    --muted: #64645c;
    --brand: #abba5d;
    --brand-dark: #79883d;
    --danger: #b3261e;
    --border: #deded5;
    --shadow: 0 18px 45px rgba(0, 0, 0, 0.18);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--text);
    background: var(--bg);
}

button,
input,
a {
    font: inherit;
}

button,
a.download {
    min-height: 44px;
    border: 0;
    border-radius: 6px;
    padding: 0 18px;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
}

button:disabled {
    cursor: wait;
    opacity: 0.65;
}

.danger {
    background: #fff5f4;
    color: var(--danger);
    border: 1px solid rgba(179, 38, 30, 0.35);
}

.page {
    width: min(1120px, calc(100% - 28px));
    margin: 0 auto;
    padding: 24px 0 40px;
}

.panel {
    background: var(--surface);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.intro {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: flex-start;
    padding: 28px;
    margin-bottom: 16px;
}

.eyebrow {
    margin: 0 0 6px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--brand-dark);
    font-weight: 700;
    font-size: 13px;
}

h1 {
    margin: 0;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.08;
}

.lead {
    max-width: 680px;
    margin: 12px 0 0;
    color: var(--muted);
    line-height: 1.5;
}

.language-button {
    flex: 0 0 auto;
    background: var(--surface-soft);
    color: #111;
    border: 1px solid var(--border);
}

.form-panel {
    padding: 22px;
}

.form-grid {
    display: grid;
    grid-template-columns: minmax(160px, 240px) minmax(240px, 1fr);
    gap: 14px;
}

label span {
    display: block;
    margin-bottom: 7px;
    font-weight: 700;
}

input[type="text"],
input[type="number"],
input[type="file"] {
    width: 100%;
    min-height: 44px;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 9px 11px;
    background: #fff;
}

.file-field {
    grid-column: span 1;
}

.privacy-row {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    margin-top: 16px;
    line-height: 1.4;
}

.privacy-row input {
    margin-top: 3px;
}

.text-button {
    display: inline;
    min-height: 0;
    padding: 0;
    background: transparent;
    color: var(--brand-dark);
    text-decoration: underline;
    font-weight: 700;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
}

.primary {
    background: var(--brand);
    color: #111;
}

.secondary {
    background: var(--surface-soft);
    color: #111;
    border: 1px solid var(--border);
}

a.download {
    background: #111;
    color: #fff;
}

.message {
    margin-top: 16px;
    border-radius: 6px;
    padding: 12px 14px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    line-height: 1.4;
}

.message.error {
    color: var(--danger);
    border-color: rgba(179, 38, 30, 0.35);
    background: #fff5f4;
}

.editor {
    display: grid;
    grid-template-columns: minmax(260px, 430px) minmax(280px, 1fr);
    gap: 18px;
    align-items: start;
    margin-top: 18px;
}

.preview-wrap {
    background: #050505;
    border-radius: 8px;
    padding: 10px;
    box-shadow: var(--shadow);
}

canvas {
    display: block;
    width: 100%;
    height: auto;
    aspect-ratio: 9 / 16;
    background: #fff;
    border-radius: 4px;
    touch-action: none;
}

.controls {
    background: var(--surface);
    border-radius: 8px;
    padding: 18px;
    box-shadow: var(--shadow);
}

.control-group,
.range-control {
    display: block;
    margin-bottom: 18px;
}

.control-title {
    margin: 0 0 8px;
    font-weight: 700;
}

.button-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.button-grid button,
.controls button {
    background: var(--surface-soft);
    border: 1px solid var(--border);
}

.range-control input {
    width: 100%;
    accent-color: var(--brand-dark);
}

dialog {
    width: min(680px, calc(100% - 28px));
    border: 0;
    border-radius: 8px;
    padding: 0;
    box-shadow: var(--shadow);
}

dialog::backdrop {
    background: rgba(0, 0, 0, 0.55);
}

.dialog-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 16px 18px;
    border-bottom: 1px solid var(--border);
}

.dialog-head h2 {
    margin: 0;
    font-size: 22px;
}

.dialog-head button {
    width: 40px;
    min-height: 40px;
    padding: 0;
    background: var(--surface-soft);
}

.dialog-body {
    padding: 18px;
    line-height: 1.5;
}

.dialog-body h3 {
    margin: 0 0 6px;
}

.dialog-body p {
    margin: 0 0 18px;
}

@media (max-width: 820px) {
    .form-grid,
    .editor {
        grid-template-columns: 1fr;
    }

    .intro {
        flex-direction: column;
    }

    .preview-wrap {
        max-width: 430px;
        width: 100%;
        margin: 0 auto;
    }
}

@media (max-width: 560px) {
    .page {
        width: min(100% - 18px, 1120px);
        padding-top: 9px;
    }

    .intro,
    .form-panel,
    .controls {
        padding: 16px;
    }

    .button-row > * {
        width: 100%;
    }
}
