* {
  box-sizing: border-box;
  transition: background 0.2s ease;
}

:root {
  --vh: 1vh;
}

body {
  margin: 0;
  background: #0d0f12;
  color: #e6e6eb;
  font-family: system-ui, -apple-system, sans-serif;
  height: calc(var(--vh) * 100);
  overflow: hidden;
  touch-action: manipulation;
}

.topbar {
  height: 56px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid #1f2937;
  background: #0d0f12;
  z-index: 100;
}

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

button {
  background: #1f2937;
  color: #e6e6eb;
  border: 1px solid #374151;
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 11px;
  /* Slightly smaller buttons */
  cursor: pointer;
}

.primary-btn {
  background: #2563eb;
  border: none;
  font-weight: 600;
}

.layout {
  display: flex;
  height: calc(calc(var(--vh) * 100) - 56px);
}

.sidebar {
  width: 250px;
  border-right: 1px solid #1f2937;
  padding: 10px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Prevent sidebar itself from scrolling */
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
  width: 0;
  padding: 0;
  border-right: none;
}


#notesList {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 10px;
}

.note {
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  /* Reduced from 14px */
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  user-select: none;
}

.note.active {
  background: #1f2937;
  border: 1px solid #374151;
  color: white;
}

.archive-divider {
  margin: 16px 0 6px;
  font-size: 10px;
  color: #6b7280;
  text-transform: uppercase;
  padding-left: 8px;
  display: flex;
  align-items: center;
}

#archiveArrow {
  display: inline-block;
  transition: transform 0.2s ease;
  margin-right: 6px;
  font-size: 7px;
}

.archive-divider.expanded #archiveArrow {
  transform: rotate(90deg);
}

#archivedNotesList {
  overflow-y: auto;
  max-height: 40%;
  /* Limit archive height so it doesn't takeover */
  flex-shrink: 0;
}

#archivedNotesList.collapsed {
  display: none;
}

.editor {
  position: relative;
  flex: 1;
  padding: 20px;
  max-width: 980px;
  /* Slightly wider as requested */
  margin: 0 auto;
  display: flex;
  flex-direction: column;
}

#noteTitle {
  width: 100%;
  background: transparent;
  border: none;
  color: #e6e6eb;
  font-size: 24px;
  font-weight: 600;
  padding: 10px 0;
  margin-bottom: 10px;
  outline: none;
}

#noteTitle::placeholder {
  color: #4b5563;
}

.editor-content {
  width: 100%;
  flex: 1;
  background: #14171c;
  border: 1px solid #22262d;
  color: #e6e6eb;
  padding: 16px;
  border-radius: 10px;
  font-size: 14px;
  /* Reduced from 15px */
  line-height: 1.6;
  outline: none;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  white-space: pre-wrap;
  word-break: break-word;
}

.editor-content h2 {
  font-size: 20px;
  font-weight: 700;
  margin: 24px 0 12px 0;
  color: #e6e6eb;
}

.editor-content h3 {
  font-size: 17px;
  font-weight: 600;
  margin: 20px 0 10px 0;
  color: #e6e6eb;
}

.editor-content a {
  color: #3b82f6;
  text-decoration: underline;
  cursor: pointer;
}

.editor-content:empty:before {
  content: attr(placeholder);
  color: #6b7280;
}

.editor-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 4px 0;
}

.action-btn {
  background: rgba(31, 41, 55, 0.6);
  padding: 6px 10px;
  font-size: 9px;
}

.stats {
  display: flex;
  gap: 12px;
  font-size: 11px;
  color: #6b7280;
}

#versionsPanel {
  position: absolute;
  bottom: 60px;
  left: 20px;
  width: 200px;
  background: #16191d;
  border: 1px solid #374151;
  padding: 10px;
  border-radius: 8px;
  z-index: 100;
  box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.5);
}

#versionsPanel button {
  display: block;
  width: 100%;
  margin-top: 4px;
  text-align: left;
  font-size: 10px;
}

.save-indicator {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #374151;
}

.save-indicator.active {
  background: #22c55e;
  box-shadow: 0 0 6px #22c55e;
}

.actions-left {
  display: flex;
  gap: 8px;
}

/* Link Popup */
.popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  z-index: 1000;
  backdrop-filter: blur(2px);
}

.popup-overlay[hidden] {
  display: none !important;
}

.popup-content {
  background: #16191d;
  border: 1px solid #374151;
  padding: 20px;
  border-radius: 10px;
  width: 320px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.popup-content h3 {
  margin: 0 0 15px 0;
  font-size: 14px;
  color: #e6e6eb;
}

.input-group {
  margin-bottom: 12px;
}

.input-group label {
  display: block;
  font-size: 11px;
  color: #9ca3af;
  margin-bottom: 4px;
}

.input-group input {
  width: 100%;
  background: #0d0f12;
  border: 1px solid #374151;
  color: #e6e6eb;
  padding: 8px;
  border-radius: 6px;
  font-size: 13px;
  outline: none;
}

.input-group input:focus {
  border-color: #2563eb;
}

.input-group input:disabled {
  background: #1f2937;
  color: #9ca3af;
  cursor: not-allowed;
}

.popup-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

.popup-actions button {
  padding: 6px 14px;
}