:root {
  --brand: #be185d;
  --brand-dark: #9d174d;
  --ink: #0f172a;
  --muted: #64748b;
  --bg: #f8fafc;
  --card: #ffffff;
  --line: #e2e8f0;
  --good: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --radius: 14px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 8px 24px rgba(15, 23, 42, 0.05);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.6;
}

.container { max-width: 920px; margin: 0 auto; padding: 0 20px; }

/* Header */
.site-header {
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 50;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 62px;
}

.logo {
  font-size: 1.35rem;
  font-weight: 800;
  text-decoration: none;
  color: var(--ink);
  letter-spacing: -0.5px;
}

.logo span { color: var(--brand); }

.nav { display: flex; gap: 20px; }

.nav a {
  text-decoration: none;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.95rem;
}

.nav a:hover { color: var(--brand); }

.lang-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(100, 116, 139, 0.10);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px;
  white-space: nowrap;
}

.lang-switch a,
.lang-switch .current {
  display: inline-block;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.6px;
  text-decoration: none;
  color: var(--muted);
}

.lang-switch a:hover { color: var(--ink); background: rgba(100, 116, 139, 0.14); }

.lang-switch .current { background: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(109, 40, 217, 0.35); }

/* Hero */
.hero { text-align: center; padding: 48px 20px 12px; }

.hero h1 {
  font-size: 2.35rem;
  line-height: 1.2;
  margin: 0 0 14px;
  letter-spacing: -1px;
}

.hero p {
  font-size: 1.1rem;
  color: var(--muted);
  max-width: 640px;
  margin: 0 auto;
}

.badge {
  display: inline-block;
  background: #f5f3ff;
  color: var(--brand-dark);
  font-weight: 700;
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 999px;
  margin-bottom: 16px;
}

/* Tool grid */
.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 16px;
  margin: 32px 0 40px;
}

.tool-card {
  display: block;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  text-decoration: none;
  color: inherit;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.tool-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: #ddd6fe;
}

.tool-card .icon { font-size: 1.6rem; margin-bottom: 8px; }

.tool-card h3 { margin: 0 0 6px; font-size: 1.05rem; color: var(--brand-dark); }

.tool-card p { margin: 0; font-size: 0.9rem; color: var(--muted); }

/* Page title area */
.breadcrumb { font-size: 0.85rem; color: var(--muted); margin: 24px 0 8px; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--brand); }

h1 { font-size: 1.9rem; line-height: 1.25; margin: 0 0 10px; letter-spacing: -0.5px; }

.lead { color: var(--muted); font-size: 1.05rem; margin: 0 0 24px; }

/* Cards & forms */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 28px;
}

.field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
}

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }

.field label { font-weight: 600; font-size: 0.9rem; }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 1rem;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(109, 40, 217, 0.15);
}

.hint { font-size: 0.8rem; color: var(--muted); }

/* Dropzone & file list */
.dropzone {
  border: 2px dashed #c4b5fd;
  border-radius: 14px;
  background: #faf5ff;
  padding: 38px 20px;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.dropzone:hover, .dropzone.dragover {
  background: #f3e8ff;
  border-color: var(--brand);
}

.dropzone .dz-icon { font-size: 2.1rem; margin-bottom: 8px; }
.dropzone .dz-text { font-weight: 700; }
.dropzone .dz-sub { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }

.file-list { margin-top: 14px; display: flex; flex-direction: column; gap: 8px; }

.file-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 13px;
  font-size: 0.9rem;
}

.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-btns { display: flex; gap: 6px; flex: none; }

/* PDF editor / signature */
.pdf-nav { display: flex; align-items: center; gap: 10px; margin: 12px 0; flex-wrap: wrap; }
.pdf-stage { position: relative; display: inline-block; max-width: 100%; border: 1px solid var(--line); border-radius: 10px; }
.pdf-stage canvas { display: block; max-width: 100%; height: auto; border-radius: 10px; }
.pdf-overlay { position: absolute; inset: 0; }
.pdf-el { position: absolute; cursor: move; touch-action: none; }
.pdf-el .del-badge {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--bad);
  color: #fff;
  font-size: 12px;
  line-height: 22px;
  text-align: center;
  cursor: pointer;
  font-weight: 700;
  display: none;
}

.pdf-el:hover .del-badge,
.pdf-el.selected .del-badge {
  display: block;
}

.pdf-num-preview {
  position: absolute;
  color: #64748b;
  font-family: Arial, Helvetica, sans-serif;
  pointer-events: none;
  opacity: 0.85;
}

.draw-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 6;
}

.draw-canvas.drawing {
  pointer-events: auto;
  cursor: crosshair;
}

.draw-options {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  flex-wrap: wrap;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 12px;
  margin: 0 0 12px;
}

.draw-options .field { margin-bottom: 0; }

.draw-swatches { display: flex; gap: 6px; align-items: center; }

.swatch {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
  cursor: pointer;
  padding: 0;
}

.swatch.selected { box-shadow: 0 0 0 2px var(--brand); }
.pdf-el.selected { outline: 1.5px dashed var(--brand); }
.pdf-el img, .pdf-el .svg-mark { display: block; pointer-events: none; }
.sig-pad { background: #fff; border: 2px dashed #c4b5fd; border-radius: 12px; touch-action: none; max-width: 100%; }
.editor-toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.editor-toolbar .field { margin-bottom: 0; }

/* Word-style editor ribbon */
.editor-ribbon {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 7px 9px;
  margin: 16px 0 12px;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.06);
}

.ribbon-group {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 9px;
  border-right: 1px solid var(--line);
}

.ribbon-group:first-child { padding-left: 2px; }
.ribbon-group:last-child { border-right: none; padding-right: 2px; }

.icon-btn {
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: #334155;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  font-size: 14px;
  flex: none;
}

.icon-btn:hover { background: #f1f5f9; border-color: var(--line); }
.icon-btn:active { transform: translateY(1px); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn:disabled:hover { background: transparent; border-color: transparent; }

.icon-btn.active {
  background: #ede9fe;
  border-color: #c4b5fd;
  color: var(--brand);
}

.icon-btn.active svg {
  stroke-width: 2.8;
}
.icon-btn:has(.hidden-check:checked) {
  background: #ede9fe;
  border-color: #c4b5fd;
  color: var(--brand);
}

.hidden-check { position: absolute; opacity: 0; pointer-events: none; width: 0; height: 0; }

.ribbon-text {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  font: inherit;
  font-size: 0.88rem;
  width: 100%;
  min-width: 120px;
}

.ribbon-select {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 6px;
  background: #fff;
  font-size: 0.82rem;
  font-family: inherit;
  color: var(--ink);
}

.ribbon-size {
  width: 56px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font: inherit;
  font-size: 0.85rem;
}

.ribbon-color {
  width: 32px;
  height: 32px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
}

@media (max-width: 720px) {
  .ribbon-group { border-right: none; padding: 0 4px; }
  .editor-ribbon { gap: 6px; }
}

[hidden] { display: none !important; }

/* Modals (editor) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 18, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
}

.modal-backdrop.hidden { display: none !important; }

.modal {
  width: min(560px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.35);
}

.modal h3 { margin: 0 0 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }

/* Deleted page banner */
.page-banner {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(220, 38, 38, 0.94);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 10;
  max-width: 92%;
}

.page-banner button {
  background: #fff;
  color: var(--bad);
  border: none;
  font-weight: 700;
  border-radius: 8px;
  padding: 5px 10px;
  font-size: 0.78rem;
  cursor: pointer;
  flex: none;
}

/* Form hint bar */
.form-hint {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  padding: 10px 14px;
  margin: 0 0 12px;
  font-size: 0.88rem;
  font-weight: 600;
  color: #1e40af;
}

.ribbon-inline {
  height: 32px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 8px;
  font: inherit;
  font-size: 0.82rem;
  background: #fff;
  max-width: 150px;
}

.pdf-text-input {
  position: absolute;
  min-width: 90px;
  min-height: 1.2em;
  background: rgba(109, 40, 217, 0.06);
  border: 1.5px solid var(--brand);
  border-radius: 4px;
  padding: 2px 4px;
  outline: none;
  white-space: pre;
  z-index: 20;
  cursor: text;
  line-height: 1.15;
  caret-color: var(--brand);
}

.pdf-text-input:empty:before {
  content: attr(data-placeholder);
  color: #94a3b8;
}
.tool-tabs { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }
.tool-tab {
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ink);
}
.tool-tab.active { background: var(--brand); color: #fff; border-color: var(--brand); }
.form-fields { display: flex; flex-direction: column; gap: 10px; }

button, .btn {
  display: inline-block;
  background: var(--brand);
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  text-decoration: none;
}

button:hover, .btn:hover { background: var(--brand-dark); }

.btn-secondary { background: #e2e8f0; color: var(--ink); }
.btn-secondary:hover { background: #cbd5e1; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 16px; }

/* Results */
.result {
  margin-top: 22px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-left: 5px solid var(--brand);
  border-radius: 12px;
  padding: 18px 20px;
}

.result h3 { margin: 0 0 12px; font-size: 1rem; }

.result-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 14px;
  padding: 8px 0;
  border-bottom: 1px dashed #cbd5e1;
}

.result-row:last-child { border-bottom: none; }

.result-row .value { font-weight: 700; text-align: right; }

.big-number { font-size: 1.9rem; font-weight: 800; color: var(--brand-dark); }

.error { color: var(--bad); font-weight: 600; }

.cat-normal { color: var(--good); font-weight: 700; }
.cat-warn { color: var(--warn); font-weight: 700; }
.cat-bad { color: var(--bad); font-weight: 700; }

/* Tables */
.table-wrap {
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
}

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }

th, td { padding: 9px 12px; text-align: right; border-bottom: 1px solid var(--line); white-space: nowrap; }

th:first-child, td:first-child { text-align: left; }

th {
  background: #f1f5f9;
  font-weight: 700;
  position: sticky;
  top: 0;
}

/* Content sections */
.content h2, .faq h2 { font-size: 1.35rem; margin: 34px 0 10px; letter-spacing: -0.3px; }

.content p, .content li { color: #334155; }

.content ul { padding-left: 22px; }

.faq details {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 18px;
  margin-bottom: 10px;
}

.faq summary { font-weight: 700; cursor: pointer; }

.faq details[open] summary { margin-bottom: 8px; color: var(--brand-dark); }

.faq p { margin: 0; color: #334155; }

/* Ad slots */
.ad-slot {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  font-size: 0.8rem;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin: 28px 0;
  background: #fff;
}

/* Footer */
.site-footer {
  background: #0f172a;
  color: #cbd5e1;
  margin-top: 56px;
  padding: 36px 0;
  font-size: 0.9rem;
}

.footer-inner { display: flex; flex-direction: column; gap: 14px; }

.footer-links { display: flex; flex-wrap: wrap; gap: 16px; }

.site-footer a { color: #94a3b8; text-decoration: none; }

.site-footer a:hover { color: #fff; }

.footer-note { color: #64748b; font-size: 0.82rem; }

/* Utility */
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }

@media (max-width: 640px) {
  .hero h1 { font-size: 1.75rem; }
  h1 { font-size: 1.55rem; }
  .field-grid { grid-template-columns: 1fr; }
  .header-inner { height: 56px; }
  .nav { gap: 14px; }
  .card { padding: 18px; }
  .big-number { font-size: 1.5rem; }
}

/* Organise PDF */
.pg-toolbar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 16px 0 4px;
}

.pg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.page-card {
  position: relative;
  background: var(--card);
  border: 2px solid var(--line);
  border-radius: 12px;
  padding: 8px;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}

.page-card:hover { border-color: #c4b5fd; }

.page-card.dragging {
  border-color: var(--brand);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.22);
  transform: scale(1.04);
  cursor: grabbing;
  z-index: 5;
}

.page-card.swap-target {
  border-color: var(--brand);
  border-style: dashed;
  background: #f5f3ff;
  transform: scale(1.03);
}

.pg-thumb-wrap {
  height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #f5f3ff;
  border-radius: 8px;
}

.pg-thumb {
  max-width: 100%;
  max-height: 100%;
  transition: transform 0.15s;
  pointer-events: none;
}

.pg-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  margin-top: 6px;
}

.pg-num {
  font-size: 12px;
  font-weight: 800;
  color: var(--brand);
  min-width: 18px;
}

.pg-bar .icon-btn {
  padding: 2px 6px;
  font-size: 13px;
  line-height: 1.2;
}

.meta-section { margin-top: 18px; }

.meta-section summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--brand-dark);
}

.meta-section .field-grid { margin-top: 12px; }


/* Hide empty ad placeholders until real ads are added */
.ad-slot:empty { display: none; }

/* e-kahwin: checklist progress + print */
.ckl-wrap { background: var(--line); border-radius: 999px; height: 10px; overflow: hidden; margin: 10px 0; }
#ckl-bar { background: var(--brand); height: 100%; width: 0; transition: width 0.2s; }
.ckl-item { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; }
.ckl-item input { width: auto; margin-top: 4px; }
.ckl-item label { font-weight: 400; }
@media print {
  .site-header, .site-footer, .ad-slot, .btn-row, .breadcrumb, .ckl-actions { display: none !important; }
  .card { border: none; box-shadow: none; padding: 0; }
}
