:root {
  --color-bg: #fff;
  --color-surface: #fff;
  --color-surface-subtle: #f7f7f8;
  --color-text: #202124;
  --color-text-soft: #6f7177;
  --color-border: #e8e8eb;
  --color-accent: #2563eb;
  --color-accent-soft: #eff6ff;
  --color-code: #f5f6f7;
  --header-height: 64px;
  --sidebar-width: 320px;
  --content-width: 1020px;
  --toc-width: 280px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 12px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --shadow-sm: 0 1px 3px rgb(0 0 0 / .06);
  --shadow-lg: 0 16px 50px rgb(0 0 0 / .18);
  color-scheme: light;
}

:root.dark {
  --color-bg: #111413;
  --color-surface: #171a19;
  --color-surface-subtle: #202422;
  --color-text: #eceeed;
  --color-text-soft: #a2a8a5;
  --color-border: #2c312f;
  --color-accent: #91a0ef;
  --color-accent-soft: #252b49;
  --color-code: #202422;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

[hidden],
.modal-backdrop[hidden],
.editor-workspace[hidden],
.editor-toast[hidden] {
  display: none !important;
}

html {
  scrollbar-gutter: stable;
  overscroll-behavior: none;
  -webkit-overscroll-behavior: none;
  overflow-x: clip;
}

body {
  margin: 0;
  background: var(--color-bg);
  color: var(--color-text);
  font: 15px/1.7 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-overscroll-behavior: none;
  overflow-x: clip;
}

a {
  color: var(--color-accent);
  text-decoration: none;
}

button,
input,
select {
  font: inherit;
}

.ux {
  --ux-page: var(--color-bg);
  --ux-surface: var(--color-surface);
  --ux-surface-2: var(--color-surface-subtle);
  --ux-surface-3: var(--color-code);
  --ux-ink: var(--color-text);
  --ux-ink-2: color-mix(in srgb, var(--color-text) 86%, var(--color-text-soft));
  --ux-ink-3: var(--color-text-soft);
  --ux-line: var(--color-border);
  --ux-line-2: var(--color-border);
  --ux-accent: var(--color-accent);
  --ux-accent-soft: var(--color-accent-soft);
  --ux-shadow-strong: rgb(0 0 0 / .22);
  --ux-ease: cubic-bezier(.22, .68, 0, 1);
  --ux-spring: cubic-bezier(.34, 1.56, .64, 1);
  box-sizing: border-box;
  font-family: inherit;
}

.ux *,
.ux *::before,
.ux *::after {
  box-sizing: border-box;
}

.ux :focus-visible {
  outline: 2px solid var(--ux-accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {

  .ux *,
  .ux *::before,
  .ux *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Shared controls */
.header-search,
.language-picker,
.search-wrap {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
}

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--color-text-soft);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s ease;
}

.icon-btn:hover {
  color: var(--color-text);
  background: var(--color-surface-subtle);
  border-color: var(--color-border);
}

.icon-btn.theme .theme-icon-dark {
  display: none;
}

:root.dark .icon-btn.theme .theme-icon-light {
  display: none;
}

:root.dark .icon-btn.theme .theme-icon-dark {
  display: block;
}

kbd {
  padding: 0 5px;
  color: var(--color-text-soft);
  border: 1px solid var(--color-border);
  border-radius: 5px;
  font-size: 11px;
}

/* Header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  height: var(--header-height);
  padding: 0 32px;
  background: color-mix(in srgb, var(--color-bg) 94%, transparent);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  -webkit-transform: translate3d(0, 0, 0);
  transform: translate3d(0, 0, 0);
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--color-text);
  font-size: 16.5px;
  font-weight: 750;
  letter-spacing: -.02em;
  white-space: nowrap;
  flex-shrink: 0;
  text-decoration: none;
  line-height: 1;
}

.brand-name {
  color: var(--color-text);
  white-space: nowrap;
  font-weight: 750;
}

.brand-sub {
  color: var(--color-text-soft);
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
  margin-left: 2px;
}

.brand-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  flex-shrink: 0;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.topnav {
  align-self: stretch;
  display: flex;
  flex: 1 1 auto;
  align-items: center;
  gap: 4px;
  min-width: 0;
  margin-left: 20px;
  overflow: visible;
}

.topnav::-webkit-scrollbar {
  display: none;
}

.topnav-item-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.topnav a {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--color-text-soft);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: color .15s ease, background .15s ease;
  text-decoration: none;
}

.topnav a:hover {
  color: var(--color-text);
  background: var(--color-surface-subtle);
}

.topnav a.active {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  font-weight: 600;
}

.topnav a::after {
  display: none !important;
}

/* TopNav Dropdown (Support & Updates) */
.topnav-link.has-dropdown {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}

.topnav-chevron {
  display: inline-block;
  width: 12px;
  height: 12px;
  stroke: currentColor;
  stroke-width: 2.2;
  transition: transform .2s cubic-bezier(.22, .68, 0, 1);
  opacity: .8;
  flex-shrink: 0;
  pointer-events: none;
}

.has-dropdown-wrap:hover .topnav-chevron,
.has-dropdown-wrap.open .topnav-chevron {
  transform: rotate(180deg);
}

.has-dropdown-wrap:hover > .topnav-link.has-dropdown,
.has-dropdown-wrap.open > .topnav-link.has-dropdown {
  color: var(--color-accent);
  background: var(--color-accent-soft);
}

.topnav-dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 1000;
  min-width: 170px;
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 14px 34px -4px rgba(0, 0, 0, 0.12), 0 4px 12px -2px rgba(0, 0, 0, 0.05);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(4px) scale(0.98);
  transform-origin: top left;
  transition: opacity .18s cubic-bezier(.22, .68, 0, 1), transform .18s cubic-bezier(.22, .68, 0, 1), visibility .18s;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

/* Invisible bridge so cursor doesn't lose hover across the 6px gap */
.topnav-dropdown-menu::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 0;
  right: 0;
  height: 8px;
}

.has-dropdown-wrap:hover .topnav-dropdown-menu,
.has-dropdown-wrap.open .topnav-dropdown-menu {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.topnav-dropdown-item {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 16px;
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text);
  border-radius: 9px;
  text-decoration: none;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}

.topnav-dropdown-item:hover {
  background: var(--color-surface-subtle);
  color: var(--color-accent);
}

.topnav-dropdown-item.active {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: 600;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 228px;
  height: 38px;
  padding: 0 12px;
  color: #92949a;
  cursor: pointer;
}

.header-search-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: #8e9096;
  transition: color .2s, transform .2s;
}

.header-search:hover .header-search-icon {
  color: var(--color-accent);
  transform: scale(1.08);
}

.header-search span {
  flex: 1;
  font-size: 13.5px;
}

.language-picker {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 9px;
  color: var(--color-text-soft);
}

.language-picker select {
  color: var(--color-text);
  background: var(--color-surface);
  border: 0;
  outline: 0;
  font-size: 13px;
  font-weight: 650;
  cursor: pointer;
}

#menu {
  display: none;
}

.theme {
  margin-left: auto;
}

/* Page shell */
.layout {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr) 280px;
  width: 100%;
  max-width: 100%;
  min-height: calc(100vh - var(--header-height));
  margin: 0;
  border-inline: none;
}

.sidebar {
  position: sticky;
  top: var(--header-height);
  height: calc(100vh - var(--header-height));
  padding: 20px 16px 24px 22px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
}

.sidebar::-webkit-scrollbar {
  width: 5px;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-search {
  display: none !important;
}

.search-wrap {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 42px;
  padding: 0 10px;
}

.search-wrap input {
  min-width: 0;
  flex: 1;
  color: var(--color-text);
  background: none;
  border: 0;
  outline: 0;
}

/* Navigation tree (GitBook structure) */
#nav {
  margin-top: 8px;
}

.nav-branch {
  position: relative;
  display: flex;
  flex-direction: column;
}

.nav-branch.section-hidden {
  display: none !important;
}

.nav-children {
  position: relative;
  display: flex;
  flex-direction: column;
}

/* Continuous tree guide lines (GitBook style) */
.nav-branch.depth-0>.nav-children {
  margin-left: 18px;
  padding-left: 10px;
  border-left: 1px solid var(--color-border);
}

.nav-branch.depth-1>.nav-children,
.nav-branch.depth-2>.nav-children,
.nav-branch.depth-3>.nav-children {
  margin-left: 14px;
  padding-left: 10px;
  border-left: 1px solid var(--color-border);
}

.nav-branch:not(.expanded)>.nav-children {
  display: none;
}

#nav a.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 5px 8px;
  overflow: hidden;
  color: #4b5563;
  border-radius: 6px;
  line-height: 1.35;
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 480;
  transition: color 120ms ease, background 120ms ease;
}

#nav a.nav-item:hover {
  color: #111827;
  background: rgba(0, 0, 0, 0.04);
}

#nav a.nav-item:focus,
#nav a.nav-item:focus-visible {
  outline: 0;
  box-shadow: none;
}

#nav a.nav-item.depth-0 {
  font-weight: 500;
  font-size: 13.5px;
  padding: 6px 8px;
  color: #374151;
}

#nav a.nav-item.depth-1 {
  font-size: 13.5px;
  font-weight: 450;
  min-height: 30px;
  padding: 4px 8px;
}

#nav a.nav-item.depth-2 {
  font-size: 13px;
  min-height: 28px;
  padding: 4px 8px;
}

#nav a.nav-item.depth-3 {
  font-size: 12.5px;
  min-height: 28px;
  padding: 4px 8px;
}

/* Active root item */
#nav .nav-branch.depth-0>a.nav-item.depth-0.active {
  color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.16);
  font-weight: 600;
  border-radius: 6px;
  box-shadow: none;
}

/* Active child items (GitBook style: faint subtle border, thin accent indicator on guide line) */
.nav-children a.nav-item.active {
  margin-left: -11px;
  padding-left: 9px;
  color: #2563eb;
  background: rgba(37, 99, 235, 0.08);
  border: 1px solid rgba(37, 99, 235, 0.15);
  border-left: 2px solid #2563eb;
  border-radius: 0 6px 6px 0;
  font-weight: 600;
  box-shadow: none;
}

.nav-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  color: #9ca3af;
  margin-right: 2px;
}

.nav-icon svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-item:hover .nav-icon,
.nav-item.active .nav-icon {
  color: #2563eb;
}

.nav-label {
  flex: 1;
}

.nav-item[data-expandable="true"] {
  cursor: pointer;
  user-select: none;
}

.nav-item[data-expandable="true"]:hover .chevron {
  color: var(--color-text);
}

.chevron {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  color: #9ca3af;
  font-size: 15px;
  font-weight: 500;
  margin-left: auto;
  margin-right: -4px;
  border-radius: 6px;
  transition: transform 150ms ease, color 120ms ease, background 120ms ease;
}

.chevron:hover {
  background: var(--color-surface-subtle);
  color: var(--color-text);
}

.nav-branch.expanded > .nav-item-wrap > a.nav-item > .chevron,
.nav-branch.expanded > a.nav-item > .chevron {
  transform: rotate(90deg);
}

@media (prefers-reduced-motion: reduce) {
  #nav a {
    transition-duration: .01ms;
  }
}

/* Search results and sidebar footer */
.results {
  margin-top: 14px;
}

.results a {
  display: block;
  padding: 12px 8px;
  border-bottom: 1px solid var(--color-border);
}

.results strong,
.results span {
  display: block;
}

.results strong {
  color: var(--color-text);
}

.results span {
  margin-top: 3px;
  color: var(--color-text-soft);
  font-size: 12px;
  line-height: 1.45;
}

.sidebar footer {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 18px;
  padding: 12px 14px;
  color: var(--color-text-soft);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  font-size: 12px;
}

.gitbook-mark {
  font-size: 18px;
}

/* Document content */
main {
  width: 100%;
  max-width: 1100px;
  min-width: 0;
  justify-self: center;
  padding: 40px 56px 88px;
}

.page-tools {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-4);
  min-height: 32px;
  margin-bottom: 24px;
  color: var(--color-text-soft);
  font-size: 12px;
}

.page-tools-right {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  margin-left: auto;
}

.reader-breadcrumb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--color-text-soft);
  max-width: 65%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.reader-breadcrumb .crumb-link {
  display: inline-flex;
  align-items: center;
  color: var(--color-text-soft);
  text-decoration: none;
  border-radius: 4px;
  padding: 2px 4px;
  transition: color 0.15s ease, background 0.15s ease;
}

.reader-breadcrumb .crumb-link:hover {
  color: var(--color-text);
  background: var(--color-surface-subtle);
}

.reader-breadcrumb .crumb-home {
  padding: 4px;
  color: var(--color-text-soft);
}

.reader-breadcrumb .crumb-sep {
  color: color-mix(in srgb, var(--color-text-soft) 40%, transparent);
  font-size: 11px;
  user-select: none;
}

.reader-breadcrumb .crumb-current {
  color: var(--color-text);
  font-weight: 550;
  overflow: hidden;
  text-overflow: ellipsis;
}

article {
  font-size: 16px;
  line-height: 1.75;
  text-wrap: pretty;
}

article,
.pager {
  opacity: 1;
  filter: none;
  transform: none;
  transition: none;
}

article.page-out,
.pager.page-out {
  opacity: .18;
  filter: blur(2px);
  transform: translateY(4px);
  pointer-events: none;
  transition-duration: .3s;
}

#nav {
  opacity: 1;
  transition: none;
}

#nav.nav-out {
  opacity: .28;
  pointer-events: none;
}

.loading {
  padding: 80px 0;
  color: var(--color-text-soft);
  text-align: center;
}

/* Modern Skeleton Loader for Page Transitions */
.page-skeleton-loader {
  padding: 32px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.skeleton-line {
  background: var(--color-surface-subtle);
  border-radius: 6px;
  height: 15px;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
}

.skeleton-line.skeleton-title {
  height: 38px;
  width: 50%;
  margin-bottom: 16px;
  border-radius: 8px;
}

@keyframes skeleton-shimmer {
  0%, 100% { opacity: 0.45; }
  50% { opacity: 0.9; }
}

.pager[hidden],
.pager:empty,
.pager button:empty,
.pager button[hidden],
.pager button:not(.pager-card) {
  display: none !important;
}

.pager:empty,
.pager[hidden] {
  display: none !important;
  border-top: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

article h1,
article h2,
article h3,
article h4 {
  color: var(--color-text);
  text-wrap: balance;
  position: relative;
  scroll-margin-top: 84px;
}

article h1 {
  margin: 6px 0 28px;
  font: 700 clamp(36px, 3.2vw, 48px) / 1.15 'Be Vietnam Pro', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: -.02em;
}

article h2 {
  margin: 52px 0 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 26px;
  line-height: 1.3;
  letter-spacing: -.025em;
}

article h3 {
  margin: 34px 0 12px;
  font-size: 20px;
  line-height: 1.4;
  letter-spacing: -.015em;
}

article h4 {
  margin: 25px 0 8px;
  font-size: 16px;
}

article p,
article li {
  color: color-mix(in srgb, var(--color-text) 90%, var(--color-text-soft));
}

article p {
  margin: 0 0 18px;
}

article p:empty {
  display: none;
}

article ul,
article ol {
  margin: 0 0 20px;
  padding-left: 1.45em;
}

article li+li {
  margin-top: 6px;
}

/* Reader Mode Images & GitBook Figure Frames */
div[data-with-frame="true"] {
  margin: 20px 0;
  text-align: center;
}

div[data-with-frame="true"] figure,
article figure {
  margin: 0 auto;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}

article img,
article video {
  height: auto;
  max-width: 100%;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.05);
}

article img {
  cursor: zoom-in;
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
  display: inline-block;
}

/* Tôn trọng thuộc tính chiều rộng khi đã được chỉnh */
article img[width],
article figure img[width] {
  max-width: 100%;
}

/* Giới hạn chiều cao hợp lý cho các ảnh chụp màn hình điện thoại chưa đặt width để không bị phóng to choán màn hình */
article img:not([width]) {
  max-height: 540px;
  width: auto;
  object-fit: contain;
}

article figure figcaption,
figcaption {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--color-text-soft);
  text-align: center;
  font-style: italic;
}

article img:hover {
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.1);
}

article pre {
  padding: 14px 48px 14px 16px;
  overflow: auto;
  background: var(--color-code);
  border-radius: var(--radius-md);
  font-size: 13px;
  line-height: 1.55;
}

article code {
  padding: 2px 5px;
  background: var(--color-code);
  border-radius: 5px;
}

article pre code {
  padding: 0;
  background: transparent;
}

/* Code copy button fixed at corner */
.code-block-wrap {
  position: relative;
  margin: var(--space-4) 0;
}

.code-block-wrap pre {
  margin: 0;
}

.code-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  color: var(--color-text-soft);
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  cursor: pointer;
  z-index: 4;
  transition: all 140ms ease;
}

.code-copy:hover {
  color: var(--color-text);
  border-color: #9ca3af;
  background: var(--color-surface);
  transform: translateY(-1px);
}

.code-copy.copied {
  color: #10b981;
  border-color: #10b981;
}

.code-copy svg {
  display: block;
}

/* Callouts / Notes (Lưu ý) */
.callout-box,
article blockquote {
  position: relative;
  margin: 20px 0;
  padding: 14px 18px;
  background: color-mix(in srgb, #f59e0b 8%, var(--color-surface));
  border: 1px solid color-mix(in srgb, #f59e0b 26%, var(--color-border));
  border-left: 4px solid #f59e0b;
  border-radius: 8px;
  color: var(--color-text);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.03);
}

:root.dark .callout-box,
:root.dark article blockquote {
  background: color-mix(in srgb, #f59e0b 12%, var(--color-surface));
  border-color: color-mix(in srgb, #f59e0b 32%, var(--color-border));
  border-left-color: #fbbf24;
}

.callout-box:has(.callout-icon-wrap) {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.callout-icon-wrap {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: #d97706;
  margin-top: 1px;
}

:root.dark .callout-icon-wrap {
  color: #fbbf24;
}

.callout-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 15px;
  font-weight: 700;
  color: #b45309;
}

.callout-header svg {
  flex: none;
  color: #d97706;
}

:root.dark .callout-header {
  color: #fcd34d;
}

:root.dark .callout-header svg {
  color: #fbbf24;
}

.callout-body {
  flex: 1;
  min-width: 0;
}

.callout-box p,
article blockquote p {
  margin: 6px 0;
  line-height: 1.6;
}

.callout-box p:first-child,
article blockquote p:first-child {
  margin-top: 0;
}

.callout-box p:last-child,
article blockquote p:last-child {
  margin-bottom: 0;
}

.callout-box ul,
.callout-box ol,
article blockquote ul,
article blockquote ol {
  margin: 6px 0 6px 20px;
  padding: 0;
}

.callout-box li,
article blockquote li {
  margin: 4px 0;
  line-height: 1.55;
}

article table {
  display: block;
  width: 100%;
  overflow: auto;
  border-collapse: collapse;
}

article td,
article th {
  padding: 10px;
  border: 1px solid var(--color-border);
  text-align: left;
}

.video-frame {
  margin: 24px 0;
}

.video-frame video,
.video-frame iframe {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 0;
  border-radius: var(--radius-md);
  object-fit: contain;
  background: #0b0b0b;
  box-shadow: 0 8px 30px rgb(0 0 0 / .10);
}

.video-frame figcaption {
  margin-top: 7px;
  color: var(--color-text-soft);
  font-size: 12px;
}

.media-card {
  margin: 20px 0;
  padding: 16px;
  background: var(--color-code);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

/* App Download Buttons (Simple & Clean) */
.app-download-simple {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin: 10px 0 20px;
}

ul + .app-download-simple,
ol + .app-download-simple {
  margin-top: 4px;
}

.store-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  height: 42px;
  padding: 0 14px;
  background: #000000 !important;
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.10);
  text-decoration: none !important;
  transition: transform .18s ease, box-shadow .18s ease, background-color .18s ease;
  user-select: none;
}

:root.dark .store-badge-btn {
  background: #18191d !important;
  border-color: rgba(255, 255, 255, 0.15) !important;
}

.store-badge-btn:hover {
  transform: translateY(-1px);
  background: #1c1d22 !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.20);
  color: #ffffff !important;
}

.store-badge-btn:active {
  transform: translateY(0);
}

.store-badge-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.store-apple .store-badge-icon {
  color: #ffffff;
}

.store-badge-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  text-align: left;
}

.store-badge-sub {
  font-size: 8.5px;
  line-height: 1.15;
  letter-spacing: .04em;
  opacity: .82;
  text-transform: uppercase;
  font-weight: 500;
  color: #ffffff !important;
}

.store-badge-name {
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: -.01em;
  color: #ffffff !important;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.arcade-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin: 20px 0 28px;
  padding: 14px 16px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: 12px;
}

.arcade-card>span {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  color: #fff;
  background: #171717;
  border-radius: 50%;
  font-size: 12px;
}

.arcade-card strong,
.arcade-card small {
  display: block;
}

.arcade-card strong {
  color: var(--color-text);
  font-size: 14px;
}

.arcade-card small {
  margin-top: 2px;
  color: var(--color-text-soft);
  font-size: 12px;
}

.arcade-card>a {
  padding: 7px 10px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .arcade-card {
    grid-template-columns: 36px 1fr;
  }

  .arcade-card>a {
    grid-column: 1 / -1;
    text-align: center;
  }
}

.release-label {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 14px;
  margin: 24px 0 28px;
  padding: 14px 16px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.release-label span {
  padding: 4px 9px;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 750;
  white-space: nowrap;
}

.release-label strong {
  font-size: 14px;
  font-weight: 650;
}

.gitbook-hint {
  margin-block: 22px;
}

/* Lucian UX/UI Prompt #044 · MIT License (c) 2026 Seokwoooo · https://lucianlabs.dev/uxui-prompt/#044 */
.faq-page {
  --ux-page: var(--color-bg);
  --ux-surface: var(--color-surface);
  --ux-surface-2: var(--color-surface-subtle);
  --ux-ink: var(--color-text);
  --ux-ink-2: color-mix(in srgb, var(--color-text) 86%, var(--color-text-soft));
  --ux-ink-3: var(--color-text-soft);
  --ux-line: var(--color-border);
  --ux-line-2: color-mix(in srgb, var(--color-accent) 28%, var(--color-border));
  --ux-accent: var(--color-accent);
  --ux-shadow-strong: rgb(0 0 0 / .18);
  --ux-ease: cubic-bezier(.22, .68, 0, 1);
  --ux-spring: cubic-bezier(.34, 1.56, .64, 1);
}

.faq-page details.u044-it {
  position: relative;
  margin: 0 0 10px;
  overflow: clip;
  background: var(--ux-surface);
  border-radius: 18px;
  box-shadow: 0 0 0 1px var(--ux-line);
  transition: background-color .4s var(--ux-ease), box-shadow .5s var(--ux-ease), transform .5s var(--ux-spring);
}

.faq-page details.u044-it.open {
  box-shadow: 0 0 0 1px var(--ux-line-2), 0 22px 40px -22px var(--ux-shadow-strong);
  transform: translateY(-2px);
}

.faq-page summary.u044-q {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 64px;
  padding: 10px 16px;
  color: var(--ux-ink);
  border-radius: 18px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -.02em;
  list-style: none;
  text-align: left;
}

.faq-page summary.u044-q::-webkit-details-marker {
  display: none;
}

.faq-page summary.u044-q:focus-visible {
  outline: 2px solid var(--ux-accent);
  outline-offset: -3px;
}

.faq-page .u044-n {
  color: var(--ux-ink-3);
  font-size: 12px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: color .3s;
}

.faq-page details.open .u044-n {
  color: var(--ux-accent);
}

.faq-page .u044-t {
  flex: 1;
}

.faq-page .u044-pm {
  position: relative;
  flex: none;
  width: 30px;
  height: 30px;
  background: var(--ux-surface-2);
  border-radius: 50%;
  transition: background-color .35s var(--ux-ease), transform .45s var(--ux-spring);
}

.faq-page summary:hover .u044-pm {
  transform: scale(1.1);
}

.faq-page .u044-pm::before,
.faq-page .u044-pm::after {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 11px;
  height: 2px;
  margin: -1px 0 0 -5.5px;
  background: var(--ux-ink);
  border-radius: 2px;
  content: "";
  transition: transform .5s var(--ux-spring), background-color .3s;
}

.faq-page .u044-pm::after {
  transform: rotate(90deg);
}

.faq-page details.open .u044-pm {
  background: var(--ux-ink);
}

.faq-page details.open .u044-pm::before,
.faq-page details.open .u044-pm::after {
  background: var(--ux-page);
}

.faq-page details.open .u044-pm::after {
  transform: rotate(180deg);
}

.faq-page .u044-body {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows .5s var(--ux-ease);
}

.faq-page details.open .u044-body {
  grid-template-rows: 1fr;
}

.faq-page .u044-body>div {
  min-height: 0;
  overflow: hidden;
}

.faq-page .u044-a {
  padding: 0 18px 20px 42px;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity .25s var(--ux-ease), transform .45s var(--ux-spring);
}

.faq-page details.open .u044-a {
  opacity: 1;
  transform: none;
  transition-delay: .12s;
}

.faq-page .u044-a> :last-child {
  margin-bottom: 0;
}

.faq-page .u044-a>hr {
  display: none;
}

.faq-page>hr {
  display: none;
}

.faq-page details p,
.faq-page details li {
  font-size: 14px;
  line-height: 1.65;
}

.faq-index>ul {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 0;
  list-style: none;
}

.faq-index>ul li {
  margin: 0;
}

.faq-index>ul a {
  position: relative;
  display: flex;
  align-items: center;
  min-height: 88px;
  padding: 20px 52px 20px 20px;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  box-shadow: var(--shadow-sm);
  font-size: 16px;
  font-weight: 700;
  transition: border-color .2s, transform .35s var(--ux-spring), box-shadow .35s;
}

.faq-index>ul a::after {
  position: absolute;
  right: 20px;
  color: var(--color-accent);
  content: "→";
  font-size: 20px;
  transition: transform .3s var(--ux-spring);
}

.faq-index>ul a:hover {
  border-color: color-mix(in srgb, var(--color-accent) 42%, var(--color-border));
  box-shadow: 0 14px 32px -24px var(--ux-shadow-strong);
  transform: translateY(-2px);
}

.faq-index>ul a:hover::after {
  transform: translateX(4px);
}

/* Lucian UX/UI Prompt #002 · MIT License (c) 2026 Seokwoooo · https://lucianlabs.dev/uxui-prompt/#002 */
.pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 56px;
  padding-top: 22px;
  border-top: 1px solid var(--color-border);
}

.pager-card {
  --pager-blob: #171717;
  position: relative;
  isolation: isolate;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 58px;
  padding: 9px 13px 9px 9px;
  overflow: hidden;
  color: var(--color-text);
  background: var(--color-surface);
  border: 0;
  border-radius: 13px;
  box-shadow: 0 0 0 1px var(--color-border), 0 12px 26px -25px rgb(0 0 0 / .28);
  cursor: pointer;
  text-align: left;
  transition: transform .35s var(--ux-spring), box-shadow .35s var(--ux-ease);
}

.pager-card:hover {
  box-shadow: 0 0 0 1px transparent, 0 24px 44px -24px rgb(91 72 255 / .5);
  transform: translateY(-2px);
}

.pager-card:active {
  transform: scale(.98);
}

.pager-card:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 4px;
}

.pager-fill {
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--pager-blob);
  clip-path: circle(18px at 27px 50%);
  opacity: .1;
  transition: clip-path .8s var(--ux-ease), opacity .5s var(--ux-ease);
}

.pager-card:hover .pager-fill,
.pager-card:focus-visible .pager-fill {
  clip-path: circle(160% at 27px 50%);
  opacity: .09;
}

.pager-orb {
  position: relative;
  display: grid;
  flex: 0 0 36px;
  place-items: center;
  width: 36px;
  height: 36px;
  overflow: hidden;
  color: #fff;
  background: var(--pager-blob);
  border-radius: 50%;
  transition: transform .7s var(--ux-spring);
}

.pager-orb svg {
  position: absolute;
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.3;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.pager-next .pager-orb svg:last-child {
  transform: translateX(-44px);
}

.pager-prev .pager-orb svg:last-child {
  transform: translateX(44px);
}

.pager-next.is-leaving .pager-orb svg:first-child {
  animation: pager-next-out .55s var(--ux-ease) forwards;
}

.pager-next.is-leaving .pager-orb svg:last-child {
  animation: pager-next-in .6s var(--ux-spring) .12s forwards;
}

.pager-prev.is-leaving .pager-orb svg:first-child {
  animation: pager-prev-out .55s var(--ux-ease) forwards;
}

.pager-prev.is-leaving .pager-orb svg:last-child {
  animation: pager-prev-in .6s var(--ux-spring) .12s forwards;
}

@keyframes pager-next-out {
  to {
    transform: translateX(44px);
  }
}

@keyframes pager-next-in {
  to {
    transform: none;
  }
}

@keyframes pager-prev-out {
  to {
    transform: translateX(-44px);
  }
}

@keyframes pager-prev-in {
  to {
    transform: none;
  }
}

.pager-copy {
  display: block;
  min-width: 0;
}

.pager-copy strong {
  display: -webkit-box;
  overflow: hidden;
  font-size: 13px;
  line-height: 1.35;
  letter-spacing: -.005em;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.pager-prev {
  grid-column: 1;
}

.pager-next {
  grid-column: 2;
  flex-direction: row-reverse;
  padding: 9px 9px 9px 13px;
  text-align: right;
}

.pager-next .pager-fill {
  clip-path: circle(18px at calc(100% - 27px) 50%);
}

.pager-next:hover .pager-fill,
.pager-next:focus-visible .pager-fill {
  clip-path: circle(160% at calc(100% - 27px) 50%);
}

.toc {
  position: sticky;
  top: var(--header-height);
  align-self: start;
  height: calc(100vh - var(--header-height));
  padding: 44px 24px 40px 28px;
  overflow-y: auto;
  background: var(--color-bg);
  border-left: 1px solid var(--color-border);
}

.toc-card {
  width: 100%;
  max-width: var(--toc-width);
}

.toc-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 0 14px;
  color: var(--color-text-soft);
  background: transparent;
  border: 0;
  cursor: pointer;
}

.toc-heading strong {
  font: 700 11.5px/1.2 Inter, -apple-system, sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-text-soft);
}

.toc-heading strong::before,
.toc-heading strong::after {
  display: none !important;
  content: none !important;
}

.toc-heading span {
  color: var(--color-text-soft);
  font-size: 14px;
  transition: transform 160ms ease;
}

.toc-heading[aria-expanded="false"] span {
  transform: rotate(180deg);
}

#toc {
  display: grid;
  gap: 2px;
  max-height: min(58vh, 620px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--color-text-soft) 28%, transparent) transparent;
}

#toc::-webkit-scrollbar {
  width: 4px;
}

#toc::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--color-text-soft) 28%, transparent);
  border-radius: 999px;
}

#toc a {
  display: block;
  padding: 8px 10px 8px 15px;
  color: var(--color-text-soft);
  border-left: 1px solid var(--color-border);
  font-size: 13px;
  line-height: 1.45;
  transition: color 120ms ease, border-color 120ms ease;
}

#toc a:hover,
#toc a.active {
  color: var(--color-accent);
  border-left-color: var(--color-accent);
}

#toc a.h3 {
  padding-left: 28px;
  font-size: 12.5px;
}

#toc a.h4 {
  padding-left: 40px;
  font-size: 12px;
}

#toc a.h5,
#toc a.h6 {
  padding-left: 48px;
  font-size: 12px;
}

/* bước: chỉ thụt lề, không chấm đầu dòng */
#toc a.toc-step {
  position: relative;
  padding-left: 40px;
  font-size: 12px;
}


.doc-subsection {
  scroll-margin-top: calc(var(--header-height) + 20px);
}

.toc-card.collapsed #toc {
  display: none;
}

.toc-card.collapsed .toc-heading {
  padding-bottom: 0;
}

.toc-card.no-toc .toc-heading,
.toc-card.no-toc #toc {
  display: none;
}

.toc-card.no-toc .toc-shortcuts {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.toc-shortcuts {
  display: grid;
  gap: 8px;
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid var(--color-border);
}

.toc-shortcuts strong {
  margin-bottom: 4px;
  font: 700 11.5px/1.2 Inter, -apple-system, sans-serif;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--color-text-soft);
}

.toc-shortcuts strong::before,
.toc-shortcuts strong::after {
  display: none !important;
  content: none !important;
}

.toc-shortcuts button,
.toc-shortcuts a {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 10px;
  color: var(--color-text-soft);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  font: 550 12.5px/1.3 Inter, -apple-system, sans-serif;
  text-align: left;
  cursor: pointer;
  transition: all .15s ease;
}

.toc-shortcuts button:hover,
.toc-shortcuts a:hover {
  color: var(--color-accent);
  border-color: color-mix(in srgb, var(--color-accent) 35%, var(--color-border));
  background: var(--color-accent-soft);
  transform: translateY(-1px);
}

.toc-shortcuts svg {
  flex-shrink: 0;
  color: currentColor;
}

.overlay {
  display: none;
}

/* Lucian UX/UI Prompt #046 · MIT License (c) 2026 Seokwoooo · https://lucianlabs.dev/uxui-prompt/#046 */
.command-backdrop {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: start center;
  padding-top: min(15vh, 130px);
  background: rgb(18 21 28 / .32);
  backdrop-filter: blur(5px);
}

.command-backdrop[hidden] {
  display: none;
}

.u046 {
  position: relative;
  width: min(480px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 180px));
}

.u046-pal {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  border-radius: 24px;
  background: var(--ux-surface);
  box-shadow: 0 0 0 1px var(--ux-line), 0 34px 60px -34px var(--ux-shadow-strong);
  clip-path: inset(0 0 0 0 round 24px);
}

.u046-field {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  height: 56px;
  flex: none;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--ux-line);
}

.u046-field svg.u046-search-icon,
.u046-field>svg {
  width: 19px;
  height: 19px;
  flex: none;
  fill: none;
  stroke: var(--ux-ink-3);
  stroke-width: 2;
  stroke-linecap: round;
}

.u046-in {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  color: var(--ux-ink);
  background: none;
  border: 0;
  outline: none;
  font-size: 15.5px;
  font-weight: 560;
}

.u046-in:focus,
.u046-in:focus-visible {
  outline: 0;
  box-shadow: none;
}

.u046-in::placeholder {
  color: var(--ux-ink-3);
}

.u046-field-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}

.u046-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  color: var(--ux-ink-3);
  background: var(--ux-surface-2);
  border: 1px solid var(--ux-line-2);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
}

.u046-close-btn:hover {
  color: var(--ux-ink);
  background: var(--ux-surface-3);
  border-color: var(--ux-line);
  transform: scale(1.06);
}

.u046-close-btn:active {
  transform: scale(0.95);
}

.u046-close-btn svg {
  width: 14px;
  height: 14px;
  stroke-width: 2.2;
}

.u046-kbd {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 7px;
  color: var(--ux-ink-3);
  background: var(--ux-surface-2);
  border-radius: 7px;
  box-shadow: inset 0 -1px 0 var(--ux-line-2);
  font: 700 11.5px/1 inherit;
  white-space: nowrap;
  cursor: pointer;
  user-select: none;
  transition: background .15s, color .15s;
}

.u046-kbd:hover {
  color: var(--ux-ink);
  background: var(--ux-surface-3);
}

.u046-field:has(.u046-in:focus-visible) {
  border-bottom-color: var(--ux-line);
  box-shadow: none;
}

.u046-body {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 6px 8px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.u046-body::-webkit-scrollbar {
  display: none;
}

.u046-hl {
  position: absolute;
  left: 8px;
  right: 8px;
  top: 0;
  height: 58px;
  background: var(--ux-accent-soft);
  border-radius: 13px;
  box-shadow: inset 3px 0 0 var(--ux-accent);
  transform: translateY(var(--y, 0));
  transition: transform .4s var(--ux-spring), opacity .2s;
  pointer-events: none;
}

.u046-list {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.u046-g {
  padding: 10px 10px 6px;
  color: var(--ux-ink-3);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.u046-op {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 58px;
  padding: 7px 10px;
  color: var(--ux-ink-2);
  border-radius: 13px;
  font-size: 14.5px;
  font-weight: 620;
  cursor: pointer;
  animation: u046-in .45s var(--ux-spring) backwards;
  animation-delay: calc(var(--i) * 28ms);
}

.u046-op[aria-selected="true"] {
  color: var(--ux-ink);
}

.u046-op mark {
  color: var(--ux-accent);
  background: none;
  font-weight: 800;
}

.u046-ic {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--color-text-soft);
  background: var(--color-surface-subtle);
  border: 1px solid color-mix(in srgb, var(--color-border) 75%, transparent);
  border-radius: 8px;
  transition: all .15s ease;
}

.u046-ic svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.u046-op:hover .u046-ic,
.u046-op[aria-selected="true"] .u046-ic {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-color: color-mix(in srgb, var(--color-accent) 30%, transparent);
}

.u046-copy {
  display: block;
  min-width: 0;
}

.u046-copy b,
.u046-copy small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.u046-copy b {
  color: inherit;
  font-size: 14px;
}

.u046-copy small {
  margin-top: 2px;
  color: var(--ux-ink-3);
  font-size: 11.5px;
  font-weight: 450;
}

.u046-copy mark,
.results mark {
  color: var(--ux-accent);
  background: transparent;
  font-weight: 800;
}

article mark.search-hit {
  padding: 2px 3px;
  color: var(--color-text);
  background: #fff2a8;
  border-radius: 4px;
  box-shadow: 0 0 0 3px rgb(255 226 86 / .2);
}

:root.dark article mark.search-hit {
  color: #171a19;
  background: #ffe36e;
}

.u046-empty {
  padding: 40px 0;
  color: var(--ux-ink-3);
  text-align: center;
  font-size: 14px;
}

.u046-empty b {
  display: block;
  margin-bottom: 4px;
  color: var(--ux-ink);
  font-size: 15px;
}

@keyframes u046-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.u046-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  height: 44px;
  flex: none;
  padding: 0 16px;
  color: var(--ux-ink-3);
  border-top: 1px solid var(--ux-line);
  font-size: 12px;
  font-weight: 600;
}

.u046-foot .u046-kbd {
  height: 20px;
  margin-right: 4px;
  padding: 0 5px;
  font-size: 11px;
}

/* Responsive */
/* Responsive */
@media (min-width: 901px) and (max-width: 1240px) {
  .layout {
    grid-template-columns: 280px minmax(0, 1fr);
    width: 100%;
    border-inline: 0;
  }

  .sidebar {
    padding-left: 20px;
  }

  main {
    max-width: var(--content-width);
    justify-self: center;
    padding-inline: 44px;
  }

  .toc {
    display: none;
  }
}

.sidebar-section-nav {
  display: none;
}

.sidebar-mobile-header,
.sidebar-mobile-lang-wrap {
  display: none;
}

@media (max-width: 900px) {
  :root {
    --header-height: 56px;
  }

  #menu {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  .topbar {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    height: var(--header-height);
    min-height: var(--header-height);
    padding: 0 14px;
    gap: 8px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-sizing: border-box;
  }

  .brand {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    white-space: nowrap;
  }

  .brand .brand-sub,
  .brand span:last-child,
  .header-search {
    display: none;
  }

  .header-actions {
    margin-left: auto;
    gap: 6px;
    flex-shrink: 0;
  }

  /* Bỏ thanh ngang ở ngoài trên điện thoại */
  .topnav {
    display: none !important;
  }

  .sidebar-mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 2px 0 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--color-border);
  }

  .sidebar-mobile-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 650;
    color: var(--color-text);
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .sidebar-mobile-lang-wrap {
    display: block;
    margin: 0 0 14px;
    padding-right: 18px;
  }

  .sidebar-mobile-lang-segmented {
    display: flex;
    align-items: center;
    background: var(--color-surface-subtle);
    border: 1px solid var(--color-border);
    border-radius: 9px;
    padding: 3px;
    gap: 3px;
  }

  .mobile-lang-tab {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    padding: 0 12px;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--color-text-soft);
    font-size: 12.5px;
    font-weight: 550;
    font-family: inherit;
    cursor: pointer;
    transition: all .15s ease;
  }

  .mobile-lang-tab:hover {
    color: var(--color-text);
  }

  .mobile-lang-tab.active {
    background: var(--color-surface);
    color: var(--color-text);
    font-weight: 650;
    box-shadow: 0 1px 4px rgb(0 0 0 / .08);
  }

  .sidebar-close-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: 1px solid var(--color-border);
    background: var(--color-surface-subtle);
    color: var(--color-text-soft);
    cursor: pointer;
    transition: all .15s ease;
  }

  .sidebar-close-btn:hover {
    color: var(--color-text);
    background: var(--color-surface);
    border-color: var(--color-accent);
  }

  .sidebar-section-nav {
    display: block;
    margin: 12px 0 16px;
    padding: 0 4px;
  }

  .sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
  }

  .sidebar-section-title {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--color-text-soft);
  }

  .sidebar-section-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
  }

  .sidebar-section-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 6px 11px;
    font-size: 12.5px;
    font-weight: 550;
    color: var(--color-text-soft);
    background: var(--color-surface-subtle);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.15s ease;
    font-family: inherit;
  }

  .sidebar-section-chip:hover {
    color: var(--color-text);
    background: var(--color-surface);
    border-color: var(--color-accent);
  }

  .sidebar-section-chip.active {
    color: #ffffff;
    background: var(--color-accent);
    border-color: var(--color-accent);
    font-weight: 650;
    box-shadow: 0 2px 8px color-mix(in srgb, var(--color-accent) 25%, transparent);
  }

  .language-picker {
    padding: 0 8px;
    height: 36px;
    flex-shrink: 0;
  }

  .language-picker select {
    width: auto;
    min-width: 82px;
    max-width: 115px;
    font-size: 13px;
    cursor: pointer;
  }

  .layout {
    display: block;
    width: 100%;
    border-inline: 0;
  }

  .sidebar-search {
    display: flex !important;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 30;
    width: min(86vw, var(--sidebar-width));
    height: 100vh;
    padding-left: 18px;
    background: var(--color-bg);
    box-shadow: var(--shadow-lg);
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }

  .sidebar.open {
    transform: none;
  }

  .overlay {
    position: fixed;
    inset: 0;
    z-index: 25;
    background: rgb(0 0 0 / .36);
    border: 0;
  }

  .overlay.show {
    display: block;
  }

  main {
    padding: 22px 20px 60px;
  }

  .page-tools {
    padding-bottom: 12px;
  }

  article h1 {
    margin-top: 8px;
  }

  .pager {
    grid-template-columns: 1fr;
  }

  .pager-card {
    min-height: 54px;
  }

  .toc {
    display: none;
  }

  .faq-index>ul {
    grid-template-columns: 1fr;
  }

  .release-label {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .faq-page .u044-a {
    padding-inline: 18px;
  }
}

@media (min-width: 1600px) {
  :root {
    --sidebar-width: 280px;
    --content-width: 1040px;
    --toc-width: 300px;
  }

  main {
    padding-inline: 64px;
  }
}

/* Retion Control Surface — technology visual system */
:root {
  --color-bg: #ffffff;
  --color-surface: #ffffff;
  --color-surface-subtle: #f6f8fa;
  --color-text: #171717;
  --color-text-soft: #667085;
  --color-border: #e3e7ec;
  --color-accent: #2563eb;
  --color-accent-2: #1d4ed8;
  --color-accent-soft: #eff6ff;
  --color-code: #f4f6f8;
  --shadow-sm: 0 1px 2px rgb(17 24 39 / .05), 0 8px 28px -24px rgb(17 24 39 / .22);
}

:root.dark {
  --color-bg: #080b09;
  --color-surface: #101512;
  --color-surface-subtle: #17201a;
  --color-text: #f5f7f5;
  --color-text-soft: #9da9a1;
  --color-border: #28342c;
  --color-accent: #60a5fa;
  --color-accent-2: #93c5fd;
  --color-accent-soft: rgba(59, 130, 246, 0.14);
  --color-code: #131b16;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / .22), 0 12px 32px -24px rgb(0 0 0 / .48);
}

body {
  background-color: var(--color-bg);
  background-image: none;
}

.topbar {
  background: color-mix(in srgb, var(--color-bg) 82%, transparent);
  border-bottom-color: color-mix(in srgb, var(--color-border) 82%, transparent);
  box-shadow: 0 8px 30px -28px rgb(29 46 94 / .7);
}

.topbar::after {
  position: absolute;
  left: 0;
  bottom: -1px;
  width: 172px;
  height: 1px;
  background: var(--color-border);
  content: "";
}

:root.page-loading .topbar::after {
  width: 172px;
  animation: none;
}

.brand {
  letter-spacing: -.025em;
}

.header-search,
.language-picker,
.search-wrap {
  background: color-mix(in srgb, var(--color-surface) 88%, transparent);
  border-color: color-mix(in srgb, var(--color-border) 86%, transparent);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
}

.header-search {
  transition: border-color .2s, box-shadow .25s, transform .25s;
}

.header-search:hover {
  border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border));
  box-shadow: 0 10px 30px -22px color-mix(in srgb, var(--color-accent) 65%, transparent);
  transform: translateY(-1px);
}

.sidebar,
.toc {
  background: color-mix(in srgb, var(--color-bg) 87%, transparent);
  backdrop-filter: blur(18px);
}

.sidebar {
  border-right-color: color-mix(in srgb, var(--color-border) 75%, transparent);
}

.toc {
  border-left-color: color-mix(in srgb, var(--color-border) 75%, transparent);
}

.nav-icon {
  color: #7e8ca4;
}

.sidebar footer {
  background: color-mix(in srgb, var(--color-surface) 85%, transparent);
  border-color: color-mix(in srgb, var(--color-border) 85%, transparent);
}

.gitbook-mark {
  color: var(--color-accent-2);
  text-shadow: 0 0 16px color-mix(in srgb, var(--color-accent-2) 55%, transparent);
}

main {
  position: relative;
  background: color-mix(in srgb, var(--color-bg) 91%, transparent);
}

.page-source-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 10px;
  color: var(--color-text-soft);
  background: color-mix(in srgb, var(--color-surface) 75%, transparent);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  font: 600 11.5px/1 Inter, -apple-system, sans-serif;
  text-decoration: none;
  cursor: pointer;
  transition: all .2s cubic-bezier(.16, 1, .3, 1);
  white-space: nowrap;
}

.page-source-btn .md-logo {
  flex-shrink: 0;
  color: var(--color-text-soft);
  opacity: .85;
  transition: all .2s ease;
}

.page-source-btn:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
  box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--color-accent) 25%, transparent);
}

.page-source-btn:hover .md-logo {
  color: var(--color-accent);
  opacity: 1;
}

.page-source-btn:active {
  transform: scale(0.98);
}

:root.dark .page-source-btn .md-logo {
  color: var(--color-text-soft);
}

:root.dark .page-source-btn:hover .md-logo {
  color: var(--color-accent);
}

article img,
article video {
  background: var(--color-surface);
  box-shadow: 0 18px 48px -38px rgb(27 40 80 / .55), 0 0 0 1px color-mix(in srgb, var(--color-border) 70%, transparent);
}

article pre {
  border: 1px solid var(--color-border);
  box-shadow: inset 0 1px 0 color-mix(in srgb, #fff 45%, transparent);
}

article code {
  color: color-mix(in srgb, var(--color-accent) 80%, var(--color-text));
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

article th {
  color: var(--color-text);
  background: var(--color-surface-subtle);
}

.toc-heading strong,
.toc-shortcuts strong {
  color: var(--color-text-soft);
  font-family: Inter, -apple-system, sans-serif;
}

#toc a {
  border-left-color: color-mix(in srgb, var(--color-border) 85%, transparent);
}

#toc a:hover,
#toc a.active {
  background: var(--color-surface-subtle);
  border-left-color: var(--color-text);
}

.faq-page details.u044-it,
.faq-index>ul a,
.pager-card {
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  backdrop-filter: blur(12px);
}

.faq-page details.u044-it.open {
  border-color: color-mix(in srgb, var(--color-accent) 32%, var(--color-border));
}

.release-label {
  background: var(--color-surface-subtle);
}

@media (max-width: 900px) {
  body {
    background-size: auto, 28px 28px, 28px 28px;
  }

  .sidebar {
    background: color-mix(in srgb, var(--color-bg) 96%, transparent);
  }

  article h1 {
    padding-bottom: 16px;
  }

  article h1::after {
    width: 62px;
  }
}

@media (prefers-reduced-motion: reduce) {

  article,
  .pager {
    transition-duration: .01ms;
  }

  :root.page-loading .topbar::after {
    animation: none;
  }
}

/* Monochrome controls */
.topbar::after {
  background: #d7dbe0;
}

.topnav a::after {
  background: #171717;
}

.page-tools a:hover,
.toc-shortcuts button:hover,
.toc-shortcuts a:hover {
  color: var(--color-text);
  border-color: #aeb4bc;
}

.pager-card {
  --pager-blob: #171717;
}

.pager-card:hover {
  box-shadow: 0 0 0 1px #aeb4bc, 0 16px 34px -28px rgb(0 0 0 / .42);
}

.pager-card:focus-visible {
  outline-color: #171717;
}

.icon-btn,
.language-picker,
.header-search,
.toc-heading,
.toc-shortcuts button {
  accent-color: #171717;
}

:root.dark .topnav a::after {
  box-shadow: inset 2px 0 0 #f5f7f5;
}

:root.dark .pager-card {
  --pager-blob: #4b5563;
}

/* ==========================================================================
   WordPress Page Editor & Book Management System
   ========================================================================== */

/* Topbar & Header Action Buttons (Common standard for Edit, Login, Logout) */
.header-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px;
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-surface) 90%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all .18s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-sizing: border-box;
}

.header-action-btn:hover {
  border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border));
  color: var(--color-accent);
  background: var(--color-accent-soft);
  transform: translateY(-1px);
}

.header-action-btn:active {
  transform: translateY(0);
}

.header-action-btn svg {
  flex-shrink: 0;
  display: block;
}

.header-action-btn.edit-toggle-btn.active {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  box-shadow: 0 2px 8px -1px color-mix(in srgb, var(--color-accent) 40%, transparent);
}

/* Sidebar Authoring Toolbar (Book Manager) */
.sidebar-author-bar {
  display: flex;
  gap: 6px;
  margin: 10px 0 4px;
}

.sidebar-author-btn {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-soft);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s ease;
}

.sidebar-author-btn:hover {
  color: var(--color-text);
  border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border));
  background: var(--color-surface);
}

/* In-reader page edit button */
.page-tools-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.page-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 28px;
  padding: 3px 10px;
  color: var(--color-text-soft);
  background: color-mix(in srgb, var(--color-surface) 75%, transparent);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  font: 600 11.5px/1 Inter, sans-serif;
  cursor: pointer;
  transition: all .2s ease;
}

.page-edit-btn:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
  background: var(--color-accent-soft);
}

/* WordPress Editor Workspace Container */
body.in-editor-mode .layout {
  grid-template-columns: 280px minmax(0, 1fr) !important;
}

body.in-editor-mode aside.toc {
  display: none !important;
}

body.in-editor-mode main {
  max-width: none !important;
  width: 100% !important;
}

.editor-workspace {
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
  min-height: calc(100vh - var(--header-height));
  margin: 0 calc(-1 * var(--space-4));
  border-top: 1px solid var(--color-border);
}

@media (min-width: 1024px) {
  .editor-workspace {
    margin: 0 -36px;
  }
}

/* Editor Topbar */
.editor-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 8px 20px;
  background: color-mix(in srgb, var(--color-surface) 92%, transparent);
  border-bottom: 1px solid var(--color-border);
  backdrop-filter: blur(20px);
  position: sticky;
  top: var(--header-height);
  z-index: 15;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.editor-meta-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.editor-mode-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  background: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface));
  color: var(--color-accent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 26%, transparent);
  border-radius: 999px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.editor-mode-badge .badge-icon {
  font-size: 12px;
  line-height: 1;
}

.editor-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 999px;
  transition: all .2s ease;
  border: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
  color: var(--color-text-soft);
}

.editor-status-pill .status-dot,
.editor-status-pill .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.7);
  display: inline-block;
  flex-shrink: 0;
}

.editor-status-pill.clean {
  color: #16a34a;
  border-color: rgba(34, 197, 94, 0.25);
  background: rgba(34, 197, 94, 0.06);
}

.editor-status-pill.dirty {
  color: #d97706;
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
}

.editor-status-pill.dirty .status-dot,
.editor-status-pill.dirty .dot {
  background: #f59e0b;
  box-shadow: 0 0 6px rgba(245, 158, 11, 0.8);
}

/* View Mode Selector (Segmented Capsule Switcher) */
.editor-view-modes {
  display: flex;
  align-items: center;
  background: var(--color-surface-subtle);
  padding: 3px;
  border-radius: 999px;
  border: 1px solid var(--color-border);
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}

.view-mode-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 13px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--color-text-soft);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  transition: all .16s ease;
}

.view-mode-btn:hover {
  color: var(--color-text);
  background: color-mix(in srgb, var(--color-surface) 70%, transparent);
}

.view-mode-btn.active {
  background: var(--color-surface);
  color: var(--color-accent);
  font-weight: 650;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1), 0 0 0 1px color-mix(in srgb, var(--color-accent) 25%, transparent);
}

.view-mode-btn svg {
  flex-shrink: 0;
}

/* Editor Action Buttons */
.editor-top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.editor-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 11px;
  font-size: 12px;
  font-weight: 550;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
  height: 32px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.02);
}

.editor-action-btn:hover {
  background: var(--color-surface-subtle);
  border-color: color-mix(in srgb, var(--color-text-soft) 40%, var(--color-border));
  color: var(--color-accent);
  transform: translateY(-1px);
}

.editor-action-btn.btn-action-delete:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

.editor-action-sep {
  width: 1px;
  height: 18px;
  background: var(--color-border);
  margin: 0 3px;
}

/* Editor Save Button & States */
.editor-btn-save {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 0 13px;
  font-size: 12.5px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: background .2s ease, border-color .2s ease, color .2s ease, transform .15s ease, box-shadow .2s ease;
  white-space: nowrap;
  flex-shrink: 0;
  height: 32px;
  user-select: none;
}

/* 1. Clean State (Đã lưu / Chưa có thay đổi mới) */
.editor-btn-save.is-clean,
.editor-btn-save:not(.has-changes):not(.is-saving):not(.is-saved):not(.is-error) {
  background: var(--color-surface);
  color: var(--color-text-soft);
  border: 1px solid var(--color-border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}
.editor-btn-save.is-clean:hover,
.editor-btn-save:not(.has-changes):not(.is-saving):not(.is-saved):not(.is-error):hover {
  background: var(--color-surface-subtle);
  border-color: color-mix(in srgb, var(--color-border) 70%, var(--color-text));
  color: var(--color-text);
  transform: translateY(-1px);
}
.editor-btn-save.is-clean .btn-clean-check,
.editor-btn-save:not(.has-changes):not(.is-saving):not(.is-saved):not(.is-error) .btn-clean-check {
  color: #10b981;
}
.editor-btn-save.is-clean .btn-kbd,
.editor-btn-save:not(.has-changes):not(.is-saving):not(.is-saved):not(.is-error) .btn-kbd {
  background: var(--color-surface-subtle);
  color: var(--color-text-soft);
  border: 1px solid var(--color-border);
}

/* 2. Has Changes State (Có thay đổi chưa lưu) */
.editor-btn-save.has-changes {
  color: #fff;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 10px rgba(37, 99, 235, 0.38), 0 1px 3px rgba(37, 99, 235, 0.2);
  animation: savePulseGlow 2.5s infinite alternate ease-in-out;
}
.editor-btn-save.has-changes:hover {
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.5);
}
.editor-btn-save.has-changes:active {
  transform: translateY(0);
}
.editor-btn-save.has-changes .btn-kbd {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.32);
}
.editor-btn-save .btn-save-indicator {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #fbbf24;
  border-radius: 50%;
  box-shadow: 0 0 6px #fbbf24;
  margin-right: -2px;
}

/* 3. Saving State (Đang lưu...) */
.editor-btn-save.is-saving {
  color: #fff;
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 2px 8px rgba(29, 78, 216, 0.3);
  cursor: wait;
  pointer-events: none;
}
.editor-btn-save .btn-spin-icon {
  animation: btnSpin .7s linear infinite;
}
@keyframes btnSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* 4. Saved Success State (Đã lưu thành công) */
.editor-btn-save.is-saved {
  color: #fff;
  background: linear-gradient(135deg, #10b981, #059669);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.4);
  animation: saveSuccessPop .3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
.editor-btn-save.is-saved .btn-kbd {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.editor-btn-save.is-saved .btn-success-icon {
  animation: checkPop .35s ease;
}
@keyframes saveSuccessPop {
  0% { transform: scale(0.96); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
@keyframes checkPop {
  0% { transform: scale(0.6); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* 5. Error State (Lỗi khi lưu) */
.editor-btn-save.is-error {
  color: #fff;
  background: linear-gradient(135deg, #ef4444, #dc2626);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.4);
  animation: btnShake .35s ease-in-out;
}
.editor-btn-save.is-error .btn-kbd {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}
@keyframes btnShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-3px); }
  40%, 80% { transform: translateX(3px); }
}

@keyframes savePulseGlow {
  0% { box-shadow: 0 2px 10px rgba(37, 99, 235, 0.35); }
  100% { box-shadow: 0 2px 14px rgba(37, 99, 235, 0.65); }
}

:root.dark .editor-btn-save.is-clean,
:root.dark .editor-btn-save:not(.has-changes):not(.is-saving):not(.is-saved):not(.is-error) {
  background: rgba(255, 255, 255, 0.04);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--color-text-soft);
}
:root.dark .editor-btn-save.is-clean:hover,
:root.dark .editor-btn-save:not(.has-changes):not(.is-saving):not(.is-saved):not(.is-error):hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: var(--color-text);
}
:root.dark .editor-btn-save.has-changes {
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  box-shadow: 0 2px 14px rgba(59, 130, 246, 0.45);
}

.btn-kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 10px;
  background: rgba(255, 255, 255, .25);
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, .3);
  color: #fff;
}

.editor-btn-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: transparent;
  border: 1px solid var(--color-border);
  border-radius: 7px;
  color: var(--color-text-soft);
  cursor: pointer;
  transition: all .15s ease;
}

.editor-btn-close:hover {
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.08);
}

/* Gutenberg-style Block Formatting Toolbar */
.editor-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 16px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: calc(var(--header-height) + 52px);
  z-index: 14;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  margin: 0 4px;
}

.toolbar-select {
  height: 28px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: 0;
  cursor: pointer;
}

.tool-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-width: 28px;
  height: 28px;
  padding: 0 7px;
  font-size: 12px;
  font-weight: 500;
  color: var(--color-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s ease;
}

.tool-btn svg {
  flex-shrink: 0;
  color: var(--color-text-soft);
  transition: color .15s ease;
}

.tool-btn:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-border);
}

.tool-btn:hover svg {
  color: var(--color-text);
}

.tool-badge-h {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  padding: 0 4px;
  height: 17px;
  border-radius: 3px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-accent);
  line-height: 1;
}

.toolbar-stats {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--color-text-soft);
  font-family: ui-monospace, SFMono-Regular, monospace;
}

/* Editor Panes Container */
.editor-container {
  display: flex;
  flex: 1 1 auto;
  min-height: 600px;
  position: relative;
}

.editor-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Editor Modes (Blocks, Split, Code, Preview) */
.editor-container.blocks-mode .editor-blocks-pane {
  flex: 1 1 100%;
  display: flex;
}

.editor-container.blocks-mode .editor-code-pane,
.editor-container.blocks-mode .editor-preview-pane {
  display: none;
}

.editor-container.split-mode .editor-blocks-pane {
  flex: 1 1 50%;
  display: flex;
  border-right: 1px solid var(--color-border);
}

.editor-container.split-mode .editor-preview-pane {
  flex: 1 1 50%;
  display: flex;
}

.editor-container.split-mode .editor-code-pane {
  display: none;
}

.editor-container.code-mode .editor-code-pane {
  flex: 1 1 100%;
  display: flex;
}

.editor-container.code-mode .editor-blocks-pane,
.editor-container.code-mode .editor-preview-pane {
  display: none;
}

.editor-container.preview-mode .editor-preview-pane {
  flex: 1 1 100%;
  display: flex;
}

.editor-container.preview-mode .editor-blocks-pane,
.editor-container.preview-mode .editor-code-pane {
  display: none;
}

/* Code Editor Textarea */
.editor-textarea-wrap {
  flex: 1 1 auto;
  position: relative;
  display: flex;
}

#editor-textarea {
  width: 100%;
  min-height: 540px;
  padding: 20px 24px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 13.5px;
  line-height: 1.68;
  color: var(--color-text);
  background: var(--color-bg);
  border: 0;
  outline: 0;
  resize: vertical;
  tab-size: 2;
  white-space: pre-wrap;
  word-break: break-word;
}

.editor-pane-footer {
  display: flex;
  justify-content: space-between;
  padding: 6px 16px;
  font-size: 11px;
  color: var(--color-text-soft);
  background: var(--color-surface-subtle);
  border-top: 1px solid var(--color-border);
}

/* Preview Pane */
.editor-preview-pane {
  background: var(--color-bg);
  overflow-y: auto;
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 24px;
  background: var(--color-surface-subtle);
  border-bottom: 1px solid var(--color-border);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-text-soft);
}

.preview-badge {
  font-size: 10px;
  padding: 2px 6px;
  background: color-mix(in srgb, var(--color-accent) 20%, transparent);
  color: var(--color-accent);
  border-radius: 10px;
}

.preview-content {
  padding: 24px 32px 60px;
}

/* Inspector Drawer (WordPress Right Sidebar) */
.editor-inspector {
  width: 290px;
  flex-shrink: 0;
  border-left: 1px solid var(--color-border);
  background: var(--color-surface);
  display: flex;
  flex-direction: column;
}

.editor-inspector.collapsed {
  display: none;
}

.inspector-tabs {
  display: flex;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
}

.inspector-tab {
  flex: 1;
  padding: 10px;
  font-size: 12px;
  font-weight: 650;
  color: var(--color-text-soft);
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all .15s ease;
}

.inspector-tab.active {
  color: var(--color-text);
  border-bottom-color: var(--color-accent);
  background: var(--color-surface);
}

.inspector-tab-content {
  display: none;
  padding: 16px;
  overflow-y: auto;
}

.inspector-tab-content.active {
  display: block;
}

.inspector-field {
  margin-bottom: 14px;
}

.inspector-field label {
  display: block;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-text-soft);
  margin-bottom: 5px;
}

.inspector-field input {
  width: 100%;
  padding: 7px 10px;
  font-size: 12.5px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  outline: 0;
}

.inspector-field input:focus {
  border-color: var(--color-accent);
}

.inspector-field input.input-readonly {
  background: var(--color-surface-subtle);
  color: var(--color-text-soft);
  font-family: ui-monospace, monospace;
  font-size: 11.5px;
}

/* Inspector Stats Box */
.inspector-stats-box {
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin-bottom: 16px;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: var(--color-text-soft);
  padding: 3px 0;
}

.stat-row strong {
  color: var(--color-text);
}

.inspector-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.inspector-action-btn {
  width: 100%;
  padding: 7px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text);
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: center;
  transition: all .15s ease;
}

.inspector-action-btn:hover {
  background: var(--color-surface);
  border-color: #92949a;
}

.inspector-action-btn.danger {
  color: #ef4444;
  border-color: color-mix(in srgb, #ef4444 30%, transparent);
}

.inspector-action-btn.danger:hover {
  background: #fef2f2;
  border-color: #ef4444;
}

:root.dark .inspector-action-btn.danger:hover {
  background: #2b1111;
}

/* Block Cards Inserter (Sidebar Library) */
.library-guide {
  font-size: 11px;
  color: var(--color-text-soft);
  margin-bottom: 10px;
  padding: 6px 10px;
  background: var(--color-surface-subtle);
  border-radius: var(--radius-sm);
  border: 1px dashed var(--color-border);
}

.block-cards-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.block-card {
  padding: 10px 12px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  cursor: grab;
  transition: all .15s ease;
  user-select: none;
}

.block-card:active {
  cursor: grabbing;
}

.block-card:hover {
  border-color: var(--color-accent);
  background: var(--color-surface);
  transform: translateY(-1px);
  box-shadow: 0 3px 8px rgb(0 0 0 / .07);
}

.block-card-title {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--color-text);
  margin-bottom: 2px;
}

.block-card-title svg {
  flex-shrink: 0;
  color: var(--color-accent);
}

.block-card-desc {
  font-size: 11px;
  color: var(--color-text-soft);
  line-height: 1.4;
}

/* ==========================================================
   GITBOOK DOCUMENT BLOCK EDITOR CANVAS & STYLES
   ========================================================== */
.editor-blocks-pane {
  background: var(--color-bg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.blocks-canvas-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 32px 64px 140px;
  scroll-behavior: smooth;
}

.gb-document-canvas {
  max-width: 820px;
  margin: 0 auto;
  width: 100%;
  position: relative;
  min-height: 480px;
}

/* Document Title (Large H1 like GitBook) */
.gb-title-section {
  margin-bottom: 28px;
}

.gb-doc-title-input {
  width: 100%;
  font-size: 36px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--color-text);
  background: transparent;
  border: none;
  outline: none;
  padding: 4px 0;
  line-height: 1.25;
  font-family: inherit;
  transition: opacity .15s;
}

.gb-doc-title-input::placeholder {
  color: color-mix(in srgb, var(--color-text-soft) 50%, transparent);
}

.gb-canvas-hint {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
  border: 1px dashed color-mix(in srgb, var(--color-accent) 25%, transparent);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--color-text-soft);
  margin-top: 10px;
}

.gb-canvas-hint kbd {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 11px;
  font-family: monospace;
}

.gb-gutter-preview {
  display: inline-block;
  padding: 0 4px;
  background: color-mix(in srgb, var(--color-accent) 15%, transparent);
  border-radius: 3px;
  color: var(--color-accent);
  font-weight: bold;
}

/* Blocks Container */
.gb-blocks-container {
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
  min-height: 200px;
}

.gb-blocks-container:empty::after {
  content: "Tài liệu trống. Bấm vào đây hoặc gõ '/' để bắt đầu viết nội dung...";
  display: block;
  padding: 40px 20px;
  color: var(--color-text-soft);
  font-size: 14.5px;
  text-align: center;
  border: 1.5px dashed var(--color-border);
  border-radius: 8px;
}

/* Individual GitBook Block Item */
.gb-block {
  position: relative;
  border-radius: 5px;
  transition: background .12s ease;
  min-height: 32px;
}

.gb-block.is-dragging {
  opacity: 0.3 !important;
}

/* Gutter on the left (-54px) with continuous zero-gap hit area */
.gb-gutter {
  position: absolute;
  left: -54px;
  width: 54px;
  top: 0;
  height: 100%;
  min-height: 32px;
  display: flex !important;
  flex-direction: row !important;
  flex-wrap: nowrap !important;
  align-items: flex-start !important;
  justify-content: flex-end !important;
  padding-top: 5px;
  padding-right: 6px;
  gap: 2px !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  user-select: none;
  z-index: 25;
  box-sizing: border-box;
}

/* Invisible bridge so moving cursor between block and gutter NEVER loses hover */
.gb-gutter::before {
  content: "";
  position: absolute;
  top: -10px;
  bottom: -10px;
  left: -20px;
  right: 0;
  pointer-events: auto;
  z-index: -1;
}

.gb-block:hover>.gb-gutter,
.gb-block.gb-hovered>.gb-gutter,
.gb-block.active>.gb-gutter,
.gb-block.menu-open>.gb-gutter,
.gb-block.slash-open>.gb-gutter,
.gb-gutter:hover {
  opacity: 1 !important;
  pointer-events: auto !important;
}

/* Heading vertical alignment offsets for gutter */
.gb-block-h1>.gb-gutter {
  padding-top: 12px;
}

.gb-block-h2>.gb-gutter {
  padding-top: 8px;
}

.gb-block-h3>.gb-gutter {
  padding-top: 6px;
}

.gb-gutter-btn {
  width: 22px !important;
  height: 22px !important;
  min-width: 22px !important;
  padding: 0 !important;
  margin: 0 !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  flex-shrink: 0 !important;
  border-radius: 6px;
  border: none !important;
  background: transparent;
  color: var(--color-text-soft);
  cursor: pointer;
  transition: all .16s ease;
  box-sizing: border-box;
  line-height: 1;
}

.gb-gutter-btn svg {
  display: block;
  pointer-events: none;
}

.gb-btn-add {
  border-radius: 5px !important;
  background: transparent !important;
  border: 1px solid transparent !important;
  color: var(--color-text-soft) !important;
  box-shadow: none !important;
  transform: none !important;
}

.gb-btn-add:hover {
  background: var(--color-surface) !important;
  border-color: var(--color-border) !important;
  color: var(--color-text) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08) !important;
  transform: none !important;
}

.gb-btn-add:active {
  transform: scale(0.92) !important;
}

.gb-drag-handle {
  border-radius: 5px !important;
  cursor: grab;
  border: 1px solid transparent !important;
}

.gb-drag-handle:hover {
  background: var(--color-surface) !important;
  border-color: var(--color-border) !important;
  color: var(--color-text) !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.gb-drag-handle:active {
  cursor: grabbing;
}

/* GitBook Block Content Elements */
.gb-content {
  outline: none;
  word-break: break-word;
}

/* Paragraph */
.gb-paragraph {
  font-size: 15.5px;
  line-height: 1.76;
  color: var(--color-text);
  padding: 3px 4px;
  border-radius: 4px;
  min-height: 28px;
}

.gb-paragraph:empty::before {
  content: attr(placeholder);
  color: color-mix(in srgb, var(--color-text-soft) 55%, transparent);
  pointer-events: none;
}

/* Headings */
.gb-heading-h1 {
  font-size: 26px;
  font-weight: 750;
  color: var(--color-text);
  margin: 22px 0 8px;
  line-height: 1.3;
  letter-spacing: -0.02em;
  padding: 3px 4px;
}

.gb-heading-h2 {
  font-size: 21px;
  font-weight: 700;
  color: var(--color-text);
  margin: 18px 0 6px;
  line-height: 1.35;
  letter-spacing: -0.015em;
  padding: 3px 4px;
}

.gb-heading-h3 {
  font-size: 17.5px;
  font-weight: 650;
  color: var(--color-text);
  margin: 14px 0 4px;
  line-height: 1.4;
  padding: 3px 4px;
}

.gb-heading-h1:empty::before,
.gb-heading-h2:empty::before,
.gb-heading-h3:empty::before {
  content: attr(placeholder);
  color: color-mix(in srgb, var(--color-text-soft) 50%, transparent);
  pointer-events: none;
}

/* GitBook Callout / Hint Box */
.gb-callout {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  border-radius: 8px;
  border-left: 3.5px solid var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 8%, var(--color-surface));
  margin: 10px 0;
  box-shadow: 0 1px 2px rgb(0 0 0 / .03);
}

.gb-callout.callout-warning {
  border-left-color: #f59e0b;
  background: color-mix(in srgb, #f59e0b 8%, var(--color-surface));
}

.gb-callout-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  user-select: none;
  cursor: pointer;
  flex-shrink: 0;
  margin-top: 3px;
  color: var(--color-accent);
  transition: transform .15s ease, color .15s ease;
}

.gb-callout.callout-warning .gb-callout-icon {
  color: #f59e0b;
}

.gb-callout-icon:hover {
  transform: scale(1.12);
}

.gb-callout-body {
  flex: 1;
  outline: none;
  font-size: 14.5px;
  line-height: 1.68;
  color: var(--color-text);
}

.gb-callout-body:empty::before {
  content: attr(placeholder);
  color: color-mix(in srgb, var(--color-text-soft) 60%, transparent);
  pointer-events: none;
}

/* GitBook Code Block */
.gb-code-wrap {
  border: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
  border-radius: 8px;
  overflow: hidden;
  margin: 10px 0;
}

.gb-code-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: color-mix(in srgb, var(--color-surface-subtle) 75%, black);
  border-bottom: 1px solid var(--color-border);
}

.gb-code-title {
  font-size: 12px;
  font-family: monospace;
  background: transparent;
  border: none;
  outline: none;
  color: var(--color-text);
  font-weight: 600;
}

.gb-code-lang {
  font-size: 11px;
  padding: 2px 6px;
  border: 1px solid var(--color-border);
  border-radius: 4px;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
}

.gb-code-textarea {
  width: 100%;
  min-height: 80px;
  padding: 12px 14px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13.5px;
  line-height: 1.62;
  background: transparent;
  border: none;
  color: var(--color-text);
  outline: none;
  resize: vertical;
  white-space: pre;
  tab-size: 2;
}

/* GitBook Table */
.gb-table-wrap {
  margin: 12px 0;
  overflow-x: auto;
}

.gb-table-toolbar {
  display: flex;
  gap: 6px;
  margin-bottom: 6px;
}

.btn-gb-table {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  font-size: 11px;
  border: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
  border-radius: 4px;
  color: var(--color-text-soft);
  cursor: pointer;
  transition: all .15s;
}

.btn-gb-table:hover {
  border-color: var(--color-accent);
  color: var(--color-text);
}

.gb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.gb-table th,
.gb-table td {
  border: 1px solid var(--color-border);
  padding: 9px 12px;
  text-align: left;
}

.gb-table th {
  background: var(--color-surface-subtle);
  font-weight: 650;
}

.gb-table [contenteditable] {
  outline: none;
  min-height: 20px;
}

/* GitBook List */
.gb-list-wrap {
  padding-left: 20px;
  margin: 4px 0;
}

.gb-list-item-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 2px 0;
}

.gb-list-bullet {
  color: var(--color-accent);
  font-weight: 700;
  width: 14px;
  flex-shrink: 0;
  user-select: none;
}

.gb-list-input {
  flex: 1;
  font-size: 15px;
  line-height: 1.6;
  border: none;
  outline: none;
  background: transparent;
  color: var(--color-text);
  padding: 2px 0;
}

.btn-gb-list-rm {
  border: none;
  background: transparent;
  color: var(--color-text-soft);
  cursor: pointer;
  font-size: 12px;
  opacity: 0;
  transition: opacity .15s;
}

.gb-list-item-row:hover .btn-gb-list-rm {
  opacity: 1;
}

/* GitBook Image Block in Editor */
.gb-image-wrap {
  margin: 18px 0;
  text-align: center;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.gb-image-frame-container {
  position: relative;
  display: inline-block;
  max-width: 100%;
}

.gb-image-frame {
  max-width: 100%;
  border-radius: 8px;
  overflow: hidden;
  border: 1.5px solid var(--color-border);
  display: inline-flex;
  justify-content: center;
  align-items: center;
  background: var(--color-surface-subtle);
  position: relative;
  transition: width 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.05);
}

.gb-image-frame:hover {
  border-color: var(--color-accent);
}

.gb-image-frame img {
  max-width: 100%;
  max-height: 520px;
  width: auto;
  height: auto;
  object-fit: contain;
  display: block;
}

.gb-image-frame.has-custom-width {
  display: block;
}

.gb-image-frame.has-custom-width img {
  width: 100%;
  height: auto;
}

/* Interactive Drag Resize Handle (Bottom-Right corner) */
.gb-image-resize-handle {
  position: absolute;
  right: -7px;
  bottom: -7px;
  width: 20px;
  height: 20px;
  background: var(--color-accent);
  color: #fff;
  border: 2px solid #fff;
  border-radius: 50%;
  cursor: nwse-resize;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  user-select: none;
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
  z-index: 10;
}

.gb-image-frame-container:hover .gb-image-resize-handle,
.gb-image-resize-handle.active {
  opacity: 1;
  transform: scale(1.15);
}

/* Image Size & Alignment Toolbar */
.gb-image-toolbar {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  padding: 4px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.02);
  flex-wrap: wrap;
  justify-content: center;
  transition: all 0.15s ease;
}

:root.dark .gb-image-toolbar {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
}

.gb-image-btn-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: var(--color-surface-subtle);
  padding: 2px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.btn-img-size,
.btn-img-align {
  padding: 3.5px 8px;
  font-size: 11.5px;
  font-weight: 550;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--color-text-soft);
  cursor: pointer;
  transition: all 0.12s ease;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  user-select: none;
  font-family: inherit;
}

.btn-img-size:hover,
.btn-img-align:hover {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.04);
}

:root.dark .btn-img-size:hover,
:root.dark .btn-img-align:hover {
  background: rgba(255, 255, 255, 0.06);
}

.btn-img-size.active,
.btn-img-align.active {
  background: var(--color-surface);
  color: var(--color-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

:root.dark .btn-img-size.active,
:root.dark .btn-img-align.active {
  background: var(--color-surface-subtle);
  color: var(--color-accent);
}

.gb-image-divider {
  width: 1px;
  height: 16px;
  background: var(--color-border);
}

.gb-image-slider-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.gb-image-slider {
  width: 90px;
  height: 4px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.gb-image-size-badge {
  font-size: 11px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--color-text-soft);
  min-width: 42px;
  text-align: right;
  font-weight: 500;
}

.gb-image-caption-input {
  display: block;
  width: min(540px, 90%);
  margin: 8px auto 0;
  text-align: center;
  font-size: 12.5px;
  color: var(--color-text-soft);
  border: none;
  border-bottom: 1px dashed transparent;
  outline: none;
  background: transparent;
  padding: 4px 8px;
  transition: all .15s ease;
  font-family: inherit;
}

.gb-image-caption-input:hover,
.gb-image-caption-input:focus {
  border-bottom-color: var(--color-border);
  color: var(--color-text);
}

.gb-image-url-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
}

.gb-image-url-input {
  width: 280px;
  font-size: 12px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-subtle);
  color: var(--color-text);
  outline: none;
  transition: all 0.15s ease;
  font-family: inherit;
}

.gb-image-url-input:focus {
  border-color: var(--color-accent);
  background: var(--color-surface);
  box-shadow: 0 0 0 2px var(--color-accent-soft);
}

/* GitBook Embed & Video Cards */
.gb-embed-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  margin: 14px 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.gb-embed-card:hover {
  border-color: var(--color-accent);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.gb-embed-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
  min-width: 0;
}

.gb-embed-icon {
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: color-mix(in srgb, var(--color-accent) 12%, var(--color-surface));
  color: var(--color-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.gb-embed-meta {
  flex: 1;
  min-width: 0;
}

.gb-embed-title {
  font-size: 14px;
  font-weight: 650;
  color: var(--color-text);
  margin-bottom: 3px;
}

.gb-embed-url-input {
  width: 100%;
  font-size: 12.5px;
  color: var(--color-text-soft);
  background: transparent;
  border: none;
  border-bottom: 1px dashed transparent;
  outline: none;
  padding: 2px 0;
  font-family: inherit;
}

.gb-embed-url-input:focus {
  border-bottom-color: var(--color-accent);
  color: var(--color-text);
}

.gb-embed-open-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 550;
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 10%, var(--color-surface));
  border-radius: var(--radius-sm);
  text-decoration: none;
  flex-shrink: 0;
  transition: background .15s ease;
}

.gb-embed-open-btn:hover {
  background: color-mix(in srgb, var(--color-accent) 20%, var(--color-surface));
}

/* GitBook Arcade & App Badges Embed Cards */
.gb-arcade-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  margin: 10px 0;
}

.gb-arcade-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.gb-arcade-play {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* GitBook Columns (Multi-column layout) */
.doc-columns-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin: 20px 0;
  padding: 18px 20px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.doc-column {
  min-width: 0;
}

.doc-column> :first-child {
  margin-top: 0;
}

.doc-column> :last-child {
  margin-bottom: 0;
}

/* Editor Visual Columns Canvas */
.gb-columns-container {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  width: 100%;
  margin: 6px 0;
  padding: 12px 14px;
  background: var(--color-surface-subtle);
  border: 1px dashed var(--color-border);
  border-radius: 8px;
}

.gb-column-item {
  min-width: 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  padding: 10px 12px;
}

.gb-column-header {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--color-text-soft);
  margin-bottom: 8px;
  letter-spacing: .04em;
}

.gb-column-inner {
  min-height: 48px;
  outline: none;
  font-size: 14.5px;
  line-height: 1.6;
}

.gb-arcade-inputs {
  display: flex;
  gap: 8px;
}

.gb-divider-line {
  height: 1px;
  background: var(--color-border);
  margin: 20px 0;
}

/* Glowing Blue Drop Line for Drag and Drop */
.gb-drop-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 3px;
  background: #2563eb;
  border-radius: 3px;
  box-shadow: 0 0 10px rgba(37, 99, 235, 0.7);
  pointer-events: none;
  z-index: 50;
  transition: top .08s ease;
}

/* Canvas Footer Button */
.gb-canvas-footer {
  margin-top: 32px;
  display: flex;
  justify-content: center;
}

.gb-bottom-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1.5px dashed var(--color-border);
  background: var(--color-surface);
  border-radius: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--color-text-soft);
  cursor: pointer;
  transition: all .15s ease;
}

.gb-bottom-add-btn:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: color-mix(in srgb, var(--color-accent) 6%, var(--color-surface));
  transform: translateY(-1px);
}

/* Floating Slash Command Menu (GitBook / Notion style) */
.gb-slash-menu {
  position: fixed;
  width: 290px;
  max-height: 380px;
  background: #1a1a20;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 2200;
  overflow-y: auto;
  padding: 6px;
  backdrop-filter: blur(20px);
  animation: gbMenuIn .12s cubic-bezier(0.16, 1, 0.3, 1);
}

:root:not(.dark) .gb-slash-menu {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.15);
}

.gb-slash-header {
  position: sticky;
  top: -6px;
  background: inherit;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 10px 6px;
  margin: -6px -6px 4px -6px;
  font-size: 11px;
  font-weight: 650;
  color: #71717a;
  letter-spacing: .02em;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(20px);
}

:root:not(.dark) .gb-slash-header {
  color: #64748b;
  border-bottom-color: rgba(0, 0, 0, 0.06);
}

.gb-slash-header kbd {
  font-size: 10.5px;
  color: #71717a;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

:root:not(.dark) .gb-slash-header kbd {
  color: #94a3b8;
}

.gb-slash-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.gb-slash-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: all .12s ease;
  color: #e4e4e7;
}

:root:not(.dark) .gb-slash-item {
  color: #1e293b;
}

.gb-slash-item:hover,
.gb-slash-item.selected {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

:root:not(.dark) .gb-slash-item:hover,
:root:not(.dark) .gb-slash-item.selected {
  background: #f1f5f9;
  color: #0f172a;
}

.gb-slash-icon {
  width: 18px;
  height: 18px;
  background: transparent !important;
  border: none !important;
  border-radius: 0 !important;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a1a1aa;
  flex-shrink: 0;
  transition: color .12s ease;
}

:root:not(.dark) .gb-slash-icon {
  color: #64748b;
}

.gb-slash-item:hover .gb-slash-icon,
.gb-slash-item.selected .gb-slash-icon {
  color: #ffffff;
}

:root:not(.dark) .gb-slash-item:hover .gb-slash-icon,
:root:not(.dark) .gb-slash-item.selected .gb-slash-icon {
  color: #0f172a;
}

.gb-slash-icon-svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}

.gb-slash-badge-h {
  display: inline-block;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: inherit;
  line-height: 1;
  width: 18px;
  text-align: center;
}

.gb-slash-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.gb-slash-text strong {
  font-size: 13px;
  font-weight: 500;
  line-height: 1.35;
}

.gb-slash-text small {
  font-size: 11px;
  color: #71717a;
  line-height: 1.3;
}

:root:not(.dark) .gb-slash-text small {
  color: #64748b;
}

/* Floating Block Context Menu (GitBook "Turn into" Menu) */
.gb-block-menu {
  position: absolute;
  width: 224px;
  background: #1a1a20;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.05);
  z-index: 2200;
  padding: 6px;
  backdrop-filter: blur(20px);
  user-select: none;
  animation: gbMenuIn .12s cubic-bezier(0.16, 1, 0.3, 1);
}

:root:not(.dark) .gb-block-menu {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.15);
}

@keyframes gbMenuIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.gb-menu-section-title {
  font-size: 11px;
  font-weight: 650;
  color: #71717a;
  padding: 6px 10px 4px;
  letter-spacing: .02em;
}

:root:not(.dark) .gb-menu-section-title {
  color: #64748b;
}

.gb-menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 450;
  color: #e4e4e7;
  text-align: left;
  transition: all .12s ease;
  line-height: 1.4;
}

:root:not(.dark) .gb-menu-item {
  color: #1e293b;
}

.gb-menu-item:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

:root:not(.dark) .gb-menu-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.gb-menu-item.active {
  color: #ffffff;
}

:root:not(.dark) .gb-menu-item.active {
  color: #0284c7;
}

.gb-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #f87171;
}

.gb-menu-item:disabled,
.gb-menu-item.disabled {
  opacity: 0.35;
  cursor: not-allowed !important;
  pointer-events: none;
}

.gb-menu-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.gb-menu-icon {
  flex-shrink: 0;
  color: #a1a1aa;
}

.gb-menu-item:hover .gb-menu-icon {
  color: #ffffff;
}

:root:not(.dark) .gb-menu-icon {
  color: #64748b;
}

:root:not(.dark) .gb-menu-item:hover .gb-menu-icon {
  color: #0f172a;
}

.gb-menu-badge-h {
  display: inline-block;
  font-size: 12.5px;
  font-weight: 700;
  width: 16px;
  color: #a1a1aa;
  letter-spacing: -0.02em;
}

.gb-menu-item:hover .gb-menu-badge-h {
  color: #ffffff;
}

.gb-menu-check {
  font-size: 13px;
  font-weight: 700;
  color: #60a5fa;
  opacity: 0;
  transform: scale(0.8);
  transition: all .12s ease;
}

.gb-menu-item.active .gb-menu-check {
  opacity: 1;
  transform: scale(1);
}

.gb-menu-arrow {
  font-size: 11px;
  color: #71717a;
}

.gb-menu-kbd {
  font-size: 10.5px;
  color: #71717a;
  font-family: ui-monospace, SFMono-Regular, monospace;
}

.gb-menu-separator {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
  margin: 5px 4px;
}

:root:not(.dark) .gb-menu-separator {
  background: rgba(0, 0, 0, 0.08);
}

.gb-menu-more-blocks {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-left: 12px;
  margin: 3px 0;
  border-left: 2px solid rgba(255, 255, 255, 0.1);
}

.gb-menu-item.sub {
  font-size: 12px;
  padding: 5px 8px;
}

/* Focused / Active Block in Canvas */
.gb-block {
  position: relative;
  border-radius: 6px;
  transition: background .12s ease, outline .12s ease;
  min-height: 32px;
  padding: 2px 4px;
}

.gb-block:hover,
.gb-block.gb-hovered,
.gb-block.menu-open,
.gb-block.focused {
  background: rgba(255, 255, 255, 0.035);
}

:root:not(.dark) .gb-block:hover,
:root:not(.dark) .gb-block.gb-hovered,
:root:not(.dark) .gb-block.menu-open,
:root:not(.dark) .gb-block.focused {
  background: rgba(0, 0, 0, 0.02);
}

.gb-block.menu-open {
  outline: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.05);
}

/* Empty Paragraph Row & Quick Actions (Image, Video, Code, List) */
.gb-paragraph-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: relative;
  width: 100%;
}

.gb-paragraph-row .gb-paragraph {
  flex: 1;
  min-width: 0;
}

.gb-quick-actions {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s ease;
  flex-shrink: 0;
}

.gb-block:hover .gb-quick-actions,
.gb-block.focused .gb-quick-actions,
.gb-paragraph-row:hover .gb-quick-actions {
  opacity: 1;
  pointer-events: auto;
}

.gb-quick-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: #9ca3af;
  cursor: pointer;
  transition: all .15s ease;
}

:root:not(.dark) .gb-quick-btn {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #64748b;
}

.gb-quick-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

:root:not(.dark) .gb-quick-btn:hover {
  background: #e2e8f0;
  color: #0f172a;
  border-color: #cbd5e1;
}

.gb-quick-btn .gb-tooltip {
  position: absolute;
  bottom: calc(100% + 7px);
  left: 50%;
  transform: translateX(-50%) translateY(2px);
  background: #ffffff;
  color: #09090b;
  font-size: 11.5px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 5px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
  z-index: 500;
  transition: all .15s cubic-bezier(0.16, 1, 0.3, 1);
}

:root:not(.dark) .gb-quick-btn .gb-tooltip {
  background: #0f172a;
  color: #ffffff;
}

.gb-quick-btn:hover .gb-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

/* Rich Video Block Widget */
.gb-video-card {
  margin: 14px 0;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
  transition: border-color .15s ease;
}

.gb-video-card:hover {
  border-color: var(--color-accent);
}

.gb-video-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--color-surface-subtle);
  border-bottom: 1px solid var(--color-border);
}

.gb-video-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 650;
  color: var(--color-text);
}

.gb-video-preview-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16/9;
  max-height: 420px;
  background: #09090b;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gb-video-preview-wrap iframe,
.gb-video-preview-wrap video {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.gb-video-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #71717a;
  text-align: center;
  padding: 20px;
}

.gb-video-placeholder-icon {
  font-size: 36px;
}

.gb-video-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 14px;
  background: var(--color-surface);
}

.gb-video-url-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gb-video-url-input {
  flex: 1;
  font-size: 12.5px;
  padding: 6px 10px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface-subtle);
  color: var(--color-text);
  outline: none;
}

.gb-video-url-input:focus {
  border-color: var(--color-accent);
}

.gb-video-caption-input {
  width: 100%;
  font-size: 12px;
  border: none;
  background: transparent;
  color: var(--color-text-soft);
  outline: none;
  padding: 2px 0;
}

.gb-video-caption-input:focus {
  color: var(--color-text);
}

.btn-upload-media {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 550;
  border-radius: 6px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: all .15s ease;
  flex-shrink: 0;
}

.btn-upload-media:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-accent);
  color: var(--color-accent);
}

/* Modals */

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(15, 23, 42, 0.48);
  backdrop-filter: blur(8px) saturate(160%);
  -webkit-backdrop-filter: blur(8px) saturate(160%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: backdropFadeIn .2s ease-out;
}

@keyframes backdropFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.modal-card {
  width: 100%;
  max-width: 520px;
  background: var(--color-surface);
  border: 1px solid color-mix(in srgb, var(--color-border) 80%, transparent);
  border-radius: 16px;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalIn .24s cubic-bezier(0.16, 1, 0.3, 1);
}

:root.dark .modal-card {
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 30px 80px -15px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.modal-card.modal-large {
  max-width: 820px;
  max-height: 86vh;
}

@keyframes modalIn {
  from {
    opacity: 0;
    transform: scale(.95) translateY(10px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid var(--color-border);
  gap: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.3;
}

.modal-header-info {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
}

.modal-icon-badge {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  color: var(--color-accent);
  border: 1px solid color-mix(in srgb, var(--color-accent) 22%, transparent);
  flex-shrink: 0;
}

.modal-subtitle {
  margin: 3px 0 0 0;
  font-size: 12.5px;
  color: var(--color-text-soft);
  font-weight: 400;
  line-height: 1.4;
}

.modal-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.modal-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  color: var(--color-text-soft);
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  font-size: 15px;
  color: var(--color-text-soft);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background .15s, color .15s, transform .15s;
}

.modal-close:hover {
  color: var(--color-text);
  background: var(--color-surface-subtle);
  transform: scale(1.06);
}

.modal-body {
  padding: 22px 24px;
  overflow-y: auto;
}

.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--color-text);
  margin-bottom: 7px;
}

.form-group .required {
  color: #ef4444;
}

.form-group input,
.form-group select {
  width: 100%;
  height: 42px;
  padding: 0 13px;
  font-size: 13.5px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  outline: 0;
  transition: border-color .15s, box-shadow .15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-accent) 18%, transparent);
}

.input-prefix-group {
  display: flex;
  align-items: stretch;
}

.input-prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-right: 0;
  border-radius: 8px 0 0 8px;
  font-size: 12.5px;
  color: var(--color-text-soft);
  font-family: ui-monospace, monospace;
}

.input-prefix-group input {
  border-radius: 0 8px 8px 0;
}

.form-hint {
  display: block;
  font-size: 11.5px;
  color: var(--color-text-soft);
  margin-top: 5px;
  line-height: 1.4;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-subtle);
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 16px;
  font-size: 13px;
  font-weight: 550;
  color: var(--color-text);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s, border-color .15s, transform .15s, box-shadow .15s;
}

.btn-secondary:hover {
  background: var(--color-surface-subtle);
  border-color: color-mix(in srgb, var(--color-border) 75%, var(--color-text));
  transform: translateY(-1px);
}

.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 38px;
  padding: 0 18px;
  font-size: 13px;
  font-weight: 650;
  color: #fff;
  background: #171717;
  border: 1px solid #171717;
  border-radius: 8px;
  cursor: pointer;
  box-shadow: 0 2px 6px -1px rgba(0, 0, 0, 0.2);
  transition: background .15s, transform .15s, box-shadow .15s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px -2px rgba(0, 0, 0, 0.28);
}

:root.dark .btn-primary {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: #111;
}

:root.dark .btn-primary:hover {
  box-shadow: 0 4px 16px -2px color-mix(in srgb, var(--color-accent) 45%, transparent);
}

/* Book Manage List */
.book-manage-toolbar {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
}

.book-search-input {
  flex: 1;
  padding: 7px 12px;
  font-size: 13px;
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.book-chapters-list {
  max-height: 440px;
  overflow-y: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface-subtle);
}

.book-chapter-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
  transition: background .15s ease;
}

.book-chapter-item:last-child {
  border-bottom: 0;
}

.book-chapter-item:hover {
  background: var(--color-surface-subtle);
}

.book-chapter-info {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.book-chapter-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
}

.book-chapter-path {
  font-size: 11px;
  color: var(--color-text-soft);
  font-family: ui-monospace, monospace;
}

.book-chapter-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.btn-action-icon {
  padding: 3px 7px;
  font-size: 11.5px;
  font-weight: 600;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  color: var(--color-text);
  cursor: pointer;
}

.btn-action-icon:hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
}

.btn-action-icon.danger:hover {
  border-color: #ef4444;
  color: #ef4444;
}

/* Floating Toast Notification */
.editor-toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  background: #171717;
  color: #fff;
  border-radius: var(--radius-md);
  box-shadow: 0 8px 30px rgb(0 0 0 / .28);
  font-size: 13px;
  font-weight: 600;
  animation: toastSlideUp .25s cubic-bezier(.22, .68, 0, 1);
}

:root.dark .editor-toast {
  background: #252b49;
  border: 1px solid var(--color-accent);
  color: #fff;
}

.editor-toast.toast-error {
  background: #dc2626;
}

.toast-icon {
  font-weight: 800;
}

@keyframes toastSlideUp {
  from {
    opacity: 0;
    transform: translateY(16px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Topbar Authentication & Profile Controls */
.retion-auth-container {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.retion-profile-wrapper {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

/* Header Login Button (.login-btn) */
.header-action-btn.login-btn {
  /* Inherits full .header-action-btn styles */
}

.header-action-btn.login-btn:hover {
  border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border));
  color: var(--color-accent);
  background: var(--color-accent-soft);
}



/* Profile Pill in Topbar */
.header-profile-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px 0 5px;
  background: color-mix(in srgb, var(--color-surface) 90%, transparent);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  cursor: pointer;
  transition: all .18s ease;
  box-shadow: var(--shadow-sm);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-sizing: border-box;
}

.header-profile-btn:hover,
.header-profile-btn.active {
  background: var(--color-surface-subtle);
  border-color: color-mix(in srgb, var(--color-accent) 45%, var(--color-border));
  transform: translateY(-1px);
}

.header-profile-name {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text);
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-avatar-circle {
  position: relative;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  overflow: visible;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.header-avatar-initials {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #ffffff;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.avatar-online-status {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 8.5px;
  height: 8.5px;
  border-radius: 50%;
  background: #10b981;
  border: 1.5px solid var(--color-surface);
  box-shadow: 0 0 4px rgba(16, 185, 129, 0.7);
}

.header-avatar-caret {
  color: var(--color-text-soft);
  transition: transform .18s ease;
}

.header-profile-btn.active .header-avatar-caret {
  transform: rotate(180deg);
}

/* Floating Profile Dropdown Card */
.profile-dropdown-card {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 1000;
  width: 290px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.22), 0 3px 10px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  animation: profileCardIn .18s cubic-bezier(.22, .68, 0, 1);
}

@keyframes profileCardIn {
  from {
    opacity: 0;
    transform: translateY(-6px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.profile-card-top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--color-surface-subtle);
}

.profile-large-avatar-wrap {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  flex-shrink: 0;
  cursor: pointer;
}

.profile-large-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
  display: block;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.1);
}

.profile-large-avatar-initials {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: linear-gradient(135deg, #2563eb 0%, #7c3aed 100%);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.avatar-upload-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  opacity: 0;
  cursor: pointer;
  transition: opacity .15s ease;
}

.profile-large-avatar-wrap:hover .avatar-upload-overlay {
  opacity: 1;
}

.profile-user-details {
  flex: 1;
  min-width: 0;
}

.profile-name-row {
  display: flex;
  align-items: center;
  gap: 5px;
}

.profile-display-name {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--color-text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-verified-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #3b82f6;
  color: #fff;
  font-size: 9px;
  font-weight: bold;
}

.profile-email {
  font-size: 11.5px;
  color: var(--color-text-soft);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}

.profile-badge-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 5px;
}

.profile-role-tag {
  font-size: 10px;
  font-weight: 650;
  padding: 1.5px 7px;
  background: rgba(59, 130, 246, 0.12);
  color: #2563eb;
  border-radius: 10px;
}

:root.dark .profile-role-tag {
  background: rgba(59, 130, 246, 0.22);
  color: #60a5fa;
}

.profile-status-tag {
  font-size: 10.5px;
  color: #10b981;
  font-weight: 550;
}

.profile-card-divider {
  height: 1px;
  background: var(--color-border);
}

.profile-card-menu {
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.profile-menu-action {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--color-text);
  text-align: left;
  cursor: pointer;
  transition: background .12s ease;
}

.profile-menu-action:hover {
  background: var(--color-surface-subtle);
}

.profile-action-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  flex-shrink: 0;
}

.profile-action-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.profile-action-text strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--color-text);
}

.profile-action-text small {
  font-size: 11px;
  color: var(--color-text-soft);
}

.profile-card-footer {
  padding: 8px 12px 10px;
  background: var(--color-surface-subtle);
  border-top: 1px solid var(--color-border);
}

.profile-logout-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  height: 36px;
  padding: 0 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text-soft);
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .18s ease;
  box-sizing: border-box;
}

.profile-logout-btn svg {
  flex-shrink: 0;
  color: var(--color-text-soft);
  transition: color .18s ease;
}

.profile-logout-btn:hover {
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.35);
  color: #dc2626;
  transform: translateY(-1px);
}

.profile-logout-btn:hover svg {
  color: #dc2626;
}

:root.dark .profile-logout-btn {
  background: var(--color-surface);
  border-color: var(--color-border);
}

:root.dark .profile-logout-btn:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(248, 113, 113, 0.4);
  color: #f87171;
}

:root.dark .profile-logout-btn:hover svg {
  color: #f87171;
}

/* Admin Login Modal (Modern Portal) */
.modal-card.modal-auth {
  max-width: 440px;
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 45px -10px rgba(0, 0, 0, 0.25), 0 0 1px 1px var(--color-border);
}

.auth-body {
  padding: 20px 24px 24px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 0;
}

.auth-form label {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text);
  letter-spacing: -0.01em;
}

.auth-form .required {
  color: #ef4444;
}

.auth-input-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.auth-field-icon {
  position: absolute;
  left: 12px;
  color: var(--color-text-soft);
  opacity: .75;
  pointer-events: none;
  transition: all .15s ease;
}

.auth-input-wrap input {
  width: 100%;
  padding-left: 38px !important;
  padding-right: 14px;
  height: 42px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: 13.5px;
  transition: all .18s ease;
  box-sizing: border-box;
}

.auth-input-wrap input:hover {
  border-color: rgba(37, 99, 235, 0.4);
}

.auth-input-wrap input:focus {
  border-color: var(--color-accent);
  background: var(--color-surface);
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.auth-input-wrap:focus-within .auth-field-icon {
  color: var(--color-accent);
  opacity: 1;
}

.token-input-wrap input {
  padding-right: 42px !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
  letter-spacing: 0.04em;
}

.btn-token-eye {
  position: absolute;
  right: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 0;
  cursor: pointer;
  padding: 6px;
  color: var(--color-text-soft);
  border-radius: var(--radius-sm);
  transition: all .15s ease;
}

.btn-token-eye:hover {
  color: var(--color-text);
  background: var(--color-surface-subtle);
}

.auth-options-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: -2px;
}

.auth-remember-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--color-text-soft);
  cursor: pointer;
  user-select: none;
}

.auth-remember-label input[type="checkbox"] {
  accent-color: var(--color-accent);
  cursor: pointer;
  width: 15px;
  height: 15px;
  margin: 0;
}

.auth-error {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 12.5px;
  font-weight: 550;
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: var(--radius-md);
  animation: fadeIn .18s ease-out;
}

:root.dark .auth-error {
  background: rgba(239, 68, 68, 0.12);
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.modal-footer.auth-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--color-border);
}

.modal-footer.auth-footer button {
  height: 38px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-weight: 600;
  font-size: 13px;
  border-radius: var(--radius-md);
}

/* Inspector Git Sync Card */
.inspector-sync-box {
  margin-top: 18px;
  padding: 14px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
}

.sync-box-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.sync-box-icon {
  font-size: 18px;
}

.sync-box-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--color-text);
}

.sync-box-sub {
  font-size: 10.5px;
  color: #059669;
  font-weight: 600;
}

:root.dark .sync-box-sub {
  color: #34d399;
}

.sync-box-desc {
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--color-text-soft);
  margin-bottom: 12px;
}

.sync-box-desc code {
  background: var(--color-bg);
  padding: 2px 4px;
  border-radius: 3px;
  border: 1px solid var(--color-border);
  font-size: 11px;
}

.inspector-action-btn.sync-btn {
  background: #0284c7;
  color: #fff;
  border-color: #0284c7;
  font-weight: 650;
  box-shadow: 0 2px 6px rgba(2, 132, 199, .2);
}

.inspector-action-btn.sync-btn:hover {
  background: #0369a1;
  border-color: #0369a1;
}

/* Email Input Wrap with Verified Tag */
.auth-email-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.auth-email-wrap input {
  padding-right: 110px !important;
  font-weight: 600;
}

.email-verified-tag {
  position: absolute;
  right: 8px;
  background: rgba(16, 185, 129, .15);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, .3);
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  pointer-events: none;
}

:root.dark .email-verified-tag {
  background: rgba(16, 185, 129, .25);
  color: #34d399;
}

/* Visibility Control: Hide Editing Interface When Not Logged In */
body:not(.is-author-logged-in) #btn-edit-mode,
body:not(.is-author-logged-in) .sidebar-author-bar,
body:not(.is-author-logged-in) #reader-edit-shortcut,
body:not(.is-author-logged-in) #reader-delete-shortcut,
body:not(.is-author-logged-in) #btn-book-quick-add,
body:not(.is-author-logged-in) #btn-book-git-sync,
body:not(.is-author-logged-in) #modal-book-manage,
body:not(.is-author-logged-in) #modal-add-page,
body:not(.is-author-logged-in) .book-chapter-actions [data-edit-doc] {
  display: none !important;
}

/* Nút đăng nhập: Mặc định ẩn hoàn toàn (khi load trang và cho độc giả vãng lai) */
#btn-header-login,
.header-action-btn.login-btn {
  display: none !important;
}

/* Chỉ hiện khi vào link Admin (?admin, #admin, /admin) VÀ chưa đăng nhập */
body.is-admin-portal:not(.is-author-logged-in) #btn-header-login,
body.is-admin-portal:not(.is-author-logged-in) .header-action-btn.login-btn {
  display: inline-flex !important;
}

body:not(.is-author-logged-in) .retion-profile-wrapper {
  display: none !important;
}

/* GitBook-style Pages Header */
.sidebar-pages-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px 6px;
  margin-top: 4px;
}

.pages-header-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-soft);
  text-transform: none;
  letter-spacing: .02em;
}

.pages-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.sidebar-icon-add-btn,
.sidebar-icon-manage-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--color-text-soft);
  cursor: pointer;
  transition: all .15s ease;
}

.sidebar-icon-add-btn:hover,
.sidebar-icon-manage-btn:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-border);
  color: var(--color-text);
}

/* Nav Item Hover Add Button */
.nav-item-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.nav-item-wrap .nav-item {
  flex: 1;
}

.nav-item-tools {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  align-items: center;
  gap: 3px;
  z-index: 5;
}

body.is-author-logged-in.in-editor-mode .nav-item-wrap:hover .nav-item-tools,
body.is-author-logged-in.in-editor-mode .nav-item-wrap .nav-item.active~.nav-item-tools {
  display: flex;
}

.nav-inline-add-btn,
.nav-inline-more-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
  transition: all .12s ease;
}

.nav-inline-add-btn:hover {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}

.nav-inline-more-btn {
  font-size: 14px;
  line-height: 1;
}

.nav-inline-more-btn:hover {
  background: var(--color-surface-subtle);
  border-color: var(--color-text-soft);
  color: var(--color-text);
}

/* Nav Add Indicator Line with Circle Plus Button (Matching Screenshot) */
.nav-add-divider {
  position: relative;
  display: flex;
  align-items: center;
  height: 14px;
  margin: -2px 0;
  padding: 0 8px 0 14px;
  z-index: 10;
  cursor: pointer;
}

.nav-add-line {
  position: absolute;
  left: 28px;
  right: 12px;
  height: 1px;
  background: #3b82f6;
  opacity: 0.85;
  pointer-events: none;
}

.nav-circle-add-btn {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  border: 1.5px solid #3b82f6;
  color: #1d4ed8;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
  transition: transform .15s ease, background .15s ease;
  padding: 0;
}

:root.dark .nav-circle-add-btn {
  background: #1e293b;
  border-color: #60a5fa;
  color: #93c5fd;
}

.nav-add-divider:hover .nav-circle-add-btn {
  transform: scale(1.15);
  background: #3b82f6;
  color: #fff;
}

:root.dark .nav-add-divider:hover .nav-circle-add-btn {
  background: #3b82f6;
  color: #fff;
}

/* Floating GitBook Dropdown Menu & Context Menu */
.gitbook-add-menu {
  position: fixed;
  z-index: 9999;
  min-width: 250px;
  background: #1f1f23;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.5), 0 2px 8px rgba(0, 0, 0, 0.3);
  animation: gbMenuIn .15s cubic-bezier(.22, .68, 0, 1);
}

:root:not(.dark) .gitbook-add-menu {
  background: #ffffff;
  border-color: #e5e7eb;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.14), 0 2px 8px rgba(0, 0, 0, 0.06);
}

@keyframes gbMenuIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.gb-menu-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: #f3f4f6;
  text-align: left;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
}

:root:not(.dark) .gb-menu-item {
  color: #1f2937;
}

.gb-menu-item:hover {
  background: rgba(255, 255, 255, 0.09);
  color: #ffffff;
}

:root:not(.dark) .gb-menu-item:hover {
  background: #f3f4f6;
  color: #111827;
}

.gb-menu-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.gb-menu-title {
  font-size: 13px;
  font-weight: 600;
  color: inherit;
  line-height: 1.3;
}

.gb-menu-desc {
  font-size: 11px;
  color: #9ca3af;
  line-height: 1.35;
  font-weight: 400;
}

:root:not(.dark) .gb-menu-desc {
  color: #6b7280;
}

.gb-menu-item.item-danger {
  color: #f87171;
}

.gb-menu-item.item-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #ef4444;
}

:root:not(.dark) .gb-menu-item.item-danger {
  color: #dc2626;
}

:root:not(.dark) .gb-menu-item.item-danger:hover {
  background: #fee2e2;
  color: #b91c1c;
}

.gb-menu-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  opacity: .85;
  flex-shrink: 0;
}

.gb-menu-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
  margin: 5px 6px;
}

:root:not(.dark) .gb-menu-divider {
  background: #e5e7eb;
}

/* Page Delete Buttons in Reader and Editor */
.page-delete-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 550;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid var(--color-border);
  color: #ef4444;
  cursor: pointer;
  transition: all .15s ease;
}

.page-delete-btn:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
  color: #dc2626;
}

.btn-top-delete {
  color: #ef4444 !important;
}

.btn-top-delete:hover {
  background: rgba(239, 68, 68, 0.12) !important;
  border-color: #ef4444 !important;
  color: #dc2626 !important;
}

.btn-action-danger {
  color: #ef4444 !important;
  border-color: rgba(239, 68, 68, 0.3) !important;
}

.btn-action-danger:hover {
  background: rgba(239, 68, 68, 0.1) !important;
  border-color: #ef4444 !important;
}

/* Visibility Control for Author Tools:
   Strictly hidden during reading; ONLY visible when actively editing in Editor Mode */
body:not(.in-editor-mode) .sidebar-icon-add-btn,
body:not(.in-editor-mode) .sidebar-icon-manage-btn,
body:not(.in-editor-mode) .pages-header-actions,
body:not(.in-editor-mode) .nav-inline-add-btn,
body:not(.in-editor-mode) .nav-inline-more-btn,
body:not(.in-editor-mode) .nav-item-tools,
body:not(.in-editor-mode) .nav-add-divider,
body:not(.in-editor-mode) .nav-circle-add-btn,
body:not(.in-editor-mode) .page-delete-btn,
body:not(.in-editor-mode) #reader-delete-shortcut,
body:not(.in-editor-mode) .btn-top-delete,
body:not(.in-editor-mode) .topnav-item-edit-btn,
body:not(.in-editor-mode) .topnav-add-btn {
  display: none !important;
}

/* Visitor Mode: When accessing via guest link without admin access */
body.is-visitor-mode #btn-header-login,
body.is-visitor-mode #retion-auth-container,
body.is-visitor-mode #modal-retion-login,
body.is-visitor-mode #btn-edit-mode,
body.is-visitor-mode #reader-edit-shortcut {
  display: none !important;
}

/* TopNav Editing & Tabs Management */
.topnav-item-wrap {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}

.topnav-item-wrap .topnav-link {
  position: relative;
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 6px;
  color: var(--color-text-soft);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: color .15s ease, background .15s ease;
  text-decoration: none;
}

.topnav-item-wrap .topnav-link:hover {
  color: var(--color-text);
  background: var(--color-surface-subtle);
}

.topnav-item-wrap .topnav-link.active {
  color: var(--color-accent);
  background: var(--color-accent-soft);
  font-weight: 600;
}

.topnav-item-wrap .topnav-link::after {
  display: none !important;
}

.topnav-item-edit-btn {
  display: none;
  position: absolute;
  right: 2px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  border-radius: 4px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-soft);
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  z-index: 5;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
  transition: all .12s ease;
}

body.is-author-logged-in.in-editor-mode .topnav-item-wrap:hover .topnav-item-edit-btn,
body.is-author-logged-in.in-editor-mode .topnav-item-wrap.menu-open .topnav-item-edit-btn {
  display: inline-flex;
}

.topnav-item-edit-btn:hover {
  background: #3b82f6;
  border-color: #2563eb;
  color: #fff;
  transform: translateY(-50%) scale(1.15);
}

.topnav-add-btn {
  display: none;
  align-items: center;
  gap: 5px;
  padding: 0 10px;
  margin-left: 6px;
  border-radius: 6px;
  border: 1px dashed var(--color-border);
  background: transparent;
  color: var(--color-text-soft);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  align-self: center;
  height: 26px;
  white-space: nowrap;
}

body.is-author-logged-in.in-editor-mode .topnav-add-btn {
  display: inline-flex;
}

.topnav-add-btn:hover {
  background: var(--color-surface-subtle);
  border-color: #3b82f6;
  color: #3b82f6;
  transform: translateY(-1px);
}

/* Floating TopNav Context Menu */
.topnav-context-menu {
  position: fixed;
  z-index: 10000;
  min-width: 230px;
  background: var(--color-surface);
  border: 1px solid color-mix(in srgb, var(--color-border) 80%, transparent);
  border-radius: 12px;
  padding: 6px;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.22), 0 2px 6px rgba(0, 0, 0, 0.06);
  animation: gbMenuIn .15s cubic-bezier(.22, .68, 0, 1);
  backdrop-filter: blur(14px);
}

:root.dark .topnav-context-menu {
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.06);
}

.topnav-menu-header {
  padding: 7px 12px 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--color-text-soft);
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 4px;
}

.topnav-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  height: 36px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background .12s ease, color .12s ease;
  text-align: left;
}

.topnav-menu-item svg {
  flex-shrink: 0;
  color: var(--color-text-soft);
  transition: color .12s, transform .12s;
}

.topnav-menu-item:hover {
  background: var(--color-surface-subtle);
}

.topnav-menu-item:hover svg {
  color: var(--color-text);
  transform: scale(1.08);
}

.topnav-menu-item.danger {
  color: #ef4444;
}

.topnav-menu-item.danger svg {
  color: #ef4444;
}

.topnav-menu-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #dc2626;
}

.topnav-menu-item.danger:hover svg {
  color: #dc2626;
}

.topnav-menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: 4px 6px;
}

/* Modal TopNav Manage */
.topnav-modal-body {
  padding: 20px 24px;
  max-height: 65vh;
  overflow-y: auto;
}

.topnav-help-tip {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.25);
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--color-text);
  line-height: 1.5;
}

.topnav-help-tip .tip-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
}

.topnav-help-tip .tip-text {
  flex: 1;
}

.topnav-help-tip strong {
  color: #2563eb;
}

[data-theme="dark"] .topnav-help-tip strong {
  color: #60a5fa;
}

.topnav-list-header {
  display: grid;
  grid-template-columns: 28px 1fr 1.35fr 110px;
  align-items: center;
  gap: 8px;
  padding: 0 10px 6px 10px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-soft);
  border-bottom: 1px solid var(--color-border);
}

.topnav-list-header .col-stt {
  text-align: center;
}

.topnav-list-header .col-actions {
  text-align: center;
}

.topnav-manage-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 16px 0;
}

.topnav-row {
  display: grid;
  grid-template-columns: 28px 1fr 1.35fr 34px 34px 34px;
  align-items: center;
  gap: 8px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 8px 10px;
  transition: border-color .15s ease;
}

.topnav-row:hover {
  border-color: var(--color-text-soft);
}

.topnav-row-drag {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-soft);
  font-size: 12px;
  font-weight: 700;
}

.topnav-input-title,
.topnav-select-path,
.topnav-custom-path-input {
  width: 100%;
  padding: 7px 10px;
  font-size: 13px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
  box-sizing: border-box;
}

.topnav-input-title:focus,
.topnav-select-path:focus,
.topnav-custom-path-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.topnav-picker-btn {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--color-text);
  cursor: pointer;
  text-align: left;
  transition: all .15s ease;
  min-height: 34px;
  box-sizing: border-box;
}

.topnav-picker-btn:hover {
  border-color: #3b82f6;
  background: var(--color-surface-subtle);
}

.topnav-picker-btn.active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

.topnav-picker-btn .picker-icon {
  font-size: 14px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
}

.topnav-picker-btn .picker-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}

.topnav-picker-btn .picker-slug {
  font-size: 11px;
  color: var(--color-text-soft);
  background: var(--color-surface-subtle);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
  max-width: 130px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.topnav-picker-btn .picker-arrow {
  flex-shrink: 0;
  color: var(--color-text-soft);
  transition: transform .15s ease;
}

.topnav-picker-btn.active .picker-arrow {
  transform: rotate(180deg);
}

.topnav-target-popover {
  position: fixed;
  z-index: 10050;
  width: 400px;
  max-width: 90vw;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 10px;
  box-shadow: 0 16px 40px -8px rgba(0, 0, 0, 0.25), 0 0 0 1px var(--color-border);
  backdrop-filter: blur(16px);
  padding: 8px;
  display: flex;
  flex-direction: column;
  animation: popoverFadeIn .12s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes popoverFadeIn {
  from {
    opacity: 0;
    transform: scale(.97) translateY(-4px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.popover-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  margin-bottom: 6px;
}

.popover-search-wrap .search-icon {
  color: var(--color-text-soft);
  flex-shrink: 0;
}

.popover-search-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  color: var(--color-text);
  padding: 0;
}

.popover-quick-actions {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-bottom: 6px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.popover-action-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 6px 8px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: background .12s ease;
  color: var(--color-text);
}

.popover-action-btn:hover {
  background: rgba(59, 130, 246, 0.09);
}

.popover-action-btn .action-icon {
  font-size: 15px;
  flex-shrink: 0;
}

.popover-action-btn .action-details {
  flex: 1;
  min-width: 0;
}

.popover-action-btn .action-title {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: #2563eb;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-theme="dark"] .popover-action-btn .action-title {
  color: #60a5fa;
}

.popover-action-btn .action-desc {
  display: block;
  font-size: 11px;
  color: var(--color-text-soft);
}

.popover-custom-input-box {
  display: flex;
  gap: 6px;
  padding: 6px 4px 8px 4px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 6px;
}

.custom-url-field {
  flex: 1;
  padding: 6px 8px;
  font-size: 12.5px;
  border: 1px solid var(--color-border);
  border-radius: 6px;
  background: var(--color-surface);
  color: var(--color-text);
  outline: none;
}

.custom-url-field:focus {
  border-color: #3b82f6;
}

.btn-confirm-url {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  background: #2563eb;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
}

.btn-confirm-url:hover {
  background: #1d4ed8;
}

.popover-section-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px 6px 8px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--color-text-soft);
}

.popover-pages-list {
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-right: 2px;
}

.popover-page-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  border: none;
  border-radius: 6px;
  background: transparent;
  cursor: pointer;
  text-align: left;
  transition: all .1s ease;
  color: var(--color-text);
}

.popover-page-item:hover {
  background: var(--color-surface-subtle);
}

.popover-page-item.selected {
  background: rgba(59, 130, 246, 0.1);
  color: #2563eb;
}

[data-theme="dark"] .popover-page-item.selected {
  color: #60a5fa;
}

.popover-page-item .page-icon {
  font-size: 13px;
  flex-shrink: 0;
  opacity: .8;
}

.popover-page-item .page-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.popover-page-item .page-title {
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popover-page-item .page-path {
  font-size: 11px;
  color: var(--color-text-soft);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.popover-page-item .page-check {
  font-size: 12px;
  font-weight: 700;
  color: #2563eb;
  flex-shrink: 0;
}

[data-theme="dark"] .popover-page-item .page-check {
  color: #60a5fa;
}

.topnav-row-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  color: var(--color-text-soft);
  cursor: pointer;
  transition: all .12s ease;
  font-size: 12px;
}

.topnav-row-btn:hover {
  background: var(--color-surface-subtle);
  color: var(--color-text);
  border-color: var(--color-text-soft);
}

.topnav-row-btn.danger:hover {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: #ef4444;
}

.topnav-add-row-bar {
  margin-top: 12px;
}

.btn-topnav-modal-add {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 7px;
  border: 1px dashed var(--color-border);
  background: transparent;
  color: var(--color-text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
}

.btn-topnav-modal-add:hover {
  background: var(--color-surface-subtle);
  border-color: #3b82f6;
  color: #3b82f6;
}

/* Modern In-App Dialog Popup (Confirm / Alert / Prompt) */
.app-dialog-backdrop {
  z-index: 3000;
  backdrop-filter: blur(8px);
  background: rgba(0, 0, 0, 0.55);
}

.app-dialog-card {
  max-width: 440px;
  background: #1a1a22;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.05);
  animation: dialogPopIn .18s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

:root:not(.dark) .app-dialog-card {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.18), 0 0 0 1px rgba(0, 0, 0, 0.04);
}

@keyframes dialogPopIn {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(6px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.app-dialog-body {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 22px 22px 16px;
}

.app-dialog-icon-wrap {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
  border: 1px solid rgba(59, 130, 246, 0.2);
}

.app-dialog-icon-wrap.danger {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.2);
}

.app-dialog-icon-wrap.warning {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
  border-color: rgba(245, 158, 11, 0.2);
}

.app-dialog-icon-wrap.success {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
  border-color: rgba(16, 185, 129, 0.2);
}

.app-dialog-content {
  flex: 1;
  min-width: 0;
}

.app-dialog-title {
  margin: 0 0 8px 0;
  font-size: 16px;
  font-weight: 650;
  color: #f4f4f5;
  line-height: 1.35;
}

:root:not(.dark) .app-dialog-title {
  color: #0f172a;
}

.app-dialog-message {
  font-size: 13.5px;
  line-height: 1.55;
  color: #a1a1aa;
}

:root:not(.dark) .app-dialog-message {
  color: #475569;
}

.app-dialog-message code {
  font-size: 12px;
  padding: 2px 5px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
  color: #e2e8f0;
}

:root:not(.dark) .app-dialog-message code {
  background: #f1f5f9;
  color: #0f172a;
}

.app-dialog-message strong {
  color: #f4f4f5;
  font-weight: 600;
}

:root:not(.dark) .app-dialog-message strong {
  color: #0f172a;
}

.app-dialog-input-wrap {
  margin-top: 12px;
}

.app-dialog-input {
  width: 100%;
  padding: 9px 12px;
  font-size: 13.5px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: #111116;
  color: #ffffff;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
  box-sizing: border-box;
}

:root:not(.dark) .app-dialog-input {
  background: #f8fafc;
  border-color: #cbd5e1;
  color: #0f172a;
}

.app-dialog-input:focus {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.app-dialog-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 22px;
  background: rgba(255, 255, 255, 0.02);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

:root:not(.dark) .app-dialog-footer {
  background: #fafafa;
  border-top-color: rgba(0, 0, 0, 0.06);
}

.app-dialog-footer .btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s ease;
}

.app-dialog-footer .btn-secondary {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #d4d4d8;
}

:root:not(.dark) .app-dialog-footer .btn-secondary {
  border-color: #cbd5e1;
  color: #475569;
  background: #ffffff;
}

.app-dialog-footer .btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
}

:root:not(.dark) .app-dialog-footer .btn-secondary:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.app-dialog-footer .btn-primary {
  background: #3b82f6;
  border: 1px solid transparent;
  color: #ffffff;
}

.app-dialog-footer .btn-primary:hover {
  background: #2563eb;
}

.app-dialog-footer .btn-primary.btn-danger {
  background: #ef4444;
}

.app-dialog-footer .btn-primary.btn-danger:hover {
  background: #dc2626;
}

/* --- Reader Upgrade: Image Lightbox Modal --- */
.lightbox-backdrop {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(10, 15, 29, 0.9);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.lightbox-backdrop:not([hidden]) {
  opacity: 1;
  pointer-events: auto;
}

.lightbox-toolbar {
  position: absolute;
  top: 18px;
  left: 24px;
  right: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  z-index: 2;
}

.lightbox-caption {
  color: rgba(255, 255, 255, 0.9);
  font-size: 13.5px;
  font-weight: 500;
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: rgba(255, 255, 255, 0.1);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(8px);
}

.lightbox-caption:empty {
  display: none;
}

.lightbox-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.lightbox-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease, border-color 0.15s ease;
  text-decoration: none;
}

.lightbox-btn:hover {
  background: rgba(255, 255, 255, 0.25);
  border-color: rgba(255, 255, 255, 0.35);
  transform: scale(1.06);
}

.lightbox-btn-close:hover {
  background: rgba(239, 68, 68, 0.85);
  border-color: rgba(239, 68, 68, 1);
}

.lightbox-viewport {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  padding: 50px 20px 20px;
  cursor: zoom-out;
}

.lightbox-img {
  max-width: 94vw;
  max-height: 86vh;
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(255, 255, 255, 0.12);
  transform: scale(0.96);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  cursor: default;
}

.lightbox-backdrop:not([hidden]) .lightbox-img {
  transform: scale(1);
}

.lightbox-img.zoomed {
  max-width: none;
  max-height: none;
  cursor: grab;
}

/* GitBook LLM Copy & AI Actions Split Button & Dropdown Menu */
.page-action-dropdown-wrap {
  position: relative;
  display: inline-block;
}

.split-copy-btn-group {
  display: inline-flex;
  align-items: stretch;
  height: 32px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  overflow: hidden;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.split-copy-btn-group:hover {
  border-color: color-mix(in srgb, var(--color-text-soft) 40%, var(--color-border));
}

.split-btn-main {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 0 10px;
  color: var(--color-text);
  background: transparent;
  border: none;
  font: 500 13px/1 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
  white-space: nowrap;
}

.split-btn-main .copy-main-icon,
.split-btn-main svg {
  color: var(--color-text-soft);
  flex-shrink: 0;
  transition: color .15s ease;
}

.split-btn-main:hover {
  background: var(--color-surface-subtle);
  color: var(--color-text);
}

.split-btn-main:hover svg {
  color: var(--color-text);
}

.split-btn-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 100%;
  padding: 0;
  color: var(--color-text-soft);
  background: transparent;
  border: none;
  border-left: 1px solid var(--color-border);
  cursor: pointer;
  transition: background-color .15s ease, color .15s ease;
}

.split-btn-arrow:hover,
.page-action-dropdown-wrap.open .split-btn-arrow {
  color: var(--color-text);
  background: var(--color-surface-subtle);
}

.split-btn-arrow .chevron-icon {
  transition: transform .2s cubic-bezier(.16, 1, .3, 1);
}

.page-action-dropdown-wrap.open .split-btn-arrow .chevron-icon {
  transform: rotate(180deg);
}

.page-action-menu {
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  width: 356px;
  max-width: calc(100vw - 24px);
  padding: 6px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  z-index: 1100;
  display: flex;
  flex-direction: column;
  animation: menuPopIn .18s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes menuPopIn {
  from {
    opacity: 0;
    transform: translateY(-4px) scale(0.98);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.page-action-menu[hidden] {
  display: none !important;
}

.menu-group {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.action-menu-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  padding: 7px 10px;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background-color .12s ease;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

.action-menu-item:hover {
  background: var(--color-surface-subtle);
}

.action-menu-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  color: #4b5563;
  margin-top: 1px;
  transition: color .15s ease;
}

.action-menu-icon svg {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
}

:root.dark .action-menu-icon {
  color: #9ca3af;
}

.action-menu-item:hover .action-menu-icon {
  color: var(--color-text);
}

.action-menu-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

.action-menu-title {
  font: 500 13px/1.3 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--color-text);
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.action-menu-desc {
  font: 400 11.5px/1.35 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: var(--color-text-soft);
}

.ext-arrow {
  font-size: 11px;
  opacity: .65;
  font-weight: 400;
  margin-left: 2px;
}

.action-menu-divider {
  height: 1px;
  background: var(--color-border);
  margin: 5px 4px;
  opacity: .8;
}

/* Viewer.js - Interactive Deep Zoom & Pan (fengyuanchen/viewerjs) */
.viewer-container {
  z-index: 99999 !important;
}

.viewer-backdrop {
  background-color: rgba(10, 15, 29, 0.85) !important;
  backdrop-filter: blur(18px) !important;
  -webkit-backdrop-filter: blur(18px) !important;
}

.viewer-toolbar>ul {
  background-color: color-mix(in srgb, var(--color-surface) 90%, #000) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 28px !important;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5) !important;
  padding: 4px 8px !important;
}

.viewer-toolbar>ul>li {
  background-color: transparent !important;
  border-radius: 50% !important;
  transition: all .15s ease !important;
}

.viewer-toolbar>ul>li:hover {
  background-color: var(--color-accent) !important;
  transform: scale(1.1) !important;
}

.viewer-tooltip {
  font-family: Inter, -apple-system, sans-serif !important;
  font-weight: 600 !important;
  border-radius: 6px !important;
  background-color: rgba(0, 0, 0, 0.8) !important;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3) !important;
}

.viewer-button {
  background-color: rgba(0, 0, 0, 0.5) !important;
  border-radius: 50% !important;
  transition: all .2s ease !important;
}

.viewer-button:hover {
  background-color: var(--color-accent) !important;
}

article img {
  cursor: zoom-in;
}

/* Markdown Source Viewer Modal (Prism.js) */
.markdown-viewer-card {
  width: min(920px, calc(100vw - 32px)) !important;
  max-width: 920px !important;
  max-height: calc(100vh - 80px) !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 70px -20px rgba(0, 0, 0, 0.35);
}

.md-viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.md-viewer-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.md-icon-badge {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.md-viewer-path {
  margin: 0;
  font-size: 14.5px;
  font-weight: 650;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.md-viewer-stats {
  margin: 2px 0 0;
  font-size: 11.5px;
  color: var(--color-text-soft);
}

.md-viewer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.md-viewer-body {
  position: relative;
  flex: 1 1 auto;
  min-height: 280px;
  max-height: calc(100vh - 200px);
  overflow-y: auto;
  background: #1d1f21;
  padding: 0;
}

.md-viewer-body pre {
  margin: 0 !important;
  padding: 20px 24px !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  font-size: 13px !important;
  line-height: 1.65 !important;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace !important;
}

.md-viewer-body code {
  color: #ccc;
  font-family: inherit;
  font-size: inherit;
  background: transparent !important;
  padding: 0 !important;
}

/* ============================================================
   Image Studio Modal (Cropper.js + Display Dimensions)
   Modern Apple / Linear design with checkered stage & floating pill
   ============================================================ */
.studio-modal-backdrop {
  backdrop-filter: blur(12px) !important;
  background: rgba(15, 23, 42, 0.65) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99999;
}

.studio-modal-card {
  width: min(1080px, calc(100vw - 40px)) !important;
  max-width: 1080px !important;
  height: min(780px, calc(100vh - 48px)) !important;
  max-height: calc(100vh - 48px) !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 0 !important;
  overflow: hidden !important;
  background: var(--color-surface) !important;
  border: 1px solid var(--color-border) !important;
  border-radius: 16px !important;
  box-shadow: 0 25px 70px -15px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(255, 255, 255, 0.08) !important;
  animation: studioModalPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes studioModalPop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.studio-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.studio-badge {
  background: var(--color-accent-soft) !important;
  color: var(--color-accent) !important;
}

.studio-modal-header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.studio-modal-body {
  position: relative;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  padding: 0 !important;
  background: #0f1117;
  overflow: hidden;
}

:root.dark .studio-modal-body {
  background: #0b0c10;
}

/* Stage Area with subtle checkered pattern */
.studio-stage-wrap {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  height: calc(100% - 64px);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background-color: #12141a;
  background-image: 
    linear-gradient(45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(255, 255, 255, 0.03) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(255, 255, 255, 0.03) 75%);
  background-size: 20px 20px;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
}

.studio-stage-canvas {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.studio-stage-canvas img {
  max-width: 100%;
  max-height: 100%;
  display: block;
}

/* Floating dimension indicator badge */
.studio-dimension-pill {
  position: absolute;
  top: 14px;
  right: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  background: rgba(18, 20, 26, 0.75);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #e2e8f0;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-weight: 500;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  z-index: 10;
}

.studio-dimension-pill svg {
  color: var(--color-accent);
}

/* Bottom Control Dock */
.studio-control-dock {
  flex-shrink: 0;
  height: 58px;
  padding: 0 16px;
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  box-sizing: border-box;
}

.studio-control-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.studio-group-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-text-soft);
  white-space: nowrap;
}

.studio-dock-sep {
  width: 1px;
  height: 20px;
  background: var(--color-border);
  flex-shrink: 0;
}

/* Segmented pill chips */
.studio-segmented {
  display: inline-flex;
  align-items: center;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  gap: 2px;
}

.studio-chip,
.studio-chip-size {
  padding: 3.5px 9px;
  font-size: 11.5px;
  font-weight: 550;
  color: var(--color-text-soft);
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.12s ease;
  white-space: nowrap;
  font-family: inherit;
}

.studio-chip:hover,
.studio-chip-size:hover {
  color: var(--color-text);
  background: rgba(0, 0, 0, 0.04);
}

:root.dark .studio-chip:hover,
:root.dark .studio-chip-size:hover {
  background: rgba(255, 255, 255, 0.06);
}

.studio-chip.active,
.studio-chip-size.active {
  background: var(--color-surface);
  color: var(--color-accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  font-weight: 600;
}

:root.dark .studio-chip.active,
:root.dark .studio-chip-size.active {
  background: var(--color-surface-subtle);
  color: var(--color-accent);
}

/* Transform icon buttons */
.studio-btn-row {
  display: flex;
  align-items: center;
  gap: 4px;
}

.studio-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  background: var(--color-surface-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-soft);
  cursor: pointer;
  transition: all 0.12s ease;
}

.studio-icon-btn:hover {
  background: var(--color-surface);
  border-color: var(--color-accent);
  color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.studio-icon-btn:active {
  transform: translateY(0);
}

/* Override Cropper.js styles to fit design tokens */
.cropper-view-box {
  outline: 2px solid var(--color-accent) !important;
  outline-color: var(--color-accent) !important;
}

.cropper-line {
  background-color: var(--color-accent) !important;
}

.cropper-point {
  background-color: #ffffff !important;
  border: 2px solid var(--color-accent) !important;
  border-radius: 50% !important;
  width: 9px !important;
  height: 9px !important;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25) !important;
}

.cropper-point.point-se {
  width: 11px !important;
  height: 11px !important;
}

.cropper-modal {
  background-color: rgba(10, 12, 16, 0.72) !important;
  backdrop-filter: blur(2px) !important;
}

/* Button in Image Block Toolbar */
.btn-open-image-studio {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--color-accent);
  background: var(--color-accent-soft);
  border: 1px solid color-mix(in srgb, var(--color-accent) 25%, transparent);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.btn-open-image-studio:hover {
  background: var(--color-accent);
  color: #fff;
  border-color: var(--color-accent);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.25);
}
/* Popup chọn ngôn ngữ (thay select mặc định) */
.lang-popup { position: relative; padding: 0 !important; }
.lang-popup-trigger {
  white-space: nowrap;
  display: flex; align-items: center; gap: 7px; height: 100%; padding: 0 12px;
  font: inherit; font-size: 14px; font-weight: 600; color: var(--color-text);
  background: transparent; border: 0; cursor: pointer;
}
.lang-popup-chevron { transition: transform .2s ease; }
.lang-popup-trigger[aria-expanded="true"] .lang-popup-chevron { transform: rotate(180deg); }
.lang-popup-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 1100; width: 208px; padding: 6px;
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1);
  animation: menuPopIn .18s cubic-bezier(0.16, 1, 0.3, 1);
}
.lang-popup-menu[hidden] { display: none; }
.lang-popup-item {
  display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%;
  padding: 8px 10px; font: inherit; text-align: left; color: var(--color-text);
  background: none; border: 0; border-radius: 8px; cursor: pointer;
}
.lang-popup-item:hover, .lang-popup-item:focus-visible { background: var(--color-surface-subtle); outline: none; }
.lang-popup-item span { display: flex; flex-direction: column; }
.lang-popup-item strong { font-size: 14px; font-weight: 600; }
.lang-popup-item small { font-size: 12px; color: var(--color-text-soft); }
.lang-popup-item > svg { visibility: hidden; }
.lang-popup-item.active { color: var(--color-accent); }
.lang-popup-item.active > svg { visibility: visible; }
/* Logo chữ Retion */
.brand-wordmark { width: auto !important; height: 29px !important; border-radius: 0 !important; }
:root.dark .brand-wordmark { filter: invert(1) hue-rotate(180deg); }

/* Bảng lịch sử chỉnh sửa trang (editor) */
.page-history-list { list-style: none; margin: 0; padding: 0; max-height: 55vh; overflow-y: auto; text-align: left; }
.page-history-item { padding: 10px 0; border-bottom: 1px solid var(--border, #e5e7eb); }
.page-history-item small { margin-left: 6px; opacity: 0.7; }
.page-history-msg { margin: 4px 0 6px; font-size: 13px; opacity: 0.85; word-break: break-word; }
.page-history-actions { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.page-history-preview { max-height: 60vh; overflow-y: auto; text-align: left; font-size: 14px; }
.page-history-preview img { max-width: 100%; height: auto; }
#app-dialog-modal:has(.page-history-preview) .app-dialog-card,
#app-dialog-modal:has(.page-history-list) .app-dialog-card { max-width: min(860px, 92vw); width: 100%; }
