:root {
  color-scheme: dark;
  --bg: #051221;
  --panel: rgba(8, 31, 53, .86);
  --panel-strong: #0b2844;
  --line: rgba(107, 209, 250, .16);
  --cyan: #55dbff;
  --text: #eefaff;
  --muted: #86a8bc;
  --danger: #ff8198;
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-height: 100vh; color: var(--text); background: radial-gradient(circle at 8% 0%, rgba(8,119,177,.25), transparent 34rem), linear-gradient(145deg, #030c17, #071c30 54%, #061321); }
button, input, textarea, select { font: inherit; }
.admin-shell { width: min(1480px, calc(100% - 40px)); margin: 0 auto; padding: 26px 0 44px; }
.admin-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.eyebrow { margin: 0 0 5px; color: var(--cyan); font-size: 10px; font-weight: 800; letter-spacing: .18em; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 5px; font-size: 28px; }
h2 { margin-bottom: 0; font-size: 22px; }
.subline { margin-bottom: 0; color: var(--muted); font-size: 13px; }
.back-link, .button { display: inline-flex; align-items: center; justify-content: center; min-height: 38px; padding: 0 14px; border-radius: 10px; border: 1px solid var(--line); text-decoration: none; cursor: pointer; transition: .2s; }
.back-link { color: #b9efff; background: rgba(22,96,134,.24); }
.back-link:hover, .button.secondary:hover { border-color: rgba(85,219,255,.48); color: white; }
.access-notice { margin-bottom: 15px; padding: 12px 15px; border: 1px solid rgba(85,219,255,.18); border-radius: 12px; color: #abd3e2; background: rgba(18,93,126,.13); font-size: 12px; line-height: 1.6; }
.access-notice strong { margin-right: 9px; color: #83e2fa; }
.header-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.current-user { font-size: 12px; color: var(--muted); }
.app-version { padding: 5px 9px; border: 1px solid var(--line); border-radius: 7px; color: #b9efff; font-size: 12px; white-space: nowrap; }
.x1-setup-panel { margin-bottom: 18px; padding: 18px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.x1-setup-panel p { margin: 10px 0; color: #bad7e4; line-height: 1.6; }
.x1-setup-panel h2 { font-size: 18px; }
#x1SetupForm { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 12px; margin: 15px 0; }
#x1SetupForm label { display: grid; gap: 8px; }
#x1SetupForm input { min-width: 0; padding: 10px; color: white; background: #041526; border: 1px solid var(--line); border-radius: 8px; }
.login-shell { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(430px, 100%); padding: 36px; border: 1px solid var(--line); border-radius: 22px; background: var(--panel); box-shadow: 0 24px 80px rgba(0,0,0,.3); }
.login-card h1 { margin-top: 12px; }
.login-description { margin: 12px 0 26px; color: var(--muted); font-size: 13px; line-height: 1.8; }
#loginForm label { display: grid; gap: 9px; margin-bottom: 18px; font-size: 13px; color: #b8dbe7; }
#loginForm input { width: 100%; height: 46px; padding: 0 13px; color: white; background: #041526; border: 1px solid var(--line); border-radius: 10px; outline: none; }
#loginForm input:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(85,219,255,.1); }
#loginButton { width: 100%; min-height: 46px; }
.login-error { min-height: 20px; margin: 8px 0 12px; color: var(--danger); font-size: 12px; line-height: 1.6; }
.login-back { display: block; margin-top: 22px; color: #93c9dc; font-size: 12px; text-align: center; text-decoration: none; }
.summary-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; margin-bottom: 15px; }
.summary-grid article { min-height: 92px; padding: 17px 19px; border: 1px solid var(--line); border-radius: 15px; background: var(--panel); box-shadow: 0 14px 36px rgba(0,0,0,.13); }
.summary-grid span { display: block; color: var(--muted); font-size: 11px; }
.summary-grid strong { display: inline-block; margin: 11px 6px 0 0; font-size: 24px; }
.summary-grid small { color: var(--muted); font-size: 10px; }
.usage-card { margin-bottom: 15px; padding: 18px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 18px 48px rgba(0,0,0,.16); }
.usage-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 14px; }
.usage-heading h2 { font-size: 20px; }
.usage-heading > span { color: var(--muted); font-size: 10px; }
.usage-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 14px; }
.usage-grid article { min-height: 82px; padding: 14px 16px; border: 1px solid rgba(107,209,250,.12); border-radius: 13px; background: rgba(3,20,36,.56); }
.usage-grid span { display: block; color: var(--muted); font-size: 10px; }
.usage-grid strong { display: inline-block; margin: 9px 5px 0 0; font-size: 22px; color: #dff9ff; }
.usage-grid small { color: var(--muted); font-size: 9px; }
.usage-table-wrap { max-height: 250px; overflow: auto; border: 1px solid rgba(107,209,250,.1); border-radius: 12px; }
.usage-table { table-layout: auto; }
.usage-table th, .usage-table td { width: auto !important; padding: 10px 13px; }
.usage-table td { color: #bcd7e2; font-size: 11px; }
.usage-table tbody tr:last-child td { border-bottom: 0; }
.workspace-card { overflow: hidden; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 22px 60px rgba(0,0,0,.2); }
.toolbar { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; padding: 18px; border-bottom: 1px solid var(--line); }
.search-field { display: grid; gap: 7px; color: var(--muted); font-size: 10px; }
.search-field input { width: min(420px, 42vw); height: 40px; padding: 0 13px; color: white; border: 1px solid var(--line); border-radius: 10px; outline: none; background: rgba(2,15,28,.72); }
.search-field input:focus { border-color: rgba(85,219,255,.56); box-shadow: 0 0 0 3px rgba(85,219,255,.07); }
.toolbar-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.button { color: #c5eefa; background: rgba(10,54,82,.48); font-size: 12px; }
.button.primary { color: white; border-color: transparent; background: linear-gradient(135deg, #13bde9, #0873d7); font-weight: 700; }
.button.primary:hover { filter: brightness(1.08); }
.button:disabled { opacity: .42; cursor: not-allowed; }
.button.danger { color: #ffb1bf; border-color: rgba(255,129,152,.35); background: rgba(128,34,57,.24); }
.button.danger:hover:not(:disabled) { background: rgba(168,43,69,.4); }
.selection-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--line); }
.selection-toolbar strong { color: #aeeeff; font-size: 12px; }
.selection-toolbar span { margin-left: 14px; color: var(--muted); font-size: 11px; }
.selection-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.selection-actions .button { min-height: 32px; font-size: 11px; }
.file-button input { display: none; }
.import-status { padding: 9px 18px; color: #6f98af; background: rgba(1,16,29,.34); font-size: 10px; }
.import-status.success { color: #65eabd; }
.import-status.error { color: #ff9db0; }
.table-wrap { max-height: calc(100vh - 330px); min-height: 360px; overflow: auto; }
table { width: 100%; border-collapse: collapse; table-layout: fixed; }
th { position: sticky; top: 0; z-index: 1; padding: 12px 14px; text-align: left; color: #87bed2; background: #0a243d; border-bottom: 1px solid var(--line); font-size: 10px; letter-spacing: .08em; }
td { padding: 13px 14px; vertical-align: top; border-bottom: 1px solid rgba(107,209,250,.08); color: #d8ecf3; font-size: 12px; line-height: 1.55; }
.knowledge-table th:nth-child(1), .knowledge-table td:nth-child(1) { width: 4%; }
.knowledge-table th:nth-child(2), .knowledge-table td:nth-child(2) { width: 18%; }
.knowledge-table th:nth-child(3), .knowledge-table td:nth-child(3) { width: 24%; }
.knowledge-table th:nth-child(4), .knowledge-table td:nth-child(4) { width: 36%; }
.knowledge-table th:nth-child(5), .knowledge-table td:nth-child(5) { width: 10%; }
.knowledge-table th:nth-child(6), .knowledge-table td:nth-child(6) { width: 8%; }
.select-cell { text-align: center; padding-left: 8px; padding-right: 8px; }
.select-cell input { width: 16px; height: 16px; cursor: pointer; accent-color: #25bce3; }
.knowledge-table tr.selected-row { background: rgba(24,143,185,.14); }
.usage-table th:nth-child(n), .usage-table td:nth-child(n) { width: auto; }
tbody tr:hover { background: rgba(31,111,148,.1); }
.category-tag { display: inline-flex; max-width: 100%; padding: 4px 8px; border-radius: 9px; color: #83dff5; background: rgba(23,117,154,.2); border: 1px solid rgba(83,205,237,.13); white-space: normal; overflow-wrap: anywhere; }
.question-text, .answer-text { overflow-wrap: anywhere; }
.question-text { color: white; font-weight: 650; }
.answer-text { display: -webkit-box; overflow: hidden; -webkit-line-clamp: 3; -webkit-box-orient: vertical; }
.date-text { color: #7198ad; font-size: 10px; white-space: nowrap; }
.row-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.row-action { flex-shrink: 0; white-space: nowrap; padding: 5px 7px; border: 1px solid var(--line); border-radius: 7px; color: #9edbee; background: transparent; cursor: pointer; font-size: 10px; }
.row-action.delete { color: var(--danger); border-color: rgba(255,129,152,.18); }
.loading-cell { padding: 80px 20px; text-align: center; color: var(--muted); }
dialog { width: min(680px, calc(100% - 28px)); padding: 0; color: var(--text); border: 1px solid rgba(92,218,255,.25); border-radius: 18px; background: #091f36; box-shadow: 0 30px 90px rgba(0,0,0,.55); }
dialog::backdrop { background: rgba(0,8,17,.7); backdrop-filter: blur(6px); }
#entryForm { padding: 22px; }
.dialog-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 19px; }
.close-button { padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; color: var(--muted); background: transparent; cursor: pointer; }
#entryForm > label { display: grid; gap: 7px; margin-bottom: 14px; color: #94bacb; font-size: 11px; }
#entryForm input, #entryForm textarea { width: 100%; padding: 11px 12px; resize: vertical; color: white; border: 1px solid var(--line); border-radius: 10px; outline: none; background: rgba(2,15,28,.62); line-height: 1.6; }
#entryForm input:focus, #entryForm textarea:focus { border-color: rgba(85,219,255,.55); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 20px; }
.delete-content { padding: 26px; }
.delete-content > p:not(.eyebrow) { font-size: 13px; line-height: 1.7; }
#deleteSummary { margin-top: 16px; color: #c9e5ef; }
#deletePreview { max-height: 180px; overflow: auto; padding-left: 22px; color: #a8c9d8; font-size: 12px; line-height: 1.9; }
.delete-warning { color: #ffb6c3; }
.toast { position: fixed; right: 24px; bottom: 24px; max-width: 380px; padding: 12px 16px; border: 1px solid rgba(81,230,184,.25); border-radius: 11px; color: #a9ffe2; background: rgba(5,58,51,.94); box-shadow: 0 14px 40px rgba(0,0,0,.28); opacity: 0; transform: translateY(12px); pointer-events: none; transition: .25s; }
.toast.show { opacity: 1; transform: translateY(0); }
.toast.error { color: #ffc1cc; border-color: rgba(255,129,152,.25); background: rgba(72,20,34,.95); }
.admin-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 16px; }
.admin-tab { min-height: 43px; padding: 0 20px; border: 1px solid var(--line); border-radius: 11px; color: #a4c9d9; background: rgba(9,39,63,.6); cursor: pointer; font: inherit; font-size: 13px; }
.admin-tab.active { color: #dffaff; border-color: rgba(85,219,255,.5); background: rgba(22,139,183,.24); box-shadow: inset 0 -2px 0 var(--cyan); }
.admin-tab:focus-visible, .character-card button:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.character-card { padding: 25px; border: 1px solid var(--line); border-radius: 18px; background: var(--panel); box-shadow: 0 22px 60px rgba(0,0,0,.2); }
.character-heading { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.character-metadata { color: var(--muted); font-size: 11px; line-height: 1.7; }
.character-description { max-width: 980px; margin: 18px 0 10px; color: #b8dbe8; font-size: 13px; line-height: 1.9; }
.profile-status { min-height: 22px; margin: 12px 0; color: #98dcef; font-size: 12px; line-height: 1.8; }
.profile-status.error { color: #ffafbf; }
.profile-status.success { color: #8ef2c9; }
#characterForm { max-width: 1050px; }
#characterForm label, .character-preview-controls label { display: grid; gap: 8px; margin-bottom: 18px; color: #c0dce7; font-size: 12px; }
#characterForm input:not([type="checkbox"]), #characterForm textarea, #characterForm select, .character-preview-controls input { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; color: #f2fbff; background: #061b2d; outline: none; line-height: 1.7; }
#characterForm textarea { resize: vertical; }
#characterForm input:focus, #characterForm textarea:focus, #characterForm select:focus, .character-preview-controls input:focus { border-color: rgba(85,219,255,.65); box-shadow: 0 0 0 3px rgba(85,219,255,.07); }
#characterForm small, .character-help { margin: 0; color: #8fb3c7; font-size: 11px; line-height: 1.8; }
#characterForm .character-switch { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border: 1px solid rgba(85,219,255,.2); border-radius: 11px; background: rgba(15,102,136,.12); font-size: 13px; }
.character-switch input { width: 18px; height: 18px; accent-color: #24bde6; }
.character-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 20px; align-items: start; }
.character-full-width { grid-column: 1 / -1; }
.character-source-preview { margin: 14px 0 22px; padding: 17px; border: 1px solid rgba(107,209,250,.15); border-radius: 12px; background: rgba(2,15,27,.46); }
.character-source-preview strong { color: #9fe2f4; font-size: 12px; }
.character-source-preview p, .character-preview-result { margin: 10px 0 0; color: #d6ebf4; font-size: 13px; line-height: 1.95; white-space: pre-wrap; overflow-wrap: anywhere; }
.character-save-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 9px; margin: 4px 0 24px; }
.character-preview { border-top: 1px solid var(--line); padding-top: 24px; }
.character-preview h3 { margin: 0 0 8px; font-size: 17px; }
.character-preview-controls { display: flex; align-items: flex-end; gap: 12px; max-width: 1050px; margin-top: 18px; }
.character-preview-controls label { flex: 1; margin-bottom: 0; }
.character-preview-controls .button { min-height: 43px; flex-shrink: 0; }
.character-preview-result { padding: 17px; border: 1px solid rgba(85,219,255,.16); border-radius: 12px; background: rgba(5,47,67,.5); }
@media (max-width: 900px) {
  .summary-grid { grid-template-columns: 1fr 1fr; }
  .usage-grid { grid-template-columns: 1fr 1fr; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .selection-toolbar { align-items: flex-start; flex-direction: column; }
  .search-field input { width: 100%; }
  .table-wrap { overflow-x: auto; }
  table { min-width: 980px; }
  .character-card { padding: 20px; }
}
@media (max-width: 560px) {
  .admin-shell { width: calc(100% - 20px); padding-top: 16px; }
  .admin-header { align-items: flex-start; gap: 14px; }
  .header-actions { justify-content: flex-end; }
  h1 { font-size: 22px; }
  .back-link { min-height: 34px; padding: 0 9px; font-size: 10px; }
  .summary-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .usage-heading { align-items: flex-start; flex-direction: column; }
  .usage-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .toolbar-actions { display: grid; grid-template-columns: 1fr 1fr; }
  .admin-tab { flex: 1; padding: 0 12px; }
  .character-card { padding: 16px; }
  .character-fields { grid-template-columns: 1fr; }
  .character-preview-controls { align-items: stretch; flex-direction: column; }
}
