 :root {
    --ink: #1a1a1a;
    --ink-soft: #333;
    --line: #1a1a1a;
    --line-soft: #666;
    --brand: #0a2f5c;          /* BTEC / Pearson deep navy */
    --brand-accent: #a41e34;   /* Pearson-ish red */
    --paper: #ffffff;
    --paper-tint: #f7f5f0;
    --office: #fff9e6;
    --field-bg: #fafafa;
}

* { box-sizing: border-box; }
#main-content {
    margin: 0;
    padding: 0;
    background: #e8e6e1;
    font-family: "Noto Sans HK", "Helvetica Neue", Helvetica, Arial, "PingFang HK", "Microsoft JhengHei", sans-serif;
    color: var(--ink);
    font-size: 12px;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
    position: relative;
    display: flow-root;
}
/* A4 page */
.page {
    width: 1200px;
    min-height: 297mm;
    margin: 24px auto;
    background: var(--paper);
    padding: 14mm 14mm 12mm;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08), 0 12px 40px rgba(0,0,0,0.12);
    position: relative;
}

/* ---------- HEADER ---------- */
.header {
    display: grid;
    grid-template-columns: 1fr 34mm;
    gap: 8mm;
    align-items: stretch;
    padding-bottom: 6mm;
    border-bottom: 2px solid var(--brand);
    margin-bottom: 5mm;
}
.brand {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}
.brand-mark {
    display: flex;
    align-items: center;
    gap: 10px;
}
.brand-logo {
    width: 44px;
    height: 44px;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-family: "Noto Serif HK", Georgia, serif;
    font-weight: 700;
    font-size: 18px;
    letter-spacing: 0.5px;
    border-radius: 2px;
}
.brand-mark .brand-text {
    font-family: "Noto Serif HK", Georgia, serif;
}
.brand-mark .brand-name {
    font-size: 15px;
    font-weight: 700;
    color: var(--brand);
    letter-spacing: 0.5px;
}
.brand-mark .brand-sub {
    font-size: 10px;
    color: var(--ink-soft);
    letter-spacing: 0.3px;
}

.title-block { margin-top: 6mm; }
.title-en {
    font-family: "Noto Serif HK", Georgia, serif;
    font-size: 20px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.3px;
    line-height: 1.15;
}
.title-zh {
    font-size: 15px;
    font-weight: 500;
    color: var(--ink-soft);
    margin-top: 2px;
}
.subtitle {
    margin-top: 4mm;
    font-size: 11px;
    color: var(--ink-soft);
    font-style: italic;
    border-left: 3px solid var(--brand-accent);
    padding-left: 8px;
}

/* Photo + Application No. column */
.aside-col {
    display: flex;
    flex-direction: column;
    gap: 3mm;
}
.photo-box {
    border: 1px dashed var(--line);
    height: 44mm;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4mm 3mm;
    background: repeating-linear-gradient(
    45deg,
    #fafafa 0 6px,
    #f2f0eb 6px 12px
    );
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: border-color 0.15s, background 0.15s;
}
.photo-box:hover {
    border-color: var(--brand);
    background: repeating-linear-gradient(45deg, #eef3fb 0 6px, #e6edf7 6px 12px);
}
.photo-box.has-photo {
    background: none;
    padding: 0;
    border-style: solid;
    border-color: var(--brand);
}
.photo-box .label {
    font-size: 10px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.4px;
}
.photo-box .hint {
    font-size: 8.5px;
    color: var(--ink-soft);
    margin-top: 3px;
    line-height: 1.3;
    font-style: italic;
}
.photo-box .upload-icon {
    font-size: 20px;
    color: var(--brand);
    margin-bottom: 4px;
}
.photo-box .photo-preview {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}
.photo-box.has-photo .photo-preview { display: block; }
.photo-box.has-photo .label,
.photo-box.has-photo .hint,
.photo-box.has-photo .upload-icon { display: none; }
.photo-box .photo-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    background: var(--brand-accent);
    color: #fff;
    border: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 12px;
    line-height: 1;
    cursor: pointer;
    display: none;
    z-index: 2;
    padding: 0;
    font-weight: 700;
}
.photo-box.has-photo .photo-remove { display: block; }
.photo-box input[type="file"] { display: none; }
.photo-box .photo-spec {
    display: inline-block;
    background: var(--brand);
    color: #fff;
    font-size: 7.5px;
    padding: 1px 5px;
    border-radius: 6px;
    margin-top: 4px;
    letter-spacing: 0.3px;
    font-weight: 700;
    font-style: normal;
}
.app-no {
    border: 1px solid var(--line);
    background: var(--office);
    padding: 3mm;
}
.app-no .label {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.3px;
    color: var(--ink);
}
.app-no .field {
    margin-top: 4px;
    border-bottom: 1px solid var(--ink);
    height: 14px;
}
.app-no .tiny {
    display: block;
    font-size: 7.5px;
    color: var(--ink-soft);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    margin-top: 3px;
}

/* ---------- SECTIONS ---------- */
.section {
    margin-top: 4mm;
    border: 1px solid var(--line);
}
.section-head {
    background: var(--brand);
    color: #fff;
    padding: 2.4mm 3mm;
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}
.section-head .zh {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.5px;
}
.section-head .en {
    font-size: 10.5px;
    font-weight: 500;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    opacity: 0.92;
}
.section-head .num {
    font-family: "Noto Serif HK", Georgia, serif;
    font-size: 11px;
    background: rgba(255,255,255,0.15);
    padding: 1px 6px;
    border-radius: 2px;
    margin-right: 6px;
}
.section-head .head-left { display: flex; align-items: baseline; gap: 6px; }

.section-body { padding: 3mm 3mm 3.5mm; }
.section-note {
    font-size: 9.5px;
    color: var(--ink-soft);
    font-style: italic;
    padding: 2mm 3mm;
    background: var(--paper-tint);
    border-bottom: 1px solid #e5e2da;
}

/* ---------- FIELDS ---------- */
#bteApplicationForm .row {
    display: grid;
    gap: 3mm;
    /* margin-bottom: 2.5mm; */
    margin: 0 auto 2.5mm auto;
}
#bteApplicationForm .row:last-child { margin-bottom: 0; }
#bteApplicationForm .row.c2 { grid-template-columns: 1fr 1fr; }
#bteApplicationForm .row.c3 { grid-template-columns: 1fr 1fr 1fr; }
#bteApplicationForm .row.c11 { grid-template-columns: 1.2fr 1fr; }

.field {
    display: flex;
    flex-direction: column;
}
.field .lbl {
    font-size: 9.5px;
    line-height: 1.25;
    color: var(--ink);
    margin-bottom: 3px;
}
.field .lbl .zh { font-weight: 700; }
.field .lbl .en {
    color: var(--ink-soft);
    font-weight: 500;
    margin-left: 4px;
    font-size: 9px;
    letter-spacing: 0.2px;
}
.field .lbl .req { color: var(--brand-accent); margin-left: 2px; }
.required {
    font-size: .8rem;
    color: red;
    text-decoration: none !important;
}
.input {
    border: none;
    border-bottom: 1px solid var(--ink);
    background: var(--field-bg);
    height: 8mm;
    padding: 0 4px;
    font-family: inherit;
    font-size: 11px;
    color: var(--ink);
}
.input:focus { outline: none; background: #fff8dc; border-bottom-color: var(--brand); }
textarea.input { height: 14mm; padding: 4px; resize: none; }

.title-picker {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    padding: 2px 0;
}
.title-picker .opt {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    cursor: pointer;
}
.title-picker .opt input { accent-color: var(--brand); }
.title-picker .hint {
    font-size: 9px;
    color: var(--ink-soft);
    font-style: italic;
    margin-left: auto;
}

/* Programme title inline banner */
.prog-banner {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 2mm 3mm;
    background: #f0eee8;
    border-left: 3px solid var(--brand-accent);
}
.prog-banner .tag {
    font-family: "Noto Serif HK", Georgia, serif;
    background: var(--brand);
    color: #fff;
    font-size: 10px;
    padding: 2px 6px;
    letter-spacing: 0.5px;
}
.prog-banner .input { flex: 1; background: transparent; border-bottom: 1px dashed var(--ink-soft); }
.prog-banner.prog-fixed { padding: 3mm 4mm; }
.prog-banner .prog-title { line-height: 1.3; }
.prog-banner .prog-en {
    font-family: "Noto Serif HK", Georgia, serif;
    font-size: 13px;
    font-weight: 700;
    color: var(--ink);
    letter-spacing: 0.2px;
}
.prog-banner .prog-en em { font-style: italic; color: var(--brand); font-weight: 700; }
.prog-banner .prog-zh {
    font-size: 10px;
    color: var(--ink-soft);
    margin-top: 2px;
    letter-spacing: 0.3px;
}

/* ---------- CHECKBOXES ---------- */
.checks.study-mode {
    row-rule: 2px solid #181818;
}
.checks {
    /* display: flex;
    flex-wrap: wrap;
    gap: 5mm 8mm;
    align-items: center;
    padding: 1mm 0; */
    display: grid;
    gap: 2mm;
    padding: 3mm 0;
    grid-template-columns: repeat(3, 1fr);
}

.checks label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    cursor: pointer;
    padding: 1mm 3mm;
}
.checkbox {
    width: 14px;
    height: 14px;
    border: 1.5px solid var(--ink);
    display: inline-block;
    position: relative;
    flex-shrink: 0;
    background: #fff;
}
input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 14px; height: 14px;
    border: 1.5px solid var(--ink);
    background: #fff;
    display: inline-block;
    position: relative;
    cursor: pointer;
    margin: 0;
    flex-shrink: 0;
}
input[type="checkbox"]:checked {
    background: var(--brand);
    border-color: var(--brand);
}
input[type="checkbox"]:checked::after {
    content: "✓";
    position: absolute;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    top: -2px;
    left: 1px;
}
.check-label .zh { font-weight: 500; }
.check-label .en { color: var(--ink-soft); margin-left: 3px; font-size: 10px; }

/* ---------- TABLES ---------- */
table.grid {
    width: 100%;
    border-collapse: collapse;
    font-size: 10.5px;
}
table.grid th, table.grid td {
    border: 1px solid var(--line);
    padding: 4px 5px;
    vertical-align: top;
}
table.grid thead th {
    background: #f0eee8;
    font-weight: 700;
    text-align: left;
    font-size: 9.5px;
    line-height: 1.3;
}
table.grid thead th .en {
    display: block;
    font-weight: 500;
    color: var(--ink-soft);
    font-size: 8.5px;
    letter-spacing: 0.2px;
    margin-top: 1px;
}
table.grid tbody td { height: 9mm; }
table.grid tbody tr:nth-child(even) td { background: #fbfaf6; }
table.grid td .cellinput {
    width: 100%;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 10.5px;
    outline: none;
    padding: 0;
}
.row-num {
    width: 8mm;
    text-align: center;
    font-family: "Noto Serif HK", Georgia, serif;
    background: #f0eee8 !important;
    color: var(--brand);
    font-weight: 700;
}

/* ---------- DECLARATION ---------- */
.declaration {
    font-size: 10px;
    line-height: 1.55;
    color: var(--ink);
}
.declaration ol {
    list-style: none;
    padding: 0;
    margin: 0;
    counter-reset: dec;
}
.declaration li {
    counter-increment: dec;
    padding: 3mm 0 3mm 12mm;
    position: relative;
    border-bottom: 1px dotted #d5d2ca;
}
.declaration li:last-child { border-bottom: none; }
.declaration li::before {
    content: "(" counter(dec, lower-alpha) ")";
    position: absolute;
    left: 3mm;
    top: 3mm;
    font-family: "Noto Serif HK", Georgia, serif;
    font-weight: 700;
    color: var(--brand);
}
.declaration .zh { display: block; margin-bottom: 2px; }
.declaration .en { display: block; color: var(--ink-soft); font-style: italic; font-size: 9.5px; }

.sign-row {
    margin-top: 4mm;
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 6mm;
}
.sign-field .cap {
    font-size: 9.5px;
    color: var(--ink);
    margin-top: 3px;
    font-weight: 700;
}
.sign-field .cap .en { color: var(--ink-soft); font-weight: 500; margin-left: 4px; }

/* Signature capture */
.sig-tabs {
    display: flex;
    gap: 2px;
    margin-bottom: 4px;
}
.sig-tabs button {
    flex: 0 0 auto;
    background: #efece5;
    border: 1px solid #cfcbc0;
    border-bottom: none;
    padding: 4px 12px;
    font-family: inherit;
    font-size: 9.5px;
    color: var(--ink-soft);
    cursor: pointer;
    border-radius: 3px 3px 0 0;
    letter-spacing: 0.3px;
}
.sig-tabs button.active {
    background: #fff;
    color: var(--brand);
    border-color: var(--brand);
    font-weight: 700;
}
.sig-stage {
    position: relative;
    border: 1.5px solid var(--ink);
    background: var(--field-bg);
    height: 22mm;
    overflow: hidden;
}
.sig-stage canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
    background: repeating-linear-gradient(
    to right,
    transparent 0 20px,
    #eeece5 20px 21px
    );
}
.sig-stage input.sig-typed {
    display: none;
    width: 100%;
    height: 100%;
    border: none;
    background: transparent;
    font-family: "Homemade Apple", "Segoe Script", "Bradley Hand", cursive;
    font-size: 23px;
    color: #0a2f5c;
    padding: 0 12px;
    outline: none;
}
.sig-stage.mode-type input.sig-typed { display: block; }
.sig-stage.mode-type canvas { display: none; }
.sig-stage .sig-hint {
    position: absolute;
    bottom: 4px;
    right: 8px;
    font-size: 8.5px;
    color: #b8b4a8;
    font-style: italic;
    pointer-events: none;
    letter-spacing: 0.2px;
}
.sig-clear {
    margin-top: 3px;
    background: none;
    border: none;
    color: var(--brand-accent);
    font-family: inherit;
    font-size: 9px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
    letter-spacing: 0.3px;
}
.sig-clear:hover { color: #6b1420; }

.date-input {
    width: 100%;
    border: none;
    border-bottom: 1.5px solid var(--ink);
    background: var(--field-bg);
    height: 22mm;
    padding: 0 8px;
    font-family: inherit;
    font-size: 12px;
    color: var(--ink);
    text-align: center;
    letter-spacing: 2px;
}
.date-input:focus { outline: none; background: #fff8dc; border-bottom-color: var(--brand); }

/* ---------- OFFICE USE ---------- */
.office {
    margin-top: 4mm;
    border: 1.5px solid var(--ink);
    background: var(--office);
}
.office .section-head {
    background: var(--ink);
    color: #ffd54a;
}
.office .section-head .num { background: rgba(255,255,255,0.12); color: #ffd54a; }
.office-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 3mm;
    padding: 3mm;
}
.office-body .full { grid-column: 1 / -1; }

/* ---------- FOOTER NOTE ---------- */
.footer-note {
    margin-top: 5mm;
    border-top: 1px solid var(--line-soft);
    padding-top: 3mm;
    font-size: 9.5px;
    color: var(--ink-soft);
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 8mm;
    align-items: start;
}
.footer-note .tag {
    background: var(--brand-accent);
    color: #fff;
    font-weight: 700;
    padding: 3px 8px;
    font-size: 9px;
    letter-spacing: 1px;
    text-transform: uppercase;
    align-self: start;
}
.footer-note .body .zh { color: var(--ink); font-weight: 500; }
.footer-note .body .en { font-style: italic; margin-top: 2px; }
.footer-note .ref {
    font-family: "Noto Serif HK", Georgia, serif;
    font-size: 9px;
    color: var(--line-soft);
    letter-spacing: 0.5px;
}

/* Page break for print */
.page-break { page-break-after: always; }

/* Print */
@media print {
    body { background: #fff; }
    .page {
    margin: 0;
    box-shadow: none;
    width: 210mm;
    min-height: 297mm;
    }
    .toolbar { display: none !important; }
}

/* Toolbar (screen only) */
.toolbar {
    position: absolute;
    top: 12px;
    right: 12px;
    display: flex;
    gap: 6px;
    z-index: 100;
}
.toolbar button, .submit button {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 8px 14px;
    font-family: inherit;
    font-size: 12px;
    cursor: pointer;
    border-radius: 3px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}
.toolbar button:hover, .submit button:hover { background: #163f70; }
.toolbar button.ghost { background: #fff; color: var(--brand); border: 1px solid var(--brand); }
.submit {text-align: end;}
.submit button {margin: 0 17px;}
#recaptcha-section{margin-top: 4mm; display: grid; grid-template-columns: repeat(2, 1fr); align-items: center;}
/* ---------- ID document group ---------- */
  .id-group {
    margin: 2.5mm 0;
    padding: 3.5mm 4mm 4mm;
    background: #f9f8f4;
    border: 1px solid #e5e2da;
    border-left: 3px solid var(--brand);
    border-radius: 0 3px 3px 0;
  }
  .id-group-head {
    margin-bottom: 3mm;
    padding-bottom: 2.5mm;
    border-bottom: 1px dotted #d5d2ca;
  }
  .id-group-title {
    font-size: 13px;
    color: var(--ink);
  }
  .id-group-title .zh { font-weight: 700; }
  .id-group-title .en {
    color: var(--ink-soft);
    font-weight: 500;
    margin-left: 5px;
    font-size: 12px;
    letter-spacing: 0.2px;
  }
  .id-group-title .req {
    color: var(--brand-accent);
    margin-left: 3px;
    font-weight: 700;
    font-size: 14px;
  }
  .id-group-note {
    font-size: 11px;
    color: var(--ink-soft);
    margin-top: 3px;
  }
  .id-group-note em { font-style: italic; }
  .id-group .upload { margin-top: 3.5mm; }

  /* ---------- File upload widget ---------- */
  .upload {
    margin-top: 3.5mm;
    border: 1.5px dashed var(--brand);
    background: #f4f7fc;
    padding: 3.5mm 4.5mm;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 4mm;
    border-radius: 2px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
  }
  .upload:hover {
    background: #eaf0f9;
    border-color: #163f70;
  }
  .upload .icon {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: var(--brand);
    color: #fff;
    display: grid; place-items: center;
    font-size: 16px;
    font-weight: 700;
    flex-shrink: 0;
  }
  .upload .txt .zh {
    font-size: 12.5px;
    font-weight: 700;
    color: var(--ink);
    display: block;
  }
  .upload .txt .en {
    display: block;
    font-size: 11px;
    color: var(--ink-soft);
    font-style: italic;
    margin-top: 2px;
  }
  .upload .txt .spec {
    display: inline-block;
    background: #fff;
    border: 1px solid var(--brand);
    color: var(--brand);
    font-size: 10.5px;
    padding: 2px 9px;
    border-radius: 10px;
    margin-top: 6px;
    font-weight: 700;
    letter-spacing: 0.3px;
  }
  .upload .btn {
    background: var(--brand);
    color: #fff;
    border: none;
    padding: 9px 18px;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 700;
    cursor: pointer;
    border-radius: 2px;
    letter-spacing: 0.3px;
    white-space: nowrap;
  }
  .upload:hover .btn { background: #163f70; }
  .upload input[type="file"] { display: none; }
  .upload .filelist {
    grid-column: 1 / -1;
    margin-top: 3mm;
    padding-top: 3mm;
    border-top: 1px dotted var(--brand);
    display: none;
    flex-wrap: wrap;
    gap: 6px;
  }
  .upload .filelist.has { display: flex; }
  .upload .filelist .chip {
    background: #fff;
    border: 1px solid var(--brand);
    padding: 3px 10px;
    font-size: 11.5px;
    color: var(--brand);
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
  }
  .upload .filelist .chip .rm {
    cursor: pointer;
    color: var(--brand-accent);
    font-weight: 700;
    font-size: 13px;
    line-height: 1;
  }