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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex;
  height: 100vh;
  background: #f0f2f5;
  color: #333;
}

/* Sidebar */
.sidebar {
  width: 280px;
  background: #1a1a2e;
  color: #fff;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.btn-create {
  margin: 16px 20px 8px;
  padding: 10px;
  background: #4361ee;
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.btn-create:hover {
  background: #3a56d4;
}

.search-box {
  padding: 8px 20px;
}

.search-box input {
  width: 100%;
  padding: 8px 12px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  color: #fff;
  font-size: 13px;
  outline: none;
}

.search-box input::placeholder {
  color: rgba(255,255,255,0.4);
}

.search-box input:focus {
  border-color: #4361ee;
}

.note-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.note-item {
  padding: 12px 20px;
  cursor: pointer;
  border-left: 3px solid transparent;
  transition: all 0.15s;
}

.note-item:hover {
  background: rgba(255,255,255,0.05);
}

.note-item.active {
  background: rgba(67, 97, 238, 0.15);
  border-left-color: #4361ee;
}

.note-item-title {
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-preview {
  font-size: 12px;
  color: rgba(255,255,255,0.5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.note-item-time {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  margin-top: 4px;
}

/* Editor Area */
.editor-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Toolbar */
.toolbar {
  display: flex;
  align-items: center;
  padding: 6px 12px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
  flex-wrap: wrap;
  gap: 2px;
}

.toolbar-group {
  display: flex;
  align-items: center;
  gap: 2px;
}

.toolbar-divider {
  width: 1px;
  height: 24px;
  background: #e0e0e0;
  margin: 0 6px;
}

.toolbar button {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #555;
  font-size: 14px;
  transition: all 0.15s;
}

.toolbar button:hover {
  background: #e8eaed;
  color: #333;
}

/* Save Dropdown */
.save-dropdown-wrap {
  position: relative;
}

.save-dropdown-wrap > button {
  display: flex;
  align-items: center;
}

.save-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  z-index: 50;
  min-width: 180px;
  padding: 4px 0;
  margin-top: 4px;
}

.save-dropdown.open {
  display: block;
}

.save-dropdown button {
  width: 100% !important;
  height: auto !important;
  padding: 8px 14px !important;
  text-align: left;
  justify-content: flex-start !important;
  font-size: 13px;
  border-radius: 0 !important;
  color: #333 !important;
}

.save-dropdown button:hover {
  background: #f0f4ff !important;
  color: #4361ee !important;
}

.toolbar select {
  padding: 4px 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 13px;
  background: #fff;
  color: #555;
  outline: none;
  cursor: pointer;
}

.toolbar select:hover {
  border-color: #bbb;
}

/* Note Title */
.note-title-bar {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  background: #fff;
  border-bottom: 1px solid #e0e0e0;
}

.note-title-bar input {
  flex: 1;
  border: none;
  font-size: 18px;
  font-weight: 500;
  outline: none;
  color: #333;
  background: transparent;
}

.btn-delete {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
  transition: all 0.15s;
}

.btn-delete:hover {
  background: #fee2e2;
  color: #ef4444;
}

/* Editor */
.editor-wrapper {
  flex: 1;
  overflow: auto;
  background: #fff;
}

#editor {
  min-height: 100%;
  padding: 20px 24px;
  font-size: 15px;
  line-height: 1.7;
  outline: none;
  color: #333;
}

#editor:empty::before {
  content: 'Start typing your note...';
  color: #bbb;
}

/* Status Bar */
.status-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 6px 16px;
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
  font-size: 12px;
  color: #888;
}

#saveStatus {
  margin-left: auto;
}

/* Find & Replace Dialog */
.dialog-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.dialog {
  background: #fff;
  border-radius: 12px;
  width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
}

.dialog-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.dialog-close {
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  font-size: 20px;
  cursor: pointer;
  border-radius: 4px;
  color: #888;
}

.dialog-close:hover {
  background: #f0f0f0;
}

.dialog-body {
  padding: 16px 20px;
}

.dialog-body label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
  color: #555;
}

.dialog-body input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
}

.dialog-body input:focus {
  border-color: #4361ee;
  box-shadow: 0 0 0 3px rgba(67,97,238,0.1);
}

.dialog-footer {
  display: flex;
  gap: 8px;
  padding: 12px 20px 16px;
  justify-content: flex-end;
}

.dialog-footer button {
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}

.dialog-footer button:hover {
  background: #f5f5f5;
}

.dialog-footer button:first-child {
  background: #4361ee;
  color: #fff;
  border-color: #4361ee;
}

.dialog-footer button:first-child:hover {
  background: #3a56d4;
}

/* Scrollbar */
.note-list::-webkit-scrollbar,
.editor-wrapper::-webkit-scrollbar {
  width: 6px;
}

.note-list::-webkit-scrollbar-thumb,
.editor-wrapper::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}

/* Print */
@media print {
  .sidebar, .toolbar, .note-title-bar, .status-bar {
    display: none !important;
  }
  .editor-area {
    position: static;
  }
  .editor-wrapper {
    overflow: visible;
  }
  #editor {
    padding: 0;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 240px;
    position: fixed;
    left: -240px;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: left 0.3s;
  }
  .sidebar.open {
    left: 0;
  }
}
