@font-face {
  font-family: "AK Kabir Handwriting";
  src: url("assets/custom/AK-Kabir-Handwriting-Regular.woff2") format("woff2");
  font-display: swap;
}

:root {
  --ink: #2e281f;
  --muted: #746b5d;
  --paper: #fffdf8;
  --cream: #f5eddf;
  --gold: #b48738;
  --deep: #302419;
  --line: #ddcfb8;
  --shadow: 0 18px 50px rgba(76, 55, 27, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 8% 8%, rgba(180, 134, 54, 0.12), transparent 22rem),
    #f6f1e8;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
}

button, input, textarea, select { font: inherit; }
button { cursor: pointer; }

.topbar {
  min-height: 170px;
  padding: 32px clamp(20px, 6vw, 86px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 30px;
  color: white;
  background:
    radial-gradient(circle at 88% 10%, rgba(221, 182, 105, 0.25), transparent 28%),
    linear-gradient(125deg, #211912, #594025);
  border-bottom: 4px solid var(--gold);
}

.eyebrow {
  margin: 0 0 9px;
  color: #e4c98f;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .19em;
}

.topbar h1 {
  margin: 0;
  font: 700 clamp(30px, 4.5vw, 52px)/1.1 Georgia, serif;
}

.topbar > div > p:last-child {
  margin: 10px 0 0;
  color: #e8dfd2;
  line-height: 1.55;
}

.primary, .secondary, .ghost {
  border-radius: 10px;
  padding: 12px 17px;
  font-weight: 700;
}

.primary {
  flex: 0 0 auto;
  border: 0;
  color: white;
  background: var(--gold);
  box-shadow: 0 8px 20px rgba(0,0,0,.22);
}

.secondary {
  border: 1px solid var(--gold);
  color: var(--deep);
  background: #fffaf0;
}

.ghost {
  border: 1px solid var(--line);
  color: var(--muted);
  background: white;
}

.workspace {
  width: min(1480px, calc(100% - 34px));
  margin: 30px auto 60px;
  display: grid;
  grid-template-columns: minmax(360px, .84fr) minmax(680px, 1.16fr);
  gap: 28px;
  align-items: start;
}

.editor {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
  padding: 25px;
  background: rgba(255,255,255,.94);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.section-title {
  display: flex;
  align-items: center;
  gap: 13px;
  margin-bottom: 20px;
}

.section-title > span {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  color: #f2d59a;
  background: var(--deep);
  font-weight: 700;
}

.section-title h2 {
  margin: 0;
  font: 700 25px Georgia, serif;
}

.section-title p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 15px;
}

label > span {
  color: #574c3e;
  font-size: 13px;
  font-weight: 700;
}

input[type="text"], input[type="search"], textarea, select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  outline: none;
  color: var(--ink);
  background: #fffefa;
}

input:focus, textarea:focus, select:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(180,134,54,.14);
}

textarea {
  min-height: 220px;
  resize: vertical;
  line-height: 1.55;
}

#fontStyleInput { min-height: 176px; }

.two-columns, .font-toolbar, .control-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 14px;
}

.font-sample {
  min-height: 66px;
  margin-top: 9px;
  padding: 11px 13px;
  display: flex;
  align-items: center;
  overflow: hidden;
  border: 1px dashed #c8b791;
  border-radius: 10px;
  color: #102452;
  background: #fffaf0;
  font: 26px/1.35 "AK Kabir Handwriting", cursive;
}

.range-row {
  min-height: 38px;
  display: grid;
  grid-template-columns: 1fr 62px;
  align-items: center;
  gap: 8px;
}

.range-row input { accent-color: var(--gold); }
.range-row output {
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.colour {
  width: 100%;
  height: 40px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
}

.actions {
  margin-top: 20px;
  padding-top: 17px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  border-top: 1px solid var(--line);
}

.status {
  margin: 16px 0 0;
  color: #5d5346;
  font-size: 12px;
}

.tip {
  margin: 12px 0 0;
  padding: 11px;
  border-left: 4px solid var(--gold);
  color: #665946;
  background: var(--cream);
  font-size: 12px;
  line-height: 1.5;
}

.preview { min-width: 0; }

.paper {
  width: 210mm;
  min-height: 297mm;
  margin: 0 auto;
  padding: 17mm 18mm 14mm;
  display: flex;
  flex-direction: column;
  color: #102452;
  background-color: var(--paper);
  border: 1px solid #dfd3c1;
  box-shadow: var(--shadow);
}

.paper.ruled {
  background-image: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 12.6mm,
    rgba(72,120,170,.13) 12.8mm,
    transparent 13mm
  );
}

.letterhead {
  padding-bottom: 13px;
  text-align: center;
  background: inherit;
}

.letterhead p {
  margin: 0 0 7px;
  color: #9a742f;
  font: 700 9px/1.2 Arial, sans-serif;
  letter-spacing: .17em;
}

.letterhead h2 {
  margin: 0;
  color: #302419;
  font: 700 23px/1.2 Georgia, serif;
  letter-spacing: .035em;
}

.rule {
  height: 7px;
  margin-top: 9px;
  border-top: 2px solid #9d752e;
  border-bottom: 1px solid #cdb17b;
}

.rule span {
  display: block;
  width: 84px;
  height: 5px;
  margin: -3px auto 0;
  background: #9d752e;
}

.document-meta {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 4px;
  color: #8c7c64;
  font: 700 9px Arial, sans-serif;
  letter-spacing: .08em;
}

#headlinePreview {
  margin: 25px 0 20px;
  color: inherit;
  font-size: 1.32em;
  text-align: center;
  text-decoration: underline;
  text-underline-offset: 7px;
}

.handwriting-text {
  flex: 1;
  min-height: 210mm;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: "AK Kabir Handwriting", cursive;
  font-size: 27px;
  line-height: 1.8;
}

.paper-footer {
  margin-top: 14mm;
  padding-top: 7px;
  display: flex;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid rgba(157,117,46,.55);
  color: #7c6b52;
  font: 10px Arial, sans-serif;
}

@media (max-width: 1180px) {
  .workspace { grid-template-columns: 1fr; }
  .editor { position: static; max-height: none; }
  .paper { transform-origin: top center; }
}

@media (max-width: 860px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .workspace { width: min(100% - 18px, 760px); }
  .two-columns, .font-toolbar, .control-grid { grid-template-columns: 1fr; }
  .preview { overflow-x: auto; }
  .paper { margin-left: 0; }
}

@page { size: A4; margin: 0; }

@media print {
  html, body { width: 210mm; margin: 0; background: white; }
  .no-print { display: none !important; }
  .workspace { display: block; width: 210mm; margin: 0; }
  .preview { width: 210mm; }
  .paper {
    width: 210mm;
    min-height: 297mm;
    margin: 0;
    border: 0;
    box-shadow: none;
    break-after: page;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
