/* CSS Variables for theming - Default Dark Theme */
:root {
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;

  /* Dark theme as default */
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-tertiary: #334155;
  --bg-modal: rgba(0, 0, 0, 0.8);

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #64748b;

  --border-color: #334155;
  --border-hover: #475569;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.4), 0 4px 6px -2px rgba(0, 0, 0, 0.3);

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;

  --transition: all 0.2s ease-in-out;
}

/* Light theme */
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --bg-modal: rgba(0, 0, 0, 0.5);

  --text-primary: #1e293b;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --border-color: #e2e8f0;
  --border-hover: #cbd5e1;

  /* Light theme shadows */
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

/* Light theme specific markdown adjustments */
[data-theme="light"] .memo-content.markdown::after {
  background: linear-gradient(transparent, var(--bg-primary));
}

[data-theme="light"] .markdown-content code,
[data-theme="light"] .memo-content.markdown code {
  background: var(--bg-tertiary);
  color: var(--primary-color);
}

[data-theme="light"] .markdown-content pre,
[data-theme="light"] .memo-content.markdown pre {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  line-height: 1.6;
  transition: var(--transition);
  overflow-x: hidden; /* Prevent horizontal scrolling */
  width: 100%;
  max-width: 100vw;
}

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

/* Header */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.header-content {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-sizing: border-box;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-icon {
  font-size: 1.5rem;
}

.logo h1 {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Search bar */
.search-bar {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem;
}

.search-bar > div {
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 0 1rem;
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  box-sizing: border-box;
}

.search-container {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input {
  width: 100%;
  padding: 0.75rem 2.5rem 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
}

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

.search-clear {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.25rem;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.search-clear:hover {
  color: var(--text-secondary);
  background: var(--bg-tertiary);
}

.filter-container {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.tag-filter {
  padding: 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
}

/* Main content */
.main {
  flex: 1;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
  padding: 2rem 1rem;
  display: grid;
  grid-template-columns: 250px 1fr;
  gap: 2rem;
  box-sizing: border-box;
  overflow-x: hidden; /* Prevent horizontal overflow */
}

/* Responsive main layout */
@media (min-width: 1600px) {
  .main {
    max-width: 1600px;
    padding: 2rem 2rem;
  }
}

@media (min-width: 1200px) and (max-width: 1599px) {
  .main {
    max-width: 1400px;
    padding: 2rem 1.5rem;
  }
}

@media (min-width: 992px) and (max-width: 1199px) {
  .main {
    max-width: 1200px;
    padding: 2rem 1rem;
    grid-template-columns: 220px 1fr;
    gap: 1.5rem;
  }
}

/* Sidebar */
.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.stats {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.stat-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.stat-item + .stat-item {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.stat-number {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--primary-color);
}

.stat-label {
  font-size: 0.875rem;
  color: var(--text-secondary);
}

.tags-section {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.tags-section h3 {
  margin-bottom: 1rem;
  font-size: 1rem;
  font-weight: 600;
}

.tags-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.tag-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: var(--transition);
}

.tag-item:hover {
  background: var(--bg-secondary);
}

.tag-info {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.tag-color {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.tag-name {
  font-size: 0.875rem;
}

.tag-delete {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  opacity: 0;
  transition: var(--transition);
}

.tag-item:hover .tag-delete {
  opacity: 1;
}

.tag-delete:hover {
  color: var(--error-color);
  background: rgba(239, 68, 68, 0.1);
}

/* Content area */
.content {
  min-height: 400px;
  width: 100%;
  overflow-x: hidden; /* Prevent horizontal overflow */
}

.memos-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start; /* Prevent cards from stretching to match tallest card */
}

/* Ensure consistent card sizing */
.memo-card {
  width: 100%;
  height: auto;
  min-height: 200px; /* Minimum height for consistency */
}

/* Desktop responsive breakpoints */
@media (min-width: 1600px) {
  .memos-grid {
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 2rem;
    max-width: none; /* Allow full width usage */
  }
}

@media (min-width: 1400px) and (max-width: 1599px) {
  .memos-grid {
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 2rem;
  }
}

@media (min-width: 1200px) and (max-width: 1399px) {
  .memos-grid {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
  }
}

@media (min-width: 992px) and (max-width: 1199px) {
  .memos-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
  }
}

@media (min-width: 769px) and (max-width: 991px) {
  .memos-grid {
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
  }
}

/* Tablet */
@media (max-width: 768px) {
  .memos-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
}

/* Mobile */
@media (max-width: 480px) {
  .memos-grid {
    gap: 0.75rem;
  }
}

/* Memo cards */
.memo-card {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  position: relative;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden; /* Prevent content overflow */
}

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

.memo-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 0.5rem;
  min-height: 1.5rem;
}

.memo-title {
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
  line-height: 1.4;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0; /* Allow flex item to shrink below content size */
}

.memo-actions {
  display: flex;
  gap: 0.25rem;
  opacity: 0.7;
  transition: var(--transition);
  flex-shrink: 0; /* Prevent buttons from shrinking */
}

.memo-card:hover .memo-actions {
  opacity: 1;
}

/* Always show actions on mobile */
@media (max-width: 768px) {
  .memo-actions {
    opacity: 1;
  }
}

.memo-action {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 0.375rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  transition: var(--transition);
  font-size: 0.875rem;
  min-width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.memo-action:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.memo-action.favorite {
  color: var(--warning-color);
  background: rgba(245, 158, 11, 0.1);
  border-color: var(--warning-color);
}

.memo-action.favorite:hover {
  background: var(--warning-color);
  color: white;
}

.memo-content {
  color: var(--text-secondary);
  font-size: 0.875rem;
  line-height: 1.6;
  margin-bottom: 1rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  flex: 1; /* Take up remaining space */
  overflow: hidden; /* Prevent overflow */
}

.memo-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto; /* Push footer to bottom */
  flex-shrink: 0; /* Prevent footer from shrinking */
}

.memo-tags {
  display: flex;
  gap: 0.25rem;
  flex-wrap: wrap;
}

.memo-tag {
  padding: 0.125rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 500;
  color: white;
}

.memo-date {
  white-space: nowrap;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-secondary);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.empty-state h3 {
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  border: none;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
}

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

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

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

.btn-outline:hover {
  background: var(--bg-secondary);
  border-color: var(--border-hover);
}

.btn-icon {
  padding: 0.5rem;
  background: transparent;
  color: var(--text-secondary);
}

.btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.75rem;
}

/* Modal styles */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-modal);
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal.active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease-out;
}

.modal-content {
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.2s ease-out;
}

.modal-small {
  max-width: 400px;
}

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

.modal-header h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.modal-body {
  padding: 1.5rem;
}

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 1.5rem;
}

/* Form styles */
.form-group {
  margin-bottom: 1.5rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group label .optional {
  font-weight: 400;
  color: var(--text-muted);
  font-size: 0.875rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  color: var(--text-primary);
  font-size: 0.875rem;
  transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-group textarea {
  resize: vertical;
  min-height: 120px;
}

/* Content Editor with Markdown support */
.content-editor {
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--bg-secondary);
}

.editor-tabs {
  display: flex;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
}

.editor-tab {
  flex: 1;
  padding: 0.75rem 1rem;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: var(--transition);
}

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

.editor-tab.active {
  background: var(--bg-secondary);
  color: var(--primary-color);
  font-weight: 500;
}

.editor-toolbar {
  display: flex;
  gap: 0.25rem;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-color);
  flex-wrap: wrap;
}

.toolbar-btn {
  padding: 0.375rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  min-width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.toolbar-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

.toolbar-btn strong,
.toolbar-btn em {
  font-size: 0.75rem;
}

.editor-content {
  position: relative;
}

.editor-content textarea {
  border: none;
  border-radius: 0;
  background: transparent;
  min-height: 200px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875rem;
  line-height: 1.6;
}

.editor-content textarea:focus {
  box-shadow: none;
}

.markdown-preview {
  padding: 0.75rem;
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  background: var(--bg-secondary);
  border-radius: 0;
}

.markdown-help {
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.markdown-help details {
  padding: 0.5rem 0.75rem;
}

.markdown-help summary {
  cursor: pointer;
  font-size: 0.75rem;
  color: var(--text-secondary);
  user-select: none;
}

.markdown-help summary:hover {
  color: var(--text-primary);
}

.markdown-syntax {
  margin-top: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  line-height: 1.4;
}

.markdown-syntax p {
  margin: 0.25rem 0;
  color: var(--text-secondary);
}

.markdown-syntax code {
  background: var(--bg-tertiary);
  padding: 0.125rem 0.25rem;
  border-radius: 2px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

/* Markdown content styles */
.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4,
.markdown-content h5,
.markdown-content h6 {
  margin: 1rem 0 0.5rem 0;
  font-weight: 600;
  line-height: 1.3;
  color: var(--text-primary);
}

.markdown-content h1 { font-size: 1.5rem; }
.markdown-content h2 { font-size: 1.25rem; }
.markdown-content h3 { font-size: 1.125rem; }
.markdown-content h4 { font-size: 1rem; }
.markdown-content h5 { font-size: 0.875rem; }
.markdown-content h6 { font-size: 0.75rem; }

.markdown-content p {
  margin: 0.75rem 0;
  line-height: 1.6;
}

.markdown-content strong {
  font-weight: 600;
  color: var(--text-primary);
}

.markdown-content em {
  font-style: italic;
}

.markdown-content code {
  background: var(--bg-tertiary);
  padding: 0.125rem 0.375rem;
  border-radius: var(--radius-sm);
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
  font-size: 0.875em;
  color: var(--primary-color);
}

.markdown-content pre {
  background: var(--bg-tertiary);
  padding: 1rem;
  border-radius: var(--radius-md);
  overflow-x: auto;
  margin: 1rem 0;
  border: 1px solid var(--border-color);
}

.markdown-content pre code {
  background: none;
  padding: 0;
  color: var(--text-primary);
}

.markdown-content blockquote {
  border-left: 4px solid var(--primary-color);
  padding-left: 1rem;
  margin: 1rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.markdown-content ul,
.markdown-content ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
}

.markdown-content li {
  margin: 0.25rem 0;
  line-height: 1.5;
}

.markdown-content a {
  color: var(--primary-color);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: var(--transition);
}

.markdown-content a:hover {
  border-bottom-color: var(--primary-color);
}

.markdown-content img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-md);
  margin: 0.5rem 0;
}

.markdown-content hr {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: 1.5rem 0;
}

.markdown-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.875rem;
}

.markdown-content th,
.markdown-content td {
  padding: 0.5rem;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
}

.markdown-content th {
  font-weight: 600;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Memo card markdown content */
.memo-content.markdown {
  font-size: 0.875rem;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto; /* Enable hyphenation for better text wrapping */
}

/* Ensure consistent spacing in markdown content */
.memo-content.markdown > *:first-child {
  margin-top: 0;
}

.memo-content.markdown > *:last-child {
  margin-bottom: 0;
}

.memo-content.markdown h1,
.memo-content.markdown h2,
.memo-content.markdown h3,
.memo-content.markdown h4,
.memo-content.markdown h5,
.memo-content.markdown h6 {
  font-size: 1rem;
  margin: 0.25rem 0;
  font-weight: 600;
  color: var(--text-primary);
}

.memo-content.markdown h1 { font-size: 1.125rem; }
.memo-content.markdown h2 { font-size: 1.0625rem; }
.memo-content.markdown h3 { font-size: 1rem; }

.memo-content.markdown p {
  margin: 0.25rem 0;
  color: var(--text-secondary);
}

.memo-content.markdown p:first-child {
  margin-top: 0;
}

.memo-content.markdown strong {
  color: var(--text-primary);
  font-weight: 600;
}

.memo-content.markdown em {
  font-style: italic;
}

.memo-content.markdown code {
  font-size: 0.75rem;
  padding: 0.125rem 0.25rem;
  background: var(--bg-tertiary);
  border-radius: 2px;
  font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
}

.memo-content.markdown .preview-code {
  color: var(--primary-color);
  font-style: italic;
}

.memo-content.markdown pre {
  background: var(--bg-tertiary);
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  margin: 0.5rem 0;
  font-size: 0.75rem;
  overflow: hidden;
}

.memo-content.markdown pre code {
  background: none;
  padding: 0;
}

.memo-content.markdown ul,
.memo-content.markdown ol {
  margin: 0.25rem 0;
  padding-left: 1rem;
}

.memo-content.markdown li {
  margin: 0.125rem 0;
  color: var(--text-secondary);
}

.memo-content.markdown blockquote {
  border-left: 2px solid var(--primary-color);
  padding-left: 0.5rem;
  margin: 0.25rem 0;
  color: var(--text-secondary);
  font-style: italic;
}

.memo-content.markdown a {
  color: var(--primary-color);
  text-decoration: none;
}

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

.memo-content.markdown hr {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: 0.5rem 0;
}

.memo-content.markdown img {
  max-width: 100%;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 0.25rem 0;
}

/* Mobile optimizations for markdown content */
@media (max-width: 768px) {
  .memo-content.markdown {
    font-size: 0.875rem;
  }

  .memo-content.markdown h1,
  .memo-content.markdown h2,
  .memo-content.markdown h3 {
    font-size: 1rem;
    margin: 0.5rem 0 0.25rem 0;
  }

  .memo-content.markdown pre {
    padding: 0.75rem;
    font-size: 0.75rem;
    overflow-x: auto;
  }

  .memo-content.markdown code {
    font-size: 0.75rem;
  }

  .memo-content.markdown ul,
  .memo-content.markdown ol {
    padding-left: 1.25rem;
  }
}

/* Checkbox styles */
.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  margin-bottom: 0 !important;
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkmark {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  position: relative;
  transition: var(--transition);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark {
  background: var(--primary-color);
  border-color: var(--primary-color);
}

.checkbox-label input[type="checkbox"]:checked + .checkmark::after {
  content: '✓';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: white;
  font-size: 12px;
  font-weight: bold;
}

/* Tags input */
.tags-input-container {
  position: relative;
}

.available-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.available-tag {
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  border: 1px solid var(--border-color);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.available-tag:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

/* Color picker */
.color-picker {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.color-picker input[type="color"] {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.color-presets {
  display: flex;
  gap: 0.5rem;
}

.color-preset {
  width: 24px;
  height: 24px;
  border: 2px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: var(--transition);
}

.color-preset:hover {
  border-color: var(--text-muted);
  transform: scale(1.1);
}

/* Loading spinner */
.loading {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.loading.active {
  display: flex;
}

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

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  padding: 0.75rem 1rem;
  border-radius: var(--radius-md);
  color: white;
  font-size: 0.875rem;
  box-shadow: var(--shadow-lg);
  animation: slideInRight 0.3s ease-out;
  max-width: 300px;
}

.toast.success {
  background: var(--success-color);
}

.toast.error {
  background: var(--error-color);
}

.toast.warning {
  background: var(--warning-color);
}

.toast.info {
  background: var(--primary-color);
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Theme toggle */
.theme-icon {
  transition: var(--transition);
}

[data-theme="light"] .theme-icon {
  transform: rotate(180deg);
}

/* Responsive design */
@media (max-width: 768px) {
  .main {
    grid-template-columns: 1fr;
    gap: 1rem;
    padding: 0.5rem;
    max-width: 100%;
  }

  .sidebar {
    order: 2;
  }

  .content {
    order: 1;
  }

  .search-bar {
    padding: 0.5rem;
  }

  .search-bar > div {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
    padding: 0 0.5rem;
  }

  .filter-container {
    justify-content: space-between;
  }

  .modal-content {
    width: 95%;
    margin: 0.5rem;
    max-height: 95vh;
  }

  .modal-actions {
    flex-direction: column-reverse;
  }

  .header-actions {
    gap: 0.25rem;
    flex-wrap: wrap;
  }

  .btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
  }

  .header-content {
    padding: 0 0.5rem;
  }

  .logo h1 {
    font-size: 1.25rem;
  }

  .stats {
    padding: 1rem;
  }

  .tags-section {
    padding: 1rem;
  }
}

/* Small mobile devices */
@media (max-width: 480px) {
  .main {
    padding: 0.25rem;
  }

  .memo-card {
    padding: 1rem;
  }

  .memo-action {
    min-width: 36px;
    height: 36px;
    font-size: 1rem;
    padding: 0.5rem;
  }

  .memo-header {
    gap: 0.75rem;
  }

  .header-content {
    flex-direction: column;
    gap: 0.5rem;
    align-items: stretch;
  }

  .header-actions {
    justify-content: center;
  }

  .search-container {
    min-width: auto;
  }

  .modal-content {
    width: 98%;
    margin: 0.25rem;
  }
}
