:root {
  --plate: #1F4B99;
  --plate-ink: #FFFFFF;
  --wall: #E8EAED;
  --paper: #F7F8F9;
  --ink: #16202E;
  --ink-2: #4A5565;
  --vest: #F26A1B;
  --fade: #8C939D;
  --line: #CDD2D9;
  --ok: #2D7A57;
  --font: "IBM Plex Sans Thai Looped", "IBM Plex Sans KR", system-ui, -apple-system, sans-serif;
  --num: "IBM Plex Sans Condensed", "IBM Plex Sans Thai Looped", system-ui, sans-serif;
  --gutter: 16px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --plate: #2A5BB0;
    --wall: #0F1A2C;
    --paper: #16233A;
    --ink: #E9EDF3;
    --ink-2: #A9B4C4;
    --fade: #7E8897;
    --line: #2B3A55;
    --ok: #5BB98C;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--wall);
  color: var(--ink);
  font: 400 16px/1.55 var(--font);
  min-height: 100dvh;
}
button, input { font: inherit; color: inherit; }
a { color: var(--plate); }
@media (prefers-color-scheme: dark) { a { color: #8FB3F0; } }
:focus-visible { outline: 3px solid var(--vest); outline-offset: 2px; }
[hidden] { display: none !important; }
#app { max-width: 560px; margin: 0 auto; padding: 0 0 calc(24px + env(safe-area-inset-bottom)); }

/* ---------- the soi plate ---------- */
.plate {
  background: var(--plate);
  color: var(--plate-ink);
  border-radius: 6px;
  box-shadow: inset 0 0 0 3px var(--plate), inset 0 0 0 5px var(--plate-ink);
  padding: 14px 20px 12px;
}
.plate p { margin: 0; }
.plate__th { font-weight: 700; font-size: 34px; line-height: 1.15; letter-spacing: .01em; }
.plate__en { font-family: var(--num); font-weight: 500; font-size: 15px; letter-spacing: .04em; opacity: .9; }
.plate--gate { display: inline-block; padding: 22px 34px 18px; }
.plate--gate .plate__th { font-size: clamp(54px, 18vw, 76px); }
.plate--gate .plate__en { font-size: 20px; }
.plate--top { flex: 1; min-width: 0; }
.plate--top .plate__th { font-size: clamp(24px, 7vw, 32px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- gate ---------- */
.gate { min-height: 100dvh; display: flex; flex-direction: column; justify-content: center; padding: 32px var(--gutter); }
.gate__slogan { font-size: clamp(26px, 7.5vw, 34px); line-height: 1.25; font-weight: 700; margin: 28px 0 6px; }
.gate__sub { margin: 0 0 28px; color: var(--ink-2); max-width: 32ch; }
.gate__msg { min-height: 1.5em; margin: 14px 0 0; color: var(--ink); }
.gate__pulse { margin-top: 26px; color: var(--ink-2); font-size: 15px; }
.gate__pulse b { font-family: var(--num); font-weight: 600; color: var(--ink); font-size: 22px; margin-right: 4px; }
.gate__pulse p { margin: 2px 0; }
.gate__privacy { margin-top: 28px; font-size: 13px; color: var(--ink-2); max-width: 40ch; }

.btn {
  display: inline-flex; align-items: center; gap: 10px;
  border: 0; border-radius: 999px; padding: 14px 24px; cursor: pointer;
  font-weight: 600; font-size: 18px;
}
.btn--here { background: var(--ink); color: var(--paper); align-self: flex-start; }
.btn--here:disabled { opacity: .6; cursor: progress; }
.dot { width: 12px; height: 12px; border-radius: 50%; background: var(--vest); box-shadow: 0 0 0 4px rgba(242,106,27,.25); flex: none; }
.btn--here.is-busy .dot { animation: ping 1.1s ease-out infinite; }
@keyframes ping { 0% { box-shadow: 0 0 0 0 rgba(242,106,27,.55); } 100% { box-shadow: 0 0 0 14px rgba(242,106,27,0); } }

/* ---------- top ---------- */
.top { position: sticky; top: 0; z-index: 5; display: flex; gap: 10px; align-items: stretch;
       padding: calc(10px + env(safe-area-inset-top)) var(--gutter) 10px; background: var(--wall); }
.top__tools { display: flex; flex-direction: column; gap: 8px; justify-content: space-between; }
.seg { display: flex; background: var(--paper); border-radius: 999px; padding: 3px; border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 5px 9px; font-family: var(--num);
              font-size: 13px; font-weight: 600; cursor: pointer; color: var(--ink-2); white-space: nowrap; }
.seg button[aria-checked="true"] { background: var(--plate); color: var(--plate-ink); }
.iconbtn { align-self: flex-end; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
           background: var(--paper); display: grid; place-items: center; cursor: pointer; }
.iconbtn.is-busy .dot { animation: ping 1.1s ease-out infinite; }

/* ---------- find ---------- */
.find { padding: 4px var(--gutter) 6px; }
.find__box { display: flex; align-items: center; gap: 8px; background: var(--paper); border: 2px solid var(--ink);
             border-radius: 12px; padding: 0 12px; }
.find__box svg { width: 20px; height: 20px; fill: none; stroke: var(--ink-2); stroke-width: 2; stroke-linecap: round; flex: none; }
.find__box input { flex: 1; min-width: 0; border: 0; background: transparent; padding: 12px 0; font-size: 17px; outline: none; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 5px; border: 1px solid var(--line); background: var(--paper);
        border-radius: 999px; padding: 6px 12px 6px 9px; cursor: pointer; font-size: 14px; white-space: nowrap; }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.chip .e { font-size: 16px; line-height: 1; }

.status { margin: 6px var(--gutter) 0; min-height: 1.2em; font-size: 13px; color: var(--ink-2); }

/* ---------- results ---------- */
.list { list-style: none; margin: 4px 0 0; padding: 0; }
.row { display: grid; grid-template-columns: 74px 1fr 52px; gap: 0 12px; align-items: center;
       padding: 12px var(--gutter); border-top: 1px solid var(--line); background: var(--paper); cursor: pointer;
       text-align: left; width: 100%; border-left: 0; border-right: 0; border-bottom: 0; }
.list li:last-child .row { border-bottom: 1px solid var(--line); }
.row__d { font-family: var(--num); font-weight: 600; font-size: 24px; line-height: 1; text-align: right; }
.row__d small { display: block; font-size: 12px; font-weight: 500; color: var(--ink-2); margin-top: 3px; }
.row__main { min-width: 0; }
.row__name { font-weight: 600; font-size: 16px; line-height: 1.3; overflow: hidden; display: -webkit-box;
             -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.row__meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; display: flex; flex-wrap: wrap; gap: 4px 8px; }
.row__pic { width: 52px; height: 52px; border-radius: 8px; object-fit: cover; background: var(--wall);
            display: grid; place-items: center; font-size: 24px; }

/* seed: open data nobody has checked yet */
.row--seed .row__name { color: var(--ink-2); font-weight: 500; }
.row--seed .row__pic { background: transparent; border: 2px dashed var(--fade); filter: grayscale(1); opacity: .75; }
.row--seed .row__d { color: var(--fade); }
.row--alive .row__pic { border: 2px solid var(--ok); background: transparent; }
/* human records age: fresh, living, fading */
.row--fresh .row__pic { box-shadow: 0 0 0 3px var(--vest); }
.row--fading { opacity: .72; }
.row--fading .row__pic { filter: sepia(.7) saturate(.6); }
/* soi page with a paid slot */
.row--paid { background: linear-gradient(90deg, rgba(31,75,153,.08), transparent 60%), var(--paper); }
.tag { font-size: 12px; border-radius: 4px; padding: 0 6px; line-height: 1.6; }
.tag--paid { background: var(--plate); color: var(--plate-ink); }
.tag--seed { border: 1px dashed var(--fade); color: var(--ink-2); }
.tag--ok { border: 1px solid var(--ok); color: var(--ok); }

.empty { margin: 18px var(--gutter); padding: 22px 20px; background: var(--paper); border-radius: 12px; border: 1px solid var(--line); }
.empty h2 { font-size: 20px; margin: 0 0 6px; }
.empty p { margin: 0 0 14px; color: var(--ink-2); }
.btn--line { background: transparent; border: 2px solid var(--ink); color: var(--ink); font-size: 16px; padding: 10px 18px; text-decoration: none; }

/* ---------- foot ---------- */
.foot { padding: 28px var(--gutter) 0; font-size: 13px; color: var(--ink-2); }
.foot p { margin: 0 0 10px; }
.foot__ratio { font-size: 15px; color: var(--ink); }
.foot__ratio b { font-family: var(--num); font-size: 20px; }
.foot__links { display: flex; gap: 16px; flex-wrap: wrap; }
.foot__langs button { border: 0; background: none; padding: 4px 8px 4px 0; cursor: pointer; color: var(--ink-2); text-decoration: underline; text-underline-offset: 3px; }
.foot__langs button[aria-current="true"] { color: var(--ink); text-decoration: none; font-weight: 600; }

/* ---------- sheet ---------- */
.sheet { position: fixed; inset: 0; z-index: 20; }
.sheet__scrim { position: absolute; inset: 0; background: rgba(10,18,32,.45); }
.sheet__body { position: absolute; left: 0; right: 0; bottom: 0; max-width: 560px; margin: 0 auto; max-height: 88dvh;
               overflow-y: auto; background: var(--paper); border-radius: 18px 18px 0 0;
               padding: 22px var(--gutter) calc(24px + env(safe-area-inset-bottom)); animation: up .22s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .4; } to { transform: none; opacity: 1; } }
.sheet__close { position: absolute; right: 10px; top: 10px; width: 40px; height: 40px; border-radius: 50%;
                border: 1px solid var(--line); background: var(--paper); cursor: pointer; font-size: 16px; }
.sh__kind { font-size: 14px; color: var(--ink-2); margin: 0 48px 4px 0; }
.sh__name { font-size: 24px; line-height: 1.25; margin: 0 48px 4px 0; }
.sh__alt { margin: 0 0 8px; color: var(--ink-2); }
.sh__d { font-family: var(--num); font-weight: 600; font-size: 20px; margin: 0 0 12px; }
.sh__state { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 16px; }
.sh__acts { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 18px; }
.act { display: inline-flex; align-items: center; gap: 6px; padding: 10px 16px; border-radius: 999px; border: 1px solid var(--line);
       background: var(--wall); color: var(--ink); text-decoration: none; font-weight: 600; font-size: 15px; cursor: pointer; }
.act--main { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.mark { border-top: 1px solid var(--line); padding-top: 16px; }
.mark p { margin: 0 0 10px; color: var(--ink-2); font-size: 14px; }
.mark__btns { display: flex; gap: 8px; }
.mark__btns button { flex: 1; padding: 13px 10px; border-radius: 12px; font-weight: 600; cursor: pointer; font-size: 16px; }
.mark__here { background: var(--vest); color: #fff; border: 0; }
.mark__gone { background: transparent; border: 2px solid var(--ink-2); color: var(--ink); }
.mark__btns button:disabled { opacity: .45; cursor: not-allowed; }
.sh__cover { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 12px; margin: 0 0 12px; background: var(--wall); }
.thing { display: grid; grid-template-columns: 72px 1fr; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.thing img { width: 72px; height: 72px; object-fit: cover; border-radius: 8px; background: var(--wall); }
.thing h3 { margin: 0 0 2px; font-size: 16px; }
.thing p { margin: 0; font-size: 14px; color: var(--ink-2); }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%);
         z-index: 30; max-width: calc(100% - 32px); background: var(--ink); color: var(--paper);
         padding: 12px 18px; border-radius: 12px; font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
