/* Giao diện riêng: nền pastel, khung trắng bo tròn, nhấn tím. Nạp sau CSS gốc; bỏ dòng <link> trong base.html là về bản gốc.
 * Chỉ đè token và vài khối. Tiền tố `html` để thắng cả CSS nạp muộn (coord.css). Không dùng ảnh hay font ngoài (CSP). */

html:root {
  --bg: #fdfcff; --side-bg: #ffffff; --surface: #ffffff; --surface-2: #f8f6fd; --surface-3: #f2eefb;
  --bubble: #f3effc; --composer: #ffffff;
  --text: #26233a; --text-2: #403c58; --muted: #6a6583; --faint: #7d7895;
  --line: #ece8f6; --line-2: #ddd6ef;
  --accent: #7a48dc; --accent-hover: #6836c9; --accent-soft: #f2ebff; --accent-text: #6a3cc9; --on-accent: #ffffff; --accent-mark: #9a5cf5;
  --nav-active-bg: #f3eeff;
  --code-bg: #f4f1fb; --code-text: #39345a;
  --shadow-sm: 0 1px 2px rgba(76, 52, 140, .05);
  --shadow: 0 2px 8px rgba(76, 52, 140, .07);
  --shadow-lg: 0 18px 44px rgba(76, 52, 140, .16), 0 2px 8px rgba(76, 52, 140, .06);
  --shadow-composer: 0 8px 28px rgba(122, 72, 220, .10), 0 0 0 .5px rgba(122, 72, 220, .08);
  --r-sm: 10px; --r: 14px; --r-lg: 18px; --r-xl: 28px;
  /* chữ không chân cho cả tiêu đề: chữ có chân gốc đặt dấu tiếng Việt bị lệch */
  --serif: var(--sans);
  --rieng-page: radial-gradient(60% 55% at 55% 108%, #fbdcf3 0%, transparent 70%),
                radial-gradient(45% 50% at 100% 45%, #f6e1f4 0%, transparent 70%),
                linear-gradient(165deg, #d6e4f7 0%, #e6e3f8 48%, #f5e2f4 100%);
  --rieng-glow: radial-gradient(55% 38% at 50% 96%, rgba(236, 190, 245, .34) 0%, transparent 72%),
                radial-gradient(35% 30% at 26% 100%, rgba(190, 205, 250, .28) 0%, transparent 72%);
  --rieng-grad: linear-gradient(135deg, #a866f7 0%, #7a48dc 100%);
}
@media (prefers-color-scheme: dark) {
  html:root {
    --bg: #1c1a29; --side-bg: #201e2f; --surface: #272439; --surface-2: #232034; --surface-3: #322e49;
    --bubble: #2d2942; --composer: #272439;
    --text: #f3f1fb; --text-2: #ddd9ee; --muted: #aba6c4; --faint: #928dab;
    --line: #36324e; --line-2: #474262;
    --accent: #b18cf7; --accent-hover: #c1a3fa; --accent-soft: #332a52; --accent-text: #c4a8fb; --on-accent: #1b1430; --accent-mark: #b18cf7;
    --nav-active-bg: #342d53;
    --code-bg: #1a1826; --code-text: #ddd9ee;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25); --shadow: 0 2px 8px rgba(0, 0, 0, .3); --shadow-lg: 0 18px 44px rgba(0, 0, 0, .5);
    --shadow-composer: 0 8px 28px rgba(0, 0, 0, .35), 0 0 0 .5px rgba(255, 255, 255, .05);
    --rieng-page: radial-gradient(60% 55% at 55% 108%, #3a2347 0%, transparent 70%), linear-gradient(165deg, #121627 0%, #17142a 50%, #221730 100%);
    --rieng-glow: radial-gradient(55% 38% at 50% 96%, rgba(160, 100, 220, .16) 0%, transparent 72%);
    --rieng-grad: linear-gradient(135deg, #c4a2fb 0%, #a67cf3 100%);
  }
}

html body { background: var(--rieng-page) fixed, var(--bg); }

/* ---------------------------------------------------------------- khung nổi (màn rộng) */
@media (min-width: 1101px) {
  html .shell:not(.noside), html .shell.set { background: transparent; padding: 16px; gap: 12px; }
  html .shell:not(.noside) > .side, html .shell > .sset {
    top: 16px; height: calc(100vh - 32px); height: calc(100dvh - 32px);
    border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
  }
  html .shell:not(.noside) > .main {
    background: var(--bg); border: 1px solid var(--line); border-radius: 24px; box-shadow: var(--shadow);
    min-height: calc(100vh - 32px); min-height: calc(100dvh - 32px); overflow: clip;
  }
  /* trang trò chuyện và trang lượt chạy cao đúng một khung, tự cuộn bên trong */
  html body.chat-page .shell > .main, html body.run-page .shell > .main { height: calc(100vh - 32px); height: calc(100dvh - 32px); min-height: 0; }
}

/* ---------------------------------------------------------------- thanh bên */
html .brand .ic { color: var(--accent-mark); }
html .side-search { border-radius: 999px; background: var(--surface-2); border-color: transparent; }
html .side-search:focus-within { border-color: var(--accent); }
html .side .nav { gap: 4px; }
html .side .nav a { height: 42px; border-radius: 14px; padding: 0 8px 0 6px; gap: 11px; }
html .side .nav a .ic {
  box-sizing: border-box; width: 30px; height: 30px; padding: 7px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--line); color: var(--accent-mark);
}
html .side .nav a:nth-of-type(2) .ic { color: #d99a2b; }
html .side .nav a:nth-of-type(3) .ic { color: #4a86e0; }
html .side .nav a:nth-of-type(4) .ic { color: #e0803c; }
html .side .nav a:nth-of-type(5) .ic { color: #2fa57c; }
html .side .nav a.on { box-shadow: none; background: var(--nav-active-bg); color: var(--accent-text); }
html .snav a { border-radius: 12px; }
html .snav a.on { box-shadow: none; color: var(--accent-text); }
html .snav a .ic { color: var(--accent-mark); }
@media (max-width: 1100px) and (min-width: 761px) { html .side .nav a { padding-left: 5px; } }
html .side-new { border-radius: 14px; }
html .side-new-ic { background: var(--surface-3); color: var(--text); }

/* ---------------------------------------------------------------- nút, thẻ, ô nhập */
html .btn.primary { background: var(--rieng-grad); border-color: transparent; box-shadow: 0 4px 14px rgba(122, 72, 220, .22); }
html .btn.primary:hover { background: var(--rieng-grad); border-color: transparent; filter: brightness(1.06); }
html .card, html .stat { border-radius: 20px; }
html .mgr-form, html .composer { border-color: var(--line); border-radius: 26px; }

/* ---------------------------------------------------------------- trang trò chuyện */
html body.chat-page .shell > .main { background-image: var(--rieng-glow); background-color: var(--bg); }
html body.run-page .run-dock { background: transparent; }
html body.chat-page .composer-wrap { background: transparent; }
html body.chat-page .mgr-chat:not(.is-empty) .composer-wrap { background: linear-gradient(transparent, var(--bg) 18px); }
html .mgr-hero b { font-weight: 450; letter-spacing: -.02em; }
html .mgr-hero .hero-mark { color: var(--accent-mark); filter: drop-shadow(0 6px 14px rgba(154, 92, 245, .35)); }
html .mgr-hero .hanex-ten { font-style: normal; color: var(--accent-mark); }
/* ẩn hàng nút gợi ý dưới ô nhập (theo ý người dùng). Cần !important: coord.css bật lại bằng selector có id (#coord …) */
html .mgr-suggest { display: none !important; }

/* ---------------------------------------------------------------- chọn nhân vật (form agent) */
html .av-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(124px, 1fr)); gap: 10px; }
html .av { position: relative; display: block; margin: 0; cursor: pointer; }
html .av input { position: absolute; opacity: 0; width: 1px; height: 1px; }
html .av-body { display: flex; flex-direction: column; align-items: center; gap: 2px; height: 100%; padding: 8px; text-align: center;
  border: 1.5px solid var(--line); border-radius: 18px; background: var(--surface-2); }
html .av-body canvas { width: 100%; max-width: 112px; height: auto; aspect-ratio: 1; }
html .av-auto { display: grid; place-items: center; width: 100%; max-width: 112px; aspect-ratio: 1; font-size: 40px; color: var(--accent-mark); }
html .av input:checked + .av-body { border-color: var(--accent); background: var(--accent-soft); box-shadow: 0 0 0 2px var(--accent) inset; }
html .av input:focus-visible + .av-body { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------------------------------------------------------------- danh sách gợi ý khi gõ @ */
html .mgr-at[hidden] { display: none; }
html .mgr-at { position: fixed; z-index: 60; list-style: none; margin: 0; padding: 6px; display: flex; flex-direction: column; gap: 2px; max-height: 240px; overflow: auto;
  border: 1px solid var(--line-2); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
html .mgr-at li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 10px; border-radius: 10px; cursor: pointer; }
html .mgr-at li span { color: var(--muted); font-size: .85em; }
html .mgr-at li[aria-selected="true"], html .mgr-at li:hover { background: var(--accent-soft); }

/* Logo Hanex (nút xoắn tím): thay hình vẽ của biểu tượng "logo" bằng ảnh, kể cả chỗ island coord/ tự vẽ */
html .brand .ic, html .hero-mark, html .mm-mark .ic { background: url("hanex-mark.png") center / contain no-repeat; }
html .brand .ic > use, html .hero-mark > use, html .mm-mark .ic > use { display: none; }
