:root {
  color-scheme: light;
  --ink: #142823;
  --muted: #566961;
  --line: #dfe7e0;
  --base: #f5f7f5;
  --wash: #edf2ee;
  --accent: #ddf4ab;
  --accent-hover: #cbe994;
  --green: #315747;
  font: 100%/1.5 "Inter", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--base);
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; }
button, select, input, textarea { font: inherit; }
button, summary { cursor: pointer; }
button:disabled { cursor: default; opacity: .48; }
:focus-visible { outline: 3px solid #487f68; outline-offset: 2px; }

.site-header { background: #fff; border-bottom: 1px solid var(--line); }
.header-inner, .workspace { width: min(1600px, calc(100% - 40px)); margin-inline: auto; }
.header-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 66px; }
.brand { display: flex; align-items: center; margin: 0; font-size: 1.4rem; font-weight: 800; letter-spacing: -.06em; }
.brand-mark { width: 30px; height: 30px; margin-right: 8px; background: #1d3a30; border-radius: 9px; position: relative; }
.brand-mark::before { content: ""; position: absolute; inset: 7px 9px; border: 1.5px solid var(--accent); border-radius: 2px; }
.brand-mark::after { content: ""; position: absolute; top: 12px; left: 12px; width: 6px; height: 1px; background: var(--accent); box-shadow: 0 4px var(--accent); }
.brand-dot { color: #5b8259; }
.toolbar { display: flex; align-items: center; gap: 8px; }
.button { display: inline-flex; align-items: center; justify-content: center; min-height: 40px; padding: 6px 13px; border-radius: 8px; border: 1px solid var(--line); font-size: .875rem; font-weight: 700; white-space: nowrap; color: var(--ink); }
.button-secondary { background: #fff; }
.button-secondary:hover:where(:not(:disabled)) { background: var(--wash); }
.button-primary { background: var(--accent); border-color: #c0d88e; }
.button-primary:hover:where(:not(:disabled)) { background: var(--accent-hover); }
.more { position: relative; }
.more > summary { display: flex; gap: 7px; list-style: none; }
.more > summary::-webkit-details-marker { display: none; }
.more > summary::after { content: ""; width: 6px; height: 6px; border: solid currentColor; border-width: 0 1.5px 1.5px 0; transform: translateY(-2px) rotate(45deg); }
.more-actions { position: absolute; z-index: 2; top: calc(100% + 6px); right: 0; min-width: 193px; padding: 4px; border: 1px solid var(--line); border-radius: 9px; background: white; box-shadow: 0 6px 26px #25412e21; }
.more-actions > * { display: block; width: 100%; border: 0; border-radius: 5px; padding: 8px 10px; background: transparent; color: var(--ink); text-align: left; text-decoration: none; font-size: .875rem; white-space: nowrap; }
.more-actions > :hover { background: var(--wash); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; margin-block: 16px; }
.panel { display: flex; flex-direction: column; height: max(400px, calc(100dvh - 99px)); min-width: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; }
.panel-header { display: flex; min-height: 46px; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 13px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: .92rem; font-weight: 740; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-format, #preview-status { flex-shrink: 0; color: var(--muted); font-size: .78rem; text-align: end; }
#preview-status.stale { color: #81551d; }
#editor { flex: 1; min-height: 0; width: 100%; resize: none; border: 0; padding: 16px; background: #fdfefd; color: var(--ink); font: .93rem/1.65 ui-monospace, "DejaVu Sans Mono", monospace; tab-size: 4; white-space: pre-wrap; overflow-wrap: break-word; }
#editor:focus, .docx-stage:focus { outline-offset: -3px; }
#editor.dragging { background: #ecf7e4; }
.docx-stage { flex: 1; min-height: 0; overflow: auto; overflow-anchor: none; background: var(--wash); padding: clamp(10px, 2vw, 22px); }
.docx-pages { display: grid; justify-items: center; gap: 16px; }
.docx-page { display: block; width: min(100%, 720px); height: auto; background: white; box-shadow: 0 1px 7px #25412e24; }
.placeholder { display: grid; min-height: 100%; place-items: center; text-align: center; padding: 15px; color: var(--muted); font-size: .9rem; }
.panel-error { margin: 0; padding: 8px 13px; background: #fff3f3; border-bottom: 1px solid #f1dddd; }
.panel-error, .file-error { color: #8b252a; font-size: .875rem; overflow-wrap: anywhere; }
.warnings { max-height: 30%; overflow: auto; padding: 6px 13px; color: #79532b; background: #fffaee; border-top: 1px solid #f0e5cc; font-size: .875rem; }
.warnings ul { margin: 6px 0; padding-left: 20px; }

dialog { width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 24px); color: var(--ink); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 18px; box-shadow: 0 12px 50px #14282335; }
dialog::backdrop { background: #14282359; }
dialog p { margin: 8px 0; font-size: .875rem; }
.dialog-heading, .dialog-footer { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dialog-heading { margin-bottom: 14px; }
.dialog-heading h2 { margin: 0; font-size: 1.125rem; }
.dialog-footer { justify-content: end; margin-top: 15px; }
.text-button { padding: 0; border: 0; background: none; color: var(--green); font-size: .875rem; font-weight: 700; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; color: var(--muted); font-size: .875rem; font-weight: 600; }
.field select, .field input:not([type="checkbox"]) { width: 100%; min-width: 0; min-height: 37px; border: 1px solid var(--line); border-radius: 7px; background: #fff; color: var(--ink); padding: 5px 9px; }
.field input[type="color"] { padding: 4px 7px; }
.field input[type="checkbox"] { margin: 0; width: 16px; height: 16px; accent-color: var(--green); }
.check-field { flex-direction: row; align-items: center; gap: 7px; min-height: 30px; }
.scope-control { display: flex; gap: 3px; margin: 14px 0 10px; padding: 3px; background: var(--wash); border-radius: 8px; }
.scope-control button { flex: 1; padding: 5px 4px; color: var(--muted); border: 1px solid transparent; border-radius: 6px; background: none; font-size: .84rem; font-weight: 700; }
.scope-control button[aria-pressed="true"] { background: white; border-color: var(--line); color: var(--ink); }
.style-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px 9px; margin-top: 9px; }
.field-wide { grid-column: 1 / -1; }
.advanced { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.advanced summary { font-size: .875rem; font-weight: 690; }
.asset-list { display: grid; gap: 3px; list-style: none; margin: 10px 0 0; padding: 0; }
.asset-list li { display: flex; align-items: center; justify-content: space-between; gap: 4px; font-size: .85rem; }
.asset-list span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.asset-list button { border: 0; background: var(--wash); color: var(--ink); border-radius: 4px; font-size: 1rem; padding: 1px 8px; }

@media (max-width: 740px) {
  .header-inner, .workspace { width: calc(100% - 24px); }
  .workspace { grid-template-columns: minmax(0, 1fr); gap: 12px; margin-block: 12px; }
  .editor-panel { height: max(340px, 52svh); }
  .preview-panel { height: max(400px, 70svh); }
}
@media (max-width: 560px) {
  .header-inner { flex-wrap: wrap; gap: 8px; padding: 9px 0; }
  .toolbar { width: 100%; justify-content: space-between; gap: 4px; }
  .toolbar .button { min-height: 39px; padding-inline: clamp(5px, 1.5vw, 10px); font-size: .78rem; }
  #editor { font-size: 1rem; }
}
