:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --surface-2: #efe7d6;
  --text: #1f1d1a;
  --muted: #6b645a;
  --border: #ddd2bd;
  --ink: #1b2a6b;
  --ink-text: #ffffff;
  --ok: #1e7a46;
  --ok-bg: #e3f3e8;
  --warn: #8a5a00;
  --warn-bg: #fdf0d2;
  --bad: #a3231b;
  --bad-bg: #fbe3e0;
  --info: #24548f;
  --info-bg: #e2ecf8;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.05), 0 4px 16px rgb(0 0 0 / 0.04);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15161b;
    --surface: #1e2027;
    --surface-2: #272a33;
    --text: #ece8df;
    --muted: #a39d92;
    --border: #353844;
    --ink: #8da2ff;
    --ink-text: #10132a;
    --ok: #6fd39a;
    --ok-bg: #173325;
    --warn: #f0c060;
    --warn-bg: #3a2e14;
    --bad: #ff8f84;
    --bad-bg: #3d1c1a;
    --info: #8db9f0;
    --info-bg: #182a40;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0 auto;
  max-width: 1080px;
  padding: 0 16px 48px;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Leelawadee UI", "Noto Sans Thai", "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif;
}

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.6rem; letter-spacing: 0.01em; }
h2 { font-size: 1.35rem; margin-top: 0.5em; }
h3 { font-size: 1.02rem; margin-top: 1.2em; }
.card > h3:first-child, .options > h3:first-of-type { margin-top: 0; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.95em; background: var(--surface-2); padding: 0.1em 0.4em; border-radius: 6px; }
a { color: var(--ink); }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 20px 0 8px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand h1 { margin: 0; }
.tagline { margin: 0; color: var(--muted); font-size: 0.92rem; }
.lang { display: flex; border: 1px solid var(--border); border-radius: 999px; overflow: hidden; flex-shrink: 0; }
.lang button { border: 0; border-radius: 0; background: transparent; color: var(--text); padding: 6px 12px; }
.lang button[aria-pressed="true"] { background: var(--ink); color: var(--ink-text); }
.privacy { margin: 0 0 16px; color: var(--muted); font-size: 0.9rem; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tabs button {
  display: flex; align-items: center; gap: 8px;
  background: none; border: 0; border-bottom: 3px solid transparent; border-radius: 0;
  color: var(--muted); padding: 10px 14px; font-weight: 600; white-space: nowrap;
}
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tabs .num {
  display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 50%;
  background: var(--surface-2); font-size: 0.8rem;
}
.tabs button[aria-selected="true"] .num { background: var(--ink); color: var(--ink-text); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.grid2 .card { margin-bottom: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.big { font-size: 1.3rem; font-weight: 700; }
.label { color: var(--muted); font-size: 0.88rem; }

label { display: block; margin-bottom: 12px; font-size: 0.92rem; }
label > span:first-child { display: block; margin-bottom: 4px; color: var(--muted); }
label.check, label.inline { display: flex; align-items: center; gap: 8px; }
label.check > span, label.inline > span:first-child { display: inline; margin: 0; color: var(--text); }
input, select, textarea, button { font: inherit; }
input:not([type]), input[type="password"], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text);
}
input[type="file"] { max-width: 100%; }
input[type="range"] { width: 100%; accent-color: var(--ink); }
input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--ink); flex-shrink: 0; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; border-radius: 8px; border: 1px solid var(--ink);
  background: var(--ink); color: var(--ink-text); font-weight: 600; cursor: pointer; text-decoration: none;
}
button.secondary, .button.secondary { background: transparent; color: var(--ink); }
button.link { background: none; border: 0; color: var(--muted); text-decoration: underline; padding: 9px 4px; }
button.primary { width: 100%; padding: 13px; font-size: 1.05rem; margin-top: 8px; }
button:disabled { opacity: 0.55; cursor: progress; }

.row { display: flex; gap: 8px; align-items: center; }
.row.wrap { flex-wrap: wrap; margin-top: 12px; }
.row input { flex: 1; min-width: 0; }
.row label { margin: 0; }
.spacer { flex: 1; }

.msg { min-height: 1.4em; margin: 8px 0 0; font-size: 0.92rem; }
.msg.error { color: var(--bad); }
.msg.ok { color: var(--ok); }

.banner { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-size: 0.95rem; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.error { background: var(--bad-bg); color: var(--bad); }
.note { background: var(--surface-2); border-radius: var(--radius); padding: 14px 18px; margin-top: 16px; font-size: 0.92rem; }
.note ul { margin: 6px 0 0; padding-left: 20px; }

.active-id { display: flex; justify-content: space-between; align-items: center; gap: 12px; border-color: var(--ok); }

/* The pad is always paper-coloured so dark ink stays visible in dark mode too. */
.pad { display: block; width: 100%; height: 240px; touch-action: none; cursor: crosshair; border-radius: 8px;
  border: 1px solid var(--border);
  background: linear-gradient(transparent 179px, #ddd2bd 179px 180px, transparent 180px), #fbf7ee; }
.swatches { display: inline-flex; gap: 6px; align-items: center; }
.swatches button { width: 26px; height: 26px; padding: 0; border-radius: 50%; background: var(--c); border: 2px solid var(--border); }
.swatches button[aria-pressed="true"] { outline: 2px solid var(--ink); outline-offset: 2px; }
.swatches input[type="color"] { width: 30px; height: 30px; padding: 0; border: 0; background: none; }
.upload { margin-top: 14px; }

.checker {
  background-color: #fff;
  background-image: linear-gradient(45deg, #e8e8e8 25%, transparent 25%, transparent 75%, #e8e8e8 75%),
    linear-gradient(45deg, #e8e8e8 25%, transparent 25%, transparent 75%, #e8e8e8 75%);
  background-size: 16px 16px; background-position: 0 0, 8px 8px;
}
.sig-preview { min-height: 100px; display: grid; place-items: center; border-radius: 8px; padding: 12px; color: #6b645a; }
.sig-preview img { max-width: 100%; max-height: 160px; }

.drop {
  display: grid; place-items: center; min-height: 140px; padding: 24px; margin-bottom: 16px;
  border: 2px dashed var(--border); border-radius: var(--radius); background: var(--surface);
  color: var(--muted); text-align: center; cursor: pointer;
}
.drop.over, .drop:hover { border-color: var(--ink); color: var(--ink); }
.drop input { position: absolute; width: 1px; height: 1px; opacity: 0; }

.seal-layout { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(280px, 1fr); gap: 16px; align-items: start; }
@media (max-width: 760px) {
  .seal-layout { grid-template-columns: 1fr; }
  .preview-wrap { position: static; }
}
@media (max-width: 520px) {
  .tabs { gap: 0; scrollbar-width: none; }
  .tabs button { flex: 1; justify-content: center; padding: 10px 4px; font-size: 0.88rem; }
  .tabs .num { display: none; }
  .tagline { font-size: 0.82rem; }
}
.preview-wrap { position: sticky; top: 12px; }
.preview { display: block; max-width: 100%; border-radius: 8px; box-shadow: var(--shadow); touch-action: none; cursor: move; }
.corners { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin-bottom: 8px; }
.corners button { padding: 6px; background: transparent; color: var(--ink); }
.options select#opt-strength { margin: -4px 0 12px; }
.result { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; padding: 14px; border-radius: 8px; background: var(--ok-bg); color: var(--ok); }

.report { border-radius: var(--radius); padding: 20px; margin-bottom: 16px; border: 1px solid transparent; }
.report h3 { margin: 0 0 6px; font-size: 1.2rem; }
.report p { margin: 0; }
.report.ok { background: var(--ok-bg); color: var(--ok); }
.report.warn { background: var(--warn-bg); color: var(--warn); }
.report.bad { background: var(--bad-bg); color: var(--bad); }
.report.info { background: var(--info-bg); color: var(--info); }
.report.none { background: var(--surface-2); color: var(--muted); }
.details { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }
.verify-thumb { max-width: 100%; max-height: 220px; border-radius: 8px; display: block; margin-bottom: 16px; }

footer { margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--border); color: var(--muted); font-size: 0.85rem; }
footer p { margin: 0 0 4px; }

[hidden] { display: none !important; }
