:root {
    --page-bg-1: #0f172a;
    --page-bg-2: #241c2b;
    --page-bg-3: #5b3920;
    --panel: #ffffff;
    --paper: #fffaf1;
    --paper-2: #fffdf8;
    --ink: #17130f;
    --muted: #70675d;
    --border: #e7d9c2;
    --gold: #b98745;
    --gold-dark: #7d5127;
    --accent: #284b63;
    --accent-2: #0f766e;
    --error: #a62020;
    --shadow: 0 24px 70px rgb(0 0 0 / 22%);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(circle at 20% 12%, rgb(255 255 255 / 14%), transparent 28%),
        radial-gradient(circle at 85% 8%, rgb(255 215 128 / 16%), transparent 26%),
        linear-gradient(135deg, var(--page-bg-1) 0%, var(--page-bg-2) 50%, var(--page-bg-3) 100%);
}

main {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 36px 0 48px;
}

body.certificate-page main {
    display: grid;
    width: min(980px, calc(100% - 24px));
    min-height: 100vh;
    place-items: center;
    padding: clamp(12px, 3vw, 36px) 0;
}

body.certificate-page .certificate {
    width: 100%;
}

.hero {
    display: flex;
    justify-content: space-between;
    align-items: end;
    gap: 24px;
    margin-bottom: 24px;
    color: white;
}

.page-title {
    margin: 0;
    font-size: clamp(2.1rem, 5vw, 4.6rem);
    letter-spacing: -0.05em;
    line-height: 0.95;
}

.page-subtitle {
    max-width: 520px;
    margin: 12px 0 0;
    color: rgb(255 255 255 / 78%);
    font-size: 1.02rem;
    line-height: 1.6;
}

.layout {
    display: grid;
    grid-template-columns: minmax(320px, 390px) minmax(0, 1fr);
    gap: 28px;
    align-items: start;
}

.panel {
    padding: 22px;
    border: 1px solid rgb(255 255 255 / 45%);
    border-radius: 24px;
    background: rgb(255 255 255 / 92%);
    box-shadow: 0 18px 50px rgb(0 0 0 / 18%);
}

.panel h2 {
    margin: 0 0 16px;
    font-size: 1.35rem;
    letter-spacing: -0.02em;
}

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

input[type="text"],
input[type="number"] {
    width: 100%;
    min-height: 46px;
    padding: 11px 13px;
    border: 1px solid #cfc4b4;
    border-radius: 14px;
    font: inherit;
    color: var(--ink);
    background: #fffdf8;
    transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

input[type="range"] {
    width: 100%;
    accent-color: var(--accent-2);
}

input:focus {
    outline: none;
    border-color: var(--accent-2);
    box-shadow: 0 0 0 4px rgb(15 118 110 / 17%);
    background: white;
}

.field {
    margin-bottom: 17px;
}

.range-row {
    display: grid;
    grid-template-columns: 1fr 86px;
    gap: 12px;
    align-items: center;
}

.hint {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 0.92rem;
    line-height: 1.45;
}

.error {
    margin: 7px 0 0;
    color: var(--error);
    font-weight: 750;
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #e0a0a0;
    border-radius: 14px;
    color: var(--error);
    background: #fff0f0;
}

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

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 11px 16px;
    border: 0;
    border-radius: 999px;
    font: inherit;
    font-weight: 800;
    text-decoration: none;
    color: white;
    background: linear-gradient(135deg, var(--accent), #0f766e);
    cursor: pointer;
    box-shadow: 0 10px 22px rgb(15 118 110 / 24%);
}

.certificate {
    position: relative;
    overflow: hidden;
    overflow-wrap: anywhere;
    min-height: 620px;
    padding: clamp(18px, 3vw, 28px);
    border-radius: 32px;
    background:
        radial-gradient(circle at 18% 18%, rgb(255 255 255 / 92%), transparent 30%),
        linear-gradient(135deg, var(--paper-2) 0%, var(--paper) 48%, #f5e6d0 100%);
    box-shadow: var(--shadow);
    text-align: center;
    isolation: isolate;
}

.certificate::before {
    content: "";
    position: absolute;
    inset: 18px;
    border: 1px solid rgb(185 135 69 / 62%);
    border-radius: 24px;
    pointer-events: none;
    z-index: 2;
}

.certificate::after {
    content: "";
    position: absolute;
    inset: 31px;
    border: 1px dashed rgb(125 81 39 / 30%);
    border-radius: 18px;
    pointer-events: none;
    z-index: 2;
}

.certificate-decoration {
    position: absolute;
    inset: auto -80px -100px auto;
    width: 300px;
    height: 300px;
    border-radius: 50%;
    background: radial-gradient(circle, rgb(185 135 69 / 22%), transparent 67%);
    z-index: 0;
}

.certificate-inner {
    position: relative;
    z-index: 1;
    display: flex;
    min-height: 564px;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(30px, 5vw, 62px) clamp(22px, 5vw, 66px);
}

.cert-kicker {
    margin: 0 0 16px;
    color: var(--gold-dark);
    font-size: clamp(0.72rem, 1.5vw, 0.82rem);
    font-weight: 800;
    letter-spacing: 0.28em;
    text-transform: uppercase;
}

.certificate h2 {
    margin: 0;
    max-width: 820px;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.35rem, 6.5vw, 5.2rem);
    line-height: 0.98;
    letter-spacing: -0.055em;
}

.cert-rule {
    width: min(360px, 68%);
    height: 2px;
    margin: 26px 0 30px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.cert-intro,
.cert-label {
    margin: 0;
    color: #55483a;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.08rem, 2.6vw, 1.55rem);
    font-style: italic;
    line-height: 1.5;
}

.cert-person {
    margin: 12px 0 14px;
    max-width: 100%;
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(2.05rem, 7vw, 4.4rem);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.04em;
}

.cert-reason {
    max-width: 720px;
    margin: 16px 0 0;
    padding: 12px 20px;
    border: 1px solid rgb(185 135 69 / 24%);
    border-radius: 999px;
    color: #33291e;
    background: rgb(255 255 255 / 56%);
    font-family: Georgia, "Times New Roman", serif;
    font-size: clamp(1.25rem, 3.8vw, 2.3rem);
    line-height: 1.22;
}

.cert-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: end;
    justify-content: center;
    gap: 26px 42px;
    margin-top: 38px;
}

.cert-seal {
    display: grid;
    width: clamp(106px, 18vw, 132px);
    height: clamp(106px, 18vw, 132px);
    place-content: center;
    border: 2px solid rgb(125 81 39 / 28%);
    border-radius: 50%;
    color: #4f2d10;
    background:
        radial-gradient(circle at 32% 24%, #fff5d8 0 24%, transparent 25%),
        linear-gradient(135deg, #e7c07a, #b98745 55%, #845526);
    box-shadow: 0 16px 28px rgb(125 81 39 / 22%);
    transform: rotate(-5deg);
    font-family: Georgia, "Times New Roman", serif;
}

.cert-seal span,
.cert-seal b {
    display: inline;
    font-size: clamp(2rem, 4vw, 2.6rem);
    line-height: 0.95;
}

.cert-seal small {
    display: block;
    margin-top: 5px;
    font-family: Inter, ui-sans-serif, system-ui, sans-serif;
    font-size: 0.72rem;
    font-weight: 850;
    letter-spacing: 0.18em;
    text-transform: uppercase;
}

.cert-date {
    min-width: 170px;
    padding-top: 13px;
    border-top: 2px solid rgb(125 81 39 / 35%);
    font-family: Georgia, "Times New Roman", serif;
}

.cert-date span {
    display: block;
    color: #5d5044;
    font-size: 1.08rem;
    font-style: italic;
}

.cert-date strong {
    display: block;
    margin-top: 4px;
    font-size: clamp(1.35rem, 3.2vw, 1.8rem);
}

.not-found {
    max-width: 680px;
    margin: 0 auto;
    text-align: center;
}

@media (max-width: 860px) {
    main {
        width: min(100% - 22px, 1180px);
        padding: 22px 0 34px;
    }

    .hero {
        display: block;
    }

    .layout {
        grid-template-columns: 1fr;
    }

    .certificate,
    .certificate-inner {
        min-height: auto;
    }
}

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

    .cert-reason {
        border-radius: 22px;
    }

    .certificate::before {
        inset: 12px;
    }

    .certificate::after {
        inset: 22px;
    }
}

@media print {
    body {
        background: white;
    }

    main {
        width: 100%;
        padding: 0;
    }

    .hero,
    .panel {
        display: none !important;
    }

    .certificate {
        min-height: 95vh;
        border-radius: 0;
        box-shadow: none;
    }
}
