:root {
  /* Color Palette - Minimalist Light (Beige/White) */
  --bg-body: #fdfbf7;
  --bg-card: #ffffff;
  --bg-card-hover: #fafaf9;
  --text-primary: #1c1917;
  --text-secondary: #57534e;
  --text-muted: #a8a29e;
  --primary: #44403c;
  --primary-hover: #1c1917;
  --accent: #d97706;
  --border: #e7e5e4;
  --border-light: #f5f5f4;
  
  /* Spacing & Layout */
  --container-width: 1000px;
  --header-height: 70px;
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 20px;
  
  /* Typography */
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s ease;
}

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

/* Layout */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* Header */
.header {
  height: var(--header-height);
  border-bottom: 1px solid var(--border);
  background: rgba(253, 251, 247, 0.8);
  backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.nav {
  display: flex;
  gap: 24px;
}

.nav-link {
  font-weight: 500;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.nav-link:hover, .nav-link.active {
  color: var(--text-primary);
}

/* Main Content */
.main {
  flex: 1;
  padding: 40px 0 80px;
}

/* Article List (Grid) */
.article-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 24px;
}

.article-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 24px;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.article-card:hover {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.05);
}

.card-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 12px;
  line-height: 1.4;
  color: var(--text-primary);
}

.card-summary {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 20px;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}

.card-tags {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.mini-tag {
  font-size: 0.75rem;
  color: var(--primary);
  background: rgba(0, 0, 0, 0.03);
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
}

.card-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  font-size: 0.85rem;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  padding-top: 16px;
  margin-top: auto;
}

.meta-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Tag Filter */
.tag-filter {
  display: flex;
  gap: 12px;
  margin-bottom: 40px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}

.tag-pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 16px;
  border-radius: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.tag-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.tag-pill.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.tag-count {
  font-size: 0.75rem;
  margin-left: 6px;
  opacity: 0.7;
}

/* Article Detail */
.article-container {
  max-width: 800px;
  margin: 0 auto;
}

.article-header {
  text-align: center;
  margin-bottom: 48px;
}

.article-title {
  font-size: 2.5rem;
  font-weight: 800;
  line-height: 1.2;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.article-info {
  display: flex;
  justify-content: center;
  gap: 24px;
  color: var(--text-secondary);
  font-size: 0.95rem;
}

.tags {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 20px;
}

.tag {
  background: var(--border-light);
  color: var(--text-secondary);
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 500;
}

/* Markdown Content */
.markdown-body {
  font-size: 1.1rem;
  color: var(--text-primary);
  line-height: 1.8;
}

.markdown-body h1, .markdown-body h2, .markdown-body h3 {
  margin-top: 2em;
  margin-bottom: 0.8em;
  font-weight: 700;
  color: var(--text-primary);
}

.markdown-body p {
  margin-bottom: 1.5em;
}

.markdown-body a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 4px;
}

.markdown-body pre {
  background: #1c1917;
  padding: 20px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow-x: auto;
  margin: 0 0 2em 0;
  border: 1px solid var(--border);
  border-top: none;
  color: #f5f5f4;
  transition: all 0.3s ease;
}

/* Code Block Folding */
.code-block-wrapper {
  margin: 2em 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.code-block-wrapper pre {
  margin: 0;
  border: none;
  border-radius: 0;
}

.code-block-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background: #292524;
  color: #a8a29e;
  font-family: var(--font-sans);
  font-size: 0.85rem;
  border-bottom: 1px solid #44403c;
}

.code-lang {
  font-weight: 600;
  color: #d6d3d1;
}

.code-toggle {
  background: transparent;
  border: none;
  color: inherit;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: background 0.2s;
}

.code-toggle:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}

.code-toggle svg {
  transition: transform 0.3s;
}

/* Collapsed State */
.code-block-wrapper.collapsed pre {
  display: none;
}

.code-block-wrapper.collapsed .code-toggle svg {
  transform: rotate(-90deg);
}

.code-block-wrapper.collapsed {
  border-color: var(--border);
}

.markdown-body code {
  font-family: var(--font-mono);
  font-size: 0.9em;
}

.markdown-body :not(pre) > code {
  background: rgba(0, 0, 0, 0.05);
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--primary);
}

.markdown-body blockquote {
  border-left: 4px solid var(--primary);
  padding-left: 20px;
  margin: 2em 0;
  color: var(--text-secondary);
  font-style: italic;
}

.markdown-body img {
  max-width: 100%;
  border-radius: var(--radius-md);
  margin: 2em 0;
}

.markdown-body table {
  width: 100%;
  border-collapse: collapse;
  margin: 2em 0;
  font-size: 0.95rem;
}

.markdown-body th,
.markdown-body td {
  border: 1px solid var(--border);
  padding: 10px 14px;
  text-align: left;
}

.markdown-body th {
  background: var(--bg-card);
  font-weight: 700;
}

.markdown-body tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.02);
}

/* Editor */
.writer-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  background: var(--bg-body);
}

.writer-header {
  padding: 20px 40px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  background: var(--bg-body);
  flex-shrink: 0;
}

.writer-inputs {
  flex: 1;
  margin-right: 40px;
}

.input-title-large {
  background: transparent;
  border: none;
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 800;
  width: 100%;
  outline: none;
  font-family: var(--font-sans);
  margin-bottom: 12px;
}

.input-title-large::placeholder {
  color: var(--text-muted);
}

.input-tags-line {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 0.95rem;
  width: 100%;
  outline: none;
  font-family: var(--font-mono);
}

.writer-actions {
  display: flex;
  gap: 12px;
  padding-top: 8px;
}

.writer-body {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr;
  overflow: hidden;
}

.editor-pane, .preview-pane {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.editor-pane {
  border-right: none;
}

.textarea-editor {
  flex: 1;
  width: 100%;
  background: var(--bg-body);
  border: none;
  padding: 40px;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 1.05rem;
  line-height: 1.7;
  resize: none;
  outline: none;
}

.preview-content {
  flex: 1;
  padding: 40px;
  overflow-y: auto;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.btn-outline:hover {
  border-color: var(--text-primary);
  color: var(--text-primary);
}

/* Utilities */
.text-center { text-align: center; }
.mt-4 { margin-top: 1rem; }
.mb-4 { margin-bottom: 1rem; }
.hidden { display: none; }

/* Icons */
.icon {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

/* Admin Dashboard */
.admin-dashboard {
  padding: 40px 0;
}

.dashboard-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 40px;
}

.dashboard-title {
  font-size: 2rem;
  font-weight: 800;
  color: var(--text-primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 24px;
  margin-bottom: 48px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 24px;
  border-radius: var(--radius-md);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 8px;
}

.stat-value {
  color: var(--text-primary);
  font-size: 2rem;
  font-weight: 700;
}

.section-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 24px;
  color: var(--text-primary);
}

.table-container {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  padding: 16px 24px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.admin-table th {
  background: var(--bg-body);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 0.9rem;
}

.admin-table td {
  color: var(--text-primary);
}

.admin-table tr:last-child td {
  border-bottom: none;
}

.table-link {
  color: var(--text-primary);
  font-weight: 500;
  text-decoration: none;
}

.table-link:hover {
  color: var(--primary);
}

.action-buttons {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-primary);
}

.delete-btn:hover {
  color: #ef4444;
  background: rgba(239, 68, 68, 0.1);
}

/* Beautify Floating Panel */
/* Float Beautify Ball */
.float-ball {
  position: fixed;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #111827, #1f2937);
  box-shadow: 0 18px 30px -12px rgba(0,0,0,0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 30;
  color: #fff;
  cursor: grab;
  transition: transform 0.25s ease, opacity 0.25s ease, left 0.25s ease, top 0.25s ease;
  overflow: visible;
}

.float-ball.dragging {
  opacity: 0.9;
  cursor: grabbing;
}

.float-ball .ball-face {
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.ball-dot {
  width: 8px;
  height: 8px;
  background: #ffffff;
  border-radius: 50%;
  opacity: 0.85;
  animation: pulse 1.6s ease-in-out infinite;
}

.ball-dot:nth-child(2) { animation-delay: 0.15s; }
.ball-dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.2); opacity: 1; }
}

.float-ball .ball-menu {
  position: absolute;
  left: 64px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  gap: 8px;
  background: rgba(17, 24, 39, 0.96);
  padding: 8px 10px;
  border-radius: 14px;
  box-shadow: 0 12px 30px -14px rgba(0,0,0,0.45);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.float-ball:hover .ball-menu,
.float-ball.retracted:hover .ball-menu,
.float-ball.dragging .ball-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(-50%) translateX(4px);
}

.menu-item {
  background: transparent;
  color: #e5e7eb;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 10px;
  padding: 6px 10px;
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s ease;
}

.menu-item:hover {
  background: rgba(255,255,255,0.12);
  border-color: rgba(255,255,255,0.35);
}

.float-ball.retracted {
  opacity: 0.65;
  transform: translateX(-14px);
}

.float-ball.right-edge.retracted {
  transform: translateX(14px);
}

.float-ball.left-edge {
  left: 0;
}

.float-ball.right-edge {
  right: 0;
}

.float-ball.right-edge .ball-menu {
  left: auto;
  right: 64px;
}

.float-ball.right-edge .ball-menu {
  flex-direction: row-reverse;
}

/* Admin Tags */
.tags-grid-admin {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 40px;
}

.tag-card-admin {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 16px;
  border-radius: var(--radius-md);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.tag-info {
  display: flex;
  flex-direction: column;
}

.tag-name {
  font-weight: 600;
  color: var(--text-primary);
}

.tag-count {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 4px;
}

.tag-actions {
  display: flex;
  gap: 4px;
}

/* Dropdown */
.dropdown {
  position: relative;
  display: inline-block;
  margin-right: 8px;
}
.dropdown-menu {
  position: absolute;
  top: 100%;
  left: 0;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  min-width: 160px;
  z-index: 100;
  padding: 4px;
  margin-top: 6px;
  display: none;
  animation: fadeIn 0.15s ease-out;
}
.dropdown-menu.show {
  display: block;
}
.dropdown-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.dropdown-item:hover {
  background-color: var(--border-light);
  color: var(--text-primary);
}
.dropdown-item svg {
  width: 16px;
  height: 16px;
  margin-right: 10px;
  fill: currentColor;
  opacity: 0.7;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Floating Preview Window */
.floating-preview {
  position: fixed;
  width: 400px; /* Default small size */
  height: 600px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  z-index: 80;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
  resize: both; /* Allow resizing */
  min-width: 300px;
  min-height: 200px;
  bottom: 40px;
  right: 40px;
  transition: opacity 0.2s ease;
}

.preview-handle {
  height: 40px;
  background-color: var(--bg-body);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.preview-handle span {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.preview-controls {
  display: flex;
  gap: 8px;
}

.preview-mini-btn {
  position: absolute;
  top: 8px;
  right: 10px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px rgba(0,0,0,0.08);
}

.preview-mini-btn:hover {
  color: var(--primary);
  border-color: var(--primary);
}

.preview-control-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-control-btn:hover {
  background-color: var(--border);
  color: var(--text-primary);
}

.preview-content-area {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background-color: #fff;
}

/* Adjust Writer Layout */
.writer-layout.full-width .writer-body {
  grid-template-columns: 1fr;
}
.writer-layout.full-width .editor-pane {
  border-right: none;
}

/* Floating Preview Window */
.floating-preview {
  position: fixed;
  width: 400px; /* Default small size */
  height: 600px;
  background-color: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
  z-index: 50;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-md);
  overflow: hidden;
  resize: both; /* Allow resizing */
  min-width: 300px;
  min-height: 200px;
  bottom: 40px;
  right: 40px;
  transition: opacity 0.2s ease;
}

.preview-handle {
  height: 40px;
  background-color: var(--bg-body);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  cursor: move;
  user-select: none;
  flex-shrink: 0;
}

.preview-handle span {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.preview-controls {
  display: flex;
  gap: 8px;
}

.preview-control-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.preview-control-btn:hover {
  background-color: var(--border);
  color: var(--text-primary);
}

.preview-content-area {
  flex: 1;
  overflow: auto;
  padding: 20px;
  background-color: #fff;

}

/* Adjust Writer Layout */
.writer-layout.full-width .writer-body {
  grid-template-columns: 1fr;
}
.writer-layout.full-width .editor-pane {
  border-right: none;
}

/* Centered Writer and New Layout */
.writer-layout {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height));
  position: relative;
}

.writer-body {
  /* Using flex to center the editor */
  display: flex !important;
  justify-content: center;
  background-color: var(--bg-body);
}

.editor-pane {
  max-width: 800px; /* Centered max width */
  width: 100%;
  border-right: 1px solid var(--border-light); /* Subtle border */
  border-left: 1px solid var(--border-light);
  background: var(--bg-card);
  box-shadow: 0 0 40px rgba(0,0,0,0.02);
}

/* Move buttons */
.writer-header {
  /* Redefine header layout */
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 40px;
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
}

.writer-inputs {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  max-width: 800px;
  margin: 0 auto; /* Center inputs */
}

/* Left aligned action buttons container */
.header-left-actions {
  position: absolute;
  left: 40px;
  top: 10px; /* Adjust based on header height */
  display: flex;
  gap: 8px;
  height: 40px;
  align-items: center;
}

/* Floating Import Button (Bottom Right) */
.fixed-import-btn {
  position: fixed;
  bottom: 40px;
  right: 40px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 40;
  transition: all 0.2s;
  color: var(--text-secondary);
}
.fixed-import-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(0,0,0,0.15);
  color: var(--primary);
}

/* --- Writer Refresh 2026 --- */
.writer-layout {
  background: var(--bg-body);
}

.writer-header {
  padding: 24px 48px 12px;
  display: flex;
  gap: 24px;
  align-items: flex-start;
  justify-content: space-between;
  background: var(--bg-body);
  border-bottom: 1px solid var(--border-light);
}

.writer-header-left {
  flex: 1;
  min-width: 0;
}

.writer-header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.meta-inline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.chip-btn {
  border: 1px dashed var(--border);
  background: transparent;
  color: var(--text-secondary);
  padding: 6px 12px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.15s ease;
}

.chip-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.meta-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: #fff;
  border-radius: 10px;
  cursor: pointer;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.meta-toggle:hover {
  border-color: var(--primary);
  box-shadow: 0 8px 20px rgba(0,0,0,0.04);
}

.input-title-large {
  text-align: left;
  font-size: 2.2rem;
  margin: 0 0 6px 0;
}

.writer-body {
  padding: 0 48px 32px;
  background: var(--bg-body);
}

.editor-shell {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: 0 16px 40px rgba(0,0,0,0.04);
  overflow: hidden;
}

.editor-pane {
  max-width: 960px;
  width: 100%;
  margin: 0 auto;
  background: #fff;
  border: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  box-shadow: none;
}

.editor-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: #fff;
  border-bottom: 1px solid var(--border-light);
  padding: 10px 18px;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}

.toolbar-text {
  font-weight: 700;
  font-size: 0.9rem;
}

.textarea-editor {
  background: #fff;
  padding: 32px;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  border: none;
}

.meta-panel {
  position: fixed;
  top: var(--header-height, 72px);
  right: 0;
  width: 420px;
  max-width: 90vw;
  height: calc(100vh - var(--header-height, 72px));
  background: #fff;
  box-shadow: -12px 0 30px rgba(0,0,0,0.08);
  border-left: 1px solid var(--border-light);
  transform: translateX(100%);
  transition: transform 0.25s ease;
  z-index: 120;
  padding: 24px;
  overflow-y: auto;
}

.meta-panel.open {
  transform: translateX(0);
}

.meta-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.meta-title {
  font-weight: 700;
  font-size: 1.05rem;
}

.meta-grid {
  display: grid;
  gap: 16px;
}

.meta-field label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
}

.field-hint {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: 6px;
}

.cover-dropzone {
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
  text-align: center;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 140px;
  display: grid;
  place-items: center;
  background: var(--bg-body);
}

.cover-dropzone.dragging {
  border-color: var(--primary);
  color: var(--primary);
  background: #f8fbff;
}

.cover-preview {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.08);
}

.cover-loading {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.cover-url-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.preview-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.95rem;
  background: var(--bg-body);
  border-bottom: 1px solid var(--border-light);
}

.floating-preview.hidden {
  opacity: 0;
  pointer-events: none;
}

.zen-mode .header {
  display: none;
}

.zen-mode .writer-header {
  padding-top: 12px;
}

.zen-mode #floating-preview {
  display: none;
}

.float-ball.fab-hidden {
  opacity: 0;
  pointer-events: none;
}

/* Floating Preview - Minimized State */
.floating-preview.minimized {
  width: 40px !important;
  height: 40px !important;
  min-width: 40px !important;
  min-height: 40px !important;
  overflow: hidden;
  resize: none;
  border-radius: 50%;
  bottom: 110px; /* Above import button */
  right: 40px;
  left: auto !important;
  top: auto !important;
  padding: 0;
  cursor: pointer;
  background: var(--primary);
  color: white;
  justify-content: center;
  align-items: center;
  border: none;
}

.floating-preview.minimized .preview-handle, 
.floating-preview.minimized .preview-content-area {
  display: none;
}

/* Icon for minimized state */
.preview-minimized-icon {
  display: none;
}
.floating-preview.minimized .preview-minimized-icon {
  display: block;
  width: 24px;
  height: 24px;
  fill: currentColor;
}

/* Restore floating preview styles tweaks */
.preview-handle {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
}


/* Editor Toolbar */
.editor-toolbar {
  display: flex;
  gap: 8px;
  padding: 8px 16px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-light);
  flex-wrap: wrap;
}

.toolbar-btn {
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  padding: 6px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.toolbar-btn:hover {
  background: var(--bg-card-hover);
  color: var(--text-primary);
  border-color: var(--border-light);
}

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

/* Save Status Indicator */
.save-status {
  margin-left: auto;
  font-size: 0.85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
}

.save-status.saving {
  color: var(--accent);
}

.save-status.saved {
  color: #10b981;
}

/* Cover Image Input Area */
.cover-image-area {
  padding: 0 40px;
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.input-cover {
  flex: 1;
  background: transparent;
  border: none;
  font-family: var(--font-sans);
  font-size: 0.9rem;
  color: var(--text-secondary);
  padding: 8px 0;
  border-bottom: 1px solid transparent;
  transition: border-color 0.2s;
}

.input-cover:focus {
  outline: none;
  border-bottom-color: var(--border);
  color: var(--text-primary);
}

/* Index Page Search & Cover */
.search-container {
  max-width: 600px;
  margin: 0 auto 30px;
  position: relative;
}

.search-input {
  width: 100%;
  padding: 12px 20px 12px 48px;
  border: 1px solid var(--border);
  border-radius: 50px;
  background: var(--bg-card);
  font-size: 1rem;
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(68, 64, 60, 0.1);
}

.search-icon-absolute {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}

.article-card-cover {
  width: 100%;
  height: 200px;
  overflow: hidden;
  border-radius: var(--radius-md);
  margin-bottom: 16px;
  background-color: var(--bg-card-hover);
}

.article-card-cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

.article-card:hover .article-card-cover img {
  transform: scale(1.05);
}


/* Clean up Writer Header Layout */
.writer-header {
  display: flex !important;
  align-items: flex-start !important; /* Allow variable height */
  padding: 24px 40px !important;
  height: auto !important;
  gap: 32px;
}

.header-left-actions {
  position: static !important; /* Remove absolute positioning */
  display: flex;
  flex-direction: column; /* Stack buttons vertically or just keep them block? */
  gap: 12px;
  margin-top: 4px; /* Align with title input */
  flex-shrink: 0;
  width: 140px; /* Fixed width for stability */
}

.header-left-actions .btn {
  width: 100%;
  justify-content: flex-start;
}

.writer-inputs {
  flex: 1;
  max-width: 720px !important;
  margin: 0 auto; /* Center roughly */
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Refined Inputs */
.input-title-large {
  font-size: 2.2rem !important;
  font-weight: 800;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 0;
  background: transparent;
  outline: none;
  width: 100%;
  color: var(--text-primary);
  transition: border-color 0.2s;
  text-align: left; /* Center looks weird with side actions */
}

.input-title-large:focus {
  border-bottom-color: var(--border);
}

.meta-inputs-row {
  display: flex;
  gap: 24px;
  align-items: center;
}

.input-minimal {
  flex: 1;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border-light);
  padding: 8px 0;
  font-size: 0.95rem;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.input-minimal:focus {
  border-bottom-color: var(--text-primary);
  color: var(--text-primary);
  outline: none;
}

/* Hide old separate inputs styling if needed */
.cover-image-area {
  margin: 0 !important;
  padding: 0 !important;
  flex: 1;
}

/* Editor Toolbar Polish */
.editor-toolbar {
  border-bottom: 1px solid var(--border-light);
  background: #fff; /* Ensure it pops against bg */
  border-radius: var(--radius-md) var(--radius-md) 0 0; /* Rounded top */
  padding: 10px 20px;
}

.writer-body {
  margin-top: 20px;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 24px rgba(0,0,0,0.03); /* Softer shadow */
}

.editor-pane {
  background: #fff;
  border: none !important;
  border-radius: 0 0 var(--radius-md) var(--radius-md); /* Rounded bottom */
  min-height: calc(100vh - 300px);
}
