:root {
  --ink: #1A1A1A;
  --accent: #7A2530;
  --muted: #444444;
  --line: #AAAAAA;
  --shell: #EFECE5;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--shell);
  display: flex;
  flex-direction: row;
  min-height: 100vh;
}

@media (max-width: 1024px) {
  body { flex-direction: column; }
}

/* ========== FORM PANEL ========== */
.form-panel {
  width: 400px;
  flex-shrink: 0;
  background: #fff;
  border-right: 1px solid #e5e7eb;
  padding: 24px;
  overflow-y: auto;
}

@media (max-width: 1024px) {
  .form-panel { width: 100%; border-right: none; border-bottom: 1px solid #e5e7eb; }
}

@media (max-width: 640px) {
  .form-panel { padding: 16px; }
}

.form-panel h1 {
  font-size: 18px;
  font-weight: 600;
  color: #1f2937;
  margin: 0 0 4px;
}

/* Devntric brand link in heading */
.brand-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}
.brand-link:hover { text-decoration: underline; }

.form-panel > p.subtitle {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 16px;
}

.field { display: block; margin-bottom: 12px; }
.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: #6b7280;
  margin-bottom: 4px;
}
.field input[type="text"],
.field select,
.field textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #111827;
}
.field textarea { resize: none; }
.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  box-shadow: 0 0 0 2px #9ca3af;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 24px 0 12px;
  padding-bottom: 4px;
  border-bottom: 1px solid #e5e7eb;
}
.section-title span.label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.section-title label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #6b7280;
  cursor: pointer;
}

/* Logo uploader */
.logo-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}
.logo-preview img {
  height: 64px;
  width: 64px;
  object-fit: contain;
  border: 1px solid #e5e7eb;
  border-radius: 4px;
  background: #fff;
}
.logo-preview button {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: #6b7280;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
}
.logo-preview button:hover { color: #dc2626; }

.logo-upload {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px dashed #d1d5db;
  border-radius: 6px;
  padding: 12px;
  font-size: 14px;
  color: #6b7280;
  cursor: pointer;
  margin-bottom: 8px;
}
.logo-upload:hover { background: #f9fafb; }
.logo-upload input { display: none; }

.logo-hint {
  font-size: 12px;
  color: #9ca3af;
  margin: 0 0 12px;
}

/* ========== STYLE SWITCHER ========== */
.style-switcher {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}
.style-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 10px 8px;
  cursor: pointer;
  font-size: 12px;
  color: #4b5563;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.style-option:hover { background: #f9fafb; }
.style-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.style-option:has(input:checked) {
  border-color: var(--accent);
  background: #fdf2f3;
  color: var(--accent);
  font-weight: 600;
}
.style-swatch {
  display: block;
  width: 100%;
  height: 36px;
  border-radius: 6px;
  border: 1px solid #e5e7eb;
}
.style-swatch-lu {
  background: #ffffff;
  border: 2px solid #1A1A1A;
}
.style-swatch-iu {
  background: linear-gradient(to bottom, #16692f 0 30%, #ffffff 30% 100%);
}
.style-swatch-lutable {
  background: #ffffff;
  border: 2px solid #7A2530;
  position: relative;
}
.style-swatch-lutable::after {
  content: "田";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: #7A2530;
  font-size: 14px;
}

/* Custom fields */
.custom-field-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: flex-start;
}
.custom-field-row input {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 14px;
  font-family: inherit;
  color: #111827;
}
.custom-field-row input.label-input { width: 33%; }
.custom-field-row input.value-input { flex: 1; }
.custom-field-row button {
  background: none;
  border: none;
  color: #9ca3af;
  cursor: pointer;
  padding: 6px;
  font-size: 16px;
}
.custom-field-row button:hover { color: #dc2626; }

.add-field-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: #4b5563;
  background: none;
  border: none;
  cursor: pointer;
  margin: 4px 0 24px;
  padding: 0;
}
.add-field-btn:hover { color: #111827; }

.download-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  font-weight: 600;
  font-size: 15px;
  border: none;
  border-radius: 8px;
  padding: 12px;
  cursor: pointer;
  background: var(--accent);
  letter-spacing: 0.3px;
  transition: background 0.15s;
}
.download-btn:hover { background: #621f28; }
.download-btn:active { background: #4e1820; transform: scale(0.99); }

.download-hint {
  font-size: 12px;
  color: #9ca3af;
  margin-top: 10px;
  text-align: center;
}
.hint-link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.hint-link:hover { text-decoration: underline; }

/* ========== PREVIEW PANEL ========== */
.preview-panel {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 32px 24px;
  overflow: auto;
  background: var(--shell);
}

@media (max-width: 640px) {
  .preview-panel { padding: 16px 8px; }
}

#cover-page-wrap {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  width: 794px;
  flex-shrink: 0;
  transform-origin: top center;
}

#cover-page {
  width: 794px;
  min-height: 1123px;
  background: #ffffff;
  padding: 14px;
  box-shadow: 0 6px 32px rgba(0, 0, 0, 0.14);
  box-sizing: border-box;
  font-family: "Times New Roman", Times, serif;
  color: var(--ink);
  flex-shrink: 0;
}

/* Visual scaling breakpoints */
@media (max-width: 1300px) { #cover-page-wrap { transform: scale(0.88); margin-bottom: -130px; } }
@media (max-width: 1150px) { #cover-page-wrap { transform: scale(0.78); margin-bottom: -247px; } }
@media (max-width: 1024px) { #cover-page-wrap { transform: scale(0.72); margin-bottom: -314px; } }
@media (max-width: 860px) { #cover-page-wrap { transform: scale(0.58); margin-bottom: -471px; } }
@media (max-width: 680px) { #cover-page-wrap { transform: scale(0.46); margin-bottom: -605px; } }
@media (max-width: 520px) { #cover-page-wrap { transform: scale(0.38); margin-bottom: -697px; } }
@media (max-width: 400px) { #cover-page-wrap { transform: scale(0.32); margin-bottom: -764px; } }

/* ========== COVER PAGE CONTENT (Default LU Look) ========== */
.cover-border {
  border: 2px solid var(--ink);
  padding: 44px 54px;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  min-height: calc(1123px - 28px);
}

.text-center { text-align: center; }

.cp-logo {
  height: 110px;
  width: auto;
  max-width: 200px;
  object-fit: contain;
  margin: 0 auto 16px;
  display: block;
}

.cp-university {
  font-size: 26px;
  font-weight: 700;
  line-height: 1.3;
}

.cp-department {
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 10px;
  margin-bottom: 10px;
  line-height: 1.3;
}

.cp-doctype {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  margin-top: 30px;
}

.cp-hr { display: none; }
.cp-title {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.4;
  margin-bottom: 10px;
}

.cp-plain-line, .cp-lv, .cp-section, .cp-semester, .cp-batch {
  margin-bottom: 6px;
  font-size: 19px;
  line-height: 1.65;
}
.cp-lv .lv-label { font-weight: 700; }

.cp-block { margin-top: 26px; }
.cp-block-heading {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 10px;
  color: var(--ink);
}

.cp-date {
  font-size: 19px;
  text-align: center;
  margin-top: 40px;
  padding-top: 10px;
  line-height: 1.65;
}
.cp-date .date-label { font-weight: 700; }

sup {
  font-size: 0.62em;
  vertical-align: super;
  line-height: 0;
}

/* ========== STYLE 03: LU TABLE SPECIFIC STYLES ========== */
.cp-student-table {
  margin: 15px auto;
  border-collapse: collapse;
  width: 85%;
  font-size: 19px;
  text-align: left;
}

.cp-student-table td {
  border: 1px solid var(--ink);
  padding: 8px 14px;
  line-height: 1.5;
}

.cp-student-table td:first-child {
  font-weight: 700;
  width: 30%;
  background-color: #fafafa;
}

/* ========== ISLAMIC UNIVERSITY STYLE (theme-iu) ========== */
#cover-page.theme-iu { font-family: "Times New Roman", Times, serif; }
#cover-page.theme-iu .cover-border { border: none; padding: 44px 54px 30px; }
#cover-page.theme-iu .cp-logo { height: 120px; margin-bottom: 18px; }
#cover-page.theme-iu .cp-university { color: #000000; font-size: 26px; font-weight: 700; }
#cover-page.theme-iu .cp-department { color: #000000; font-weight: 700; font-size: 20px; }
#cover-page.theme-iu .cp-doctype { color: #000000; font-size: 26px; font-weight: 700; margin-top: 26px; }
#cover-page.theme-iu .cp-title { color: #000000; font-size: 22px; }
#cover-page.theme-iu .cp-block-heading { color: #000000; text-decoration: underline; display: inline-block; }
#cover-page.theme-iu .cp-plain-line,
#cover-page.theme-iu .cp-lv,
#cover-page.theme-iu .cp-section,
#cover-page.theme-iu .cp-semester,
#cover-page.theme-iu .cp-batch,
#cover-page.theme-iu .cp-date { font-size: 18px; }

#cover-page.theme-iu #cpSubmittedToBlock,
#cover-page.theme-iu #cpSubmittedByBlock { text-align: left; display: inline-block; }
#cover-page.theme-iu #cpSubmittedByBlock { align-self: flex-end; margin-top: 20px; }
#cover-page.theme-iu .cp-block { display: flex; flex-direction: column; }

/* ========== PRINT ========== */
@media print {
  body * { visibility: hidden; }
  #cover-page, #cover-page * { visibility: visible; }
  #cover-page-wrap {
    position: fixed;
    inset: 0;
    transform: none !important;
    margin: 0 !important;
    width: 210mm !important;
  }
  #cover-page {
    box-shadow: none !important;
    width: 210mm !important;
    min-height: 297mm !important;
    padding: 4mm !important;
  }
  .cover-border {
    min-height: calc(297mm - 8mm) !important;
    padding: 14mm 18mm !important;
  }
  .preview-panel { padding: 0; }
  @page { size: A4; margin: 0; }
}

.hidden { display: none !important; }