:root {
  --bg: #0d111b;
  --surface: #151b29;
  --surface-2: #1d2536;
  --ink: #e8ecf4;
  --muted: #93a0b8;
  --line: #2a3448;
  --accent: #2dd4bf;
  --accent-ink: #06231f;
  --danger: #f87171;
  --warn: #f5b942;
  --ok: #5fd08a;
  --shadow: 0 10px 34px rgba(0, 0, 0, .45);
  --t-gmail: #f0685b;
  --t-calendar: #5b8ff5;
  --t-gpt: #2bbf99;
  --t-claude: #e08a66;
  --t-gemini: #a78bfa;
  --t-manager: #e08a66;
  --t-director: #7f95c9;
  --t-pet: #f5b942;
  --t-reception: #2dd4bf;
  --t-guest: #cbd5e1;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
h3, h4, h5, p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
.muted { color: var(--muted); }
.error { color: var(--danger); }
code {
  font: 12.5px/1.4 Consolas, "Cascadia Mono", monospace;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 1px 6px;
  user-select: all;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Thanh trên ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand strong { display: block; font-size: 15px; }
.brand-mark {
  width: 30px; height: 30px; border-radius: 8px;
  background:
    linear-gradient(var(--surface), var(--surface)) 7px 8px / 6px 6px no-repeat,
    linear-gradient(var(--surface), var(--surface)) 17px 8px / 6px 6px no-repeat,
    linear-gradient(var(--surface), var(--surface)) 7px 18px / 6px 6px no-repeat,
    linear-gradient(var(--surface), var(--surface)) 17px 18px / 6px 12px no-repeat,
    var(--warn);
}
.conn { font-size: 12px; color: var(--muted); }
.conn.is-live::before { content: "● "; color: var(--ok); }
.conn.is-down::before { content: "● "; color: var(--danger); }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.clock { font-variant-numeric: tabular-nums; color: var(--muted); margin-right: 4px; }

.btn {
  border: 1px solid var(--line);
  background: var(--surface-2);
  border-radius: 9px;
  padding: 7px 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, filter .15s, transform .05s;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.btn-ghost { border-color: transparent; background: transparent; padding: 4px 8px; }
.btn-small { padding: 3px 10px; font-size: 12.5px; }
.badge { background: var(--warn); color: #231a02; border-radius: 999px; font-size: 11px; font-weight: 700; padding: 0 6px; margin-left: 4px; }

/* ---------- Phòng làm việc ---------- */
.stage { flex: 1; min-height: 0; display: flex; }
.scene { position: relative; flex: 1; min-width: 0; overflow: hidden; background: var(--bg); }
.scene canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; cursor: grab; touch-action: none; }
.scene canvas:active { cursor: grabbing; }
.labels { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.scene-fail {
  position: absolute; inset: 0; display: grid; place-content: center; gap: 14px;
  text-align: center; color: var(--muted); padding: 24px; z-index: 2;
}
.scene-fail .quick { justify-content: center; }

.tag {
  position: absolute; left: 0; top: 0; will-change: transform;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 0; background: none; padding: 0 0 4px; cursor: pointer; pointer-events: auto;
}
.tag-name {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(13, 17, 27, .86); border: 1px solid var(--line);
  border-radius: 999px; padding: 2px 9px 2px 7px; font-size: 12px; white-space: nowrap;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .35);
}
.tag-name i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); }
.tag:hover .tag-name { border-color: var(--accent); }
.tag-bubble {
  max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  background: rgba(13, 17, 27, .92); border: 1px solid var(--accent); color: var(--ink);
  border-radius: 9px; padding: 3px 9px; font-size: 12px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .4);
}
.tag-bubble[hidden] { display: none; }
/* Nhãn bị nhãn quan trọng hơn đè lên: làm mờ, rê chuột vào thì rõ lại */
.tag.is-dim { opacity: .4; }
.tag.is-dim:hover { opacity: 1; z-index: 6; }
/* Lời nói: bong bóng sáng, xuống dòng được. Suy nghĩ / việc đang làm: nét đứt, chữ nghiêng. */
.tag-bubble.is-say {
  white-space: normal; max-width: 220px; text-align: center; line-height: 1.35;
  display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical;
  background: #f8fafc; color: #0f172a; border-color: #f8fafc; font-weight: 500;
}
/* Mờ dần, bay lên khi hết lượt hoặc bị bong bóng mới hơn đè */
.tag-bubble { transition: opacity .5s ease, transform .5s ease; }
.tag-bubble.is-gone { opacity: 0; transform: translateY(-18px); pointer-events: none; }
/* Suy nghĩ hiện đầy đủ, tự xuống dòng (người dùng không muốn bị cắt bằng "…") */
.tag-bubble.is-think {
  font-style: italic; border-style: dashed; border-color: #64748b; color: #cbd5e1;
  white-space: normal; text-overflow: clip; max-width: 240px; line-height: 1.35;
}
.tag-emote { font-size: 22px; line-height: 1; animation: pop .35s ease-out; filter: drop-shadow(0 2px 3px rgba(0, 0, 0, .5)); }
.tag-pet .tag-name { padding: 1px 8px; font-size: 11.5px; border-color: color-mix(in srgb, var(--t-pet) 55%, var(--line)); }
.tag-pet .tag-name i, .tag-hire .tag-name i { display: none; }
.tag-hire .tag-name { border-style: dashed; color: var(--muted); padding: 2px 10px; }
.tag-hire:hover .tag-name { color: var(--accent); }
@keyframes pop { from { transform: scale(.3) translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }

.toolbar {
  position: absolute; left: 14px; bottom: 14px;
  display: flex; align-items: center; gap: 2px;
  background: rgba(21, 27, 41, .92); border: 1px solid var(--line); border-radius: 12px; padding: 4px;
  box-shadow: var(--shadow);
}
.toolbar button { border: 0; background: none; border-radius: 8px; padding: 6px 11px; cursor: pointer; }
.toolbar button:hover { background: var(--surface-2); }
.toolbar span { min-width: 48px; text-align: center; font-variant-numeric: tabular-nums; color: var(--muted); }
.hint {
  position: absolute; left: 50%; top: 12px; transform: translateX(-50%); margin: 0;
  background: rgba(21, 27, 41, .82); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 14px; font-size: 12.5px; color: var(--muted); white-space: nowrap; pointer-events: none;
  max-width: calc(100% - 28px); overflow: hidden; text-overflow: ellipsis;
}

/* ---------- Bảng tin (góc dưới bên phải cảnh) ---------- */
.feed {
  position: absolute; right: 14px; bottom: 14px; z-index: 5;
  width: 340px; max-width: calc(100% - 28px);
  display: flex; flex-direction: column;
  background: rgba(21, 27, 41, .9); backdrop-filter: blur(8px);
  border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  overflow: hidden;
}
.feed[hidden] { display: none; }
.feed-head { display: flex; align-items: center; gap: 6px; padding: 5px 6px 5px 4px; }
.feed-title {
  display: inline-flex; align-items: center; gap: 7px; flex: 1; min-width: 0;
  border: 0; background: none; color: var(--ink); font: inherit; font-size: 13.5px; font-weight: 600;
  padding: 5px 8px; border-radius: 9px; cursor: pointer; text-align: left;
}
.feed-title:hover { background: var(--surface-2); }
.feed-icon { font-size: 14px; }
.feed-new {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink); font-size: 11px; font-weight: 700;
  display: inline-grid; place-items: center; font-variant-numeric: tabular-nums;
  animation: feed-pop .3s ease-out;
}
.feed-new[hidden] { display: none; }
.feed-caret {
  margin-left: auto; width: 7px; height: 7px; border: solid var(--muted); border-width: 0 1.6px 1.6px 0;
  transform: translateY(-2px) rotate(45deg); transition: transform .2s ease;
}
.feed.is-closed .feed-caret { transform: translateY(2px) rotate(-135deg); }
.feed-filter { display: flex; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 2px; }
.feed-filter button {
  border: 0; background: none; color: var(--muted); font: inherit; font-size: 11.5px;
  padding: 3px 8px; border-radius: 7px; cursor: pointer;
}
.feed-filter button[aria-pressed="true"] { background: var(--surface-2); color: var(--ink); }
.feed.is-closed .feed-filter { display: none; }

.feed-list {
  list-style: none; margin: 0; padding: 2px 6px 8px;
  max-height: min(290px, 38vh); overflow-y: auto; overscroll-behavior: contain;
  border-top: 1px solid var(--line);
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}
.feed.is-closed .feed-list, .feed.is-closed .feed-empty { display: none; }
.feed-empty { margin: 0; padding: 14px 12px 16px; font-size: 12.5px; color: var(--muted); text-align: center; border-top: 1px solid var(--line); }
.feed-list:not(:empty) + .feed-empty { display: none; }
.feed.only-work .feed-item.is-fun { display: none; }

.feed-item {
  position: relative; padding: 7px 8px 7px 14px; margin-top: 4px; border-radius: 9px;
  cursor: pointer; animation: feed-in .35s ease-out;
}
.feed-item:hover { background: var(--surface-2); }
.feed-item::before {
  content: ""; position: absolute; left: 4px; top: 9px; bottom: 9px; width: 3px; border-radius: 3px;
  background: var(--c);
}
.feed-meta { display: flex; align-items: baseline; gap: 8px; font-size: 12px; }
.feed-meta b { color: var(--c); font-weight: 600; }
.feed-meta time { margin-left: auto; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.feed-item p { margin: 2px 0 0; font-size: 13px; line-height: 1.4; color: var(--ink); overflow-wrap: anywhere; }
.feed-item:not(.is-say) p { color: #c3cbdb; font-style: italic; }
.feed-item:not(.is-say) p::before { content: "💭 "; font-style: normal; }
.feed-item.is-say p::before { content: "💬 "; }
.feed-item.is-idle { opacity: .78; }

.feed-form {
  display: flex; align-items: center; gap: 6px; padding: 8px;
  border-top: 1px solid var(--line); background: rgba(13, 17, 27, .35);
}
.feed.is-closed .feed-form { display: none; }
.feed-form select, .feed-form input {
  height: 32px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--bg); color: var(--ink); font: inherit; font-size: 12.5px;
}
.feed-form select { flex: none; max-width: 112px; padding: 0 6px; cursor: pointer; }
.feed-form input { flex: 1; min-width: 0; padding: 0 10px; }
.feed-form input:focus, .feed-form select:focus { border-color: var(--accent); outline: none; }
.feed-icon-btn {
  flex: none; width: 32px; height: 32px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface-2); color: var(--muted); font-size: 14px; cursor: pointer;
  display: grid; place-items: center;
}
.feed-icon-btn:hover { color: var(--ink); border-color: var(--accent); }
.feed-send { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.feed-send:hover { color: var(--accent-ink); filter: brightness(1.08); }

@keyframes feed-in { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: none; } }
@keyframes feed-pop { from { transform: scale(.6); } to { transform: scale(1); } }

/* ---------- Khung trò chuyện ---------- */
.panel {
  width: 390px; flex: none; display: flex; flex-direction: column; min-height: 0;
  background: var(--surface); border-left: 1px solid var(--line);
}
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 12px 12px 14px; border-bottom: 1px solid var(--line); }
.avatar {
  --c: var(--muted);
  width: 36px; height: 36px; flex: none; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 15px;
  color: #0d111b; background: var(--c);
}
.panel-title { flex: 1; min-width: 0; }
.panel-title strong { display: block; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-title span { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.panel-body { flex: 1; min-height: 0; overflow: auto; padding: 14px; display: flex; flex-direction: column; gap: 9px; }
.panel-extra { padding: 0 14px 10px; display: flex; flex-direction: column; gap: 8px; }
.panel-extra:empty { display: none; }
.msg { max-width: 90%; padding: 8px 12px; border-radius: 13px; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg small { display: block; font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.msg-me { align-self: flex-end; background: var(--accent); color: var(--accent-ink); border-bottom-right-radius: 4px; }
.msg-me small { color: color-mix(in srgb, var(--accent-ink) 70%, transparent); }
.msg-them { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg-err { border-color: color-mix(in srgb, var(--danger) 55%, var(--line)); }
.msg-sys { align-self: center; max-width: 100%; font-size: 12.5px; color: var(--muted); text-align: center; padding: 2px 8px; }
.msg-wide { align-self: stretch; max-width: 100%; white-space: normal; padding: 8px 10px; }
.msg-report { max-width: 96%; line-height: 1.55; }
.msg-report b { color: var(--ink); }
.mail-link {
  display: inline-block; margin-left: 4px; padding: 0 7px; border-radius: 999px; font-size: 11.5px; line-height: 18px;
  border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--line)); color: var(--accent); text-decoration: none; white-space: nowrap; vertical-align: 1px;
}
.mail-link:hover { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.msg-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; white-space: normal; }
.msg-actions .chip-btn { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.msg-actions .chip-btn:disabled { opacity: .45; cursor: default; }

/* Nhóm việc của nhân viên (thu gọn) */
.work { align-self: stretch; border: 1px dashed var(--line); border-radius: 10px; font-size: 12.5px; color: var(--muted); }
.work > summary { cursor: pointer; padding: 6px 10px; list-style: none; }
.work > summary::-webkit-details-marker { display: none; }
.work > summary::before { content: '▸'; display: inline-block; width: 14px; transition: transform .15s; }
.work[open] > summary::before { transform: rotate(90deg); }
.work > summary:hover { color: var(--ink); }
.work-body { display: flex; flex-direction: column; gap: 10px; padding: 4px 10px 10px; }
.w-task { display: flex; flex-direction: column; gap: 5px; }
.w-title { font-size: 12px; color: var(--muted); }
.w-task .msg { max-width: 100%; font-size: 13px; color: var(--ink); }
.work.is-live { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-style: solid; }
.spin { width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--line); border-top-color: var(--accent); animation: spin .8s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Bảng thư */
.mail-table { white-space: normal; display: flex; flex-direction: column; font-size: 13px; }
.mt-head { font-size: 11.5px; color: var(--muted); padding: 4px 2px 3px; }
.mt-head:not(:first-child) { margin-top: 6px; }
.mt-note, .mt-err { font-size: 11.5px; color: var(--muted); padding-top: 5px; }
.mt-err { color: var(--warn); white-space: pre-wrap; }
.mrow { border-top: 1px solid var(--line); }
.mrow > summary { display: grid; grid-template-columns: minmax(0, 32%) minmax(0, 1fr) auto; gap: 8px; align-items: baseline; padding: 6px 2px; cursor: pointer; list-style: none; }
.mrow > summary::-webkit-details-marker { display: none; }
.mrow > summary:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }
.m-from, .m-subj { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.m-from { color: var(--muted); }
.mrow.is-unread .m-from, .mrow.is-unread .m-subj { color: var(--ink); font-weight: 600; }
.mrow time { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.m-more { padding: 2px 2px 8px; }
.m-more p { color: var(--muted); font-size: 12.5px; margin: 0 0 6px; }
.m-btns { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.m-btns .mail-link { margin-left: 0; }

/* Thanh cảnh báo phiên đăng nhập */
.alert-bar {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 6;
  display: flex; align-items: center; gap: 10px; max-width: calc(100% - 32px);
  padding: 8px 10px 8px 14px; border-radius: 12px; font-size: 13px;
  background: color-mix(in srgb, var(--warn) 16%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 55%, var(--line));
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
}
.alert-bar .btn { flex: none; }
.scene.has-alert .hint { display: none; }

.typing { display: inline-flex; gap: 4px; align-items: center; padding: 12px 14px; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1.1s infinite; }
.typing i:nth-child(2) { animation-delay: .18s; }
.typing i:nth-child(3) { animation-delay: .36s; }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
.empty { color: var(--muted); text-align: center; padding: 26px 10px; }
.banner { background: color-mix(in srgb, var(--warn) 12%, var(--surface)); border: 1px solid color-mix(in srgb, var(--warn) 40%, var(--line)); border-radius: 10px; padding: 9px 11px; font-size: 13px; }
.banner .btn { margin-top: 7px; }
.quick { display: flex; gap: 6px; flex-wrap: wrap; }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px;
  padding: 4px 11px; font-size: 12.5px; cursor: pointer; color: var(--muted);
}
.chip-btn:hover { color: var(--ink); border-color: var(--accent); }
.composer { display: flex; gap: 8px; padding: 10px 14px 14px; border-top: 1px solid var(--line); align-items: flex-end; }
textarea, input, select {
  width: 100%; background: var(--bg); border: 1px solid var(--line); border-radius: 9px; padding: 8px 10px;
}
textarea { resize: vertical; min-height: 40px; }
select { width: auto; }

.card { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--surface-2); align-self: stretch; }
.card h5 { font-size: 14px; }
.card dl { margin: 8px 0; display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; font-size: 13px; }
.card dt { color: var(--muted); }
.card dd { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 170px; overflow: auto; }
.card-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* Thú cưng */
.pet-face { font-size: 34px; line-height: 1; display: block; }
.pet-hero { text-align: center; padding: 6px 0 2px; }
.pet-hero .pet-face { font-size: 58px; }
.pet-hero p { margin-top: 6px; }
.meter { display: grid; grid-template-columns: 34px 1fr 30px; gap: 8px; align-items: center; font-size: 13px; }
.meter .bar { height: 9px; border-radius: 999px; background: var(--bg); overflow: hidden; border: 1px solid var(--line); }
.meter .bar i { display: block; height: 100%; border-radius: 999px; background: var(--ok); transition: width .5s; }
.meter .bar i.is-low { background: var(--danger); }
.meter .bar i.is-mid { background: var(--warn); }
.meter b { text-align: right; font-variant-numeric: tabular-nums; }
.pet-actions { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.pet-actions .btn { padding: 10px 6px; }
.inline-form { display: flex; gap: 8px; }

/* ---------- Hộp thoại ---------- */
.dialog {
  border: 1px solid var(--line); border-radius: 16px; padding: 0;
  background: var(--surface); color: var(--ink);
  width: min(520px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .6);
}
.dialog-wide { width: min(640px, calc(100vw - 32px)); }
.dialog[open] { display: flex; flex-direction: column; }
.dialog::backdrop { background: rgba(5, 8, 14, .6); }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 16px 18px 12px; border-bottom: 1px solid var(--line); }
.dialog-head h3 { font-size: 17px; }
.dialog-body { padding: 16px 18px 18px; overflow: auto; display: flex; flex-direction: column; gap: 18px; }
.dialog-body h4 { font-size: 12px; letter-spacing: .07em; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.grid-form label, .field { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.grid-form label > *, .field > * { color: var(--ink); font-size: 14px; }
.span2 { grid-column: 1 / -1; }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.inline { display: flex; align-items: center; gap: 8px; }
.acct { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.acct small { color: var(--warn); display: block; }
.conn-note { padding: 9px 11px; border-radius: 9px; background: var(--surface-2); font-size: 13px; margin-bottom: 8px; }
.conn-actions { margin-top: 10px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.type-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.type-card { --c: var(--accent); position: relative; border: 1px solid var(--line); border-radius: 11px; padding: 10px 12px; cursor: pointer; display: block; background: var(--surface-2); }
.type-card input { position: absolute; opacity: 0; width: 1px; height: 1px; padding: 0; }
.type-card .pet-face { font-size: 36px; }
.type-card strong { display: block; color: var(--c); }
.type-card span { font-size: 12.5px; color: var(--muted); }
.type-card:has(input:checked) { border-color: var(--c); box-shadow: inset 0 0 0 1px var(--c); }
.type-card:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.pet-choice { --c: var(--t-pet); text-align: center; }
/* Ngoại hình thú cưng (giới tính, màu, hoa văn, dáng, tai) */
.pet-opts { display: grid; gap: 10px; margin: 4px 0 12px; }
.pet-opt { display: grid; gap: 5px; }
.pet-opt-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; gap: 6px; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg span { display: inline-block; padding: 6px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); font-size: 13px; }
.seg input:checked + span { border-color: var(--t-pet); box-shadow: inset 0 0 0 1px var(--t-pet); color: var(--t-pet); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatches { display: flex; flex-wrap: wrap; gap: 7px; align-items: center; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.swatch i { display: block; width: 28px; height: 28px; border-radius: 50%; background: var(--sw); border: 2px solid rgba(255, 255, 255, .18); }
.swatch input:checked + i { outline: 2px solid var(--t-pet); outline-offset: 2px; }
.swatch input:focus-visible + i { outline: 2px solid var(--accent); outline-offset: 2px; }
.swatch-custom { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.swatch-custom input[type="color"] { width: 32px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 7px; background: none; cursor: pointer; }
.pet-look-btn { margin-top: 2px; }
.pet-opt.is-off { opacity: .45; pointer-events: none; }
.pet-guest-note { font-size: 12.5px; margin: 0; text-align: center; }
.engine-list { display: grid; gap: 6px; margin-bottom: 10px; }
.engine { display: flex; gap: 8px; align-items: center; font-size: 13px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.dot.is-on { background: var(--ok); }
.check { display: flex; gap: 10px; align-items: flex-start; margin-top: 12px; padding: 10px 12px; border-radius: 9px; background: var(--surface-2); font-size: 13px; cursor: pointer; }
.check input { margin-top: 2px; flex: none; width: 16px; height: 16px; accent-color: var(--accent); }
.guide { margin-top: 10px; font-size: 13px; }
.guide summary { cursor: pointer; color: var(--accent); font-weight: 600; }
.guide ol { margin: 8px 0; padding-left: 20px; display: grid; gap: 5px; }

.toast {
  position: fixed; left: 50%; bottom: 62px; transform: translateX(-50%);
  background: var(--ink); color: var(--bg); padding: 9px 16px; border-radius: 10px; z-index: 100;
  max-width: calc(100vw - 32px); box-shadow: var(--shadow);
}

@media (max-width: 860px) {
  .stage { flex-direction: column; }
  .panel { width: auto; height: 58%; border-left: 0; border-top: 1px solid var(--line); }
  .hint, .clock { display: none; }
}
@media (max-width: 600px) {
  .feed { bottom: 64px; }
}
@media (max-width: 520px) {
  .grid-form, .type-cards { grid-template-columns: 1fr; }
  .topbar-actions .btn { padding: 6px 9px; font-size: 13px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Quyền: quản lý / khách ---------- */
.guest-only { display: none; }
body.is-guest .guest-only { display: inline-flex; }
body.is-guest .admin-only { display: none; }
.role-tag {
  font-size: 12px; padding: 4px 10px; border-radius: 999px; white-space: nowrap;
  border: 1px solid color-mix(in srgb, var(--accent) 50%, var(--line)); color: var(--accent);
  max-width: 260px; overflow: hidden; text-overflow: ellipsis;
}
.role-tag[hidden] { display: none; }
.role-tag.is-guest { color: var(--muted); border-color: var(--line); }
.msg a { color: var(--accent); text-decoration: underline; overflow-wrap: anywhere; }

/* ---------- Màn chọn cách vào ---------- */
.gate {
  position: fixed; inset: 0; z-index: 200; display: grid; place-items: center; padding: 16px;
  background: rgba(8, 11, 18, .72); backdrop-filter: blur(6px);
}
.gate[hidden] { display: none; }
.gate-card {
  width: min(400px, 100%); display: flex; flex-direction: column; align-items: stretch; gap: 10px;
  padding: 28px 26px 22px; border-radius: 18px; text-align: center;
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow);
}
.gate-card h1 { margin: 6px 0 0; font-size: 21px; }
.gate-card > .muted { margin: 0 0 8px; }
.gate-mark { align-self: center; transform: scale(1.5); margin: 6px 0 4px; }
.gate-btn { justify-content: center; padding: 10px 14px; font-size: 14.5px; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.gate-btn[hidden] { display: none; }
.g-logo { width: 20px; height: 20px; border-radius: 50%; background: #fff; color: #4285f4; font-weight: 800; display: inline-grid; place-items: center; font-size: 13px; }
.gate-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 4px 0; }
.gate-or::before, .gate-or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.gate-note { margin: 4px 0 0; font-size: 12.5px; line-height: 1.5; }
#gateMsg:empty { display: none; }
#gateMsg { color: var(--warn); }

/* ---------- Thẻ câu lệnh Veo ---------- */
.veo-card {
  margin: 8px 0; padding: 10px; border-radius: 10px; white-space: normal;
  background: color-mix(in srgb, var(--accent) 8%, var(--bg)); border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--line));
}
.veo-head { font-size: 12px; font-weight: 600; color: var(--accent); margin-bottom: 6px; }
.veo-text {
  margin: 0 0 8px; padding: 8px 10px; border-radius: 8px; background: var(--bg); border: 1px solid var(--line);
  font: 12.5px/1.5 ui-monospace, Consolas, monospace; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 220px; overflow: auto;
}
.veo-btns { display: flex; gap: 6px; flex-wrap: wrap; }
.msg .veo-btns a.btn { text-decoration: none; color: var(--ink); }
.msg .veo-btns a.btn-primary { color: var(--accent-ink); }
