/* Single light theme on purpose: a legal form read on paper-white, every color set explicitly. */
:root {
  color-scheme: light;
  --text: #1a1a1a;
  --muted: #5c5c5c;
  --line: #d6d6d6;
  --bg: #f6f6f3;
  --card: #fff;
  --accent: #0b6e4f;
  --error: #b42318;
  --mark: #ffe94d;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 Tahoma, Thonburi, "Noto Sans Thai", sans-serif;
}

main {
  max-width: 760px;
  margin: 0 auto;
  padding-block: 24px 64px;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
}

h1 { font-size: 1.45rem; line-height: 1.35; margin: 0 0 16px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }

section, fieldset.section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px 16px;
  margin: 0 0 16px;
  min-width: 0;
}

.field { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.field > label:not(.choice), legend { display: block; font-weight: bold; margin-bottom: 4px; padding: 0; }
.help, .info, .meta { color: var(--muted); font-size: 0.92rem; margin: 0 0 6px; }
.req { color: var(--error); }

input[type=text], input[type=email], input[type=url], input[type=tel], textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  font: inherit;
  background: #fff;
}

input:focus, textarea:focus, button:focus, summary:focus { outline: 2px solid var(--accent); outline-offset: 2px; }

.choice { display: flex; gap: 10px; align-items: flex-start; padding: 6px 0; cursor: pointer; }
.choice input { margin-top: 6px; flex: none; width: 18px; height: 18px; accent-color: var(--accent); }
.tick .choice { background: #f1f7f4; border-radius: 6px; padding: 10px 12px; }

[aria-invalid=true] { border-color: var(--error) !important; }
.error { color: var(--error); font-size: 0.92rem; margin: 4px 0 0; }
.error-summary, .banner { border-radius: 8px; padding: 12px 16px; margin: 0 0 16px; font-weight: bold; }
.error-summary { background: #fdecea; color: var(--error); }
.banner { background: var(--mark); }

details.doc { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 18px; }
details.doc summary { cursor: pointer; padding: 10px 12px; font-weight: bold; color: var(--accent); }
details.doc[open] summary { border-bottom: 1px solid var(--line); }
details.doc .doc-body, details.doc p { padding: 0 12px; }
details.doc .doc-body { max-height: 60vh; overflow-y: auto; font-size: 0.93rem; }

.doc-body h1 { font-size: 1.15rem; margin: 12px 0; }
.doc-body h2 { font-size: 1rem; margin: 16px 0 6px; }
.doc-body p { margin: 0 0 8px; }
.doc-body .item { padding-left: 1.4em; text-indent: -1.4em; }
article.doc-body { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }
mark { background: var(--mark); }

.table { overflow-x: auto; margin: 4px 0 12px; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; }
td { border: 1px solid var(--line); padding: 6px 8px; vertical-align: top; }
tr:first-child td { background: #eee; font-weight: bold; }

button[type=submit], .steps-nav button {
  width: 100%;
  padding: 14px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-weight: bold;
  cursor: pointer;
}

.receipt { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 16px; }

@media print {
  body { background: #fff; }
  button { display: none; }
}

.trap { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
input[type=file] { display: block; width: 100%; padding: 10px; border: 1px dashed var(--line); border-radius: 6px; background: #fff; font: inherit; }
progress { display: block; width: 100%; height: 10px; margin-top: 8px; accent-color: var(--accent); }
.upload-status { font-size: 0.92rem; margin: 6px 0 0; }
.upload-status.done { color: var(--accent); font-weight: bold; }
.upload-status.failed { color: var(--error); }
button[type=submit]:disabled { opacity: 0.55; cursor: not-allowed; }
.preview-note { background: #e8f1ff; border-radius: 8px; padding: 12px 16px; margin: 0 0 16px; font-size: 0.92rem; }

/* Steps (static/app.js); without JavaScript every step is shown. */
.step.off { display: none; }
.progress { font-weight: bold; color: var(--accent); margin: 0 0 12px; }
.steps-nav { display: flex; gap: 12px; justify-content: space-between; flex-wrap: wrap; }
.steps-nav button { flex: 1 1 0; width: auto; }
.steps-nav [hidden] { display: none; }
button.secondary { background: #fff; color: var(--accent); border: 1px solid var(--accent); }
ul.summary { margin: 0 0 14px; padding-left: 1.2em; font-size: 0.95rem; }
ul.summary li { margin: 0 0 4px; }
fieldset.inline .choice { display: inline-flex; margin-right: 18px; }
.decline-all { margin: 0 0 14px; }

/* Full document modal (static/app.js): scroll to the end, tick, accept. Full screen on phones. */
.doc-opener { margin: 0 0 18px; }
.doc-opener button { width: 100%; padding: 12px; border-radius: 8px; font: inherit; font-weight: bold; cursor: pointer; }
.doc-status { font-size: 0.92rem; color: var(--muted); margin: 6px 0 0; }
.doc-status.done { color: var(--accent); font-weight: bold; }
.gated.locked { opacity: 0.45; }
dialog.doc-modal { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 10px; color: var(--text); background: var(--card); }
dialog.doc-modal[open] { display: flex; flex-direction: column; }
dialog.doc-modal::backdrop { background: rgba(0, 0, 0, 0.5); }
.doc-modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.doc-modal-head h2 { margin: 0; font-size: 1.05rem; }
.doc-close { background: none; border: 0; color: var(--accent); font: inherit; font-weight: bold; cursor: pointer; padding: 6px; }
.doc-modal-body { flex: 1; overflow-y: auto; padding: 12px 16px; font-size: 0.93rem; overscroll-behavior: contain; }
.doc-modal-foot { border-top: 1px solid var(--line); padding: 10px 16px 14px; }
.doc-modal-foot [hidden] { display: none; }
.doc-hint { color: var(--muted); font-size: 0.9rem; margin: 0 0 4px; }
.doc-accept { width: 100%; margin-top: 8px; padding: 12px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font: inherit; font-weight: bold; cursor: pointer; }
.doc-accept:disabled, .doc-modal-foot .choice:has(input:disabled) { opacity: 0.5; cursor: not-allowed; }
@media (max-width: 600px) {
  dialog.doc-modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; margin: 0; border-radius: 0; }
}
.doc-answers { margin: 20px -16px 0; padding: 16px 16px 4px; border-top: 2px solid var(--accent); background: #f7faf8; }
.doc-answers h3 { margin: 0 0 12px; font-size: 1rem; }
.doc-answers .gated[inert] { opacity: 0.45; }
.doc-link { margin: 0 0 14px; }
.doc-link a { font-weight: bold; color: var(--accent); }
.login { margin: 0 0 18px; }
.login a.button { display: block; text-align: center; padding: 12px; border-radius: 8px; font-weight: bold; text-decoration: none; background: #fff; color: var(--accent); border: 1px solid var(--accent); }
.login .help { margin: 6px 0 0; }
