/* Shared stylesheet for manual.html and adminmanual.html */

body.manual-page {
--ribbon-bg: #ffffff;
      --ribbon-border: #e5e7eb;
      --ribbon-accent: #059669;
      /* Primary Green */
      --accent-orange: #f97316;
      /* Energetic Orange */
      --bg-site: #ffffff;
      --sidebar-bg: #ffffff;
      --sidebar-border: #e5e7eb;
      --text-main: #111827;
      --text-muted: #6b7280;
      --hover-bg: #f3f4f6;
      --active-bg: #ecfdf5;
      --radius: 8px;
}

html[data-theme="dark"] body.manual-page {
--ribbon-bg: #111827;
      --ribbon-border: #374151;
      --ribbon-accent: #10b981;
      --accent-orange: #fb923c;
      --bg-site: #030712;
      --sidebar-bg: #0f172a;
      --sidebar-border: #1f2937;
      --text-main: #f9fafb;
      --text-muted: #9ca3af;
      --hover-bg: #1f2937;
      --active-bg: #064e3b;
}

body.manual-page * {
margin: 0;
      padding: 0;
      box-sizing: border-box;
}

body.manual-page * {
scrollbar-width: thin;
      scrollbar-color: rgba(17, 24, 39, 0.28) transparent;
}

body.manual-page *::-webkit-scrollbar {
width: 4px;
      height: 4px;
}

body.manual-page *::-webkit-scrollbar-track {
background: transparent;
}

body.manual-page *::-webkit-scrollbar-thumb {
background: rgba(17, 24, 39, 0.18);
      border-radius: 999px;
}

body.manual-page *::-webkit-scrollbar-thumb:hover {
background: rgba(17, 24, 39, 0.30);
}

html[data-theme="dark"] body.manual-page * {
scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

html[data-theme="dark"] body.manual-page *::-webkit-scrollbar-thumb {
background: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] body.manual-page *::-webkit-scrollbar-thumb:hover {
background: rgba(148, 163, 184, 0.34);
}

body.manual-page {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
      background: var(--bg-site);
      color: var(--text-main);
      display: flex;
      height: 100vh;
      overflow: hidden;
}

body.manual-page #content-container {
overflow-x: hidden;
}

/* --- SIDEBAR --- */

body.manual-page #sidebar {
width: 280px;
      display: flex;
      flex-direction: column;
      border-right: 1px solid var(--sidebar-border);
      background: var(--sidebar-bg);
      z-index: 100;
}

body.manual-page .sb-header {
padding: 20px;
      border-bottom: 1px solid var(--sidebar-border);
}

body.manual-page .logo {
font-size: 1.1rem;
      font-weight: 700;
      color: var(--ribbon-accent);
      margin-bottom: 15px;
}

body.manual-page #search-box {
width: 100%;
      padding: 8px 12px;
      border: 1px solid var(--sidebar-border);
      border-radius: var(--radius);
      outline: none;
      font-size: 13px;
      background: var(--bg-site);
      color: var(--text-main);
}

body.manual-page #tree {
flex: 1;
      overflow-y: auto;
      padding: 10px;
}

body.manual-page .nav-item {
padding: 8px 12px;
      border-radius: var(--radius);
      cursor: pointer;
      font-size: 13px;
      display: flex;
      align-items: center;
      justify-content: space-between;
      color: var(--text-main);
      margin-bottom: 2px;
}

body.manual-page .nav-link-box {
display: flex;
      align-items: center;
      gap: 8px;
      flex: 1;
      overflow: hidden;
}

body.manual-page .nav-item:hover {
background: var(--hover-bg);
}

body.manual-page .nav-item.active {
background: var(--ribbon-accent);
      color: white;
      font-weight: 600;
}

body.manual-page .tree-toggle {
width: 14px;
      height: 14px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      font-size: 8px;
      transition: 0.2s;
      opacity: 0.6;
}

body.manual-page .tree-toggle.collapsed {
transform: rotate(-90deg);
}

/* --- MAIN AREA --- */

body.manual-page #main {
flex: 1;
      display: flex;
      flex-direction: column;
      overflow: hidden;
      position: relative;
}

body.manual-page #header-bar {
height: 60px;
      background: white;
      border-bottom: 1px solid var(--sidebar-border);
      display: flex;
      align-items: center;
      justify-content: space-between;
      padding: 0 40px;
      box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

html[data-theme="dark"] body.manual-page #header-bar {
background: var(--sidebar-bg);
}

body.manual-page #viewer-layout {
flex: 1;
      display: grid;
      grid-template-columns: minmax(0, 1fr) 260px;
      overflow: hidden;
      background: #ffffff;
}

html[data-theme="dark"] body.manual-page #viewer-layout {
background: var(--bg-site);
}

body.manual-page #content-container {
overflow-y: auto;
      padding: 40px 40px 40px 60px;
      scroll-behavior: smooth;
      min-width: 0;
      max-width: 100%;
      -ms-overflow-style: none;
      scrollbar-width: none;
}

body.manual-page #content-container::-webkit-scrollbar {
display: none;
}

body.manual-page .page-sheet {
max-width: 1000px;
      margin: 0 auto;
      padding: 0;
      background: transparent;
      box-shadow: none;
      position: relative;
}

body.manual-page #page-title {
font-size: 32px;
      font-weight: 700;
      color: var(--ribbon-accent);
      margin-bottom: 30px;
}

body.manual-page #content {
line-height: 1.7;
      font-size: 16px;
      color: var(--text-main);
}

body.manual-page #content h1, body.manual-page #content h2, body.manual-page #content h3, body.manual-page #content h4, body.manual-page #content h5, body.manual-page #content h6 {
color: var(--text-main);
      margin: 1.5em 0 0.5em;
}

body.manual-page #content p {
margin-bottom: 1em;
}

body.manual-page .feedback-section {
margin-top: 36px;
      padding: 22px 24px;
      border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 2px;
      background: rgba(255, 255, 255, 0.78);
      box-shadow: 0 10px 30px rgba(15, 23, 42, 0.04);
}

html[data-theme="dark"] body.manual-page .feedback-section {
background: rgba(15, 23, 42, 0.78);
      border-color: rgba(148, 163, 184, 0.16);
      box-shadow: none;
}

body.manual-page .feedback-header {
display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 16px;
      margin-bottom: 16px;
}

body.manual-page .feedback-title {
font-size: 20px;
      font-weight: 700;
      color: var(--text-main);
}

body.manual-page .feedback-subtitle {
font-size: 13px;
      color: var(--text-muted);
      margin-top: 4px;
}

body.manual-page .feedback-count {
font-size: 12px;
      font-weight: 700;
      color: var(--ribbon-accent);
      background: rgba(5, 150, 105, 0.10);
      border-radius: 999px;
      padding: 6px 10px;
      white-space: nowrap;
}

body.manual-page .feedback-form {
display: grid;
      gap: 12px;
      margin-bottom: 18px;
}

body.manual-page .feedback-form-row {
display: grid;
      grid-template-columns: 1fr 180px;
      gap: 12px;
}

body.manual-page .feedback-input, body.manual-page .feedback-select, body.manual-page .feedback-textarea {
width: 100%;
      border: 1px solid var(--sidebar-border);
      border-radius: 2px;
      background: var(--bg-site);
      color: var(--text-main);
      padding: 11px 12px;
      font: inherit;
      outline: none;
}

body.manual-page .feedback-textarea {
min-height: 108px;
      resize: vertical;
      line-height: 1.6;
}

body.manual-page .feedback-input:focus, body.manual-page .feedback-select:focus, body.manual-page .feedback-textarea:focus {
border-color: var(--ribbon-accent);
      box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.12);
}

body.manual-page .feedback-actions {
display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      flex-wrap: wrap;
}

body.manual-page .feedback-hint {
font-size: 12px;
      color: var(--text-muted);
}

body.manual-page .feedback-submit {
border: none;
      border-radius: 10px;
      background: var(--ribbon-accent);
      color: white;
      padding: 10px 16px;
      font-weight: 700;
      cursor: pointer;
}

body.manual-page .feedback-submit:hover {
filter: brightness(1.05);
}

body.manual-page .feedback-list {
display: grid;
      gap: 12px;
}

body.manual-page .feedback-empty {
border: 1px dashed rgba(15, 23, 42, 0.14);
      border-radius: 2px;
      padding: 18px 16px;
      text-align: center;
      color: var(--text-muted);
      font-size: 14px;
}

body.manual-page .feedback-item {
border: 1px solid rgba(15, 23, 42, 0.08);
      border-radius: 14px;
      padding: 14px 16px;
      background: rgba(255, 255, 255, 0.7);
}

html[data-theme="dark"] body.manual-page .feedback-item {
background: rgba(2, 6, 23, 0.38);
      border-color: rgba(148, 163, 184, 0.14);
}

body.manual-page .feedback-meta {
display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 12px;
      margin-bottom: 8px;
      flex-wrap: wrap;
}

body.manual-page .feedback-author {
font-size: 14px;
      font-weight: 700;
      color: var(--text-main);
}

body.manual-page .feedback-date {
font-size: 12px;
      color: var(--text-muted);
}

body.manual-page .feedback-badge {
display: inline-flex;
      align-items: center;
      justify-content: center;
      border-radius: 999px;
      padding: 4px 9px;
      font-size: 11px;
      font-weight: 800;
      letter-spacing: 0.02em;
      text-transform: uppercase;
}

body.manual-page .feedback-badge.question {
background: rgba(37, 99, 235, 0.12);
      color: #1d4ed8;
}

body.manual-page .feedback-badge.comment {
background: rgba(5, 150, 105, 0.12);
      color: #047857;
}

body.manual-page .feedback-badge.note {
background: rgba(249, 115, 22, 0.14);
      color: #c2410c;
}

body.manual-page .feedback-message {
font-size: 14px;
      line-height: 1.7;
      color: var(--text-main);
      white-space: pre-wrap;
      word-break: break-word;
}

body.manual-page #content blockquote {
border-left: 4px solid var(--ribbon-accent);
      padding: 8px 14px;
      margin: 14px 0;
      background: rgba(5, 150, 105, 0.06);
      border-radius: 0 6px 6px 0;
      color: var(--text-muted);
}

body.manual-page #content pre {
background: #0f172a;
      color: #e5e7eb;
      border-radius: 8px;
      padding: 14px;
      overflow-x: auto;
      margin: 14px 0;
}

body.manual-page #content code {
font-family: Consolas, "Courier New", monospace;
      font-size: 13px;
}

body.manual-page #content hr {
border: none;
      border-top: 1px dashed var(--sidebar-border);
      margin: 20px 0;
}

body.manual-page #content table {
width: 100%;
      border-collapse: collapse;
      margin: 20px 0;
      border: 1px solid var(--sidebar-border);
}

body.manual-page #content th, body.manual-page #content td {
padding: 10px;
      border: 1px solid var(--sidebar-border);
      text-align: left;
}

body.manual-page #content th {
background: var(--hover-bg);
}

body.manual-page #content img {
width: auto;
      max-width: 100%;
      height: auto;
      display: block;
      border-radius: 4px;
}

/* Video always consistent 16:9 and full-width */

body.manual-page .media-aspect {
width: 100%;
      aspect-ratio: 16 / 9;
      background: #000;
      border-radius: 8px;
      overflow: hidden;
      margin: 20px 0;
}

body.manual-page .media-aspect iframe {
width: 100%;
      height: 100%;
      border: 0;
      display: block;
}

body.manual-page .media-delete-btn {
display: none !important;
}

body.manual-page .media-wrapper {
margin: 20px 0;
}

/* --- BUTTONS --- */

body.manual-page .btn-edit {
background: var(--ribbon-accent);
      color: white;
      border: none;
      padding: 8px 16px;
      border-radius: var(--radius);
      cursor: pointer;
      font-weight: 600;
      font-size: 13px;
      display: flex;
      align-items: center;
      gap: 6px;
}

body.manual-page .btn-edit:hover {
filter: brightness(1.1);
}

body.manual-page .reader-tools {
display: flex;
      align-items: center;
      gap: 8px;
}

body.manual-page .btn-tool {
height: 32px;
      min-width: 32px;
      border: 1px solid var(--sidebar-border);
      background: var(--bg-site);
      color: var(--text-main);
      border-radius: 6px;
      cursor: pointer;
      font-weight: 600;
      padding: 0 8px;
      font-size: 12px;
}

body.manual-page .btn-tool:hover {
background: var(--hover-bg);
}

body.manual-page #line-height-select {
height: 32px;
      border: 1px solid var(--sidebar-border);
      border-radius: 6px;
      background: var(--bg-site);
      color: var(--text-main);
      font-size: 12px;
      padding: 0 6px;
      outline: none;
}

/* --- TOC --- */

body.manual-page #toc-container {
position: relative;
      top: auto;
      right: auto;
      width: 100%;
      padding: 18px 14px;
      border-left: 1px dashed rgba(15, 23, 42, 0.22);
      background: transparent;
      box-shadow: none;
      display: none;
      z-index: 1;
      overflow-y: auto;
      min-width: 0;
}

html[data-theme="dark"] body.manual-page #toc-container {
background: rgba(31, 41, 55, 0.8);
      border-left-color: rgba(148, 163, 184, 0.2);
}

body.manual-page #toc-container h4 {
font-size: 10px;
      text-transform: uppercase;
      color: var(--text-muted);
      margin-bottom: 12px;
      letter-spacing: 1px;
}

body.manual-page .toc-item {
font-size: 13px;
      color: var(--text-main);
      cursor: pointer;
      padding: 5px 0;
      display: block;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
}

body.manual-page .toc-item:hover {
color: var(--ribbon-accent);
      font-weight: 600;
}

body.manual-page .toc-item.h2 {
padding-left: 15px;
      font-size: 12px;
}

body.manual-page .toc-item.h3 {
padding-left: 25px;
      font-size: 11px;
}

body.manual-page .toc-item.h4, body.manual-page .toc-item.h5, body.manual-page .toc-item.h6 {
padding-left: 32px;
      font-size: 11px;
}

/* --- BREADCRUMB & METADATA --- */

body.manual-page .page-header-header {
display: flex;
      flex-direction: column;
      gap: 2px;
}

body.manual-page .breadcrumb {
display: flex;
      align-items: center;
      gap: 6px;
      font-size: 13px;
      color: var(--text-muted);
}

body.manual-page .breadcrumb span:last-child {
color: var(--ribbon-accent);
      font-weight: 600;
}

body.manual-page .breadcrumb-sep {
opacity: 0.5;
      font-size: 10px;
}

body.manual-page .page-meta {
font-size: 11px;
      color: var(--text-muted);
      opacity: 0.7;
}

@media (max-width: 1100px) {
body.manual-page #viewer-layout {
grid-template-columns: 1fr;
}

body.manual-page #toc-container {
border-left: 0;
        border-top: 1px dashed rgba(15, 23, 42, 0.22);
        max-height: 220px;
}

body.manual-page .feedback-form-row {
grid-template-columns: 1fr;
}
}

/* ===== Admin page styles ===== */

body.admin-page {
--ribbon-bg: #ffffff;
            --ribbon-border: #e5e7eb;
            --ribbon-accent: #059669;
            /* Primary Green */
            --accent-orange: #f97316;
            /* Energetic Orange */
            --bg-site: #ffffff;
            --sidebar-bg: #ffffff;
            --sidebar-border: #e5e7eb;
            --text-main: #111827;
            --text-muted: #6b7280;
            --active-bg: #ecfdf5;
            --hover-bg: #f3f4f6;
            --radius: 8px;
            --shadow: none;
}

html[data-theme="dark"] body.admin-page {
--ribbon-bg: #111827;
            --ribbon-border: #374151;
            --ribbon-accent: #10b981;
            /* Brighter Green for Dark Mode */
            --accent-orange: #fb923c;
            --bg-site: #030712;
            --sidebar-bg: #0f172a;
            --sidebar-border: #1f2937;
            --text-main: #f9fafb;
            --text-muted: #9ca3af;
            --active-bg: #064e3b;
            --hover-bg: #1f2937;
}

body.admin-page * {
box-sizing: border-box;
            transition: background-color 0.2s;
}

body.admin-page * {
scrollbar-width: thin;
            scrollbar-color: rgba(17, 24, 39, 0.28) transparent;
}

body.admin-page *::-webkit-scrollbar {
width: 4px;
            height: 4px;
}

body.admin-page *::-webkit-scrollbar-track {
background: transparent;
}

body.admin-page *::-webkit-scrollbar-thumb {
background: rgba(17, 24, 39, 0.18);
            border-radius: 999px;
}

body.admin-page *::-webkit-scrollbar-thumb:hover {
background: rgba(17, 24, 39, 0.30);
}

html[data-theme="dark"] body.admin-page * {
scrollbar-color: rgba(148, 163, 184, 0.35) transparent;
}

html[data-theme="dark"] body.admin-page *::-webkit-scrollbar-thumb {
background: rgba(148, 163, 184, 0.22);
}

html[data-theme="dark"] body.admin-page *::-webkit-scrollbar-thumb:hover {
background: rgba(148, 163, 184, 0.34);
}

body.admin-page {
font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
            margin: 0;
            display: flex;
            height: 100vh;
            background: var(--bg-site);
            color: var(--text-main);
            overflow: hidden;
}

/* --- PREVIEW MODE (no redirect, toggle in-place) --- */

body.admin-page.preview-mode #ribbon {
display: none;
}

body.admin-page.preview-mode .media-delete-btn {
display: none !important;
}

body.admin-page.preview-mode .media-wrapper:hover {
box-shadow: none;
}

body.admin-page.focus-mode #sidebar, body.admin-page.focus-mode #toc-container {
display: none !important;
}

body.admin-page.focus-mode #main {
width: 100%;
}

/* --- SIDEBAR --- */

body.admin-page #sidebar {
width: 280px;
            display: flex;
            flex-direction: column;
            border-right: 1px solid var(--sidebar-border);
            background: var(--sidebar-bg);
            z-index: 100;
}

body.admin-page .sb-header {
padding: 20px;
            border-bottom: 1px solid var(--sidebar-border);
}

body.admin-page .logo {
font-size: 1.2rem;
            font-weight: 700;
            color: var(--ribbon-accent);
            display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 16px;
}

body.admin-page .logo img {
filter: drop-shadow(0 2px 4px rgba(5, 150, 105, 0.2));
}

body.admin-page #search-box {
width: 100%;
            padding: 8px 12px;
            border: 1px solid var(--sidebar-border);
            border-radius: var(--radius);
            outline: none;
            background: var(--bg-site);
            color: var(--text-main);
            font-size: 13px;
}

body.admin-page .tree-scroll {
flex: 1;
            overflow-y: auto;
            padding: 12px;
}

body.admin-page .nav-item {
padding: 8px 12px;
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 14px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            color: var(--text-main);
            margin-bottom: 2px;
}

body.admin-page .nav-item {
padding: 6px 12px;
            border-radius: var(--radius);
            cursor: pointer;
            font-size: 13px;
            display: flex;
            align-items: center;
            justify-content: space-between;
            color: var(--text-main);
            margin-bottom: 2px;
            transition: background 0.2s;
            gap: 4px;
}

body.admin-page .nav-link-box {
display: flex;
            align-items: center;
            gap: 6px;
            flex: 1;
            overflow: hidden;
}

body.admin-page .nav-item:hover {
background: var(--hover-bg);
}

body.admin-page .nav-item.active {
background: var(--ribbon-accent);
            color: white;
            font-weight: 600;
}

body.admin-page .tree-toggle {
display: inline-flex;
            width: 14px;
            height: 14px;
            align-items: center;
            justify-content: center;
            font-size: 8px;
            transition: 0.2s;
            opacity: 0.6;
}

body.admin-page .tree-toggle:hover {
opacity: 1;
            background: rgba(0, 0, 0, 0.1);
            border-radius: 2px;
}

body.admin-page .tree-toggle.collapsed {
transform: rotate(-90deg);
}

body.admin-page .nav-actions {
display: flex;
            gap: 4px;
            opacity: 0;
}

body.admin-page .nav-item:hover .nav-actions {
opacity: 1;
}

body.admin-page .btn-sm {
padding: 2px 6px;
            border: none;
            background: rgba(0, 0, 0, 0.1);
            color: inherit;
            cursor: pointer;
            border-radius: 3px;
            font-size: 10px;
}

/* --- RIBBON UI --- */

body.admin-page #ribbon {
background: var(--ribbon-bg);
            border-bottom: 1px solid var(--ribbon-border);
            display: flex;
            flex-direction: column;
            z-index: 200;
}

body.admin-page .ribbon-tabs {
display: flex;
            padding-left: 20px;
            background: #ffffff;
            border-bottom: 1px solid var(--ribbon-border);
            color: var(--text-main);
}

html[data-theme="dark"] body.admin-page .ribbon-tabs {
background: #0f172a;
}

body.admin-page .ribbon-tab {
padding: 10px 24px;
            font-size: 13px;
            cursor: pointer;
            border-bottom: 2px solid transparent;
            font-weight: 500;
            color: var(--text-muted);
            transition: 0.2s;
}

body.admin-page .ribbon-tab:hover {
color: var(--ribbon-accent);
}

body.admin-page .ribbon-tab.active {
color: var(--ribbon-accent);
            border-bottom-color: var(--ribbon-accent);
            font-weight: 600;
}

body.admin-page .ribbon-content {
display: flex;
            padding: 10px 0px;
            gap: 1px;
            background: var(--ribbon-bg);
}

body.admin-page .ribbon-group {
display: flex;
            flex-direction: column;
            align-items: center;
            border-right: 1px solid var(--ribbon-border);
            padding: 0 12px;
            position: relative;
}

body.admin-page .ribbon-group:last-child {
border-right: none;
}

body.admin-page .ribbon-group-controls {
display: flex;
            flex-direction: column;
            gap: 4px;
            flex: 1;
            justify-content: flex-start;
}

body.admin-page .ribbon-row {
display: flex;
            align-items: center;
            gap: 4px;
}

body.admin-page .r-btn {
border: 1px solid transparent;
            background: transparent;
            padding: 4px;
            border-radius: var(--radius);
            cursor: pointer;
            display: flex;
            align-items: center;
            justify-content: center;
            color: var(--text-main);
            font-size: 12px;
            min-width: 28px;
            height: 28px;
            transition: 0.1s;
            position: relative;
}

body.admin-page .r-btn:hover {
background: var(--hover-bg);
            border-color: var(--ribbon-border);
}

body.admin-page .r-btn.active {
background: var(--active-bg);
            border-color: var(--ribbon-border);
            box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.1);
}

body.admin-page .r-btn svg {
width: 16px;
            height: 16px;
            stroke-width: 2;
}

body.admin-page .r-btn.large {
flex-direction: column;
            height: 64px;
            min-width: 50px;
            font-size: 11px;
            gap: 4px;
}

body.admin-page .r-btn.large svg {
width: 24px;
            height: 24px;
}

body.admin-page .r-select {
background: white;
            border: 1px solid var(--ribbon-border);
            padding: 2px 4px;
            border-radius: 2px;
            font-size: 11px;
            outline: none;
}

html[data-theme="dark"] body.admin-page .r-select {
background: #374151;
            color: white;
}

body.admin-page .group-label {
font-size: 10px;
            color: var(--text-muted);
            text-transform: capitalize;
            margin-top: 8px;
            padding-bottom: 2px;
}

/* --- COLOR PICKER POPOVER --- */

body.admin-page .color-popover {
display: none;
            position: absolute;
            top: 100%;
            left: 0;
            background: #ffffff;
            border: 1px solid var(--ribbon-border);
            border-radius: 10px;
            padding: 10px;
            box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
            z-index: 1000;
            width: 220px;
}

html[data-theme="dark"] body.admin-page .color-popover {
background: #1f2937;
            border-color: #374151;
}

body.admin-page .color-picker-title {
font-size: 11px;
            font-weight: 700;
            color: var(--text-muted);
            margin-bottom: 8px;
            letter-spacing: 0.03em;
            text-transform: uppercase;
}

body.admin-page .color-picker-row {
display: flex;
            align-items: center;
            gap: 8px;
            margin-bottom: 8px;
}

body.admin-page .color-wheel {
width: 42px;
            height: 32px;
            border: 1px solid var(--ribbon-border);
            border-radius: 6px;
            background: transparent;
            padding: 0;
            cursor: pointer;
}

body.admin-page .color-hex {
flex: 1;
            height: 32px;
            border: 1px solid var(--ribbon-border);
            border-radius: 6px;
            padding: 0 9px;
            font-size: 12px;
            background: var(--bg-site);
            color: var(--text-main);
            outline: none;
            font-family: "JetBrains Mono", Consolas, monospace;
}

body.admin-page .color-quick {
display: grid;
            grid-template-columns: repeat(8, 1fr);
            gap: 6px;
            margin: 6px 0 8px;
}

body.admin-page .color-quick button {
width: 20px;
            height: 20px;
            border-radius: 4px;
            border: 1px solid rgba(0, 0, 0, 0.12);
            cursor: pointer;
            padding: 0;
}

body.admin-page .color-quick button:hover {
transform: translateY(-1px);
}

body.admin-page .color-actions {
display: flex;
            gap: 6px;
}

body.admin-page .color-actions .r-btn {
height: 30px;
            min-width: auto;
            padding: 0 10px;
            font-size: 11px;
}

/* --- STYLES GALLERY --- */

body.admin-page .styles-gallery {
display: flex;
            gap: 8px;
            overflow-x: auto;
            max-width: 400px;
            padding: 4px 0;
}

body.admin-page .style-item {
border: 1px solid var(--ribbon-border);
            background: white;
            padding: 4px 12px;
            border-radius: 2px;
            min-width: 80px;
            height: 60px;
            display: flex;
            flex-direction: column;
            justify-content: center;
            cursor: pointer;
            font-size: 11px;
            white-space: nowrap;
}

html[data-theme="dark"] body.admin-page .style-item {
background: #374151;
}

body.admin-page .style-item:hover {
border-color: var(--ribbon-accent);
}

body.admin-page .style-item b {
font-size: 14px;
}

/* --- MAIN AREA --- */

body.admin-page #main {
flex: 1;
            display: flex;
            flex-direction: column;
            overflow: hidden;
            position: relative;
}

body.admin-page #editor-layout {
flex: 1;
            display: grid;
            grid-template-columns: minmax(0, 1fr) 260px;
            overflow: hidden;
            background: #ffffff;
}

html[data-theme="dark"] body.admin-page #editor-layout {
background: var(--bg-site);
}

body.admin-page #content-container {
overflow-y: auto;
            overflow-x: hidden;
            padding: 40px 40px 40px 60px;
            scroll-behavior: smooth;
            min-width: 0;
            max-width: 100%;
            -ms-overflow-style: none;
            scrollbar-width: none;
}

body.admin-page #content-container::-webkit-scrollbar {
display: none;
}

body.admin-page .page-sheet {
max-width: 1000px;
            margin: 0 auto;
            padding: 0;
            background: transparent;
            box-shadow: none;
            position: relative;
}

html[data-theme="dark"] body.admin-page .page-sheet {
border-color: transparent;
}

body.admin-page #edit-title {
width: 100%;
            border: none;
            background: transparent;
            font-size: 25px;
            font-weight: 700;
            color: black;
            outline: none;
            margin-bottom: 20px;
            border-bottom: 1px solid transparent;
}

body.admin-page #edit-title:focus {
border-bottom-color: var(--ribbon-border);
}

body.admin-page #editor {
outline: none;
            min-height: 800px;
            font-size: 11pt;
            line-height: 1.6;
            color: var(--text-main);
            max-width: 100%;
            overflow-x: hidden;
}

/* Hard guard: never allow media to overflow horizontally */

body.admin-page #editor img, body.admin-page #editor iframe, body.admin-page #editor video {
max-width: 100% !important;
}

body.admin-page .media-wrapper {
position: relative;
            margin: 20px 0;
            border-radius: var(--radius);
            overflow: visible;
            transition: 0.3s;
            display: block;
            width: fit-content;
            max-width: min(100%, 1000px);
            line-height: 0;
            clear: both;
}

body.admin-page .media-wrapper.media-align-left {
margin-left: 0;
            margin-right: auto;
}

body.admin-page .media-wrapper.media-align-center {
margin-left: auto;
            margin-right: auto;
}

body.admin-page .media-wrapper.media-align-right {
margin-left: auto;
            margin-right: 0;
}

body.admin-page .media-wrapper:focus, body.admin-page .media-wrapper:focus-visible, body.admin-page .media-resizable:focus, body.admin-page .media-resizable:focus-visible {
outline: none !important;
}

body.admin-page .media-resizable {
position: relative;
            display: block;
            max-width: 100%;
            min-width: 120px;
            min-height: 80px;
            border: none;
            overflow: visible;
            line-height: 0;
}

/* Normalize image/video sizing so small images won't be tiny and big images won't overflow */

body.admin-page .media-wrapper img {
width: 100%;
            max-width: 100%;
            height: auto;
            display: block;
            border-radius: var(--radius);
            object-fit: initial;
}

body.admin-page .media-aspect {
width: 100%;
            aspect-ratio: 16 / 9;
            background: #000;
            border-radius: var(--radius);
            overflow: hidden;
}

body.admin-page .media-aspect iframe {
width: 100%;
            height: 100%;
            border: none;
            display: block;
            pointer-events: none;
}

body.admin-page.preview-mode .media-aspect iframe {
pointer-events: auto;
}

body.admin-page .resize-handle {
position: absolute;
            width: 10px;
            height: 10px;
            background: #ffffff;
            border: 1px solid #059669;
            border-radius: 2px;
            z-index: 6;
            opacity: 0;
}

body.admin-page .media-wrapper:hover .resize-handle {
opacity: 1;
}

body.admin-page .media-wrapper.media-selected .resize-handle {
opacity: 1;
}

body.admin-page.preview-mode .resize-handle {
display: none !important;
}

body.admin-page .resize-handle.nw {
left: -6px;
            top: -6px;
            cursor: nwse-resize;
}

body.admin-page .resize-handle.ne {
right: -6px;
            top: -6px;
            cursor: nesw-resize;
}

body.admin-page .resize-handle.sw {
left: -6px;
            bottom: -6px;
            cursor: nesw-resize;
}

body.admin-page .resize-handle.se {
right: -6px;
            bottom: -6px;
            cursor: nwse-resize;
}

body.admin-page .resize-handle.n {
top: -6px;
            left: calc(50% - 5px);
            cursor: ns-resize;
}

body.admin-page .resize-handle.s {
bottom: -6px;
            left: calc(50% - 5px);
            cursor: ns-resize;
}

body.admin-page .resize-handle.w {
left: -6px;
            top: calc(50% - 5px);
            cursor: ew-resize;
}

body.admin-page .resize-handle.e {
right: -6px;
            top: calc(50% - 5px);
            cursor: ew-resize;
}

body.admin-page .media-wrapper:hover {
box-shadow: none;
}

body.admin-page .media-delete-btn {
display: none !important;
            position: absolute;
            top: -15px;
            right: -5px;
            background: #ef4444;
            color: white;
            border: none;
            border-radius: 4px;
            padding: 4px 8px;
            cursor: pointer;
            z-index: 1000;
            opacity: 0;
            transition: 0.2s;
            font-size: 11px;
            font-weight: bold;
            box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

body.admin-page .media-wrapper:hover .media-delete-btn {
opacity: 1;
}

/* CONTENT STYLES */

body.admin-page #editor h1 {
font-size: 18pt;
            margin: 24pt 0 12pt;
            color: var(--text-main);
}

body.admin-page #editor h2 {
font-size: 16pt;
            margin: 18pt 0 6pt;
            color: var(--text-main);
}

body.admin-page #editor h3, body.admin-page #editor h4, body.admin-page #editor h5, body.admin-page #editor h6 {
margin: 14pt 0 6pt;
            color: var(--text-main);
}

body.admin-page #editor p {
margin-bottom: 12pt;
}

body.admin-page #editor blockquote {
border-left: 4px solid var(--ribbon-accent);
            margin: 14px 0;
            padding: 8px 14px;
            color: var(--text-muted);
            background: rgba(5, 150, 105, 0.06);
            border-radius: 0 6px 6px 0;
}

body.admin-page #editor pre {
background: #0f172a;
            color: #e5e7eb;
            border-radius: 8px;
            padding: 14px;
            overflow-x: auto;
            line-height: 1.5;
            margin: 14px 0;
}

body.admin-page #editor code {
font-family: "JetBrains Mono", Consolas, monospace;
            font-size: 12px;
}

body.admin-page #editor hr {
border: none;
            border-top: 1px dashed var(--ribbon-border);
            margin: 20px 0;
}

body.admin-page #editor table {
width: 100%;
            border-collapse: collapse;
            margin-bottom: 10pt;
}

body.admin-page #editor th, body.admin-page #editor td {
border: 1px solid #bfbfbf;
            padding: 8px;
            text-align: left;
}

/* MISC */

body.admin-page #theme-toggle {
position: absolute;
            top: 12px;
            right: 20px;
            cursor: pointer;
            font-size: 16px;
            opacity: 0.6;
}

body.admin-page #theme-toggle:hover {
opacity: 1;
}

body.admin-page .status-bar {
height: 26px;
            background: var(--ribbon-accent);
            color: white;
            display: flex;
            align-items: center;
            padding: 0 20px;
            font-size: 11px;
            justify-content: space-between;
            font-weight: 500;
}

body.admin-page .advanced-controls {
display: flex;
            flex-direction: column;
            gap: 6px;
            margin-bottom: 8px;
            justify-content: center;
}

body.admin-page .advanced-controls .advanced-action-btn {
width: 34px;
            height: 34px;
            min-width: 34px;
            font-size: 17px;
            font-weight: 800;
            border: 1px solid transparent;
            background: transparent;
}

body.admin-page .advanced-controls .advanced-action-btn:hover {
filter: brightness(0.98);
            border-color: var(--ribbon-accent);
            background: var(--hover-bg);
}

body.admin-page .advanced-controls .ribbon-row {
gap: 6px;
            justify-content: center;
}

body.admin-page .insert-icon-btn {
height: 40px !important;
            min-width: 40px !important;
            padding: 0 8px !important;
            font-size: 18px !important;
            font-weight: 800;
            line-height: 1;
}

body.admin-page .insert-icon-btn svg {
width: 20px !important;
            height: 20px !important;
}

body.admin-page .border-tool-wrap {
position: relative;
}

body.admin-page .size-tool-wrap {
position: relative;
}

body.admin-page .line-spacing-tool-wrap {
position: relative;
}

body.admin-page .border-popover {
display: none;
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            width: 250px;
            z-index: 1002;
            background: #ffffff;
            border: 1px solid var(--ribbon-border);
            border-radius: 10px;
            box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
            padding: 10px;
}

html[data-theme="dark"] body.admin-page .border-popover {
background: #1f2937;
            border-color: #374151;
}

body.admin-page .border-popover-title {
font-size: 11px;
            font-weight: 700;
            color: var(--text-muted);
            text-transform: uppercase;
            letter-spacing: 0.03em;
            margin-bottom: 8px;
}

body.admin-page .border-grid {
display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 8px;
            margin-bottom: 8px;
}

body.admin-page .border-field {
display: flex;
            flex-direction: column;
            gap: 4px;
}

body.admin-page .border-field label {
font-size: 11px;
            color: var(--text-muted);
}

body.admin-page .border-field input[type="number"], body.admin-page .border-field input[type="color"] {
height: 30px;
            border: 1px solid var(--ribbon-border);
            border-radius: 6px;
            background: var(--bg-site);
            color: var(--text-main);
            font-size: 12px;
            padding: 0 8px;
            outline: none;
}

body.admin-page .border-field input[type="color"] {
padding: 2px;
            cursor: pointer;
}

body.admin-page .border-actions {
display: flex;
            gap: 6px;
            margin-top: 8px;
}

body.admin-page .border-actions .r-btn {
width: auto;
            min-width: auto;
            padding: 0 10px;
}

body.admin-page .border-note {
font-size: 11px;
            color: var(--text-muted);
            opacity: 0.9;
}

body.admin-page .size-popover {
display: none;
            position: absolute;
            top: calc(100% + 8px);
            left: 0;
            width: 240px;
            z-index: 1002;
            background: #ffffff;
            border: 1px solid var(--ribbon-border);
            border-radius: 10px;
            box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
            padding: 10px;
}

html[data-theme="dark"] body.admin-page .size-popover {
background: #1f2937;
            border-color: #374151;
}

body.admin-page #find-panel {
display: none;
            align-items: center;
            gap: 8px;
            padding: 10px 14px;
            border-bottom: 1px solid var(--ribbon-border);
            background: var(--ribbon-bg);
}

body.admin-page #find-panel input {
height: 30px;
            border: 1px solid var(--ribbon-border);
            border-radius: 6px;
            padding: 0 10px;
            font-size: 12px;
            background: var(--bg-site);
            color: var(--text-main);
            outline: none;
}

body.admin-page #find-panel .r-btn {
height: 30px;
            padding: 0 10px;
            min-width: auto;
}

/* --- Link modal (Chèn liên kết) --- */

body.admin-page .link-modal {
position: fixed;
            inset: 0;
            z-index: 10050;
            display: none;
            align-items: center;
            justify-content: center;
            padding: 24px;
            box-sizing: border-box;
}

body.admin-page .link-modal.is-open {
display: flex;
}

body.admin-page .link-modal-backdrop {
position: absolute;
            inset: 0;
            background: rgba(15, 23, 42, 0.45);
            cursor: pointer;
}

html[data-theme="dark"] body.admin-page .link-modal-backdrop {
background: rgba(0, 0, 0, 0.55);
}

body.admin-page .link-modal-dialog {
position: relative;
            z-index: 1;
            width: 100%;
            max-width: 420px;
            padding: 22px 24px;
            border-radius: 12px;
            border: 1px solid var(--ribbon-border);
            background: var(--bg-site);
            color: var(--text-main);
            box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
}

body.admin-page .link-modal-title {
margin: 0 0 8px;
            font-size: 18px;
            font-weight: 700;
            color: var(--text-main);
}

body.admin-page .link-modal-hint {
margin: 0 0 16px;
            font-size: 13px;
            line-height: 1.45;
            color: var(--text-muted, #64748b);
}

body.admin-page .link-modal-label {
display: block;
            font-size: 12px;
            font-weight: 600;
            margin-bottom: 6px;
            color: var(--text-main);
}

body.admin-page .link-modal-input {
width: 100%;
            box-sizing: border-box;
            height: 40px;
            padding: 0 12px;
            border: 1px solid var(--ribbon-border);
            border-radius: 8px;
            font-size: 14px;
            background: var(--bg-site);
            color: var(--text-main);
            outline: none;
}

body.admin-page .link-modal-input:focus {
border-color: var(--ribbon-accent);
            box-shadow: 0 0 0 2px rgba(43, 87, 154, 0.2);
}

body.admin-page .link-modal-actions {
display: flex;
            justify-content: flex-end;
            gap: 10px;
            margin-top: 18px;
}

body.admin-page .link-modal-btn-ok {
background: var(--ribbon-accent);
            color: #fff !important;
            border: none;
            font-weight: 600;
}

body.admin-page .link-modal-btn-ok:hover {
filter: brightness(1.05);
}

body.link-modal-open {
overflow: hidden;
}

/* Liên kết trong nội dung: không gạch chân (editor + trang đọc) */

body.admin-page #editor a,
body.manual-page #content a {
text-decoration: none !important;
            color: var(--ribbon-accent);
            cursor: pointer;
}

body.admin-page #editor a:hover,
body.manual-page #content a:hover {
opacity: 0.88;
}

/* --- Chỉ số trên / dưới (sup/sub): nội dung + nút ribbon --- */

body.admin-page #editor sup,
body.admin-page #editor sub,
body.manual-page #content sup,
body.manual-page #content sub {
font-size: 0.62em;
            line-height: 0;
            position: relative;
            vertical-align: baseline;
}

body.admin-page #editor sup,
body.manual-page #content sup {
vertical-align: super;
}

body.admin-page #editor sub,
body.manual-page #content sub {
vertical-align: sub;
}

body.admin-page #editor span[style*="vertical-align:super"],
body.admin-page #editor span[style*="vertical-align: super"],
body.manual-page #content span[style*="vertical-align:super"],
body.manual-page #content span[style*="vertical-align: super"] {
font-size: 0.62em !important;
            line-height: 0 !important;
}

body.admin-page #editor span[style*="vertical-align:sub"],
body.admin-page #editor span[style*="vertical-align: sub"],
body.manual-page #content span[style*="vertical-align:sub"],
body.manual-page #content span[style*="vertical-align: sub"] {
font-size: 0.62em !important;
            line-height: 0 !important;
}

body.admin-page .r-btn.sup-sub-btn {
min-width: 2.25rem;
            padding-inline: 0.35rem;
}

body.admin-page .r-btn.sup-sub-btn .sup-sub-mark {
display: inline-flex;
            align-items: baseline;
            justify-content: center;
            font-size: 0.95rem;
            font-weight: 600;
            line-height: 1;
            letter-spacing: -0.02em;
            font-family: "Segoe UI", system-ui, sans-serif;
}

body.admin-page .r-btn.sup-sub-btn .sup-sub-mark sup,
body.admin-page .r-btn.sup-sub-btn .sup-sub-mark sub {
font-size: 0.62em;
            font-weight: 700;
            line-height: 0;
            position: relative;
            vertical-align: baseline;
}

body.admin-page .r-btn.sup-sub-btn.is-active {
background: color-mix(in srgb, var(--ribbon-accent, #2b579a) 18%, transparent);
            box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ribbon-accent, #2b579a) 45%, transparent);
}

html[data-theme="dark"] body.admin-page .r-btn.sup-sub-btn.is-active {
background: color-mix(in srgb, var(--ribbon-accent, #60a5fa) 22%, transparent);
            box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--ribbon-accent, #60a5fa) 50%, transparent);
}

body.admin-page .r-btn.sup-sub-btn:focus-visible {
outline: 2px solid var(--ribbon-accent, #2b579a);
            outline-offset: 2px;
}

/* --- TOC --- */

body.admin-page #toc-container {
position: relative;
            top: auto;
            right: auto;
            width: 100%;
            background: transparent;
            border-left: 1px dashed rgba(15, 23, 42, 0.22);
            padding: 18px 14px;
            box-shadow: none;
            display: none;
            z-index: 1;
            overflow-y: auto;
            min-width: 0;
}

html[data-theme="dark"] body.admin-page #toc-container {
background: #111827;
            border-left-color: rgba(148, 163, 184, 0.2);
}

body.admin-page #toc-container h4 {
font-size: 11px;
            text-transform: uppercase;
            color: var(--text-muted);
            margin-bottom: 12px;
            letter-spacing: 1px;
            border-bottom: 1px solid var(--sidebar-border);
            padding-bottom: 5px;
}

body.admin-page .toc-item {
font-size: 13px;
            color: var(--text-main);
            cursor: pointer;
            padding: 6px 0;
            display: block;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
}

body.admin-page .toc-item:hover {
color: var(--ribbon-accent);
            font-weight: 600;
}

body.admin-page .toc-item.h2 {
padding-left: 15px;
            font-size: 12px;
            color: var(--text-muted);
}

body.admin-page .toc-item.h3 {
padding-left: 25px;
            font-size: 11px;
            color: var(--text-muted);
}

body.admin-page .toc-item.h4, body.admin-page .toc-item.h5, body.admin-page .toc-item.h6 {
padding-left: 32px;
            font-size: 11px;
            color: var(--text-muted);
}

body.admin-page #header-bar {
height: 50px;
            background: white;
            border-bottom: 1px solid var(--sidebar-border);
            display: flex;
            align-items: center;
            justify-content: space-between;
            padding: 0 40px;
}

html[data-theme="dark"] body.admin-page #header-bar {
background: var(--sidebar-bg);
}

body.admin-page .page-header-header {
display: flex;
            flex-direction: column;
            gap: 2px;
}

body.admin-page .breadcrumb {
display: flex;
            align-items: center;
            gap: 6px;
            font-size: 13px;
            color: var(--text-muted);
}

body.admin-page .breadcrumb span:last-child {
color: var(--ribbon-accent);
            font-weight: 600;
}

body.admin-page .breadcrumb-sep {
opacity: 0.5;
            font-size: 10px;
}

body.admin-page .page-meta {
font-size: 11px;
            color: var(--text-muted);
            opacity: 0.7;
}

@media (max-width: 1100px) {
body.admin-page #editor-layout {
grid-template-columns: 1fr;
}

body.admin-page #toc-container {
border-left: 0;
                border-top: 1px dashed rgba(15, 23, 42, 0.22);
                max-height: 220px;
}
}
