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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Hiragino Sans', sans-serif;
  background: #f8f9fb;
  color: #1a1a2e;
  min-height: 100vh;
}

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

a:hover {
  color: #1d4ed8;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid #e2e6ef;
  background: #fff;
}

.header h1 {
  font-size: 1.2rem;
  font-weight: 300;
  color: #2563eb;
  letter-spacing: 0.08em;
}

.header nav {
  display: flex;
  gap: 16px;
  align-items: center;
}

.header nav a {
  font-size: 0.85rem;
  color: #6b7280;
}

.header nav a:hover {
  color: #2563eb;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #e2e6ef;
  border-radius: 6px;
  background: #fff;
  color: #1a1a2e;
  font-size: 0.85rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.btn:hover {
  border-color: #2563eb;
  background: #f0f4ff;
}

.btn-primary {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.btn-primary:hover {
  background: #1d4ed8;
}

.btn-danger {
  border-color: #ef4444;
  color: #ef4444;
}

.btn-danger:hover {
  background: #fef2f2;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 0.8rem;
}

/* Form controls */
input[type="text"],
input[type="password"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #e2e6ef;
  border-radius: 6px;
  background: #fff;
  color: #1a1a2e;
  font-size: 0.9rem;
  font-family: inherit;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

textarea {
  resize: vertical;
  min-height: 60px;
}

label {
  display: block;
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.form-group {
  margin-bottom: 16px;
}

/* Checkbox */
.checkbox-group {
  display: flex;
  gap: 20px;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.9rem;
  color: #1a1a2e;
  cursor: pointer;
  text-transform: none;
  letter-spacing: 0;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #2563eb;
}

/* --- List Page --- */
.list-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

.toolbar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.toolbar .search-input {
  flex: 1;
  min-width: 200px;
}

.toolbar select {
  width: auto;
  min-width: 140px;
}

.post-count {
  font-size: 0.8rem;
  color: #9ca3af;
  margin-bottom: 12px;
}

/* Post table */
.post-table {
  width: 100%;
  border-collapse: collapse;
}

.post-table th,
.post-table td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid #e2e6ef;
}

.post-table th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9ca3af;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.post-table th:hover {
  color: #6b7280;
}

.post-table th .sort-arrow {
  margin-left: 4px;
  opacity: 0.5;
}

.post-table th .sort-arrow.active {
  opacity: 1;
  color: #2563eb;
}

.post-table tr:hover td {
  background: #f0f4ff;
}

.post-table .title-cell {
  max-width: 400px;
}

.post-table .title-cell a {
  color: #1a1a2e;
  font-weight: 500;
}

.post-table .title-cell a:hover {
  color: #2563eb;
}

.post-table .date-cell {
  white-space: nowrap;
  font-size: 0.85rem;
  color: #6b7280;
}

.post-table .filename-cell {
  font-size: 0.8rem;
  color: #9ca3af;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.tag-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #eff6ff;
  color: #2563eb;
  font-size: 0.75rem;
  margin: 1px 2px;
  border: 1px solid #dbeafe;
}

.draft-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #fffbeb;
  color: #d97706;
  font-size: 0.75rem;
  border: 1px solid #fde68a;
}

.featured-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  background: #f0fdf4;
  color: #16a34a;
  font-size: 0.75rem;
  border: 1px solid #bbf7d0;
}

/* --- Editor Page --- */
.editor-container {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 0;
  height: calc(100vh - 57px);
}

.sidebar {
  background: #fff;
  border-right: 1px solid #e2e6ef;
  padding: 20px;
  overflow-y: auto;
}

.sidebar h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #2563eb;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 1px solid #e2e6ef;
}

.editor-main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 20px;
  border-bottom: 1px solid #e2e6ef;
  background: #fafbfc;
}

.editor-toolbar .filename {
  font-size: 0.85rem;
  color: #9ca3af;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.editor-toolbar .actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.unsaved-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f59e0b;
  display: none;
}

.unsaved-dot.visible {
  display: inline-block;
}

.editor-content {
  flex: 1;
  overflow: auto;
  padding: 0;
}

/* Tag Input */
.tag-input-container {
  border: 1px solid #e2e6ef;
  border-radius: 6px;
  background: #fff;
  padding: 6px;
  min-height: 38px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  cursor: text;
  position: relative;
}

.tag-input-container:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 10px;
  color: #2563eb;
  font-size: 0.8rem;
}

.tag-chip .remove {
  cursor: pointer;
  opacity: 0.6;
  font-size: 0.9rem;
  line-height: 1;
}

.tag-chip .remove:hover {
  opacity: 1;
  color: #ef4444;
}

.tag-input-field {
  border: none;
  background: transparent;
  color: #1a1a2e;
  font-size: 0.85rem;
  outline: none;
  flex: 1;
  min-width: 80px;
  padding: 2px 4px;
}

.tag-suggestions {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #e2e6ef;
  border-radius: 6px;
  margin-top: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  display: none;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.tag-suggestions.visible {
  display: block;
}

.tag-suggestion-item {
  padding: 6px 12px;
  cursor: pointer;
  font-size: 0.85rem;
  display: flex;
  justify-content: space-between;
}

.tag-suggestion-item:hover,
.tag-suggestion-item.active {
  background: #f0f4ff;
}

.tag-suggestion-item .count {
  color: #9ca3af;
  font-size: 0.75rem;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 0.85rem;
  animation: toast-in 0.3s ease;
  border: 1px solid;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.toast-success {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #bbf7d0;
}

.toast-error {
  background: #fef2f2;
  color: #ef4444;
  border-color: #fecaca;
}

@keyframes toast-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* EasyMDE light theme */
.EasyMDEContainer {
  height: 100%;
  display: flex;
  flex-direction: column;
}

.EasyMDEContainer .CodeMirror {
  flex: 1;
  background: #fff;
  color: #1a1a2e;
  border: none;
  border-radius: 0;
  font-size: 0.95rem;
  line-height: 1.7;
}

.EasyMDEContainer .CodeMirror-cursor {
  border-left-color: #1a1a2e;
}

.EasyMDEContainer .CodeMirror-selected {
  background: #dbeafe !important;
}

.EasyMDEContainer .CodeMirror-focused .CodeMirror-selected {
  background: #bfdbfe !important;
}

.EasyMDEContainer .editor-toolbar {
  background: #fafbfc;
  border-bottom: 1px solid #e2e6ef;
  border-top: none;
  padding: 4px 8px;
}

.EasyMDEContainer .editor-toolbar button {
  color: #6b7280 !important;
  border: none;
}

.EasyMDEContainer .editor-toolbar button:hover,
.EasyMDEContainer .editor-toolbar button.active {
  background: #eff6ff;
  color: #2563eb !important;
}

.EasyMDEContainer .editor-toolbar i.separator {
  border-left-color: #e2e6ef;
}

.EasyMDEContainer .editor-preview,
.EasyMDEContainer .editor-preview-side {
  background: #fafbfc;
  color: #1a1a2e;
  border: none;
  border-left: 1px solid #e2e6ef;
  padding: 20px;
}

.EasyMDEContainer .editor-preview h1,
.EasyMDEContainer .editor-preview h2,
.EasyMDEContainer .editor-preview h3,
.EasyMDEContainer .editor-preview-side h1,
.EasyMDEContainer .editor-preview-side h2,
.EasyMDEContainer .editor-preview-side h3 {
  color: #1e40af;
}

.EasyMDEContainer .editor-preview pre,
.EasyMDEContainer .editor-preview-side pre {
  background: #f1f5f9;
  border: 1px solid #e2e6ef;
  border-radius: 6px;
}

.EasyMDEContainer .editor-preview code,
.EasyMDEContainer .editor-preview-side code {
  color: #2563eb;
}

.EasyMDEContainer .editor-statusbar {
  background: #fafbfc;
  border-top: 1px solid #e2e6ef;
  color: #9ca3af;
}

.EasyMDEContainer .cm-header {
  color: #1e40af;
}

.EasyMDEContainer .cm-link {
  color: #2563eb;
}

.EasyMDEContainer .cm-url {
  color: #9ca3af;
}

.EasyMDEContainer .cm-comment {
  color: #9ca3af;
}

.EasyMDEContainer .cm-quote {
  color: #6b7280;
}

.EasyMDEContainer .cm-strong {
  color: #d97706;
}

.EasyMDEContainer .cm-em {
  color: #7c3aed;
}

/* Delete confirm modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}

.modal {
  background: #fff;
  border: 1px solid #e2e6ef;
  border-radius: 12px;
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.modal h3 {
  color: #1a1a2e;
  margin-bottom: 12px;
}

.modal p {
  color: #6b7280;
  font-size: 0.9rem;
  margin-bottom: 20px;
}

.modal .actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* Toolbar left */
.toolbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Build Status Badge */
.build-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 10px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 500;
  border: 1px solid;
  cursor: pointer;
  transition: opacity 0.2s;
  background: none;
  font-family: inherit;
}

.build-badge:hover {
  opacity: 0.8;
}

.build-succeed {
  background: #f0fdf4;
  color: #16a34a;
  border-color: #bbf7d0;
}

.build-failed, .build-cancelled {
  background: #fef2f2;
  color: #ef4444;
  border-color: #fecaca;
}

.build-running, .build-pending, .build-provisioning {
  background: #fffbeb;
  color: #d97706;
  border-color: #fde68a;
}

.build-unknown {
  background: #f3f4f6;
  color: #6b7280;
  border-color: #e5e7eb;
}

.build-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Proofread Panel */
.proof-panel {
  border-bottom: 1px solid #e2e6ef;
  background: #fafbfc;
  max-height: 300px;
  overflow-y: auto;
}

.proof-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  border-bottom: 1px solid #e2e6ef;
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 10;
}

.proof-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: #1a1a2e;
}

.proof-close {
  background: none;
  border: none;
  font-size: 1.2rem;
  color: #9ca3af;
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}

.proof-close:hover {
  color: #ef4444;
}

.proof-summary {
  padding: 8px 16px;
  font-size: 0.85rem;
  color: #6b7280;
  border-bottom: 1px solid #e2e6ef;
}

.proof-list {
  padding: 4px 0;
}

.proof-item {
  padding: 10px 16px;
  border-bottom: 1px solid #f0f1f3;
  border-left: 3px solid #e2e6ef;
  position: relative;
}

.proof-item:last-child {
  border-bottom: none;
}

.proof-type-typo {
  border-left-color: #ef4444;
}

.proof-type-grammar {
  border-left-color: #f59e0b;
}

.proof-type-readability {
  border-left-color: #3b82f6;
}

.proof-type-consistency {
  border-left-color: #8b5cf6;
}

.proof-original {
  font-size: 0.85rem;
  color: #ef4444;
  text-decoration: line-through;
  margin-bottom: 4px;
}

.proof-corrected {
  font-size: 0.85rem;
  color: #16a34a;
  margin-bottom: 4px;
}

.proof-reason {
  font-size: 0.8rem;
  color: #6b7280;
  margin-bottom: 6px;
}

.proof-apply {
  border-color: #2563eb;
  color: #2563eb;
}

.proof-apply:hover {
  background: #eff6ff;
}

.proof-empty {
  padding: 16px;
  text-align: center;
  color: #9ca3af;
  font-size: 0.85rem;
}

/* Responsive */
@media (max-width: 900px) {
  .editor-container {
    grid-template-columns: 1fr;
    height: auto;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid #e2e6ef;
  }

  .toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar select {
    width: 100%;
  }
}
