:root {
    --ink: #101b2b;
    --ink-soft: #3d4a5c;
    --paper: #ffffff;
    --canvas: #f3f5f7;
    --line: #d9dee5;
    --line-strong: #aeb7c4;
    --red: #d71920;
    --red-dark: #a80f17;
    --red-soft: #fff1f1;
    --blue: #165ea8;
    --success: #176b45;
    --error: #b42318;
    --shadow-sm: 0 1px 2px rgba(16, 27, 43, .07);
    --shadow-lg: 0 24px 70px rgba(16, 27, 43, .11);
    --radius-sm: 8px;
    --radius: 16px;
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;
    --space-6: 32px;
    --space-7: 48px;
    --space-8: 64px;
    --display: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
    --body: "Noto Sans", "Segoe UI", Arial, sans-serif;
    --cjk: "Noto Sans SC", "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
    --utility: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: rgba(22, 94, 168, .16); }
html { scroll-behavior: smooth; scroll-padding-top: 24px; }
body {
    margin: 0;
    min-width: 320px;
    color: var(--ink);
    background: var(--canvas);
    font-family: var(--body);
    font-size: 16px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; }
button, label, summary, a { touch-action: manipulation; }
a { color: inherit; }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.skip-link {
    position: fixed;
    left: 16px;
    top: 12px;
    z-index: 1000;
    padding: 10px 14px;
    background: var(--ink);
    color: white;
    transform: translateY(-160%);
    transition: transform .18s ease-out;
}
.skip-link:focus { transform: translateY(0); }

.site-header {
    width: min(1440px, 100%);
    margin: 0 auto;
    min-height: 92px;
    padding: 14px clamp(20px, 4vw, 64px);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--paper);
    border-bottom: 1px solid var(--line);
}
.brand { display: inline-flex; min-height: 48px; align-items: center; }
.brand img { width: 196px; height: auto; display: block; }
.header-meta { display: grid; text-align: right; line-height: 1.25; }
.header-meta span { color: var(--ink-soft); font-size: .75rem; text-transform: uppercase; letter-spacing: .12em; }
.header-meta strong { font-family: var(--display); font-size: 1.08rem; }

main { width: min(1440px, 100%); margin: 0 auto; background: var(--canvas); }
.intro {
    min-height: 280px;
    padding: clamp(56px, 7vw, 88px) clamp(20px, 6vw, 88px);
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
    background: var(--paper);
}
.intro::before {
    content: "";
    position: absolute;
    width: 260px;
    height: 8px;
    left: clamp(20px, 6vw, 88px);
    top: 0;
    background: var(--red);
}
.intro::after {
    content: "";
    position: absolute;
    right: clamp(20px, 6vw, 88px);
    bottom: 0;
    width: clamp(72px, 12vw, 172px);
    height: 1px;
    background: var(--line-strong);
}
.intro-message {
    width: min(1080px, 100%);
    padding-left: clamp(20px, 2.4vw, 32px);
    position: relative;
}
.intro-message::before {
    content: "";
    position: absolute;
    left: 0;
    top: .18em;
    bottom: .12em;
    width: 6px;
    background: var(--red);
}
.eyebrow, .progress-card p, .completion-panel p, .dialog-header p {
    margin: 0 0 14px;
    color: var(--red-dark);
    font-family: var(--utility);
    font-size: .75rem;
    font-weight: 700;
    letter-spacing: .12em;
}
.intro h1 {
    margin: 0;
    max-width: 1040px;
    font-family: var(--cjk);
    font-size: clamp(1.9rem, 3.5vw, 3.65rem);
    font-weight: 700;
    letter-spacing: .015em;
    line-height: 1.38;
    text-wrap: balance;
}
.intro-action {
    color: var(--red-dark);
    background: linear-gradient(transparent 68%, var(--red-soft) 68%);
    box-decoration-break: clone;
    -webkit-box-decoration-break: clone;
}

@media (min-width: 721px) {
    .intro-lead, .intro-action { display: inline-block; white-space: nowrap; }
}

.form-layout {
    max-width: 1260px;
    margin: 0 auto;
    padding: 72px clamp(16px, 4vw, 48px) 100px;
    display: grid;
    grid-template-columns: 210px minmax(0, 1fr);
    gap: 40px;
    align-items: start;
}
.progress-rail { position: sticky; top: 24px; }
.progress-card { padding: 24px; background: var(--ink); color: white; box-shadow: var(--shadow-lg); }
.progress-card p { color: #ff9b9f; }
.progress-card strong { display: block; font-family: var(--display); font-size: 2.7rem; line-height: 1; }
.progress-card small { display: block; margin-top: 12px; color: #c8d0dc; font-size: .74rem; }
.progress-track { height: 4px; margin-top: 20px; overflow: hidden; background: rgba(255,255,255,.2); }
.progress-track span { display: block; width: 100%; height: 100%; background: #ff3f46; transform: scaleX(0); transform-origin: left center; transition: transform .25s ease-out; }
.progress-rail nav { display: grid; margin-top: 22px; border-left: 1px solid var(--line-strong); }
.progress-rail nav a { padding: 9px 16px; color: var(--ink-soft); font-size: .84rem; text-decoration: none; border-left: 3px solid transparent; transform: translateX(-2px); }
.progress-rail nav a.is-active { color: var(--ink); font-weight: 700; border-left-color: var(--red); }

#application-form { min-width: 0; }
.form-section { margin-bottom: 32px; scroll-margin-top: 24px; background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow-sm); }
.section-heading { display: grid; grid-template-columns: 92px 1fr; min-height: 124px; border-bottom: 1px solid var(--line); }
.section-index { padding: 28px 12px; color: white; background: var(--red); font: 700 .78rem/1.3 var(--utility); letter-spacing: .08em; text-align: center; }
.section-heading > div:last-child { padding: 24px 30px; align-self: center; }
.section-heading p { margin: 0 0 2px; color: var(--red-dark); font-size: .78rem; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; }
.section-heading h2, .completion-panel h2 { margin: 0; font-family: var(--display); font-size: clamp(1.55rem, 3vw, 2.25rem); letter-spacing: -.035em; line-height: 1.2; text-wrap: balance; }
.section-body { padding: clamp(24px, 4vw, 44px); }

.programme-fields { display: grid; gap: 20px; min-width: 0; }

.field { display: grid; align-content: start; gap: 7px; min-width: 0; font-style: normal; }
.field > span, fieldset > legend { color: var(--ink); font-size: .83rem; font-weight: 700; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.field-label-row label { color: var(--ink); font-size: .83rem; font-weight: 700; }
.translate-button { min-width: 70px; padding: 7px 16px; color: white; background: var(--blue); border: 1px solid var(--blue); border-radius: 7px; font-size: .82rem; font-weight: 750; cursor: pointer; }
.translate-button:hover { filter: brightness(.9); }
.translate-button:disabled { opacity: .58; cursor: wait; }
.address-field textarea::placeholder { color: #8a94a3; opacity: 1; }
.field b, fieldset b, .signature-card h3 b { color: var(--red); }
.field input, .field select, .field textarea {
    width: 100%;
    min-height: 48px;
    padding: 11px 13px;
    color: var(--ink);
    background: #fcfcfd;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    outline: none;
    transition: border-color .18s ease-out, box-shadow .18s ease-out, background-color .18s ease-out;
}
.field textarea { resize: vertical; min-height: 108px; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: #758195; }
.field input:focus-visible, .field select:focus-visible, .field textarea:focus-visible, button:focus-visible, a:focus-visible, summary:focus-visible, .binary-field input:focus-visible + span, .policy-confirmation input:focus-visible {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(22,94,168,.2);
}
.field input[readonly] { color: #596577; background: #eef1f4; border-style: dashed; }
.field small { min-height: 1em; color: #667386; font-size: .73rem; }
.field-error { min-height: 1em; color: var(--error); font-size: .75rem; font-style: normal; }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--error); background: #fff9f8; }
.field-grid { display: grid; gap: 22px; }
.two-col { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.span-two { grid-column: 1 / -1; }
.split-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.combobox-control { position: relative; }
.combobox-control svg { position: absolute; z-index: 1; left: 13px; top: 14px; width: 20px; color: var(--ink-soft); }
.combobox-control input { padding-left: 43px; }
.programme-combobox { position: relative; z-index: 4; }
.programme-results {
    position: absolute;
    z-index: 20;
    top: 82px;
    left: 0;
    right: 0;
    max-height: 280px;
    overflow-y: auto;
    padding: 6px;
    background: white;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    box-shadow: 0 18px 45px rgba(16,27,43,.16);
}
.programme-option { width: 100%; min-height: 44px; padding: 9px 11px; text-align: left; color: var(--ink); background: transparent; border: 0; border-radius: 5px; cursor: pointer; }
.programme-option:hover, .programme-option[aria-selected="true"] { background: var(--red-soft); color: var(--red-dark); }
.programme-empty { padding: 15px; color: var(--ink-soft); font-size: .82rem; }

.binary-field, .subsection { margin: 0; padding: 0; border: 0; }

.question-block, .subsection, .sibling-block { margin-top: 36px; padding-top: 30px; border-top: 1px solid var(--line); }
.question-row { display: grid; grid-template-columns: minmax(300px, 1.1fr) minmax(220px, .9fr); gap: 24px; align-items: start; }
.question-row + .question-row { margin-top: 24px; }
.binary-field legend { max-width: 42ch; }
.binary-field > div { display: flex; gap: 26px; margin-top: 12px; }
.binary-field label { min-height: 44px; display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.binary-field input { position: absolute; opacity: 0; }
.binary-field label span { width: 19px; height: 19px; display: inline-block; background: white; border: 1.5px solid #667386; border-radius: 2px; }
.binary-field input:checked + span { background: var(--red); border-color: var(--red); box-shadow: inset 0 0 0 4px white; }
.subsection > legend { color: var(--red-dark); font-family: var(--display); font-size: 1rem; }
.final-row { margin-top: 36px; padding-top: 30px; border-top: 1px solid var(--line); }
.sibling-block > p { margin: 0 0 18px; color: var(--red-dark); font-size: .84rem; font-weight: 700; }

.policy-card { border: 1px solid var(--line); background: #fcfcfd; }
.policy-card + .policy-card { margin-top: 12px; }
.policy-card summary { min-height: 70px; padding: 14px 18px; display: grid; align-content: center; cursor: pointer; list-style-position: inside; }
.policy-card summary span { font-weight: 700; }
.policy-card summary small { display: block; margin-left: 19px; color: var(--ink-soft); }
.policy-copy { padding: 0 24px 24px; color: var(--ink-soft); font-size: .86rem; }
.policy-copy h3 { margin: 20px 0 8px; color: var(--ink); font-size: .9rem; text-transform: uppercase; }
.policy-copy li + li { margin-top: 5px; }
.signature-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.signature-card { min-width: 0; padding: 20px; border: 1px solid var(--line); }
.signature-card > p { margin: 0; color: var(--red-dark); font: 700 .68rem/1.2 var(--utility); letter-spacing: .08em; text-transform: uppercase; }
.signature-card h3 { min-height: 42px; margin: 5px 0 12px; font-family: var(--display); font-size: 1rem; line-height: 1.3; text-wrap: balance; }
.signature-preview { height: 112px; display: grid; place-items: center; overflow: hidden; color: #7a8492; background: #f7f8fa; border: 1px dashed var(--line-strong); }
.signature-preview img { max-width: 95%; max-height: 94px; object-fit: contain; }
.signature-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.signature-error { min-height: 1em; display: block; margin-top: 8px; color: var(--error); font-size: .75rem; font-style: normal; }
.secondary-button, .text-button, .primary-button, .icon-button {
    min-height: 44px;
    padding: 10px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: color .18s ease-out, border-color .18s ease-out, background-color .18s ease-out, opacity .18s ease-out;
}
.secondary-button { color: var(--ink); background: white; border: 1px solid var(--line-strong); font-weight: 700; }
.secondary-button:hover { border-color: var(--ink); }
.text-button { color: var(--blue); background: transparent; border: 1px solid transparent; font-weight: 700; }
.text-button:hover { background: #eef4fa; }
.primary-button { color: white; background: var(--red); border: 1px solid var(--red); font-weight: 750; }
.primary-button:hover { background: var(--red-dark); border-color: var(--red-dark); }
.secondary-button:active, .text-button:active, .primary-button:active, .icon-button:active { opacity: .78; }
.primary-button:disabled { opacity: .52; cursor: wait; }
.primary-button:disabled, .secondary-button:disabled, .text-button:disabled { cursor: not-allowed; }
.secondary-button svg, .text-button svg, .primary-button svg { width: 19px; }
.declaration-details { margin-top: 22px; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.completion-action {
    padding: 30px clamp(18px, 4vw, 38px);
    display: flex;
    justify-content: center;
    background: white;
    border-top: 1px solid var(--line);
}
.completion-action .primary-button {
    min-width: min(100%, 382px);
    min-height: 58px;
    padding: 15px 22px;
    box-shadow: 0 10px 22px rgba(226, 20, 34, .18);
}
.completion-panel {
    padding: clamp(28px, 4vw, 42px) clamp(24px, 5vw, 48px);
    display: grid;
    grid-template-columns: minmax(220px, .78fr) minmax(160px, .48fr) minmax(260px, 1fr);
    align-items: end;
    gap: clamp(28px, 6vw, 72px);
    color: white;
    background: var(--ink);
}
.completion-panel .completion-title > p { margin: 0 0 14px; color: #ff9b9f; }
.completion-panel h2 { font-size: clamp(1.5rem, 2.7vw, 2.05rem); }
.completion-panel h2 span { color: #f4f6f9; }
.completion-resources { display: grid; justify-items: center; }
.application-download { min-height: 48px; padding: 11px 17px; display: inline-flex; align-items: center; justify-content: center; gap: 9px; color: #ff747a; border: 2px solid #ff4e57; font-weight: 750; text-decoration: none; }
.application-download:hover { color: white; background: var(--red); border-color: var(--red); }
.application-download svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.completion-panel .completion-note { margin: 0; padding-left: 24px; color: #d2d9e2; border-left: 1px solid rgba(255,255,255,.22); font: 400 .86rem/1.75 var(--body); letter-spacing: 0; text-transform: none; }
.completion-panel .completion-note span { color: #aeb9c8; }

.error-summary { margin-bottom: 24px; padding: 18px 22px; color: var(--error); background: #fff3f1; border-left: 4px solid var(--error); }
.error-summary ul { margin: 7px 0 0; padding-left: 20px; }
.error-summary a { color: inherit; }
.toast { position: fixed; z-index: 100; right: 24px; bottom: 24px; max-width: min(420px, calc(100vw - 32px)); padding: 14px 18px; color: white; background: var(--success); box-shadow: var(--shadow-lg); }

.signature-dialog, .policy-dialog { width: min(760px, calc(100% - 24px)); max-height: calc(100dvh - 24px); padding: 0; overflow: auto; overscroll-behavior: contain; border: 0; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.signature-dialog::backdrop, .policy-dialog::backdrop { background: rgba(9,16,27,.68); backdrop-filter: blur(3px); }
.dialog-shell { padding: 24px; }
.dialog-header { display: flex; justify-content: space-between; gap: 20px; align-items: start; }
.dialog-header > div { min-width: 0; }
.dialog-header p { margin-bottom: 2px; }
.dialog-header h2 { margin: 0; font-family: var(--display); }
.icon-button { width: 44px; padding: 10px; color: var(--ink); background: white; border: 1px solid var(--line); }
.icon-button:hover { color: var(--red-dark); border-color: var(--red); background: var(--red-soft); }
.icon-button svg { width: 20px; }
.dialog-hint { color: var(--ink-soft); font-size: .86rem; }
.signature-dialog canvas { width: 100%; height: 240px; display: block; background: #fbfbfc; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); touch-action: none; cursor: crosshair; }
.dialog-actions { margin-top: 16px; display: flex; justify-content: space-between; }
.policy-dialog { width: min(820px, calc(100% - 24px)); }
.policy-dialog-shell { padding: 0; }
.policy-dialog .dialog-header { position: sticky; z-index: 2; top: 0; padding: 22px 24px 18px; background: white; border-bottom: 1px solid var(--line); }
.policy-timer { min-width: 76px; min-height: 44px; padding: 9px 12px; display: grid; place-items: center; color: var(--red-dark); background: var(--red-soft); border: 1px solid #f2b9bc; border-radius: 999px; font: 700 .72rem/1 var(--utility); text-align: center; }
.policy-dialog-copy { max-height: min(52dvh, 520px); padding: 22px 28px; overflow-y: auto; color: var(--ink-soft); font-size: .88rem; }
.policy-dialog-copy:focus-visible { outline: 3px solid rgba(22,94,168,.28); outline-offset: -3px; }
.policy-dialog-copy h3 { margin: 18px 0 8px; color: var(--ink); font-size: .92rem; }
.policy-dialog-copy li + li { margin-top: 8px; }
.policy-lead { margin-top: 0; color: var(--ink); font-family: var(--display); font-size: 1.08rem; font-weight: 700; }
.policy-confirmation { padding: 18px 24px; background: #f4f7fa; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.policy-confirmation label { min-height: 44px; display: flex; align-items: center; gap: 10px; font-weight: 700; cursor: pointer; }
.policy-confirmation input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--red); }
.policy-confirmation input:disabled + span { color: #707b8a; }
.policy-confirmation small { display: block; margin: 6px 0 0 30px; color: var(--ink-soft); }
.policy-dialog-actions { margin: 0; padding: 16px 24px 22px; background: white; }

@media (max-width: 980px) {
    .form-layout { grid-template-columns: 1fr; }
    .progress-rail { position: static; display: grid; grid-template-columns: 220px 1fr; gap: 14px; }
    .progress-rail nav { grid-template-columns: repeat(4, 1fr); align-items: center; margin: 0; border: 1px solid var(--line); background: white; }
    .progress-rail nav a { text-align: center; border-left: 0; border-bottom: 3px solid transparent; transform: none; }
    .progress-rail nav a.is-active { border-left: 0; border-bottom-color: var(--red); }
    .completion-panel { grid-template-columns: minmax(220px, .8fr) minmax(160px, .5fr) minmax(230px, 1fr); gap: 24px; }
}

@media (max-width: 720px) {
    .site-header { min-height: 76px; padding: 10px 18px; }
    .site-header { padding-left: max(18px, env(safe-area-inset-left)); padding-right: max(18px, env(safe-area-inset-right)); }
    .brand img { width: 154px; }
    .header-meta span { display: none; }
    .header-meta strong { font-size: .85rem; }
    .intro { min-height: 220px; padding: 48px 20px; }
    .intro::before { width: 112px; left: 20px; }
    .intro-message { padding-left: 18px; }
    .intro-message::before { width: 4px; }
    .intro h1 { font-size: clamp(1.4rem, 6.2vw, 2.25rem); line-height: 1.55; }
    .form-layout { padding: 48px 12px 72px; gap: 22px; }
    .progress-rail { grid-template-columns: 1fr; }
    .progress-rail nav { display: none; }
    .progress-card { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; }
    .progress-card p, .progress-card small { grid-column: 1; }
    .progress-card strong { grid-column: 2; grid-row: 1 / 3; }
    .progress-track { grid-column: 1 / -1; }
    .section-heading { grid-template-columns: 68px 1fr; min-height: 108px; }
    .section-index { padding: 24px 7px; }
    .section-heading > div:last-child { padding: 20px 18px; }
    .section-body { padding: 24px 18px; }
    .two-col, .split-fields, .signature-grid, .declaration-details, .question-row { grid-template-columns: 1fr; }
    .question-row { gap: 14px; }
    .completion-action { padding: 20px 18px; }
    .completion-action .primary-button { width: 100%; min-width: 0; }
    .completion-panel { grid-template-columns: 1fr; align-items: start; gap: 22px; }
    .completion-resources { width: 100%; justify-items: start; }
    .completion-panel .completion-note { padding: 20px 0 0; border-left: 0; border-top: 1px solid rgba(255,255,255,.22); }
    .signature-dialog canvas { height: 200px; }
    .policy-dialog .dialog-header { padding: 18px; }
    .policy-dialog-copy { max-height: 48dvh; padding: 18px; }
    .policy-confirmation, .policy-dialog-actions { padding-left: 18px; padding-right: 18px; }
    .policy-dialog-actions .primary-button { width: 100%; }
}

@media (min-width: 375px) and (max-width: 720px) {
    .intro-lead, .intro-action { display: inline-block; white-space: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

@media print {
    .site-header, .intro, .progress-rail, .completion-action, .completion-panel { display: none !important; }
    .form-layout { display: block; padding: 0; }
    .form-section { box-shadow: none; break-inside: avoid; }
}
