* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #f5f7fb;
  color: #172033;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

[hidden] {
  display: none !important;
}

button,
input,
select,
textarea {
  font: inherit;
}

a {
  color: #2563eb;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.auth-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
}

.auth-card {
  width: min(420px, calc(100vw - 40px));
  padding: 32px;
  border: 1px solid #e3e8f2;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(31, 41, 55, 0.10);
}

.auth-card h1 {
  margin: 0 0 10px;
  font-size: 26px;
  line-height: 1.25;
}

.auth-card p {
  margin: 0 0 24px;
  color: #657084;
  line-height: 1.7;
  font-size: 15px;
}

.auth-card label,
.editor-form label {
  display: grid;
  gap: 8px;
  color: #374151;
  font-weight: 700;
  font-size: 14px;
}

.auth-card input,
.search-input,
.select-input,
.editor-form input,
.editor-form select,
.editor-form textarea {
  width: 100%;
  border: 1px solid #ccd5e3;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  outline: none;
}

.auth-card input,
.search-input,
.select-input,
.editor-form input,
.editor-form select {
  height: 44px;
  padding: 0 12px;
}

.editor-form textarea {
  padding: 12px;
  resize: vertical;
}

.auth-card input:focus,
.search-input:focus,
.select-input:focus,
.editor-form input:focus,
.editor-form select:focus,
.editor-form textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.auth-card button,
.primary-button {
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #2563eb;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.auth-card button {
  width: 100%;
  margin-top: 16px;
}

.auth-card button:hover,
.primary-button:hover {
  background: #1d4ed8;
}

.secondary-button,
.icon-button {
  height: 40px;
  border: 1px solid #ccd5e3;
  border-radius: 8px;
  background: #fff;
  color: #263346;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button {
  padding: 0 16px;
}

.secondary-button:hover,
.icon-button:hover {
  border-color: #9fb0c8;
  background: #f8fafc;
}

.danger {
  color: #b42318;
}

.message,
.admin-message {
  margin-bottom: 16px;
  border-radius: 8px;
  padding: 11px 12px;
  font-size: 14px;
  line-height: 1.5;
}

.error {
  color: #b42318;
  background: #fff1f0;
  border: 1px solid #ffd3cf;
}

.admin-message {
  border: 1px solid #b8e3c4;
  background: #f0fbf3;
  color: #166534;
}

.shop-link {
  display: block;
  margin-top: 18px;
  color: #2563eb;
  text-align: center;
  font-size: 15px;
  font-weight: 800;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 58px;
  padding: 0 30px;
  border-bottom: 1px solid #dce4ef;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.brand {
  color: #111827;
  font-size: 22px;
  font-weight: 900;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 18px;
  font-size: 14px;
  font-weight: 800;
}

.kb-shell,
.admin-shell {
  display: grid;
  gap: 22px;
  width: min(1480px, calc(100vw - 56px));
  margin: 28px auto;
}

.kb-shell {
  grid-template-columns: 300px minmax(0, 1fr);
}

.admin-shell {
  grid-template-columns: 340px minmax(0, 1fr);
}

.kb-sidebar,
.admin-list-panel,
.article-panel,
.editor-panel {
  border: 1px solid #dce4ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(31, 41, 55, 0.08);
}

.kb-sidebar,
.admin-list-panel {
  position: sticky;
  top: 82px;
  align-self: start;
  max-height: calc(100vh - 110px);
  padding: 16px;
  overflow: auto;
}

.sidebar-head,
.editor-toolbar,
.article-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.sidebar-head {
  margin-bottom: 14px;
}

.sidebar-head h1,
.editor-toolbar h1,
.article-head h1 {
  margin: 0;
  color: #111827;
  line-height: 1.25;
  letter-spacing: 0;
}

.sidebar-head h1 {
  font-size: 22px;
}

.sidebar-head span {
  color: #657084;
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.icon-button {
  width: 40px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.search-input,
.select-input {
  margin-bottom: 10px;
}

.article-list {
  display: grid;
  gap: 8px;
}

.article-item {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 11px 12px;
  background: #f8fafc;
  color: #1f2937;
  text-align: left;
  cursor: pointer;
}

.article-item:hover,
.article-item.is-active {
  border-color: #b9c9e2;
  background: #eef5ff;
}

.article-item strong {
  display: block;
  margin-bottom: 5px;
  overflow-wrap: anywhere;
  font-size: 14px;
}

.article-item span {
  display: block;
  color: #657084;
  font-size: 12px;
  line-height: 1.45;
}

.article-panel,
.editor-panel {
  min-height: calc(100vh - 116px);
}

.article-panel {
  padding: 0;
  overflow: visible;
}

.article-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: calc(100vh - 116px);
}

.article-toc {
  position: sticky;
  top: 82px;
  align-self: start;
  max-height: calc(100vh - 110px);
  overflow: auto;
  padding: 24px 16px;
  border-right: 1px solid #edf1f7;
  background: #fbfdff;
}

.article-toc__title {
  margin: 0 0 14px;
  color: #111827;
  font-size: 15px;
  font-weight: 900;
}

.article-toc nav {
  display: grid;
  gap: 4px;
}

.article-toc a {
  display: block;
  border-radius: 8px;
  padding: 7px 10px;
  color: #526175;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.article-toc a:hover,
.article-toc a.is-active {
  background: #eaf2ff;
  color: #2563eb;
  text-decoration: none;
}

.article-toc .toc-level-1 {
  color: #263346;
  font-weight: 900;
}

.article-toc .toc-level-2 {
  padding-left: 10px;
  font-weight: 800;
}

.article-toc .toc-level-3 {
  padding-left: 20px;
}

.article-toc .toc-level-4 {
  padding-left: 30px;
  font-size: 12px;
}

.article-toc .toc-level-5,
.article-toc .toc-level-6 {
  padding-left: 38px;
  font-size: 12px;
}

.article-main {
  min-width: 0;
}

.article-head {
  padding: 34px 34px 20px;
  border-bottom: 1px solid #edf1f7;
}

.article-head h1 {
  font-size: 31px;
}

.admin-link {
  flex: 0 0 auto;
  font-size: 14px;
  font-weight: 800;
}

.article-category {
  margin: 0 0 8px;
  color: #2563eb;
  font-size: 13px;
  font-weight: 900;
}

.article-meta {
  margin: 0;
  padding: 14px 34px 0;
  color: #657084;
  font-size: 13px;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 14px 34px 0;
}

.tag {
  border: 1px solid #d6e2f3;
  border-radius: 999px;
  padding: 4px 10px;
  background: #f7fbff;
  color: #41516a;
  font-size: 12px;
  font-weight: 800;
}

.article-body {
  padding: 18px 34px 42px;
  color: #202938;
  line-height: 1.8;
}

.article-body h1,
.article-body h2,
.article-body h3,
.article-body h4,
.article-body h5,
.article-body h6 {
  color: #111827;
  line-height: 1.35;
  letter-spacing: 0;
}

.article-body h1 {
  font-size: 30px;
}

.article-body h2 {
  margin-top: 34px;
  border-top: 1px solid #e6edf7;
  padding-top: 24px;
  font-size: 24px;
}

.article-body h3 {
  margin-top: 26px;
  font-size: 21px;
}

.article-body p {
  margin: 12px 0;
}

.article-body a {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.article-body span,
.article-body em,
.article-body strong,
.article-body code {
  overflow-wrap: anywhere;
  word-break: break-word;
}

.article-body img {
  max-width: 100%;
  height: auto;
  border: 1px solid #e4eaf3;
  border-radius: 8px;
  background: #fff;
}

.article-body .doc-figure {
  margin: 18px 0;
}

.article-body table {
  max-width: 100%;
  border-collapse: collapse;
}

.article-body .note-box {
  width: 100%;
  margin: 14px 0;
  border: 1px solid #dbe7f8;
  border-radius: 8px;
  background: #f8fbff;
}

.article-body .note-box td {
  padding: 10px 12px;
}

.empty-state {
  display: grid;
  min-height: calc(100vh - 116px);
  place-items: center;
  color: #657084;
  font-size: 15px;
  font-weight: 800;
}

.editor-panel {
  padding: 24px;
}

.editor-toolbar {
  margin-bottom: 18px;
}

.editor-toolbar h1 {
  font-size: 26px;
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.toolbar-actions .primary-button {
  min-width: 90px;
  padding: 0 18px;
}

.editor-form {
  display: grid;
  gap: 16px;
}

.form-grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.content-editor {
  min-height: 420px;
  line-height: 1.65;
}

.rich-editor-block {
  display: grid;
  gap: 10px;
}

.rich-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.rich-editor-head label {
  color: #374151;
  font-weight: 800;
  font-size: 14px;
}

.editor-mode-switch {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid #ccd5e3;
  border-radius: 8px;
  background: #fff;
}

.editor-mode-switch button {
  height: 36px;
  border: 0;
  border-left: 1px solid #ccd5e3;
  padding: 0 14px;
  background: #fff;
  color: #41516a;
  font-weight: 800;
  cursor: pointer;
}

.editor-mode-switch button:first-child {
  border-left: 0;
}

.editor-mode-switch button.is-active {
  background: #2563eb;
  color: #fff;
}

.rich-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  border: 1px solid #dbe4f1;
  border-radius: 8px;
  padding: 10px;
  background: #f8fbff;
}

.rich-toolbar button,
.rich-toolbar select {
  height: 36px;
  border: 1px solid #ccd5e3;
  border-radius: 7px;
  background: #fff;
  color: #263346;
  font-weight: 800;
}

.rich-toolbar button {
  padding: 0 12px;
  cursor: pointer;
}

.rich-toolbar select {
  min-width: 118px;
  padding: 0 10px;
}

.rich-toolbar button:hover,
.rich-toolbar select:focus {
  border-color: #8fb1e8;
}

.rich-editor-surface,
.source-editor {
  width: 100%;
  min-height: 640px;
  max-height: none;
  border: 1px solid #ccd5e3;
  border-radius: 8px;
  background: #fff;
  outline: none;
}

.rich-editor-surface {
  padding: 22px 28px 36px;
  overflow: auto;
}

.rich-editor-surface:focus,
.source-editor:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.rich-editor-surface:empty::before {
  content: "从这里开始写文章...";
  color: #9aa7b8;
}

.source-editor {
  padding: 14px;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
}

.admin-tabs {
  position: sticky;
  top: 58px;
  z-index: 9;
  display: flex;
  gap: 8px;
  width: min(1480px, calc(100vw - 56px));
  margin: 18px auto 0;
  border-bottom: 1px solid #dce4ef;
  background: rgba(245, 247, 251, 0.94);
  backdrop-filter: blur(12px);
}

.admin-tabs button {
  height: 42px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: #526175;
  font-weight: 900;
  cursor: pointer;
}

.admin-tabs button:hover,
.admin-tabs button.is-active {
  color: #2563eb;
  border-bottom-color: #2563eb;
}

.admin-wide-panel {
  width: min(1480px, calc(100vw - 56px));
  margin: 22px auto;
  border: 1px solid #dce4ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 18px 48px rgba(31, 41, 55, 0.08);
  padding: 24px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
}

.panel-head h1 {
  margin: 0;
  font-size: 26px;
  line-height: 1.25;
}

.editor-status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 8px;
  color: #657084;
  font-size: 13px;
  font-weight: 800;
}

.editor-status-row span:last-child {
  color: #b45309;
}

.compact-select {
  width: 210px;
  height: 40px;
  border: 1px solid #ccd5e3;
  border-radius: 8px;
  background: #fff;
  color: #263346;
  font-weight: 800;
}

.editor-workspace {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 12px;
}

.editor-toc {
  position: sticky;
  top: 128px;
  align-self: start;
  max-height: calc(100vh - 160px);
  overflow: auto;
  border: 1px solid #dbe4f1;
  border-radius: 8px;
  background: #fbfdff;
  padding: 14px;
}

.editor-toc nav {
  display: grid;
  gap: 3px;
}

.editor-toc a,
.editor-toc .toc-empty {
  display: block;
  border-radius: 7px;
  padding: 6px 8px;
  color: #526175;
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.editor-toc a:hover {
  background: #eaf2ff;
  color: #2563eb;
  text-decoration: none;
}

.editor-toc .toc-level-1,
.editor-toc .toc-level-2 {
  color: #263346;
  font-weight: 900;
}

.editor-toc .toc-level-3 {
  padding-left: 16px;
}

.editor-toc .toc-level-4,
.editor-toc .toc-level-5,
.editor-toc .toc-level-6 {
  padding-left: 26px;
  font-size: 12px;
}

.editor-canvas {
  min-width: 0;
}

.media-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.media-card {
  overflow: hidden;
  border: 1px solid #dce4ef;
  border-radius: 8px;
  background: #fff;
}

.media-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #f8fafc;
  border-bottom: 1px solid #edf1f7;
}

.media-card__body {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.media-card__body strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.media-card__body span {
  color: #657084;
  font-size: 12px;
}

.media-actions,
.manager-row > div {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.media-actions button,
.manager-row button {
  min-height: 32px;
  border: 1px solid #ccd5e3;
  border-radius: 7px;
  background: #fff;
  color: #263346;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.media-actions button {
  flex: 1 1 auto;
}

.media-actions button:hover,
.manager-row button:hover {
  border-color: #8fb1e8;
  background: #f8fbff;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.46);
}

.watermark-dialog {
  width: min(1180px, calc(100vw - 48px));
  max-height: calc(100vh - 48px);
  overflow: auto;
  border: 1px solid #dce4ef;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.28);
  padding: 22px;
}

.watermark-editor {
  display: grid;
  gap: 18px;
  grid-template-columns: minmax(0, 1fr) 280px;
}

.watermark-canvas-wrap {
  min-width: 0;
  max-height: calc(100vh - 210px);
  overflow: auto;
  border: 1px solid #dbe4f1;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #f2f5fa 25%, transparent 25%),
    linear-gradient(-45deg, #f2f5fa 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f2f5fa 75%),
    linear-gradient(-45deg, transparent 75%, #f2f5fa 75%);
  background-color: #fff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

#watermarkCanvas {
  display: block;
  width: 100%;
  height: auto;
  cursor: move;
}

.watermark-controls {
  display: grid;
  align-content: start;
  gap: 14px;
}

.watermark-controls label {
  display: grid;
  gap: 7px;
  color: #374151;
  font-size: 14px;
  font-weight: 800;
}

.watermark-controls select,
.watermark-controls input[type="range"] {
  width: 100%;
}

.watermark-controls select {
  height: 40px;
  border: 1px solid #ccd5e3;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  padding: 0 10px;
}

.taxonomy-grid {
  display: grid;
  gap: 18px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.taxonomy-card {
  border: 1px solid #dce4ef;
  border-radius: 8px;
  padding: 18px;
  background: #fbfdff;
}

.taxonomy-card h2 {
  margin: 0 0 14px;
  font-size: 20px;
}

.inline-form {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(0, 1fr) 88px;
  margin-bottom: 14px;
}

.inline-form input {
  min-width: 0;
  height: 42px;
  border: 1px solid #ccd5e3;
  border-radius: 8px;
  padding: 0 12px;
}

.import-form {
  display: grid;
  gap: 16px;
}

.import-form label {
  display: grid;
  gap: 8px;
  color: #374151;
  font-size: 14px;
  font-weight: 800;
}

.import-form input,
.import-form textarea {
  width: 100%;
  border: 1px solid #ccd5e3;
  border-radius: 8px;
  background: #fff;
  color: #172033;
  outline: none;
}

.import-form input {
  height: 44px;
  padding: 0 12px;
}

.import-form textarea {
  min-height: 220px;
  padding: 12px;
  resize: vertical;
  font-family: Consolas, "SFMono-Regular", Menlo, monospace;
  font-size: 13px;
  line-height: 1.7;
}

.import-form input:focus,
.import-form textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.manager-list {
  display: grid;
  gap: 8px;
}

.manager-row,
.manager-empty {
  border: 1px solid #e3eaf5;
  border-radius: 8px;
  background: #fff;
}

.manager-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
}

.manager-row span {
  overflow-wrap: anywhere;
  font-weight: 800;
}

.manager-empty {
  padding: 16px;
  color: #657084;
  text-align: center;
  font-weight: 800;
}

.backup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.primary-link-button,
.secondary-file-button {
  display: inline-grid;
  place-items: center;
  min-height: 44px;
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 900;
  cursor: pointer;
}

.primary-link-button {
  background: #2563eb;
  color: #fff;
}

.primary-link-button:hover {
  background: #1d4ed8;
  text-decoration: none;
}

.secondary-file-button {
  border: 1px solid #ccd5e3;
  background: #fff;
  color: #263346;
}

.secondary-file-button:hover {
  border-color: #9fb0c8;
  background: #f8fafc;
}

.help-text {
  max-width: 760px;
  margin: 16px 0 0;
  color: #657084;
  line-height: 1.7;
}

/* Visual polish layer */
:root {
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --surface-tint: #f4f8ff;
  --border: #d9e2ef;
  --border-strong: #bccbe0;
  --text: #142033;
  --muted: #64748b;
  --muted-2: #8a97aa;
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eaf2ff;
  --success: #138a54;
  --warning: #b45309;
  --danger: #b42318;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 32px rgba(15, 23, 42, 0.08);
  --shadow-lg: 0 24px 64px rgba(15, 23, 42, 0.14);
  --radius: 8px;
}

body {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.64), rgba(255, 255, 255, 0) 220px),
    var(--bg);
  color: var(--text);
  font-size: 15px;
}

a {
  color: var(--primary);
}

button,
a,
input,
select,
textarea {
  transition: border-color 160ms ease, background 160ms ease, color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

button:active {
  transform: translateY(1px);
}

.app-header {
  min-height: 64px;
  padding: 0 36px;
  border-bottom-color: rgba(196, 208, 226, 0.78);
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 1px 0 rgba(15, 23, 42, 0.03);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #111827;
  letter-spacing: 0;
}

.brand::before {
  content: "";
  width: 10px;
  height: 22px;
  border-radius: 999px;
  background: var(--primary);
  box-shadow: inset 0 -8px 0 rgba(255, 255, 255, 0.24);
}

.app-nav a {
  border-radius: 999px;
  padding: 8px 10px;
  color: var(--muted);
}

.app-nav a:hover {
  background: var(--primary-soft);
  color: var(--primary);
  text-decoration: none;
}

.auth-card,
.kb-sidebar,
.admin-list-panel,
.article-panel,
.editor-panel,
.admin-wide-panel,
.taxonomy-card,
.watermark-dialog {
  border-color: rgba(205, 216, 232, 0.92);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
}

.auth-card {
  padding: 34px;
  box-shadow: var(--shadow-lg);
}

.auth-card h1,
.sidebar-head h1,
.editor-toolbar h1,
.article-head h1,
.panel-head h1 {
  color: #0f172a;
  font-weight: 900;
}

.auth-card p,
.article-meta,
.help-text,
.media-card__body span,
.article-item span,
.sidebar-head span,
.editor-status-row {
  color: var(--muted);
}

.auth-card input,
.search-input,
.select-input,
.editor-form input,
.editor-form select,
.editor-form textarea,
.import-form input,
.import-form textarea,
.inline-form input,
.compact-select,
.watermark-controls select {
  border-color: var(--border);
  background: #fff;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

.auth-card input:hover,
.search-input:hover,
.select-input:hover,
.editor-form input:hover,
.editor-form select:hover,
.editor-form textarea:hover,
.import-form input:hover,
.import-form textarea:hover,
.inline-form input:hover,
.compact-select:hover {
  border-color: var(--border-strong);
}

.auth-card input:focus,
.search-input:focus,
.select-input:focus,
.editor-form input:focus,
.editor-form select:focus,
.editor-form textarea:focus,
.import-form input:focus,
.import-form textarea:focus,
.inline-form input:focus,
.compact-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}

.primary-button,
.auth-card button,
.primary-link-button {
  background: var(--primary);
  box-shadow: 0 8px 18px rgba(37, 99, 235, 0.20);
}

.primary-button:hover,
.auth-card button:hover,
.primary-link-button:hover {
  background: var(--primary-strong);
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.24);
}

.secondary-button,
.icon-button,
.secondary-file-button,
.media-actions button,
.manager-row button,
.rich-toolbar button,
.rich-toolbar select {
  border-color: var(--border);
  background: #fff;
  color: #233044;
  box-shadow: var(--shadow-sm);
}

.secondary-button:hover,
.icon-button:hover,
.secondary-file-button:hover,
.media-actions button:hover,
.manager-row button:hover,
.rich-toolbar button:hover,
.rich-toolbar select:focus {
  border-color: #aac0dd;
  background: var(--surface-tint);
  color: var(--primary);
  text-decoration: none;
}

.danger {
  border-color: #f3c1bd;
  background: #fffafa;
  color: var(--danger);
}

.danger:hover {
  border-color: #ee9b95;
  background: #fff1f0;
  color: var(--danger);
}

.kb-shell,
.admin-shell {
  gap: 24px;
  margin-top: 26px;
}

.kb-sidebar,
.admin-list-panel {
  top: 88px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.94);
}

.search-input,
.select-input {
  height: 46px;
  margin-bottom: 12px;
}

.article-list {
  gap: 10px;
}

.article-item {
  border-color: transparent;
  background: #f8fafc;
  padding: 13px 14px;
  box-shadow: none;
}

.article-item:hover {
  border-color: #c7d6ea;
  background: #f3f7fd;
}

.article-item.is-active {
  border-color: #aec7ed;
  background: var(--primary-soft);
  box-shadow: inset 3px 0 0 var(--primary);
}

.article-panel,
.editor-panel {
  background: rgba(255, 255, 255, 0.96);
}

.article-layout {
  grid-template-columns: 280px minmax(0, 1fr);
}

.article-toc {
  top: 88px;
  background: #fbfdff;
  border-right-color: #e8eef7;
}

.article-toc__title {
  letter-spacing: 0;
}

.article-toc a,
.editor-toc a,
.editor-toc .toc-empty {
  color: var(--muted);
}

.article-toc a:hover,
.article-toc a.is-active,
.editor-toc a:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.article-head {
  padding: 38px 42px 22px;
  background: linear-gradient(180deg, #fff, #fbfdff);
}

.article-head h1 {
  max-width: 980px;
  font-size: 33px;
}

.article-category {
  color: var(--primary);
  letter-spacing: 0;
}

.article-meta,
.tag-row,
.article-body {
  padding-left: 42px;
  padding-right: 42px;
}

.article-body {
  max-width: 980px;
  color: #1f2937;
  font-size: 16px;
  line-height: 1.86;
}

.article-body h2 {
  border-top-color: #e7edf6;
  font-size: 25px;
}

.article-body h3 {
  font-size: 21px;
}

.article-body img {
  border-color: #dfe7f2;
  border-radius: var(--radius);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.08);
}

.tag {
  border-color: #cbdcf4;
  background: #f2f7ff;
  color: #345276;
}

.admin-tabs {
  top: 64px;
  align-items: center;
  gap: 6px;
  min-height: 54px;
  margin-top: 0;
  border: 1px solid rgba(205, 216, 232, 0.8);
  border-top: 0;
  border-radius: 0 0 var(--radius) var(--radius);
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.90);
  box-shadow: 0 10px 26px rgba(15, 23, 42, 0.06);
}

.admin-tabs button {
  height: 38px;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0 14px;
  color: var(--muted);
}

.admin-tabs button:hover {
  border-color: #d3dfef;
  background: #f8fbff;
}

.admin-tabs button.is-active {
  border-color: #b8cff5;
  background: var(--primary-soft);
  color: var(--primary);
}

.admin-tabs button.is-active,
.admin-tabs button:hover {
  border-bottom-color: #b8cff5;
}

.editor-panel,
.admin-wide-panel {
  padding: 26px;
}

.editor-toolbar {
  align-items: flex-start;
  gap: 18px;
  border-bottom: 1px solid #edf2f7;
  padding-bottom: 18px;
}

.toolbar-actions {
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.editor-status-row span {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  border-radius: 999px;
  padding: 0 10px;
  background: #f2f6fb;
}

.editor-status-row span:last-child {
  background: #fff7ed;
  color: var(--warning);
}

.form-grid {
  gap: 16px;
}

.editor-form {
  gap: 18px;
}

.rich-editor-block {
  gap: 12px;
}

.rich-toolbar {
  border-color: #d9e5f4;
  background: #f5f8fc;
  padding: 12px;
}

.editor-mode-switch {
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

.editor-mode-switch button.is-active {
  background: var(--primary);
}

.editor-workspace {
  grid-template-columns: 230px minmax(0, 1fr);
  gap: 14px;
}

.editor-toc {
  border-color: #dbe6f3;
  background: #fbfdff;
}

.rich-editor-surface,
.source-editor {
  border-color: #d7e1ee;
  box-shadow: inset 0 1px 0 rgba(15, 23, 42, 0.03);
}

.rich-editor-surface {
  padding: 26px 32px 40px;
  background: #fff;
}

.media-grid {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}

.media-card {
  border-color: #dbe5f1;
  background: #fff;
  box-shadow: var(--shadow-sm);
}

.media-card:hover {
  border-color: #c3d2e7;
  box-shadow: var(--shadow-md);
}

.media-card img {
  background: #f5f7fb;
}

.media-card__body {
  padding: 14px;
}

.media-actions button {
  min-height: 34px;
}

.panel-head {
  border-bottom: 1px solid #edf2f7;
  padding-bottom: 18px;
}

.taxonomy-card {
  background: #fbfdff;
  box-shadow: var(--shadow-sm);
}

.manager-row,
.manager-empty {
  border-color: #e0e8f3;
  box-shadow: var(--shadow-sm);
}

.admin-message {
  border-color: #bfe6cf;
  background: #f0fbf5;
  color: var(--success);
}

.message.error,
.admin-message.error,
.error {
  border-color: #ffd3cf;
  background: #fff1f0;
  color: var(--danger);
}

.modal-backdrop {
  background: rgba(15, 23, 42, 0.52);
  backdrop-filter: blur(5px);
}

.watermark-dialog {
  box-shadow: var(--shadow-lg);
}

.watermark-canvas-wrap {
  border-color: #d7e1ee;
}

@media (max-width: 860px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
    padding: 12px 20px;
  }

  .app-nav {
    flex-wrap: wrap;
  }

  .kb-shell,
  .admin-shell,
  .admin-tabs,
  .admin-wide-panel {
    width: min(100vw - 28px, 680px);
  }

  .admin-shell {
    grid-template-columns: 1fr;
    margin: 18px auto;
  }

  .kb-shell {
    grid-template-columns: 1fr;
    margin: 18px auto;
  }

  .admin-tabs {
    top: 100px;
    overflow-x: auto;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .kb-sidebar,
  .admin-list-panel,
  .article-toc {
    position: static;
    max-height: none;
  }

  .article-layout {
    grid-template-columns: 1fr;
  }

  .article-toc {
    border-right: 0;
    border-bottom: 1px solid #edf1f7;
    padding: 18px 20px;
  }

  .article-head,
  .editor-toolbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .article-head,
  .article-meta,
  .tag-row,
  .article-body {
    padding-left: 20px;
    padding-right: 20px;
  }

  .article-head h1 {
    font-size: 25px;
  }

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

  .toolbar-actions {
    flex-wrap: wrap;
  }

  .compact-select {
    width: min(100%, 260px);
  }

  .rich-editor-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .editor-workspace,
  .taxonomy-grid,
  .watermark-editor {
    grid-template-columns: 1fr;
  }

  .watermark-dialog {
    width: min(100vw - 24px, 680px);
    padding: 16px;
  }

  .watermark-canvas-wrap {
    max-height: 46vh;
  }

  .editor-toc {
    position: static;
    max-height: 240px;
  }

  .rich-editor-surface,
  .source-editor {
    min-height: 520px;
  }
}

/* Premium purple theme */
:root {
  --bg: #f6f3fb;
  --surface: #ffffff;
  --surface-soft: #faf8ff;
  --surface-tint: #f4efff;
  --border: #ded5ee;
  --border-strong: #c7b7df;
  --text: #1f1830;
  --muted: #726981;
  --muted-2: #9a8faa;
  --primary: #7c3aed;
  --primary-strong: #5b21b6;
  --primary-soft: #f0e8ff;
  --success: #0f8a64;
  --warning: #a15c11;
  --danger: #b42318;
  --shadow-sm: 0 1px 2px rgba(45, 31, 69, 0.07);
  --shadow-md: 0 16px 38px rgba(45, 31, 69, 0.10);
  --shadow-lg: 0 28px 72px rgba(45, 31, 69, 0.18);
}

body {
  background:
    radial-gradient(circle at 16% 0%, rgba(124, 58, 237, 0.10), rgba(124, 58, 237, 0) 330px),
    radial-gradient(circle at 100% 4%, rgba(76, 29, 149, 0.08), rgba(76, 29, 149, 0) 360px),
    linear-gradient(180deg, #fbf9ff 0%, #f6f3fb 42%, #f7f8fc 100%);
  color: var(--text);
}

.app-header {
  border-bottom-color: rgba(196, 181, 253, 0.42);
  background: rgba(252, 250, 255, 0.88);
  box-shadow: 0 10px 28px rgba(45, 31, 69, 0.05);
}

.brand {
  color: #1f1830;
}

.brand::before {
  background: linear-gradient(180deg, #9f7aea, #6d28d9);
  box-shadow: 0 8px 18px rgba(124, 58, 237, 0.28);
}

.app-nav a {
  color: #6d647a;
}

.app-nav a:hover {
  background: #f1eaff;
  color: #6d28d9;
}

.auth-card,
.kb-sidebar,
.admin-list-panel,
.article-panel,
.editor-panel,
.admin-wide-panel,
.taxonomy-card,
.watermark-dialog {
  border-color: rgba(216, 204, 235, 0.90);
  background: rgba(255, 255, 255, 0.94);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.84) inset,
    0 20px 50px rgba(45, 31, 69, 0.10);
}

.auth-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 247, 255, 0.96));
}

.auth-card h1,
.sidebar-head h1,
.editor-toolbar h1,
.article-head h1,
.panel-head h1 {
  color: #1b1430;
}

.article-category,
.admin-link,
a {
  color: #6d28d9;
}

.auth-card input,
.search-input,
.select-input,
.editor-form input,
.editor-form select,
.editor-form textarea,
.import-form input,
.import-form textarea,
.inline-form input,
.compact-select,
.watermark-controls select {
  border-color: #ddd3ee;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: 0 1px 2px rgba(45, 31, 69, 0.04);
}

.auth-card input:focus,
.search-input:focus,
.select-input:focus,
.editor-form input:focus,
.editor-form select:focus,
.editor-form textarea:focus,
.import-form input:focus,
.import-form textarea:focus,
.inline-form input:focus,
.compact-select:focus,
.watermark-controls select:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.14);
}

.primary-button,
.auth-card button,
.primary-link-button {
  background: linear-gradient(180deg, #8b5cf6, #6d28d9);
  box-shadow: 0 12px 24px rgba(109, 40, 217, 0.24);
}

.primary-button:hover,
.auth-card button:hover,
.primary-link-button:hover {
  background: linear-gradient(180deg, #7c3aed, #581c87);
  box-shadow: 0 14px 28px rgba(109, 40, 217, 0.30);
}

.secondary-button,
.icon-button,
.secondary-file-button,
.media-actions button,
.manager-row button,
.rich-toolbar button,
.rich-toolbar select {
  border-color: #dacfed;
  background: rgba(255, 255, 255, 0.92);
  color: #35264d;
}

.secondary-button:hover,
.icon-button:hover,
.secondary-file-button:hover,
.media-actions button:hover,
.manager-row button:hover,
.rich-toolbar button:hover,
.rich-toolbar select:focus {
  border-color: #b99de8;
  background: #f5efff;
  color: #6d28d9;
}

.article-item {
  background: rgba(250, 248, 255, 0.80);
}

.article-item:hover {
  border-color: #cdbdf0;
  background: #f8f4ff;
}

.article-item.is-active {
  border-color: #bba1ef;
  background: #f1eaff;
  box-shadow: inset 3px 0 0 #7c3aed;
}

.article-head {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(250, 247, 255, 0.86));
}

.article-toc,
.editor-toc {
  background: rgba(251, 249, 255, 0.88);
}

.article-toc a:hover,
.article-toc a.is-active,
.editor-toc a:hover {
  background: #f1eaff;
  color: #6d28d9;
}

.tag {
  border-color: #d7c7f5;
  background: #f5efff;
  color: #4c3575;
}

.article-body h2 {
  border-top-color: #ece4f7;
}

.article-body img {
  border-color: #e2d8f1;
  box-shadow: 0 16px 38px rgba(45, 31, 69, 0.11);
}

.admin-tabs {
  border-color: rgba(216, 204, 235, 0.82);
  background: rgba(252, 250, 255, 0.92);
  box-shadow: 0 16px 36px rgba(45, 31, 69, 0.08);
}

.admin-tabs button {
  color: #766b87;
}

.admin-tabs button:hover {
  border-color: #d6c7ef;
  background: #faf7ff;
  color: #6d28d9;
}

.admin-tabs button.is-active {
  border-color: #b99de8;
  background: linear-gradient(180deg, #f6f0ff, #eee5ff);
  color: #5b21b6;
  box-shadow: 0 8px 18px rgba(109, 40, 217, 0.12);
}

.editor-toolbar,
.panel-head {
  border-bottom-color: #ede5f7;
}

.editor-status-row span {
  background: #f6f0ff;
  color: #655277;
}

.rich-toolbar {
  border-color: #ddd2ef;
  background: #faf7ff;
}

.editor-mode-switch button.is-active {
  background: linear-gradient(180deg, #8b5cf6, #6d28d9);
}

.rich-editor-surface,
.source-editor {
  border-color: #ddd3ee;
}

.rich-editor-surface:focus,
.source-editor:focus {
  border-color: #8b5cf6;
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.14);
}

.media-card {
  border-color: #e0d6ef;
  background: rgba(255, 255, 255, 0.95);
}

.media-card:hover {
  border-color: #c5afe8;
  box-shadow: 0 18px 42px rgba(45, 31, 69, 0.13);
}

.media-card img {
  background:
    linear-gradient(45deg, #f4f1fb 25%, transparent 25%),
    linear-gradient(-45deg, #f4f1fb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f4f1fb 75%),
    linear-gradient(-45deg, transparent 75%, #f4f1fb 75%);
  background-color: #fff;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

.taxonomy-card,
.manager-row,
.manager-empty {
  border-color: #e1d8ef;
}

.admin-message {
  border-color: #c9eadb;
  background: #f2fbf7;
}

.modal-backdrop {
  background: rgba(33, 20, 51, 0.56);
}

.watermark-canvas-wrap {
  border-color: #ddd3ee;
}

@media (max-width: 860px) {
  .app-header,
  .admin-tabs {
    background: rgba(252, 250, 255, 0.94);
  }
}

/* A-Border brand */
.brand {
  min-height: 42px;
  font-size: 21px;
}

.brand::before {
  content: none;
}

.brand span {
  color: #1f1830;
  font-size: 21px;
  font-weight: 900;
  letter-spacing: 0;
  white-space: nowrap;
}

.auth-logo {
  display: inline-flex;
  align-items: center;
  margin-bottom: 20px;
}

.auth-logo span {
  color: #1f1830;
  font-size: 22px;
  font-weight: 900;
  white-space: nowrap;
}

@media (max-width: 860px) {
  .brand span,
  .auth-logo span {
    font-size: 18px;
  }
}
