:root {
  --bg: #0b0b0c; --card: #131314; --card2: #19191b; --field: #0e0e0f; --line: #29261f; --text: #f1ede3; --muted: #99948a;
  --gold: #d8bb74; --gold-line: rgba(216,187,116,.55); --gold-soft: rgba(216,187,116,.12); --on-gold: #1c1508;
  --grad: linear-gradient(135deg, #f2dfa4 0%, #d6b35c 48%, #b68c37 100%); --bad: #e08a7d;
  color-scheme: dark;
}
* { box-sizing: border-box; margin: 0; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Sukhumvit Set", "Noto Sans Thai", sans-serif;
  background: radial-gradient(90% 340px at 50% -90px, rgba(216,187,116,.13) 0%, transparent 72%), var(--bg);
  color: var(--text); line-height: 1.5; min-height: 100dvh;
  max-width: 620px; margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 16px calc(170px + env(safe-area-inset-bottom));
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 1px solid var(--line); background: var(--card2); border-radius: 12px; padding: 10px 16px; min-height: 44px; }
button:disabled { opacity: .45; cursor: default; }
:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
input { width: 100%; min-width: 0; background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 11px 12px; font-size: 16px; }

.brand { text-align: center; margin-bottom: 22px; }
.brand img { display: block; width: 144px; height: auto; margin: 0 auto 6px; filter: drop-shadow(0 10px 22px rgba(0,0,0,.55)); }
.brand h1 { font-family: "Optima", "Avenir Next", -apple-system, sans-serif; font-size: 17px; font-weight: 600; letter-spacing: .34em; padding-left: .34em; color: var(--gold); }
.brand p { color: var(--muted); font-size: 12.5px; margin-top: 4px; }
.brand::after { content: ""; display: block; width: 120px; height: 1px; margin: 14px auto 0; background: linear-gradient(90deg, transparent, var(--gold-line), transparent); }

.ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; vertical-align: -4px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; margin-bottom: 14px; }
.card h2 { font-size: 16px; font-weight: 600; margin-bottom: 12px; overflow-wrap: anywhere; }
.card h2 .ico { color: var(--gold); margin-right: 9px; }
.muted { color: var(--muted); font-size: 13px; }
.warn { border-color: var(--gold-line); background: var(--gold-soft); font-size: 14px; }
.err { color: var(--bad); font-size: 14px; overflow-wrap: anywhere; }
.err:empty { display: none; }
.note { text-align: center; }

#auth { display: flex; flex-direction: column; gap: 12px; }
#auth h2 { margin: 0; }
#auth label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
#passkey-login { display: flex; align-items: center; justify-content: center; gap: 10px; }
#passkey-login .ico { width: 26px; height: 26px; }
.or { display: flex; align-items: center; gap: 10px; margin-top: 14px; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
#passkeys { list-style: none; padding: 0; }
#passkeys li { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--line); }
#passkeys small { display: block; }
#passkey-note:not(:empty) { margin-top: 8px; }
#passkey-add { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
#passkey-add .big { font-size: 16px; }
#passkey-error { margin-top: 8px; }

.drop-card { text-align: center; padding: 28px 16px 20px; border: 1px solid var(--gold-line); border-radius: 18px; margin-bottom: 14px; background: linear-gradient(180deg, var(--gold-soft), transparent 75%), var(--card); }
.drop-card > .ico { display: block; width: 40px; height: 40px; margin: 0 auto 12px; color: var(--gold); stroke-width: 1.2; }
.drop-card label { display: block; font-size: 20px; font-weight: 600; margin-bottom: 4px; }
.link-row { display: flex; gap: 8px; margin-top: 16px; }
.link-row input { flex: 1; }
.link-row button { flex: none; border-color: var(--gold-line); color: var(--gold); border-radius: 12px; }
.drop-card .err { margin-top: 10px; }

#thumb { display: block; margin: 0 auto 12px; max-width: 100%; max-height: 340px; border-radius: 14px; }
#result h2 { margin-bottom: 4px; }

.choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.choice { text-align: left; padding: 12px; display: flex; flex-direction: column; justify-content: flex-start; }
.choice.wide { grid-column: 1 / -1; }
.choice b { display: flex; gap: 8px; align-items: center; font-weight: 600; }
.choice b .ico { color: var(--gold); width: 18px; height: 18px; }
.choice small { display: block; font-size: 12px; color: var(--muted); line-height: 1.45; margin-top: 6px; }
.choice.on { border-color: var(--gold); background: var(--gold-soft); }
.choice.on b { color: var(--gold); }

.primary { background: var(--grad); border: 0; color: var(--on-gold); font-weight: 700; }
.big { width: 100%; font-size: 17px; letter-spacing: .02em; padding: 15px; border-radius: 14px; }

#jobs { list-style: none; padding: 0; }
#jobs li p { overflow-wrap: anywhere; }
.caution { color: var(--gold); font-size: 13px; margin-top: 6px; }
.keep { text-align: center; margin-bottom: 12px; }
.card .keep { text-align: left; margin: 10px 0 0; }
.state { display: flex; justify-content: space-between; padding: 5px 0; }
.state span { color: var(--gold); }
.state span.bad { color: var(--bad); }
#diagnose { margin-top: 12px; font-size: 15px; }
#report { margin-top: 10px; padding: 12px; background: var(--field); border: 1px solid var(--line); border-radius: 12px; font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }
progress { -webkit-appearance: none; appearance: none; display: block; width: 100%; height: 6px; margin-top: 10px; border: 0; border-radius: 10px; overflow: hidden; background: #24221d; }
progress::-webkit-progress-bar { background: #24221d; }
progress::-webkit-progress-value { background: var(--grad); }
progress::-moz-progress-bar { background: var(--grad); }
.actions { display: flex; gap: 8px; margin-top: 12px; }
.actions a { flex: 1; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; border-radius: 12px; padding: 10px 16px; text-decoration: none; }
.actions a.primary { color: var(--on-gold); }
.actions button:not(.primary) { margin-left: auto; }
.actions button.primary { flex: 1; font-size: 16px; }
.actions button.primary:disabled { opacity: .75; }
#jobs .how { margin-top: 8px; text-align: center; }
#device { font-size: 12px; color: var(--muted); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }

/* Fade at the bottom so content does not show behind the button and menu. */
body.in::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: calc(104px + env(safe-area-inset-bottom)); background: linear-gradient(transparent, var(--bg) 38%); pointer-events: none; z-index: 4; }
#cta { position: fixed; left: 50%; transform: translateX(-50%); width: min(100% - 32px, 588px); bottom: calc(92px + env(safe-area-inset-bottom)); z-index: 5; }
#cta .big { box-shadow: 0 8px 28px rgba(0,0,0,.5); }
#cta .big:disabled { opacity: 1; background: #1d1c1a; border: 1px solid var(--line); color: var(--muted); }
#tabs { position: fixed; left: 50%; transform: translateX(-50%); width: min(100% - 20px, 600px); bottom: calc(10px + env(safe-area-inset-bottom));
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; background: #111112; border: 1px solid var(--line); border-radius: 20px; padding: 6px; z-index: 6; }
#tabs button { border: 0; background: none; color: var(--muted); font-size: 12.5px; padding: 8px 7px 6px; border-radius: 15px; }
#tabs button .ico { display: block; width: 22px; height: 22px; margin: 0 auto 3px; }
#tabs button.on { background: var(--gold-soft); color: var(--gold); font-weight: 600; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); top: calc(12px + env(safe-area-inset-top)); width: max-content; max-width: calc(100% - 32px);
  background: #1f1d18; border: 1px solid var(--gold-line); border-radius: 14px; padding: 10px 16px; font-size: 14px; z-index: 20; opacity: 0; pointer-events: none; transition: opacity .2s; }
#toast.show { opacity: 1; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
