/* SuperWow Phase 1 — ตาม mockup v2 ที่ CEO อนุมัติ: แถบข้างน้ำเงินเข้ม + ทองอำพัน */
:root {
  --bg: #F3F4F6;
  --surface: #FFFFFF;
  --surface-2: #EAECEF;
  --ink: #141C26;
  --muted: #5A6472;
  --line: #DFE3E8;
  --side-bg: #131C2B;
  --side-ink: #E7ECF4;
  --side-muted: #8B96A8;
  --side-line: #243146;
  --side-active: #1D2A3F;
  --accent: #F59E0B;
  --accent-ink: #241300;
  --accent-deep: #8A5300;
  --accent-soft: #FCF1DC;
  --ok: #22A05C;
  --ok-soft: #E4F5EB;
  --danger: #D64545;
  --user-bubble: #16233A;
  --user-bubble-ink: #EDF1F7;
  --shadow: 0 10px 32px rgba(10, 16, 25, 0.12);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0E131B; --surface: #161D28; --surface-2: #1E2733;
    --ink: #E8EDF4; --muted: #939EAD; --line: #28323F;
    --side-bg: #0A0F16; --side-ink: #E7ECF4; --side-muted: #7E8A9C;
    --side-line: #1C2634; --side-active: #182335;
    --accent: #F6AD2B; --accent-ink: #241300; --accent-deep: #FFC964; --accent-soft: #2C2210;
    --ok: #3FBF72; --ok-soft: #14301F; --danger: #E06A6A;
    --user-bubble: #24354F; --user-bubble-ink: #E8EDF4;
    --shadow: 0 10px 32px rgba(0, 0, 0, 0.5);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Sukhumvit Set", "Thonburi", "Segoe UI", "Leelawadee UI", sans-serif;
  line-height: 1.6;
}
button { font: inherit; cursor: pointer; border: none; background: none; color: inherit; }
textarea, input { font: inherit; color: inherit; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; }

#app { display: flex; height: 100dvh; overflow: hidden; }

/* ---------- Sidebar ---------- */
#sidebar {
  width: 264px; flex: none; background: var(--side-bg); color: var(--side-ink);
  display: flex; flex-direction: column; gap: 12px; padding: 16px 14px;
  z-index: 30;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }
.brand .mark {
  width: 30px; height: 30px; border-radius: 9px; flex: none;
  background: linear-gradient(135deg, var(--accent), #FBBF24);
  color: var(--accent-ink); display: grid; place-items: center; font-size: 16px;
}
.brand.big { font-size: 22px; justify-content: center; }
.new-chat {
  background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 14px;
  border-radius: 10px; padding: 10px; text-align: center;
}
.new-chat:hover { filter: brightness(1.06); }
.search {
  background: var(--side-active); border: 1px solid var(--side-line); color: var(--side-ink);
  border-radius: 9px; padding: 8px 12px; font-size: 13.5px; outline: none; width: 100%;
}
.search::placeholder { color: var(--side-muted); }
.side-group { display: flex; flex-direction: column; gap: 2px; min-height: 0; }
.side-group.grow { flex: 1; overflow-y: auto; }
.side-label {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--side-muted); margin: 6px 0 4px;
}
.chat-item {
  padding: 8px 10px; border-radius: 9px; font-size: 13.5px; cursor: pointer;
  display: flex; flex-direction: column; gap: 1px; position: relative;
}
.chat-item:hover { background: var(--side-active); }
.chat-item.active { background: var(--side-active); outline: 1px solid var(--side-line); }
.chat-item .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding-right: 60px; }
.chat-item .d { font-size: 11.5px; color: var(--side-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .acts {
  position: absolute; right: 6px; top: 7px; display: none; gap: 2px;
}
.chat-item:hover .acts { display: flex; }
.chat-item .acts button {
  font-size: 12px; padding: 2px 4px; border-radius: 6px; opacity: 0.85;
}
.chat-item .acts button:hover { background: var(--side-line); opacity: 1; }
.side-bottom { border-top: 1px solid var(--side-line); padding-top: 12px; display: flex; flex-direction: column; gap: 8px; }
.side-row { display: flex; align-items: center; gap: 9px; font-size: 13px; color: var(--side-muted); }
.side-row.btns { justify-content: space-between; }
.side-btn { font-size: 13px; color: var(--side-muted); padding: 4px 6px; border-radius: 7px; }
.side-btn:hover { color: var(--side-ink); background: var(--side-active); }
.ok-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.icon-btn { font-size: 16px; padding: 4px 8px; border-radius: 8px; color: inherit; }
.icon-btn:hover { background: var(--side-active); }

/* ---------- Main ---------- */
#main { flex: 1; display: flex; flex-direction: column; min-width: 0; position: relative; background: var(--surface); }
.topbar {
  display: flex; align-items: center; gap: 12px; padding: 12px 20px;
  border-bottom: 1px solid var(--line); flex: none;
}
.topbar .title { font-weight: 700; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.topbar .icon-btn:hover { background: var(--surface-2); }
.chips { display: flex; align-items: center; gap: 8px; flex: none; }
.chip {
  display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600;
  border: 1px solid var(--line); border-radius: 999px; padding: 5px 12px; background: var(--surface);
}
.chip.model { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-deep); cursor: pointer; }
.chip.model:hover { filter: brightness(1.03); }
.chip.mem { color: var(--ok); border-color: var(--ok); background: var(--ok-soft); }
.pdot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }

/* ---------- Model dropdown ---------- */
.dropdown {
  position: absolute; top: 54px; right: 20px; width: min(330px, calc(100vw - 40px)); z-index: 40;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); overflow: hidden; max-height: 70vh; overflow-y: auto;
}
.dd-head {
  padding: 10px 16px; font-size: 11.5px; font-weight: 700; color: var(--muted);
  border-bottom: 1px solid var(--line); letter-spacing: 0.06em; text-transform: uppercase;
}
.dd-group { padding: 6px 8px; border-bottom: 1px solid var(--line); }
.dd-provider { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 700; color: var(--muted); padding: 6px 8px; }
.dd-provider .off { margin-left: auto; font-size: 10.5px; font-weight: 700; color: var(--muted); background: var(--surface-2); border-radius: 5px; padding: 1px 7px; }
.dd-model {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 8px;
  font-size: 13.5px; width: 100%; text-align: left;
}
.dd-model:not(:disabled):hover { background: var(--surface-2); }
.dd-model:disabled { opacity: 0.45; cursor: not-allowed; }
.dd-model.current { background: var(--accent-soft); }
.dd-model .name { font-weight: 600; }
.dd-model .tag { font-size: 10.5px; font-weight: 700; border-radius: 5px; padding: 1px 7px; margin-left: auto; background: var(--surface-2); color: var(--muted); flex: none; }
.dd-model .tag.hot { background: var(--accent-soft); color: var(--accent-deep); }
.dd-model .check { color: var(--accent-deep); font-weight: 800; }
.dd-foot { padding: 10px 16px; font-size: 11.5px; color: var(--muted); background: var(--surface-2); }
.dd-foot b { color: var(--ok); }

/* ---------- Thread ---------- */
.thread {
  flex: 1; overflow-y: auto; background: var(--bg);
  padding: 24px max(22px, calc((100% - 860px) / 2));
  display: flex; flex-direction: column; gap: 6px;
}
.empty { margin: auto; text-align: center; color: var(--muted); }
.empty-mark {
  width: 68px; height: 68px; margin: 0 auto 14px; border-radius: 20px;
  background: linear-gradient(135deg, var(--accent), #FBBF24);
  display: grid; place-items: center; font-size: 34px; color: var(--accent-ink);
  box-shadow: 0 10px 30px rgba(245, 158, 11, 0.3);
}
.empty h2 { margin: 8px 0 4px; color: var(--ink); }
.empty p { margin: 0; font-size: 14px; }
.suggests { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-top: 18px; }
.suggest {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  border-radius: 999px; padding: 8px 15px; font-size: 13px;
}
.suggest:hover { border-color: var(--accent); color: var(--accent-deep); background: var(--accent-soft); }

.msg { max-width: 76%; padding: 10px 14px; border-radius: 14px; font-size: 14px; line-height: 1.65; margin: 4px 0; overflow-wrap: break-word; }
.msg .who { font-size: 11px; font-weight: 700; color: var(--muted); margin-bottom: 3px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.msg.user { align-self: flex-end; background: var(--user-bubble); color: var(--user-bubble-ink); border-bottom-right-radius: 4px; white-space: pre-wrap; }
.msg.ai { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.ai pre {
  background: var(--side-bg); color: var(--side-ink); border-radius: 8px; padding: 10px 12px;
  overflow-x: auto; font-size: 12.5px; font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.msg.ai code { background: var(--surface); border: 1px solid var(--line); border-radius: 5px; padding: 0 5px; font-size: 12.5px; font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.msg.ai .li { padding-left: 6px; }
.msg.err { align-self: center; background: none; border: 1px dashed var(--danger); color: var(--danger); font-size: 13px; border-radius: 10px; max-width: 90%; }
.msg-actions { display: flex; gap: 6px; margin: -2px 0 6px 4px; align-self: flex-start; }
.mini-btn {
  font-size: 11.5px; font-weight: 600; color: var(--muted); border: 1px solid var(--line);
  background: var(--surface); border-radius: 7px; padding: 3px 9px;
}
.mini-btn:hover { background: var(--surface-2); color: var(--ink); }

.switch-divider { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.switch-divider .rule { flex: 1; height: 1px; background: var(--line); }
.switch-divider .tag {
  font-size: 12px; font-weight: 700; color: var(--accent-deep); background: var(--accent-soft);
  border: 1px dashed var(--accent); border-radius: 999px; padding: 4px 12px;
  max-width: 78%; text-align: center;
}

.tool-chip {
  align-self: flex-start; display: inline-flex; gap: 9px; align-items: center;
  font-size: 12.5px; font-weight: 600; color: var(--ink);
  background: var(--surface); border: 1px solid #3B82F6;
  border-radius: 12px; padding: 7px 14px; margin: 2px 0;
}
.tool-chip .mdot { width: 10px; height: 10px; border-radius: 3px; background: #3B82F6; flex: none; }

.caret { display: inline-block; width: 8px; height: 15px; background: var(--accent); vertical-align: text-bottom; animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .caret { animation: none; } }
.status-line { align-self: flex-start; font-size: 12px; color: var(--muted); padding: 2px 6px; }
/* P13.2: แถบสถานะสดในแชทหลัก (ฟีดแบ็ก CEO: ยิง API แล้วจอเงียบ) — spinner + วินาทีเดินต่อกิจกรรม */
.status-line.live { display: flex; align-items: center; gap: 8px; padding: 4px 6px; }
.status-line .spin { width: 12px; height: 12px; border: 2px solid var(--line); border-top-color: var(--accent);
  border-radius: 50%; animation: tbspin .8s linear infinite; flex: none; }
@media (prefers-reduced-motion: reduce) { .status-line .spin { animation: none; } }

/* ---------- Composer ---------- */
.composer {
  flex: none; border-top: 1px solid var(--line);
  padding: 12px max(20px, calc((100% - 900px) / 2)) calc(12px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 6px; background: var(--surface);
}
.composer .box {
  display: flex; align-items: flex-end; gap: 10px; border: 1.5px solid var(--line);
  border-radius: 14px; padding: 9px 12px; background: var(--surface);
}
.composer .box:focus-within { border-color: var(--accent); }
.attach-btn { color: var(--muted); font-size: 16px; padding: 2px 7px 5px; border-radius: 8px; flex: none; }
.attach-btn:hover { background: var(--surface-2); color: var(--accent-deep); }

/* ---------- Phase 2: ไฟล์แนบ ---------- */
.tray { display: flex; gap: 8px; flex-wrap: wrap; }
.pend {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  background: var(--surface-2); border-radius: 10px; padding: 6px 9px; font-size: 12px; max-width: 240px;
}
.pend img { width: 34px; height: 34px; object-fit: cover; border-radius: 6px; }
.pend .pi { width: 34px; height: 34px; border-radius: 6px; background: var(--accent-soft); display: grid; place-items: center; font-size: 16px; flex: none; }
.pend .pn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pend .px { color: var(--muted); font-size: 13px; padding: 2px 5px; border-radius: 6px; flex: none; }
.pend .px:hover { color: var(--danger); background: var(--surface); }
.pend.up { opacity: 0.55; }

.attach-menu {
  position: absolute; bottom: 92px; left: max(20px, calc((100% - 900px) / 2)); width: 260px;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  box-shadow: var(--shadow); overflow: hidden; z-index: 50;
}
.attach-menu .am-head { font-size: 11px; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); padding: 9px 14px; border-bottom: 1px solid var(--line); }
.attach-menu .am-item { display: flex; gap: 10px; align-items: center; padding: 9px 14px; font-size: 13.5px; width: 100%; text-align: left; }
.attach-menu .am-item:hover { background: var(--surface-2); }
.attach-menu .am-item small { display: block; color: var(--muted); font-size: 11px; font-weight: 400; }

.msg-img {
  max-width: 280px; max-height: 220px; border-radius: 10px; display: block;
  margin: 2px 0 6px; cursor: zoom-in; border: 1px solid rgba(127, 127, 127, 0.3);
}
.fcard {
  display: flex; align-items: center; gap: 10px; background: rgba(127, 127, 127, 0.12);
  border: 1px solid rgba(127, 127, 127, 0.28); border-radius: 10px; padding: 8px 12px;
  margin: 2px 0 6px; min-width: 200px; max-width: 300px; text-decoration: none; color: inherit;
}
.fcard:hover { border-color: var(--accent); }
.fcard .fic { width: 34px; height: 34px; border-radius: 8px; background: var(--accent-soft); display: grid; place-items: center; font-size: 16px; flex: none; }
.fcard .fn { font-weight: 700; font-size: 12.5px; word-break: break-all; }
.fcard .fd { font-size: 11px; opacity: 0.75; }

.drop-overlay { position: fixed; inset: 0; z-index: 200; background: rgba(10, 15, 22, 0.6); display: grid; place-items: center; }
.drop-overlay > div {
  border: 2px dashed var(--accent); border-radius: 20px; background: var(--accent-soft);
  color: var(--accent-deep); font-weight: 800; font-size: 18px; padding: 40px 60px; text-align: center; line-height: 1.8;
}
.drop-overlay small { font-weight: 500; font-size: 13px; }

.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(5, 8, 12, 0.88); display: grid; place-items: center; cursor: zoom-out; padding: 20px; }
.lightbox img { max-width: 95vw; max-height: 92vh; border-radius: 10px; }
.composer textarea {
  flex: 1; border: none; outline: none; background: none; resize: none;
  font-size: 14px; line-height: 1.5; max-height: 160px; padding: 3px 0;
}
.composer .send {
  background: var(--accent); color: var(--accent-ink); font-weight: 800; border-radius: 10px;
  width: 38px; height: 34px; font-size: 15px; flex: none;
}
.composer .send:disabled { opacity: 0.5; cursor: not-allowed; }
.composer .hint { font-size: 11.5px; color: var(--muted); }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed; inset: 0; background: rgba(10, 15, 22, 0.55); z-index: 100;
  display: grid; place-items: center; padding: 20px;
}
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 16px;
  box-shadow: var(--shadow); padding: 24px; width: min(360px, 100%);
  display: flex; flex-direction: column; gap: 12px;
}
.card.wide { width: min(560px, 100%); max-height: 86vh; overflow-y: auto; }
.card h2 { margin: 0; font-size: 18px; }
.card h3 { margin: 8px 0 0; font-size: 14px; }
.card-head { display: flex; align-items: center; justify-content: space-between; }
.card-head .icon-btn:hover { background: var(--surface-2); }
.card input[type="password"], .card textarea {
  border: 1.5px solid var(--line); border-radius: 10px; padding: 9px 12px;
  background: var(--surface); outline: none; width: 100%;
}
.card input:focus, .card textarea:focus { border-color: var(--accent); }
/* P11.1: การ์ดตั้งค่าเป็น flex เลื่อนได้ — ห้ามบีบช่องความจำจนแบนอ่านไม่ออก (บั๊กที่ CEO เจอ 15 ก.ค.) */
.card textarea { flex-shrink: 0; min-height: 130px; resize: vertical; }
.primary {
  background: var(--accent); color: var(--accent-ink); font-weight: 800;
  border-radius: 10px; padding: 9px 16px;
}
.err { color: var(--danger); font-size: 13px; margin: 0; min-height: 1em; }
.muted { color: var(--muted); font-size: 13px; margin: 0; }
.note { font-size: 12.5px; color: var(--ok); background: var(--ok-soft); border: 1px solid var(--ok); border-radius: 10px; padding: 8px 12px; margin: 0; }
.note code { font-family: ui-monospace, Menlo, monospace; }
.row { display: flex; align-items: center; gap: 10px; }

.pv-row {
  display: flex; align-items: center; gap: 10px; border: 1px solid var(--line);
  border-radius: 12px; padding: 10px 14px; font-size: 13.5px; margin-bottom: 8px; flex-wrap: wrap;
}
.pv-row .nm { font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 130px; }
.pv-row .st { font-size: 11.5px; font-weight: 700; border-radius: 999px; padding: 3px 10px; }
.st.on { color: var(--ok); background: var(--ok-soft); border: 1px solid var(--ok); }
.st.off { color: var(--muted); background: var(--surface-2); border: 1px solid var(--line); }
.pv-row .use { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }

.backdrop { position: fixed; inset: 0; background: rgba(10, 15, 22, 0.45); z-index: 25; }
.mobile-only { display: none; }
.brand .mobile-only { margin-left: auto; }

/* ---------- Mobile ---------- */
@media (max-width: 760px) {
  .mobile-only { display: inline-flex; }
  #sidebar {
    position: fixed; inset: 0 auto 0 0; height: 100dvh; width: min(300px, 85vw);
    transform: translateX(-102%); transition: transform 0.22s ease;
    box-shadow: var(--shadow);
  }
  #sidebar.open { transform: translateX(0); }
  .msg { max-width: 88%; }
  .thread { padding: 14px; }
  .topbar { padding: 10px 12px; }
  .composer { padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); }
  .chip.mem { display: none; }
  .dropdown { right: 10px; }
}

/* ---------- P7a: โฟลเดอร์จัดแชท ---------- */
.folders-head { display: flex; align-items: center; justify-content: space-between; }
.folder-add { background: none; border: none; color: var(--accent); font-size: 12px; font-weight: 700; cursor: pointer; padding: 2px 4px; }
.folder-add:hover { text-decoration: underline; }
.folder-group { border: 1px solid var(--side-line); border-radius: 10px; margin: 0 0 8px; overflow: hidden; }
.folder-hd { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--side-active); color: var(--side-ink); font-size: 13px; font-weight: 600; cursor: pointer; }
.folder-hd .car { color: var(--side-muted); font-size: 11px; width: 12px; }
.folder-hd .fn { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.folder-hd .cnt { color: var(--side-muted); font-weight: 400; font-size: 12px; }
.folder-hd .facts { margin-left: auto; display: none; gap: 2px; }
.folder-hd:hover .facts { display: flex; }
.folder-hd .facts button { background: none; border: none; cursor: pointer; font-size: 13px; padding: 1px 4px; border-radius: 5px; }
.folder-hd .facts button:hover { background: var(--side-line); }
.folder-group .chat-item { padding-left: 22px; }
.move-menu { position: fixed; z-index: 300; width: 200px; background: var(--side-bg); border: 1px solid var(--side-line); border-radius: 10px; padding: 5px; box-shadow: 0 14px 40px rgba(0,0,0,.45); display: flex; flex-direction: column; }
.move-menu button { background: none; border: none; color: var(--side-ink); text-align: left; padding: 7px 9px; border-radius: 7px; cursor: pointer; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.move-menu button:hover { background: var(--side-active); }
.mm-hint { color: var(--side-muted); font-size: 11.5px; padding: 5px 9px 2px; }
.boost-row { display: flex; gap: 9px; align-items: flex-start; font-size: 13px; color: var(--muted); margin-top: 12px; cursor: pointer; line-height: 1.5; }
.boost-row input { margin-top: 3px; accent-color: var(--accent); }

/* ---------- เฟสเสริม Backup: การ์ดใน ⚙️ + แถบเตือนแดงทุกหน้า ---------- */
.backup-warn { position: sticky; top: 0; z-index: 2000; background: var(--danger); color: #fff; text-align: center; padding: 8px 14px; font-size: 13.5px; font-weight: 600; line-height: 1.45; }
.backup-card { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; margin-top: 8px; display: flex; flex-direction: column; gap: 10px; font-size: 13.5px; }
.bk-row { display: flex; align-items: flex-start; gap: 10px; }
.bk-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--muted); flex: none; margin-top: 4px; }
.bk-dot.ok { background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); }
.bk-dot.bad { background: var(--danger); }
.bk-status { flex: 1; line-height: 1.5; }
.bk-err { color: var(--danger); font-size: 12.5px; }
.bk-btn { flex: none; white-space: nowrap; }
.bk-info { color: var(--muted); font-size: 12.5px; line-height: 1.6; }
.bk-info code { background: var(--surface-2); border-radius: 5px; padding: 1px 6px; font-size: 11.5px; }

/* ---------- P10 เวิร์กช็อป: การ์ดตั๋วยืนยันการรันของ AI ---------- */
.ws-ticket { max-width: 640px; margin: 10px auto; background: var(--surface); border: 1.5px solid var(--accent);
  border-radius: 14px; padding: 14px 18px; box-shadow: var(--shadow); }
.wst-head { font-weight: 800; color: var(--accent-deep); margin-bottom: 8px; }
.wst-cmd { background: #0d1420; color: #fcd34d; padding: 10px 14px; border-radius: 10px; margin: 0 0 6px;
  font: 12.5px/1.6 ui-monospace, "SF Mono", Menlo, monospace; overflow-x: auto; white-space: pre-wrap; word-break: break-word; }
.wst-reason { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.wst-btns { display: flex; gap: 10px; }
.wst-yes { background: var(--accent); color: var(--accent-ink); border: none; border-radius: 10px;
  padding: 8px 18px; font-weight: 700; font-size: 14px; cursor: pointer; }
.wst-yes:disabled { opacity: .7; cursor: wait; }
.wst-no { background: var(--surface-2); color: var(--ink); border: 1px solid var(--line); border-radius: 10px;
  padding: 8px 16px; font-size: 14px; cursor: pointer; }
@media (prefers-color-scheme: dark) { .wst-head { color: var(--accent); } }

/* P10.5: แถบสถานะชุดงาน */
.job-bar { background: #241d0b; border-bottom: 1.5px solid var(--accent); color: #fcd34d;
  font-size: 13px; padding: 7px 14px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.job-bar b { max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.job-stop { margin-left: auto; background: #7f1d1d; color: #fecaca; border: 1px solid #b91c1c;
  border-radius: 8px; padding: 3px 12px; font-weight: 700; font-size: 12.5px; cursor: pointer; white-space: nowrap; }

/* ---------- P15: เซิร์ฟเวอร์ (SSH) ---------- */
.srv-keytabs { display: flex; gap: 8px; margin-bottom: 8px; flex-wrap: wrap; }
.srv-keytabs .iconbtn { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; cursor: pointer; }
.srv-keytabs .iconbtn:hover { border-color: var(--accent); }
.kt-gen-box { display: flex; flex-direction: column; gap: 8px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; }
.howto-sm { font-size: 12.5px; color: var(--muted); line-height: 1.6; }
.howto-sm code { background: var(--surface); padding: 1px 5px; border-radius: 4px; }
.kt-pub { font-size: 11.5px !important; word-break: break-all; }

/* ---------- P14: ตู้เซฟรหัสส่วนตัว ---------- */
.vault-gate { background: var(--surface-2); border: 1px dashed var(--accent); border-radius: 12px;
  padding: 16px 18px; font-size: 14px; line-height: 1.6; }
.vault-gate code { background: var(--surface); padding: 1px 6px; border-radius: 5px; font-size: 12.5px; }
.vault-add { margin-bottom: 8px; }
.vault-cat { font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
  margin: 16px 0 8px; }
.vault-cred { display: flex; align-items: center; gap: 12px; background: var(--surface-2);
  border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; margin-bottom: 8px; flex-wrap: wrap; }
.vc-info { flex: 1; min-width: 150px; }
.vc-nm { font-weight: 700; }
.vc-un { font-size: 12.5px; color: var(--muted); word-break: break-all; }
.vc-acts { display: flex; gap: 6px; flex-wrap: wrap; }
.vault-cred .iconbtn { background: var(--surface); border: 1px solid var(--line); color: var(--ink);
  border-radius: 8px; padding: 5px 10px; font-size: 13px; cursor: pointer; white-space: nowrap; }
.vault-cred .iconbtn:hover { border-color: var(--accent); }
.vault-cred .iconbtn.danger:hover { border-color: #EF4444; }
.vc-reveal { flex-basis: 100%; display: flex; gap: 8px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.vc-reveal .fld { flex: 1; min-width: 180px; }
.vc-msg { font-size: 12.5px; color: var(--muted); }
.vc-shown { flex-basis: 100%; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.vc-secret { font-family: ui-monospace, Menlo, monospace; background: var(--surface); border: 1px solid var(--accent);
  border-radius: 8px; padding: 6px 12px; user-select: all; word-break: break-all; }

.vault-form-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex;
  align-items: center; justify-content: center; padding: 16px; z-index: 60; }
.vault-form { max-width: 420px; width: 100%; }
.vault-form .mt { font-weight: 800; font-size: 1.05rem; }
.vault-form .sub { font-size: 12.5px; color: var(--muted); margin: 4px 0 8px; }
.vault-form label { display: block; font-size: 12.5px; color: var(--muted); margin: 10px 0 4px; }
.vault-form .fld { width: 100%; box-sizing: border-box; background: var(--surface-2); border: 1px solid var(--line);
  border-radius: 9px; padding: 9px 12px; color: var(--ink); font-size: 14.5px; font-family: inherit; }
.vault-form .row2 { display: flex; gap: 10px; }
.vault-form .row2 > div { flex: 1; }
.vault-form .mbtns { display: flex; gap: 10px; margin-top: 16px; }
.vault-form .ghost { background: var(--surface-2); border: 1px solid var(--line); color: var(--ink);
  border-radius: 10px; padding: 9px 18px; cursor: pointer; font-family: inherit; }
.vf-msg { font-size: 12.5px; margin-top: 8px; min-height: 1em; }

/* ---------- P13: ทีมงานย่อย — แถบสถานะสด + การ์ดรายงานทีม ---------- */
.team-bar { background: #241d0b; border-bottom: 1.5px solid var(--accent); color: #fcd34d;
  font-size: 13px; padding: 7px 14px; display: flex; flex-direction: column; gap: 4px; }
.team-bar .tb-head { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.team-bar .tb-head span:first-child { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-bar .tb-member { display: flex; align-items: center; gap: 7px; font-size: 12.5px; opacity: .72; }
.team-bar .tb-member.working { opacity: 1; }
.tb-spin { width: 11px; height: 11px; border: 2px solid #fcd34d; border-top-color: transparent;
  border-radius: 50%; animation: tbspin 1s linear infinite; flex: none; }
@keyframes tbspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tb-spin { animation: none; } }

.team-card { align-self: stretch; max-width: 640px; margin: 10px auto; width: 100%; box-sizing: border-box;
  background: var(--surface); border: 1.5px solid var(--accent); border-radius: 14px;
  padding: 14px 18px; box-shadow: var(--shadow); }
.tc-head { font-weight: 800; color: var(--accent-deep); margin-bottom: 6px; }
@media (prefers-color-scheme: dark) { .tc-head { color: var(--accent); } }
.tc-task { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.tc-leader { border: 1px dashed var(--accent); border-radius: 10px; padding: 8px 12px;
  margin-bottom: 6px; font-size: 13px; font-weight: 600; background: var(--surface-2); }
.tc-member { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px;
  margin-bottom: 6px; background: var(--surface-2); }
.tc-member summary { cursor: pointer; font-size: 13px; font-weight: 600; }
.tc-report { margin-top: 8px; font-size: 13px; border-left: 3px solid var(--accent); padding-left: 10px; }

/* P11.1: ส่วน "สมองและความจำ" ใน ⚙️ ตั้งค่า (ย้ายจากหัวจอ — ความลับของเจ้าของ) */
.brain-row { display: flex; flex-direction: column; gap: 7px; font-size: 13.5px;
  background: var(--surface-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; }
.brain-row .br-line { display: flex; align-items: center; gap: 7px; }
.brain-row .br-ok { color: var(--ok); }
.dbtn-like { align-self: flex-start; font-size: 13px; font-weight: 700; padding: 7px 14px; border-radius: 9px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; }
.dbtn-like:hover { border-color: var(--accent); }
