:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1c2430;
  --muted: #5b6676;
  --line: #dde2e9;
  --accent: #1f4e79;
  --accent-text: #ffffff;
  --accent-soft: #e6eef6;
  --danger: #a4262c;
  --box: rgba(31, 78, 121, 0.35);
  --box-on: rgba(230, 126, 34, 0.45);
  font-family: "Kantumruy Pro", "Khmer OS Battambang", "Noto Sans Khmer", system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161c; --surface: #1b2129; --text: #e8edf3; --muted: #9aa6b5; --line: #2c3540;
    --accent: #6fa8dc; --accent-text: #0d1117; --accent-soft: #1f2d3b; --danger: #ff8a80;
    --box: rgba(111, 168, 220, 0.35); --box-on: rgba(255, 167, 38, 0.5);
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); line-height: 1.7; }
a { color: var(--accent); }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px;
       max-width: 1200px; margin: 0 auto; }
.brand { display: flex; gap: 10px; align-items: center; font-weight: 600; font-size: 1.1rem;
         color: var(--text); text-decoration: none; }
.badge { font-size: 0.7rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
         color: var(--accent); background: var(--accent-soft); border-radius: 999px; padding: 2px 8px; }
.top nav { display: flex; gap: 14px; align-items: center; }
.lang { border: 1px solid var(--line); background: var(--surface); color: var(--text);
        border-radius: 999px; padding: 4px 12px; font: inherit; cursor: pointer; }

main { max-width: 1200px; margin: 0 auto; padding: 0 16px 40px; }
.hero { text-align: center; padding: 28px 0 8px; }
.hero h1 { font-size: clamp(1.5rem, 4vw, 2.2rem); margin: 0 0 6px; font-weight: 600; }
.lead { color: var(--muted); margin: 0 auto; max-width: 640px; }

.upload { max-width: 720px; margin: 24px auto 0; }
.drop { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center;
        padding: 40px 16px; border: 2px dashed var(--line); border-radius: 14px; background: var(--surface);
        color: var(--accent); cursor: pointer; transition: border-color .15s, background .15s; }
.drop strong { color: var(--text); font-weight: 500; }
.drop.over, .drop:hover { border-color: var(--accent); background: var(--accent-soft); }
.hint { color: var(--muted); font-size: .9rem; }
.actions { display: flex; gap: 12px; align-items: center; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.turnstile { display: flex; justify-content: center; margin-top: 12px; }
@media (hover: none) { .paste { display: none; } }

.button { display: inline-block; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-text);
          border-radius: 8px; padding: 8px 16px; font: inherit; cursor: pointer; text-decoration: none; }
.button.secondary { background: var(--surface); color: var(--accent); }
.button:focus-visible, .lang:focus-visible, .drop:focus-visible { outline: 3px solid var(--box-on); outline-offset: 2px; }

.progress { max-width: 720px; margin: 28px auto 0; text-align: center; }
.bar { height: 8px; background: var(--line); border-radius: 999px; overflow: hidden; }
.bar div { height: 100%; width: 0; background: var(--accent); transition: width .3s; }
.error { max-width: 720px; margin: 20px auto 0; color: var(--danger); text-align: center; }

.result { margin-top: 24px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 12px; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.pages { display: flex; gap: 6px; flex-wrap: wrap; }
.pages button { border: 1px solid var(--line); background: var(--surface); color: var(--text); border-radius: 6px;
                padding: 2px 10px; font: inherit; cursor: pointer; }
.pages button[aria-selected="true"] { border-color: var(--accent); background: var(--accent-soft); }
.buttons { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.views { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.views button { border: 0; background: var(--surface); color: var(--text); padding: 6px 14px; font: inherit; cursor: pointer; }
.views button[aria-selected="true"] { background: var(--accent); color: var(--accent-text); }
.panes { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.panes.text-only { grid-template-columns: 1fr; }
@media (max-width: 800px) { .panes { grid-template-columns: 1fr; } }
.image { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 8px;
         max-height: 75vh; overflow: auto; }
.stage { position: relative; }
.stage img { display: block; width: 100%; height: auto; }
.stage svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage polygon { fill: transparent; stroke: var(--box); stroke-width: 2; vector-effect: non-scaling-stroke; cursor: pointer; }
.stage polygon.on { fill: var(--box-on); stroke: var(--box-on); }
.stage rect { fill: transparent; stroke: var(--box); stroke-width: 2; vector-effect: non-scaling-stroke; cursor: pointer; }
.stage rect[data-type="table"] { stroke: #c0392b; }
.stage rect[data-type="figure"], .stage rect[data-type="stamp"] { stroke: #27ae60; }
.stage rect[data-type="title"], .stage rect[data-type="heading"] { stroke: #d68910; }
.stage rect.on { fill: var(--box-on); stroke: var(--box-on); }

.doc-pane { min-width: 0; }
.doc { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 28px 32px;
       max-height: 75vh; overflow: auto; line-height: 1.9; }
@media (max-width: 600px) { .doc { padding: 16px; } }
.doc .blk { margin: 0 0 .55em; padding: 2px 4px; border-radius: 4px; transition: background .15s; }
.doc .blk.on { background: var(--box-on); }
.doc .blk p { margin: 0; }
.doc .title { font-size: 1.35em; font-weight: 600; }
.doc .heading { font-size: 1.12em; font-weight: 600; }
.doc .caption { font-style: italic; font-size: .92em; color: var(--muted); }
.doc .furn { font-size: .82em; color: var(--muted); }
.doc.no-furniture .furn { display: none; }
.doc table { border-collapse: collapse; width: 100%; font-size: .95em; }
.doc td { border: 1px solid var(--line); padding: 4px 6px; vertical-align: top; }
.doc figure { margin: 0; text-align: center; }
.doc figure img { max-width: 100%; height: auto; border-radius: 4px; }
.doc .scroll { overflow-x: auto; }
.furniture { display: block; margin-top: 6px; }
.text textarea { width: 100%; min-height: 60vh; resize: vertical; padding: 12px; border-radius: 10px;
                 border: 1px solid var(--line); background: var(--surface); color: var(--text);
                 font: 1.05rem/1.9 "Kantumruy Pro", "Khmer OS Battambang", "Noto Sans Khmer", sans-serif; }

footer { display: flex; gap: 18px; justify-content: center; flex-wrap: wrap; padding: 24px 16px; color: var(--muted);
         font-size: .9rem; border-top: 1px solid var(--line); }

.about { max-width: 720px; margin: 0 auto; }
.about h1 { font-weight: 600; }
.about h2 { font-weight: 600; font-size: 1.2rem; margin-top: 28px; }

.personal { text-align: center; color: var(--muted); font-size: .85rem; margin: 6px auto 0; max-width: 640px; }

.contact form { display: grid; gap: 14px; margin-top: 18px; }
.contact label { display: block; font-weight: 500; }
.contact label small { display: block; font-weight: 400; color: var(--muted); }
.contact input, .contact select, .contact textarea {
  display: block; margin-top: 4px; width: 100%; padding: 8px 10px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); font: inherit; }
.contact textarea { min-height: 160px; resize: vertical; }
.contact input:focus-visible, .contact select:focus-visible, .contact textarea:focus-visible {
  outline: 3px solid var(--box-on); outline-offset: 1px; }
.contact .trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.contact .turnstile { justify-content: flex-start; margin-top: 0; }
.contact .sent { padding: 16px; border-radius: 10px; background: var(--accent-soft); }

/* "try a sample" under the upload box */
.samples { margin-top: 22px; text-align: center; }
.sample-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin: 8px 0; }
@media (max-width: 600px) { .sample-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.sample { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 8px; border: 1px solid var(--line);
          border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: .85rem;
          line-height: 1.4; cursor: pointer; }
.sample:hover { border-color: var(--accent); background: var(--accent-soft); }
.sample:focus-visible { outline: 3px solid var(--box-on); outline-offset: 2px; }
.sample img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; object-position: top; border-radius: 6px;
              border: 1px solid var(--line); background: #fff; }
.sample-note { margin: 0 0 12px; padding: 10px 14px; border-radius: 10px; background: var(--accent-soft); font-size: .92rem; }

/* the business page */
.uses { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 18px 0; }
@media (max-width: 760px) { .uses { grid-template-columns: minmax(0, 1fr); } }
.use { display: flex; flex-direction: column; gap: 8px; padding: 14px; border: 1px solid var(--line); border-radius: 12px;
       background: var(--surface); }
.use img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--line); }
.use h3 { margin: 0; font-size: 1.05rem; font-weight: 600; }
.use p { margin: 0; font-size: .92rem; }
.use a.more { margin-top: auto; font-size: .9rem; }
.offer { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin: 14px 0; }
@media (max-width: 760px) { .offer { grid-template-columns: minmax(0, 1fr); } }
.offer div { padding: 14px; border-radius: 12px; background: var(--accent-soft); }
.offer h3 { margin: 0 0 4px; font-size: 1rem; font-weight: 600; }
.offer p { margin: 0; font-size: .92rem; }
.cta { text-align: center; margin: 26px 0; }
.business { max-width: 960px; margin: 0 auto; }
.business h1 { font-weight: 600; }
.business h2 { font-weight: 600; font-size: 1.2rem; margin-top: 30px; }
.business .note { color: var(--muted); font-size: .9rem; }
.top nav a { white-space: nowrap; }
@media (max-width: 480px) { .top nav .nav-biz { display: none; } }   /* in the footer too */
.sample[data-sample="idcard"] img { object-fit: contain; background: #7a624c; }
