:root {
    color-scheme: light;
    --bg: #f5f7f8;
    --ink: #162022;
    --muted: #627073;
    --line: #d9e0e2;
    --panel: #ffffff;
    --primary: #006b63;
    --primary-dark: #004d48;
    --accent: #d9282f;
    --ok: #147a3d;
    --shadow: 0 18px 50px rgba(22, 32, 34, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--bg);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
a {
    -webkit-tap-highlight-color: transparent;
}

.shell {
    width: min(1120px, calc(100% - 32px));
    margin: 0 auto;
    padding: 32px 0 48px;
}

.intro,
.panel,
.final-panel {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.intro {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    padding: 28px;
    border-top: 5px solid var(--primary);
}

.auth-shell {
    min-height: 100vh;
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(560px, 100%);
}

.login-form {
    display: grid;
    gap: 10px;
    margin-top: 22px;
}

.login-form label {
    color: var(--muted);
    font-weight: 800;
}

.login-form input {
    min-height: 48px;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 0 12px;
    font: inherit;
}

.login-error {
    margin: 14px 0 0;
    color: #8a1c22;
    font-weight: 800;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 800;
    letter-spacing: 0;
    text-transform: uppercase;
}

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

h1 {
    margin-bottom: 10px;
    font-size: clamp(30px, 4vw, 46px);
    line-height: 1.08;
}

h2 {
    margin-bottom: 4px;
    font-size: 22px;
}

h3 {
    margin-bottom: 4px;
    font-size: 19px;
}

.lede,
.panel-head p,
.final-panel p,
.card p,
.hint {
    color: var(--muted);
}

.lede {
    margin-bottom: 0;
    max-width: 720px;
    font-size: 17px;
    line-height: 1.5;
}

.ghost-link,
button {
    min-height: 44px;
    border-radius: 8px;
    font: inherit;
    font-weight: 800;
}

.ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    padding: 0 18px;
    border: 1px solid var(--line);
    color: var(--ink);
    text-decoration: none;
}

.panel {
    margin-top: 22px;
    padding: 24px;
}

.panel-head,
.final-panel {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.cards {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    margin-top: 20px;
}

.card {
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 18px;
    background: #fbfcfc;
}

.card-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 14px;
}

.card-head p {
    margin-bottom: 0;
    line-height: 1.35;
}

.badge {
    flex: 0 0 auto;
    padding: 6px 10px;
    border-radius: 999px;
    background: #f3dfe0;
    color: #8a1c22;
    font-size: 13px;
    font-weight: 900;
}

.badge.is-signed {
    background: #dff0e7;
    color: var(--ok);
}

.signature-box {
    position: relative;
    height: 180px;
    overflow: hidden;
    border: 2px dashed #b9c5c8;
    border-radius: 8px;
    background: #fff;
    touch-action: none;
}

canvas,
.saved-signature {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

canvas {
    z-index: 2;
    cursor: crosshair;
}

.saved-signature {
    z-index: 1;
    object-fit: contain;
    padding: 18px;
    opacity: 0.82;
}

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

button {
    cursor: pointer;
    border: 0;
    padding: 0 16px;
}

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

.primary,
.generate-button {
    background: var(--primary);
    color: #fff;
}

.primary:hover,
.generate-button:hover {
    background: var(--primary-dark);
}

.secondary {
    background: #e9eef0;
    color: var(--ink);
}

.hint {
    margin: 10px 0 0;
    font-size: 13px;
}

.final-panel {
    margin-top: 22px;
    padding: 24px;
    border-left: 5px solid var(--accent);
}

.final-panel p {
    margin-bottom: 0;
}

.generate-button {
    flex: 0 0 auto;
    min-width: 260px;
}

.status {
    position: fixed;
    left: 50%;
    bottom: 24px;
    z-index: 10;
    max-width: min(620px, calc(100% - 32px));
    transform: translateX(-50%);
    border-radius: 8px;
    background: var(--ink);
    color: #fff;
    padding: 14px 18px;
    box-shadow: var(--shadow);
    opacity: 0;
    pointer-events: none;
    transition: opacity 160ms ease;
}

.status.is-visible {
    opacity: 1;
}

@media (max-width: 820px) {
    .intro,
    .panel-head,
    .final-panel {
        align-items: stretch;
        flex-direction: column;
    }

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

    .ghost-link,
    .generate-button {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .shell {
        width: min(100% - 20px, 1120px);
        padding-top: 16px;
    }

    .intro,
    .panel,
    .final-panel,
    .card {
        padding: 16px;
    }

    .actions {
        flex-direction: column;
    }
}
