:root {
  --ivory: #f4f2ed;
  --paper: #f8f6f1;
  --navy: #2b5885;
  --navy-deep: #214f7a;
  --blue-soft: #587b98;
  --ink: #30475a;
  --muted: #758695;
  --line: #d6dde0;
  --choice-border: #b9c8d1;
  --faq-border: #2b5885;
  --footer-line: #d9dddc;
  --error: #a53b32;
  --success: #2f6858;
  --shadow: 0 1rem 3rem rgba(43, 88, 133, 0.1);
  --serif: "Iowan Old Style", Georgia, "Noto Serif SC", "Songti SC", "STSong", serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans SC", sans-serif;
}

* { box-sizing: border-box; }

html {
  min-width: 20rem;
  background-color: var(--ivory);
  background-image: url("assets/ivory-paper-texture.png");
  background-repeat: repeat;
  color: var(--ink);
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--ivory);
  background-image: url("assets/ivory-paper-texture.png");
  background-repeat: repeat;
  font-family: var(--sans);
  letter-spacing: 0;
}

button, input, textarea { font: inherit; letter-spacing: 0; }
button, a, label[for] { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: var(--navy); text-underline-offset: 0.2em; }

.app-shell {
  min-height: 100vh;
  padding: 0 4vw;
}

.form-frame {
  width: min(100%, 92rem);
  min-height: 100vh;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: transparent;
}

.step-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  min-height: 7rem;
  padding: 1.25rem 1rem;
  border-bottom: 1px solid var(--line);
}

.mini-logo { width: 6rem; height: auto; object-fit: contain; }
.step-meta { width: min(100%, 24rem); margin-left: auto; color: var(--muted); font-size: 0.9rem; }
.progress-track { height: 0.18rem; margin-top: 0.55rem; overflow: hidden; background: #dfe3e2; }
.progress-track span { display: block; width: 0; height: 100%; background: var(--navy); transition: width 260ms ease; }

#thesis-form { display: flex; flex: 1; }

.panel {
  width: min(100%, 68rem);
  min-height: calc(100vh - 11rem);
  margin: 0 auto;
  padding: clamp(3rem, 8vh, 7rem) 2rem 2rem;
  display: flex;
  flex-direction: column;
  animation: panel-in 260ms ease both;
}

.panel[hidden], [hidden] { display: none !important; }

@keyframes panel-in {
  from { opacity: 0; transform: translateY(0.55rem); }
  to { opacity: 1; transform: translateY(0); }
}

.brand-intro { margin: 0 auto 3.2rem; text-align: center; }
.brand-logo { width: min(100%, 7.5rem); height: auto; }
.slogan { margin: 0.35rem 0 0; color: var(--blue-soft); font-family: var(--serif); font-size: 1rem; }

.panel-copy { margin-bottom: 2.5rem; }
.panel:not([data-step="1"]):not([data-step="6"]) {
  padding-top: clamp(2.4rem, 5.5vh, 4.5rem);
}
.panel:not([data-step="1"]):not([data-step="6"]) .panel-copy { margin-bottom: 1.8rem; }
.centered-copy { text-align: center; }
.eyebrow { margin: 0 0 0.55rem; color: var(--blue-soft); font-size: 0.72rem; font-weight: 700; letter-spacing: 0; text-transform: uppercase; }
h1, h2 { margin: 0; color: var(--navy-deep); font-family: var(--serif); font-weight: 600; line-height: 1.24; }
h1:focus { outline: none; }
h1 { font-size: 3.85rem; }
.lang-title-break { display: none; }
h2 { font-size: 1.28rem; }
.supporting { margin: 0.9rem 0 0; color: var(--muted); font-size: 1.15rem; line-height: 1.65; }
.supporting-stack { display: grid; gap: 0.5rem; margin-top: 0.9rem; }
.supporting-stack .supporting { margin: 0; }
.step-one-count { display: none; }

.language-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1.5rem; margin-top: 1rem; }
.language-choice {
  width: 100%;
  min-height: 7.2rem;
  padding: 1.5rem 1.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  text-align: left;
  color: var(--navy-deep);
  background: transparent;
  border: 1px solid var(--choice-border);
  border-radius: 0.4rem;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}
.language-choice:hover, .language-choice:focus-visible { border-color: var(--navy); background: rgba(255, 255, 255, 0.34); transform: translateY(-1px); outline: none; }
.choice-name { font-family: var(--serif); font-size: 1.6rem; font-weight: 600; }
.choice-note { max-width: 11rem; color: var(--muted); font-size: 0.9rem; text-align: right; line-height: 1.35; }
.choice-arrow { flex: 0 0 auto; color: var(--navy); font-family: var(--serif); font-size: 1.8rem; font-weight: 400; line-height: 1; }

.field-group { display: grid; gap: 0.55rem; }
.grow-field { flex: 1; }
.field-group > label:not(.upload-control) { color: var(--navy-deep); font-size: 0.84rem; font-weight: 700; }
input[type="email"], textarea {
  width: 100%;
  color: var(--ink);
  background: #faf9f5;
  border: 1px solid #c7d1d6;
  border-radius: 0.25rem;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}
input[type="email"] { min-height: 4.2rem; padding: 0.9rem 1rem; }
textarea { min-height: 15rem; padding: 0.85rem 0.9rem; resize: vertical; line-height: 1.55; }
input[type="email"]:focus, textarea:focus { border-color: var(--navy); box-shadow: 0 0 0 0.18rem rgba(43, 88, 133, 0.1); }
.has-error { border-color: var(--error) !important; }
.field-error, .submit-error { min-height: 1.1rem; margin: 0; color: var(--error); font-size: 0.78rem; line-height: 1.35; }

.upload-zone {
  min-height: 12rem;
  padding: 1.25rem;
  display: grid;
  place-items: center;
  color: var(--navy);
  background: rgba(43, 88, 133, 0.018);
  border: 1px dashed #8fa5b4;
  border-radius: 0.3rem;
}
.upload-zone:hover, .upload-zone:focus-within { background: rgba(43, 88, 133, 0.045); border-color: var(--navy); }
.upload-control {
  width: 100%;
  min-height: 9.5rem;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 0.35rem;
  text-align: center;
  color: var(--navy);
  cursor: pointer;
}
.upload-control:hover .upload-label { text-decoration: underline; text-underline-offset: 0.25rem; }
.upload-icon { font-family: var(--serif); font-size: 1.55rem; line-height: 1; }
.upload-label { font-size: 0.9rem; font-weight: 700; }
.upload-meta { max-width: 100%; overflow-wrap: anywhere; color: var(--muted); font-size: 0.75rem; }

.selected-file-card {
  width: min(100%, 31rem);
  min-height: 7.2rem;
  padding: 1.1rem 1rem;
  display: grid;
  grid-template-columns: 3.4rem minmax(0, 1fr) 2.8rem;
  align-items: center;
  gap: 1rem;
  background: #faf9f5;
  border: 1px solid #d0d8db;
  box-shadow: 0 0.25rem 0.7rem rgba(43, 88, 133, 0.07);
}
.file-card-icon { display: grid; place-items: center; color: var(--navy); font-size: 2.7rem; transform: rotate(90deg); }
.file-card-copy { min-width: 0; display: grid; gap: 0.3rem; }
.file-card-copy strong { overflow: hidden; color: var(--ink); font-size: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.file-card-copy span { color: var(--muted); font-size: 0.75rem; }
.remove-file-button {
  width: 2.75rem;
  height: 2.75rem;
  display: grid;
  place-items: center;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 50%;
  font-size: 1.3rem;
}
.remove-file-button:hover, .remove-file-button:focus-visible { color: var(--error); background: rgba(165, 59, 50, 0.08); outline: none; }

.consent-row { margin-top: 1rem; display: grid; grid-template-columns: 1.1rem 1fr; gap: 0.7rem; color: #526879; font-size: 0.78rem; line-height: 1.55; }
.consent-row input { width: 1.05rem; height: 1.05rem; margin: 0.12rem 0 0; accent-color: var(--navy); }
.consent-error { margin-left: 1.8rem; }

.submission-summary { margin-top: 1.35rem; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.submission-summary div { min-height: 3.4rem; padding: 0.7rem 0; display: grid; grid-template-columns: 6rem 1fr; align-items: center; gap: 0.8rem; }
.submission-summary div + div { border-top: 1px solid var(--line); }
.submission-summary span { color: var(--muted); font-size: 0.76rem; }
.submission-summary strong { min-width: 0; overflow-wrap: anywhere; color: var(--navy-deep); font-size: 0.78rem; text-align: right; }

.panel-actions { width: min(100%, 36rem); margin: auto auto 0; padding-top: 2.5rem; display: grid; grid-template-columns: 1fr 1.45fr; gap: 1.2rem; }
.primary-button, .back-button {
  min-height: 4rem;
  padding: 0.9rem 1.2rem;
  border-radius: 0.25rem;
  font-weight: 700;
}
.primary-button { display: inline-flex; align-items: center; justify-content: center; gap: 0.65rem; color: white; background: var(--navy); border: 1px solid var(--navy); }
.primary-button:hover, .primary-button:focus-visible { background: var(--navy-deep); border-color: var(--navy-deep); outline: none; }
.primary-button:disabled { cursor: wait; opacity: 0.65; }
.back-button { color: var(--navy); background: transparent; border: 1px solid #b9c8d1; }
.back-button:hover, .back-button:focus-visible { background: rgba(255, 255, 255, 0.3); border-color: var(--navy); outline: none; }

.success-panel { align-items: center; justify-content: center; text-align: center; }
.success-logo { width: 7.5rem; margin-bottom: 2.5rem; }
.success-mark { width: 3.6rem; height: 3.6rem; margin-bottom: 1.4rem; display: grid; place-items: center; color: white; background: var(--success); border-radius: 50%; font-size: 1.6rem; }
.success-message { max-width: 20rem; margin: 1rem auto 0; color: var(--muted); line-height: 1.7; }
.success-email { margin: 1rem 0 0; color: var(--navy); font-weight: 700; }
.home-button { width: min(100%, 22rem); margin-top: 3rem; }

.site-footer { min-height: 4.2rem; margin-top: auto; padding: 1rem 1.5rem; display: flex; justify-content: center; align-items: center; gap: 0.65rem; color: #a2a7a9; border-top: 1px solid var(--footer-line); font-size: 0.74rem; font-weight: 400; }
.site-footer a { color: #7f898f; text-decoration: none; }
.site-footer a:hover { color: var(--navy); text-decoration: underline; }

.faq-trigger {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 20;
  min-width: 10rem;
  height: 3rem;
  padding: 0.3rem 1.15rem 0.3rem 0.32rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  color: var(--navy-deep);
  background: var(--paper);
  border: 2px solid var(--faq-border);
  border-radius: 999px;
  box-shadow: 0 0.65rem 1.5rem rgba(43, 88, 133, 0.14);
  font-size: 0.9rem;
  font-weight: 600;
}
.faq-trigger-icon { width: 2.4rem; height: 2.4rem; display: grid; flex: 0 0 auto; place-items: center; color: white; background: var(--navy-deep); border-radius: 50%; font-family: var(--serif); font-size: 1.15rem; }
.faq-trigger-label { white-space: nowrap; color: var(--navy-deep); }
.faq-trigger:hover, .faq-trigger:focus-visible { border-color: var(--navy-deep); background: #fbfaf6; outline: 0.18rem solid rgba(43, 88, 133, 0.08); }
.faq-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.1rem;
  z-index: 19;
  width: min(calc(100vw - 2.5rem), 24rem);
  max-height: min(38rem, calc(100vh - 7rem));
  overflow: auto;
  background: var(--paper);
  border: 1px solid rgba(18, 60, 90, 0.2);
  border-radius: 0.4rem;
  box-shadow: var(--shadow);
}
.faq-header { position: sticky; top: 0; z-index: 1; padding: 1.15rem 1.2rem; display: flex; align-items: center; justify-content: space-between; background: var(--paper); border-bottom: 1px solid var(--line); }
.faq-header .eyebrow { margin-bottom: 0.2rem; }
.icon-button { width: 2.3rem; height: 2.3rem; color: var(--navy); background: transparent; border: 0; font-size: 1.6rem; }
.faq-item { border-bottom: 1px solid var(--line); }
.faq-question { width: 100%; padding: 1rem 1.2rem; display: flex; justify-content: space-between; gap: 1rem; text-align: left; color: var(--ink); background: transparent; border: 0; font-size: 0.86rem; font-weight: 700; line-height: 1.4; }
.faq-question span:last-child { color: var(--blue-soft); font-size: 1.05rem; }
.faq-answer { margin: 0; padding: 0 1.2rem 1rem; color: var(--muted); font-size: 0.8rem; line-height: 1.65; }

.confirm-dialog { width: min(calc(100% - 2rem), 24rem); padding: 0; color: var(--ink); background: var(--paper); border: 1px solid rgba(18, 60, 90, 0.2); border-radius: 0.4rem; box-shadow: var(--shadow); }
.confirm-dialog::backdrop { background: rgba(11, 31, 44, 0.42); }
.confirm-dialog form { padding: 1.5rem; }
.confirm-dialog p:not(.eyebrow) { color: var(--muted); line-height: 1.6; }
.dialog-actions { margin-top: 1.5rem; display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }

.static-page { min-height: 100vh; padding: 3rem 1.5rem; }
.static-shell { width: min(100%, 52rem); margin: 0 auto; padding: 2rem; background: transparent; }
.static-logo { width: 7.5rem; margin-bottom: 2.5rem; }
.static-shell h1 { margin-bottom: 1rem; }
.static-shell p { color: var(--muted); line-height: 1.75; }
.placeholder-policy { margin: 2rem 0; padding: 1.25rem 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.text-link { display: inline-flex; margin-top: 1rem; font-weight: 700; }
.feedback-form { margin-top: 2rem; display: grid; gap: 1rem; }
.feedback-form textarea { min-height: 12rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

@media (max-width: 37rem) {
  .app-shell { display: block; padding: 0; }
  .form-frame { width: 100%; min-height: 100vh; }
  .step-header { min-height: 6.2rem; padding: 1rem 1.1rem; }
  .mini-logo { width: 5.25rem; }
  .step-meta { width: 10rem; font-size: 0.8rem; }
  .panel { min-height: calc(100vh - 10.4rem); padding: 2.4rem 1.1rem 1.25rem; }
  #thesis-form[data-current-step="1"] { flex: 0 0 auto; }
  .panel[data-step="1"] { min-height: auto; padding: 2.15rem 1rem 0.75rem; }
  .panel:not([data-step="1"]):not([data-step="6"]) { padding-top: 1.65rem; }
  .panel:not([data-step="1"]):not([data-step="6"]) .panel-copy { margin-bottom: 1.35rem; }
  .panel[data-step="1"] .brand-intro { margin-bottom: 2.15rem; }
  .panel[data-step="1"] .brand-logo { width: 6.4rem; }
  .panel[data-step="1"] .slogan {
    position: relative;
    margin-top: 1.45rem;
    padding-bottom: 1rem;
    color: var(--blue-soft);
    font-size: 1.02rem;
    letter-spacing: 0.12em;
  }
  .panel[data-step="1"] .slogan::after {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0;
    width: 9.5rem;
    height: 0.45rem;
    transform: translateX(-50%);
    background:
      linear-gradient(var(--line), var(--line)) left top / 44% 1px no-repeat,
      linear-gradient(var(--line), var(--line)) right top / 44% 1px no-repeat;
    border-bottom: 1px solid transparent;
  }
  .panel[data-step="1"] .slogan::before {
    content: "";
    position: absolute;
    left: 50%;
    bottom: 0.12rem;
    width: 0.42rem;
    height: 0.42rem;
    transform: translateX(-50%) rotate(45deg);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
  }
  .panel[data-step="1"] .panel-copy { margin-bottom: 0; }
  .panel[data-step="1"] .eyebrow { display: none; }
  .panel[data-step="1"] h1 {
    max-width: 21rem;
    margin: 0 auto;
    font-size: 2.55rem;
    line-height: 1.42;
  }
  .lang-title-break { display: inline; }
  .panel[data-step="1"] .supporting { margin-top: 0.7rem; font-size: 1rem; line-height: 1.45; }
  .step-one-count {
    margin: 1.5rem 0 1.45rem;
    display: flex;
    justify-content: center;
    gap: 0.35rem;
    color: #b5b9bb;
    font-size: 0.92rem;
    line-height: 1;
  }
  .step-one-count strong { color: var(--navy); font-weight: 500; }
  h1 { font-size: 2.8rem; }
  .panel[data-step="2"] h1,
  .panel[data-step="3"] h1,
  .panel[data-step="4"] h1,
  .panel[data-step="5"] h1 {
    white-space: nowrap;
  }
  .panel[data-step="2"] h1 { font-size: 2.25rem; }
  .panel[data-step="3"] h1 { font-size: 2rem; }
  .panel[data-step="4"] h1,
  .panel[data-step="5"] h1 { font-size: 1.7rem; }
  html[lang="en"] .panel[data-step="2"] h1 { font-size: 2.05rem; }
  html[lang="en"] .panel[data-step="3"] h1 { font-size: 1.58rem; }
  html[lang="en"] .panel[data-step="4"] h1,
  html[lang="en"] .panel[data-step="5"] h1 { font-size: 1.18rem; }
  .supporting-stack { gap: 0.35rem; margin-top: 0.7rem; }
  .supporting-stack .supporting { font-size: 0.92rem; line-height: 1.55; }
  .language-options { grid-template-columns: 1fr; gap: 0.9rem; margin-top: 0; }
  .language-choice {
    min-height: 6.1rem;
    padding: 1.15rem 1.45rem;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name arrow"
      "note arrow";
    column-gap: 1rem;
    row-gap: 0.25rem;
  }
  .choice-name { font-size: 1.4rem; }
  .choice-note { font-size: 0.85rem; }
  .panel[data-step="1"] .choice-name { grid-area: name; align-self: end; }
  .panel[data-step="1"] .choice-note { grid-area: note; max-width: none; align-self: start; text-align: left; }
  .panel[data-step="1"] .choice-arrow { grid-area: arrow; align-self: center; font-size: 2rem; }
  .panel-actions { width: 100%; gap: 0.75rem; }
  .upload-zone { min-height: 11rem; padding: 0.8rem; }
  .selected-file-card { grid-template-columns: 2.7rem minmax(0, 1fr) 2.75rem; gap: 0.7rem; }
  .file-card-icon { font-size: 2.2rem; }
  .faq-trigger {
    position: relative;
    right: auto;
    bottom: auto;
    width: fit-content;
    min-width: 10rem;
    height: 3rem;
    margin: 1.75rem 1.15rem 1.6rem auto;
    padding: 0.3rem 1.15rem 0.3rem 0.32rem;
    border-radius: 999px;
  }
  .faq-trigger-icon { width: 2.4rem; height: 2.4rem; }
  .faq-trigger-label { display: inline; }
  .faq-panel { right: 0.75rem; bottom: 1rem; width: calc(100vw - 1.5rem); }
  .site-footer { min-height: 4rem; margin-top: 0; padding: 1rem; }
  .static-page { padding: 0; }
  .static-shell { min-height: 100vh; padding: 1.5rem 0; }
}

@media (max-width: 22rem) {
  html[lang="en"] .panel[data-step="3"] h1,
  html[lang="en"] .panel[data-step="4"] h1 {
    white-space: normal;
  }
}

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