:root {
  --aui-bg: #f7f7f5;
  --aui-surface: #fdf8f8;
  --aui-panel: #f3f2ef;
  --aui-panel-high: #ebe7e6;
  --aui-card: #fcfcfb;
  --aui-card-strong: #ffffff;
  --aui-border: #e7e7e4;
  --aui-border-strong: #d8d6d2;
  --aui-text: #111111;
  --aui-muted: #6b6b6b;
  --aui-soft: #8b8986;
  --aui-inverse: #1c1b1b;
  --aui-inverse-muted: #d8d5d2;
  --aui-blue: #5b8def;
  --aui-coral: #dd8b76;
  --aui-green: #6fae91;
  --aui-amber: #c7923b;
  --aui-radius-card: 24px;
  --aui-radius-control: 12px;
}

html,
body {
  background: var(--aui-bg) !important;
  color: var(--aui-text) !important;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif !important;
  letter-spacing: 0 !important;
}

body::before,
.grid-pattern {
  background-image:
    linear-gradient(rgba(28, 27, 27, 0.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(28, 27, 27, 0.035) 1px, transparent 1px) !important;
  background-size: 64px 64px !important;
}

.bg-minimal,
body.bg-minimal {
  background: var(--aui-bg) !important;
}

.bg-minimal::before {
  background: linear-gradient(180deg, rgba(91, 141, 239, 0.08), transparent 42%) !important;
}

/* Old dark Tailwind surfaces remapped to the Auralis light system. */
.bg-zinc-950,
.bg-zinc-950\/80,
.bg-zinc-950\/90 {
  background-color: rgba(247, 247, 245, 0.92) !important;
}

.bg-zinc-900,
.bg-zinc-900\/95,
.bg-zinc-900\/80,
.bg-zinc-900\/70,
.bg-zinc-900\/50,
.bg-zinc-900\/30 {
  background-color: var(--aui-panel) !important;
}

.bg-zinc-800,
.bg-zinc-800\/80,
.bg-zinc-800\/60,
.bg-zinc-800\/50,
.bg-zinc-800\/40,
.bg-zinc-800\/30,
.bg-zinc-800\/20,
.bg-zinc-700,
.bg-zinc-700\/50 {
  background-color: var(--aui-panel-high) !important;
}

.border-zinc-900,
.border-zinc-800,
.border-zinc-800\/60,
.border-zinc-800\/50,
.border-zinc-800\/40,
.border-zinc-800\/30,
.border-zinc-700,
.border-zinc-700\/50,
.border-zinc-700\/40,
.border-zinc-700\/30,
.border-zinc-600 {
  border-color: var(--aui-border) !important;
}

.text-zinc-100,
.text-zinc-200,
.text-gray-100,
.text-gray-200,
.text-white {
  color: var(--aui-text) !important;
}

.text-zinc-300,
.text-zinc-400,
.text-zinc-500,
.text-gray-300,
.text-gray-400,
.text-gray-500 {
  color: var(--aui-muted) !important;
}

.text-zinc-600,
.text-zinc-700,
.text-gray-600,
.text-gray-700,
.text-gray-800 {
  color: var(--aui-soft) !important;
}

.placeholder-zinc-600::placeholder,
.placeholder-zinc-500::placeholder {
  color: #9a9692 !important;
}

.glass-card,
.logo-container {
  background: var(--aui-card) !important;
  border: 1px solid var(--aui-border) !important;
  border-radius: var(--aui-radius-card) !important;
  box-shadow: none !important;
  backdrop-filter: none !important;
}

.admin-btn,
.pdf-ctrl-btn,
.icon-btn,
.media-act-btn {
  background: var(--aui-card) !important;
  border: 1px solid var(--aui-border) !important;
  color: var(--aui-muted) !important;
  border-radius: var(--aui-radius-control) !important;
  box-shadow: none !important;
}

.admin-btn:hover,
.pdf-ctrl-btn:hover:not(:disabled),
.icon-btn:hover,
.media-act-btn:hover {
  background: var(--aui-panel) !important;
  border-color: var(--aui-border-strong) !important;
  color: var(--aui-text) !important;
  transform: translateY(-1px);
}

.bg-blue-600,
.hover\:bg-blue-500:hover,
.bg-emerald-600,
.hover\:bg-emerald-500:hover,
.bg-violet-600,
.hover\:bg-violet-500:hover {
  background-color: var(--aui-text) !important;
  border-color: var(--aui-text) !important;
  color: var(--aui-card) !important;
}

.bg-blue-600 *,
.bg-emerald-600 *,
.bg-violet-600 *,
.hover\:bg-blue-500:hover *,
.hover\:bg-emerald-500:hover *,
.hover\:bg-violet-500:hover * {
  color: var(--aui-card) !important;
}

.bg-red-900\/30,
.hover\:bg-red-900\/50:hover {
  background-color: #fff0ee !important;
  border-color: #f0c8c2 !important;
  color: #9f3427 !important;
}

.input-field,
.input-pw,
input:not([type="checkbox"]):not([type="file"]),
textarea,
select {
  background: var(--aui-panel) !important;
  border: 1px solid var(--aui-border) !important;
  color: var(--aui-text) !important;
  border-radius: var(--aui-radius-control) !important;
  box-shadow: none !important;
}

.input-field:focus,
.input-pw:focus,
input:not([type="checkbox"]):not([type="file"]):focus,
textarea:focus,
select:focus {
  border-color: rgba(91, 141, 239, 0.55) !important;
  box-shadow: 0 0 0 4px rgba(91, 141, 239, 0.12) !important;
  outline: none !important;
}

input[type="checkbox"] {
  border-color: var(--aui-border-strong) !important;
  background-color: var(--aui-card) !important;
}

/* App shell */
#dashboard > header,
body > header {
  background: rgba(247, 247, 245, 0.86) !important;
  border-bottom: 1px solid var(--aui-border) !important;
  backdrop-filter: blur(18px) !important;
}

#dashboard main {
  max-width: 1280px !important;
}

#dashboard nav,
#editorModeToggle,
.theme-btn,
.flex.bg-zinc-800\/50.rounded-lg.p-1,
.flex.bg-zinc-900\/80.rounded-lg.p-1 {
  background: var(--aui-panel) !important;
  border: 1px solid var(--aui-border) !important;
  border-radius: 9999px !important;
}

.tab-btn,
#editorModeToggle button,
.theme-btn,
#pickerFilterAll,
#pickerFilterImage,
#pickerFilterVideo {
  border-radius: 9999px !important;
}

.tab-btn.active,
#editorModeToggle button.bg-blue-600,
.theme-btn.bg-zinc-700,
#pickerFilterAll.bg-zinc-700,
#pickerFilterImage.bg-zinc-700,
#pickerFilterVideo.bg-zinc-700 {
  background: var(--aui-card) !important;
  border-color: var(--aui-border) !important;
  color: var(--aui-text) !important;
}

/* Lists and cards */
.page-card {
  background: var(--aui-card) !important;
  border-color: var(--aui-border) !important;
  border-radius: var(--aui-radius-card) !important;
  box-shadow: none !important;
}

.page-card:hover {
  background: var(--aui-card-strong) !important;
  border-color: var(--aui-border-strong) !important;
  transform: translateY(-2px) !important;
}

.drag-handle {
  color: var(--aui-soft) !important;
}

.type-chip,
.type-badge,
.badge-html,
.badge-md,
.badge-novel,
.badge-folder,
.badge-toc,
.badge-link,
.badge-pdf {
  border-radius: 9999px !important;
  background: var(--aui-panel) !important;
  border: 1px solid var(--aui-border) !important;
  color: var(--aui-muted) !important;
  letter-spacing: 0.08em !important;
}

.type-badge-html,
.type-badge-md,
.type-badge-novel,
.type-badge-folder,
.type-badge-toc,
.type-badge-link,
.type-badge-pdf {
  border-radius: 9999px !important;
  border: 1px solid var(--aui-border) !important;
}

.accent-html,
.badge-html {
  background: #e58b64 !important;
  color: #ffffff !important;
}

.accent-md,
.badge-md {
  background: #5b8def !important;
  color: #ffffff !important;
}

.accent-novel,
.badge-novel {
  background: #9b8ce3 !important;
  color: #ffffff !important;
}

.accent-folder,
.badge-folder {
  background: #6fae91 !important;
  color: #ffffff !important;
}

.accent-toc,
.badge-toc {
  background: #66aebd !important;
  color: #ffffff !important;
}

.accent-link,
.badge-link {
  background: #d9798f !important;
  color: #ffffff !important;
}

.accent-pdf,
.badge-pdf {
  background: #c7923b !important;
  color: #ffffff !important;
}

.chip-html {
  background: #fff1ea !important;
  color: #a95530 !important;
}

.chip-md {
  background: #eef4ff !important;
  color: #2d5fa7 !important;
}

.chip-novel {
  background: #f2efff !important;
  color: #6854a8 !important;
}

.chip-folder {
  background: #edf8f2 !important;
  color: #3f7a5d !important;
}

.chip-toc {
  background: #edf8fa !important;
  color: #397480 !important;
}

.chip-link {
  background: #fff0f4 !important;
  color: #9b4054 !important;
}

.chip-pdf {
  background: #fff6e7 !important;
  color: #866020 !important;
}

/* Modals */
.modal-overlay {
  background: rgba(28, 27, 27, 0.34) !important;
  backdrop-filter: blur(14px) !important;
}

#pageModal > .relative,
#mediaPickerModal > .relative,
#mediaPreviewModal > .relative,
#passwordModal .glass-card {
  background: var(--aui-card) !important;
  border: 1px solid var(--aui-border) !important;
  border-radius: 28px !important;
  box-shadow: none !important;
}

#pageModal .sticky,
#mediaPickerModal .border-b,
#mediaPickerModal .border-t {
  background: rgba(252, 252, 251, 0.92) !important;
  border-color: var(--aui-border) !important;
}

#tiptapEditor,
#wysiwygContainer,
#rawCodeContainer textarea,
#livePreviewContainer,
#tocSortableList,
#folderFilesList,
#backupListContainer,
.drop-zone,
#mediaDropZone,
#htmlMediaDropZone,
#adminFolderDropZone,
#pdfDropZone {
  background: var(--aui-panel) !important;
  border-color: var(--aui-border) !important;
  color: var(--aui-text) !important;
  border-radius: var(--aui-radius-card) !important;
}

#livePreviewContent,
#livePreviewContent.theme-dark {
  background: var(--aui-card) !important;
  color: var(--aui-muted) !important;
}

.tiptap-menu {
  background: var(--aui-card) !important;
  border-color: var(--aui-border) !important;
  box-shadow: none !important;
}

.tiptap-menu button {
  color: var(--aui-muted) !important;
}

.tiptap-menu button:hover,
.tiptap-menu button.is-active {
  background: var(--aui-panel) !important;
  color: var(--aui-text) !important;
}

/* Tables and media */
table thead {
  background: var(--aui-panel) !important;
}

tbody tr:hover {
  background: rgba(28, 27, 27, 0.025) !important;
}

.media-item,
.media-picker-item {
  background: var(--aui-card) !important;
  border: 1px solid var(--aui-border) !important;
  border-radius: 18px !important;
}

.media-item:hover,
.media-picker-item:hover,
.media-picker-item.selected {
  border-color: var(--aui-border-strong) !important;
  box-shadow: 0 0 0 4px rgba(91, 141, 239, 0.12) !important;
}

.media-overlay {
  background: linear-gradient(to top, rgba(28, 27, 27, 0.78), rgba(28, 27, 27, 0.08)) !important;
}

.media-name,
.media-size {
  color: var(--aui-inverse-muted) !important;
}

/* Public pages */
#readProgress {
  background: linear-gradient(90deg, var(--aui-text), var(--aui-blue)) !important;
}

.md-content {
  color: var(--aui-muted) !important;
}

.md-content h1,
.md-content h2,
.md-content h3,
.preview-md h1,
.preview-md h2,
.preview-md h3 {
  color: var(--aui-text) !important;
  letter-spacing: 0 !important;
}

.md-content h2,
.preview-md h2 {
  border-color: var(--aui-border) !important;
}

.md-content pre,
.preview-md pre,
.md-content code,
.preview-md code {
  background: var(--aui-panel) !important;
  border-color: var(--aui-border) !important;
  color: var(--aui-text) !important;
}

.md-content blockquote,
.preview-md blockquote {
  border-left-color: var(--aui-border-strong) !important;
  color: var(--aui-muted) !important;
}

.novel-reader.theme-dark,
.novel-reader.theme-light,
.novel-reader.theme-sepia {
  background: var(--aui-card) !important;
  border: 1px solid var(--aui-border) !important;
  color: var(--aui-text) !important;
}

.file-item:hover {
  background: rgba(28, 27, 27, 0.035) !important;
}

#pdfViewerWrap {
  background: var(--aui-panel) !important;
  border-color: var(--aui-border) !important;
  border-radius: var(--aui-radius-card) !important;
}

#pdfControls {
  background: var(--aui-card) !important;
  border-color: var(--aui-border) !important;
}

#pdfScrollArea {
  background: var(--aui-panel) !important;
}

#pdfCanvas {
  box-shadow: none !important;
  border: 1px solid var(--aui-border) !important;
}

iframe#htmlFrame {
  background: var(--aui-card) !important;
}

footer {
  border-color: var(--aui-border) !important;
}

@media (max-width: 640px) {
  :root {
    --aui-radius-card: 18px;
  }

  #dashboard main,
  main {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
}
