:root {
  color-scheme: light;
  --ink: #263d35;
  --ink-soft: #53645d;
  --muted: #78827b;
  --paper: #f5f2eb;
  --card: #fffefa;
  --line: #e6e1d6;
  --accent: #b28a43;
  --accent-pale: #f3ead5;
  --shadow: 0 16px 42px rgba(37, 48, 41, .07);
  font-family: "DM Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background:
    radial-gradient(ellipse at 50% 0, rgba(232, 224, 204, .34), transparent 38rem),
    var(--paper);
  color: #242d28;
  min-width: 320px;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }

.site-header {
  height: 76px;
  padding: 0 max(5vw, calc((100vw - 1260px) / 2));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(38, 61, 53, .09);
  background: rgba(255, 254, 250, .75);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  font-family: "Playfair Display", Georgia, serif;
  font-weight: 700;
  font-size: 1.24rem;
  text-decoration: none;
}

.brand img { display: block; }
.language-picker { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: .82rem; font-weight: 600; }

select, input, textarea {
  border: 1px solid #dedbd1;
  border-radius: 7px;
  background: #fff;
  color: #27332d;
  outline: none;
}

select:focus, input:focus, textarea:focus {
  border-color: #9d8250;
  box-shadow: 0 0 0 3px rgba(178, 138, 67, .13);
}

.language-picker select { padding: 9px 31px 9px 11px; }

main { width: min(1260px, calc(100% - 48px)); margin: 0 auto; }

.intro { padding: 51px 0 29px; text-align: center; }
.eyebrow { margin: 0 0 9px; color: #8c7448; font-size: .68rem; font-weight: 700; letter-spacing: .16em; }
h1, h2, h3, p { margin-top: 0; }
.intro h1 { margin-bottom: 13px; color: var(--ink); font: 700 clamp(1.9rem, 3.5vw, 2.75rem)/1.15 "Playfair Display", Georgia, serif; }
.intro > p:last-child { max-width: 680px; margin: 0 auto; color: var(--ink-soft); font-size: .97rem; line-height: 1.65; }

.instructions, .editor-panel, .preview-panel {
  border: 1px solid rgba(38, 61, 53, .09);
  border-radius: 12px;
  background: var(--card);
  box-shadow: var(--shadow);
}

.instructions { padding: 23px 27px 22px; margin-bottom: 24px; }
.section-heading, .panel-heading, .custom-heading { display: flex; justify-content: space-between; align-items: center; gap: 14px; }
.section-heading { align-items: flex-start; }
.section-heading h2, .panel-heading h2 { margin: 0; color: var(--ink); font: 700 1.2rem/1.3 "Playfair Display", Georgia, serif; }
.guide-icon { display: grid; width: 35px; height: 35px; place-items: center; border-radius: 10px; background: var(--accent-pale); color: #96743a; font-size: 1.2rem; }
.guide-list { margin: 17px 0 0; padding: 0; list-style: none; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 25px; counter-reset: guide; }
.guide-list li { position: relative; min-height: 27px; padding-left: 35px; color: #59645e; font-size: .84rem; line-height: 1.55; counter-increment: guide; }
.guide-list li::before { content: counter(guide, decimal-leading-zero); position: absolute; left: 0; top: 0; color: #a77f37; font-weight: 700; font-size: .72rem; }
.guide-list strong { color: #34443c; }
.guide-list code { padding: 1px 4px; border-radius: 3px; background: #f1efe9; color: #49534d; font-size: .79rem; }

.workspace { display: grid; grid-template-columns: minmax(0, 1.03fr) minmax(0, .97fr); gap: 24px; align-items: start; }
.editor-panel, .preview-panel { padding: 23px; }
.panel-heading { margin-bottom: 21px; }
.panel-heading .eyebrow { margin-bottom: 6px; }
.button { border: 1px solid transparent; border-radius: 7px; padding: 9px 13px; font-size: .78rem; font-weight: 600; transition: background .16s ease, transform .16s ease, border-color .16s ease; }
.button:hover { transform: translateY(-1px); }
.button-subtle { border-color: var(--line); background: transparent; color: #66716a; }
.button-subtle:hover, .button-secondary:hover { border-color: #c6b994; background: #faf8f2; }
.button-small { padding: 7px 10px; white-space: nowrap; }
.button-primary { background: var(--ink); color: white; }
.button-primary:hover { background: #354f44; }
.button-secondary { border-color: var(--line); background: white; color: var(--ink); }

.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 13px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label, .field-label { color: #46564d; font-size: .75rem; font-weight: 600; }
.field input, .field textarea { width: 100%; padding: 9px 10px; font-size: .81rem; }
.field textarea { min-height: 68px; resize: vertical; line-height: 1.45; }
.field input[type="file"] { padding: 7px; font-size: .76rem; }
.field input[type="file"]::file-selector-button { margin-right: 9px; padding: 5px 8px; border: 0; border-radius: 4px; background: #efede6; color: #48564e; font-size: .74rem; }
.field-hint { color: var(--muted); font-size: .68rem; line-height: 1.4; }
.field-section { grid-column: 1 / -1; margin: 8px 0 -3px; padding-top: 14px; border-top: 1px solid #eeece5; color: var(--ink); font-size: .78rem; font-weight: 700; }
.field-section:first-child { margin-top: 0; padding-top: 0; border-top: 0; }

.custom-editor { margin-top: 20px; padding-top: 17px; border-top: 1px solid #eeece5; }
.custom-heading { align-items: flex-start; margin-bottom: 12px; }
.custom-heading h3 { margin: 0 0 4px; color: var(--ink); font-size: .84rem; }
.custom-heading p { max-width: 280px; margin: 0; color: var(--muted); font-size: .7rem; line-height: 1.45; }
.custom-row { display: grid; grid-template-columns: minmax(95px, .7fr) 1fr 1fr auto auto auto auto; gap: 7px; margin-bottom: 8px; }
.custom-row input, .custom-row select { min-width: 0; width: 100%; padding: 7px 8px; font-size: .72rem; }
.custom-row .custom-position { grid-column: 1 / 4; }
.move-row { border: 1px solid var(--line); border-radius: 6px; background: white; color: var(--ink); font-size: .82rem; }
.remove-row { border: 1px solid var(--line); border-radius: 6px; background: white; color: #8b5a4b; font-size: 1rem; }
.move-row:disabled { cursor: not-allowed; opacity: .4; }
.form-actions { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 19px; }
.copy-status { min-height: 1em; margin: 9px 0 0; color: #476b53; font-size: .75rem; }
.copy-status[data-state="error"] { color: #a34a3b; }
.button:disabled { cursor: wait; opacity: .65; transform: none; }

.live-badge { display: inline-flex; align-items: center; gap: 7px; padding: 6px 9px; border-radius: 99px; background: #edf4ed; color: #527054; font-size: .68rem; font-weight: 600; white-space: nowrap; }
.live-badge > span:first-child { width: 6px; height: 6px; border-radius: 50%; background: #6fa477; }
.preview-stage { min-height: 600px; display: flex; align-items: flex-start; justify-content: center; padding: 27px 13px; border: 1px solid #ebe8df; border-radius: 8px; background-color: #f5f4ef; background-image: radial-gradient(#dedbd2 .75px, transparent .75px); background-size: 13px 13px; overflow: auto; }
.preview-content { display: flex; width: 100%; align-items: center; flex-direction: column; gap: 18px; }
.wiki-box { width: min(100%, 312px); align-self: center; border: 1px solid #b4bbc8; padding: 3px; background: #f8f9fa; color: #202122; font-family: sans-serif; font-size: 14.4px; line-height: 1.4; overflow-wrap: anywhere; }
.wiki-title { padding: 5px; background: #c3d6ef; color: #202122; text-align: center; font-size: 1.4em; font-weight: 700; line-height: 1.2; }
.wiki-subtitle { padding: 1px; background: #dcdcdc; color: #202122; text-align: center; font-size: 1em; }
.wiki-image-cell { padding: 1px; text-align: center; }
.wiki-image { display: block; max-width: 100%; max-height: 520px; height: auto; margin: 0 auto; object-fit: contain; }
.wiki-image-caption { padding: 1px; text-align: center; font-size: .95em; line-height: 1.4; }
.wiki-meta { width: 100%; border-collapse: separate; border-spacing: 2px; }
.wiki-meta th, .wiki-meta td { padding: 1px; border: 0; text-align: left; vertical-align: top; }
.wiki-meta th { width: 38%; font-size: .95em; font-weight: 700; }
.wiki-section { padding: 1px; background: #c3d6ef; color: #202122; text-align: center; font-size: 1em; font-weight: 700; line-height: 1.4; }
.wiki-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 2px; }
.wiki-side { min-width: 0; padding: 1px; text-align: left; }
.wiki-side + .wiki-side { border: 0; }
.wiki-side-label { margin-bottom: 1px; color: #202122; font-size: .95em; font-weight: 700; text-align: left; }
.wiki-list { margin: 0; padding: 0 3px 0 1.5em; text-align: left; }
.wiki-list li { padding-left: 1px; }
.wiki-link { color: #0645ad; text-decoration: none; }
.wiki-empty { color: #72777d; }
.preview-note { margin: 12px 0 0; color: var(--muted); font-size: .71rem; line-height: 1.5; text-align: center; }
footer { width: min(1260px, calc(100% - 48px)); margin: 25px auto 0; padding: 18px 0 22px; border-top: 1px solid rgba(38, 61, 53, .1); display: flex; justify-content: space-between; gap: 20px; color: #78827b; font-size: .72rem; }

@media (max-width: 900px) {
  .workspace { grid-template-columns: 1fr; }
  .preview-stage { min-height: 460px; }
}

@media (max-width: 600px) {
  .site-header { height: 66px; padding: 0 18px; }
  .brand { gap: 8px; font-size: 1.08rem; }
  .brand img { width: 36px; height: 36px; }
  .language-picker { gap: 6px; font-size: .72rem; }
  .language-picker select { max-width: 138px; padding: 8px 25px 8px 8px; }
  main, footer { width: calc(100% - 30px); }
  .intro { padding: 39px 0 23px; }
  .intro h1 { font-size: 1.85rem; }
  .intro > p:last-child { font-size: .88rem; }
  .instructions, .editor-panel, .preview-panel { padding: 18px; }
  .guide-list { grid-template-columns: 1fr; gap: 10px; }
  .field-grid { grid-template-columns: 1fr; }
  .field.full, .field-section { grid-column: 1; }
  .custom-row { grid-template-columns: 1fr 1fr 32px 32px; }
  .custom-row input:first-child { grid-column: 1 / -1; }
  .custom-row input:nth-child(2) { grid-column: 1 / 3; }
  .custom-row input:nth-child(3) { grid-column: 3 / 5; }
  .custom-row .custom-position { grid-column: 1 / -1; }
  .custom-row .move-row, .custom-row .remove-row { grid-row: 4; }
  .custom-row .move-row:first-of-type { grid-column: 2; }
  .custom-row .move-row:nth-last-child(2) { grid-column: 3; }
  .custom-row .remove-row { grid-column: 4; }
  .preview-stage { min-height: 400px; padding: 16px 8px; }
  footer { flex-direction: column; gap: 5px; }
}
