/* Minimal hand-rolled styling for Kontract.
 * Single stylesheet — no build step. Mirrors the schedule_app palette
 * (near-black ink, subtle green accent, off-white background) so the
 * generated PDF and the web pages feel like one product.
 */

:root {
    --ink: #1A1A1A;
    --ink-2: #5F5E5A;
    --ink-3: #888780;
    --hairline: #E5E5E5;
    --hairline-strong: #CFCFCF;
    --bg: #FAFAF8;
    --card-bg: #FFFFFF;
    --accent: #0F6E56;
    --accent-pale: #E1F5EE;
    --danger: #B42318;
    --danger-bg: #FEF3F2;
    --radius: 10px;
}

* { box-sizing: border-box; }
/* The HTML5 `hidden` attribute should always win — without this,
 * .btn's `display: inline-block` rule (and similar element-level
 * display values) override the browser default and leave hidden
 * buttons visible. !important here is the standard fix. */
[hidden] { display: none !important; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: var(--ink);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---------- Top chrome --------------------------------------------------- */
.topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 28px;
    background: #fff;
    border-bottom: 0.5px solid var(--hairline);
    position: relative;     /* anchors the mobile dropdown menu */
}
.brand {
    font-weight: 700;
    font-size: 16px;
    color: var(--ink);
    margin-right: auto;     /* pins brand left, pushes everything else right */
}
.brand:hover { text-decoration: none; }

/* Language toggle and nav-menu live to the right of the brand. The
 * brand's `margin-right: auto` consumes all free space, so these two
 * land flush against the right edge with the default flex gap between
 * them. */
.topbar-lang { /* no margin needed — brand pushes it right */ }

/* `.nav-menu` holds the hamburger + the inline nav. On desktop the
 * <nav> renders inline and the <button> toggle is hidden; on mobile
 * the <nav> hides until the button flips an `is-open` class on it. */
.nav-menu { position: relative; }

.nav-menu-toggle {
    display: none;     /* shown only on mobile */
    background: none;
    border: none;
    padding: 6px 10px;
    border-radius: 8px;
    cursor: pointer;
    line-height: 1;
    color: var(--ink);
}
.nav-menu-toggle:hover { background: var(--bg); }
.hamburger-icon { font-size: 20px; line-height: 1; }

.nav-menu-items {
    display: flex;
    gap: 18px;
    align-items: center;
}
.nav-menu-items a,
.nav-menu-items button { font-size: 13px; color: var(--ink-2); }

.inline-form { display: inline; margin: 0; }
.btn-link {
    background: none; border: none; padding: 0; cursor: pointer;
    font: inherit; color: var(--ink-2);
}
.btn-link:hover { color: var(--ink); }

/* Pill-shaped language toggle with a sliding accent indicator. The
 * slider's translateX is driven by `data-lang` on the wrapper; JS
 * animates it on click then submits the form. */
.lang-pill {
    position: relative;
    display: inline-flex;
    background: var(--bg);
    border: 0.5px solid var(--hairline-strong);
    border-radius: 999px;
    padding: 2px;
    font-size: 11px;
    user-select: none;
}
.lang-slider {
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 2px;
    width: calc(50% - 2px);
    background: var(--accent);
    border-radius: 999px;
    transition: transform 0.22s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
    pointer-events: none;
}
.lang-pill[data-lang="ko"] .lang-slider { transform: translateX(0); }
.lang-pill[data-lang="en"] .lang-slider { transform: translateX(100%); }

.lang-option {
    position: relative;
    z-index: 2;
    border: none;
    background: transparent;
    padding: 5px 14px;
    font: inherit;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: var(--ink-2);
    cursor: pointer;
    border-radius: 999px;
    transition: color 0.22s ease;
    white-space: nowrap;
}
.lang-pill[data-lang="ko"] .lang-option[data-lang="ko"],
.lang-pill[data-lang="en"] .lang-option[data-lang="en"] {
    color: white;
}
.lang-option:hover { color: var(--ink); }
.lang-pill[data-lang="ko"] .lang-option[data-lang="ko"]:hover,
.lang-pill[data-lang="en"] .lang-option[data-lang="en"]:hover {
    color: white;
}

/* ---------- Layout ------------------------------------------------------- */
.container { max-width: 960px; margin: 0 auto; padding: 24px 28px 80px; }
.auth-card { max-width: 380px; margin: 60px auto; }

.page-title { font-size: 22px; font-weight: 700; margin: 0 0 4px; }
.page-subtitle { color: var(--ink-2); margin: 0 0 20px; font-size: 13px; }
.section-title { font-size: 13px; font-weight: 700; color: var(--ink-3); letter-spacing: 0.04em; text-transform: uppercase; margin: 0 0 8px; }
.micro-label { font-size: 11px; font-weight: 700; color: var(--accent); letter-spacing: 0.04em; text-transform: uppercase; }

/* ---------- Cards -------------------------------------------------------- */
.card {
    background: var(--card-bg);
    border: 0.5px solid var(--hairline);
    border-radius: var(--radius);
    padding: 18px 20px;
}
.card + .card { margin-top: 14px; }
.card-compact { padding: 12px 14px; }
.stack > * + * { margin-top: 12px; }

/* ---------- Buttons ------------------------------------------------------ */
.btn {
    display: inline-block;
    padding: 9px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: 8px;
    border: 0.5px solid transparent;
    cursor: pointer;
    line-height: 1.2;
}
.btn-primary {
    background: var(--accent);
    color: white;
}
.btn-primary:hover { background: #0c5a47; text-decoration: none; color: white; }
.btn-ghost {
    background: white;
    color: var(--ink);
    border-color: var(--hairline-strong);
}
.btn-ghost:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.btn-danger {
    background: white;
    color: var(--danger);
    border-color: var(--hairline-strong);
}
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Social-login button + "or" divider on the auth pages. */
.btn-oauth { display: inline-flex; align-items: center; gap: 8px; }
.btn-oauth svg { display: block; }
.oauth-divider {
    display: flex; align-items: center; gap: 12px;
    margin: 16px 0; color: var(--ink-3); font-size: 12px;
}
.oauth-divider::before, .oauth-divider::after {
    content: ""; flex: 1; height: 0.5px; background: var(--hairline);
}

/* ---------- Form fields -------------------------------------------------- */
.field { display: block; }
.field + .field { margin-top: 12px; }
.field-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--ink-2);
    margin-bottom: 4px;
}
.field-input {
    display: block;
    width: 100%;
    padding: 8px 10px;
    font-size: 14px;
    border: 0.5px solid var(--hairline-strong);
    border-radius: 8px;
    background: white;
    color: var(--ink);
    font-family: inherit;
}
.field-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-pale);
}
textarea.field-input { min-height: 80px; resize: vertical; line-height: 1.5; }
.field-help { font-size: 12px; color: var(--ink-3); margin: 4px 0 0; }
.field-errors { color: var(--danger); font-size: 12px; margin: 4px 0 0; padding-left: 18px; }
.error-block {
    background: var(--danger-bg);
    border: 0.5px solid var(--danger);
    color: var(--danger);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
}

/* ---------- Lists -------------------------------------------------------- */
.list { list-style: none; padding: 0; margin: 0; }
.list-item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    padding: 14px 16px;
    border-bottom: 0.5px solid var(--hairline);
}
.list-item:last-child { border-bottom: 0; }
.list-item-title { font-weight: 600; }
.list-item-meta { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 999px;
    letter-spacing: 0.02em;
}
.badge-ok { background: var(--accent-pale); color: var(--accent); }
.badge-pending { background: #FBEFE0; color: #92621D; }
.badge-muted { background: var(--bg); color: var(--ink-3); border: 0.5px solid var(--hairline); }
.badge-danger { background: #FCE9E6; color: var(--danger); }

/* ---------- Wizard ------------------------------------------------------ */
/* Step-by-step template creation. One step visible at a time; progress
 * tracker at top; Back / Continue / Save in a sticky footer-ish row at
 * the bottom of the card. Mobile-first: progress nodes shrink and the
 * labels hide on narrow screens. */

.wizard {
    max-width: 720px;
    margin: 0 auto;
}
.wizard-header {
    margin-bottom: 20px;
    text-align: center;
}
.wizard-header .page-title { margin-bottom: 4px; }

/* --- Progress tracker --- */
.wizard-progress {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    list-style: none;
    margin: 0 0 24px;
    padding: 0;
    counter-reset: step;
    position: relative;
}
.wizard-progress::before {
    /* Connecting line drawn behind all nodes. JS doesn't manage this —
     * it's just a static rail; node colors signal progress. */
    content: "";
    position: absolute;
    top: 14px;
    left: 14px;
    right: 14px;
    height: 2px;
    background: var(--hairline);
    z-index: 0;
}
.wizard-progress-step {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    min-width: 0;
}
.wizard-progress-node {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--card-bg);
    border: 2px solid var(--hairline-strong);
    color: var(--ink-3);
    font-size: 12px;
    font-weight: 700;
    transition: all 0.2s ease;
}
.wizard-progress-label {
    margin-top: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--ink-3);
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.wizard-progress-step.is-active .wizard-progress-node {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
    box-shadow: 0 0 0 4px var(--accent-pale);
}
.wizard-progress-step.is-active .wizard-progress-label {
    color: var(--ink);
}
.wizard-progress-step.is-completed .wizard-progress-node {
    background: var(--accent-pale);
    border-color: var(--accent);
    color: var(--accent);
}
.wizard-progress-step.is-completed .wizard-progress-label {
    color: var(--ink-2);
}

/* --- Step card --- */
.wizard-step {
    background: var(--card-bg);
    border: 0.5px solid var(--hairline);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    margin-bottom: 16px;
    min-height: 200px;
}
.wizard-step-title {
    font-size: 18px;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--ink);
}
.wizard-step-help {
    color: var(--ink-2);
    font-size: 13px;
    margin: 0 0 18px;
}
.wizard-placeholder {
    padding: 40px 16px;
    border: 1px dashed var(--hairline-strong);
    border-radius: 8px;
    text-align: center;
    color: var(--ink-3);
    font-style: italic;
    font-size: 13px;
}

/* --- Nav row --- */
.wizard-nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.wizard-nav .wizard-cancel {
    margin-right: auto;
    font-size: 12px;
}
.wizard-nav #wizard-next,
.wizard-nav #wizard-submit {
    margin-left: auto;
}

/* --- Mobile (≤ 480px) --- */
@media (max-width: 480px) {
    .wizard-progress-label {
        display: none;
    }
    .wizard-progress-step.is-active .wizard-progress-label {
        /* Only the active step's label shows on narrow screens. */
        display: block;
        position: absolute;
        top: 36px;
        left: 50%;
        transform: translateX(-50%);
        font-size: 11px;
        background: transparent;
    }
    .wizard-progress {
        margin-bottom: 40px;  /* leave room for the floating active label */
    }
    .wizard-step {
        padding: 20px 16px;
    }
    .wizard-nav {
        flex-direction: column;
        align-items: stretch;
    }
    .wizard-nav .wizard-cancel {
        order: 3;
        margin: 6px auto 0;
    }
    .wizard-nav .btn {
        width: 100%;
    }
    .wizard-nav #wizard-next,
    .wizard-nav #wizard-submit {
        margin-left: 0;
        order: 1;
    }
    .wizard-nav #wizard-back {
        order: 2;
    }
}

/* Wizard step 4 reuses the contract-preview layout but the summary
 * card is one big container — render each section as an inset block. */
.contract-preview-section {
    padding: 14px 0;
    border-bottom: 0.5px solid var(--hairline);
}
.contract-preview-section:first-child { padding-top: 0; }
.contract-preview-section:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

/* ---------- Contract preview (template detail + wizard step 4) -------- */
.contract-preview { padding: 22px 24px; }
.contract-preview + .contract-preview { margin-top: 14px; }

.intro-pair { margin-top: 14px; }
.intro-pair:first-child { margin-top: 0; }
.intro-pair + .intro-pair { margin-top: 18px; }
.intro-pair-heading {
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    margin: 0 0 8px;
}
.kv td.placeholder {
    color: var(--ink-3);
    letter-spacing: 2px;
}

.contract-clause {
    padding: 14px 0;
    border-bottom: 0.5px solid var(--hairline);
}
.contract-clause:last-child { border-bottom: 0; }

.signature-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}
@media (max-width: 540px) {
    .signature-grid { grid-template-columns: 1fr; }
}
.signature-block { display: flex; flex-direction: column; }
.signature-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 28px;
}
.signature-line {
    border-bottom: 1px solid var(--ink-2);
    margin-bottom: 28px;
}
.signature-meta {
    display: flex;
    align-items: baseline;
    gap: 8px;
}
.signature-meta-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.signature-meta-line {
    flex: 1;
    border-bottom: 1px solid var(--hairline-strong);
    height: 0;
    margin-top: 12px;
}

/* ---------- Wizard intro custom-field row builder --------------------- */
.intro-field-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 0.5px solid var(--hairline);
}
.intro-field-row:last-child { border-bottom: none; }
.intro-field-row-main {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}
.intro-field-row-main .field-input {
    flex: 1;
    min-width: 0;
}
.intro-field-required {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ink-3);
    white-space: nowrap;
    cursor: pointer;
}
.intro-field-required input[type="checkbox"] {
    accent-color: var(--accent);
}
@media (max-width: 480px) {
    .intro-field-row-main {
        flex-direction: column;
        align-items: stretch;
    }
    .intro-field-required {
        margin-top: 4px;
    }
}

/* ---------- Wizard step 6: method picker + upload zone ---------------- */
.method-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
@media (max-width: 580px) {
    .method-grid { grid-template-columns: 1fr; }
}
.method-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 14px 16px;
    border: 1px solid var(--hairline-strong);
    border-radius: var(--radius);
    background: white;
    text-align: left;
    cursor: pointer;
    font: inherit;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.method-card:hover { border-color: var(--ink-3); }
.method-card.is-active {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-pale);
}
.method-card-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.method-card-help { font-size: 12px; color: var(--ink-3); line-height: 1.4; }

/* Compact bar shown after a method has been chosen — confirms the
 * choice and exposes the "Change method" affordance without the bulk
 * of the picker cards. */
.method-active {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 14px;
    background: var(--accent-pale);
    border: 0.5px solid var(--accent);
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 13px;
}
.method-active-label { color: var(--ink-2); }
.method-active-label strong { color: var(--ink); margin-left: 4px; }
.method-active .btn-link { font-size: 12px; color: var(--accent); }
.method-active .btn-link:hover { color: var(--ink); }

.upload-zone {
    padding: 14px;
    border: 1px dashed var(--hairline-strong);
    border-radius: 8px;
    background: var(--bg);
    margin-bottom: 16px;
}
.upload-status { margin: 6px 0 0; font-size: 12px; color: var(--ink-2); }
.upload-status.error { color: var(--danger); }

/* AI questionnaire (wizard step 3, "Generate with AI" path). The
 * card mimics the rest of the wizard's `.card` look so it feels
 * integrated; status line below mirrors `.upload-status`. */
.ai-questionnaire {
    padding: 16px;
    border: 0.5px solid var(--hairline);
    border-radius: 10px;
    background: #fff;
    margin-bottom: 16px;
}
.ai-questionnaire .field { margin-bottom: 12px; }
.ai-status { margin: 10px 0 0; font-size: 12px; color: var(--ink-2); }
.ai-status.error { color: var(--danger); }

/* Available-tags reference in the clause editor. Tags are clickable
 * chips; clicking one inserts it into the active clause body. */
.tag-reference {
    border: 0.5px solid var(--hairline);
    border-radius: 8px;
    padding: 10px 12px;
    background: var(--bg);
}
.tag-reference summary {
    cursor: pointer;
    color: var(--ink);
}
.tag-list { margin-top: 8px; }
.tag-group-title {
    margin: 10px 0 4px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-2);
}
.tag-group-title:first-child { margin-top: 0; }
.tag-chip {
    display: inline-block;
    margin: 0 4px 4px 0;
    padding: 3px 8px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 12px;
    color: var(--accent);
    background: #fff;
    border: 0.5px solid var(--hairline-strong);
    border-radius: 6px;
    cursor: pointer;
}
.tag-chip:hover { background: var(--accent-pale); }
.tag-new-row {
    display: flex;
    gap: 8px;
    margin: 8px 0;
}
.tag-new-row .field-input { flex: 1; }

.wizard-clause-editor .clause-row {
    margin-bottom: 10px;
}

/* ---------- Wizard step 8: summary -------------------------------------- */
.summary-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
    border-bottom: 0.5px solid var(--hairline);
}
.summary-row:last-child { border-bottom: none; }
.summary-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    flex-shrink: 0;
}
.summary-value {
    font-size: 13px;
    color: var(--ink);
    text-align: right;
    word-break: break-word;
}

/* ---------- Wizard step content ----------------------------------------- */

/* Type-pick cards (step 1) */
.type-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}
@media (max-width: 480px) {
    .type-grid { grid-template-columns: 1fr; }
}
.type-card {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 16px 18px;
    border: 1.5px solid var(--hairline-strong);
    border-radius: var(--radius);
    background: white;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}
.type-card input[type="radio"] {
    position: absolute;
    top: 14px;
    right: 14px;
}
.type-card-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--ink);
}
.type-card-help {
    font-size: 12px;
    color: var(--ink-3);
    line-height: 1.45;
}
.type-card:has(input:checked) {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-pale);
}
.type-card-disabled {
    cursor: not-allowed;
    opacity: 0.55;
    background: var(--bg);
}

/* Field toggle list (steps 2-5) */
.field-toggle-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.field-toggle {
    padding: 12px 14px;
    border-bottom: 0.5px solid var(--hairline);
}
.field-toggle:last-child { border-bottom: none; }
.field-toggle-row {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
}
.field-toggle-row input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent);
    cursor: pointer;
    flex-shrink: 0;
}

/* Required rows — checkbox locked checked. Faint badge so the
 * "you can't turn this off" affordance is visible without being
 * shouty. */
.field-toggle-required .field-toggle-row {
    cursor: default;
}
.field-toggle-required input[type="checkbox"] {
    accent-color: var(--accent);
    opacity: 0.6;
}
.field-toggle-badge {
    margin-left: auto;
    padding: 2px 8px;
    border-radius: 999px;
    background: var(--accent-pale);
    color: var(--accent);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}
.field-toggle-help {
    font-size: 12px;
    color: var(--ink-3);
    margin: 4px 0 0 28px;
}

/* Categorical fields get an inset options box */
.field-toggle-categorical {
    background: var(--bg);
    border-radius: 8px;
    margin-bottom: 8px;
    border-bottom: none;
    padding-bottom: 14px;
}
.option-list {
    margin-top: 10px;
    margin-left: 28px;
}
.option-list-label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: var(--ink-3);
    letter-spacing: 0.04em;
    text-transform: uppercase;
    margin-bottom: 4px;
}
.option-list textarea {
    font-family: inherit;
    line-height: 1.45;
}

/* ---------- Import panel (template create/edit) ------------------------ */
.import-panel summary {
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: baseline;
    gap: 4px;
}
.import-panel summary::-webkit-details-marker { display: none; }
.import-panel summary::before {
    content: "▸";
    color: var(--ink-3);
    margin-right: 6px;
    transition: transform 0.15s ease;
    display: inline-block;
}
.import-panel[open] summary::before {
    transform: rotate(90deg);
}
.import-panel[open] > * { margin-top: 12px; }
.import-panel[open] > summary { margin-top: 0; }

.paste-zone {
    min-height: 200px;
    max-height: 480px;
    overflow-y: auto;
    padding: 12px 14px;
    border: 1px dashed var(--hairline-strong);
    border-radius: 8px;
    background: white;
    font-size: 13px;
    line-height: 1.55;
}
.paste-zone:focus {
    outline: none;
    border-color: var(--accent);
    border-style: solid;
    box-shadow: 0 0 0 3px var(--accent-pale);
}
.paste-zone:empty::before {
    content: attr(data-placeholder);
    color: var(--ink-3);
    font-style: italic;
    pointer-events: none;
}
/* Headings inside the paste zone — keep them readable so the user can
 * see what was captured as a section delimiter. */
.paste-zone h1, .paste-zone h2, .paste-zone h3,
.paste-zone h4, .paste-zone h5, .paste-zone h6 {
    margin: 14px 0 4px;
    font-weight: 700;
    line-height: 1.3;
}
.paste-zone h1 { font-size: 17px; }
.paste-zone h2 { font-size: 15px; }
.paste-zone h3, .paste-zone h4, .paste-zone h5, .paste-zone h6 { font-size: 14px; }
.paste-zone p { margin: 6px 0; }
.paste-zone ul, .paste-zone ol { margin: 6px 0 6px 22px; padding: 0; }
.paste-zone li { margin: 2px 0; }

/* ---------- Clause editor ----------------------------------------------- */
.clause-row {
    background: white;
    border: 0.5px solid var(--hairline);
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 10px;
}
.clause-row-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}
.clause-handle {
    cursor: grab;
    color: var(--ink-3);
    user-select: none;
}

/* ---------- Messages ----------------------------------------------------- */
.messages {
    list-style: none;
    padding: 0;
    margin: 16px 28px 0;
    max-width: 960px;
}
.message {
    padding: 10px 14px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 6px;
}
.message-success { background: var(--accent-pale); color: var(--accent); }
.message-error, .message-warning { background: var(--danger-bg); color: var(--danger); }
.message-info { background: #EEF4FA; color: #1d4671; }

/* ---------- Sign page (client) ------------------------------------------ */
.sign-clause {
    background: white;
    border: 0.5px solid var(--hairline);
    border-radius: var(--radius);
    padding: 16px 18px;
    margin-bottom: 10px;
}
.sign-clause-body {
    white-space: pre-wrap;
    margin: 6px 0 12px;
    line-height: 1.6;
}
.sign-clause.agreed { background: var(--accent-pale); border-color: var(--accent); }
.signature-canvas {
    width: 100%;
    height: 160px;
    display: block;
    border: 1.5px solid var(--hairline-strong);
    border-radius: 8px;
    background: white;
    touch-action: none;
    cursor: crosshair;
}
.sig-row { display: flex; justify-content: space-between; align-items: center; margin-top: 4px; }
.muted { color: var(--ink-3); }
.text-right { text-align: right; }
.whitespace-pre { white-space: pre-wrap; }

/* ---------- Tables ------------------------------------------------------ */
table.kv {
    border-collapse: collapse;
    width: 100%;
}
table.kv td {
    padding: 6px 0;
    vertical-align: top;
    font-size: 13px;
}
table.kv td:first-child {
    color: var(--ink-3);
    width: 160px;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}


/* =========================================================================
 * Mobile pass — single responsive sweep across the whole stylesheet.
 *
 * Goal: keep the visual language (whitespace, green accent, ink-on-white)
 * but tighten gutters, fix iOS' input-zoom-on-focus, stack tables, and
 * give primary tap targets the room they need on a phone.
 *
 * Breakpoints:
 *   <= 640px — phones in landscape, narrow tablets
 *   <= 480px — phones in portrait
 *   <= 380px — small phones (iPhone SE, older Android)
 * Stricter rules nest inside narrower breakpoints.
 * =======================================================================*/

@media (max-width: 640px) {
    /* --- Chrome (mobile): collapse top-nav into a hamburger --- *
     * The dropdown floats below the toggle, right-aligned, with a
     * subtle shadow. Items stack vertically inside. */
    .topbar { padding: 12px 16px; }
    .brand { font-size: 15px; }
    .nav-menu-toggle { display: inline-flex; align-items: center; }
    .nav-menu-items {
        /* Hidden until the toggle button adds .is-open. */
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        margin-top: 6px;
        background: white;
        border: 0.5px solid var(--hairline-strong);
        border-radius: 10px;
        padding: 14px 16px;
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        min-width: 200px;
        z-index: 100;
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    }
    .nav-menu-items.is-open {
        display: flex;
    }
    /* Inside the dropdown, links and the Sign-out button become
     * block-level taps. Language toggle stays in the topbar (outside
     * this dropdown). */
    .nav-menu-items a,
    .nav-menu-items .btn-link {
        padding: 6px 0;
        font-size: 14px;
    }

    .container { padding: 16px 16px 64px; }
    .auth-card { margin: 24px auto; max-width: 100%; }
    .messages { margin: 12px 16px 0; }

    /* --- Cards --- */
    .card { padding: 14px 16px; }
    .card-compact { padding: 10px 12px; }

    /* --- Typography (slightly tighter) --- */
    .page-title { font-size: 20px; }
    .page-subtitle { font-size: 13px; line-height: 1.5; }

    /* --- Form fields --- *
     * 16px on inputs prevents iOS Safari from zooming the viewport
     * when an input gains focus. Slightly more padding for thumb
     * accuracy. */
    .field-input {
        font-size: 16px;
        padding: 10px 12px;
    }
    textarea.field-input {
        font-size: 15px;       /* multi-line is fine to be slightly smaller */
        line-height: 1.5;
    }
    .field-help { font-size: 12px; }
    .field-label { font-size: 13px; }

    /* The share-link `<input readonly>` uses an inline font-size:12px to
     * fit the token. On mobile, allow it to scroll horizontally inside
     * its width rather than overflowing the card. */
    input[readonly].field-input {
        overflow-x: auto;
        white-space: nowrap;
    }

    /* --- Buttons --- *
     * Primary buttons get a min-height so they comfortably hit the
     * 40-44px tap-target zone without changing the visual size of
     * .btn-sm secondary actions. */
    .btn {
        padding: 11px 16px;
        min-height: 42px;
        line-height: 1.2;
    }
    .btn-sm { min-height: 32px; }
    .btn-row { gap: 8px; flex-wrap: wrap; }

    /* --- Key/value tables: stack label above value --- *
     * The fixed 160px label column is too wide on a phone; let it
     * collapse so each row reads "Label\nValue" with the value taking
     * full width. Applies everywhere `table.kv` is used (contract
     * preview, status panels, profile setup, etc.). */
    table.kv td {
        display: block;
        width: 100%;
        padding: 0;
    }
    table.kv td:first-child {
        padding-top: 8px;
    }
    table.kv td:last-child {
        padding-bottom: 8px;
    }
    table.kv tr { display: block; border-bottom: 0.5px solid var(--hairline); }
    table.kv tr:last-child { border-bottom: none; }

    /* --- List items: wrap right-column meta below when crowded --- */
    .list-item {
        flex-wrap: wrap;
        align-items: flex-start;
        gap: 4px 12px;
    }
    .list-item .text-right { text-align: left; }

    /* --- Wizard --- */
    .wizard { max-width: 100%; }
    .wizard-step {
        padding: 18px 16px;
        min-height: auto;
    }
    .wizard-step-title { font-size: 16px; }
    .wizard-step-help { font-size: 13px; }
    .wizard-progress { margin-bottom: 28px; }

    /* Wizard nav stacks vertically on phones, with Continue on top
     * (primary action), then Save, then Back, with Cancel as a quiet
     * tail. `order` lets us re-sort the flow without changing DOM. */
    .wizard-nav {
        flex-direction: column;
        gap: 8px;
    }
    .wizard-nav .btn,
    .wizard-nav .wizard-cancel {
        width: 100%;
        margin: 0;
        text-align: center;
    }
    .wizard-nav #wizard-next { order: 1; }
    .wizard-nav #wizard-save { order: 2; }
    .wizard-nav #wizard-back { order: 3; }
    .wizard-nav .wizard-cancel { order: 4; padding-top: 4px; }

    /* --- Contract preview / signature blocks --- */
    .contract-preview { padding: 16px 14px; }
    .signature-grid { gap: 18px; }

    /* --- Sign canvas --- */
    .signature-canvas { height: 140px; }

    /* --- Method picker --- */
    .method-active {
        flex-wrap: wrap;
        gap: 6px;
    }

    /* --- Paste zone (template upload page) --- */
    .paste-zone { min-height: 160px; padding: 10px 12px; font-size: 14px; }
}

@media (max-width: 480px) {
    /* --- Even tighter on phones in portrait --- */
    .topbar { padding: 10px 14px; }
    .container { padding: 14px 14px 56px; }
    .messages { margin: 10px 14px 0; }

    /* Cards near the edge — give the page a little air */
    .card { padding: 12px 14px; }

    .page-title { font-size: 18px; }

    /* Buttons row: stack vertically when there are 3+ buttons (e.g.
     * detail page's Back + Edit row already 2, but the contract sign
     * page has more). Keep gap modest. */
    .btn-row { gap: 6px; }

    /* Lighter list-item meta */
    .list-item-meta { font-size: 11px; }

    /* Wizard signature block stacks */
    .signature-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 380px) {
    /* --- Very small phones (iPhone SE, older Android) --- */
    .topbar { padding: 10px 12px; gap: 6px; }
    .topnav { gap: 8px; }
    .topnav a, .topnav .btn-link { font-size: 12px; }
    .brand { font-size: 14px; }
    .container { padding: 12px 12px 48px; }
    .card { padding: 12px 12px; }
    .page-title { font-size: 17px; }
}

/* Tap-friendly touch targets across the board — applies regardless of
 * viewport width, but the bigger min-height kicks in on coarse pointers
 * (touch devices). Using `pointer: coarse` so desktop mouse users keep
 * the compact UI. */
@media (pointer: coarse) {
    .field-toggle-row,
    .intro-field-required,
    .lang-option {
        min-height: 36px;
    }
    .clause-row .btn-sm { min-height: 32px; }
}


/* ---------- Public landing page ---------------------------------------- */
.landing-hero {
    text-align: center;
    padding: 48px 16px 40px;
    max-width: 720px;
    margin: 0 auto;
}
.landing-eyebrow {
    margin: 0 0 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
}
.landing-hero h1 {
    margin: 0;
    font-size: 34px;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: var(--ink);
}
.landing-lead {
    margin: 16px auto 0;
    max-width: 560px;
    font-size: 16px;
    line-height: 1.6;
    color: var(--ink-2);
}
.landing-cta { margin-top: 24px; }
.landing-cta .btn { padding: 11px 28px; font-size: 15px; }

.landing-section { margin: 32px auto; max-width: 920px; }
.landing-section-title {
    text-align: center;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    color: var(--ink-3);
    margin: 0 0 20px;
}
.feature-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(248px, 1fr));
    gap: 14px;
}
.feature-card {
    border: 0.5px solid var(--hairline);
    border-radius: 12px;
    background: #fff;
    padding: 18px 18px 16px;
}
.feature-card h3 {
    margin: 0 0 6px;
    font-size: 15px;
    color: var(--ink);
}
.feature-card p {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.55;
    color: var(--ink-2);
}

.landing-band {
    margin: 36px auto 12px;
    max-width: 920px;
    text-align: center;
    background: var(--accent-pale);
    border-radius: 14px;
    padding: 32px 20px;
}
.landing-band-text {
    margin: 0 0 18px;
    font-size: 18px;
    font-weight: 600;
    color: var(--accent);
}

@media (max-width: 640px) {
    .landing-hero { padding: 32px 4px 28px; }
    .landing-hero h1 { font-size: 26px; }
    .landing-lead { font-size: 15px; }
    .landing-band { padding: 26px 14px; }
    .landing-band-text { font-size: 16px; }
}
