/* GPT-RedKey · ธีมแดง-ดำ (แดงเข้ม = สีแบรนด์ · แดงสด+ไอคอนเตือน = คำเตือน/ข้อผิดพลาด) */
:root {
  --bg: #0b0b0d; --bg-2: #121215; --card: #16161a; --card-2: #1c1c21; --line: #2a2a31; --line-2: #3a3a43;
  --text: #ececf0; --text-2: #a9a9b3; --text-3: #75757f;
  --brand: #c1121f; --brand-2: #e01e2b; --brand-deep: #7a0b13; --brand-soft: rgba(193, 18, 31, .14);
  --danger: #ff4d4f; --danger-bg: rgba(255, 77, 79, .12); --ok: #2fbf71; --ok-bg: rgba(47, 191, 113, .12);
  --warn: #f5a524; --warn-bg: rgba(245, 165, 36, .12); --gold: #d9a441; --info: #5aa9ff;
  --c-up: #ff8a8a; --c-low: #ececf0; --c-dig: #6fd3ff; --c-sym: #f5c451;
  --radius: 10px; --radius-lg: 14px;
  --font: "Segoe UI", "Leelawadee UI", "Noto Sans Thai", "Sarabun", system-ui, -apple-system, sans-serif;
  --mono: "Cascadia Mono", "JetBrains Mono", Consolas, "SFMono-Regular", Menlo, monospace;
  --nav-w: 224px; --top-h: 58px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--info); }
button, input, textarea { font: inherit; color: inherit; }
.sprite { display: none; }
.hidden { display: none !important; }
.ic { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.ic.lg { width: 26px; height: 26px; } .ic.sm { width: 16px; height: 16px; }
:focus-visible { outline: 2px solid var(--brand-2); outline-offset: 2px; }

/* ---------- โครงหน้า ---------- */
.app { display: grid; grid-template-columns: var(--nav-w) 1fr; grid-template-rows: var(--top-h) 1fr; min-height: 100vh; }
.topbar { grid-column: 1 / -1; display: flex; align-items: center; gap: 10px; padding: 0 18px; background: rgba(11, 11, 13, .92); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(8px); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); text-decoration: none; }
.brand-logo { width: 36px; height: 36px; border-radius: 10px; background: linear-gradient(145deg, var(--brand-2), var(--brand-deep)); display: grid; place-items: center; color: #fff; box-shadow: 0 2px 10px rgba(193, 18, 31, .35); }
.brand-name { font-size: 18px; letter-spacing: .3px; } .brand-name b { color: var(--brand-2); }
.topbar-spacer { flex: 1; }
.nav { border-right: 1px solid var(--line); padding: 14px 10px; display: flex; flex-direction: column; gap: 4px; background: var(--bg-2); position: sticky; top: var(--top-h); height: calc(100vh - var(--top-h)); }
.nav a { display: flex; align-items: center; gap: 12px; padding: 11px 14px; border-radius: var(--radius); color: var(--text-2); text-decoration: none; font-weight: 500; }
.nav a .ic { width: 22px; height: 22px; }
.nav a:hover { background: var(--card); color: var(--text); }
.nav a.active { background: var(--brand-soft); color: #fff; box-shadow: inset 3px 0 0 var(--brand-2); }
.main { padding: 22px clamp(14px, 3vw, 34px) 80px; max-width: 1180px; width: 100%; outline: none; }
.boot { display: grid; place-items: center; gap: 12px; padding: 80px 0; color: var(--text-2); }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: var(--top-h) 1fr auto; }
  .nav { position: fixed; bottom: 0; left: 0; right: 0; top: auto; height: auto; flex-direction: row; justify-content: space-around; padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); border-right: 0; border-top: 1px solid var(--line); z-index: 25; }
  .nav a { flex-direction: column; gap: 2px; padding: 6px 4px; font-size: 11px; flex: 1; text-align: center; }
  .nav a.active { box-shadow: inset 0 3px 0 var(--brand-2); }
  .main { padding: 16px 16px 100px; }
  .brand-name { font-size: 16px; }
}

/* ---------- องค์ประกอบ ---------- */
h1 { font-size: 22px; margin: 0 0 4px; display: flex; align-items: center; gap: 10px; }
h1 .ic { width: 28px; height: 28px; color: var(--brand-2); }
h2 { font-size: 17px; margin: 0; display: flex; align-items: center; gap: 8px; }
h2 .ic { color: var(--brand-2); width: 22px; height: 22px; }
.sub { color: var(--text-2); margin: 0 0 18px; }
.muted { color: var(--text-2); } .tiny { font-size: 12.5px; color: var(--text-3); }
.grid { display: grid; gap: 16px; }
.cols-2 { grid-template-columns: minmax(0, 1.25fr) minmax(0, 1fr); }
@media (max-width: 1020px) { .cols-2 { grid-template-columns: minmax(0, 1fr); } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 16px 18px; min-width: 0; }
.card-head { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 12px; }
.card-head.collapsible { cursor: pointer; user-select: none; margin-bottom: 0; }
.card-head .chev { transition: transform .2s; color: var(--text-3); }
.card.collapsed .chev { transform: rotate(-90deg); }
.card.collapsed .card-body { display: none; }
.card:not(.collapsed) .card-head.collapsible { margin-bottom: 12px; }
.divider { height: 1px; background: var(--line); margin: 14px 0; border: 0; }
.vsep { width: 1px; align-self: stretch; background: var(--line-2); margin: 0 4px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 10px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 9px 15px; border-radius: var(--radius); border: 1px solid var(--line-2); background: linear-gradient(180deg, #24242a, #1d1d22); cursor: pointer; font-weight: 500; white-space: nowrap; box-shadow: 0 1px 2px rgba(0, 0, 0, .4); transition: background .15s, border-color .15s, transform .05s; }
.btn:hover { border-color: #55555f; background: linear-gradient(180deg, #2a2a31, #222228); }
.btn:active { transform: translateY(1px); box-shadow: none; }
.btn.primary { background: linear-gradient(180deg, var(--brand-2), var(--brand)); border-color: var(--brand); color: #fff; box-shadow: 0 2px 8px rgba(193, 18, 31, .3); }
.btn.primary:hover { background: linear-gradient(180deg, #ef2b38, #cc1622); }
.btn.gold { border-color: var(--gold); color: var(--gold); }
.btn.danger { border-color: rgba(255, 77, 79, .5); color: var(--danger); }
.btn.danger:hover { background: var(--danger-bg); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.ghost:hover { background: var(--card-2); }
.btn.sm { padding: 6px 10px; font-size: 13.5px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 38px; height: 38px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--card-2); cursor: pointer; position: relative; }
.icon-btn:hover { border-color: #55555f; } .icon-btn.sm { width: 32px; height: 32px; }
.chip-btn { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line-2); background: var(--card); cursor: pointer; font-size: 13.5px; }
.chip-btn.unlocked { border-color: rgba(47, 191, 113, .5); color: var(--ok); }
.badge { position: absolute; top: -6px; right: -6px; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--brand-2); color: #fff; font-size: 11px; display: grid; place-items: center; }
.pill { display: inline-flex; align-items: center; gap: 4px; padding: 1px 9px; border-radius: 999px; font-size: 12px; border: 1px solid var(--line-2); color: var(--text-2); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: rgba(47, 191, 113, .45); background: var(--ok-bg); }
.pill.warn { color: var(--warn); border-color: rgba(245, 165, 36, .45); background: var(--warn-bg); }
.pill.bad { color: var(--danger); border-color: rgba(255, 77, 79, .45); background: var(--danger-bg); }
.pill.brand { color: #ff9aa1; border-color: rgba(224, 30, 43, .5); background: var(--brand-soft); }
.pill.gold { color: var(--gold); border-color: rgba(217, 164, 65, .5); }

input[type=text], input[type=password], input[type=email], input[type=number], input[type=search], input[type=url], textarea {
  width: 100%; background: #0e0e11; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 9px 12px; outline: none; transition: border-color .15s;
}
input:focus, textarea:focus { border-color: var(--brand-2); }
textarea { resize: vertical; min-height: 80px; }
input[type=number] { width: 84px; }
input[type=range] { width: 100%; accent-color: var(--brand-2); height: 22px; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--brand-2); margin: 0; cursor: pointer; flex: none; }
input[type=checkbox]:disabled { cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > .lbl { font-size: 13px; color: var(--text-2); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap input { padding-right: 44px; }
.input-wrap .icon-btn { position: absolute; right: 3px; width: 34px; height: 34px; border: 0; background: transparent; }
.seg { display: inline-flex; background: #0e0e11; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 6px 13px; border-radius: 7px; cursor: pointer; color: var(--text-2); display: inline-flex; gap: 6px; align-items: center; }
.seg button.on { background: var(--brand); color: #fff; }
.seg button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------- ผลลัพธ์รหัส ---------- */
.out-box { background: #050506; border: 1px solid var(--brand); border-radius: var(--radius-lg); padding: 16px 18px; font: 500 22px/1.5 var(--mono); word-break: break-all; min-height: 70px; letter-spacing: .5px; box-shadow: inset 0 0 0 1px rgba(193, 18, 31, .15), 0 0 24px rgba(193, 18, 31, .08); }
.out-box.masked { letter-spacing: 3px; color: var(--text-3); }
.ch-up { color: var(--c-up); } .ch-low { color: var(--c-low); } .ch-dig { color: var(--c-dig); } .ch-sym { color: var(--c-sym); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-3); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: 0; }
.ch-up-bg { background: var(--c-up); } .ch-low-bg { background: var(--c-low); } .ch-dig-bg { background: var(--c-dig); } .ch-sym-bg { background: var(--c-sym); }
.mt { margin-top: 12px; margin-bottom: 12px; }
.meter { height: 8px; border-radius: 5px; background: var(--line); overflow: hidden; }
.meter > i { display: block; height: 100%; width: 0; border-radius: 5px; transition: width .3s, background .3s; }
.s0 { background: var(--danger); } .s1 { background: #ff7a45; } .s2 { background: var(--warn); } .s3 { background: #7bd389; } .s4 { background: var(--ok); }
.t-s0 { color: var(--danger); } .t-s1 { color: #ff7a45; } .t-s2 { color: var(--warn); } .t-s3 { color: #7bd389; } .t-s4 { color: var(--ok); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--card-2); border-radius: var(--radius); padding: 10px 12px; }
.stat .k { font-size: 12px; color: var(--text-3); } .stat .v { font-size: 17px; font-weight: 600; }

/* ---------- ชุดอักขระ ---------- */
.charset { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 8px 12px; align-items: center; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.charset:last-child { border-bottom: 0; }
.charset .name { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.charset .chars { grid-column: 2 / 3; font: 13.5px/1.5 var(--mono); color: var(--text-2); word-break: break-all; letter-spacing: 1.5px; }
.charset.off .chars, .charset.off .name { opacity: .45; }
.charset .minbox { display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text-3); grid-row: 1 / 3; grid-column: 3; }
.charset .minbox input { width: 62px; padding: 5px 8px; }
.sym-grid { grid-column: 1 / -1; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.sym { display: inline-flex; align-items: center; gap: 5px; padding: 3px 8px 3px 6px; border: 1px solid var(--line-2); border-radius: 7px; background: #0e0e11; font: 15px var(--mono); }
.sym.on { border-color: rgba(245, 196, 81, .55); color: var(--c-sym); }
.sym.blocked { opacity: .3; text-decoration: line-through; }
.sym input { width: 15px; height: 15px; }
.comp { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 8px; }
.comp-item { display: flex; gap: 8px; align-items: flex-start; background: var(--card-2); border-radius: var(--radius); padding: 8px 10px; }
.comp-item .cnt { font-weight: 700; } .comp-item .used { font: 12px var(--mono); color: var(--text-3); word-break: break-all; }
.rules { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.rules li { display: flex; gap: 8px; align-items: flex-start; font-size: 14px; }
.rules li .ic { width: 18px; height: 18px; margin-top: 2px; }
.rules li.ok .ic { color: var(--ok); } .rules li.no { color: var(--danger); }

/* ---------- ตัวเลือกแพลตฟอร์ม (ค้นหาได้) ---------- */
.combo { position: relative; }
.combo-input { display: flex; align-items: center; gap: 8px; background: #0e0e11; border: 1px solid var(--line-2); border-radius: var(--radius); padding: 0 10px; }
.combo-input:focus-within { border-color: var(--brand-2); }
.combo-input input { border: 0; background: transparent; padding: 10px 0; }
.combo-input input:focus { border: 0; }
.combo-list { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 30; background: #141418; border: 1px solid var(--line-2); border-radius: var(--radius); max-height: 360px; overflow: auto; box-shadow: 0 12px 30px rgba(0, 0, 0, .55); padding: 4px; }
.combo-group { font-size: 12px; color: var(--text-3); padding: 8px 10px 4px; position: sticky; top: -4px; background: #141418; }
.combo-opt { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 7px; cursor: pointer; }
.combo-opt.active, .combo-opt:hover { background: var(--brand-soft); }
.combo-opt .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.combo-empty { padding: 14px; color: var(--text-3); text-align: center; }
.dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.dot.official { background: var(--ok); } .dot.secondary { background: var(--warn); } .dot.unverified { background: var(--text-3); }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.quick button { padding: 4px 11px; border-radius: 999px; border: 1px solid var(--line-2); background: transparent; cursor: pointer; font-size: 13px; color: var(--text-2); }
.quick button:hover, .quick button.on { border-color: var(--brand-2); color: #fff; background: var(--brand-soft); }

/* ---------- รายการ ---------- */
.list { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; max-height: calc(7 * 60px); resize: vertical; min-height: 120px; }
.list.tall { max-height: calc(9 * 64px); }
.li { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--line); min-height: 60px; }
.li:last-child { border-bottom: 0; }
.li:hover { background: #18181d; }
.li .main-col { flex: 1; min-width: 0; }
.li .t1 { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .t2 { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.li .pw { font: 14px var(--mono); }
.li .acts { display: flex; gap: 4px; flex: none; }
.avatar { width: 36px; height: 36px; border-radius: 9px; display: grid; place-items: center; background: var(--card-2); border: 1px solid var(--line-2); font-weight: 700; color: var(--brand-2); flex: none; }
.empty { text-align: center; color: var(--text-3); padding: 34px 10px; }
.empty .ic { width: 40px; height: 40px; color: var(--line-2); }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar .grow { flex: 1; min-width: 200px; }
.plat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.plat-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.plat-card .hd { display: flex; gap: 10px; align-items: center; }
.plat-card .hd .nm { font-weight: 600; flex: 1; min-width: 0; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; }
.src { font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.src a { word-break: break-word; }
.banner { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--card-2); font-size: 14px; }
.banner .ic { margin-top: 2px; }
.banner.warn { border-color: rgba(245, 165, 36, .45); background: var(--warn-bg); } .banner.warn .ic { color: var(--warn); }
.banner.bad { border-color: rgba(255, 77, 79, .45); background: var(--danger-bg); } .banner.bad .ic { color: var(--danger); }
.banner.ok { border-color: rgba(47, 191, 113, .45); background: var(--ok-bg); } .banner.ok .ic { color: var(--ok); }
.banner.info .ic { color: var(--info); }
.codes { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; font: 15px var(--mono); }
.codes span { background: #0e0e11; border: 1px solid var(--line-2); border-radius: 7px; padding: 5px 9px; text-align: center; }
.mono { font-family: var(--mono); word-break: break-all; }
.excerpt { font: 12.5px/1.5 var(--mono); background: #0e0e11; border: 1px solid var(--line); border-radius: 8px; padding: 8px; white-space: pre-wrap; max-height: 160px; overflow: auto; }
.excerpt.old { border-color: rgba(255, 77, 79, .3); } .excerpt.new { border-color: rgba(47, 191, 113, .3); }

/* ---------- หน้าต่างลอย / แจ้งเตือน / รอโหลด ---------- */
.overlay { position: fixed; inset: 0; background: rgba(0, 0, 0, .68); display: grid; place-items: center; z-index: 60; padding: 16px; backdrop-filter: blur(3px); }
.modal { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); width: min(560px, 100%); max-height: calc(100vh - 32px); overflow: auto; padding: 20px; box-shadow: 0 20px 60px rgba(0, 0, 0, .6); }
.modal.wide { width: min(780px, 100%); }
.modal h3 { margin: 0 0 10px; font-size: 18px; display: flex; gap: 10px; align-items: center; }
.modal h3 .ic { color: var(--brand-2); width: 24px; height: 24px; }
.modal.danger-modal h3 .ic { color: var(--danger); }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; flex-wrap: wrap; }
.loader { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, .55); display: grid; place-items: center; }
.loader-box { background: var(--card); border: 1px solid var(--line-2); border-radius: var(--radius-lg); padding: 22px 28px; display: grid; place-items: center; gap: 10px; min-width: 240px; text-align: center; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--brand-2); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 90; max-width: min(380px, calc(100vw - 32px)); }
@media (max-width: 860px) { .toasts { bottom: 84px; left: 16px; right: 16px; max-width: none; } }
.toast { display: flex; gap: 10px; align-items: flex-start; background: #1a1a1f; border: 1px solid var(--line-2); border-left: 4px solid var(--info); border-radius: var(--radius); padding: 10px 14px; box-shadow: 0 10px 30px rgba(0, 0, 0, .5); animation: tin .2s ease-out; font-size: 14px; }
.toast.ok { border-left-color: var(--ok); } .toast.bad { border-left-color: var(--danger); } .toast.warn { border-left-color: var(--warn); }
.toast.ok .ic { color: var(--ok); } .toast.bad .ic { color: var(--danger); } .toast.warn .ic { color: var(--warn); }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }
.pulse { animation: pulse .5s ease-out; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(224, 30, 43, .55); } 100% { box-shadow: 0 0 0 14px rgba(224, 30, 43, 0); } }
.noscript { padding: 30px; text-align: center; }
.lock-screen { max-width: 440px; margin: 30px auto; text-align: center; }
.lock-screen .big-ic { width: 64px; height: 64px; border-radius: 18px; margin: 0 auto 10px; display: grid; place-items: center; background: var(--brand-soft); color: var(--brand-2); }
.lock-screen .big-ic .ic { width: 34px; height: 34px; }
.auth-card { max-width: 460px; margin: 10px auto; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; }
.tabs button { background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 9px 14px; cursor: pointer; color: var(--text-2); font-weight: 600; }
.tabs button.on { color: #fff; border-bottom-color: var(--brand-2); }
.kbd { font: 11.5px var(--mono); padding: 1px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; color: var(--text-2); }
.bulk { font: 14px var(--mono); }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
