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

:root {
  --sidebar-width: 260px;
  --toolbar-height: 56px;
  --bg-primary: #ffffff;
  --bg-secondary: #f9fafb;
  --bg-tertiary: #f3f4f6;
  --bg-hover: #f3f4f6;
  --text-primary: #111827;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --accent: #004eeb;
  --accent-hover: #003bc2;
  --accent-light: #e5edff;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --success: #10b981;
  --warning: #f59e0b;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Inter', sans-serif;
  background: var(--bg-secondary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

.app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-primary);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

/* Sidebar Logo */
.sidebar-logo {
  padding: 20px 16px 16px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.logo-surface {
  color: var(--text-primary);
}

.logo-content {
  color: var(--accent);
}

/* System Folders Section */
.system-folders {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.system-folders-header {
  padding: 8px 16px;
}

.system-folders-header h2 {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
}

.system-folder-wrapper {
  position: relative;
}

.system-folder-item {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 10px;
  cursor: pointer;
  transition: background 0.1s;
  color: var(--text-primary);
}

.system-folder-item:hover {
  background: var(--bg-hover);
}

.system-folder-item.active,
.system-folder-item.expanded {
  background: var(--bg-hover);
}

.system-folder-icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.system-folder-name {
  font-size: 13px;
  font-weight: 500;
  flex: 1;
}

.system-folder-arrow {
  font-size: 14px;
  color: var(--text-muted);
  transition: transform 0.2s;
}

.system-folder-item.expanded .system-folder-arrow {
  transform: rotate(90deg);
}

.system-folder-files {
  display: none;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-light);
}

.system-folder-files.open {
  display: block;
}

.system-file-item {
  display: flex;
  align-items: center;
  padding: 6px 16px 6px 42px;
  gap: 8px;
  cursor: pointer;
  transition: background 0.1s;
  color: var(--text-secondary);
  font-size: 12px;
}

.system-file-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.system-file-item.active {
  background: var(--accent-light);
  color: var(--accent-hover);
}

.system-file-icon {
  font-size: 14px;
}

.system-file-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Media thumbnail in system folder */
.system-media-item {
  display: flex;
  align-items: center;
  padding: 4px 16px 4px 42px;
  gap: 8px;
  cursor: pointer;
  transition: background 0.1s;
}

.system-media-item:hover {
  background: var(--bg-hover);
}

.system-media-thumb {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 4px;
  border: 1px solid var(--border);
}

.system-media-name {
  flex: 1;
  font-size: 11px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-header {
  padding: 16px 16px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
}

.sidebar-actions {
  display: flex;
  gap: 6px;
}

.sidebar-header button {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: none;
  width: 28px;
  height: 28px;
  border-radius: 0;
  font-size: 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}

.sidebar-header button:hover {
  background: var(--border);
  color: var(--text-primary);
}

#new-file-btn {
  background: var(--accent);
  color: white;
}

#new-file-btn:hover {
  background: var(--accent-hover);
  color: white;
}

.file-tree {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  min-height: 100px;
}

.file-tree.drag-over {
  background: var(--accent-light);
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

/* Sidebar Footer - Generate Button */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}

.generate-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: white;
  border: none;
  padding: 12px 16px;
  border-radius: 0;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.generate-btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.generate-btn:active {
  transform: translateY(0);
}

.generate-icon {
  font-size: 16px;
}

/* Generate Modal Styles */
.modal-content.generate-modal-content {
  width: 1000px;
  max-width: 95%;
  max-height: 90vh;
  overflow: hidden;
  padding: 0;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
}

.generate-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.generate-modal-header h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 0;
  color: var(--text-primary);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close-btn:hover {
  color: var(--text-primary);
}

.generate-modal-body {
  display: flex;
  flex: 1;
  min-height: 500px;
  max-height: calc(90vh - 60px);
}

.generate-config {
  width: 320px;
  flex-shrink: 0;
  background: var(--bg-secondary);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
}

.generate-config .form-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.generate-config .form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.generate-config-footer {
  margin-top: auto;
  padding-top: 20px;
  display: flex;
  gap: 8px;
}

.generate-config-footer button {
  flex: 1;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 0;
  cursor: pointer;
  transition: all 0.15s;
}

.generate-config-footer button:not(.primary) {
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-secondary);
}

.generate-config-footer button:not(.primary):hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.generate-config-footer button.primary {
  background: var(--accent);
  color: white;
  border: none;
}

.generate-config-footer button.primary:hover {
  background: var(--accent-hover);
}

.generate-input {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.generate-input label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.generate-input textarea {
  flex: 1;
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 16px;
  font-size: 14px;
  line-height: 1.6;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.generate-input textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

.generate-input textarea::placeholder {
  color: var(--text-muted);
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-group label::before {
  display: none;
}

.platform-checkboxes {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.platform-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.platform-checkbox:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

.platform-checkbox:has(input:checked) {
  background: var(--accent-light);
  border-color: var(--accent);
}

.platform-checkbox input {
  display: none;
}

.platform-checkbox:has(input:checked) .checkbox-label::before {
  content: '✓  ';
  color: var(--accent);
  font-weight: 600;
}

.checkbox-label {
  font-size: 13px;
  color: var(--text-primary);
  user-select: none;
}

/* Image Paste Zone */
.image-paste-zone {
  min-height: 70px;
  background: var(--bg-primary);
  border: 1px dashed var(--border);
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}

.image-paste-zone:hover,
.image-paste-zone:focus-within {
  border-color: var(--accent);
  background: var(--accent-light);
}

.image-paste-zone.has-images {
  border-style: solid;
  min-height: auto;
}

.paste-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 4px;
  text-align: center;
}

.paste-icon {
  font-size: 18px;
  opacity: 0.6;
}

.paste-text {
  font-size: 12px;
  color: var(--text-secondary);
}

.paste-hint {
  font-size: 11px;
  color: var(--text-muted);
}

.image-paste-zone.has-images .paste-placeholder {
  display: none;
}

.pasted-images {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px;
}

.pasted-images:empty {
  display: none;
}

.pasted-image-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.pasted-image-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.pasted-image-item .remove-image {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 20px;
  height: 20px;
  background: rgba(0, 0, 0, 0.6);
  border: none;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s;
}

.pasted-image-item:hover .remove-image {
  opacity: 1;
}

.pasted-image-item .remove-image:hover {
  background: #ef4444;
}

.folder-input-wrapper {
  position: relative;
}

/* URL Input for Reference Links */
.url-input-wrapper {
  display: flex;
  gap: 6px;
}

.url-input-wrapper input {
  flex: 1;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 8px 10px;
  font-size: 12px;
  outline: none;
}

.url-input-wrapper input:focus {
  border-color: var(--accent);
}

.add-url-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.add-url-btn:hover {
  background: var(--accent-hover);
}

.reference-urls-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
  max-height: 120px;
  overflow-y: auto;
}

.reference-url-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  padding: 6px 10px;
  font-size: 11px;
}

.reference-url-item.loading {
  opacity: 0.7;
}

.reference-url-item.error {
  border-color: #ef4444;
  background: #fef2f2;
}

.reference-url-item .url-icon {
  flex-shrink: 0;
}

.reference-url-item .url-text {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

.reference-url-item .url-status {
  font-size: 10px;
  color: var(--text-muted);
}

.reference-url-item .url-status.success {
  color: var(--success);
}

.reference-url-item .url-status.error {
  color: #ef4444;
}

.reference-url-item .remove-url {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  font-size: 14px;
  line-height: 1;
}

.reference-url-item .remove-url:hover {
  color: #ef4444;
}

#generate-folder {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#generate-folder::placeholder {
  color: var(--text-muted);
}

#generate-folder:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}


.tree-item {
  cursor: pointer;
  user-select: none;
}

.tree-folder,
.tree-file {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  gap: 8px;
  font-size: 14px;
  transition: background 0.1s;
  color: var(--text-primary);
}

.tree-folder:hover,
.tree-file:hover {
  background: var(--bg-hover);
}

.tree-file.active {
  background: var(--accent-light);
  color: var(--accent-hover);
  font-weight: 500;
}

.tree-folder-icon,
.tree-file-icon {
  font-size: 16px;
  opacity: 0.7;
}

.tree-children {
  margin-left: 16px;
  display: none;
}

.tree-children.open {
  display: block;
}

/* Drag and Drop Styles */
.tree-folder[draggable="true"],
.tree-file[draggable="true"] {
  cursor: grab;
}

.tree-folder.dragging,
.tree-file.dragging {
  opacity: 0.4;
}

body.is-dragging .tree-folder:not(.dragging) {
  background: var(--accent-light);
}

body.is-dragging .tree-folder:not(.dragging):hover {
  background: #c7d7fe;
}

.tree-folder.drag-over,
.tree-children.drag-over,
.file-tree.drag-over {
  background: #c7d7fe !important;
  border-radius: 4px;
}

.tree-folder.drag-over {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.tree-children {
  min-height: 0;
}

.tree-children.open {
  min-height: 8px;
}

/* Rename Input */
.rename-input {
  background: var(--bg-primary);
  border: 1px solid var(--accent);
  color: var(--text-primary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  font-family: inherit;
  outline: none;
  width: calc(100% - 40px);
  max-width: 200px;
}

/* Main Content */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-secondary);
}

/* Toolbar */
.toolbar {
  height: var(--toolbar-height);
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
}

.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

#current-file {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 500;
}

#save-status {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 12px;
  font-weight: 500;
}

#save-status.unsaved {
  background: #fef3c7;
  color: #92400e;
}

#save-status.saved {
  background: #d1fae5;
  color: #065f46;
}

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

#save-btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

#save-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}

#save-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.view-toggle {
  display: flex;
  background: var(--bg-tertiary);
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--border);
}

.view-toggle button {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.view-toggle button:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.view-toggle button.active {
  background: var(--bg-primary);
  color: var(--text-primary);
  font-weight: 500;
  box-shadow: var(--shadow-sm);
}

/* Editor Container */
.editor-container {
  flex: 1;
  display: flex;
  overflow: hidden;
  margin: 16px;
  gap: 16px;
}

.editor-pane,
.preview-pane {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

#editor {
  flex: 1;
  width: 100%;
  background: var(--bg-primary);
  color: var(--text-primary);
  border: none;
  padding: 20px;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  outline: none;
  border-radius: 12px;
}

#editor::placeholder {
  color: var(--text-muted);
}

#editor.drag-highlight {
  background: var(--accent-light);
  border: 2px dashed var(--accent);
}

.preview-pane {
  position: relative;
}

/* Format Tabs */
.format-tabs {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  flex-shrink: 0;
  border-radius: 12px 12px 0 0;
}

.format-tab {
  background: transparent;
  color: var(--text-secondary);
  border: none;
  padding: 8px 14px;
  border-radius: 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.format-tab:hover {
  color: var(--text-primary);
  background: var(--bg-primary);
}

.format-tab.active {
  background: var(--accent);
  color: white;
}

.format-tab.loading {
  opacity: 0.7;
  cursor: wait;
}

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

/* Transform Loading */
.transform-loading {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  flex-direction: column;
  align-items: center;
  gap: 16px;
  color: var(--text-secondary);
}

.transform-loading.visible {
  display: flex;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Preview Actions Container */
.preview-actions-container {
  position: absolute;
  bottom: 16px;
  right: 16px;
  display: flex;
  gap: 8px;
}

#copy-btn,
#feedback-btn {
  background: var(--bg-primary);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  padding: 8px 14px;
  border-radius: 0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

#copy-btn:hover,
#feedback-btn:hover:not(:disabled) {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}

#copy-btn.copied {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

#feedback-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Feedback Modal Styles */
.feedback-modal-content {
  width: 500px;
}

.feedback-description {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

#feedback-input {
  width: 100%;
  min-height: 120px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  resize: vertical;
  outline: none;
}

#feedback-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

#feedback-input::placeholder {
  color: var(--text-muted);
}

/* Markdown Preview Styles */
.preview-content h1,
.preview-content h2,
.preview-content h3,
.preview-content h4,
.preview-content h5,
.preview-content h6 {
  margin-top: 24px;
  margin-bottom: 16px;
  font-weight: 600;
  line-height: 1.25;
  color: var(--text-primary);
}

.preview-content h1 { font-size: 2em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.preview-content h2 { font-size: 1.5em; border-bottom: 1px solid var(--border); padding-bottom: 0.3em; }
.preview-content h3 { font-size: 1.25em; }
.preview-content h4 { font-size: 1em; }

.preview-content p {
  margin-bottom: 16px;
  line-height: 1.7;
}

.preview-content a {
  color: var(--accent);
  text-decoration: none;
}

.preview-content a:hover {
  text-decoration: underline;
}

.preview-content ul,
.preview-content ol {
  margin-bottom: 16px;
  padding-left: 2em;
}

.preview-content li {
  margin-bottom: 4px;
  line-height: 1.6;
}

.preview-content blockquote {
  margin: 16px 0;
  padding: 0 1em;
  border-left: 4px solid var(--accent);
  color: var(--text-secondary);
}

.preview-content code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.9em;
}

.preview-content pre {
  background: var(--bg-tertiary);
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
}

.preview-content pre code {
  background: transparent;
  padding: 0;
}

.preview-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 24px 0;
}

.preview-content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 16px;
}

.preview-content th,
.preview-content td {
  border: 1px solid var(--border);
  padding: 8px 12px;
  text-align: left;
}

.preview-content th {
  background: var(--bg-tertiary);
  font-weight: 600;
}

.preview-content img {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

/* View Modes */
.editor-container.edit-mode .preview-pane {
  display: none;
}

.editor-container.preview-mode .editor-pane {
  display: none;
}

.editor-container.split-mode .editor-pane,
.editor-container.split-mode .preview-pane {
  flex: 1;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.open {
  display: flex;
}

/* Login Modal */
.login-modal {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(10px);
}

.login-modal-content {
  width: 380px;
  max-width: 90%;
  padding: 40px;
  text-align: center;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.login-header {
  margin-bottom: 28px;
}

.login-logo {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin-bottom: 12px;
}

.login-header p {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#login-password {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text-primary);
  font-size: 15px;
  text-align: center;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#login-password:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

#login-password::placeholder {
  color: var(--text-muted);
}

#login-form button {
  padding: 12px 20px;
  font-size: 15px;
  font-weight: 600;
  border-radius: 0;
  border: none;
  background: var(--accent);
  color: white;
  cursor: pointer;
  transition: all 0.15s;
}

#login-form button:hover {
  background: var(--accent-hover);
}

#login-form button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.login-error {
  color: #dc2626;
  font-size: 13px;
  min-height: 20px;
}

.modal-content {
  background: var(--bg-primary);
  padding: 24px;
  border-radius: 12px;
  width: 400px;
  max-width: 90%;
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  margin-bottom: 16px;
  color: var(--text-primary);
}

.modal-content input {
  width: 100%;
  background: var(--bg-primary);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 14px;
  outline: none;
}

.modal-content input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-light);
}

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

.modal-actions button {
  padding: 8px 16px;
  border-radius: 0;
  border: none;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.modal-actions button:not(.primary) {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.modal-actions button.primary {
  background: var(--accent);
  color: white;
}

.modal-actions button:hover {
  opacity: 0.9;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

/* ============================================
   PLATFORM-SPECIFIC PREVIEW STYLES
   ============================================ */

.platform-preview {
  max-width: 600px;
  margin: 0 auto;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* LinkedIn Preview */
.linkedin-preview {
  background: #ffffff;
  border-radius: 12px;
  border: 1px solid #e0e0e0;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.linkedin-header {
  display: flex;
  align-items: flex-start;
  padding: 16px 16px 12px;
  gap: 12px;
}

.linkedin-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0a66c2, #004182);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.linkedin-avatar-initials {
  color: white;
  font-weight: 700;
  font-size: 18px;
}

.linkedin-user-info {
  flex: 1;
}

.linkedin-name {
  font-weight: 600;
  color: #000000;
  font-size: 15px;
}

.linkedin-headline {
  color: #666666;
  font-size: 13px;
  margin-top: 2px;
}

.linkedin-content {
  padding: 0 16px 16px;
  color: #191919;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.linkedin-bottom-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  border-top: 1px solid #e8e8e8;
}

.linkedin-bottom-icon {
  background: none;
  border: none;
  color: #666666;
  padding: 8px;
  border-radius: 50%;
  cursor: pointer;
}

/* X/Twitter Preview */
.x-preview {
  background: #000000;
  border-radius: 16px;
  border: 1px solid #2f3336;
}

.x-thread {
  display: flex;
  flex-direction: column;
}

.x-tweet {
  padding: 12px 16px;
  border-bottom: 1px solid #2f3336;
  display: flex;
  gap: 12px;
}

.x-tweet:last-child {
  border-bottom: none;
}

.x-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d9bf0, #1a8cd8);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
}

.x-name {
  font-weight: 700;
  color: #e7e9ea;
  font-size: 15px;
}

.x-handle {
  color: #71767b;
  font-size: 15px;
}

.x-tweet-text {
  color: #e7e9ea;
  font-size: 15px;
  line-height: 1.4;
  white-space: pre-wrap;
}

/* Tweet Preview */
.tweet-preview {
  background: #000000;
  border-radius: 16px;
  border: 1px solid #2f3336;
  padding: 12px 16px;
}

.tweet-text {
  color: #e7e9ea;
  font-size: 23px;
  line-height: 1.3;
  white-space: pre-wrap;
  margin-bottom: 16px;
}

/* Substack Preview */
.substack-preview {
  background: #ffffff;
  border-radius: 4px;
  overflow: hidden;
  color: #000000;
}

.substack-header {
  padding: 24px 24px 0;
  border-bottom: 1px solid #e5e5e5;
}

.substack-title {
  font-size: 28px;
  font-weight: 700;
  color: #000000;
  font-family: 'Charter', 'Georgia', serif;
}

.substack-content {
  padding: 24px;
  font-family: 'Charter', 'Georgia', serif;
  font-size: 18px;
  line-height: 1.7;
  color: #1a1a1a;
  white-space: pre-wrap;
}

/* Blog Preview */
.blog-preview {
  background: #fff;
  border-radius: 8px;
  max-width: 720px;
  margin: 0 auto;
}

.blog-header {
  padding: 24px 0;
  border-bottom: 1px solid #eee;
  margin-bottom: 24px;
}

.blog-title {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  color: #111;
}

.blog-content {
  font-size: 17px;
  line-height: 1.7;
  color: #333;
}

.blog-content h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 28px 0 14px 0;
  color: #111;
}

.blog-content p {
  margin: 0 0 16px 0;
}

/* Media Preview */
.preview-media-container {
  margin: 12px 0;
  border-radius: 12px;
  overflow: hidden;
}

.preview-media {
  width: 100%;
  max-height: 400px;
  object-fit: cover;
  display: block;
}

.linkedin-media .preview-media {
  border-radius: 0;
  max-height: 350px;
}

.tweet-media {
  margin: 12px 0;
  border-radius: 16px;
  border: 1px solid #2f3336;
}
