:root { --ink: #102f4f; --muted: #5c7486; --line: #d5e3ec; --bg: #f1f7fa; --paper: #fff; --accent: #1479a8; --accent-dark: #0d5c80; --gold: #f2b63d; --danger: #c0392b; --ok: #1a8f63; }
* { box-sizing: border-box; }
body { margin: 0; color: var(--ink); background: var(--bg); font-family: "Noto Sans Thai", "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif; font-size: 15px; line-height: 1.55; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.shell { max-width: 960px; margin: 0 auto; padding: 16px 16px 80px; }
.topbar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; }
.topbar h1 { flex: 1 1 auto; margin: 0; font-size: 20px; }
.topbar h1 small { display: block; color: var(--muted); font-size: 12px; font-weight: 400; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 42px; padding: 8px 16px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); font-weight: 600; }
.btn:hover { border-color: var(--accent); }
.btn.primary { color: #fff; border-color: var(--accent-dark); background: var(--accent); }
.btn.primary:hover { background: var(--accent-dark); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 34px; padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.login { max-width: 380px; margin: 12vh auto 0; padding: 28px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); box-shadow: 0 10px 30px rgba(16,47,79,.08); }
.login h1 { margin: 0 0 4px; font-size: 22px; }
.login p { margin: 0 0 18px; color: var(--muted); }
.opening { margin-top: 12vh; }
.opening .progress i { animation: opening-pulse 1s ease-in-out infinite alternate; }
@keyframes opening-pulse { from { width: 30%; opacity: .65; } to { width: 90%; opacity: 1; } }

.field { display: grid; gap: 5px; margin-bottom: 14px; }
.field > span, .field > label { font-size: 13px; font-weight: 600; color: var(--muted); }
.field input[type="text"], .field input[type="password"], .field input[type="url"], .field input[type="number"], .field select, .field textarea { width: 100%; min-height: 42px; padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.field textarea { min-height: 120px; resize: vertical; line-height: 1.6; }
.field input:focus, .field select:focus, .field textarea:focus { outline: 2px solid rgba(20,121,168,.3); border-color: var(--accent); }
.hint { margin: 0; color: var(--muted); font-size: 12.5px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; }
.row > * { flex: 1 1 200px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.check input { width: 18px; height: 18px; }

.banner { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-bottom: 14px; padding: 12px 14px; border: 1px solid #f0d28a; border-radius: 12px; background: #fff7df; }
.banner.ok { border-color: #a8e0c8; background: #eafaf3; }
.banner p { flex: 1 1 260px; margin: 0; }

.cards { display: grid; gap: 10px; }
.card-row { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 12px; padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--paper); }
.thumb { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; background: #dfeaf1; }
.thumb.empty { display: grid; place-items: center; color: var(--muted); font-size: 11px; }
.card-row h3 { margin: 0; font-size: 16px; }
.meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.badge { padding: 1px 9px; border-radius: 999px; background: #e4eef4; color: var(--muted); font-size: 12px; }
.badge.ok { background: #d9f4e8; color: var(--ok); }
.badge.warn { background: #ffefc4; color: #8a5b00; }
.badge.bad { background: #fde0dc; color: var(--danger); }
.actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.empty-state { padding: 40px 16px; text-align: center; color: var(--muted); border: 2px dashed var(--line); border-radius: 16px; }

.panel { margin-bottom: 16px; padding: 16px; border: 1px solid var(--line); border-radius: 16px; background: var(--paper); }
.panel > h2 { margin: 0 0 12px; font-size: 16px; }
.accounts { display: grid; gap: 10px; }
.account-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdfe; }
.account-row h3 { margin: 0; font-size: 16px; }
.account-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 12px; }
.share-link, .library-link a { color: var(--accent-dark); overflow-wrap: anywhere; }
.library-link { padding: 10px 14px; }
.target-box { display: grid; grid-template-columns: 120px 1fr; gap: 14px; align-items: start; }
.target-box img { width: 120px; height: 120px; object-fit: contain; border: 1px solid var(--line); border-radius: 12px; background: #f6fafc; }
.quality { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; font-weight: 600; }
.quality-bar { flex: 0 0 120px; height: 8px; border-radius: 99px; background: #e4eef4; overflow: hidden; }
.quality-bar i { display: block; height: 100%; background: var(--ok); }
.quality.mid .quality-bar i { background: var(--gold); }
.quality.low .quality-bar i { background: var(--danger); }

.block { margin-bottom: 12px; border: 1px solid var(--line); border-radius: 14px; background: #fbfdfe; }
.block-head { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--line); border-radius: 14px 14px 0 0; background: #eef5f9; }
.block-head strong { flex: 1; }
.block-body { padding: 12px; }
.add-menu { display: flex; flex-wrap: wrap; gap: 8px; }

.choice-row { display: grid; grid-template-columns: 28px 1fr auto; align-items: center; gap: 8px; margin-bottom: 6px; }
.choice-row input[type="text"] { min-height: 38px; padding: 6px 10px; border: 1px solid var(--line); border-radius: 8px; width: 100%; }
.question { margin-bottom: 12px; padding: 12px; border: 1px dashed var(--line); border-radius: 12px; background: #fff; }
.img-list { display: grid; gap: 8px; margin-bottom: 8px; }
.img-item { display: grid; grid-template-columns: 64px 1fr auto; align-items: center; gap: 10px; padding: 8px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
.img-item img { width: 64px; height: 64px; object-fit: cover; border-radius: 8px; }
.yt-preview { display: flex; align-items: center; gap: 10px; margin-top: 8px; }
.yt-preview img { width: 120px; border-radius: 8px; }

.progress { width: 100%; height: 10px; border-radius: 99px; background: #e4eef4; overflow: hidden; margin-top: 8px; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

.modal { position: fixed; inset: 0; z-index: 50; display: grid; place-items: start center; padding: 24px 12px; overflow-y: auto; background: rgba(6,20,34,.7); }
.modal-inner { width: min(100%, 460px); }
.modal-close { position: sticky; top: 0; display: block; margin: 0 0 8px auto; }
.preview-card { padding: 22px 18px; border: 1px solid rgba(174,225,243,.5); border-radius: 26px; color: #fff; background: linear-gradient(150deg, #174161, #071d30 60%, #051624); box-shadow: 0 20px 50px rgba(0,0,0,.4); }
.preview-card h1 { margin: 0 0 4px; font-size: 26px; line-height: 1.25; text-align: center; color: #fff; }
.preview-card .kicker { margin: 0 0 6px; text-align: center; color: #91cbe2; font-size: 11px; font-weight: 700; }
.preview-card .rule { height: 1px; margin: 14px 8%; background: linear-gradient(90deg, transparent, rgba(255,214,120,.7), transparent); }

.toast { position: fixed; left: 50%; bottom: 20px; z-index: 80; max-width: min(92vw, 520px); padding: 12px 18px; border-radius: 12px; color: #fff; background: #12324f; box-shadow: 0 10px 30px rgba(0,0,0,.3); transform: translateX(-50%); }
.toast.error { background: var(--danger); }
.toast.ok { background: var(--ok); }

@media (max-width: 560px) {
  .account-row { grid-template-columns: 1fr; }
  .account-row .actions { justify-content: flex-start; }
  .account-fields { grid-template-columns: 1fr; }
  .card-row { grid-template-columns: 56px 1fr; }
  .card-row .actions { grid-column: 1 / -1; justify-content: flex-start; }
  .thumb { width: 56px; height: 56px; }
  .target-box { grid-template-columns: 1fr; }
}

/* Pastel mint admin theme */
:root { --ink: #173f37; --muted: #63847a; --line: #cbe8df; --bg: #effaf5; --paper: rgba(253,255,254,.9); --accent: #409f85; --accent-dark: #277863; --gold: #c8a95f; --danger: #bd493e; --ok: #22875f; }
body {
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 8%, rgba(255,255,255,.98), transparent 28%),
    radial-gradient(circle at 92% 76%, rgba(127,216,191,.25), transparent 34%),
    linear-gradient(145deg, #fbfffd, #e5f7f0 55%, #f7fffb);
  isolation: isolate;
}
body::before, body::after { content: ""; position: fixed; z-index: -1; pointer-events: none; border-radius: 50%; filter: blur(2px); }
body::before { top: -22vw; right: -18vw; width: 70vw; height: 70vw; background: conic-gradient(from 50deg, transparent 0 27%, rgba(255,255,255,.78) 34%, transparent 42% 70%, rgba(108,206,178,.16) 78%, transparent 88%); animation: admin-shimmer 14s ease-in-out infinite alternate; }
body::after { left: -12vw; bottom: -18vw; width: 45vw; height: 45vw; background: radial-gradient(circle, rgba(117,211,185,.2), transparent 68%); animation: admin-float 10s ease-in-out infinite alternate; }
#app { position: relative; z-index: 1; }
.shell { padding-top: 22px; }
.topbar { padding: 12px 14px; border: 1px solid rgba(194,230,219,.88); border-radius: 18px; background: rgba(255,255,255,.72); box-shadow: 0 14px 38px rgba(50,126,105,.1), inset 0 1px 0 white; backdrop-filter: blur(15px); }
.admin-title { display: flex; align-items: center; gap: 10px; }
.admin-title > img { flex: 0 0 42px; width: 42px; height: 42px; object-fit: contain; filter: drop-shadow(0 7px 8px rgba(40,126,102,.18)); }
.admin-title > span { min-width: 0; }
.admin-brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.admin-brand img { width: 58px; height: 58px; object-fit: contain; filter: drop-shadow(0 9px 10px rgba(40,126,102,.2)); }
.admin-brand h1 { margin: 0; }
.btn { border-color: var(--line); background: rgba(255,255,255,.82); box-shadow: 0 5px 14px rgba(48,125,104,.06), inset 0 1px 0 white; transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease; }
.btn:hover { transform: translateY(-1px); box-shadow: 0 9px 18px rgba(48,125,104,.11), inset 0 1px 0 white; }
.btn.primary { border-color: #267862; background: linear-gradient(145deg, #58bea2, #318d75); box-shadow: 0 7px 16px rgba(42,130,106,.2), inset 0 1px 0 rgba(255,255,255,.35); }
.btn.primary:hover { background: linear-gradient(145deg, #4bb396, #277862); }
.login { border-color: rgba(182,224,211,.9); background: rgba(255,255,255,.84); box-shadow: 0 24px 65px rgba(43,125,103,.16), inset 0 1px 0 white; backdrop-filter: blur(18px); }
.field input[type="text"], .field input[type="password"], .field input[type="url"], .field input[type="number"], .field select, .field textarea { border-color: #c8e4db; background: rgba(255,255,255,.82); }
.field input:focus, .field select:focus, .field textarea:focus { outline-color: rgba(62,157,131,.26); border-color: var(--accent); box-shadow: 0 0 0 4px rgba(83,181,154,.08); }
.banner { border-color: #ead9a9; background: rgba(255,250,233,.9); box-shadow: 0 8px 24px rgba(107,92,46,.06); }
.banner.ok { border-color: #a5dbc9; background: rgba(232,250,243,.92); }
.card-row, .panel, .account-row, .block { border-color: var(--line); background: rgba(255,255,255,.78); box-shadow: 0 10px 28px rgba(47,125,104,.075), inset 0 1px 0 white; backdrop-filter: blur(10px); }
.card-row:hover, .account-row:hover { border-color: #a8d8ca; box-shadow: 0 14px 32px rgba(47,125,104,.11), inset 0 1px 0 white; }
.thumb { background: #def2eb; }
.badge { background: #e4f2ed; }
.badge.ok { background: #d9f4e8; }
.empty-state { background: rgba(255,255,255,.45); }
.share-link, .library-link a { color: #277863; }
.target-box img { background: #f5fcf9; }
.quality-bar, .progress { background: #dceee8; }
.block-head { background: linear-gradient(90deg, rgba(219,243,235,.88), rgba(247,253,250,.88)); }
.question, .img-item { border-color: var(--line); background: rgba(255,255,255,.76); }
.modal { background: rgba(14,55,47,.62); backdrop-filter: blur(6px); }
.preview-card { border-color: rgba(113,200,176,.52); color: #234f44; background: radial-gradient(circle at 50% 0, rgba(255,255,255,.96), transparent 42%), linear-gradient(150deg, #fcfffd, #e4f7f0 60%, #f7fffb); box-shadow: 0 25px 60px rgba(18,75,62,.28); }
.preview-card h1 { color: #173f37; }
.preview-card .kicker { color: #568b7c; }
.preview-card .rule { background: linear-gradient(90deg, transparent, rgba(66,166,139,.68), transparent); }
.toast { background: #245f50; }

@keyframes admin-shimmer { from { transform: rotate(-8deg) translate3d(-2%, -1%, 0); opacity: .55; } to { transform: rotate(7deg) translate3d(4%, 2%, 0); opacity: .95; } }
@keyframes admin-float { from { transform: translate3d(-8px, 0, 0) scale(.95); } to { transform: translate3d(18px, -12px, 0) scale(1.08); } }

@media (prefers-reduced-motion: reduce) {
  body::before, body::after, .opening .progress i { animation: none; }
  .btn { transition: none; }
}

@media (max-width: 560px) {
  .topbar { padding: 10px; }
  .admin-title { flex-basis: 100%; }
  .admin-title > img { width: 36px; height: 36px; flex-basis: 36px; }
  .login { margin-top: 7vh; }
}
