:root {
  font-family: "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color: #1d1d1f;
  background: #f3f4f6;
  font-synthesis: none;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 1180px; }
button, input, select { font: inherit; }

.app-shell {
  display: grid;
  grid-template-columns: 360px minmax(780px, 1fr);
  min-height: 100vh;
}

.form-panel {
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  padding: 28px 26px 36px;
  background: #fff;
  border-right: 1px solid #e5e7eb;
}

.panel-header { margin-bottom: 24px; }
.panel-header h1 { margin: 4px 0 6px; font-size: 28px; }
.panel-header p { margin: 0; color: #6b7280; line-height: 1.6; }
.eyebrow { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

form { display: grid; gap: 17px; }
label { display: grid; gap: 7px; }
label > span { font-size: 14px; font-weight: 700; }
strong { color: #b91c1c; font-size: 11px; margin-left: 5px; }
em { color: #6b7280; font-style: normal; font-size: 11px; margin-left: 5px; }

input, select {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 9px;
  padding: 10px 11px;
  background: #fff;
  color: #111827;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus { border-color: #d69d20; box-shadow: 0 0 0 3px rgba(214,157,32,.13); }
input.invalid { border-color: #dc2626; }
.field-error { min-height: 16px; color: #b91c1c; font-size: 12px; line-height: 1.35; }

.actions { display: grid; grid-template-columns: 1fr auto; gap: 10px; margin-top: 4px; }
button {
  border: 0;
  border-radius: 9px;
  padding: 11px 14px;
  cursor: pointer;
  font-weight: 800;
  background: #b87d00;
  color: #fff;
}
button:hover { filter: brightness(.96); }
button.secondary { background: #eef0f3; color: #30343b; }
.form-message { min-height: 20px; margin: 0; font-size: 13px; color: #b91c1c; }

.preview-panel { padding: 22px 28px 34px; }
.preview-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1180px;
  margin: 0 auto 10px;
  color: #5f6368;
  font-size: 13px;
  font-weight: 700;
}
.preview-stage {
  display: grid;
  place-items: center;
  min-height: calc(100vh - 70px);
}

.certificate {
  position: relative;
  width: min(100%, 1180px);
  aspect-ratio: 2000 / 1414;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 16px 50px rgba(0,0,0,.14);
  container-type: inline-size;
}
.certificate-bg { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: fill; user-select: none; }
.overlay {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  overflow: hidden;
  color: #000;
  font-family: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  font-weight: 700;
  line-height: 1;
}

.department { left: 31.0%; top: 20.1%; width: 26.2%; height: 6.0%; font-size: 3.0cqw; }
.award { left: 30.0%; top: 28.1%; width: 40.0%; height: 8.8%; font-size: 5.0cqw; font-weight: 800; }
.classroom { left: 30.0%; top: 39.2%; width: 30.0%; height: 5.8%; font-size: 2.7cqw; }
.furigana { left: 36.0%; top: 43.1%; width: 29.0%; height: 3.8%; font-size: 1.45cqw; letter-spacing: .12em; }
.student { left: 34.0%; top: 46.2%; width: 27.5%; height: 6.6%; font-size: 3.5cqw; }
.work { left: 45.0%; top: 54.3%; width: 25.5%; height: 6.2%; font-size: 2.3cqw; }
.date { left: 42.0%; top: 74.7%; width: 24.0%; height: 4.0%; font-size: 1.65cqw; }

@media (max-width: 1400px) {
  body { min-width: 1050px; }
  .app-shell { grid-template-columns: 330px minmax(700px, 1fr); }
  .form-panel { padding-inline: 22px; }
  .preview-panel { padding-inline: 18px; }
}

@page { size: A4 landscape; margin: 0; }
@media print {
  html, body { width: 297mm; height: 210mm; margin: 0; padding: 0; min-width: 0; background: #fff; }
  body * { visibility: hidden !important; }
  #certificate, #certificate * { visibility: visible !important; }
  #certificate {
    position: fixed;
    inset: 0;
    width: 297mm;
    height: 210mm;
    max-width: none;
    box-shadow: none;
    overflow: hidden;
  }
  .overlay { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .department { font-size: 8.2mm; }
  .award { font-size: 14.5mm; }
  .classroom { font-size: 7.6mm; }
  .furigana { font-size: 4.2mm; }
  .student { font-size: 10.5mm; }
  .work { font-size: 6.8mm; }
  .date { font-size: 4.7mm; }
}
